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()));
54 void vvOverlayPanel::getCurrentImageName(QString name)
56 QString filename = "<b>Current image : </b>";
57 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
58 currentImageLabel->setText(filename.toStdString().c_str());
61 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
63 if (subsampling != -1) {
65 vFFrame->setEnabled(1);
66 subSamplingSpinBox->setEnabled(1);
67 subSamplingSpinBox->setValue(subsampling);
68 scaleSpinBox->setEnabled(1);
69 scaleSpinBox->setValue(scale);
70 lutCheckBox->setEnabled(1);
72 lutCheckBox->setCheckState(Qt::Checked);
74 lutCheckBox->setCheckState(Qt::Unchecked);
77 vFFrame->setEnabled(0);
78 subSamplingSpinBox->setEnabled(0);
79 subSamplingSpinBox->setValue(0);
80 scaleSpinBox->setEnabled(0);
81 scaleSpinBox->setValue(0);
82 lutCheckBox->setEnabled(0);
83 lutCheckBox->setCheckState(Qt::Unchecked);
87 void vvOverlayPanel::getVFName(QString name)
89 QString filename = "<b>Deformation Field : </b>";
90 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
91 vectorFieldNameLabel->setText(filename.toStdString().c_str());
94 void vvOverlayPanel::setVFProperty()
96 QColor color(vfColorButton->palette().color(QPalette::Background));
97 emit VFPropertyUpdated(subSamplingSpinBox->value(),
98 scaleSpinBox->value(),
99 lutCheckBox->checkState(),
100 vfWidthSpinBox->value(),
101 color.redF(), color.greenF(), color.blueF());
104 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
106 QString motion = "<b>Displacement : </b>";
107 QString motionValue = "<b>Length : </b>";
109 motion += QString::number(x,'f',1) + " ";
110 motion += QString::number(y,'f',1) + " ";
111 motion += QString::number(z,'f',1) + " ";
113 motionValue += QString::number(value,'f',1);
115 coordinatesLabel->setText(motion);
116 normLabel->setText(motionValue);
119 void vvOverlayPanel::getOverlayName(QString name)
121 QString filename = "<b>Compare with : </b>";
122 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
123 imageComparedLabel->setText(filename.toStdString().c_str());
126 void vvOverlayPanel::getOverlayProperty(int value)
129 compareFrame->show();
130 compareFrame->setEnabled(1);
131 colorHorizontalSlider->setEnabled(1);
132 colorHorizontalSlider->setValue(value);
134 compareFrame->hide();
135 compareFrame->setEnabled(0);
136 colorHorizontalSlider->setEnabled(0);
137 colorHorizontalSlider->setValue(0);
141 void vvOverlayPanel::setOverlayProperty()
143 emit OverlayPropertyUpdated(colorHorizontalSlider->value());
146 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
148 QString refValue = "<b>Pixel value in image 1 : </b>";
149 QString overlayValue = "<b>Pixel value in image 2 : </b>";
150 QString diffValue = "<b>Pixel difference : </b>";
152 refValue += QString::number(valueRef);
153 overlayValue += QString::number(valueOver);
154 diffValue += QString::number(valueRef - valueOver);
156 refValueLabel->setText(refValue);
157 valueLabel->setText(overlayValue);
158 diffValueLabel->setText(diffValue);
160 void vvOverlayPanel::getFusionName(QString name)
162 QString filename = "<b>Fusion with : </b>";
163 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
164 dataFusionnedLabel->setText(filename.toStdString().c_str());
167 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
171 fusionFrame->setEnabled(1);
172 opacityHorizontalSlider->setEnabled(1);
173 opacityHorizontalSlider->setValue(opacity);
174 thresOpacityHorizontalSlider->setEnabled(1);
175 thresOpacityHorizontalSlider->setValue(thresOpacity);
176 fusionColorMapComboBox->setEnabled(1);
177 fusionColorMapComboBox->setCurrentIndex(colormap);
178 windowSpinBox->setEnabled(1);
179 levelSpinBox->setEnabled(1);
180 windowSpinBox->setValue(window);
181 levelSpinBox->setValue(level);
184 fusionFrame->setEnabled(0);
185 opacityHorizontalSlider->setEnabled(0);
186 opacityHorizontalSlider->setValue(0);
187 thresOpacityHorizontalSlider->setEnabled(0);
188 thresOpacityHorizontalSlider->setValue(0);
189 fusionColorMapComboBox->setEnabled(0);
190 fusionColorMapComboBox->setCurrentIndex(-1);
191 windowSpinBox->setEnabled(0);
192 levelSpinBox->setEnabled(0);
196 void vvOverlayPanel::setFusionProperty()
198 emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
199 windowSpinBox->value(), levelSpinBox->value());
202 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
204 QString fusionValue = "<b>Pixel value in image 2 : </b>";
206 fusionValue += QString::number(value,'f',1);
208 valueFusionnedLabel->setText(fusionValue);
211 void vvOverlayPanel::VFColorChangeRequest()
213 QColor color(vfColorButton->palette().color(QPalette::Background));
214 color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
215 //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
216 vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
217 this->setVFProperty();
220 #endif /* end #define _vvOverlayPanel_CXX */