ctkVTKAbstractView.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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(bool renderEnabled READ renderEnabled WRITE setRenderEnabled)
  33. public:
  34. typedef QWidget Superclass;
  35. explicit ctkVTKAbstractView(QWidget* parent = 0);
  36. virtual ~ctkVTKAbstractView();
  37. public slots:
  38. /// If a render has already been scheduled, this called is a no-op
  39. void scheduleRender();
  40. /// Force a render even if a render is already ocurring
  41. void forceRender();
  42. /// Set background color
  43. virtual void setBackgroundColor(const QColor& newBackgroundColor) = 0;
  44. /// Enable/Disable rendering
  45. void setRenderEnabled(bool value);
  46. /// Set corner annotation \a text
  47. virtual void setCornerAnnotationText(const QString& text);
  48. public:
  49. /// Get underlying RenderWindow
  50. Q_INVOKABLE vtkRenderWindow* renderWindow()const;
  51. /// Set/Get window interactor
  52. Q_INVOKABLE vtkRenderWindowInteractor* interactor()const;
  53. virtual void setInteractor(vtkRenderWindowInteractor* interactor);
  54. /// Get current interactor style
  55. Q_INVOKABLE vtkInteractorObserver* interactorStyle()const;
  56. /// Get corner annotation \a text
  57. QString cornerAnnotationText() const;
  58. Q_INVOKABLE vtkCornerAnnotation* cornerAnnotation()const;
  59. /// Get the underlying QVTKWidget
  60. Q_INVOKABLE QVTKWidget * VTKWidget() const;
  61. /// Get background color
  62. virtual QColor backgroundColor() const = 0;
  63. /// Return if rendering is enabled
  64. bool renderEnabled() const;
  65. virtual QSize minimumSizeHint()const;
  66. virtual QSize sizeHint()const;
  67. virtual bool hasHeightForWidth()const;
  68. virtual int heightForWidth(int width)const;
  69. protected:
  70. QScopedPointer<ctkVTKAbstractViewPrivate> d_ptr;
  71. ctkVTKAbstractView(ctkVTKAbstractViewPrivate* pimpl, QWidget* parent);
  72. private:
  73. Q_DECLARE_PRIVATE(ctkVTKAbstractView);
  74. Q_DISABLE_COPY(ctkVTKAbstractView);
  75. };
  76. #endif