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 connect(subSamplingSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
42 connect(scaleSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
43 connect(lutCheckBox,SIGNAL(clicked()),this,SLOT(setVFProperty()));
44 connect(vfWidthSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
45 connect(vfColorButton,SIGNAL(clicked()),this,SLOT(VFColorChangeRequest()));
46 connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty()));
47 connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
48 connect(thresOpacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
49 connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
50 connect(fusionWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
51 connect(fusionLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
52 connect(fusionOpacitySpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
53 connect(fusionThresSpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
54 connect(overlayWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
55 connect(overlayLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
56 connect(overlayLinkCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setOverlayProperty()));
58 disableFusionSignals = false;
61 void vvOverlayPanel::getCurrentImageName(QString name)
63 QString filename = "<b>Current image : </b>";
64 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
65 currentImageLabel->setText(filename.toStdString().c_str());
68 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
70 if (subsampling != -1) {
72 vFFrame->setEnabled(1);
73 subSamplingSpinBox->setEnabled(1);
74 subSamplingSpinBox->setValue(subsampling);
75 scaleSpinBox->setEnabled(1);
76 scaleSpinBox->setValue(scale);
77 lutCheckBox->setEnabled(1);
79 lutCheckBox->setCheckState(Qt::Checked);
81 lutCheckBox->setCheckState(Qt::Unchecked);
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);
94 void vvOverlayPanel::getVFName(QString name)
96 QString filename = "<b>Deformation Field : </b>";
97 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
98 vectorFieldNameLabel->setText(filename.toStdString().c_str());
101 void vvOverlayPanel::setVFProperty()
103 QColor color(vfColorButton->palette().color(QPalette::Background));
104 emit VFPropertyUpdated(subSamplingSpinBox->value(),
105 scaleSpinBox->value(),
106 lutCheckBox->checkState(),
107 vfWidthSpinBox->value(),
108 color.redF(), color.greenF(), color.blueF());
111 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
113 QString motion = "<b>Displacement : </b>";
114 QString motionValue = "<b>Length : </b>";
116 motion += QString::number(x,'f',1) + " ";
117 motion += QString::number(y,'f',1) + " ";
118 motion += QString::number(z,'f',1) + " ";
120 motionValue += QString::number(value,'f',1);
122 coordinatesLabel->setText(motion);
123 normLabel->setText(motionValue);
126 void vvOverlayPanel::getOverlayName(QString name)
128 QString filename = "<b>Compare with : </b>";
129 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
130 imageComparedLabel->setText(filename.toStdString().c_str());
133 void vvOverlayPanel::getOverlayProperty(int color, int linked, double window, double level)
136 compareFrame->show();
137 compareFrame->setEnabled(1);
138 colorHorizontalSlider->setEnabled(1);
139 colorHorizontalSlider->setValue(color);
140 overlayLinkCheckBox->setCheckState( (linked)?Qt::Checked:Qt::Unchecked );
141 overlayWindowSpinBox->setValue(window);
142 overlayLevelSpinBox->setValue(level);
144 compareFrame->hide();
145 compareFrame->setEnabled(0);
146 colorHorizontalSlider->setEnabled(0);
147 colorHorizontalSlider->setValue(0);
151 void vvOverlayPanel::setOverlayProperty()
153 overlayWindowSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
154 overlayLevelSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
155 emit OverlayPropertyUpdated(colorHorizontalSlider->value(),
156 overlayLinkCheckBox->checkState(),
157 overlayWindowSpinBox->value(),
158 overlayLevelSpinBox->value());
161 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
163 QString refValue = "<b>Pixel value in image 1 : </b>";
164 QString overlayValue = "<b>Pixel value in image 2 : </b>";
165 QString diffValue = "<b>Pixel difference : </b>";
167 refValue += QString::number(valueRef);
168 overlayValue += QString::number(valueOver);
169 diffValue += QString::number(valueRef - valueOver);
171 refValueLabel->setText(refValue);
172 valueLabel->setText(overlayValue);
173 diffValueLabel->setText(diffValue);
175 void vvOverlayPanel::getFusionName(QString name)
177 QString filename = "<b>Fusion with : </b>";
178 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
179 dataFusionnedLabel->setText(filename.toStdString().c_str());
182 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
185 //first disable signals generated by each setValue() call
186 disableFusionSignals = true;
188 fusionFrame->setEnabled(1);
189 fusionColorMapComboBox->setEnabled(1);
190 fusionColorMapComboBox->setCurrentIndex(colormap);
191 opacityHorizontalSlider->setEnabled(1);
192 opacityHorizontalSlider->setValue(opacity);
193 thresOpacityHorizontalSlider->setEnabled(1);
194 thresOpacityHorizontalSlider->setValue(thresOpacity);
195 fusionOpacitySpin->setValue(opacity);
196 fusionThresSpin->setValue(thresOpacity);
197 fusionWindowSpinBox->setEnabled(1);
198 fusionLevelSpinBox->setEnabled(1);
199 fusionWindowSpinBox->setValue(window);
200 fusionLevelSpinBox->setValue(level);
202 // re-enable signals and trigger slot function
203 disableFusionSignals = false;
207 fusionFrame->setEnabled(0);
208 opacityHorizontalSlider->setEnabled(0);
209 opacityHorizontalSlider->setValue(0);
210 thresOpacityHorizontalSlider->setEnabled(0);
211 thresOpacityHorizontalSlider->setValue(0);
212 fusionOpacitySpin->setValue(0);
213 fusionThresSpin->setValue(0);
214 fusionColorMapComboBox->setEnabled(0);
215 fusionColorMapComboBox->setCurrentIndex(-1);
216 fusionWindowSpinBox->setEnabled(0);
217 fusionLevelSpinBox->setEnabled(0);
221 void vvOverlayPanel::setFusionProperty()
223 if (disableFusionSignals)
226 fusionOpacitySpin->setValue(opacityHorizontalSlider->value());
227 fusionThresSpin->setValue(thresOpacityHorizontalSlider->value());
229 emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
230 fusionWindowSpinBox->value(), fusionLevelSpinBox->value());
233 void vvOverlayPanel::setFusionSpinProperty()
235 opacityHorizontalSlider->setValue(fusionOpacitySpin->value());
236 thresOpacityHorizontalSlider->setValue(fusionThresSpin->value());
239 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
241 QString fusionValue = "<b>Pixel value in image 2 : </b>";
243 fusionValue += QString::number(value,'f',1);
245 valueFusionnedLabel->setText(fusionValue);
248 void vvOverlayPanel::VFColorChangeRequest()
250 QColor color(vfColorButton->palette().color(QPalette::Background));
251 color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
252 //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
254 vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
255 this->setVFProperty();
258 #endif /* end #define _vvOverlayPanel_CXX */