ctkVTKRenderView.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. // 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. /// Set background color
  96. virtual void setBackgroundColor(const QColor& newBackgroundColor);
  97. /// Get background color
  98. virtual QColor backgroundColor() const;
  99. /// Get Orientation widget visibility
  100. bool orientationWidgetVisible();
  101. /// Get active camera
  102. vtkCamera* activeCamera();
  103. /// Reset camera
  104. void resetCamera();
  105. /// Get a reference to the associated vtkRenderer
  106. vtkRenderer* renderer()const;
  107. /// Set window interactor
  108. /// Reimplemented to propagate interaction to Orientation widget
  109. virtual void setInteractor(vtkRenderWindowInteractor* interactor);
  110. /// Return pitch, roll or yaw increment (in degree)
  111. int pitchRollYawIncrement()const;
  112. /// Return if animated spin is enabled
  113. bool spinEnabled() const;
  114. /// Return spin increment (in degrees)
  115. /// \sa setSpinIncrement
  116. int spinIncrement()const;
  117. /// Amount of waiting time between spin or rock increment
  118. /// \sa setAnimationIntervalMs
  119. int animationIntervalMs()const;
  120. /// Return if animated rock is enabled
  121. bool rockEnabled() const;
  122. /// Return length of the rock animation
  123. int rockLength() const;
  124. /// Return increment of animated rock
  125. int rockIncrement() const;
  126. RotateDirection pitchDirection()const;
  127. void setPitchDirection(RotateDirection newPitchDirection);
  128. RotateDirection rollDirection()const;
  129. void setRollDirection(RotateDirection newRollDirection);
  130. RotateDirection yawDirection()const;
  131. void setYawDirection(RotateDirection newYawDirection);
  132. RotateDirection spinDirection()const;
  133. void setSpinDirection(RotateDirection newSpinDirection);
  134. /// Return zoom factor
  135. double zoomFactor()const;
  136. private:
  137. Q_DECLARE_PRIVATE(ctkVTKRenderView);
  138. Q_DISABLE_COPY(ctkVTKRenderView);
  139. };
  140. #endif