Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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-2013 UJF-Grenoble 1, 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 using namespace std;
53 
54 
55 // -- Core image component stuff classes
56 #include <ImageComponent.h>
57 // -- Core stuff classes
58 class InteractiveViewer;
59 
60 using namespace camitk;
61 
62 
63 //***************************************************************************
64 
72 class ImageLutWidget : public QWidget {
73  Q_OBJECT
74 
75 public:
77  ImageLutWidget(QWidget* parent = 0);
78 
80  ~ImageLutWidget();
81 
83  void updateComponent(ImageComponent *);
84 
85 private slots:
86 
88  void sliderLUTLevelChanged(int);
89 
91  void lineEditLUTLevelChanged();
92 
94  void sliderLUTWindowChanged(int);
95 
97  void lineEditLUTWindowChanged();
98 
100  void invertButtonClicked();
101 
103  void setMinColor();
104 
106  void setMaxColor();
107 
109  virtual void resetLUT();
110 
112  void applyLUT();
113 
114 protected:
115 
117  virtual void resizeEvent(QResizeEvent *);
118 
120  virtual void showEvent(QShowEvent *);
121 
122 private:
123 
125  void initLevelGUI(int min, int max, int value);
126 
128  void initWindowGUI(int min, int max, int value);
129 
131  void initSlider(QSlider *slider, int min, int max, int value);
132 
134  void blockAllSignals(bool);
135 
137  void draw();
138 
140  void fitView();
141 
143  template<class DATATYPE> void fillHistogramTable(DATATYPE * data, unsigned int dataDim, DATATYPE minVal, DATATYPE maxVal);
144 
146  void updateGradient();
147 
150 
152  double lutMin;
153 
155  double lutMax;
156 
158  unsigned int * greyLevels;
159 
161  unsigned int highestGreyLevel;
162 
165 
167  bool invert;
168 
170  QGraphicsRectItem * sceneRectItem;
171 
173  Ui::ui_ImageLutWidget ui;
174 
175 };
176 
177 #endif