1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
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.
13 It is distributed under dual licence
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"
24 #include "QTreePushButton.h"
25 #include <QColorDialog>
27 #include <vtksys/SystemTools.hxx>
29 //====================================================================
30 vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent)
37 subSamplingSpinBox->setEnabled(0);
38 scaleSpinBox->setEnabled(0);
40 lutCheckBox->setEnabled(0);
41 fusionShowLegendCheckBox->setChecked(false);
43 connect(subSamplingSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
44 connect(scaleSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
45 connect(lutCheckBox,SIGNAL(clicked()),this,SLOT(setVFProperty()));
46 connect(vfWidthSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
47 connect(vfColorButton,SIGNAL(clicked()),this,SLOT(VFColorChangeRequest()));
48 connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty()));
49 connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
50 connect(thresOpacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
51 connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
52 connect(fusionWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
53 connect(fusionLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
54 connect(fusionOpacitySpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
55 connect(fusionThresSpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
56 connect(fusionShowLegendCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionProperty()));
57 connect(overlayWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
58 connect(overlayLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
59 connect(overlayLinkCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setOverlayProperty()));
61 disableFusionSignals = false;
64 void vvOverlayPanel::getCurrentImageName(QString name)
66 QString filename = "<b>Current image : </b>";
67 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
68 currentImageLabel->setText(filename.toStdString().c_str());
71 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
73 if (subsampling != -1) {
75 vFFrame->setEnabled(1);
76 subSamplingSpinBox->setEnabled(1);
77 subSamplingSpinBox->setValue(subsampling);
78 scaleSpinBox->setEnabled(1);
79 scaleSpinBox->setValue(scale);
80 lutCheckBox->setEnabled(1);
82 lutCheckBox->setCheckState(Qt::Checked);
84 lutCheckBox->setCheckState(Qt::Unchecked);
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);
97 void vvOverlayPanel::getVFName(QString name)
99 QString filename = "<b>Deformation Field : </b>";
100 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
101 vectorFieldNameLabel->setText(filename.toStdString().c_str());
104 void vvOverlayPanel::setVFProperty()
106 QColor color(vfColorButton->palette().color(QPalette::Background));
107 emit VFPropertyUpdated(subSamplingSpinBox->value(),
108 scaleSpinBox->value(),
109 lutCheckBox->checkState(),
110 vfWidthSpinBox->value(),
111 color.redF(), color.greenF(), color.blueF());
114 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
116 QString motion = "<b>Displacement : </b>";
117 QString motionValue = "<b>Length : </b>";
119 motion += QString::number(x,'f',1) + " ";
120 motion += QString::number(y,'f',1) + " ";
121 motion += QString::number(z,'f',1) + " ";
123 motionValue += QString::number(value,'f',1);
125 coordinatesLabel->setText(motion);
126 normLabel->setText(motionValue);
129 void vvOverlayPanel::getOverlayName(QString name)
131 QString filename = "<b>Compare with : </b>";
132 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
133 imageComparedLabel->setText(filename.toStdString().c_str());
136 void vvOverlayPanel::getOverlayProperty(int color, int linked, double window, double level)
139 compareFrame->show();
140 compareFrame->setEnabled(1);
141 colorHorizontalSlider->setEnabled(1);
142 colorHorizontalSlider->setValue(color);
143 overlayLinkCheckBox->setCheckState( (linked)?Qt::Checked:Qt::Unchecked );
144 overlayWindowSpinBox->setValue(window);
145 overlayLevelSpinBox->setValue(level);
147 compareFrame->hide();
148 compareFrame->setEnabled(0);
149 colorHorizontalSlider->setEnabled(0);
150 colorHorizontalSlider->setValue(0);
154 void vvOverlayPanel::setOverlayProperty()
156 overlayWindowSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
157 overlayLevelSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
158 emit OverlayPropertyUpdated(colorHorizontalSlider->value(),
159 overlayLinkCheckBox->checkState(),
160 overlayWindowSpinBox->value(),
161 overlayLevelSpinBox->value());
164 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
166 QString refValue = "<b>Pixel value in image 1 : </b>";
167 QString overlayValue = "<b>Pixel value in image 2 : </b>";
168 QString diffValue = "<b>Pixel difference : </b>";
170 refValue += QString::number(valueRef);
171 overlayValue += QString::number(valueOver);
172 diffValue += QString::number(valueRef - valueOver);
174 refValueLabel->setText(refValue);
175 valueLabel->setText(overlayValue);
176 diffValueLabel->setText(diffValue);
178 void vvOverlayPanel::getFusionName(QString name)
180 QString filename = "<b>Fusion with : </b>";
181 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
182 dataFusionnedLabel->setText(filename.toStdString().c_str());
185 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
188 //first disable signals generated by each setValue() call
189 disableFusionSignals = true;
191 fusionFrame->setEnabled(1);
192 fusionColorMapComboBox->setEnabled(1);
193 fusionColorMapComboBox->setCurrentIndex(colormap);
194 opacityHorizontalSlider->setEnabled(1);
195 opacityHorizontalSlider->setValue(opacity);
196 thresOpacityHorizontalSlider->setEnabled(1);
197 thresOpacityHorizontalSlider->setValue(thresOpacity);
198 fusionOpacitySpin->setValue(opacity);
199 fusionThresSpin->setValue(thresOpacity);
200 fusionWindowSpinBox->setEnabled(1);
201 fusionLevelSpinBox->setEnabled(1);
202 fusionWindowSpinBox->setValue(window);
203 fusionLevelSpinBox->setValue(level);
205 // re-enable signals and trigger slot function
206 disableFusionSignals = false;
210 fusionFrame->setEnabled(0);
211 opacityHorizontalSlider->setEnabled(0);
212 opacityHorizontalSlider->setValue(0);
213 thresOpacityHorizontalSlider->setEnabled(0);
214 thresOpacityHorizontalSlider->setValue(0);
215 fusionOpacitySpin->setValue(0);
216 fusionThresSpin->setValue(0);
217 fusionColorMapComboBox->setEnabled(0);
218 fusionColorMapComboBox->setCurrentIndex(-1);
219 fusionWindowSpinBox->setEnabled(0);
220 fusionLevelSpinBox->setEnabled(0);
224 void vvOverlayPanel::setFusionProperty()
226 if (disableFusionSignals)
229 fusionOpacitySpin->setValue(opacityHorizontalSlider->value());
230 fusionThresSpin->setValue(thresOpacityHorizontalSlider->value());
232 emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
233 fusionWindowSpinBox->value(), fusionLevelSpinBox->value(), fusionShowLegendCheckBox->isChecked());
236 void vvOverlayPanel::setFusionSpinProperty()
238 opacityHorizontalSlider->setValue(fusionOpacitySpin->value());
239 thresOpacityHorizontalSlider->setValue(fusionThresSpin->value());
242 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
244 QString fusionValue = "<b>Pixel value in image 2 : </b>";
246 fusionValue += QString::number(value,'f',1);
248 valueFusionnedLabel->setText(fusionValue);
251 void vvOverlayPanel::VFColorChangeRequest()
253 QColor color(vfColorButton->palette().color(QPalette::Background));
254 color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
255 //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
257 vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
258 this->setVFProperty();
263 #endif /* end #define _vvOverlayPanel_CXX */