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)
32 disableFusionSignals = true;
33 disableFusionSequenceSignals = true;
41 subSamplingSpinBox->setEnabled(0);
42 scaleSpinBox->setEnabled(0);
44 lutCheckBox->setEnabled(0);
45 fusionShowLegendCheckBox->setChecked(false);
47 connect(subSamplingSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
48 connect(scaleSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
49 connect(lutCheckBox,SIGNAL(clicked()),this,SLOT(setVFProperty()));
50 connect(vfWidthSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
51 connect(vfColorButton,SIGNAL(clicked()),this,SLOT(VFColorChangeRequest()));
52 connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty()));
53 connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
54 connect(thresOpacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
55 connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
56 connect(fusionWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
57 connect(fusionLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
58 connect(fusionOpacitySpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
59 connect(fusionThresSpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
60 connect(fusionShowLegendCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionProperty()));
61 connect(overlayWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
62 connect(overlayLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
63 connect(overlayLinkCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setOverlayProperty()));
65 connect(fCTUSSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionSequenceProperty()));
66 connect(fCTUSActivateSpaceSyncCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionSequenceProperty()));
67 connect(fCTUSActivateTimeSyncCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionSequenceProperty()));
68 connect(fCTUSLoadCorrespondancesPushButton,SIGNAL(clicked()),this,SIGNAL(FusionSequenceCorrespondancesButtonPressed()));
71 void vvOverlayPanel::getCurrentImageName(QString name)
73 QString filename = "<b>Current image : </b>";
74 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
75 currentImageLabel->setText(filename.toStdString().c_str());
78 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
80 if (subsampling != -1) {
82 vFFrame->setEnabled(1);
83 subSamplingSpinBox->setEnabled(1);
84 subSamplingSpinBox->setValue(subsampling);
85 scaleSpinBox->setEnabled(1);
86 scaleSpinBox->setValue(scale);
87 lutCheckBox->setEnabled(1);
89 lutCheckBox->setCheckState(Qt::Checked);
91 lutCheckBox->setCheckState(Qt::Unchecked);
94 vFFrame->setEnabled(0);
95 subSamplingSpinBox->setEnabled(0);
96 subSamplingSpinBox->setValue(0);
97 scaleSpinBox->setEnabled(0);
98 scaleSpinBox->setValue(0);
99 lutCheckBox->setEnabled(0);
100 lutCheckBox->setCheckState(Qt::Unchecked);
104 void vvOverlayPanel::getVFName(QString name)
106 QString filename = "<b>Deformation Field : </b>";
107 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
108 vectorFieldNameLabel->setText(filename.toStdString().c_str());
111 void vvOverlayPanel::setVFProperty()
113 QColor color(vfColorButton->palette().color(QPalette::Background));
114 emit VFPropertyUpdated(subSamplingSpinBox->value(),
115 scaleSpinBox->value(),
116 lutCheckBox->checkState(),
117 vfWidthSpinBox->value(),
118 color.redF(), color.greenF(), color.blueF());
121 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
123 QString motion = "<b>Displacement : </b>";
124 QString motionValue = "<b>Length : </b>";
126 motion += QString::number(x,'f',1) + " ";
127 motion += QString::number(y,'f',1) + " ";
128 motion += QString::number(z,'f',1) + " ";
130 motionValue += QString::number(value,'f',1);
132 coordinatesLabel->setText(motion);
133 normLabel->setText(motionValue);
136 void vvOverlayPanel::getOverlayName(QString name)
138 QString filename = "<b>Compare with : </b>";
139 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
140 imageComparedLabel->setText(filename.toStdString().c_str());
143 void vvOverlayPanel::getOverlayProperty(int color, int linked, double window, double level)
146 compareFrame->show();
147 compareFrame->setEnabled(1);
148 colorHorizontalSlider->setEnabled(1);
149 colorHorizontalSlider->setValue(color);
150 overlayLinkCheckBox->setCheckState( (linked)?Qt::Checked:Qt::Unchecked );
151 overlayWindowSpinBox->setValue(window);
152 overlayLevelSpinBox->setValue(level);
154 compareFrame->hide();
155 compareFrame->setEnabled(0);
156 colorHorizontalSlider->setEnabled(0);
157 colorHorizontalSlider->setValue(0);
161 void vvOverlayPanel::setOverlayProperty()
163 overlayWindowSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
164 overlayLevelSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
165 emit OverlayPropertyUpdated(colorHorizontalSlider->value(),
166 overlayLinkCheckBox->checkState(),
167 overlayWindowSpinBox->value(),
168 overlayLevelSpinBox->value());
171 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
173 QString refValue = "<b>Pixel value in image 1 : </b>";
174 QString overlayValue = "<b>Pixel value in image 2 : </b>";
175 QString diffValue = "<b>Pixel difference : </b>";
177 refValue += QString::number(valueRef);
178 overlayValue += QString::number(valueOver);
179 diffValue += QString::number(valueRef - valueOver);
181 refValueLabel->setText(refValue);
182 valueLabel->setText(overlayValue);
183 diffValueLabel->setText(diffValue);
185 void vvOverlayPanel::getFusionName(QString name)
187 QString filename = "<b>Fusion with : </b>";
188 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
189 dataFusionnedLabel->setText(filename.toStdString().c_str());
192 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
195 //first disable signals generated by each setValue() call
196 disableFusionSignals = true;
198 fusionFrame->setEnabled(1);
199 fusionColorMapComboBox->setEnabled(1);
200 fusionColorMapComboBox->setCurrentIndex(colormap);
201 opacityHorizontalSlider->setEnabled(1);
202 opacityHorizontalSlider->setValue(opacity);
203 thresOpacityHorizontalSlider->setEnabled(1);
204 thresOpacityHorizontalSlider->setValue(thresOpacity);
205 fusionOpacitySpin->setValue(opacity);
206 fusionThresSpin->setValue(thresOpacity);
207 fusionWindowSpinBox->setEnabled(1);
208 fusionLevelSpinBox->setEnabled(1);
209 fusionWindowSpinBox->setValue(window);
210 fusionLevelSpinBox->setValue(level);
212 // re-enable signals and trigger slot function
213 disableFusionSignals = false;
217 fusionFrame->setEnabled(0);
218 opacityHorizontalSlider->setEnabled(0);
219 opacityHorizontalSlider->setValue(0);
220 thresOpacityHorizontalSlider->setEnabled(0);
221 thresOpacityHorizontalSlider->setValue(0);
222 fusionOpacitySpin->setValue(0);
223 fusionThresSpin->setValue(0);
224 fusionColorMapComboBox->setEnabled(0);
225 fusionColorMapComboBox->setCurrentIndex(-1);
226 fusionWindowSpinBox->setEnabled(0);
227 fusionLevelSpinBox->setEnabled(0);
231 void vvOverlayPanel::setFusionProperty()
233 if (disableFusionSignals)
236 fusionOpacitySpin->setValue(opacityHorizontalSlider->value());
237 fusionThresSpin->setValue(thresOpacityHorizontalSlider->value());
239 emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
240 fusionWindowSpinBox->value(), fusionLevelSpinBox->value(), fusionShowLegendCheckBox->isChecked());
243 void vvOverlayPanel::setFusionSpinProperty()
245 opacityHorizontalSlider->setValue(fusionOpacitySpin->value());
246 thresOpacityHorizontalSlider->setValue(fusionThresSpin->value());
249 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
251 QString fusionValue = "<b>Pixel value in image 2 : </b>";
253 fusionValue += QString::number(value,'f',1);
255 valueFusionnedLabel->setText(fusionValue);
259 void vvOverlayPanel::getFusionSequenceProperty(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLenth, bool temporalSync)
261 if (sequenceFrameIndex > -1) {
262 disableFusionSequenceSignals = true;
264 fCTUSFrame->setEnabled(1);
265 fCTUSSlider->setEnabled(1);
266 fCTUSSlider->setValue(sequenceFrameIndex);
267 fCTUSSlider->setMaximum(sequenceLenth-1); //the maximum IS included, since we start at 0, go until n-1!
268 if (spatialSync) fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Checked);
269 else fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Unchecked);
270 if (fCTUSActivateTimeSyncCheckBox->isEnabled()) {
271 if ( temporalSync ) fCTUSActivateTimeSyncCheckBox->setCheckState(Qt::Checked);
272 else fCTUSActivateTimeSyncCheckBox->setCheckState(Qt::Unchecked);
274 disableFusionSequenceSignals = false;
275 setFusionSequenceProperty();
277 disableFusionSequenceSignals = true;
279 fCTUSFrame->setEnabled(0);
280 fCTUSSlider->setEnabled(0);
281 fCTUSSlider->setValue(0);
282 fCTUSSlider->setMaximum(0);
283 fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Unchecked);
284 fCTUSActivateTimeSyncCheckBox->setCheckState(Qt::Unchecked);
285 disableFusionSequenceSignals = false;
286 setFusionSequenceProperty();
291 void vvOverlayPanel::setFusionSequenceProperty()
293 if (disableFusionSequenceSignals)
295 emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum()+1, fCTUSActivateTimeSyncCheckBox->isChecked());
298 void vvOverlayPanel::enableFusionSequenceTemporalSync() {
299 bool backup = disableFusionSequenceSignals;
300 disableFusionSequenceSignals=true; //not sure this is necessary, but just in case...
301 fCTUSActivateTimeSyncCheckBox->setEnabled(1);
302 fCTUSActivateTimeSyncCheckBox->setChecked(true);
303 disableFusionSequenceSignals = backup; //
305 if (disableFusionSequenceSignals) return;
306 emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum()+1, fCTUSActivateTimeSyncCheckBox->isChecked());
309 void vvOverlayPanel::updateFusionSequenceSliderValueFromWindow(int val, bool updateVisualization) {
310 if (fCTUSSlider->value()==val) return;
312 disableFusionSequenceSignals = true; //not sure this is necessary, but just in case...
313 fCTUSSlider->setValue(val);
314 disableFusionSequenceSignals = false;
316 if (disableFusionSequenceSignals) return;
317 if (updateVisualization) emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum()+1, fCTUSActivateTimeSyncCheckBox->isChecked());
320 void vvOverlayPanel::VFColorChangeRequest()
322 QColor color(vfColorButton->palette().color(QPalette::Background));
323 color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
324 //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
326 vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
327 this->setVFProperty();
332 #endif /* end #define _vvOverlayPanel_CXX */