Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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-2013 UJF-Grenoble 1, 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_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
40 {
55 class CAMITK_API SliderTextWidget : public QWidget {
56  Q_OBJECT
57 
58  public:
60  SliderTextWidget(QWidget* parent = 0, Qt::WFlags fl = 0);
61 
64 
66  void setName(const QString &);
67 
71  void init(double min=0.0, double max=100.0, double value=50.0);
72 
74  double getValue() const;
75 
77  void setValue(const double, bool emitValueChanged = false);
78 
79  signals:
80 
82  void valueChanged();
83 
84 
85  protected slots:
87  void returnPressed();
88 
90  void valueChanged(int);
91 
93  void textModified(const QString &);
94 
95  private:
97  void updateSlider();
98 
100  void updateLineEdit();
101 
103  double sliderToValue(const int);
104 
106  int valueToSlider(const double);
107 
109  double value;
110 
112  QColor bgColor;
113 
115  double min;
116 
118  double max;
119 
121  QLabel *label;
122 
124  QLineEdit *lineEdit;
125 
127  QSlider *slider;
128 };
129 
130 inline double SliderTextWidget::getValue() const {
131  return value;
132 }
133 
134 }
135 #endif // SLIDERTEXTWIDGET_H