ctkVTKDiscretizableColorTransferWidget.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. /// Set/Get the left axis mode.
  59. /// This controls the axis range computation.
  60. /// \see vtkScalarsToColorsHistogramChart::SetLeftAxisMode
  61. void setLeftAxisMode(int mode);
  62. int leftAxisMode();
  63. void setHistogramConnection(vtkAlgorithmOutput* input);
  64. void updateHistogram(bool updateDataRange);
  65. void setViewBackgroundColor(const QColor& i_color);
  66. QColor viewBackgroundColor() const;
  67. ctkVTKScalarsToColorsComboBox* scalarsToColorsSelector() const;
  68. void setVisibleRange(double min, double max);
  69. void resetVisibleRange(ResetVisibleRange resetMode);
  70. void resetVisibleRangeToCTF();
  71. void setColorTransferFunctionRange(double min, double max);
  72. void resetColorTransferFunctionRange(ResetCTFRange resetMode);
  73. void resetCTFRangeToVisible();
  74. void centerColorTransferFunctionRange();
  75. void setDataRange(double min, double max);
  76. void resetRangesToData();
  77. void clearUndoHistory();
  78. signals:
  79. void currentScalarsToColorsModified();
  80. void currentScalarsToColorsChanged(vtkDiscretizableColorTransferFunction* ctf);
  81. public slots:
  82. void onCurrentPointEdit();
  83. void onPaletteIndexChanged(vtkScalarsToColors* ctf);
  84. void onResetRangesButtonClick();
  85. void onShrinkRangeButtonClick();
  86. void onExpandRangeButtonClick();
  87. void onUndoButtonClick();
  88. void onRangeSliderValueChange(double min, double max);
  89. void invertColorTransferFunction();
  90. void setGlobalOpacity(double opacity);
  91. void setNaNColor();
  92. void setDiscretize(bool checked);
  93. void setNumberOfDiscreteValues(int value);
  94. protected:
  95. QScopedPointer<ctkVTKDiscretizableColorTransferWidgetPrivate> d_ptr;
  96. double* getColorTransferFunctionRange();
  97. double* getVisibleRange();
  98. double* getDataRange();
  99. void updateCtfWidgets();
  100. void disableCtfWidgets();
  101. void enableCtfWidgets();
  102. void updateHistogram();
  103. private:
  104. Q_DECLARE_PRIVATE(ctkVTKDiscretizableColorTransferWidget);
  105. Q_DISABLE_COPY(ctkVTKDiscretizableColorTransferWidget);
  106. };
  107. #endif // __ctkVTKDiscretizableColorTransferWidget_h