ctkVTKAbstractView.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 "ctkVisualizationVTKWidgetsExport.h"
  22. class ctkVTKAbstractViewPrivate;
  23. class vtkCornerAnnotation;
  24. class vtkInteractorObserver;
  25. class vtkRenderWindowInteractor;
  26. class vtkRenderWindow;
  27. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKAbstractView : public QWidget
  28. {
  29. Q_OBJECT
  30. Q_PROPERTY(QString cornerAnnotationText READ cornerAnnotationText WRITE setCornerAnnotationText)
  31. Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
  32. Q_PROPERTY(QColor backgroundColor2 READ backgroundColor2 WRITE setBackgroundColor)
  33. Q_PROPERTY(bool gradientBackground READ gradientBackground WRITE setGradientBackground)
  34. Q_PROPERTY(bool renderEnabled READ renderEnabled WRITE setRenderEnabled)
  35. public:
  36. typedef QWidget Superclass;
  37. explicit ctkVTKAbstractView(QWidget* parent = 0);
  38. virtual ~ctkVTKAbstractView();
  39. public slots:
  40. /// If a render has already been scheduled, this called is a no-op
  41. void scheduleRender();
  42. /// Force a render even if a render is already ocurring
  43. void forceRender();
  44. /// Set the background color of the rendering screen.
  45. virtual void setBackgroundColor(const QColor& newBackgroundColor);
  46. /// Set the second background color of the rendering screen for gradient
  47. /// backgrounds.
  48. virtual void setBackgroundColor2(const QColor& newBackgroundColor);
  49. /// Set/Get whether this view should have a gradient background using the
  50. /// Background (top) and Background2 (bottom) colors. Default is off.
  51. virtual void setGradientBackground(bool enable);
  52. /// Enable/Disable rendering
  53. void setRenderEnabled(bool value);
  54. /// Set corner annotation \a text
  55. virtual void setCornerAnnotationText(const QString& text);
  56. public:
  57. /// Get underlying RenderWindow
  58. Q_INVOKABLE vtkRenderWindow* renderWindow()const;
  59. /// Set/Get window interactor
  60. Q_INVOKABLE vtkRenderWindowInteractor* interactor()const;
  61. virtual void setInteractor(vtkRenderWindowInteractor* interactor);
  62. /// Get current interactor style
  63. Q_INVOKABLE vtkInteractorObserver* interactorStyle()const;
  64. /// Get corner annotation \a text
  65. QString cornerAnnotationText() const;
  66. Q_INVOKABLE vtkCornerAnnotation* cornerAnnotation()const;
  67. /// Get the underlying QVTKWidget
  68. Q_INVOKABLE QVTKWidget * VTKWidget() const;
  69. /// Get background color
  70. virtual QColor backgroundColor() const;
  71. /// Get the second background color
  72. virtual QColor backgroundColor2() const;
  73. /// Is the background a gradient
  74. virtual bool gradientBackground() const;
  75. /// Return if rendering is enabled
  76. bool renderEnabled() const;
  77. virtual QSize minimumSizeHint()const;
  78. virtual QSize sizeHint()const;
  79. virtual bool hasHeightForWidth()const;
  80. virtual int heightForWidth(int width)const;
  81. protected:
  82. QScopedPointer<ctkVTKAbstractViewPrivate> d_ptr;
  83. ctkVTKAbstractView(ctkVTKAbstractViewPrivate* pimpl, QWidget* parent);
  84. private:
  85. Q_DECLARE_PRIVATE(ctkVTKAbstractView);
  86. Q_DISABLE_COPY(ctkVTKAbstractView);
  87. };
  88. #endif