Giter Club home page Giter Club logo

vtkdearimguiinjector's People

Contributors

harold2017 avatar jspanchu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vtkdearimguiinjector's Issues

Unable to catch vtkCommand::LeftButtonReleaseEvent

Clicking area A can capture vtkCommand::LeftButtonReleaseEvent, but clicking area B cannot capture it.
Snipaste_2023-11-21_14-48-50
code show as below:

class MyCallback : public vtkCommand
{
public:
    MyCallback() = default;
    ~MyCallback() = default;

    static MyCallback* New()
    {
        return new MyCallback;
    }

    void Execute(vtkObject* caller, unsigned long eventId,
        void* vtkNotUsed(callData)) override
    {
        if (vtkCommand::LeftButtonPressEvent == eventId)
        {
            std::cout << "LeftButtonPressEvent" << std::endl;
        }
        else if (vtkCommand::MouseMoveEvent == eventId)
        {
            std::cout << "MouseMoveEvent" << std::endl;

        }
        else if (vtkCommand::LeftButtonReleaseEvent == eventId)
        {
            std::cout << "LeftButtonReleaseEvent" << std::endl;
        }
    }
};

//------------------------------------------------------------------------------
// Main
//------------------------------------------------------------------------------

int main(int argc, char* argv[])
{
  // Create a renderer, render window, and interactor
  vtkNew<vtkRenderer> renderer;
  vtkNew<vtkRenderWindow> renderWindow;
  vtkNew<vtkRenderWindowInteractor> iren;
  renderWindow->SetMultiSamples(8);
  renderWindow->AddRenderer(renderer);
  iren->SetRenderWindow(renderWindow);

  // Create pipeline
  vtkNew<vtkConeSource> coneSource;
  coneSource->Update();

  vtkNew<vtkPolyDataMapper> mapper;
  mapper->SetInputConnection(coneSource->GetOutputPort());

  vtkNew<vtkActor> actor;
  actor->SetMapper(mapper);

  // Add the actors to the scene
  renderer->AddActor(actor);

  // Start rendering app
  renderer->SetBackground(0.2, 0.3, 0.4);
  renderWindow->Render();

  /// Change to your code begins here. ///
  // Initialize an overlay with DearImgui elements.
  vtkNew<vtkDearImGuiInjector> dearImGuiOverlay;
  // ๐Ÿ’‰ the overlay.
  dearImGuiOverlay->Inject(iren);
  // These functions add callbacks to ImGuiSetupEvent and ImGuiDrawEvents.
  SetupUI(dearImGuiOverlay);
  // You can draw custom user interface elements using ImGui:: namespace.
  DrawUI(dearImGuiOverlay);
  /// Change to your code ends here. ///

  vtkNew<vtkCameraOrientationWidget> camManipulator;
  camManipulator->SetParentRenderer(renderer);
  camManipulator->On();
  auto rep = vtkCameraOrientationRepresentation::SafeDownCast(camManipulator->GetRepresentation());
  rep->AnchorToLowerRight();

  // Start event loop
  renderWindow->SetSize(1920, 1000);
  vtkInteractorStyleSwitch::SafeDownCast(iren->GetInteractorStyle())->SetCurrentStyleToTrackballCamera();
  iren->EnableRenderOff();
  vtkNew<MyCallback> cb;
  iren->AddObserver(vtkCommand::LeftButtonPressEvent, cb);
  iren->AddObserver(vtkCommand::MouseMoveEvent, cb);
  iren->AddObserver(vtkCommand::LeftButtonReleaseEvent, cb);
  iren->Start();

  return 0;
}

Can multiple vtkRenderWindow be displayed?

I need to display 4 vtkRenderWindow, respectively displaying the MPR slice and VR. Using Qt, I only need to put 4 QVTKOpenGLNativeWidgets in the layout and put the vtkRenderWindow inside. I want to know if multiple vtkRenderWindow can be displayed at the same time using vtkDearImGUIInjector?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.