diff --git a/GUIWidgets/VTKWidgets/vtkSlicerQWidgetRepresentation.cxx b/GUIWidgets/VTKWidgets/vtkSlicerQWidgetRepresentation.cxx index 8cd7697..a034987 100644 --- a/GUIWidgets/VTKWidgets/vtkSlicerQWidgetRepresentation.cxx +++ b/GUIWidgets/VTKWidgets/vtkSlicerQWidgetRepresentation.cxx @@ -270,5 +270,8 @@ void vtkSlicerQWidgetRepresentation::OnTextureModified( self->PlaceWidget(bounds); // Trigger rendering in view - self->GetViewNode()->Modified(); + if (self->GetViewNode()->GetSelectable()) + { + self->GetViewNode()->Modified(); + } } diff --git a/GUIWidgets/VTKWidgets/vtkSlicerQWidgetWidget.cxx b/GUIWidgets/VTKWidgets/vtkSlicerQWidgetWidget.cxx index 206369e..0cd25dd 100644 --- a/GUIWidgets/VTKWidgets/vtkSlicerQWidgetWidget.cxx +++ b/GUIWidgets/VTKWidgets/vtkSlicerQWidgetWidget.cxx @@ -87,12 +87,16 @@ vtkSlicerMarkupsWidget* vtkSlicerQWidgetWidget::CreateInstance()const void vtkSlicerQWidgetWidget::CreateDefaultRepresentation( vtkMRMLMarkupsDisplayNode* markupsDisplayNode, vtkMRMLAbstractViewNode* viewNode, vtkRenderer* renderer) { + //if (!viewNode->IsA("vtkMRMLVirtualRealityViewNode")) if (vtkMRMLSliceNode::SafeDownCast(viewNode)) { // There is no 2D representation of the GUI widget return; } + bool wasSelectable = viewNode->GetSelectable(); + viewNode->SetSelectable(false); // Workaround to disable texture updates until setup is completed + vtkNew rep; this->SetRenderer(renderer); this->SetRepresentation(rep); @@ -100,6 +104,8 @@ void vtkSlicerQWidgetWidget::CreateDefaultRepresentation( rep->SetViewNode(viewNode); rep->UpdateFromMRML(nullptr, 0); // full update + + viewNode->SetSelectable(wasSelectable); } //------------------------------------------------------------------------------ diff --git a/GUIWidgets/VTKWidgets/vtkSlicerQWidgetWidget.h b/GUIWidgets/VTKWidgets/vtkSlicerQWidgetWidget.h index 304a15d..768a6cc 100644 --- a/GUIWidgets/VTKWidgets/vtkSlicerQWidgetWidget.h +++ b/GUIWidgets/VTKWidgets/vtkSlicerQWidgetWidget.h @@ -76,6 +76,9 @@ class VTK_SLICER_GUIWIDGETS_MODULE_VTKWIDGETS_EXPORT vtkSlicerQWidgetWidget : pu void CreateDefaultRepresentation( vtkMRMLMarkupsDisplayNode* markupsDisplayNode, vtkMRMLAbstractViewNode* viewNode, vtkRenderer* renderer) override; +protected: + QPointF LastWidgetCoordinates; + protected: vtkSlicerQWidgetWidget(); ~vtkSlicerQWidgetWidget() override; @@ -88,7 +91,6 @@ class VTK_SLICER_GUIWIDGETS_MODULE_VTKWIDGETS_EXPORT vtkSlicerQWidgetWidget : pu Active }; */ - QPointF LastWidgetCoordinates; // These methods handle events //static void SelectAction3D(vtkAbstractWidget*); diff --git a/VirtualReality/Widgets/qMRMLVirtualRealityView.cxx b/VirtualReality/Widgets/qMRMLVirtualRealityView.cxx index 294aadc..e7af3a8 100644 --- a/VirtualReality/Widgets/qMRMLVirtualRealityView.cxx +++ b/VirtualReality/Widgets/qMRMLVirtualRealityView.cxx @@ -334,11 +334,14 @@ void qMRMLVirtualRealityViewPrivate::updateWidgetFromMRML() this->Renderer->SetTwoSidedLighting(this->MRMLVirtualRealityViewNode->GetTwoSidedLighting()); - bool switchOnAllLights = this->MRMLVirtualRealityViewNode->GetBackLights(); - for (int i = 2; i < this->Lights->GetNumberOfItems(); i++) + if (this->Lights) { - vtkLight* light = vtkLight::SafeDownCast(this->Lights->GetItemAsObject(i)); - light->SetSwitch(switchOnAllLights); + bool switchOnAllLights = this->MRMLVirtualRealityViewNode->GetBackLights(); + for (int i = 2; i < this->Lights->GetNumberOfItems(); i++) + { + vtkLight* light = vtkLight::SafeDownCast(this->Lights->GetItemAsObject(i)); + light->SetSwitch(switchOnAllLights); + } } this->Renderer->SetUseDepthPeeling(this->MRMLVirtualRealityViewNode->GetUseDepthPeeling() != 0);