Explorar o código

vtkLightBoxRendererManager - Default highlightedbox color is properly set

Jean-Christophe Fillion-Robin %!s(int64=14) %!d(string=hai) anos
pai
achega
3bc8fa3c6c
Modificáronse 1 ficheiros con 15 adicións e 11 borrados
  1. 15 11
      Libs/Visualization/VTK/Core/vtkLightBoxRendererManager.cpp

+ 15 - 11
Libs/Visualization/VTK/Core/vtkLightBoxRendererManager.cpp

@@ -41,14 +41,15 @@ namespace
 class RenderWindowItem
 {
 public:
-  RenderWindowItem(const double rendererBackgroundColor[3], double colorWindow, double colorLevel);
+  RenderWindowItem(const double rendererBackgroundColor[3], const double highlightedBoxColor[3],
+                   double colorWindow, double colorLevel);
   void SetViewport(double xMin, double yMin, double viewportWidth, double viewportHeight);
 
   /// Create the actor supporing the image mapper
   void SetupImageMapperActor(double colorWindow, double colorLevel);
 
   /// Create a box around the renderer.
-  void SetupHighlightedBoxActor(bool visible = false);
+  void SetupHighlightedBoxActor(const double highlightedBoxColor[3], bool visible = false);
 
   /// Set HighlightedBox color
   void SetHighlightedBoxColor(double* newHighlightedBoxColor);
@@ -64,6 +65,7 @@ public:
 
 //-----------------------------------------------------------------------------
 RenderWindowItem::RenderWindowItem(const double rendererBackgroundColor[3],
+                                   const double highlightedBoxColor[3],
                                    double colorWindow, double colorLevel)
 {
   // Instanciate a renderer
@@ -73,7 +75,7 @@ RenderWindowItem::RenderWindowItem(const double rendererBackgroundColor[3],
                                 rendererBackgroundColor[2]);
 
   this->SetupImageMapperActor(colorWindow, colorLevel);
-  this->SetupHighlightedBoxActor();
+  this->SetupHighlightedBoxActor(highlightedBoxColor);
 }
 
 //-----------------------------------------------------------------------------
@@ -105,7 +107,7 @@ void RenderWindowItem::SetupImageMapperActor(double colorWindow, double colorLev
 }
 
 //---------------------------------------------------------------------------
-void RenderWindowItem::SetupHighlightedBoxActor(bool visible)
+void RenderWindowItem::SetupHighlightedBoxActor(const double highlightedBoxColor[3], bool visible)
 {
   assert(this->Renderer);
   assert(!this->HighlightedBoxActor);
@@ -113,11 +115,11 @@ void RenderWindowItem::SetupHighlightedBoxActor(bool visible)
   // Create a highlight actor (2D box around viewport)
   VTK_CREATE(vtkPolyData, poly);
   VTK_CREATE(vtkPoints, points);
-  double eps = 0.0;
-  points->InsertNextPoint(eps, eps, 0);
-  points->InsertNextPoint(1, eps, 0);
-  points->InsertNextPoint(1, 1, 0);
-  points->InsertNextPoint(eps, 1, 0);
+  double eps = 0.00;
+  points->InsertNextPoint(eps, eps, 0); // bottom-left
+  points->InsertNextPoint(1 + eps, eps, 0); // bottom-right
+  points->InsertNextPoint(1 + eps, 1 + eps, 0); // top-right
+  points->InsertNextPoint(eps, 1 + eps, 0); // top-left
 
   VTK_CREATE(vtkCellArray, cells);
   cells->InsertNextCell(5);
@@ -139,7 +141,8 @@ void RenderWindowItem::SetupHighlightedBoxActor(bool visible)
 
   this->HighlightedBoxActor = vtkSmartPointer<vtkActor2D>::New();
   this->HighlightedBoxActor->SetMapper(polyDataMapper);
-  this->HighlightedBoxActor->GetProperty()->SetColor(0, 1, 0); // Default to green
+  this->HighlightedBoxActor->GetProperty()->SetColor(
+      highlightedBoxColor[0], highlightedBoxColor[1], highlightedBoxColor[2]); // Default to green
   this->HighlightedBoxActor->GetProperty()->SetDisplayLocationToForeground();
   this->HighlightedBoxActor->GetProperty()->SetLineWidth(3); // wide enough so not clipped
   this->HighlightedBoxActor->SetVisibility(visible);
@@ -531,7 +534,8 @@ void vtkLightBoxRendererManager::SetRenderWindowLayout(int rowCount, int columnC
     while(extraItem > 0)
       {
       RenderWindowItem * item =
-          new RenderWindowItem(this->Internal->RendererBackgroundColor, 
+          new RenderWindowItem(this->Internal->RendererBackgroundColor,
+                               this->Internal->HighlightedBoxColor,
                                this->Internal->ColorWindow, this->Internal->ColorLevel);
       item->ImageMapper->SetInput(this->Internal->ImageData);
       this->Internal->RenderWindowItemList.push_back(item);