CEDRIC  Revision_backup-2009-02
RulerWidget.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright (C) 2008 Boris Iven, Max Hermann
4  *
5  * This file is part of the "CEDRIC Event Display" application.
6  *
7  *****************************************************************************/
8 
9 #ifndef RULERWIDGET_H
10 #define RULERWIDGET_H
11 
12 #include <QWidget>
13 #include <QSize>
14 
15 
23 class RulerWidget : public QWidget
24 {
25  Q_OBJECT
26 
27 public:
29 
30  RulerWidget( QWidget* parent=0, Orientation orient=Horizontal );
31 
32  virtual ~RulerWidget();
33 
35  void setOrientation( Orientation orient );
36 
38  void setRange( float min, float max, bool keepAutoRange=false );
39 
41 
47  void setLimits( float floor, float ceil )
48  {
49  floorRange = floor;
50  ceilRange = ceil;
51 
52  dynamicLimits = false;
53  }
54 
56 
59  void setDynamicLimits( bool enable ) { dynamicLimits = enable; }
60 
62 
66  void setDivisions( int divisions ) { fixedDivisions = divisions; }
67 
69  void enableAutoRange( bool enable=true ) { autoRange = enable; }
70 
71  QSize minimumSizeHint() const { return QSize( 20, 20 ); }
72 
73 //protected: // should be protected, but used from outside (see MainWindow::selectEvent())
77  static float signum ( float value );
79  static int digits ( float value );
81  static float ceilDecimal ( float value );
83  static float floorDecimal( float value );
85  static int multiple ( float value );
87 
88 public slots:
89  void setCurrentMarkerEnabled( bool enable ) { curMarkerEnabled = enable; }
90  void setCurrentValue( float val ) { curVal = val; }
91 
92 protected:
93  void paintEvent( QPaintEvent* event );
94 
95 private:
96  Orientation orientation;
97  bool autoRange;
98  bool dynamicLimits;
99  int fixedDivisions;
100 
101  float direction;
102  float minRange;
103  float maxRange;
104  float floorRange;
105  float ceilRange;
106 
107  float curVal;
108  float curMarkerEnabled;
109 };
110 
111 #endif
void setLimits(float floor, float ceil)
Set absolute minimum and maximum value of ruler (disables dynamicLimits)
Definition: RulerWidget.h:47
Orientation
Definition: RulerWidget.h:28
Definition: RulerWidget.h:28
static int multiple(float value)
Returns signed highest digit of value (e.g. ceilDecimal(-751)=-7)
Definition: RulerWidget.cpp:30
void setDynamicLimits(bool enable)
Enable/Disable dynamicLimits calculation.
Definition: RulerWidget.h:59
static float ceilDecimal(float value)
Returns upper "whole" decimal value (e.g. ceilDecimal(157)=200)
Definition: RulerWidget.cpp:37
static float signum(float value)
Definition: RulerWidget.cpp:20
void setOrientation(Orientation orient)
Set orientation of ruler, either Ruler::Horizontal or Ruler::Vertical.
Definition: RulerWidget.cpp:69
Definition: RulerWidget.h:28
static float floorDecimal(float value)
Returns lower "whole" decimal value (e.g. ceilDecimal(157)=100)
Definition: RulerWidget.cpp:45
Simple ruler widget.
Definition: RulerWidget.h:23
void setCurrentMarkerEnabled(bool enable)
Definition: RulerWidget.h:89
void setCurrentValue(float val)
Definition: RulerWidget.h:90
void paintEvent(QPaintEvent *event)
Definition: RulerWidget.cpp:88
void setRange(float min, float max, bool keepAutoRange=false)
Set current visible range of ruler.
Definition: RulerWidget.cpp:283
QSize minimumSizeHint() const
Definition: RulerWidget.h:71
static int digits(float value)
Returns number of decimal digits.
Definition: RulerWidget.cpp:25
void setDivisions(int divisions)
Set number of markers between floorRange and ceilRange.
Definition: RulerWidget.h:66
virtual ~RulerWidget()
Definition: RulerWidget.cpp:65
RulerWidget(QWidget *parent=0, Orientation orient=Horizontal)
Definition: RulerWidget.cpp:54
void enableAutoRange(bool enable=true)
Enable to map ruler 1:1 to pixelsize.
Definition: RulerWidget.h:69