]> Creatis software - clitk.git/blob - vv/vvOverlayPanel.cxx
Reformatted using new coding style
[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     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   } else {
73     vFFrame->hide();
74     vFFrame->setEnabled(0);
75     subSamplingSpinBox->setEnabled(0);
76     subSamplingSpinBox->setValue(0);
77     scaleSpinBox->setEnabled(0);
78     scaleSpinBox->setValue(0);
79     lutCheckBox->setEnabled(0);
80     lutCheckBox->setCheckState(Qt::Unchecked);
81   }
82 }
83
84 void vvOverlayPanel::getVFName(QString name)
85 {
86   QString filename = "<b>Deformation Field : </b>";
87   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
88   vectorFieldNameLabel->setText(filename.toStdString().c_str());
89 }
90
91 void vvOverlayPanel::setVFProperty()
92 {
93   emit VFPropertyUpdated(subSamplingSpinBox->value(),
94                          scaleSpinBox->value(),
95                          lutCheckBox->checkState(),
96                          vfWidthSpinBox->value());
97 }
98
99 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
100 {
101   QString motion = "<b>Displacement : </b>";
102   QString motionValue = "<b>Length : </b>";
103   if (visibility) {
104     motion += QString::number(x,'f',1) + " ";
105     motion += QString::number(y,'f',1) + " ";
106     motion += QString::number(z,'f',1) + " ";
107
108     motionValue += QString::number(value,'f',1);
109   }
110   coordinatesLabel->setText(motion);
111   normLabel->setText(motionValue);
112 }
113
114 void vvOverlayPanel::getOverlayName(QString name)
115 {
116   QString filename = "<b>Compare with : </b>";
117   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
118   imageComparedLabel->setText(filename.toStdString().c_str());
119 }
120
121 void vvOverlayPanel::getOverlayProperty(int value)
122 {
123   if (value > -1) {
124     compareFrame->show();
125     compareFrame->setEnabled(1);
126     colorHorizontalSlider->setEnabled(1);
127     colorHorizontalSlider->setValue(value);
128   } else {
129     compareFrame->hide();
130     compareFrame->setEnabled(0);
131     colorHorizontalSlider->setEnabled(0);
132     colorHorizontalSlider->setValue(0);
133   }
134 }
135
136 void vvOverlayPanel::setOverlayProperty()
137 {
138   emit OverlayPropertyUpdated(colorHorizontalSlider->value());
139 }
140
141 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
142 {
143   QString refValue = "<b>Pixel value in image 1 : </b>";
144   QString overlayValue = "<b>Pixel value in image 2 : </b>";
145   QString diffValue = "<b>Pixel difference : </b>";
146   if (visibility) {
147     refValue += QString::number(valueRef);
148     overlayValue += QString::number(valueOver,'f',1);
149     diffValue += QString::number(valueRef - valueOver,'f',1);
150   }
151   refValueLabel->setText(refValue);
152   valueLabel->setText(overlayValue);
153   diffValueLabel->setText(diffValue);
154 }
155 void vvOverlayPanel::getFusionName(QString name)
156 {
157   QString filename = "<b>Fusion with : </b>";
158   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
159   dataFusionnedLabel->setText(filename.toStdString().c_str());
160 }
161
162 void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, double level)
163 {
164   if (opacity > -1) {
165     fusionFrame->show();
166     fusionFrame->setEnabled(1);
167     opacityHorizontalSlider->setEnabled(1);
168     opacityHorizontalSlider->setValue(opacity);
169     fusionColorMapComboBox->setEnabled(1);
170     fusionColorMapComboBox->setCurrentIndex(colormap);
171     windowSpinBox->setEnabled(1);
172     levelSpinBox->setEnabled(1);
173     windowSpinBox->setValue(window);
174     levelSpinBox->setValue(level);
175   } else {
176     fusionFrame->hide();
177     fusionFrame->setEnabled(0);
178     opacityHorizontalSlider->setEnabled(0);
179     opacityHorizontalSlider->setValue(0);
180     fusionColorMapComboBox->setEnabled(0);
181     fusionColorMapComboBox->setCurrentIndex(-1);
182     windowSpinBox->setEnabled(0);
183     levelSpinBox->setEnabled(0);
184   }
185 }
186
187 void vvOverlayPanel::setFusionProperty()
188 {
189   emit FusionPropertyUpdated(opacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
190                              windowSpinBox->value(), levelSpinBox->value());
191 }
192
193 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
194 {
195   QString fusionValue = "<b>Pixel value in image 2 : </b>";
196   if (visibility) {
197     fusionValue += QString::number(value,'f',1);
198   }
199   valueFusionnedLabel->setText(fusionValue);
200 }
201
202 #endif /* end #define _vvOverlayPanel_CXX */
203