Computer Assited Medical Intervention Tool Kit  version 4.1
SliderSpinBoxWidget.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef SLIDER_SPIN_BOX_WIDGET_H
27 #define SLIDER_SPIN_BOX_WIDGET_H
28 
29 // -- QT stuff
30 #include <QSpinBox>
31 #include <QSlider>
32 
33 
34 namespace camitk {
42 class SliderSpinBoxWidget : public QWidget {
43  Q_OBJECT
44 
45 public:
47  SliderSpinBoxWidget(QWidget* parent = nullptr);
48 
50  ~SliderSpinBoxWidget() override = default;
51 
53  int getValue() const;
54 
56  void setValue(int value);
57 
59  void setRange(int min, int max);
60 
62  void addSingleStep();
63 
65  void subSingleStep();
66 
68  void addPageStep();
69 
71  void subPageStep();
72 
74  QSpinBox* getSpinBox() {
75  return spinBox;
76  }
77 
79  QSlider* getSlider() {
80  return slider;
81  }
82 
83 
84 signals:
88  void valueChanged(int);
89 
90 protected slots:
92  void spinBoxValueChanged(int);
93 
95  void sliderValueChanged(int);
96 
97 private:
99  QSpinBox* spinBox;
100 
102  QSlider* slider;
103 
105  void updateSpinBoxValue(int);
106 
108  void updateSliderValue(int);
109 
110 };
111 
112 }
113 
114 #endif
A utility class to have QSpinBox and QSlider synchronized.
Definition: SliderSpinBoxWidget.h:42
~SliderSpinBoxWidget() override=default
destructor
int getValue() const
get the current value
Definition: SliderSpinBoxWidget.cpp:62
void addPageStep()
add a larger number of natural steps to the value, for information exact number of added step is min(...
Definition: SliderSpinBoxWidget.cpp:157
void subSingleStep()
substract 1 to the value
Definition: SliderSpinBoxWidget.cpp:146
QSpinBox * spinBox
the QSpinBox instance
Definition: SliderSpinBoxWidget.h:99
Definition: Action.cpp:36
void updateSliderValue(int)
update the slider value (block signals)
Definition: SliderSpinBoxWidget.cpp:119
QSlider * slider
the QSlider instance
Definition: SliderSpinBoxWidget.h:102
void setValue(int value)
set the value (force)
Definition: SliderSpinBoxWidget.cpp:67
void setRange(int min, int max)
set the range
Definition: SliderSpinBoxWidget.cpp:75
void updateSpinBoxValue(int)
update the spinBox value (block signals)
Definition: SliderSpinBoxWidget.cpp:103
void sliderValueChanged(int)
any change in the slider value is connected to this slot (update the spinBox)
Definition: SliderSpinBoxWidget.cpp:97
void valueChanged(int)
if the user change the value either in the slider or the spinBox, this signal is emitted with the new...
void addSingleStep()
add 1 to the value
Definition: SliderSpinBoxWidget.cpp:136
void spinBoxValueChanged(int)
any change in the spinBox value is connected to this slot (update the slider)
Definition: SliderSpinBoxWidget.cpp:91
QSlider * getSlider()
the QSlider instance
Definition: SliderSpinBoxWidget.h:79
SliderSpinBoxWidget(QWidget *parent=nullptr)
constructor (have to give the parent widget)
Definition: SliderSpinBoxWidget.cpp:36
QSpinBox * getSpinBox()
the QSpinBox instance
Definition: SliderSpinBoxWidget.h:74
void subPageStep()
substract a larger number of natural steps to the value, for information exact number of added step i...
Definition: SliderSpinBoxWidget.cpp:167