瀏覽代碼

Add overlayRenderer and overlayCornerAnnotation to ctkVTKSliceView

Jean-Christophe Fillion-Robin 14 年之前
父節點
當前提交
87a5c32ed7

+ 27 - 0
Libs/Visualization/VTK/Widgets/ctkVTKSliceView.cpp

@@ -68,9 +68,26 @@ void ctkVTKSliceViewPrivate::setupRendering()
   this->RenderWindow->SetAlphaBitPlanes(1);
   this->RenderWindow->SetAlphaBitPlanes(1);
   this->RenderWindow->SetMultiSamples(0);
   this->RenderWindow->SetMultiSamples(0);
   this->RenderWindow->StereoCapableWindowOn();
   this->RenderWindow->StereoCapableWindowOn();
+  this->RenderWindow->SetNumberOfLayers(2);
 
 
+  // Initialize light box
   this->LightBoxRendererManager->Initialize(this->RenderWindow);
   this->LightBoxRendererManager->Initialize(this->RenderWindow);
 
 
+  // Setup overlay renderer
+  this->OverlayRenderer = vtkSmartPointer<vtkRenderer>::New();
+  this->OverlayRenderer->SetLayer(1);
+  this->RenderWindow->AddRenderer(this->OverlayRenderer);
+
+  // Create cornerAnnotation and set its default property
+  this->OverlayCornerAnnotation = vtkSmartPointer<vtkCornerAnnotation>::New();
+  this->OverlayCornerAnnotation->SetMaximumLineHeight(0.07);
+  vtkTextProperty *tprop = this->OverlayCornerAnnotation->GetTextProperty();
+  tprop->ShadowOn();
+  this->OverlayCornerAnnotation->ClearAllTexts();
+
+  // Add corner annotation to overlay renderer
+  this->OverlayRenderer->AddViewProp(this->OverlayCornerAnnotation);
+
   this->VTKWidget->SetRenderWindow(this->RenderWindow);
   this->VTKWidget->SetRenderWindow(this->RenderWindow);
 }
 }
 
 
@@ -137,6 +154,9 @@ CTK_GET_CPP(ctkVTKSliceView, vtkLightBoxRendererManager*,
             lightBoxRendererManager, LightBoxRendererManager);
             lightBoxRendererManager, LightBoxRendererManager);
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
+CTK_GET_CPP(ctkVTKSliceView, vtkRenderer*, overlayRenderer, OverlayRenderer);
+
+//----------------------------------------------------------------------------
 CTK_SET_CPP(ctkVTKSliceView, bool, setRenderEnabled, RenderEnabled);
 CTK_SET_CPP(ctkVTKSliceView, bool, setRenderEnabled, RenderEnabled);
 CTK_GET_CPP(ctkVTKSliceView, bool, renderEnabled, RenderEnabled);
 CTK_GET_CPP(ctkVTKSliceView, bool, renderEnabled, RenderEnabled);
 
 
@@ -202,6 +222,13 @@ void ctkVTKSliceView::setCornerAnnotationText(const QString& text)
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
+vtkCornerAnnotation * ctkVTKSliceView::overlayCornerAnnotation()const
+{
+  Q_D(const ctkVTKSliceView);
+  return d->OverlayCornerAnnotation;
+}
+
+//----------------------------------------------------------------------------
 QColor ctkVTKSliceView::backgroundColor()const
 QColor ctkVTKSliceView::backgroundColor()const
 {
 {
   Q_D(const ctkVTKSliceView);
   Q_D(const ctkVTKSliceView);

+ 9 - 0
Libs/Visualization/VTK/Widgets/ctkVTKSliceView.h

@@ -37,6 +37,7 @@ class vtkRenderWindow;
 class vtkRenderer;
 class vtkRenderer;
 class vtkCamera; 
 class vtkCamera; 
 class vtkImageData;
 class vtkImageData;
+class vtkCornerAnnotation;
 
 
 class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKSliceView : public QWidget
 class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKSliceView : public QWidget
 {
 {
@@ -71,6 +72,9 @@ public:
   /// Get lightBoxRendererManager
   /// Get lightBoxRendererManager
   vtkLightBoxRendererManager* lightBoxRendererManager() const;
   vtkLightBoxRendererManager* lightBoxRendererManager() const;
 
 
+  /// Get overlay renderer
+  vtkRenderer* overlayRenderer() const;
+
   /// Set/Get window interactor
   /// Set/Get window interactor
   vtkRenderWindowInteractor* interactor() const;
   vtkRenderWindowInteractor* interactor() const;
   void setInteractor(vtkRenderWindowInteractor* newInteractor);
   void setInteractor(vtkRenderWindowInteractor* newInteractor);
@@ -87,6 +91,11 @@ public:
   /// by the lightBoxManager
   /// by the lightBoxManager
   /// \sa vtkLightBoxRendererManager::GetCornerAnnotation()
   /// \sa vtkLightBoxRendererManager::GetCornerAnnotation()
   vtkCornerAnnotation * cornerAnnotation()const;
   vtkCornerAnnotation * cornerAnnotation()const;
+
+  /// Get overlay corner annotation actor
+  /// This corresponds to the cornerAnnotation associated added in the single overlay renderer
+  vtkCornerAnnotation* overlayCornerAnnotation()const;
+
   /// Get background color
   /// Get background color
   /// \sa setBackgroundColor();
   /// \sa setBackgroundColor();
   QColor backgroundColor()const;
   QColor backgroundColor()const;

+ 3 - 0
Libs/Visualization/VTK/Widgets/ctkVTKSliceView_p.h

@@ -40,6 +40,7 @@
 #include <vtkSmartPointer.h>
 #include <vtkSmartPointer.h>
 #include <vtkWeakPointer.h>
 #include <vtkWeakPointer.h>
 #include <vtkImageMapper.h>
 #include <vtkImageMapper.h>
+#include <vtkCornerAnnotation.h>
 
 
 class vtkRenderWindowInteractor;
 class vtkRenderWindowInteractor;
 
 
@@ -60,6 +61,8 @@ public:
   vtkSmartPointer<vtkLightBoxRendererManager>   LightBoxRendererManager;
   vtkSmartPointer<vtkLightBoxRendererManager>   LightBoxRendererManager;
   bool                                          RenderPending;
   bool                                          RenderPending;
   bool                                          RenderEnabled;
   bool                                          RenderEnabled;
+  vtkSmartPointer<vtkRenderer>                  OverlayRenderer;
+  vtkSmartPointer<vtkCornerAnnotation>          OverlayCornerAnnotation;
 
 
 };
 };