Skip to content

Commit

Permalink
BUG: Skip creation of markups and transform interaction widget in VR …
Browse files Browse the repository at this point in the history
…window

The interaction renderer instantiated in `vtkMRMLMarkupsDisplayableManager::Create()`
or `vtkMRMLLinearTransformsDisplayableManager::vtkInternal::SetupRenderer()`
is not supported in VR.

Follow-up of Slicer/Slicer@4efda83181 (`ENH: Add interaction handle visualization
for linear transform nodes (Slicer#7562)`, 2024-02-02)
  • Loading branch information
jcfr committed Feb 29, 2024
1 parent 50446f2 commit 1dd8730
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Expand Up @@ -971,6 +971,14 @@ void vtkMRMLMarkupsDisplayableManager::Create()

vtkRenderer* renderer = this->GetRenderer();
vtkRenderWindow* renderWindow = renderer->GetRenderWindow();

// Do not add add the interaction widget if the displayable manager is associated with a VR render
// window. The interaction renderer instantiated below is not supported in VR.
if (renderWindow->IsA("vtkVRRenderWindow"))
{
return;
}

if (renderWindow->GetNumberOfLayers() < INTERACTION_RENDERER_LAYER + 1)
{
renderWindow->SetNumberOfLayers(INTERACTION_RENDERER_LAYER + 1);
Expand Down
Expand Up @@ -30,6 +30,8 @@
#include <vtkObjectFactory.h>
#include <vtkProperty.h>
#include <vtkPickingManager.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSlicerMarkupsWidgetRepresentation.h>
#include <vtkSlicerMarkupsWidget.h>
Expand Down Expand Up @@ -310,6 +312,14 @@ void vtkMRMLMarkupsDisplayableManagerHelper::AddInteractionWidget(vtkMRMLMarkups
{
return;
}
// Do not add add the interaction widget if the displayable manager is associated with a VR render
// window. The interaction renderer instantiated in vtkMRMLMarkupsDisplayableManager::Create() is
// not supported in VR.
if (this->DisplayableManager->GetRenderer()->GetRenderWindow()->IsA("vtkVRRenderWindow"))
{
return;
}

// Do not add the display node if displayNodeIt is already associated with a widget object.
// This happens when a segmentation node already associated with a display node
// is copied into an other (using vtkMRMLNode::Copy()) and is added to the scene afterward.
Expand Down
Expand Up @@ -134,9 +134,13 @@ void vtkMRMLLinearTransformsDisplayableManager::vtkInternal::UpdatePipelineFromD
return;
}

// Do not add add the interaction widget if the displayable manager is associated with a VR render
// window. The interaction renderer instantiated below is not supported in VR.

vtkMRMLTransformNode* transformNode = vtkMRMLTransformNode::SafeDownCast(displayNode->GetDisplayableNode());
bool visible = this->UseTransformNode(transformNode)
&& this->UseDisplayNode(displayNode);
&& this->UseDisplayNode(displayNode)
&& !this->External->GetRenderer()->GetRenderWindow()->IsA("vtkVRRenderWindow");

vtkSmartPointer<vtkMRMLTransformHandleWidget> widget;
InteractionWidgetsCacheType::iterator pipelineIt;
Expand Down Expand Up @@ -480,6 +484,14 @@ void vtkMRMLLinearTransformsDisplayableManager::vtkInternal::SetupRenderer()
}

vtkRenderWindow* renderWindow = renderer->GetRenderWindow();

// Do not add add the interaction widget if the displayable manager is associated with a VR render
// window. The interaction renderer instantiated below is not supported in VR.
if (renderWindow->IsA("vtkVRRenderWindow"))
{
return;
}

if (renderWindow->GetNumberOfLayers() < RENDERER_LAYER + 1)
{
renderWindow->SetNumberOfLayers(RENDERER_LAYER + 1);
Expand Down

0 comments on commit 1dd8730

Please sign in to comment.