ctkVTKRenderView.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkVTKRenderView_h
  15. #define __ctkVTKRenderView_h
  16. // Qt includes
  17. #include <QWidget>
  18. // CTK includes
  19. #include <ctkPimpl.h>
  20. #include "ctkVisualizationVTKWidgetsExport.h"
  21. class ctkVTKRenderViewPrivate;
  22. class vtkInteractorObserver;
  23. class vtkRenderWindowInteractor;
  24. class vtkRenderWindow;
  25. class vtkRenderer;
  26. class vtkCamera;
  27. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKRenderView : public QWidget
  28. {
  29. Q_OBJECT
  30. Q_PROPERTY(QString cornerAnnotationText READ cornerAnnotationText WRITE setCornerAnnotationText)
  31. Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
  32. Q_PROPERTY(bool renderEnabled READ renderEnabled WRITE setRenderEnabled)
  33. Q_PROPERTY(bool orientationWidgetVisible READ orientationWidgetVisible
  34. WRITE setOrientationWidgetVisible)
  35. Q_PROPERTY(double zoomFactor READ zoomFactor WRITE setZoomFactor)
  36. Q_PROPERTY(int pitchRollYawIncrement READ pitchRollYawIncrement WRITE setPitchRollYawIncrement)
  37. Q_ENUMS(RotateDirection)
  38. Q_PROPERTY(RotateDirection pitchDirection READ pitchDirection WRITE setPitchDirection)
  39. Q_PROPERTY(RotateDirection rollDirection READ rollDirection WRITE setRollDirection)
  40. Q_PROPERTY(RotateDirection yawDirection READ yawDirection WRITE setYawDirection)
  41. Q_PROPERTY(RotateDirection spinDirection READ spinDirection WRITE setSpinDirection)
  42. Q_PROPERTY(bool spinEnabled READ spinEnabled WRITE setSpinEnabled)
  43. Q_PROPERTY(int spinIncrement READ spinIncrement WRITE setSpinIncrement)
  44. Q_PROPERTY(int animationIntervalMs READ animationIntervalMs WRITE setAnimationIntervalMs)
  45. Q_PROPERTY(bool rockEnabled READ rockEnabled WRITE setRockEnabled)
  46. Q_PROPERTY(int rockLength READ rockLength WRITE setRockLength)
  47. public:
  48. enum RotateDirection { PitchUp, PitchDown, RollLeft, RollRight, YawLeft, YawRight };
  49. typedef QWidget Superclass;
  50. explicit ctkVTKRenderView(QWidget* parent = 0);
  51. virtual ~ctkVTKRenderView();
  52. public slots:
  53. /// If a render has already been scheduled, this called is a no-op
  54. void scheduleRender();
  55. /// Force a render even if a render is already ocurring
  56. void forceRender();
  57. /// Set background color
  58. void setBackgroundColor(const QColor& newBackgroundColor);
  59. /// Enable/Disable rendering
  60. void setRenderEnabled(bool value);
  61. /// Set corner annotation \a text
  62. void setCornerAnnotationText(const QString& text);
  63. /// Show/Hide Orientation widget
  64. void setOrientationWidgetVisible(bool visible);
  65. /// Set absolute amount degrees the view should be either pitched, rolled or yawed with.
  66. /// \sa pitch setPitchDirection roll setRollDirection yaw setYawDirection
  67. /// \note The default is 5 degrees
  68. void setPitchRollYawIncrement(int newPitchRollYawIncrement);
  69. /// Pitch view of X degrees. X been set using setPitchRollYawIncrement
  70. /// \sa setPitchRollYawIncrement setPitchDirection
  71. void pitch();
  72. /// Rool view of X degrees. X been set using setPitchRollYawIncrement
  73. /// \sa setPitchRollYawIncrement setRollDirection
  74. void roll();
  75. /// Yaw view of X degrees. X been set using setPitchRollYawIncrement
  76. /// \sa setPitchRollYawIncrement setYawDirection
  77. void yaw();
  78. /// Enable or Disbled the animated spin of the view
  79. void setSpinEnabled(bool enabled);
  80. /// Set number of degrees in spin increment
  81. /// \sa setSpinDirection setSpinIntervalMs
  82. void setSpinIncrement(int newSpinIncrement);
  83. /// Amount of wait time between spin or rock increments
  84. /// \sa setSpinIncrement setRockIncrement
  85. void setAnimationIntervalMs(int ms);
  86. /// Enable or Disbled the animated rock of the view
  87. void setRockEnabled(bool enabled);
  88. /// Set length of the rock animation
  89. void setRockLength(int newRockLength);
  90. /// Set increment of animated rock
  91. void setRockIncrement(int newRockIncrement);
  92. /// \brief Set zoom factor
  93. /// zoomFactor is a value between 0.0 and 1.0
  94. /// \note The default value is 0.05
  95. void setZoomFactor(double newZoomFactor);
  96. /// Zoom in using the \a zoomfactor
  97. /// \sa setZoomFactor
  98. void zoomIn();
  99. /// Zoom out using the \a zoomfactor
  100. /// \sa setZoomFactor
  101. void zoomOut();
  102. /// Set the focal point
  103. void setFocalPoint(int x, int y, int z);
  104. /// \brief Reset focal point
  105. /// The visible scene bbox is computed, then the camera is recentered around its centroid.
  106. void resetFocalPoint();
  107. public:
  108. /// Get underlying RenderWindow
  109. vtkRenderWindow* renderWindow()const;
  110. /// Set/Get window interactor
  111. vtkRenderWindowInteractor* interactor()const;
  112. void setInteractor(vtkRenderWindowInteractor* newInteractor);
  113. /// Get current interactor style
  114. vtkInteractorObserver* interactorStyle();
  115. /// Get corner annotation \a text
  116. QString cornerAnnotationText() const;
  117. /// Get background color
  118. QColor backgroundColor() const;
  119. /// Get Orientation widget visibility
  120. bool orientationWidgetVisible();
  121. /// Get active camera
  122. vtkCamera* activeCamera();
  123. /// Reset camera
  124. void resetCamera();
  125. /// Get a reference to the associated vtkRenderer
  126. vtkRenderer* renderer()const;
  127. /// Return if rendering is enabled
  128. bool renderEnabled() const;
  129. /// Return pitch, roll or yaw increment (in degree)
  130. int pitchRollYawIncrement()const;
  131. /// Return if animated spin is enabled
  132. bool spinEnabled() const;
  133. /// Return spin increment (in degrees)
  134. /// \sa setSpinIncrement
  135. int spinIncrement()const;
  136. /// Amount of waiting time between spin or rock increment
  137. /// \sa setAnimationIntervalMs
  138. int animationIntervalMs()const;
  139. /// Return if animated rock is enabled
  140. bool rockEnabled() const;
  141. /// Return length of the rock animation
  142. int rockLength() const;
  143. /// Return increment of animated rock
  144. int rockIncrement() const;
  145. RotateDirection pitchDirection()const;
  146. void setPitchDirection(RotateDirection newPitchDirection);
  147. RotateDirection rollDirection()const;
  148. void setRollDirection(RotateDirection newRollDirection);
  149. RotateDirection yawDirection()const;
  150. void setYawDirection(RotateDirection newYawDirection);
  151. RotateDirection spinDirection()const;
  152. void setSpinDirection(RotateDirection newSpinDirection);
  153. /// Return zoom factor
  154. double zoomFactor()const;
  155. protected:
  156. QScopedPointer<ctkVTKRenderViewPrivate> d_ptr;
  157. private:
  158. Q_DECLARE_PRIVATE(ctkVTKRenderView);
  159. Q_DISABLE_COPY(ctkVTKRenderView);
  160. };
  161. #endif