ctkVTKRenderView.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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.apache.org/licenses/LICENSE-2.0.txt
  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. // CTK includes
  17. #include <ctkAxesWidget.h>
  18. #include "ctkVTKAbstractView.h"
  19. class ctkVTKRenderViewPrivate;
  20. class vtkCamera;
  21. class vtkRenderer;
  22. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKRenderView : public ctkVTKAbstractView
  23. {
  24. Q_OBJECT
  25. Q_PROPERTY(bool orientationWidgetVisible READ orientationWidgetVisible
  26. WRITE setOrientationWidgetVisible)
  27. Q_PROPERTY(double zoomFactor READ zoomFactor WRITE setZoomFactor)
  28. Q_PROPERTY(int pitchRollYawIncrement READ pitchRollYawIncrement WRITE setPitchRollYawIncrement)
  29. Q_ENUMS(RotateDirection)
  30. Q_PROPERTY(RotateDirection pitchDirection READ pitchDirection WRITE setPitchDirection)
  31. Q_PROPERTY(RotateDirection rollDirection READ rollDirection WRITE setRollDirection)
  32. Q_PROPERTY(RotateDirection yawDirection READ yawDirection WRITE setYawDirection)
  33. Q_PROPERTY(RotateDirection spinDirection READ spinDirection WRITE setSpinDirection)
  34. Q_PROPERTY(bool spinEnabled READ spinEnabled WRITE setSpinEnabled)
  35. Q_PROPERTY(int spinIncrement READ spinIncrement WRITE setSpinIncrement)
  36. Q_PROPERTY(int animationIntervalMs READ animationIntervalMs WRITE setAnimationIntervalMs)
  37. Q_PROPERTY(bool rockEnabled READ rockEnabled WRITE setRockEnabled)
  38. Q_PROPERTY(int rockLength READ rockLength WRITE setRockLength)
  39. public:
  40. enum RotateDirection { PitchUp, PitchDown, RollLeft, RollRight, YawLeft, YawRight };
  41. typedef ctkVTKAbstractView Superclass;
  42. explicit ctkVTKRenderView(QWidget* parent = 0);
  43. virtual ~ctkVTKRenderView();
  44. public slots:
  45. /// Show/Hide Orientation widget
  46. void setOrientationWidgetVisible(bool visible);
  47. /// Set absolute amount degrees the view should be either pitched, rolled or yawed with.
  48. /// \sa pitch setPitchDirection roll setRollDirection yaw setYawDirection
  49. /// \note The default is 5 degrees
  50. void setPitchRollYawIncrement(int newPitchRollYawIncrement);
  51. /// Pitch view of X degrees. X been set using setPitchRollYawIncrement
  52. /// \sa setPitchRollYawIncrement setPitchDirection
  53. void pitch();
  54. /// Rool view of X degrees. X been set using setPitchRollYawIncrement
  55. /// \sa setPitchRollYawIncrement setRollDirection
  56. void roll();
  57. /// Yaw view of X degrees. X been set using setPitchRollYawIncrement
  58. /// \sa setPitchRollYawIncrement setYawDirection
  59. void yaw();
  60. /// Enable or Disbled the animated spin of the view
  61. void setSpinEnabled(bool enabled);
  62. /// Set number of degrees in spin increment
  63. /// \sa setSpinDirection setSpinIntervalMs
  64. void setSpinIncrement(int newSpinIncrement);
  65. /// Amount of wait time between spin or rock increments
  66. /// \sa setSpinIncrement setRockIncrement
  67. void setAnimationIntervalMs(int ms);
  68. /// Enable or Disbled the animated rock of the view
  69. void setRockEnabled(bool enabled);
  70. /// Set length of the rock animation
  71. void setRockLength(int newRockLength);
  72. /// Set increment of animated rock
  73. void setRockIncrement(int newRockIncrement);
  74. /// \brief Set zoom factor
  75. /// zoomFactor is a value between 0.0 and 1.0
  76. /// \note The default value is 0.05
  77. void setZoomFactor(double newZoomFactor);
  78. /// Zoom in using the \a zoomfactor
  79. /// \sa setZoomFactor
  80. void zoomIn();
  81. /// Zoom out using the \a zoomfactor
  82. /// \sa setZoomFactor
  83. void zoomOut();
  84. /// Set the focal point
  85. void setFocalPoint(int x, int y, int z);
  86. /// \brief Reset focal point
  87. /// The visible scene bbox is computed, then the camera is recentered around its centroid.
  88. void resetFocalPoint();
  89. /// \brief Change camera to look from a given axis to the focal point
  90. /// Translate/Rotate the camera to look from a given axis
  91. /// The Field of View (fov) controls how far from the focal point the
  92. /// camera must be (final_pos = focal_point + 3*fov).
  93. void lookFromAxis(const ctkAxesWidget::Axis& axis, double fov = 10.);
  94. public:
  95. /// Get Orientation widget visibility
  96. bool orientationWidgetVisible();
  97. /// Get active camera
  98. vtkCamera* activeCamera();
  99. /// Reset camera
  100. void resetCamera();
  101. /// Get a reference to the associated vtkRenderer
  102. vtkRenderer* renderer()const;
  103. /// Set window interactor
  104. /// Reimplemented to propagate interaction to Orientation widget
  105. virtual void setInteractor(vtkRenderWindowInteractor* interactor);
  106. /// Return pitch, roll or yaw increment (in degree)
  107. int pitchRollYawIncrement()const;
  108. /// Return if animated spin is enabled
  109. bool spinEnabled() const;
  110. /// Return spin increment (in degrees)
  111. /// \sa setSpinIncrement
  112. int spinIncrement()const;
  113. /// Amount of waiting time between spin or rock increment
  114. /// \sa setAnimationIntervalMs
  115. int animationIntervalMs()const;
  116. /// Return if animated rock is enabled
  117. bool rockEnabled() const;
  118. /// Return length of the rock animation
  119. int rockLength() const;
  120. /// Return increment of animated rock
  121. int rockIncrement() const;
  122. RotateDirection pitchDirection()const;
  123. void setPitchDirection(RotateDirection newPitchDirection);
  124. RotateDirection rollDirection()const;
  125. void setRollDirection(RotateDirection newRollDirection);
  126. RotateDirection yawDirection()const;
  127. void setYawDirection(RotateDirection newYawDirection);
  128. RotateDirection spinDirection()const;
  129. void setSpinDirection(RotateDirection newSpinDirection);
  130. /// Return zoom factor
  131. double zoomFactor()const;
  132. private:
  133. Q_DECLARE_PRIVATE(ctkVTKRenderView);
  134. Q_DISABLE_COPY(ctkVTKRenderView);
  135. };
  136. #endif