Computer Assited Medical Intervention Tool Kit  version 4.1
ImageLutWidget.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 
27 #ifndef ImageLutWidget_H
28 #define ImageLutWidget_H
29 
30 // -- stl stuff
31 #include <string>
32 #include <fstream>
33 #include <vector>
34 #include <sstream>
35 
36 // -- QT stuff
37 #include <QListWidget>
38 #include <QLineEdit>
39 #include <QCheckBox>
40 #include <QMap>
41 #include <QPushButton>
42 #include <QGraphicsView>
43 #include <QGraphicsSimpleTextItem>
44 
45 // -- vtk stuff
46 #include <vtkWindowLevelLookupTable.h>
47 #include <vtkSmartPointer.h>
48 
49 // -- Camitk stuff
50 #include "ui_ImageLutWidget.h"
51 
52 // -- Core image component stuff classes
53 #include <ImageComponent.h>
54 
66 class ImageLutWidget : public QWidget {
67  Q_OBJECT
68 
69 public:
71  ImageLutWidget(QWidget* parent = nullptr);
72 
74  ~ImageLutWidget() override;
75 
78 
79 private slots:
80 
82  void sliderLUTLevelChanged(int);
83 
86 
88  void sliderLUTWindowChanged(int);
89 
92 
94  void invertButtonClicked();
95 
97  void setMinColor();
98 
100  void setMaxColor();
101 
103  virtual void resetLUT();
104 
106  void applyLUT();
107 
108 protected:
109 
111  void resizeEvent(QResizeEvent*) override;
112 
114  void showEvent(QShowEvent*) override;
115 
116 private:
117 
119  void initLevelGUI(int min, int max, int value);
120 
122  void initWindowGUI(int min, int max, int value);
123 
125  void initSlider(QSlider* slider, int min, int max, int value);
126 
128  void blockAllSignals(bool);
129 
131  void draw();
132 
134  void fitView();
135 
137  template<class DATATYPE> void fillHistogramTable(DATATYPE* data, unsigned int dataDim, DATATYPE minVal, DATATYPE maxVal);
138 
140  void updateGradient();
141 
144 
146  double lutMin;
147 
149  double lutMax;
150 
152  double* greyLevels;
153 
156 
158  unsigned int nbHistoBins;
159 
161  bool invert;
162 
164  QGraphicsRectItem* sceneRectItem;
165 
167  Ui::ui_ImageLutWidget ui;
168 
169 };
170 
171 #endif
double lutMin
Min the possible data value (given by the data type of the image)
Definition: ImageLutWidget.h:146
void lineEditLUTWindowChanged()
Slot called when the line edit for the window width has changed.
Definition: ImageLutWidget.cpp:479
void fillHistogramTable(DATATYPE *data, unsigned int dataDim, DATATYPE minVal, DATATYPE maxVal)
fill the data for the histogram
Definition: ImageLutWidget.cpp:367
void initLevelGUI(int min, int max, int value)
Init level slider and text with its minimum, maximum and current value.
Definition: ImageLutWidget.cpp:416
void applyLUT()
Update the component LUT using the GUI values.
Definition: ImageLutWidget.cpp:163
ImageLutWidget(QWidget *parent=nullptr)
Default construtor.
Definition: ImageLutWidget.cpp:48
unsigned int nbHistoBins
size of greyLevels
Definition: ImageLutWidget.h:158
virtual void resetLUT()
Slot that reset changed applied to the LUT.
Definition: ImageLutWidget.cpp:197
void setMinColor()
slot called when the min color button is clicked
Definition: ImageLutWidget.cpp:528
void showEvent(QShowEvent *) override
overwritten from QWidget to ensure fit in view, see fitView()
Definition: ImageLutWidget.cpp:404
void resizeEvent(QResizeEvent *) override
overwritten from QWidget to ensure fit in view, see fitView()
Definition: ImageLutWidget.cpp:399
void sliderLUTLevelChanged(int)
Slot called when the slider for the lut level has changed.
Definition: ImageLutWidget.cpp:457
void draw()
draws the histogram and LUT graphic representation
Definition: ImageLutWidget.cpp:216
Ui::ui_ImageLutWidget ui
the Qt GUI (build by ImageLutWidget.ui)
Definition: ImageLutWidget.h:167
void sliderLUTWindowChanged(int)
Slot called when the slider for the window width has changed.
Definition: ImageLutWidget.cpp:468
void updateComponent(camitk::ImageComponent *)
load the LUT data using the LUT from the image component
Definition: ImageLutWidget.cpp:90
The manager of the Image Volume data.
Definition: ImageComponent.h:73
bool invert
does the user asked for an invert LUT
Definition: ImageLutWidget.h:161
void fitView()
ensure that all graphics are completely visible and only that
Definition: ImageLutWidget.cpp:409
camitk::ImageComponent * myComponent
the current ImageComponent
Definition: ImageLutWidget.h:143
void updateGradient()
update the gradient display in the widget
Definition: ImageLutWidget.cpp:502
The class ImageLutWidget defines a widget controling the Look Up Table of an instance of ImageCompone...
Definition: ImageLutWidget.h:66
double lutMax
Min the possible data value (given by the data type of the image)
Definition: ImageLutWidget.h:149
double * greyLevels
Table containing histogram bins.
Definition: ImageLutWidget.h:152
void setMaxColor()
slot called when the max color button is clicked
Definition: ImageLutWidget.cpp:518
void blockAllSignals(bool)
block/unblock signals for all the GUI widgets
Definition: ImageLutWidget.cpp:538
QGraphicsRectItem * sceneRectItem
the graphics item around all other item in the graphics view
Definition: ImageLutWidget.h:164
void initSlider(QSlider *slider, int min, int max, int value)
init a slider
Definition: ImageLutWidget.cpp:434
void invertButtonClicked()
Slot called when the invert button is clicked.
Definition: ImageLutWidget.cpp:490
void lineEditLUTLevelChanged()
Slot called when the line edit for the lut level has changed.
Definition: ImageLutWidget.cpp:446
double highestGreyLevel
highest number of grey level (highest value in greyLevels array)
Definition: ImageLutWidget.h:155
~ImageLutWidget() override
destructor
Definition: ImageLutWidget.cpp:85
void initWindowGUI(int min, int max, int value)
Init window slider and text with its minimum, maximum and current value.
Definition: ImageLutWidget.cpp:425