[4271] | 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_SCALE_DRAW_H
|
---|
| 11 | #define QWT_SCALE_DRAW_H
|
---|
| 12 |
|
---|
| 13 | #include "qwt_global.h"
|
---|
| 14 | #include "qwt_abstract_scale_draw.h"
|
---|
| 15 | #include <qpoint.h>
|
---|
| 16 | #include <qrect.h>
|
---|
| 17 | #include <qtransform.h>
|
---|
| 18 |
|
---|
| 19 | /*!
|
---|
| 20 | \brief A class for drawing scales
|
---|
| 21 |
|
---|
| 22 | QwtScaleDraw can be used to draw linear or logarithmic scales.
|
---|
| 23 | A scale has a position, an alignment and a length, which can be specified .
|
---|
| 24 | The labels can be rotated and aligned
|
---|
| 25 | to the ticks using setLabelRotation() and setLabelAlignment().
|
---|
| 26 |
|
---|
| 27 | After a scale division has been specified as a QwtScaleDiv object
|
---|
| 28 | using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s),
|
---|
| 29 | the scale can be drawn with the QwtAbstractScaleDraw::draw() member.
|
---|
| 30 | */
|
---|
| 31 |
|
---|
| 32 | class QWT_EXPORT QwtScaleDraw: public QwtAbstractScaleDraw
|
---|
| 33 | {
|
---|
| 34 | public:
|
---|
| 35 | /*!
|
---|
| 36 | Alignment of the scale draw
|
---|
| 37 | \sa setAlignment(), alignment()
|
---|
| 38 | */
|
---|
| 39 | enum Alignment
|
---|
| 40 | {
|
---|
| 41 | //! The scale is below
|
---|
| 42 | BottomScale,
|
---|
| 43 |
|
---|
| 44 | //! The scale is above
|
---|
| 45 | TopScale,
|
---|
| 46 |
|
---|
| 47 | //! The scale is left
|
---|
| 48 | LeftScale,
|
---|
| 49 |
|
---|
| 50 | //! The scale is right
|
---|
| 51 | RightScale
|
---|
| 52 | };
|
---|
| 53 |
|
---|
| 54 | QwtScaleDraw();
|
---|
| 55 | virtual ~QwtScaleDraw();
|
---|
| 56 |
|
---|
| 57 | void getBorderDistHint( const QFont &, int &start, int &end ) const;
|
---|
| 58 | int minLabelDist( const QFont & ) const;
|
---|
| 59 |
|
---|
| 60 | int minLength( const QFont & ) const;
|
---|
| 61 | virtual double extent( const QFont & ) const;
|
---|
| 62 |
|
---|
| 63 | void move( double x, double y );
|
---|
| 64 | void move( const QPointF & );
|
---|
| 65 | void setLength( double length );
|
---|
| 66 |
|
---|
| 67 | Alignment alignment() const;
|
---|
| 68 | void setAlignment( Alignment );
|
---|
| 69 |
|
---|
| 70 | Qt::Orientation orientation() const;
|
---|
| 71 |
|
---|
| 72 | QPointF pos() const;
|
---|
| 73 | double length() const;
|
---|
| 74 |
|
---|
| 75 | void setLabelAlignment( Qt::Alignment );
|
---|
| 76 | Qt::Alignment labelAlignment() const;
|
---|
| 77 |
|
---|
| 78 | void setLabelRotation( double rotation );
|
---|
| 79 | double labelRotation() const;
|
---|
| 80 |
|
---|
| 81 | int maxLabelHeight( const QFont & ) const;
|
---|
| 82 | int maxLabelWidth( const QFont & ) const;
|
---|
| 83 |
|
---|
| 84 | QPointF labelPosition( double val ) const;
|
---|
| 85 |
|
---|
| 86 | QRectF labelRect( const QFont &, double val ) const;
|
---|
| 87 | QSizeF labelSize( const QFont &, double val ) const;
|
---|
| 88 |
|
---|
| 89 | QRect boundingLabelRect( const QFont &, double val ) const;
|
---|
| 90 |
|
---|
| 91 | protected:
|
---|
| 92 | QTransform labelTransformation( const QPointF &, const QSizeF & ) const;
|
---|
| 93 |
|
---|
| 94 | virtual void drawTick( QPainter *, double val, double len ) const;
|
---|
| 95 | virtual void drawBackbone( QPainter * ) const;
|
---|
| 96 | virtual void drawLabel( QPainter *, double val ) const;
|
---|
| 97 |
|
---|
| 98 | private:
|
---|
| 99 | QwtScaleDraw( const QwtScaleDraw & );
|
---|
| 100 | QwtScaleDraw &operator=( const QwtScaleDraw &other );
|
---|
| 101 |
|
---|
| 102 | void updateMap();
|
---|
| 103 |
|
---|
| 104 | class PrivateData;
|
---|
| 105 | PrivateData *d_data;
|
---|
| 106 | };
|
---|
| 107 |
|
---|
| 108 | /*!
|
---|
| 109 | Move the position of the scale
|
---|
| 110 | \sa move(const QPointF &)
|
---|
| 111 | */
|
---|
| 112 | inline void QwtScaleDraw::move( double x, double y )
|
---|
| 113 | {
|
---|
| 114 | move( QPointF( x, y ) );
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | #endif
|
---|