ctkVTKSliceView.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 __ctkVTKSliceView_h
  15. #define __ctkVTKSliceView_h
  16. // Qt includes
  17. #include <QWidget>
  18. // CTK includes
  19. #include <ctkPimpl.h>
  20. #include "CTKVisualizationVTKWidgetsExport.h"
  21. class ctkVTKSliceViewPrivate;
  22. class vtkInteractorObserver;
  23. class vtkRenderWindowInteractor;
  24. class vtkRenderWindow;
  25. class vtkRenderer;
  26. class vtkCamera;
  27. class vtkImageData;
  28. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKSliceView : public QWidget
  29. {
  30. Q_OBJECT
  31. Q_ENUMS(RenderWindowLayoutType)
  32. Q_PROPERTY(RenderWindowLayoutType renderWindowLayoutType READ renderWindowLayoutType
  33. WRITE setRenderWindowLayoutType)
  34. Q_PROPERTY(QString cornerAnnotationText READ cornerAnnotationText WRITE setCornerAnnotationText)
  35. Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
  36. Q_PROPERTY(double colorWindow READ colorWindow)
  37. Q_PROPERTY(double colorLevel READ colorLevel)
  38. Q_PROPERTY(bool renderEnabled READ renderEnabled WRITE setRenderEnabled)
  39. public:
  40. /// Constructors
  41. typedef QWidget Superclass;
  42. explicit ctkVTKSliceView(QWidget* parent = 0);
  43. virtual ~ctkVTKSliceView();
  44. /// If a render has already been scheduled, this called is a no-op
  45. void scheduleRender();
  46. /// Force a render even if a render is already ocurring
  47. void forceRender();
  48. /// Get underlying RenderWindow
  49. vtkRenderWindow* renderWindow() const;
  50. /// Set/Get window interactor
  51. vtkRenderWindowInteractor* interactor() const;
  52. void setInteractor(vtkRenderWindowInteractor* newInteractor);
  53. /// Get current interactor style
  54. vtkInteractorObserver* interactorStyle();
  55. /// Set/Get corner annotation \a text
  56. void setCornerAnnotationText(const QString& text);
  57. QString cornerAnnotationText() const;
  58. /// Set/Get background color
  59. void setBackgroundColor(const QColor& newBackgroundColor);
  60. QColor backgroundColor() const;
  61. /// Get active camera
  62. /// Note that the same camera is used with all the renderWindowItem
  63. vtkCamera* activeCamera();
  64. /// Set actice camera
  65. void setActiveCamera(vtkCamera* newActiveCamera);
  66. /// Reset cameras associated with all renderWindowItem
  67. void resetCamera();
  68. /// Return number of underlying renderer
  69. int rendererCount();
  70. /// Get a reference to the associated vtkRenderer(s) identified by its \a id
  71. vtkRenderer* renderer(int id);
  72. /// Get a reference to the associated vtkRenderer(s) given its posiion in the grid
  73. /// \sa renderer(int)
  74. vtkRenderer* renderer(int rowId, int columnId);
  75. /// The layout type determines how the image slices should be displayed
  76. /// within the different render view items.
  77. /// \sa setRenderWindowLayout() renderWindowLayoutType()
  78. enum RenderWindowLayoutType{ LeftRightTopBottom, LeftRightBottomTop};
  79. /// Get current layout type
  80. RenderWindowLayoutType renderWindowLayoutType() const;
  81. /// Set current \a layoutType
  82. void setRenderWindowLayoutType(RenderWindowLayoutType layoutType);
  83. /// Split the current vtkRenderWindow in \a rowCount per \a columnCount grid
  84. void setRenderWindowLayout(int rowCount, int columnCount);
  85. /// Highlight / Unhighlight a render view item given its \a id
  86. void setHighlightedById(int id, bool value);
  87. /// Highlight / Unhighlight a render view item given its position in the grid
  88. /// \sa setHighlighted(int, bool)
  89. void setHighlighted(int rowId, int columnId, bool value);
  90. /// Convenient function allowing to compute the renderWindowItemId
  91. /// given \a rowId and \a columnId.
  92. /// The following formula is used: ColumnCount * rowId + columnId
  93. /// Note that the \a rowCount and \a columnCount correspond to the one set
  94. /// using setRenderWindowLayout.
  95. inline int renderWindowItemId(int rowId, int columnId);
  96. /// Return if rendering is enabled
  97. bool renderEnabled() const;
  98. /// Enable/Disable rendering
  99. void setRenderEnabled(bool value);
  100. /// Get current color window
  101. double colorWindow() const;
  102. /// Get current color level
  103. double colorLevel() const;
  104. /// Set image data
  105. void setImageData(vtkImageData* newImageData);
  106. private:
  107. CTK_DECLARE_PRIVATE(ctkVTKSliceView);
  108. };
  109. #endif