]> Creatis software - clitk.git/blob - vv/vvOverlayPanel.cxx
removed headers
[clitk.git] / vv / vvOverlayPanel.cxx
1 #ifndef _vvOverlayPanel_CXX
2 #define _vvOverlayPanel_CXX
3 #include "vvOverlayPanel.h"
4
5 #include <QtGui>
6 #include <Qt>
7 #include "QTreePushButton.h"
8
9 #include <vtksys/SystemTools.hxx>
10
11 //====================================================================
12 vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent)
13 {
14     setupUi(this);
15
16     vFFrame->hide();
17     compareFrame->hide();
18     fusionFrame->hide();
19     subSamplingSpinBox->setEnabled(0);
20     scaleSpinBox->setEnabled(0);
21     lutCheckBox->hide();
22     lutCheckBox->setEnabled(0);
23     connect(subSamplingSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
24     connect(scaleSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
25     connect(lutCheckBox,SIGNAL(clicked()),this,SLOT(setVFProperty()));
26     connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty()));
27     connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
28     connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
29     connect(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
30     connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
31 }
32
33 void vvOverlayPanel::getCurrentImageName(QString name)
34 {
35     QString filename = "<b>Current image : </b>";
36     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
37     currentImageLabel->setText(filename.toStdString().c_str());
38 }
39
40 void vvOverlayPanel::getVFProperty(int subsampling, int scale, int log)
41 {
42     if (subsampling != -1)
43     {
44         vFFrame->show();
45         vFFrame->setEnabled(1);
46         subSamplingSpinBox->setEnabled(1);
47         subSamplingSpinBox->setValue(subsampling);
48         scaleSpinBox->setEnabled(1);
49         scaleSpinBox->setValue(scale);
50         lutCheckBox->setEnabled(1);
51         if (log > 0)
52             lutCheckBox->setCheckState(Qt::Checked);
53         else
54             lutCheckBox->setCheckState(Qt::Unchecked);
55     }
56     else
57     {
58         vFFrame->hide();
59         vFFrame->setEnabled(0);
60         subSamplingSpinBox->setEnabled(0);
61         subSamplingSpinBox->setValue(0);
62         scaleSpinBox->setEnabled(0);
63         scaleSpinBox->setValue(0);
64         lutCheckBox->setEnabled(0);
65         lutCheckBox->setCheckState(Qt::Unchecked);
66     }
67 }
68
69 void vvOverlayPanel::getVFName(QString name)
70 {
71     QString filename = "<b>Deformation Field : </b>";
72     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
73     vectorFieldNameLabel->setText(filename.toStdString().c_str());
74 }
75
76 void vvOverlayPanel::setVFProperty()
77 {
78     emit VFPropertyUpdated(subSamplingSpinBox->value(),
79                            scaleSpinBox->value(),
80                            lutCheckBox->checkState());
81 }
82
83 void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value)
84 {
85     QString motion = "<b>Displacement : </b>";
86     QString motionValue = "<b>Length : </b>";
87     if (visibility)
88     {
89         motion += QString::number(x,'f',1) + " ";
90         motion += QString::number(y,'f',1) + " ";
91         motion += QString::number(z,'f',1) + " ";
92
93         motionValue += QString::number(value,'f',1);
94     }
95     coordinatesLabel->setText(motion);
96     normLabel->setText(motionValue);
97 }
98
99 void vvOverlayPanel::getOverlayName(QString name)
100 {
101     QString filename = "<b>Compare with : </b>";
102     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
103     imageComparedLabel->setText(filename.toStdString().c_str());
104 }
105
106 void vvOverlayPanel::getOverlayProperty(int value)
107 {
108     if (value > -1)
109     {
110         compareFrame->show();
111         compareFrame->setEnabled(1);
112         colorHorizontalSlider->setEnabled(1);
113         colorHorizontalSlider->setValue(value);
114     }
115     else
116     {
117         compareFrame->hide();
118         compareFrame->setEnabled(0);
119         colorHorizontalSlider->setEnabled(0);
120         colorHorizontalSlider->setValue(0);
121     }
122 }
123
124 void vvOverlayPanel::setOverlayProperty()
125 {
126     emit OverlayPropertyUpdated(colorHorizontalSlider->value());
127 }
128
129 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
130 {
131     QString refValue = "<b>Pixel value in image 1 : </b>";
132     QString overlayValue = "<b>Pixel value in image 2 : </b>";
133     QString diffValue = "<b>Pixel difference : </b>";
134     if (visibility)
135     {
136         refValue += QString::number(valueRef);
137         overlayValue += QString::number(valueOver,'f',1);
138         diffValue += QString::number(valueRef - valueOver,'f',1);
139     }
140     refValueLabel->setText(refValue);
141     valueLabel->setText(overlayValue);
142     diffValueLabel->setText(diffValue);
143 }
144 void vvOverlayPanel::getFusionName(QString name)
145 {
146     QString filename = "<b>Fusion with : </b>";
147     filename += vtksys::SystemTools::GetFilenameWithoutExtension(name.toStdString()).c_str();
148     dataFusionnedLabel->setText(filename.toStdString().c_str());
149 }
150
151 void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, double level)
152 {
153     if (opacity > -1)
154     {
155         fusionFrame->show();
156         fusionFrame->setEnabled(1);
157         opacityHorizontalSlider->setEnabled(1);
158         opacityHorizontalSlider->setValue(opacity);
159         fusionColorMapComboBox->setEnabled(1);
160         fusionColorMapComboBox->setCurrentIndex(colormap);
161         windowSpinBox->setEnabled(1);
162         levelSpinBox->setEnabled(1);
163         windowSpinBox->setValue(window);
164         levelSpinBox->setValue(level);
165     }
166     else
167     {
168         fusionFrame->hide();
169         fusionFrame->setEnabled(0);
170         opacityHorizontalSlider->setEnabled(0);
171         opacityHorizontalSlider->setValue(0);
172         fusionColorMapComboBox->setEnabled(0);
173         fusionColorMapComboBox->setCurrentIndex(-1);
174         windowSpinBox->setEnabled(0);
175         levelSpinBox->setEnabled(0);
176     }
177 }
178
179 void vvOverlayPanel::setFusionProperty()
180 {
181     emit FusionPropertyUpdated(opacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
182                                windowSpinBox->value(), levelSpinBox->value());
183 }
184
185 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
186 {
187     QString fusionValue = "<b>Pixel value in image 2 : </b>";
188     if (visibility)
189     {
190         fusionValue += QString::number(value,'f',1);
191     }
192     valueFusionnedLabel->setText(fusionValue);
193 }
194
195 #endif /* end #define _vvOverlayPanel_CXX */
196