ctkVTKDiscretizableColorTransferWidget.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 __ctkVTKDiscretizableColorTransferWidget_h
  15. #define __ctkVTKDiscretizableColorTransferWidget_h
  16. // CTK includes
  17. #include "ctkVisualizationVTKWidgetsExport.h"
  18. class ctkVTKDiscretizableColorTransferWidgetPrivate;
  19. class ctkVTKScalarsToColorsComboBox;
  20. // VTK includes
  21. #include <vtkSmartPointer.h>
  22. class vtkAlgorithmOutput;
  23. class vtkDiscretizableColorTransferFunction;
  24. class vtkImageAccumulate;
  25. class vtkPiecewiseFunction;
  26. class vtkScalarsToColors;
  27. // Qt includes
  28. #include <QWidget>
  29. class QCheckBox;
  30. class QLineEdit;
  31. class QSpinBox;
  32. class QToolButton;
  33. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKDiscretizableColorTransferWidget: public QWidget
  34. {
  35. Q_OBJECT
  36. /// This property controls the color of the view.
  37. /// Dark gray by default.
  38. /// \accessors viewBackgroundColor() setViewBackgroundColor()
  39. Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor WRITE setViewBackgroundColor)
  40. public:
  41. explicit ctkVTKDiscretizableColorTransferWidget(QWidget* parent_ = CTK_NULLPTR);
  42. virtual ~ctkVTKDiscretizableColorTransferWidget();
  43. enum ResetVisibleRange
  44. {
  45. UNION_DATA_AND_CTF,
  46. UNION_DATA_AND_VISIBLE,
  47. ONLY_DATA,
  48. ONLY_CTF
  49. };
  50. enum ResetCTFRange
  51. {
  52. CTF,
  53. DATA,
  54. VISIBLE
  55. };
  56. void copyColorTransferFunction(vtkScalarsToColors* ctf, bool useCtfRange = false);
  57. vtkDiscretizableColorTransferFunction* discretizableColorTransferFunction() const;
  58. void setLeftAxisMode(int mode);
  59. void setHistogramConnection(vtkAlgorithmOutput* input);
  60. void updateHistogram(bool updateDataRange);
  61. void setViewBackgroundColor(const QColor& i_color);
  62. QColor viewBackgroundColor() const;
  63. ctkVTKScalarsToColorsComboBox* scalarsToColorsSelector() const;
  64. void resetVisibleRange(ResetVisibleRange resetMode);
  65. void resetColorTransferFunctionRange(ResetCTFRange resetMode);
  66. signals:
  67. void currentScalarsToColorsModified();
  68. void currentScalarsToColorsChanged(vtkDiscretizableColorTransferFunction* ctf);
  69. public slots:
  70. void onCurrentPointEdit();
  71. void onPaletteIndexChanged(vtkScalarsToColors* ctf);
  72. void setGlobalOpacity(double opacity);
  73. void resetVisibleRangeToCTF();
  74. void resetVisibleRangeToData();
  75. void resetColorTransferFunctionRange();
  76. void centerColorTransferFunctionRange();
  77. void invertColorTransferFunction();
  78. void setNaNColor();
  79. void setDiscretize(bool checked);
  80. void setNumberOfDiscreteValues(int value);
  81. void setColorTransferFunctionRange(double min, double max);
  82. void setVisibleRange(double min, double max);
  83. void setDataRange(double min, double max);
  84. protected:
  85. QScopedPointer<ctkVTKDiscretizableColorTransferWidgetPrivate> d_ptr;
  86. double* getColorTransferFunctionRange();
  87. double* getVisibleRange();
  88. double* getDataRange();
  89. void updateCtfWidgets();
  90. void disableCtfWidgets();
  91. void enableCtfWidgets();
  92. void updateHistogram();
  93. private:
  94. Q_DECLARE_PRIVATE(ctkVTKDiscretizableColorTransferWidget);
  95. Q_DISABLE_COPY(ctkVTKDiscretizableColorTransferWidget);
  96. };
  97. #endif // __ctkVTKDiscretizableColorTransferWidget_h