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