ctkVTKAbstractView.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.apache.org/licenses/LICENSE-2.0.txt
  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 __ctkVTKAbstractView_h
  15. #define __ctkVTKAbstractView_h
  16. // Qt includes
  17. #include <QWidget>
  18. // VTK includes
  19. #include <QVTKWidget.h>
  20. // CTK includes
  21. #include "ctkVTKObject.h"
  22. #include "ctkVisualizationVTKWidgetsExport.h"
  23. class ctkVTKAbstractViewPrivate;
  24. class vtkCornerAnnotation;
  25. class vtkInteractorObserver;
  26. class vtkRenderWindowInteractor;
  27. class vtkRenderWindow;
  28. /// \ingroup Visualization_VTK_Widgets
  29. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKAbstractView : public QWidget
  30. {
  31. Q_OBJECT
  32. QVTK_OBJECT
  33. Q_PROPERTY(QString cornerAnnotationText READ cornerAnnotationText WRITE setCornerAnnotationText)
  34. Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
  35. Q_PROPERTY(QColor backgroundColor2 READ backgroundColor2 WRITE setBackgroundColor)
  36. Q_PROPERTY(bool gradientBackground READ gradientBackground WRITE setGradientBackground)
  37. Q_PROPERTY(bool renderEnabled READ renderEnabled WRITE setRenderEnabled)
  38. public:
  39. typedef QWidget Superclass;
  40. explicit ctkVTKAbstractView(QWidget* parent = 0);
  41. virtual ~ctkVTKAbstractView();
  42. public Q_SLOTS:
  43. /// Notify QVTKWidget that the view needs to be rendered.
  44. /// scheduleRender() respects the desired framerate of the render window,
  45. /// it won't render the window more than what the current render window
  46. /// framerate is.
  47. void scheduleRender();
  48. /// Force a render even if a render is already ocurring
  49. /// Be careful when calling forceRender() as it can slow down your
  50. /// application. It is preferable to use scheduleRender() instead.
  51. void forceRender();
  52. /// Set the background color of the rendering screen.
  53. virtual void setBackgroundColor(const QColor& newBackgroundColor);
  54. /// Set the second background color of the rendering screen for gradient
  55. /// backgrounds.
  56. virtual void setBackgroundColor2(const QColor& newBackgroundColor);
  57. /// Set/Get whether this view should have a gradient background using the
  58. /// Background (top) and Background2 (bottom) colors. Default is off.
  59. virtual void setGradientBackground(bool enable);
  60. /// Enable/Disable rendering
  61. void setRenderEnabled(bool value);
  62. /// Set corner annotation \a text
  63. virtual void setCornerAnnotationText(const QString& text);
  64. public:
  65. /// Get underlying RenderWindow
  66. Q_INVOKABLE vtkRenderWindow* renderWindow()const;
  67. /// Set/Get window interactor
  68. Q_INVOKABLE vtkRenderWindowInteractor* interactor()const;
  69. /// QVTKWidget catches all render requests, and ensure the desired framerate
  70. /// is respected.
  71. /// The interactor never calls Render() on the render window.
  72. /// TBD: can we only set a QVTKRenderWindowInteractor ?
  73. virtual void setInteractor(vtkRenderWindowInteractor* interactor);
  74. /// Get current interactor style
  75. Q_INVOKABLE vtkInteractorObserver* interactorStyle()const;
  76. /// Get corner annotation \a text
  77. QString cornerAnnotationText() const;
  78. Q_INVOKABLE vtkCornerAnnotation* cornerAnnotation()const;
  79. /// Get the underlying QVTKWidget
  80. Q_INVOKABLE QVTKWidget * VTKWidget() const;
  81. /// Get background color
  82. virtual QColor backgroundColor() const;
  83. /// Get the second background color
  84. virtual QColor backgroundColor2() const;
  85. /// Is the background a gradient
  86. virtual bool gradientBackground() const;
  87. /// Return if rendering is enabled
  88. bool renderEnabled() const;
  89. virtual QSize minimumSizeHint()const;
  90. virtual QSize sizeHint()const;
  91. virtual bool hasHeightForWidth()const;
  92. virtual int heightForWidth(int width)const;
  93. protected:
  94. QScopedPointer<ctkVTKAbstractViewPrivate> d_ptr;
  95. ctkVTKAbstractView(ctkVTKAbstractViewPrivate* pimpl, QWidget* parent);
  96. private:
  97. Q_DECLARE_PRIVATE(ctkVTKAbstractView);
  98. Q_DISABLE_COPY(ctkVTKAbstractView);
  99. };
  100. #endif