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://oncora1.lyon.fnclcc.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(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
49 connect(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
50 connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
53 void vvOverlayPanel::getCurrentImageName(QString name)
55 QString filename = "<b>Current image : </b>";
56 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
57 currentImageLabel->setText(filename.toStdString().c_str());
60 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
62 if (subsampling != -1) {
64 vFFrame->setEnabled(1);
65 subSamplingSpinBox->setEnabled(1);
66 subSamplingSpinBox->setValue(subsampling);
67 scaleSpinBox->setEnabled(1);
68 scaleSpinBox->setValue(scale);
69 lutCheckBox->setEnabled(1);
71 lutCheckBox->setCheckState(Qt::Checked);
73 lutCheckBox->setCheckState(Qt::Unchecked);
76 vFFrame->setEnabled(0);
77 subSamplingSpinBox->setEnabled(0);
78 subSamplingSpinBox->setValue(0);
79 scaleSpinBox->setEnabled(0);
80 scaleSpinBox->setValue(0);
81 lutCheckBox->setEnabled(0);
82 lutCheckBox->setCheckState(Qt::Unchecked);
86 void vvOverlayPanel::getVFName(QString name)
88 QString filename = "<b>Deformation Field : </b>";
89 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
90 vectorFieldNameLabel->setText(filename.toStdString().c_str());
93 void vvOverlayPanel::setVFProperty()
95 QColor color(vfColorButton->palette().color(QPalette::Background));
96 emit VFPropertyUpdated(subSamplingSpinBox->value(),
97 scaleSpinBox->value(),
98 lutCheckBox->checkState(),
99 vfWidthSpinBox->value(),
100 color.redF(), color.greenF(), color.blueF());
103 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
105 QString motion = "<b>Displacement : </b>";
106 QString motionValue = "<b>Length : </b>";
108 motion += QString::number(x,'f',1) + " ";
109 motion += QString::number(y,'f',1) + " ";
110 motion += QString::number(z,'f',1) + " ";
112 motionValue += QString::number(value,'f',1);
114 coordinatesLabel->setText(motion);
115 normLabel->setText(motionValue);
118 void vvOverlayPanel::getOverlayName(QString name)
120 QString filename = "<b>Compare with : </b>";
121 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
122 imageComparedLabel->setText(filename.toStdString().c_str());
125 void vvOverlayPanel::getOverlayProperty(int value)
128 compareFrame->show();
129 compareFrame->setEnabled(1);
130 colorHorizontalSlider->setEnabled(1);
131 colorHorizontalSlider->setValue(value);
133 compareFrame->hide();
134 compareFrame->setEnabled(0);
135 colorHorizontalSlider->setEnabled(0);
136 colorHorizontalSlider->setValue(0);
140 void vvOverlayPanel::setOverlayProperty()
142 emit OverlayPropertyUpdated(colorHorizontalSlider->value());
145 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
147 QString refValue = "<b>Pixel value in image 1 : </b>";
148 QString overlayValue = "<b>Pixel value in image 2 : </b>";
149 QString diffValue = "<b>Pixel difference : </b>";
151 refValue += QString::number(valueRef);
152 overlayValue += QString::number(valueOver,'f',1);
153 diffValue += QString::number(valueRef - valueOver,'f',1);
155 refValueLabel->setText(refValue);
156 valueLabel->setText(overlayValue);
157 diffValueLabel->setText(diffValue);
159 void vvOverlayPanel::getFusionName(QString name)
161 QString filename = "<b>Fusion with : </b>";
162 filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
163 dataFusionnedLabel->setText(filename.toStdString().c_str());
166 void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, double level)
170 fusionFrame->setEnabled(1);
171 opacityHorizontalSlider->setEnabled(1);
172 opacityHorizontalSlider->setValue(opacity);
173 fusionColorMapComboBox->setEnabled(1);
174 fusionColorMapComboBox->setCurrentIndex(colormap);
175 windowSpinBox->setEnabled(1);
176 levelSpinBox->setEnabled(1);
177 windowSpinBox->setValue(window);
178 levelSpinBox->setValue(level);
181 fusionFrame->setEnabled(0);
182 opacityHorizontalSlider->setEnabled(0);
183 opacityHorizontalSlider->setValue(0);
184 fusionColorMapComboBox->setEnabled(0);
185 fusionColorMapComboBox->setCurrentIndex(-1);
186 windowSpinBox->setEnabled(0);
187 levelSpinBox->setEnabled(0);
191 void vvOverlayPanel::setFusionProperty()
193 emit FusionPropertyUpdated(opacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
194 windowSpinBox->value(), levelSpinBox->value());
197 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
199 QString fusionValue = "<b>Pixel value in image 2 : </b>";
201 fusionValue += QString::number(value,'f',1);
203 valueFusionnedLabel->setText(fusionValue);
206 void vvOverlayPanel::VFColorChangeRequest()
208 QColor color(vfColorButton->palette().color(QPalette::Background));
209 color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
210 //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
211 vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
212 this->setVFProperty();
215 #endif /* end #define _vvOverlayPanel_CXX */