Parcourir la source

vtkLightBoxRendererManager - Fix warning related to missing active camera

This issue was occurring after (1) adding a markup and (2) registering
a custom Slicer layout having at least on Slice view.

It addresses the following warning:

  WorldToView: no active camera, cannot compute world to view, returning 0,0,0

The "no active camera" warning/issue is also discussed in Slicer issue
#1690 but note that this commit does NOT address that problem.
Jean-Christophe Fillion-Robin il y a 10 ans
Parent
commit
722dd7935a
1 fichiers modifiés avec 6 ajouts et 0 suppressions
  1. 6 0
      Libs/Visualization/VTK/Core/vtkLightBoxRendererManager.cpp

+ 6 - 0
Libs/Visualization/VTK/Core/vtkLightBoxRendererManager.cpp

@@ -94,6 +94,11 @@ RenderWindowItem::RenderWindowItem(const double rendererBackgroundColor[3],
                                 rendererBackgroundColor[1],
                                 rendererBackgroundColor[2]);
 
+  // Ensure a vtkCamera is created and associated with the renderer
+  // This is particularly important to ensure WorldToView/ViewToWorld
+  // work as expected.
+  this->Renderer->GetActiveCamera();
+
   this->SetupImageMapperActor(colorWindow, colorLevel);
   this->SetupHighlightedBoxActor(highlightedBoxColor);
 }
@@ -669,6 +674,7 @@ void vtkLightBoxRendererManager::SetRenderWindowLayout(int rowCount, int columnC
     return;
     }
 
+
   if (this->Internal->RenderWindowRowCount == rowCount && 
       this->Internal->RenderWindowColumnCount == columnCount)
     {