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()));
66 disableFusionSignals = false;
67 disableFusionSequenceSignals = false;
70 void vvOverlayPanel::getCurrentImageName(QString name)
72 QString filename = "<b>Current image : </b>";
73 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
74 currentImageLabel->setText(filename.toStdString().c_str());
77 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
79 if (subsampling != -1) {
81 vFFrame->setEnabled(1);
82 subSamplingSpinBox->setEnabled(1);
83 subSamplingSpinBox->setValue(subsampling);
84 scaleSpinBox->setEnabled(1);
85 scaleSpinBox->setValue(scale);
86 lutCheckBox->setEnabled(1);
88 lutCheckBox->setCheckState(Qt::Checked);
90 lutCheckBox->setCheckState(Qt::Unchecked);
93 vFFrame->setEnabled(0);
94 subSamplingSpinBox->setEnabled(0);
95 subSamplingSpinBox->setValue(0);
96 scaleSpinBox->setEnabled(0);
97 scaleSpinBox->setValue(0);
98 lutCheckBox->setEnabled(0);
99 lutCheckBox->setCheckState(Qt::Unchecked);
103 void vvOverlayPanel::getVFName(QString name)
105 QString filename = "<b>Deformation Field : </b>";
106 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
107 vectorFieldNameLabel->setText(filename.toStdString().c_str());
110 void vvOverlayPanel::setVFProperty()
112 QColor color(vfColorButton->palette().color(QPalette::Background));
113 emit VFPropertyUpdated(subSamplingSpinBox->value(),
114 scaleSpinBox->value(),
115 lutCheckBox->checkState(),
116 vfWidthSpinBox->value(),
117 color.redF(), color.greenF(), color.blueF());
120 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
122 QString motion = "<b>Displacement : </b>";
123 QString motionValue = "<b>Length : </b>";
125 motion += QString::number(x,'f',1) + " ";
126 motion += QString::number(y,'f',1) + " ";
127 motion += QString::number(z,'f',1) + " ";
129 motionValue += QString::number(value,'f',1);
131 coordinatesLabel->setText(motion);
132 normLabel->setText(motionValue);
135 void vvOverlayPanel::getOverlayName(QString name)
137 QString filename = "<b>Compare with : </b>";
138 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
139 imageComparedLabel->setText(filename.toStdString().c_str());
142 void vvOverlayPanel::getOverlayProperty(int color, int linked, double window, double level)
145 compareFrame->show();
146 compareFrame->setEnabled(1);
147 colorHorizontalSlider->setEnabled(1);
148 colorHorizontalSlider->setValue(color);
149 overlayLinkCheckBox->setCheckState( (linked)?Qt::Checked:Qt::Unchecked );
150 overlayWindowSpinBox->setValue(window);
151 overlayLevelSpinBox->setValue(level);
153 compareFrame->hide();
154 compareFrame->setEnabled(0);
155 colorHorizontalSlider->setEnabled(0);
156 colorHorizontalSlider->setValue(0);
160 void vvOverlayPanel::setOverlayProperty()
162 overlayWindowSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
163 overlayLevelSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
164 emit OverlayPropertyUpdated(colorHorizontalSlider->value(),
165 overlayLinkCheckBox->checkState(),
166 overlayWindowSpinBox->value(),
167 overlayLevelSpinBox->value());
170 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
172 QString refValue = "<b>Pixel value in image 1 : </b>";
173 QString overlayValue = "<b>Pixel value in image 2 : </b>";
174 QString diffValue = "<b>Pixel difference : </b>";
176 refValue += QString::number(valueRef);
177 overlayValue += QString::number(valueOver);
178 diffValue += QString::number(valueRef - valueOver);
180 refValueLabel->setText(refValue);
181 valueLabel->setText(overlayValue);
182 diffValueLabel->setText(diffValue);
184 void vvOverlayPanel::getFusionName(QString name)
186 QString filename = "<b>Fusion with : </b>";
187 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
188 dataFusionnedLabel->setText(filename.toStdString().c_str());
191 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
194 //first disable signals generated by each setValue() call
195 disableFusionSignals = true;
197 fusionFrame->setEnabled(1);
198 fusionColorMapComboBox->setEnabled(1);
199 fusionColorMapComboBox->setCurrentIndex(colormap);
200 opacityHorizontalSlider->setEnabled(1);
201 opacityHorizontalSlider->setValue(opacity);
202 thresOpacityHorizontalSlider->setEnabled(1);
203 thresOpacityHorizontalSlider->setValue(thresOpacity);
204 fusionOpacitySpin->setValue(opacity);
205 fusionThresSpin->setValue(thresOpacity);
206 fusionWindowSpinBox->setEnabled(1);
207 fusionLevelSpinBox->setEnabled(1);
208 fusionWindowSpinBox->setValue(window);
209 fusionLevelSpinBox->setValue(level);
211 // re-enable signals and trigger slot function
212 disableFusionSignals = false;
216 fusionFrame->setEnabled(0);
217 opacityHorizontalSlider->setEnabled(0);
218 opacityHorizontalSlider->setValue(0);
219 thresOpacityHorizontalSlider->setEnabled(0);
220 thresOpacityHorizontalSlider->setValue(0);
221 fusionOpacitySpin->setValue(0);
222 fusionThresSpin->setValue(0);
223 fusionColorMapComboBox->setEnabled(0);
224 fusionColorMapComboBox->setCurrentIndex(-1);
225 fusionWindowSpinBox->setEnabled(0);
226 fusionLevelSpinBox->setEnabled(0);
230 void vvOverlayPanel::setFusionProperty()
232 if (disableFusionSignals)
235 fusionOpacitySpin->setValue(opacityHorizontalSlider->value());
236 fusionThresSpin->setValue(thresOpacityHorizontalSlider->value());
238 emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
239 fusionWindowSpinBox->value(), fusionLevelSpinBox->value(), fusionShowLegendCheckBox->isChecked());
242 void vvOverlayPanel::setFusionSpinProperty()
244 opacityHorizontalSlider->setValue(fusionOpacitySpin->value());
245 thresOpacityHorizontalSlider->setValue(fusionThresSpin->value());
248 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
250 QString fusionValue = "<b>Pixel value in image 2 : </b>";
252 fusionValue += QString::number(value,'f',1);
254 valueFusionnedLabel->setText(fusionValue);
258 void vvOverlayPanel::getFusionSequenceProperty(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLenth)
260 if (sequenceFrameIndex > -1) {
261 disableFusionSequenceSignals = true;
263 fCTUSFrame->setEnabled(1);
264 fCTUSSlider->setEnabled(1);
265 fCTUSSlider->setValue(sequenceFrameIndex);
266 fCTUSSlider->setMaximum(sequenceLenth);
267 if (spatialSync) fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Checked);
268 else fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Unchecked);
269 disableFusionSequenceSignals = false;
270 setFusionSequenceProperty();
273 fCTUSFrame->setEnabled(0);
274 fCTUSSlider->setEnabled(0);
275 fCTUSSlider->setValue(0);
276 fCTUSSlider->setMaximum(0);
277 fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Unchecked);
282 void vvOverlayPanel::setFusionSequenceProperty()
284 if (disableFusionSequenceSignals)
287 emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum());
292 void vvOverlayPanel::VFColorChangeRequest()
294 QColor color(vfColorButton->palette().color(QPalette::Background));
295 color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
296 //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
298 vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
299 this->setVFProperty();
304 #endif /* end #define _vvOverlayPanel_CXX */