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(overlayWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
53 connect(overlayLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
54 connect(overlayLinkCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setOverlayProperty()));
56 disableFusionSignals = false;
59 void vvOverlayPanel::getCurrentImageName(QString name)
61 QString filename = "<b>Current image : </b>";
62 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
63 currentImageLabel->setText(filename.toStdString().c_str());
66 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
68 if (subsampling != -1) {
70 vFFrame->setEnabled(1);
71 subSamplingSpinBox->setEnabled(1);
72 subSamplingSpinBox->setValue(subsampling);
73 scaleSpinBox->setEnabled(1);
74 scaleSpinBox->setValue(scale);
75 lutCheckBox->setEnabled(1);
77 lutCheckBox->setCheckState(Qt::Checked);
79 lutCheckBox->setCheckState(Qt::Unchecked);
82 vFFrame->setEnabled(0);
83 subSamplingSpinBox->setEnabled(0);
84 subSamplingSpinBox->setValue(0);
85 scaleSpinBox->setEnabled(0);
86 scaleSpinBox->setValue(0);
87 lutCheckBox->setEnabled(0);
88 lutCheckBox->setCheckState(Qt::Unchecked);
92 void vvOverlayPanel::getVFName(QString name)
94 QString filename = "<b>Deformation Field : </b>";
95 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
96 vectorFieldNameLabel->setText(filename.toStdString().c_str());
99 void vvOverlayPanel::setVFProperty()
101 QColor color(vfColorButton->palette().color(QPalette::Background));
102 emit VFPropertyUpdated(subSamplingSpinBox->value(),
103 scaleSpinBox->value(),
104 lutCheckBox->checkState(),
105 vfWidthSpinBox->value(),
106 color.redF(), color.greenF(), color.blueF());
109 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
111 QString motion = "<b>Displacement : </b>";
112 QString motionValue = "<b>Length : </b>";
114 motion += QString::number(x,'f',1) + " ";
115 motion += QString::number(y,'f',1) + " ";
116 motion += QString::number(z,'f',1) + " ";
118 motionValue += QString::number(value,'f',1);
120 coordinatesLabel->setText(motion);
121 normLabel->setText(motionValue);
124 void vvOverlayPanel::getOverlayName(QString name)
126 QString filename = "<b>Compare with : </b>";
127 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
128 imageComparedLabel->setText(filename.toStdString().c_str());
131 void vvOverlayPanel::getOverlayProperty(int color, int linked, double window, double level)
134 compareFrame->show();
135 compareFrame->setEnabled(1);
136 colorHorizontalSlider->setEnabled(1);
137 colorHorizontalSlider->setValue(color);
138 overlayLinkCheckBox->setCheckState( (linked)?Qt::Checked:Qt::Unchecked );
139 overlayWindowSpinBox->setValue(window);
140 overlayLevelSpinBox->setValue(level);
142 compareFrame->hide();
143 compareFrame->setEnabled(0);
144 colorHorizontalSlider->setEnabled(0);
145 colorHorizontalSlider->setValue(0);
149 void vvOverlayPanel::setOverlayProperty()
151 overlayWindowSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
152 overlayLevelSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
153 emit OverlayPropertyUpdated(colorHorizontalSlider->value(),
154 overlayLinkCheckBox->checkState(),
155 overlayWindowSpinBox->value(),
156 overlayLevelSpinBox->value());
159 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
161 QString refValue = "<b>Pixel value in image 1 : </b>";
162 QString overlayValue = "<b>Pixel value in image 2 : </b>";
163 QString diffValue = "<b>Pixel difference : </b>";
165 refValue += QString::number(valueRef);
166 overlayValue += QString::number(valueOver);
167 diffValue += QString::number(valueRef - valueOver);
169 refValueLabel->setText(refValue);
170 valueLabel->setText(overlayValue);
171 diffValueLabel->setText(diffValue);
173 void vvOverlayPanel::getFusionName(QString name)
175 QString filename = "<b>Fusion with : </b>";
176 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
177 dataFusionnedLabel->setText(filename.toStdString().c_str());
180 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
183 //first disable signals generated by each setValue() call
184 disableFusionSignals = true;
186 fusionFrame->setEnabled(1);
187 fusionColorMapComboBox->setEnabled(1);
188 fusionColorMapComboBox->setCurrentIndex(colormap);
189 opacityHorizontalSlider->setEnabled(1);
190 opacityHorizontalSlider->setValue(opacity);
191 thresOpacityHorizontalSlider->setEnabled(1);
192 thresOpacityHorizontalSlider->setValue(thresOpacity);
193 fusionWindowSpinBox->setEnabled(1);
194 fusionLevelSpinBox->setEnabled(1);
195 fusionWindowSpinBox->setValue(window);
196 fusionLevelSpinBox->setValue(level);
198 // re-enable signals and trigger slot function
199 disableFusionSignals = false;
203 fusionFrame->setEnabled(0);
204 opacityHorizontalSlider->setEnabled(0);
205 opacityHorizontalSlider->setValue(0);
206 thresOpacityHorizontalSlider->setEnabled(0);
207 thresOpacityHorizontalSlider->setValue(0);
208 fusionColorMapComboBox->setEnabled(0);
209 fusionColorMapComboBox->setCurrentIndex(-1);
210 fusionWindowSpinBox->setEnabled(0);
211 fusionLevelSpinBox->setEnabled(0);
215 void vvOverlayPanel::setFusionProperty()
217 if (disableFusionSignals)
220 emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
221 fusionWindowSpinBox->value(), fusionLevelSpinBox->value());
224 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
226 QString fusionValue = "<b>Pixel value in image 2 : </b>";
228 fusionValue += QString::number(value,'f',1);
230 valueFusionnedLabel->setText(fusionValue);
233 void vvOverlayPanel::VFColorChangeRequest()
235 QColor color(vfColorButton->palette().color(QPalette::Background));
236 color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
237 //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
238 vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
239 this->setVFProperty();
242 #endif /* end #define _vvOverlayPanel_CXX */