ctkVTKSliceView.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. public slots:
  47. /// Force a render even if a render is already ocurring
  48. void forceRender();
  49. /// Reset cameras associated with all renderWindowItem
  50. void resetCamera();
  51. public:
  52. /// Get underlying RenderWindow
  53. vtkRenderWindow* renderWindow() const;
  54. /// Set/Get window interactor
  55. vtkRenderWindowInteractor* interactor() const;
  56. void setInteractor(vtkRenderWindowInteractor* newInteractor);
  57. /// Get current interactor style
  58. vtkInteractorObserver* interactorStyle();
  59. /// Set/Get corner annotation \a text
  60. void setCornerAnnotationText(const QString& text);
  61. QString cornerAnnotationText() const;
  62. /// Set/Get background color
  63. void setBackgroundColor(const QColor& newBackgroundColor);
  64. QColor backgroundColor() const;
  65. /// Get active camera
  66. /// Note that the same camera is used with all the renderWindowItem
  67. vtkCamera* activeCamera();
  68. /// Set actice camera
  69. void setActiveCamera(vtkCamera* newActiveCamera);
  70. /// Return number of underlying renderer
  71. int rendererCount();
  72. /// Get a reference to the associated vtkRenderer(s) identified by its \a id
  73. vtkRenderer* renderer(int id);
  74. /// Get a reference to the associated vtkRenderer(s) given its posiion in the grid
  75. /// \sa renderer(int)
  76. vtkRenderer* renderer(int rowId, int columnId);
  77. /// The layout type determines how the image slices should be displayed
  78. /// within the different render view items.
  79. /// \sa setRenderWindowLayout() renderWindowLayoutType()
  80. enum RenderWindowLayoutType{ LeftRightTopBottom, LeftRightBottomTop};
  81. /// Get current layout type
  82. RenderWindowLayoutType renderWindowLayoutType() const;
  83. /// Set current \a layoutType
  84. void setRenderWindowLayoutType(RenderWindowLayoutType layoutType);
  85. /// Split the current vtkRenderWindow in \a rowCount per \a columnCount grid
  86. void setRenderWindowLayout(int rowCount, int columnCount);
  87. /// Highlight / Unhighlight a render view item given its \a id
  88. void setHighlightedById(int id, bool value);
  89. /// Highlight / Unhighlight a render view item given its position in the grid
  90. /// \sa setHighlighted(int, bool)
  91. void setHighlighted(int rowId, int columnId, bool value);
  92. /// Convenient function allowing to compute the renderWindowItemId
  93. /// given \a rowId and \a columnId.
  94. /// The following formula is used: ColumnCount * rowId + columnId
  95. /// Note that the \a rowCount and \a columnCount correspond to the one set
  96. /// using setRenderWindowLayout.
  97. inline int renderWindowItemId(int rowId, int columnId);
  98. /// Return if rendering is enabled
  99. bool renderEnabled() const;
  100. /// Enable/Disable rendering
  101. void setRenderEnabled(bool value);
  102. /// Get current color window
  103. double colorWindow() const;
  104. /// Get current color level
  105. double colorLevel() const;
  106. /// Set image data
  107. void setImageData(vtkImageData* newImageData);
  108. signals:
  109. void resized(QResizeEvent*);
  110. protected:
  111. virtual void resizeEvent(QResizeEvent * event);
  112. private:
  113. CTK_DECLARE_PRIVATE(ctkVTKSliceView);
  114. };
  115. #endif