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)
38 subSamplingSpinBox->setEnabled(0);
39 scaleSpinBox->setEnabled(0);
41 lutCheckBox->setEnabled(0);
42 fusionShowLegendCheckBox->setChecked(false);
43 fCTUSActivateSpaceSyncCheckBox->setChecked(true);
45 connect(subSamplingSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
46 connect(scaleSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
47 connect(lutCheckBox,SIGNAL(clicked()),this,SLOT(setVFProperty()));
48 connect(vfWidthSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
49 connect(vfColorButton,SIGNAL(clicked()),this,SLOT(VFColorChangeRequest()));
50 connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty()));
51 connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
52 connect(thresOpacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
53 connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
54 connect(fusionWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
55 connect(fusionLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
56 connect(fusionOpacitySpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
57 connect(fusionThresSpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
58 connect(fusionShowLegendCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionProperty()));
59 connect(overlayWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
60 connect(overlayLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
61 connect(overlayLinkCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setOverlayProperty()));
63 connect(fCTUSSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionSequenceProperty()));
64 connect(fCTUSActivateSpaceSyncCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionSequenceProperty()));
65 connect(fCTUSActivateTimeSyncCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionSequenceProperty()));
66 connect(fCTUSLoadSignalPushButton,SIGNAL(clicked()),this,SIGNAL(FusionSequenceSignalButtonPressed()));
68 disableFusionSignals = false;
69 disableFusionSequenceSignals = false;
72 void vvOverlayPanel::getCurrentImageName(QString name)
74 QString filename = "<b>Current image : </b>";
75 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
76 currentImageLabel->setText(filename.toStdString().c_str());
79 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
81 if (subsampling != -1) {
83 vFFrame->setEnabled(1);
84 subSamplingSpinBox->setEnabled(1);
85 subSamplingSpinBox->setValue(subsampling);
86 scaleSpinBox->setEnabled(1);
87 scaleSpinBox->setValue(scale);
88 lutCheckBox->setEnabled(1);
90 lutCheckBox->setCheckState(Qt::Checked);
92 lutCheckBox->setCheckState(Qt::Unchecked);
95 vFFrame->setEnabled(0);
96 subSamplingSpinBox->setEnabled(0);
97 subSamplingSpinBox->setValue(0);
98 scaleSpinBox->setEnabled(0);
99 scaleSpinBox->setValue(0);
100 lutCheckBox->setEnabled(0);
101 lutCheckBox->setCheckState(Qt::Unchecked);
105 void vvOverlayPanel::getVFName(QString name)
107 QString filename = "<b>Deformation Field : </b>";
108 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
109 vectorFieldNameLabel->setText(filename.toStdString().c_str());
112 void vvOverlayPanel::setVFProperty()
114 QColor color(vfColorButton->palette().color(QPalette::Background));
115 emit VFPropertyUpdated(subSamplingSpinBox->value(),
116 scaleSpinBox->value(),
117 lutCheckBox->checkState(),
118 vfWidthSpinBox->value(),
119 color.redF(), color.greenF(), color.blueF());
122 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
124 QString motion = "<b>Displacement : </b>";
125 QString motionValue = "<b>Length : </b>";
127 motion += QString::number(x,'f',1) + " ";
128 motion += QString::number(y,'f',1) + " ";
129 motion += QString::number(z,'f',1) + " ";
131 motionValue += QString::number(value,'f',1);
133 coordinatesLabel->setText(motion);
134 normLabel->setText(motionValue);
137 void vvOverlayPanel::getOverlayName(QString name)
139 QString filename = "<b>Compare with : </b>";
140 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
141 imageComparedLabel->setText(filename.toStdString().c_str());
144 void vvOverlayPanel::getOverlayProperty(int color, int linked, double window, double level)
147 compareFrame->show();
148 compareFrame->setEnabled(1);
149 colorHorizontalSlider->setEnabled(1);
150 colorHorizontalSlider->setValue(color);
151 overlayLinkCheckBox->setCheckState( (linked)?Qt::Checked:Qt::Unchecked );
152 overlayWindowSpinBox->setValue(window);
153 overlayLevelSpinBox->setValue(level);
155 compareFrame->hide();
156 compareFrame->setEnabled(0);
157 colorHorizontalSlider->setEnabled(0);
158 colorHorizontalSlider->setValue(0);
162 void vvOverlayPanel::setOverlayProperty()
164 overlayWindowSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
165 overlayLevelSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
166 emit OverlayPropertyUpdated(colorHorizontalSlider->value(),
167 overlayLinkCheckBox->checkState(),
168 overlayWindowSpinBox->value(),
169 overlayLevelSpinBox->value());
172 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
174 QString refValue = "<b>Pixel value in image 1 : </b>";
175 QString overlayValue = "<b>Pixel value in image 2 : </b>";
176 QString diffValue = "<b>Pixel difference : </b>";
178 refValue += QString::number(valueRef);
179 overlayValue += QString::number(valueOver);
180 diffValue += QString::number(valueRef - valueOver);
182 refValueLabel->setText(refValue);
183 valueLabel->setText(overlayValue);
184 diffValueLabel->setText(diffValue);
186 void vvOverlayPanel::getFusionName(QString name)
188 QString filename = "<b>Fusion with : </b>";
189 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
190 dataFusionnedLabel->setText(filename.toStdString().c_str());
193 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
196 //first disable signals generated by each setValue() call
197 disableFusionSignals = true;
199 fusionFrame->setEnabled(1);
200 fusionColorMapComboBox->setEnabled(1);
201 fusionColorMapComboBox->setCurrentIndex(colormap);
202 opacityHorizontalSlider->setEnabled(1);
203 opacityHorizontalSlider->setValue(opacity);
204 thresOpacityHorizontalSlider->setEnabled(1);
205 thresOpacityHorizontalSlider->setValue(thresOpacity);
206 fusionOpacitySpin->setValue(opacity);
207 fusionThresSpin->setValue(thresOpacity);
208 fusionWindowSpinBox->setEnabled(1);
209 fusionLevelSpinBox->setEnabled(1);
210 fusionWindowSpinBox->setValue(window);
211 fusionLevelSpinBox->setValue(level);
213 // re-enable signals and trigger slot function
214 disableFusionSignals = false;
218 fusionFrame->setEnabled(0);
219 opacityHorizontalSlider->setEnabled(0);
220 opacityHorizontalSlider->setValue(0);
221 thresOpacityHorizontalSlider->setEnabled(0);
222 thresOpacityHorizontalSlider->setValue(0);
223 fusionOpacitySpin->setValue(0);
224 fusionThresSpin->setValue(0);
225 fusionColorMapComboBox->setEnabled(0);
226 fusionColorMapComboBox->setCurrentIndex(-1);
227 fusionWindowSpinBox->setEnabled(0);
228 fusionLevelSpinBox->setEnabled(0);
232 void vvOverlayPanel::setFusionProperty()
234 if (disableFusionSignals)
237 fusionOpacitySpin->setValue(opacityHorizontalSlider->value());
238 fusionThresSpin->setValue(thresOpacityHorizontalSlider->value());
240 emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
241 fusionWindowSpinBox->value(), fusionLevelSpinBox->value(), fusionShowLegendCheckBox->isChecked());
244 void vvOverlayPanel::setFusionSpinProperty()
246 opacityHorizontalSlider->setValue(fusionOpacitySpin->value());
247 thresOpacityHorizontalSlider->setValue(fusionThresSpin->value());
250 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
252 QString fusionValue = "<b>Pixel value in image 2 : </b>";
254 fusionValue += QString::number(value,'f',1);
256 valueFusionnedLabel->setText(fusionValue);
260 void vvOverlayPanel::getFusionSequenceProperty(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLenth, bool temporalSync)
262 if (sequenceFrameIndex > -1) {
263 disableFusionSequenceSignals = true;
265 fCTUSFrame->setEnabled(1);
266 fCTUSSlider->setEnabled(1);
267 fCTUSSlider->setValue(sequenceFrameIndex);
268 fCTUSSlider->setMaximum(sequenceLenth);
269 if (spatialSync) fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Checked);
270 else fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Unchecked);
271 if (fCTUSActivateTimeSyncCheckBox->isEnabled()) {
272 if ( temporalSync ) fCTUSActivateTimeSyncCheckBox->setCheckState(Qt::Checked);
273 else fCTUSActivateTimeSyncCheckBox->setCheckState(Qt::Unchecked);
275 disableFusionSequenceSignals = false;
276 setFusionSequenceProperty();
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);
289 void vvOverlayPanel::setFusionSequenceProperty()
291 if (disableFusionSequenceSignals)
294 emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked());
297 void vvOverlayPanel::enableFusionSequenceTemporalSync() {
298 fCTUSActivateTimeSyncCheckBox->setEnabled(1);
299 fCTUSActivateTimeSyncCheckBox->setChecked(true);
301 if (disableFusionSequenceSignals) return;
302 emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked());
305 void vvOverlayPanel::updateFusionSequenceSliderValueFromWindow(int val, bool updateVisualization) {
306 fCTUSSlider->setValue(val);
307 if (updateVisualization) emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked());
310 void vvOverlayPanel::VFColorChangeRequest()
312 QColor color(vfColorButton->palette().color(QPalette::Background));
313 color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
314 //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
316 vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
317 this->setVFProperty();
322 #endif /* end #define _vvOverlayPanel_CXX */