jspanchu / vtkdearimguiinjector Goto Github PK
View Code? Open in Web Editor NEWInject DearImGUI into an existing VTK application. ๐
Home Page: https://jspanchu.dev/vtkDearImGUIInjector/
License: MIT License
Inject DearImGUI into an existing VTK application. ๐
Home Page: https://jspanchu.dev/vtkDearImGUIInjector/
License: MIT License
Clicking area A can capture vtkCommand::LeftButtonReleaseEvent, but clicking area B cannot capture it.
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;
}
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?
I found this amazing project and wonder how i can intergrate it into my person qt5.9-vtk9.2.5 based project,Could you giving me some instructions for doing so?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.