]> Creatis software - clitk.git/blob - vv/vvOverlayPanel.cxx
added the new headers
[clitk.git] / vv / vvOverlayPanel.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef _vvOverlayPanel_CXX
19 #define _vvOverlayPanel_CXX
20 #include "vvOverlayPanel.h"
21
22 #include <QtGui>
23 #include <Qt>
24 #include "QTreePushButton.h"
25
26 #include <vtksys/SystemTools.hxx>
27
28 //====================================================================
29 vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent)
30 {
31     setupUi(this);
32
33     vFFrame->hide();
34     compareFrame->hide();
35     fusionFrame->hide();
36     subSamplingSpinBox->setEnabled(0);
37     scaleSpinBox->setEnabled(0);
38     lutCheckBox->hide();
39     lutCheckBox->setEnabled(0);
40     connect(subSamplingSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
41     connect(scaleSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
42     connect(lutCheckBox,SIGNAL(clicked()),this,SLOT(setVFProperty()));
43     connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty()));
44     connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
45     connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
46     connect(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
47     connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
48 }
49
50 void vvOverlayPanel::getCurrentImageName(QString name)
51 {
52     QString filename = "<b>Current image : </b>";
53     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
54     currentImageLabel->setText(filename.toStdString().c_str());
55 }
56
57 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
58 {
59     if (subsampling != -1)
60     {
61         vFFrame->show();
62         vFFrame->setEnabled(1);
63         subSamplingSpinBox->setEnabled(1);
64         subSamplingSpinBox->setValue(subsampling);
65         scaleSpinBox->setEnabled(1);
66         scaleSpinBox->setValue(scale);
67         lutCheckBox->setEnabled(1);
68         if (log > 0)
69             lutCheckBox->setCheckState(Qt::Checked);
70         else
71             lutCheckBox->setCheckState(Qt::Unchecked);
72     }
73     else
74     {
75         vFFrame->hide();
76         vFFrame->setEnabled(0);
77         subSamplingSpinBox->setEnabled(0);
78         subSamplingSpinBox->setValue(0);
79         scaleSpinBox->setEnabled(0);
80         scaleSpinBox->setValue(0);
81         lutCheckBox->setEnabled(0);
82         lutCheckBox->setCheckState(Qt::Unchecked);
83     }
84 }
85
86 void vvOverlayPanel::getVFName(QString name)
87 {
88     QString filename = "<b>Deformation Field : </b>";
89     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
90     vectorFieldNameLabel->setText(filename.toStdString().c_str());
91 }
92
93 void vvOverlayPanel::setVFProperty()
94 {
95     emit VFPropertyUpdated(subSamplingSpinBox->value(),
96                            scaleSpinBox->value(),
97                            lutCheckBox->checkState());
98 }
99
100 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
101 {
102     QString motion = "<b>Displacement : </b>";
103     QString motionValue = "<b>Length : </b>";
104     if (visibility)
105     {
106         motion += QString::number(x,'f',1) + " ";
107         motion += QString::number(y,'f',1) + " ";
108         motion += QString::number(z,'f',1) + " ";
109
110         motionValue += QString::number(value,'f',1);
111     }
112     coordinatesLabel->setText(motion);
113     normLabel->setText(motionValue);
114 }
115
116 void vvOverlayPanel::getOverlayName(QString name)
117 {
118     QString filename = "<b>Compare with : </b>";
119     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
120     imageComparedLabel->setText(filename.toStdString().c_str());
121 }
122
123 void vvOverlayPanel::getOverlayProperty(int value)
124 {
125     if (value > -1)
126     {
127         compareFrame->show();
128         compareFrame->setEnabled(1);
129         colorHorizontalSlider->setEnabled(1);
130         colorHorizontalSlider->setValue(value);
131     }
132     else
133     {
134         compareFrame->hide();
135         compareFrame->setEnabled(0);
136         colorHorizontalSlider->setEnabled(0);
137         colorHorizontalSlider->setValue(0);
138     }
139 }
140
141 void vvOverlayPanel::setOverlayProperty()
142 {
143     emit OverlayPropertyUpdated(colorHorizontalSlider->value());
144 }
145
146 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
147 {
148     QString refValue = "<b>Pixel value in image 1 : </b>";
149     QString overlayValue = "<b>Pixel value in image 2 : </b>";
150     QString diffValue = "<b>Pixel difference : </b>";
151     if (visibility)
152     {
153         refValue += QString::number(valueRef);
154         overlayValue += QString::number(valueOver,'f',1);
155         diffValue += QString::number(valueRef - valueOver,'f',1);
156     }
157     refValueLabel->setText(refValue);
158     valueLabel->setText(overlayValue);
159     diffValueLabel->setText(diffValue);
160 }
161 void vvOverlayPanel::getFusionName(QString name)
162 {
163     QString filename = "<b>Fusion with : </b>";
164     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
165     dataFusionnedLabel->setText(filename.toStdString().c_str());
166 }
167
168 void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, double level)
169 {
170     if (opacity > -1)
171     {
172         fusionFrame->show();
173         fusionFrame->setEnabled(1);
174         opacityHorizontalSlider->setEnabled(1);
175         opacityHorizontalSlider->setValue(opacity);
176         fusionColorMapComboBox->setEnabled(1);
177         fusionColorMapComboBox->setCurrentIndex(colormap);
178         windowSpinBox->setEnabled(1);
179         levelSpinBox->setEnabled(1);
180         windowSpinBox->setValue(window);
181         levelSpinBox->setValue(level);
182     }
183     else
184     {
185         fusionFrame->hide();
186         fusionFrame->setEnabled(0);
187         opacityHorizontalSlider->setEnabled(0);
188         opacityHorizontalSlider->setValue(0);
189         fusionColorMapComboBox->setEnabled(0);
190         fusionColorMapComboBox->setCurrentIndex(-1);
191         windowSpinBox->setEnabled(0);
192         levelSpinBox->setEnabled(0);
193     }
194 }
195
196 void vvOverlayPanel::setFusionProperty()
197 {
198     emit FusionPropertyUpdated(opacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
199                                windowSpinBox->value(), levelSpinBox->value());
200 }
201
202 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
203 {
204     QString fusionValue = "<b>Pixel value in image 2 : </b>";
205     if (visibility)
206     {
207         fusionValue += QString::number(value,'f',1);
208     }
209     valueFusionnedLabel->setText(fusionValue);
210 }
211
212 #endif /* end #define _vvOverlayPanel_CXX */
213