Computer Assited Medical Intervention Tool Kit  version 5.0
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-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, 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
camitk::SliderTextWidget::valueToSlider
int valueToSlider(const double)
convert from value to slider
Definition: SliderTextWidget.cpp:204
camitk::SliderTextWidget::sliderToValue
double sliderToValue(const int)
convert from slider value to double
Definition: SliderTextWidget.cpp:199
camitk::SliderTextWidget::textModified
void textModified(QString)
When the user change the text.
Definition: SliderTextWidget.cpp:142
camitk::SliderTextWidget::updateSlider
void updateSlider()
update the slider position
Definition: SliderTextWidget.cpp:183
camitk::SliderTextWidget::getValue
double getValue() const
Get the current value.
Definition: SliderTextWidget.h:156
CamiTKAPI.h
camitk::SliderTextWidget::valueChanged
void valueChanged()
Signal emitted when the value has changed (either directly using the slider or when the user pressed ...
camitk::SliderTextWidget::lineEdit
QLineEdit * lineEdit
the line edit
Definition: SliderTextWidget.h:173
getValue
static Value getValue(const QMap< const QtProperty *, PrivateData > &propertyMap, const QtProperty *property, const Value &defaultValue=Value())
Definition: qtpropertymanager.cpp:222
camitk::SliderTextWidget::returnPressed
void returnPressed()
when the user press return in the line edit
Definition: SliderTextWidget.cpp:149
camitk::SliderTextWidget::~SliderTextWidget
~SliderTextWidget() override
Destructor.
Definition: SliderTextWidget.cpp:104
camitk::SliderTextWidget::setName
void setName(const QString &)
set the text label (name of the manipulated data)
Definition: SliderTextWidget.cpp:109
camitk::SliderSpinBoxWidget::slider
QSlider * slider
the QSlider instance
Definition: SliderSpinBoxWidget.h:151
camitk::SliderTextWidget::label
QLabel * label
the text label
Definition: SliderTextWidget.h:170
camitk::SliderSpinBoxWidget::valueChanged
void valueChanged(int)
if the user change the value either in the slider or the spinBox, this signal is emitted with the new...
camitk::SliderTextWidget::max
double max
the max real value
Definition: SliderTextWidget.h:167
camitk::SliderTextWidget::SliderTextWidget
SliderTextWidget(QWidget *parent=nullptr, Qt::WindowFlags fl=Qt::WindowFlags())
Default constructor, name is automatically used as the text label.
Definition: SliderTextWidget.cpp:59
camitk::SliderTextWidget::value
double value
the current value
Definition: SliderTextWidget.h:158
camitk::SliderTextWidget::setValue
void setValue(const double, bool emitValueChanged=false)
Update slider and lineedit GUI, emit the valueChanged signal only if the boolean is true (default=no)
Definition: SliderTextWidget.cpp:115
camitk::SliderTextWidget::updateLineEdit
void updateLineEdit()
Update the line edit value.
Definition: SliderTextWidget.cpp:169
SliderTextWidget.h
camitk::SliderTextWidget::slider
QSlider * slider
the slider
Definition: SliderTextWidget.h:176
camitk::SliderTextWidget::init
void init(double min=0.0, double max=100.0, double value=50.0)
initialize slider and lineedit with the label, min, max, and current value Default values are min=0,...
Definition: SliderTextWidget.cpp:126
camitk::SliderTextWidget::bgColor
QColor bgColor
the line edit bg color
Definition: SliderTextWidget.h:161
camitk::SliderTextWidget::min
double min
the min real value
Definition: SliderTextWidget.h:164
CAMITK_API
#define CAMITK_API
Definition: CamiTKAPI.h:49
camitk
Definition: Action.cpp:35