ctkVTKPropertyWidget.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 __ctkVTKPropertyWidget_h
  15. #define __ctkVTKPropertyWidget_h
  16. // Qt includes
  17. #include <QWidget>
  18. // CTK includes
  19. #include "ctkColorPickerButton.h"
  20. #include "ctkVTKObject.h"
  21. #include "ctkVisualizationVTKWidgetsExport.h"
  22. class ctkVTKPropertyWidgetPrivate;
  23. class vtkProperty;
  24. /// \ingroup Visualization_VTK_Widgets
  25. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKPropertyWidget
  26. : public QWidget
  27. {
  28. Q_OBJECT;
  29. QVTK_OBJECT;
  30. typedef QWidget Superclass;
  31. Q_FLAGS(GroupsState)
  32. /// Show/Hide, expand/collapse groups in the widget.
  33. /// Groups are visible by default and Color is the only expanded group.
  34. /// \sa groupsState(), setGroupsState()
  35. Q_PROPERTY(GroupsState groupsState READ groupsState WRITE setGroupsState )
  36. /// This property controls the color dialog option of the Color and EdgeColor
  37. /// color picker buttons.
  38. /// Same default as ctkColorPickerbutton
  39. Q_PROPERTY(ctkColorPickerButton::ColorDialogOptions colorDialogOptions READ colorDialogOptions WRITE setColorDialogOptions)
  40. public:
  41. enum GroupState {
  42. RepresentationVisible = 0x00001,
  43. RepresentationCollapsed = 0x00002,
  44. ColorVisible = 0x00010,
  45. ColorCollapsed = 0x00020,
  46. LightingVisible = 0x00100,
  47. LightingCollapsed = 0x00200,
  48. MaterialVisible = 0x01000,
  49. MaterialCollapsed = 0x02000,
  50. AllVisible = RepresentationVisible | ColorVisible | LightingVisible | MaterialVisible,
  51. AllCollapsed = RepresentationCollapsed | ColorCollapsed | LightingCollapsed | MaterialCollapsed
  52. };
  53. Q_DECLARE_FLAGS(GroupsState, GroupState)
  54. /// Construct a ctkVTKPropertyWidget with a default vtkProperty.
  55. ctkVTKPropertyWidget(QWidget* parentWidget);
  56. /// Construct a ctkVTKPropertyWidget with the given vtkProperty.
  57. ctkVTKPropertyWidget(vtkProperty* property, QWidget* parentWidget);
  58. virtual ~ctkVTKPropertyWidget();
  59. vtkProperty* property()const;
  60. /// \sa groupsState, setGroupsState()
  61. ctkVTKPropertyWidget::GroupsState groupsState()const;
  62. /// \sa groupsState, groupsState()
  63. void setGroupsState(ctkVTKPropertyWidget::GroupsState state);
  64. /// \sa colorDialogOptions, setColorDialogOptions()
  65. ctkColorPickerButton::ColorDialogOptions colorDialogOptions()const;
  66. /// \sa colorDialogOptions, colorDialogOptions()
  67. void setColorDialogOptions(ctkColorPickerButton::ColorDialogOptions options);
  68. virtual int representation()const;
  69. virtual double pointSize()const;
  70. virtual double lineWidth()const;
  71. virtual bool frontfaceCulling()const;
  72. virtual bool backfaceCulling()const;
  73. virtual QColor color()const;
  74. virtual double opacity()const;
  75. virtual bool edgeVisibility()const;
  76. virtual QColor edgeColor()const;
  77. virtual bool lighting()const;
  78. virtual int interpolation()const;
  79. virtual bool shading()const;
  80. public Q_SLOTS:
  81. virtual void setProperty(vtkProperty* property);
  82. virtual void setRepresentation(int newRepresentation);
  83. virtual void setPointSize(double newPointSize);
  84. virtual void setLineWidth(double newLineWidth);
  85. virtual void setFrontfaceCulling(bool newFrontfaceCulling);
  86. virtual void setBackfaceCulling(bool newBackfaceCulling);
  87. virtual void setColor(const QColor& newColor);
  88. virtual void setOpacity(double newOpacity);
  89. virtual void setEdgeVisibility(bool newEdgeVisibility);
  90. virtual void setEdgeColor(const QColor& newColor);
  91. virtual void setLighting(bool newLighting);
  92. virtual void setInterpolation(int newInterpolation);
  93. virtual void setShading(bool newShading);
  94. protected Q_SLOTS:
  95. void updateWidgetFromProperty();
  96. protected:
  97. QScopedPointer<ctkVTKPropertyWidgetPrivate> d_ptr;
  98. private:
  99. Q_DECLARE_PRIVATE(ctkVTKPropertyWidget);
  100. Q_DISABLE_COPY(ctkVTKPropertyWidget);
  101. };
  102. Q_DECLARE_OPERATORS_FOR_FLAGS(ctkVTKPropertyWidget::GroupsState)
  103. #endif