ctkVTKRenderView.h 6.1 KB

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