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(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
51 connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
53 disableFusionSignals = false;
56 void vvOverlayPanel::getCurrentImageName(QString name)
58 QString filename = "<b>Current image : </b>";
59 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
60 currentImageLabel->setText(filename.toStdString().c_str());
63 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
65 if (subsampling != -1) {
67 vFFrame->setEnabled(1);
68 subSamplingSpinBox->setEnabled(1);
69 subSamplingSpinBox->setValue(subsampling);
70 scaleSpinBox->setEnabled(1);
71 scaleSpinBox->setValue(scale);
72 lutCheckBox->setEnabled(1);
74 lutCheckBox->setCheckState(Qt::Checked);
76 lutCheckBox->setCheckState(Qt::Unchecked);
79 vFFrame->setEnabled(0);
80 subSamplingSpinBox->setEnabled(0);
81 subSamplingSpinBox->setValue(0);
82 scaleSpinBox->setEnabled(0);
83 scaleSpinBox->setValue(0);
84 lutCheckBox->setEnabled(0);
85 lutCheckBox->setCheckState(Qt::Unchecked);
89 void vvOverlayPanel::getVFName(QString name)
91 QString filename = "<b>Deformation Field : </b>";
92 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
93 vectorFieldNameLabel->setText(filename.toStdString().c_str());
96 void vvOverlayPanel::setVFProperty()
98 QColor color(vfColorButton->palette().color(QPalette::Background));
99 emit VFPropertyUpdated(subSamplingSpinBox->value(),
100 scaleSpinBox->value(),
101 lutCheckBox->checkState(),
102 vfWidthSpinBox->value(),
103 color.redF(), color.greenF(), color.blueF());
106 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
108 QString motion = "<b>Displacement : </b>";
109 QString motionValue = "<b>Length : </b>";
111 motion += QString::number(x,'f',1) + " ";
112 motion += QString::number(y,'f',1) + " ";
113 motion += QString::number(z,'f',1) + " ";
115 motionValue += QString::number(value,'f',1);
117 coordinatesLabel->setText(motion);
118 normLabel->setText(motionValue);
121 void vvOverlayPanel::getOverlayName(QString name)
123 QString filename = "<b>Compare with : </b>";
124 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
125 imageComparedLabel->setText(filename.toStdString().c_str());
128 void vvOverlayPanel::getOverlayProperty(int value)
131 compareFrame->show();
132 compareFrame->setEnabled(1);
133 colorHorizontalSlider->setEnabled(1);
134 colorHorizontalSlider->setValue(value);
136 compareFrame->hide();
137 compareFrame->setEnabled(0);
138 colorHorizontalSlider->setEnabled(0);
139 colorHorizontalSlider->setValue(0);
143 void vvOverlayPanel::setOverlayProperty()
145 emit OverlayPropertyUpdated(colorHorizontalSlider->value());
148 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
150 QString refValue = "<b>Pixel value in image 1 : </b>";
151 QString overlayValue = "<b>Pixel value in image 2 : </b>";
152 QString diffValue = "<b>Pixel difference : </b>";
154 refValue += QString::number(valueRef);
155 overlayValue += QString::number(valueOver);
156 diffValue += QString::number(valueRef - valueOver);
158 refValueLabel->setText(refValue);
159 valueLabel->setText(overlayValue);
160 diffValueLabel->setText(diffValue);
162 void vvOverlayPanel::getFusionName(QString name)
164 QString filename = "<b>Fusion with : </b>";
165 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
166 dataFusionnedLabel->setText(filename.toStdString().c_str());
169 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
172 //first disable signals generated by each setValue() call
173 disableFusionSignals = true;
175 fusionFrame->setEnabled(1);
176 fusionColorMapComboBox->setEnabled(1);
177 fusionColorMapComboBox->setCurrentIndex(colormap);
178 opacityHorizontalSlider->setEnabled(1);
179 opacityHorizontalSlider->setValue(opacity);
180 thresOpacityHorizontalSlider->setEnabled(1);
181 thresOpacityHorizontalSlider->setValue(thresOpacity);
182 windowSpinBox->setEnabled(1);
183 levelSpinBox->setEnabled(1);
184 windowSpinBox->setValue(window);
185 levelSpinBox->setValue(level);
187 // re-enable signals and trigger slot function
188 disableFusionSignals = false;
192 fusionFrame->setEnabled(0);
193 opacityHorizontalSlider->setEnabled(0);
194 opacityHorizontalSlider->setValue(0);
195 thresOpacityHorizontalSlider->setEnabled(0);
196 thresOpacityHorizontalSlider->setValue(0);
197 fusionColorMapComboBox->setEnabled(0);
198 fusionColorMapComboBox->setCurrentIndex(-1);
199 windowSpinBox->setEnabled(0);
200 levelSpinBox->setEnabled(0);
204 void vvOverlayPanel::setFusionProperty()
206 if (disableFusionSignals)
209 emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
210 windowSpinBox->value(), levelSpinBox->value());
213 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
215 QString fusionValue = "<b>Pixel value in image 2 : </b>";
217 fusionValue += QString::number(value,'f',1);
219 valueFusionnedLabel->setText(fusionValue);
222 void vvOverlayPanel::VFColorChangeRequest()
224 QColor color(vfColorButton->palette().color(QPalette::Background));
225 color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
226 //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
227 vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
228 this->setVFProperty();
231 #endif /* end #define _vvOverlayPanel_CXX */