itom  4.1.0
doubleRangeSlider.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom and its software development toolkit (SDK).
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  In addition, as a special exception, the Institut fuer Technische
15  Optik (ITO) gives you certain additional rights.
16  These rights are described in the ITO LGPL Exception version 1.0,
17  which can be found in the file LGPL_EXCEPTION.txt in this package.
18 
19  itom is distributed in the hope that it will be useful, but
20  WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22  General Public Licence for more details.
23 
24  You should have received a copy of the GNU Library General Public License
25  along with itom. If not, see <http://www.gnu.org/licenses/>.
26 
27  This file is a port and modified version of the
28  Common framework (http://www.commontk.org)
29 *********************************************************************** */
30 
31 #ifndef DOUBLERANGESLIDER_H
32 #define DOUBLERANGESLIDER_H
33 
34 // Qt includes
35 #include <QWidget>
36 #include <QSlider>
37 
38 #include "commonWidgets.h"
39 
40 class RangeSlider;
42 class ValueProxy;
43 
49 class ITOMWIDGETS_EXPORT DoubleRangeSlider : public QWidget
50 {
51  Q_OBJECT
52  Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
53  Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
54  Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
55  Q_PROPERTY(double minimumValue READ minimumValue WRITE setMinimumValue)
56  Q_PROPERTY(double maximumValue READ maximumValue WRITE setMaximumValue)
57  Q_PROPERTY(double minimumPosition READ minimumPosition WRITE setMinimumPosition)
58  Q_PROPERTY(double maximumPosition READ maximumPosition WRITE setMaximumPosition)
59  Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
60  Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
61  Q_PROPERTY(double tickInterval READ tickInterval WRITE setTickInterval)
62  Q_PROPERTY(QSlider::TickPosition tickPosition READ tickPosition WRITE setTickPosition)
63  Q_PROPERTY(bool symmetricMoves READ symmetricMoves WRITE setSymmetricMoves)
64 public:
65  // Superclass typedef
66  typedef QWidget Superclass;
67 
70  DoubleRangeSlider( Qt::Orientation o, QWidget* par= 0 );
71 
74  DoubleRangeSlider( QWidget* par = 0 );
75 
77  virtual ~DoubleRangeSlider();
78 
84  void setSingleStep(double ss);
85  double singleStep()const;
86 
91  bool isValidStep(double step)const;
92 
98  void setTickInterval(double ti);
99  double tickInterval()const;
100 
105  void setTickPosition(QSlider::TickPosition position);
106  QSlider::TickPosition tickPosition()const;
107 
113  double minimum()const;
114  void setMinimum(double min);
115 
121  double maximum()const;
122  void setMaximum(double max);
123 
127  void setRange(double min, double max);
128 
134  double minimumValue() const;
135 
141  double maximumValue() const;
142 
146  double minimumPosition() const;
147  void setMinimumPosition(double minPos);
148 
152  double maximumPosition() const;
153  void setMaximumPosition(double maxPos);
154 
158  void setPositions(double minPos, double maxPos);
159 
167  void setTracking(bool enable);
168  bool hasTracking()const;
169 
174  void triggerAction(QAbstractSlider::SliderAction action);
175 
179  Qt::Orientation orientation()const;
180  void setOrientation(Qt::Orientation orientation);
181 
185  bool symmetricMoves()const;
186  void setSymmetricMoves(bool symmetry);
187 
190  void setValueProxy(ValueProxy* proxy);
191  ValueProxy* valueProxy() const;
192 
193 signals:
197  void minimumValueChanged(double minVal);
198 
202  void maximumValueChanged(double maxVal);
203 
206  void valuesChanged(double minVal, double maxVal);
207 
213  void minimumPositionChanged(double minPos);
214 
220  void maximumPositionChanged(double maxPos);
221 
225  void positionsChanged(double minPos, double maxPos);
226 
230  void sliderPressed();
231 
235  void sliderReleased();
236 
242  void rangeChanged(double min, double max);
243 
244 public slots:
250  void setMinimumValue(double minVal);
251 
257  void setMaximumValue(double maxVal);
258 
261  void setValues(double minVal, double maxVal);
262 
263 protected slots:
264  void onValuesChanged(int min, int max);
265 
266  void onMinPosChanged(int value);
267  void onMaxPosChanged(int value);
268  void onPositionsChanged(int min, int max);
269  void onRangeChanged(int min, int max);
270 
271  void onValueProxyAboutToBeModified();
272  void onValueProxyModified();
273 
274 protected:
275  RangeSlider* slider()const;
277  void setSlider(RangeSlider* slider);
278 
279 protected:
280  QScopedPointer<DoubleRangeSliderPrivate> d_ptr;
281 
282 private:
283  Q_DECLARE_PRIVATE(DoubleRangeSlider);
284  Q_DISABLE_COPY(DoubleRangeSlider);
285 };
286 
287 #endif
Definition: doubleRangeSlider.h:49
Definition: rangeSlider.h:61
Base class for value proxies. Value proxy allows to decouple the displayed value from the values acce...
Definition: valueProxy.h:45
Definition: doubleRangeSlider.cpp:47