1 /*=========================================================================
4 Module: $RCSfile: vvIntensityValueSlider.cxx,v $
6 Date: $Date: 2010/03/01 07:37:25 $
7 Version: $Revision: 1.4 $
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"
30 //------------------------------------------------------------------------------
31 vvIntensityValueSlider::vvIntensityValueSlider(QWidget * parent, Qt::WindowFlags f)
32 :QWidget(parent,f), Ui::vvIntensityValueSlider()
40 // Connect signals & slots
41 connect(mSpinBox, SIGNAL(valueChanged(double)), this, SLOT(valueChangedFromSpinBox(double)));
42 connect(mSlider, SIGNAL(valueChanged(int)), this, SLOT(valueChangedFromSlider(int)));
44 //------------------------------------------------------------------------------
47 //------------------------------------------------------------------------------
48 vvIntensityValueSlider::~vvIntensityValueSlider() {
50 //------------------------------------------------------------------------------
53 //------------------------------------------------------------------------------
54 void vvIntensityValueSlider::valueChangedFromSpinBox(double v) {
59 //------------------------------------------------------------------------------
62 //------------------------------------------------------------------------------
63 void vvIntensityValueSlider::valueChangedFromSlider(int v) {
64 mSpinBox->setValue(v*mSliderFactor);
66 //------------------------------------------------------------------------------
69 //------------------------------------------------------------------------------
70 void vvIntensityValueSlider::SetText(QString t) {
73 //------------------------------------------------------------------------------
76 //------------------------------------------------------------------------------
77 void vvIntensityValueSlider::SetImage(vvImage * im) {
81 //------------------------------------------------------------------------------
84 //------------------------------------------------------------------------------
85 void vvIntensityValueSlider::SetValue(double d) {
86 mSpinBox->setValue(d);
88 //------------------------------------------------------------------------------
91 //------------------------------------------------------------------------------
92 void vvIntensityValueSlider::SetMaximum(double max) {
93 mSlider->setMaximum(max);
94 mSpinBox->setMaximum(max);
95 if (mValue > max) { SetValue(max); }
96 QString tip = QString("Min = %1 Max = %2").arg(mSpinBox->minimum()).arg(max);
99 //------------------------------------------------------------------------------
102 //------------------------------------------------------------------------------
103 void vvIntensityValueSlider::SetMinimum(double min) {
104 mSlider->setMinimum(min);
105 mSpinBox->setMinimum(min);
106 if (mValue < min) { SetValue(min); }
107 QString tip = QString("Min = %1 Max = %2").arg(min).arg(mSpinBox->maximum());
110 //------------------------------------------------------------------------------
113 //------------------------------------------------------------------------------
114 void vvIntensityValueSlider::Update() {
115 if (mImage->IsScalarTypeInteger()) {
117 mSpinBox->setSingleStep(1.0);
118 mSpinBox->setDecimals(0);
122 mImage->GetFirstVTKImageData()->GetScalarRange(range);
125 mSlider->setMaximum(mMax);
126 mSlider->setMinimum(mMin);
127 mSpinBox->setMaximum(mMax);
128 mSpinBox->setMinimum(mMin);
130 QString tip = QString("Min = %1 Max = %2").arg(mMin).arg(mMax);
134 std::cerr << "NO floating point image yet !!" << std::endl;
139 //------------------------------------------------------------------------------