Computer Assisted Medical Intervention Tool Kit  version 5.2
SliderTextWidget.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2024 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
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_TEXT_WIDGET_H
27 #define SLIDER_TEXT_WIDGET_H
28 
29 // -- Core stuff
30 #include "CamiTKAPI.h"
31 
32 // -- QT stuff
33 #include <QColor>
34 #include <QLabel>
35 #include <QLineEdit>
36 #include <QSlider>
37 
38 
39 namespace camitk {
58 class CAMITK_API SliderTextWidget : public QWidget {
59  Q_OBJECT
60 
61 public:
63  SliderTextWidget(QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags());
64 
66  ~SliderTextWidget() override;
67 
69  void setName(const QString&);
70 
74  void init(double min = 0.0, double max = 100.0, double value = 50.0);
75 
77  double getValue() const;
78 
80  void setValue(const double, bool emitValueChanged = false);
81 
82 signals:
83 
85  void valueChanged();
86 
87 
88 protected slots:
90  void returnPressed();
91 
93  void valueChanged(int);
94 
96  void textModified(QString);
97 
98 private:
100  void updateSlider();
101 
103  void updateLineEdit();
104 
106  double sliderToValue(const int);
107 
109  int valueToSlider(const double);
110 
112  double value;
113 
115  QColor bgColor;
116 
118  double min;
119 
121  double max;
122 
124  QLabel* label;
125 
127  QLineEdit* lineEdit;
128 
130  QSlider* slider;
131 };
132 
133 inline double SliderTextWidget::getValue() const {
134  return value;
135 }
136 
137 }
138 #endif // SLIDERTEXTWIDGET_H
#define CAMITK_API
Definition: CamiTKAPI.h:49
This widget allows you to use a slider with a lineedit in a Dialog Box.
Definition: SliderTextWidget.h:58
void valueChanged()
Signal emitted when the value has changed (either directly using the slider or when the user pressed ...
double getValue() const
Get the current value.
Definition: SliderTextWidget.h:133
Definition: Action.cpp:36
static Value getValue(const QMap< const QtProperty *, PrivateData > &propertyMap, const QtProperty *property, const Value &defaultValue=Value())
Definition: qtpropertymanager.cpp:222