source: ntrip/trunk/BNC/qwt/qwt_abstract_scale_draw.h@ 5915

Last change on this file since 5915 was 4271, checked in by mervart, 12 years ago
File size: 3.5 KB
Line 
1/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10#ifndef QWT_ABSTRACT_SCALE_DRAW_H
11#define QWT_ABSTRACT_SCALE_DRAW_H
12
13#include "qwt_global.h"
14#include "qwt_scale_div.h"
15#include "qwt_text.h"
16
17class QPalette;
18class QPainter;
19class QFont;
20class QwtScaleTransformation;
21class QwtScaleMap;
22
23/*!
24 \brief A abstract base class for drawing scales
25
26 QwtAbstractScaleDraw can be used to draw linear or logarithmic scales.
27
28 After a scale division has been specified as a QwtScaleDiv object
29 using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s),
30 the scale can be drawn with the QwtAbstractScaleDraw::draw() member.
31*/
32class QWT_EXPORT QwtAbstractScaleDraw
33{
34public:
35
36 /*!
37 Components of a scale
38 \sa enableComponent(), hasComponent
39 */
40 enum ScaleComponent
41 {
42 //! Backbone = the line where the ticks are located
43 Backbone = 0x01,
44
45 //! Ticks
46 Ticks = 0x02,
47
48 //! Labels
49 Labels = 0x04
50 };
51
52 //! Scale components
53 typedef QFlags<ScaleComponent> ScaleComponents;
54
55 QwtAbstractScaleDraw();
56 virtual ~QwtAbstractScaleDraw();
57
58 void setScaleDiv( const QwtScaleDiv &s );
59 const QwtScaleDiv& scaleDiv() const;
60
61 void setTransformation( QwtScaleTransformation * );
62 const QwtScaleMap &scaleMap() const;
63 QwtScaleMap &scaleMap();
64
65 void enableComponent( ScaleComponent, bool enable = true );
66 bool hasComponent( ScaleComponent ) const;
67
68 void setTickLength( QwtScaleDiv::TickType, double length );
69 double tickLength( QwtScaleDiv::TickType ) const;
70 double maxTickLength() const;
71
72 void setSpacing( double margin );
73 double spacing() const;
74
75 void setPenWidth( int width );
76 int penWidth() const;
77
78 virtual void draw( QPainter *, const QPalette & ) const;
79
80 virtual QwtText label( double ) const;
81
82 /*!
83 Calculate the extent
84
85 The extent is the distcance from the baseline to the outermost
86 pixel of the scale draw in opposite to its orientation.
87 It is at least minimumExtent() pixels.
88
89 \sa setMinimumExtent(), minimumExtent()
90 */
91 virtual double extent( const QFont & ) const = 0;
92
93 void setMinimumExtent( double );
94 double minimumExtent() const;
95
96protected:
97 /*!
98 Draw a tick
99
100 \param painter Painter
101 \param value Value of the tick
102 \param len Lenght of the tick
103
104 \sa drawBackbone(), drawLabel()
105 */
106 virtual void drawTick( QPainter *painter, double value, double len ) const = 0;
107
108 /*!
109 Draws the baseline of the scale
110 \param painter Painter
111
112 \sa drawTick(), drawLabel()
113 */
114 virtual void drawBackbone( QPainter *painter ) const = 0;
115
116 /*!
117 Draws the label for a major scale tick
118
119 \param painter Painter
120 \param value Value
121
122 \sa drawTick(), drawBackbone()
123 */
124 virtual void drawLabel( QPainter *painter, double value ) const = 0;
125
126 void invalidateCache();
127 const QwtText &tickLabel( const QFont &, double value ) const;
128
129private:
130 QwtAbstractScaleDraw( const QwtAbstractScaleDraw & );
131 QwtAbstractScaleDraw &operator=( const QwtAbstractScaleDraw & );
132
133 class PrivateData;
134 PrivateData *d_data;
135};
136
137Q_DECLARE_OPERATORS_FOR_FLAGS( QwtAbstractScaleDraw::ScaleComponents )
138
139#endif
Note: See TracBrowser for help on using the repository browser.