Skip to content
Snippets Groups Projects
Commit 7b9b5153 authored by Alexis Girault's avatar Alexis Girault
Browse files

BUG: allow DisableMouseInteraction in LaparoscopicCamera

In the LaparoscopicCamera example the mouse interaction
was supposed to be disabled, but by setting the new
interactor style after the viewer initialization, the
observers rules on the vtkViewer interactor were
overridden. Placing the interactorStyle beforehand
resolves the issue.

In the future it would be convenient to have wrapped
functions in IMSTK to make changes to the interactor
without the need to go through VTK.
parent ea0c6cbb
No related branches found
No related tags found
No related merge requests found
...@@ -410,33 +410,35 @@ int main() ...@@ -410,33 +410,35 @@ int main()
//------------------------------------------------------- //-------------------------------------------------------
// Set up the scene // Set up the scene
//------------------------------------------------------- //-------------------------------------------------------
std::shared_ptr<Scene> scene = sdk->getScene(0); std::shared_ptr<Scene> scene = sdk->getScene(0);
viewer->registerScene(scene, SMRENDERTARGET_SCREEN, "Collision pipeline demo"); viewer->registerScene(scene, SMRENDERTARGET_SCREEN, "Collision pipeline demo");
// Create camera navigation scene // Create camera navigation scene
createCameraNavigationScene(scene, "./CameraNavAppData/target.png"); createCameraNavigationScene(scene, "./CameraNavAppData/target.png");
// Initialize viewer with scene objects
// NOTE : Needs to be done before VTK Add ons since
// init create the needed renderer in the VTKView
viewer->init();
//------------------------------------------------------- //-------------------------------------------------------
// Add ons (VTK)
//-------------------------------------------------------
// Enable screenshot capture // Enable screenshot capture
//-------------------------------------------------------
// NOTE : Needs to be done before the viewer initialisation
// not to erase the changes on the observers made to the
// interactor in vtkViewer::addRenderer()
vtkNew<ScreenCaptureInteractorStyle> style; vtkNew<ScreenCaptureInteractorStyle> style;
style->initialize(vtkViewer->getRenderWindow()); style->initialize(vtkViewer->getRenderWindow());
vtkViewer->getVtkRenderWindowInteractor()->SetInteractorStyle(style.GetPointer()); vtkViewer->getVtkRenderWindowInteractor()->SetInteractorStyle(style.GetPointer());
style->SetCurrentRenderer(vtkViewer->getVtkRenderer()); style->SetCurrentRenderer(vtkViewer->getVtkRenderer());
//-------------------------------------------------------
// Initialize viewer with scene objects
//-------------------------------------------------------
// NOTE : Needs to be done before VTK Add ons since
// init create the needed renderer in the VTKViewer
viewer->init();
//-------------------------------------------------------
// Add ons (VTK)
//-------------------------------------------------------
// Add a camera controller // Add a camera controller
// NOTE: This has to come after the ScreenCaptureInteractorStyle initialization addCameraController(sdk);
// since for this to work the mouse events need disabled which are
// left as is after ScreenCaptureInteractorStyle initialization
std::shared_ptr<LaparoscopicCameraController> camController = addCameraController(sdk);
// Add a 2D overlay on the 3D scene // Add a 2D overlay on the 3D scene
add2DOverlay(vtkViewer,"./CameraNavAppData/viewfinder.png"); add2DOverlay(vtkViewer,"./CameraNavAppData/viewfinder.png");
...@@ -444,7 +446,6 @@ int main() ...@@ -444,7 +446,6 @@ int main()
//------------------------------------------------------- //-------------------------------------------------------
// Start // Start
//------------------------------------------------------- //-------------------------------------------------------
// Run the SDK // Run the SDK
sdk->run(); sdk->run();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment