Browse Source

ENH: Add convenient method renderWindow() and interactorStyle() to ctkVTKRenderView

Jean-Christophe Fillion-Robin 15 years ago
parent
commit
924b03fc47

+ 20 - 4
Libs/Visualization/VTK/Widgets/ctkVTKRenderView.cpp

@@ -110,9 +110,6 @@ ctkVTKRenderView::~ctkVTKRenderView()
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
-CTK_GET_CXX(ctkVTKRenderView, vtkRenderWindowInteractor*, interactor, CurrentInteractor);
-
-//----------------------------------------------------------------------------
 void ctkVTKRenderView::scheduleRender()
 void ctkVTKRenderView::scheduleRender()
 {
 {
   CTK_D(ctkVTKRenderView);
   CTK_D(ctkVTKRenderView);
@@ -140,9 +137,14 @@ void ctkVTKRenderView::forceRender()
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
+CTK_GET_CXX(ctkVTKRenderView, vtkRenderWindow*, renderWindow, RenderWindow);
+
+//----------------------------------------------------------------------------
+CTK_GET_CXX(ctkVTKRenderView, vtkRenderWindowInteractor*, interactor, CurrentInteractor);
+
+//----------------------------------------------------------------------------
 void ctkVTKRenderView::setInteractor(vtkRenderWindowInteractor* newInteractor)
 void ctkVTKRenderView::setInteractor(vtkRenderWindowInteractor* newInteractor)
 {
 {
-  Q_ASSERT(newInteractor);
   CTK_D(ctkVTKRenderView);
   CTK_D(ctkVTKRenderView);
   d->RenderWindow->SetInteractor(newInteractor);
   d->RenderWindow->SetInteractor(newInteractor);
   d->Orientation->SetOrientationMarker(d->Axes);
   d->Orientation->SetOrientationMarker(d->Axes);
@@ -153,6 +155,20 @@ void ctkVTKRenderView::setInteractor(vtkRenderWindowInteractor* newInteractor)
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
+vtkInteractorObserver* ctkVTKRenderView::interactorStyle()
+{
+  CTK_D(ctkVTKRenderView);
+  if (d->CurrentInteractor)
+    {
+    return d->CurrentInteractor->GetInteractorStyle();
+    }
+  else
+    {
+    return 0;
+    }
+}
+
+//----------------------------------------------------------------------------
 void ctkVTKRenderView::setCornerAnnotationText(const QString& text)
 void ctkVTKRenderView::setCornerAnnotationText(const QString& text)
 {
 {
   CTK_D(ctkVTKRenderView);
   CTK_D(ctkVTKRenderView);

+ 8 - 0
Libs/Visualization/VTK/Widgets/ctkVTKRenderView.h

@@ -30,7 +30,9 @@
 #include "CTKVisualizationVTKWidgetsExport.h"
 #include "CTKVisualizationVTKWidgetsExport.h"
 
 
 class ctkVTKRenderViewPrivate;
 class ctkVTKRenderViewPrivate;
+class vtkInteractorObserver;
 class vtkRenderWindowInteractor;
 class vtkRenderWindowInteractor;
+class vtkRenderWindow;
 class vtkRenderer;
 class vtkRenderer;
 class vtkCamera; 
 class vtkCamera; 
 
 
@@ -49,10 +51,16 @@ public:
   /// Force a render even if a render is already ocurring
   /// Force a render even if a render is already ocurring
   void forceRender();
   void forceRender();
 
 
+  /// Get underlying RenderWindow
+  vtkRenderWindow* renderWindow()const;
+  
   /// Set/Get window interactor
   /// Set/Get window interactor
   vtkRenderWindowInteractor* interactor()const;
   vtkRenderWindowInteractor* interactor()const;
   void setInteractor(vtkRenderWindowInteractor* newInteractor);
   void setInteractor(vtkRenderWindowInteractor* newInteractor);
 
 
+  /// Get current interactor style
+  vtkInteractorObserver* interactorStyle();
+
   /// Set corner annotation text
   /// Set corner annotation text
   void setCornerAnnotationText(const QString& text);
   void setCornerAnnotationText(const QString& text);