1 /*=========================================================================
4 Module: $RCSfile: vvIntensityValueSlider.cxx,v $
6 Date: $Date: 2010/02/24 11:42:42 $
7 Version: $Revision: 1.3 $
8 Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
11 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
12 CREATIS-LRMN http://www.creatis.insa-lyon.fr
14 This program is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation, version 3 of the License.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 =========================================================================*/
28 #include "vvIntensityValueSlider.h"
29 #include "clitkCommon.h"
31 //------------------------------------------------------------------------------
32 vvIntensityValueSlider::vvIntensityValueSlider(QWidget * parent, Qt::WindowFlags f)
33 :QWidget(parent,f), Ui::vvIntensityValueSlider()
41 // Connect signals & slots
42 connect(mSpinBox, SIGNAL(valueChanged(double)), this, SLOT(valueChangedFromSpinBox(double)));
43 connect(mSlider, SIGNAL(valueChanged(int)), this, SLOT(valueChangedFromSlider(int)));
45 //------------------------------------------------------------------------------
48 //------------------------------------------------------------------------------
49 vvIntensityValueSlider::~vvIntensityValueSlider() {
50 // DD("Delete vvIntensityValueSlider");
52 //------------------------------------------------------------------------------
55 //------------------------------------------------------------------------------
56 void vvIntensityValueSlider::valueChangedFromSpinBox(double v) {
57 // DD("valueChangedFromSpinBox");
63 //------------------------------------------------------------------------------
66 //------------------------------------------------------------------------------
67 void vvIntensityValueSlider::valueChangedFromSlider(int v) {
68 // DD("valueChangedFromSlider");
70 // DD(v*mSliderFactor);
71 mSpinBox->setValue(v*mSliderFactor);
72 // emit valueChanged(v*mSliderFactor);
74 //------------------------------------------------------------------------------
77 //------------------------------------------------------------------------------
78 void vvIntensityValueSlider::SetText(QString t) {
81 //------------------------------------------------------------------------------
84 //------------------------------------------------------------------------------
85 void vvIntensityValueSlider::SetImage(vvImage * im) {
89 //------------------------------------------------------------------------------
92 //------------------------------------------------------------------------------
93 void vvIntensityValueSlider::SetValue(double d) {
94 mSpinBox->setValue(d);
96 //------------------------------------------------------------------------------
99 //------------------------------------------------------------------------------
100 void vvIntensityValueSlider::SetMaximum(double max) {
101 mSlider->setMaximum(max);
102 mSpinBox->setMaximum(max);
103 if (mValue > max) { SetValue(max); }
104 QString tip = QString("Min = %1 Max = %2").arg(mSpinBox->minimum()).arg(max);
107 //------------------------------------------------------------------------------
110 //------------------------------------------------------------------------------
111 void vvIntensityValueSlider::SetMinimum(double min) {
112 mSlider->setMinimum(min);
113 mSpinBox->setMinimum(min);
114 if (mValue < min) { SetValue(min); }
115 QString tip = QString("Min = %1 Max = %2").arg(min).arg(mSpinBox->maximum());
118 //------------------------------------------------------------------------------
121 //------------------------------------------------------------------------------
122 void vvIntensityValueSlider::Update() {
123 // DD(mImage->GetScalarTypeAsString());
124 // DD(mImage->GetFirstVTKImageData()->GetScalarTypeMax());
125 // DD(mImage->GetFirstVTKImageData()->GetScalarTypeMin());
127 // double max = mImage->GetFirstVTKImageData()->GetScalarTypeMax();
128 // double min = mImage->GetFirstVTKImageData()->GetScalarTypeMin();
130 if (mImage->IsScalarTypeInteger()) {
132 mSpinBox->setSingleStep(1.0);
133 mSpinBox->setDecimals(0);
137 mImage->GetFirstVTKImageData()->GetScalarRange(range);
142 mSlider->setMaximum(mMax);
143 mSlider->setMinimum(mMin);
144 mSpinBox->setMaximum(mMax);
145 mSpinBox->setMinimum(mMin);
147 QString tip = QString("Min = %1 Max = %2").arg(mMin).arg(mMax);
151 std::cerr << "NO floating point image yet !!" << std::endl;
156 //------------------------------------------------------------------------------