ctkVTKAbstractView.h 4.3 KB

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