ctkVTKSliceView.h 4.9 KB

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