ctkVTKVolumePropertyWidget.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKVolumePropertyWidget
  25. : public QWidget
  26. {
  27. Q_OBJECT
  28. QVTK_OBJECT
  29. ///
  30. /// Control wether a range slider widget is used to edit the opacity
  31. /// function instead of a chart editor. False by default
  32. Q_PROPERTY(bool thresholdVisibility READ isThresholdVisible WRITE showThreshold)
  33. ///
  34. /// Show or hide the opacity threshold slider toggle button.
  35. /// True by default.
  36. Q_PROPERTY(bool thresholdVisibilityToggle READ hasThresholdVisibilityToggle WRITE setThresholdVisibilityToggle)
  37. public:
  38. ctkVTKVolumePropertyWidget(QWidget* parent = 0);
  39. virtual ~ctkVTKVolumePropertyWidget();
  40. vtkVolumeProperty* volumeProperty()const;
  41. bool isThresholdVisible()const;
  42. bool hasThresholdVisibilityToggle()const;
  43. void setThresholdVisibilityToggle(bool showToggle);
  44. public slots:
  45. void setVolumeProperty(vtkVolumeProperty* volumeProperty);
  46. /// Move all the control points of the opacity, colors and gradient
  47. /// of a give offset.
  48. /// \sa vtkControlPoints::movePoints()
  49. void moveAllPoints(double xOffset, double yOffset = 0.);
  50. /// Spread all the control points of the opacity, colors and gradient
  51. /// by a given offset.
  52. /// A value >0 will space the control points, a value <0. will contract
  53. /// them.
  54. /// \sa vtkControlPoints::spreadPoints()
  55. void spreadAllPoints(double factor = 1.);
  56. void showThreshold(bool enable);
  57. protected slots:
  58. void updateFromVolumeProperty();
  59. void setInterpolationMode(int mode);
  60. void setShade(bool);
  61. void setAmbient(double value);
  62. void setDiffuse(double value);
  63. void setSpecular(double value);
  64. void setSpecularPower(double value);
  65. void onThresholdOpacityToggled(bool);
  66. /// Called whenever a view (opacity, colors or gradient) has one of its axis
  67. /// modified. It synchronize all the views to see the same.
  68. void onAxesModified();
  69. protected:
  70. QScopedPointer<ctkVTKVolumePropertyWidgetPrivate> d_ptr;
  71. private:
  72. Q_DECLARE_PRIVATE(ctkVTKVolumePropertyWidget);
  73. Q_DISABLE_COPY(ctkVTKVolumePropertyWidget);
  74. };
  75. #endif