ctkVTKRenderView.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 rotateDegrees READ rotateDegrees WRITE setRotateDegrees)
  37. Q_ENUMS(PitchDirection)
  38. Q_PROPERTY(PitchDirection pitchDirection READ pitchDirection WRITE setPitchDirection)
  39. Q_ENUMS(RollDirection)
  40. Q_PROPERTY(RollDirection rollDirection READ rollDirection WRITE setRollDirection)
  41. Q_ENUMS(YawDirection)
  42. Q_PROPERTY(YawDirection yawDirection READ yawDirection WRITE setYawDirection)
  43. public:
  44. enum PitchDirection { PitchUp, PitchDown };
  45. enum RollDirection {RollLeft, RollRight};
  46. enum YawDirection {YawLeft, YawRight};
  47. /// Constructors
  48. typedef QWidget Superclass;
  49. explicit ctkVTKRenderView(QWidget* parent = 0);
  50. virtual ~ctkVTKRenderView(){}
  51. public slots:
  52. /// If a render has already been scheduled, this called is a no-op
  53. void scheduleRender();
  54. /// Force a render even if a render is already ocurring
  55. void forceRender();
  56. /// Set background color
  57. void setBackgroundColor(const QColor& newBackgroundColor);
  58. /// Enable/Disable rendering
  59. void setRenderEnabled(bool value);
  60. /// Set corner annotation \a text
  61. void setCornerAnnotationText(const QString& text);
  62. /// Show/Hide Orientation widget
  63. void setOrientationWidgetVisible(bool visible);
  64. /// Set absolute amount degrees the view should be either pitched, rolled or yawed with.
  65. /// \sa pitch setPitchDirection roll setRollDirection yaw setYawDirection
  66. /// \note The default is 5 degrees
  67. void setRotateDegrees(int newRotateDegrees);
  68. /// Pitch view of X degrees. X been set using setRotateDegrees
  69. /// \sa setRotateDegrees
  70. void pitch();
  71. /// Rool view of X degrees. X been set using setRotateDegrees
  72. /// \sa setRotateDegrees
  73. void roll();
  74. /// Yaw view of X degrees. X been set using setRotateDegrees
  75. /// \sa setRotateDegrees
  76. void yaw();
  77. /// \brief Set zoom factor
  78. /// zoomFactor is a value between 0.0 and 1.0
  79. /// \note The default value is 0.05
  80. void setZoomFactor(double newZoomFactor);
  81. /// Zoom in using the \a zoomfactor
  82. /// \sa setZoomFactor
  83. void zoomIn();
  84. /// Zoom out using the \a zoomfactor
  85. /// \sa setZoomFactor
  86. void zoomOut();
  87. public:
  88. /// Get underlying RenderWindow
  89. vtkRenderWindow* renderWindow()const;
  90. /// Set/Get window interactor
  91. vtkRenderWindowInteractor* interactor()const;
  92. void setInteractor(vtkRenderWindowInteractor* newInteractor);
  93. /// Get current interactor style
  94. vtkInteractorObserver* interactorStyle();
  95. /// Get corner annotation \a text
  96. QString cornerAnnotationText() const;
  97. /// Get background color
  98. 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. /// Return if rendering is enabled
  108. bool renderEnabled() const;
  109. /// Return amount of degrees used to either pitch, roll or yaw the view
  110. int rotateDegrees()const;
  111. PitchDirection pitchDirection()const;
  112. void setPitchDirection(PitchDirection newPitchDirection);
  113. RollDirection rollDirection()const;
  114. void setRollDirection(RollDirection newRollDirection);
  115. YawDirection yawDirection()const;
  116. void setYawDirection(YawDirection newYawDirection);
  117. /// Return zoom factor
  118. double zoomFactor()const;
  119. private:
  120. CTK_DECLARE_PRIVATE(ctkVTKRenderView);
  121. };
  122. #endif