]> Creatis software - clitk.git/blob - vv/vvOverlayPanel.cxx
allow the user to change the width of VF arrows
[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(vfWidthSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
44     connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty()));
45     connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
46     connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
47     connect(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
48     connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
49 }
50
51 void vvOverlayPanel::getCurrentImageName(QString name)
52 {
53     QString filename = "<b>Current image : </b>";
54     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
55     currentImageLabel->setText(filename.toStdString().c_str());
56 }
57
58 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
59 {
60     if (subsampling != -1)
61     {
62         vFFrame->show();
63         vFFrame->setEnabled(1);
64         subSamplingSpinBox->setEnabled(1);
65         subSamplingSpinBox->setValue(subsampling);
66         scaleSpinBox->setEnabled(1);
67         scaleSpinBox->setValue(scale);
68         lutCheckBox->setEnabled(1);
69         if (log > 0)
70             lutCheckBox->setCheckState(Qt::Checked);
71         else
72             lutCheckBox->setCheckState(Qt::Unchecked);
73     }
74     else
75     {
76         vFFrame->hide();
77         vFFrame->setEnabled(0);
78         subSamplingSpinBox->setEnabled(0);
79         subSamplingSpinBox->setValue(0);
80         scaleSpinBox->setEnabled(0);
81         scaleSpinBox->setValue(0);
82         lutCheckBox->setEnabled(0);
83         lutCheckBox->setCheckState(Qt::Unchecked);
84     }
85 }
86
87 void vvOverlayPanel::getVFName(QString name)
88 {
89     QString filename = "<b>Deformation Field : </b>";
90     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
91     vectorFieldNameLabel->setText(filename.toStdString().c_str());
92 }
93
94 void vvOverlayPanel::setVFProperty()
95 {
96     emit VFPropertyUpdated(subSamplingSpinBox->value(),
97                            scaleSpinBox->value(),
98                            lutCheckBox->checkState(),
99                            vfWidthSpinBox->value());
100 }
101
102 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
103 {
104     QString motion = "<b>Displacement : </b>";
105     QString motionValue = "<b>Length : </b>";
106     if (visibility)
107     {
108         motion += QString::number(x,'f',1) + " ";
109         motion += QString::number(y,'f',1) + " ";
110         motion += QString::number(z,'f',1) + " ";
111
112         motionValue += QString::number(value,'f',1);
113     }
114     coordinatesLabel->setText(motion);
115     normLabel->setText(motionValue);
116 }
117
118 void vvOverlayPanel::getOverlayName(QString name)
119 {
120     QString filename = "<b>Compare with : </b>";
121     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
122     imageComparedLabel->setText(filename.toStdString().c_str());
123 }
124
125 void vvOverlayPanel::getOverlayProperty(int value)
126 {
127     if (value > -1)
128     {
129         compareFrame->show();
130         compareFrame->setEnabled(1);
131         colorHorizontalSlider->setEnabled(1);
132         colorHorizontalSlider->setValue(value);
133     }
134     else
135     {
136         compareFrame->hide();
137         compareFrame->setEnabled(0);
138         colorHorizontalSlider->setEnabled(0);
139         colorHorizontalSlider->setValue(0);
140     }
141 }
142
143 void vvOverlayPanel::setOverlayProperty()
144 {
145     emit OverlayPropertyUpdated(colorHorizontalSlider->value());
146 }
147
148 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
149 {
150     QString refValue = "<b>Pixel value in image 1 : </b>";
151     QString overlayValue = "<b>Pixel value in image 2 : </b>";
152     QString diffValue = "<b>Pixel difference : </b>";
153     if (visibility)
154     {
155         refValue += QString::number(valueRef);
156         overlayValue += QString::number(valueOver,'f',1);
157         diffValue += QString::number(valueRef - valueOver,'f',1);
158     }
159     refValueLabel->setText(refValue);
160     valueLabel->setText(overlayValue);
161     diffValueLabel->setText(diffValue);
162 }
163 void vvOverlayPanel::getFusionName(QString name)
164 {
165     QString filename = "<b>Fusion with : </b>";
166     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
167     dataFusionnedLabel->setText(filename.toStdString().c_str());
168 }
169
170 void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, double level)
171 {
172     if (opacity > -1)
173     {
174         fusionFrame->show();
175         fusionFrame->setEnabled(1);
176         opacityHorizontalSlider->setEnabled(1);
177         opacityHorizontalSlider->setValue(opacity);
178         fusionColorMapComboBox->setEnabled(1);
179         fusionColorMapComboBox->setCurrentIndex(colormap);
180         windowSpinBox->setEnabled(1);
181         levelSpinBox->setEnabled(1);
182         windowSpinBox->setValue(window);
183         levelSpinBox->setValue(level);
184     }
185     else
186     {
187         fusionFrame->hide();
188         fusionFrame->setEnabled(0);
189         opacityHorizontalSlider->setEnabled(0);
190         opacityHorizontalSlider->setValue(0);
191         fusionColorMapComboBox->setEnabled(0);
192         fusionColorMapComboBox->setCurrentIndex(-1);
193         windowSpinBox->setEnabled(0);
194         levelSpinBox->setEnabled(0);
195     }
196 }
197
198 void vvOverlayPanel::setFusionProperty()
199 {
200     emit FusionPropertyUpdated(opacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
201                                windowSpinBox->value(), levelSpinBox->value());
202 }
203
204 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
205 {
206     QString fusionValue = "<b>Pixel value in image 2 : </b>";
207     if (visibility)
208     {
209         fusionValue += QString::number(value,'f',1);
210     }
211     valueFusionnedLabel->setText(fusionValue);
212 }
213
214 #endif /* end #define _vvOverlayPanel_CXX */
215