itom  3.0.0
rangeSlider.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, 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 RANGESLIDER_H
32 #define RANGESLIDER_H
33 
34 #include <QSlider>
35 
36 #include "commonWidgets.h"
37 
38 
39 class QStylePainter;
40 class RangeSliderPrivate;
41 
42 namespace ito {
43  class IntervalMeta; //forward declaration
44 }
45 
61 class ITOMWIDGETS_EXPORT RangeSlider : public QSlider
62 {
63  Q_OBJECT
64  Q_PROPERTY(int minimumValue READ minimumValue WRITE setMinimumValue)
65  Q_PROPERTY(int maximumValue READ maximumValue WRITE setMaximumValue)
66  Q_PROPERTY(int minimumPosition READ minimumPosition WRITE setMinimumPosition)
67  Q_PROPERTY(int maximumPosition READ maximumPosition WRITE setMaximumPosition)
68  Q_PROPERTY(uint stepSizePosition READ stepSizePosition WRITE setStepSizePosition)
69  Q_PROPERTY(uint minimumRange READ minimumRange WRITE setMinimumRange)
70  Q_PROPERTY(uint maximumRange READ maximumRange WRITE setMaximumRange)
71  Q_PROPERTY(uint stepSizeRange READ stepSizeRange WRITE setStepSizeRange)
72  Q_PROPERTY(bool rangeIncludeLimits READ rangeIncludeLimits WRITE setRangeIncludeLimits)
73  Q_PROPERTY(bool symmetricMoves READ symmetricMoves WRITE setSymmetricMoves)
74  Q_PROPERTY(QString handleToolTip READ handleToolTip WRITE setHandleToolTip)
75 
76 public:
77  // Superclass typedef
78  typedef QSlider Superclass;
82  explicit RangeSlider( Qt::Orientation o, QWidget* par= 0 );
83  explicit RangeSlider( QWidget* par = 0 );
84  virtual ~RangeSlider();
85 
91  int minimumValue() const;
92 
98  int maximumValue() const;
99 
103  int minimumPosition() const;
104  void setMinimumPosition(int min);
105 
109  int maximumPosition() const;
110  void setMaximumPosition(int max);
111 
115  uint stepSizePosition() const;
116  void setStepSizePosition(uint stepSize);
117 
121  uint minimumRange() const;
122  void setMinimumRange(uint min);
123 
127  uint maximumRange() const;
128  void setMaximumRange(uint max);
129 
133  uint stepSizeRange() const;
134  void setStepSizeRange(uint stepSize);
135 
140  bool rangeIncludeLimits() const;
141  void setRangeIncludeLimits(bool include);
142 
146  void setPositions(int min, int max);
147 
151  bool symmetricMoves()const;
152  void setSymmetricMoves(bool symmetry);
153 
159  QString handleToolTip()const;
160  void setHandleToolTip(const QString& toolTip);
161 
164  bool isMinimumSliderDown()const;
167  bool isMaximumSliderDown()const;
168 
173  void setLimitsFromIntervalMeta(const ito::IntervalMeta &intervalMeta);
174 
175 signals:
179  void minimumValueChanged(int min);
183  void maximumValueChanged(int max);
186  void valuesChanged(int min, int max);
187 
193  void minimumPositionChanged(int min);
194 
200  void maximumPositionChanged(int max);
201 
205  void positionsChanged(int min, int max);
206 
207 public slots:
214  void setMinimumValue(int min);
215 
222  void setMaximumValue(int max);
223 
231  void setValues(int min, int max);
232 
233 protected slots:
234  void onRangeChanged(int minimum, int maximum);
235 
236 protected:
237  RangeSlider( RangeSliderPrivate* impl, Qt::Orientation o, QWidget* par= 0 );
238  RangeSlider( RangeSliderPrivate* impl, QWidget* par = 0 );
239 
240  // Description:
241  // Standard Qt UI events
242  virtual void mousePressEvent(QMouseEvent* ev);
243  virtual void mouseMoveEvent(QMouseEvent* ev);
244  virtual void mouseReleaseEvent(QMouseEvent* ev);
245 
246  // Description:
247  // Rendering is done here.
248  virtual void paintEvent(QPaintEvent* ev);
249  virtual void initMinimumSliderStyleOption(QStyleOptionSlider* option) const;
250  virtual void initMaximumSliderStyleOption(QStyleOptionSlider* option) const;
251 
252  // Description:
253  // Reimplemented for the tooltips
254  virtual bool event(QEvent* event);
255 
256 protected:
257  QScopedPointer<RangeSliderPrivate> d_ptr;
258 
259 private:
260  Q_DECLARE_PRIVATE(RangeSlider);
261  Q_DISABLE_COPY(RangeSlider);
262 };
263 
264 #endif
265 
Definition: rangeSlider.cpp:45
Definition: apiFunctionsGraph.cpp:39
Definition: rangeSlider.h:61
Meta-information for Param of type IntArrayMeta that represent an interval [minimum, maximum).
Definition: paramMeta.h:638