]> Creatis software - clitk.git/blob - vv/vvOverlayPanel.cxx
Merge branch 'master' of /home/dsarrut/clitk3.server
[clitk.git] / vv / vvOverlayPanel.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
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
8
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.
12
13   It is distributed under dual licence
14
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"
21
22 #include <QtGui>
23 #include <Qt>
24 #include "QTreePushButton.h"
25 #include <QColorDialog>
26
27 #include <vtksys/SystemTools.hxx>
28
29 //====================================================================
30 vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent)
31 {
32   setupUi(this);
33
34   vFFrame->hide();
35   compareFrame->hide();
36   fusionFrame->hide();
37   subSamplingSpinBox->setEnabled(0);
38   scaleSpinBox->setEnabled(0);
39   lutCheckBox->hide();
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()));
52 }
53
54 void vvOverlayPanel::getCurrentImageName(QString name)
55 {
56   QString filename = "<b>Current image : </b>";
57   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
58   currentImageLabel->setText(filename.toStdString().c_str());
59 }
60
61 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
62 {
63   if (subsampling != -1) {
64     vFFrame->show();
65     vFFrame->setEnabled(1);
66     subSamplingSpinBox->setEnabled(1);
67     subSamplingSpinBox->setValue(subsampling);
68     scaleSpinBox->setEnabled(1);
69     scaleSpinBox->setValue(scale);
70     lutCheckBox->setEnabled(1);
71     if (log > 0)
72       lutCheckBox->setCheckState(Qt::Checked);
73     else
74       lutCheckBox->setCheckState(Qt::Unchecked);
75   } else {
76     vFFrame->hide();
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);
84   }
85 }
86
87 void vvOverlayPanel::getVFName(QString name)
88 {
89   QString filename = "<b>Deformation Field : </b>";
90   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
91   vectorFieldNameLabel->setText(filename.toStdString().c_str());
92 }
93
94 void vvOverlayPanel::setVFProperty()
95 {
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());
102 }
103
104 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
105 {
106   QString motion = "<b>Displacement : </b>";
107   QString motionValue = "<b>Length : </b>";
108   if (visibility) {
109     motion += QString::number(x,'f',1) + " ";
110     motion += QString::number(y,'f',1) + " ";
111     motion += QString::number(z,'f',1) + " ";
112
113     motionValue += QString::number(value,'f',1);
114   }
115   coordinatesLabel->setText(motion);
116   normLabel->setText(motionValue);
117 }
118
119 void vvOverlayPanel::getOverlayName(QString name)
120 {
121   QString filename = "<b>Compare with : </b>";
122   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
123   imageComparedLabel->setText(filename.toStdString().c_str());
124 }
125
126 void vvOverlayPanel::getOverlayProperty(int value)
127 {
128   if (value > -1) {
129     compareFrame->show();
130     compareFrame->setEnabled(1);
131     colorHorizontalSlider->setEnabled(1);
132     colorHorizontalSlider->setValue(value);
133   } else {
134     compareFrame->hide();
135     compareFrame->setEnabled(0);
136     colorHorizontalSlider->setEnabled(0);
137     colorHorizontalSlider->setValue(0);
138   }
139 }
140
141 void vvOverlayPanel::setOverlayProperty()
142 {
143   emit OverlayPropertyUpdated(colorHorizontalSlider->value());
144 }
145
146 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
147 {
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>";
151   if (visibility) {
152     refValue += QString::number(valueRef);
153     overlayValue += QString::number(valueOver);
154     diffValue += QString::number(valueRef - valueOver);
155   }
156   refValueLabel->setText(refValue);
157   valueLabel->setText(overlayValue);
158   diffValueLabel->setText(diffValue);
159 }
160 void vvOverlayPanel::getFusionName(QString name)
161 {
162   QString filename = "<b>Fusion with : </b>";
163   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
164   dataFusionnedLabel->setText(filename.toStdString().c_str());
165 }
166
167 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
168 {
169   if (opacity > -1) {
170     fusionFrame->show();
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);
182   } else {
183     fusionFrame->hide();
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);
193   }
194 }
195
196 void vvOverlayPanel::setFusionProperty()
197 {
198   emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
199                              windowSpinBox->value(), levelSpinBox->value());
200 }
201
202 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
203 {
204   QString fusionValue = "<b>Pixel value in image 2 : </b>";
205   if (visibility) {
206     fusionValue += QString::number(value,'f',1);
207   }
208   valueFusionnedLabel->setText(fusionValue);
209 }
210
211 void vvOverlayPanel::VFColorChangeRequest()
212 {
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();
218 }
219
220 #endif /* end #define _vvOverlayPanel_CXX */
221