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