]> Creatis software - clitk.git/blob - vv/vvOverlayPanel.cxx
changes in license header
[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(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()));
51 }
52
53 void vvOverlayPanel::getCurrentImageName(QString name)
54 {
55   QString filename = "<b>Current image : </b>";
56   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
57   currentImageLabel->setText(filename.toStdString().c_str());
58 }
59
60 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
61 {
62   if (subsampling != -1) {
63     vFFrame->show();
64     vFFrame->setEnabled(1);
65     subSamplingSpinBox->setEnabled(1);
66     subSamplingSpinBox->setValue(subsampling);
67     scaleSpinBox->setEnabled(1);
68     scaleSpinBox->setValue(scale);
69     lutCheckBox->setEnabled(1);
70     if (log > 0)
71       lutCheckBox->setCheckState(Qt::Checked);
72     else
73       lutCheckBox->setCheckState(Qt::Unchecked);
74   } else {
75     vFFrame->hide();
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);
83   }
84 }
85
86 void vvOverlayPanel::getVFName(QString name)
87 {
88   QString filename = "<b>Deformation Field : </b>";
89   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
90   vectorFieldNameLabel->setText(filename.toStdString().c_str());
91 }
92
93 void vvOverlayPanel::setVFProperty()
94 {
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());
101 }
102
103 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
104 {
105   QString motion = "<b>Displacement : </b>";
106   QString motionValue = "<b>Length : </b>";
107   if (visibility) {
108     motion += QString::number(x,'f',1) + " ";
109     motion += QString::number(y,'f',1) + " ";
110     motion += QString::number(z,'f',1) + " ";
111
112     motionValue += QString::number(value,'f',1);
113   }
114   coordinatesLabel->setText(motion);
115   normLabel->setText(motionValue);
116 }
117
118 void vvOverlayPanel::getOverlayName(QString name)
119 {
120   QString filename = "<b>Compare with : </b>";
121   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
122   imageComparedLabel->setText(filename.toStdString().c_str());
123 }
124
125 void vvOverlayPanel::getOverlayProperty(int value)
126 {
127   if (value > -1) {
128     compareFrame->show();
129     compareFrame->setEnabled(1);
130     colorHorizontalSlider->setEnabled(1);
131     colorHorizontalSlider->setValue(value);
132   } else {
133     compareFrame->hide();
134     compareFrame->setEnabled(0);
135     colorHorizontalSlider->setEnabled(0);
136     colorHorizontalSlider->setValue(0);
137   }
138 }
139
140 void vvOverlayPanel::setOverlayProperty()
141 {
142   emit OverlayPropertyUpdated(colorHorizontalSlider->value());
143 }
144
145 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
146 {
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>";
150   if (visibility) {
151     refValue += QString::number(valueRef);
152     overlayValue += QString::number(valueOver);
153     diffValue += QString::number(valueRef - valueOver);
154   }
155   refValueLabel->setText(refValue);
156   valueLabel->setText(overlayValue);
157   diffValueLabel->setText(diffValue);
158 }
159 void vvOverlayPanel::getFusionName(QString name)
160 {
161   QString filename = "<b>Fusion with : </b>";
162   filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
163   dataFusionnedLabel->setText(filename.toStdString().c_str());
164 }
165
166 void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, double level)
167 {
168   if (opacity > -1) {
169     fusionFrame->show();
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);
179   } else {
180     fusionFrame->hide();
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);
188   }
189 }
190
191 void vvOverlayPanel::setFusionProperty()
192 {
193   emit FusionPropertyUpdated(opacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
194                              windowSpinBox->value(), levelSpinBox->value());
195 }
196
197 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
198 {
199   QString fusionValue = "<b>Pixel value in image 2 : </b>";
200   if (visibility) {
201     fusionValue += QString::number(value,'f',1);
202   }
203   valueFusionnedLabel->setText(fusionValue);
204 }
205
206 void vvOverlayPanel::VFColorChangeRequest()
207 {
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();
213 }
214
215 #endif /* end #define _vvOverlayPanel_CXX */
216