ctkVTKVolumePropertyWidget.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 __ctkVTKVolumePropertyWidget_h
  15. #define __ctkVTKVolumePropertyWidget_h
  16. //Qt includes
  17. #include <QWidget>
  18. // CTK includes
  19. #include <ctkVTKObject.h>
  20. #include "ctkVisualizationVTKWidgetsExport.h"
  21. class ctkVTKVolumePropertyWidgetPrivate;
  22. // VTK includes
  23. class vtkVolumeProperty;
  24. /// \ingroup Visualization_VTK_Widgets
  25. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKVolumePropertyWidget
  26. : public QWidget
  27. {
  28. Q_OBJECT
  29. QVTK_OBJECT
  30. ///
  31. /// Control whether a range slider widget is used to edit the opacity
  32. /// function instead of a chart editor. False by default
  33. Q_PROPERTY(bool thresholdEnabled READ isThresholdEnabled WRITE setThresholdEnabled NOTIFY thresholdEnabledChanged)
  34. ///
  35. /// Show or hide the opacity threshold slider toggle button.
  36. /// True by default.
  37. Q_PROPERTY(bool thresholdToggleVisibility READ isThresholdToggleVisible WRITE setThresholdToggleVisible)
  38. public:
  39. ctkVTKVolumePropertyWidget(QWidget* parent = 0);
  40. virtual ~ctkVTKVolumePropertyWidget();
  41. vtkVolumeProperty* volumeProperty()const;
  42. bool isThresholdEnabled()const;
  43. bool isThresholdToggleVisible()const;
  44. void setThresholdToggleVisible(bool showToggle);
  45. void chartsBounds(double bounds[4])const;
  46. Q_INVOKABLE QList<double> chartsBounds()const;
  47. void chartsExtent(double extent[4])const;
  48. Q_INVOKABLE QList<double> chartsExtent()const;
  49. public Q_SLOTS:
  50. void setVolumeProperty(vtkVolumeProperty* volumeProperty);
  51. /// Move all the control points of the opacity, colors and gradient
  52. /// of a give offset.
  53. /// \sa vtkControlPoints::movePoints()
  54. void moveAllPoints(double xOffset, double yOffset = 0.,
  55. bool dontSpreadFirstAndLast = false);
  56. /// Spread all the control points of the opacity, colors and gradient
  57. /// by a given offset.
  58. /// A value >0 will space the control points, a value <0. will contract
  59. /// them.
  60. /// \sa vtkControlPoints::spreadPoints()
  61. void spreadAllPoints(double factor = 1.,
  62. bool dontSpreadFirstAndLast = false);
  63. void setThresholdEnabled(bool enable);
  64. /// Set chart extent
  65. void setChartsExtent(double extent[2]);
  66. void setChartsExtent(double min, double max);
  67. Q_SIGNALS:
  68. void thresholdEnabledChanged(bool enable);
  69. void chartsExtentChanged();
  70. protected Q_SLOTS:
  71. void updateFromVolumeProperty();
  72. void updateRange();
  73. void setInterpolationMode(int mode);
  74. void setShade(bool);
  75. void setAmbient(double value);
  76. void setDiffuse(double value);
  77. void setSpecular(double value);
  78. void setSpecularPower(double value);
  79. void onThresholdOpacityToggled(bool);
  80. /// Called whenever a view (opacity, colors or gradient) has one of its axis
  81. /// modified. It synchronize all the views to see the same.
  82. void onAxesModified();
  83. protected:
  84. QScopedPointer<ctkVTKVolumePropertyWidgetPrivate> d_ptr;
  85. private:
  86. Q_DECLARE_PRIVATE(ctkVTKVolumePropertyWidget);
  87. Q_DISABLE_COPY(ctkVTKVolumePropertyWidget);
  88. };
  89. #endif