CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkVTKDiscretizableColorTransferWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkVTKDiscretizableColorTransferWidget_h
22 #define __ctkVTKDiscretizableColorTransferWidget_h
23 
24 // CTK includes
25 #include "ctkVisualizationVTKWidgetsExport.h"
26 class ctkVTKDiscretizableColorTransferWidgetPrivate;
28 
29 // VTK includes
30 #include <vtkSmartPointer.h>
31 class vtkAlgorithmOutput;
32 class vtkDiscretizableColorTransferFunction;
33 class vtkImageAccumulate;
34 class vtkPiecewiseFunction;
35 class vtkScalarsToColors;
36 
37 // Qt includes
38 #include <QWidget>
39 class QCheckBox;
40 class QLineEdit;
41 class QSpinBox;
42 class QToolButton;
43 
44 class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKDiscretizableColorTransferWidget: public QWidget
45 {
46  Q_OBJECT
50  Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor WRITE setViewBackgroundColor)
51 public:
52  explicit ctkVTKDiscretizableColorTransferWidget(QWidget* parent_ = CTK_NULLPTR);
54 
56  {
60  ONLY_CTF
61  };
62 
64  {
65  CTF,
67  VISIBLE
68  };
69 
70  void copyColorTransferFunction(vtkScalarsToColors* ctf, bool useCtfRange = false);
71  vtkDiscretizableColorTransferFunction* discretizableColorTransferFunction() const;
72 
76  void setLeftAxisMode(int mode);
77  int leftAxisMode();
78 
79  void setHistogramConnection(vtkAlgorithmOutput* input);
80  void updateHistogram(bool updateDataRange);
81 
82  void setViewBackgroundColor(const QColor& i_color);
83  QColor viewBackgroundColor() const;
84 
85  ctkVTKScalarsToColorsComboBox* scalarsToColorsSelector() const;
86 
87  void setVisibleRange(double min, double max);
88  void resetVisibleRange(ResetVisibleRange resetMode);
89  void resetVisibleRangeToCTF();
90 
91  void setColorTransferFunctionRange(double min, double max);
92  void resetColorTransferFunctionRange(ResetCTFRange resetMode);
93  void resetCTFRangeToVisible();
94  void centerColorTransferFunctionRange();
95 
96  void setDataRange(double min, double max);
97  void resetRangesToData();
98 
99  void clearUndoHistory();
100 
101 signals:
102  void currentScalarsToColorsModified();
103  void currentScalarsToColorsChanged(vtkDiscretizableColorTransferFunction* ctf);
104 
105 public slots:
106  void onCurrentPointEdit();
107  void onPaletteIndexChanged(vtkScalarsToColors* ctf);
108  void onResetRangesButtonClick();
109  void onShrinkRangeButtonClick();
110  void onExpandRangeButtonClick();
111  void onUndoButtonClick();
112  void onRangeSliderValueChange(double min, double max);
113 
114  void invertColorTransferFunction();
115  void setGlobalOpacity(double opacity);
116  void setNaNColor();
117  void setDiscretize(bool checked);
118  void setNumberOfDiscreteValues(int value);
119 
120 protected:
121  QScopedPointer<ctkVTKDiscretizableColorTransferWidgetPrivate> d_ptr;
122 
123  double* getColorTransferFunctionRange();
124  double* getVisibleRange();
125  double* getDataRange();
126  void updateCtfWidgets();
127  void disableCtfWidgets();
128  void enableCtfWidgets();
129  void updateHistogram();
130 
131 private:
132  Q_DECLARE_PRIVATE(ctkVTKDiscretizableColorTransferWidget);
134 };
135 #endif // __ctkVTKDiscretizableColorTransferWidget_h
QScopedPointer< ctkVTKDiscretizableColorTransferWidgetPrivate > d_ptr