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

Last change on this file since 8127 was 8127, checked in by stoecker, 2 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

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 QwtTransform;
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 setScaleDiv(), the scale can be drawn with the draw() member.
30*/
31class QWT_EXPORT QwtAbstractScaleDraw
32{
33public:
34
35    /*!
36       Components of a scale
37       \sa enableComponent(), hasComponent
38    */
39    enum ScaleComponent
40    {
41        //! Backbone = the line where the ticks are located
42        Backbone = 0x01,
43
44        //! Ticks
45        Ticks = 0x02,
46
47        //! Labels
48        Labels = 0x04
49    };
50
51    //! Scale components
52    typedef QFlags<ScaleComponent> ScaleComponents;
53
54    QwtAbstractScaleDraw();
55    virtual ~QwtAbstractScaleDraw();
56
57    void setScaleDiv( const QwtScaleDiv &s );
58    const QwtScaleDiv& scaleDiv() const;
59
60    void setTransformation( QwtTransform * );
61    const QwtScaleMap &scaleMap() const;
62    QwtScaleMap &scaleMap();
63
64    void enableComponent( ScaleComponent, bool enable = true );
65    bool hasComponent( ScaleComponent ) const;
66
67    void setTickLength( QwtScaleDiv::TickType, double length );
68    double tickLength( QwtScaleDiv::TickType ) const;
69    double maxTickLength() const;
70
71    void setSpacing( double margin );
72    double spacing() const;
73
74    void setPenWidth( int width );
75    int penWidth() const;
76
77    virtual void draw( QPainter *, const QPalette & ) const;
78
79    virtual QwtText label( double ) const;
80
81    /*!
82      Calculate the extent
83
84      The extent is the distance from the baseline to the outermost
85      pixel of the scale draw in opposite to its orientation.
86      It is at least minimumExtent() pixels.
87
88      \param font Font used for drawing the tick labels
89      \return Number of pixels
90
91      \sa setMinimumExtent(), minimumExtent()
92    */
93    virtual double extent( const QFont &font ) const = 0;
94
95    void setMinimumExtent( double );
96    double minimumExtent() const;
97
98protected:
99    /*!
100       Draw a tick
101
102       \param painter Painter
103       \param value Value of the tick
104       \param len Length of the tick
105
106       \sa drawBackbone(), drawLabel()
107    */
108    virtual void drawTick( QPainter *painter, double value, double len ) const = 0;
109
110    /*!
111      Draws the baseline of the scale
112      \param painter Painter
113
114      \sa drawTick(), drawLabel()
115    */
116    virtual void drawBackbone( QPainter *painter ) const = 0;
117
118    /*!
119        Draws the label for a major scale tick
120
121        \param painter Painter
122        \param value Value
123
124        \sa drawTick(), drawBackbone()
125    */
126    virtual void drawLabel( QPainter *painter, double value ) const = 0;
127
128    void invalidateCache();
129    const QwtText &tickLabel( const QFont &, double value ) const;
130
131private:
132    QwtAbstractScaleDraw( const QwtAbstractScaleDraw & );
133    QwtAbstractScaleDraw &operator=( const QwtAbstractScaleDraw & );
134
135    class PrivateData;
136    PrivateData *d_data;
137};
138
139Q_DECLARE_OPERATORS_FOR_FLAGS( QwtAbstractScaleDraw::ScaleComponents )
140
141#endif
Note: See TracBrowser for help on using the repository browser.