00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_SCALE_DRAW_H
00011 #define QWT_SCALE_DRAW_H
00012
00013 #include <qstring.h>
00014 #include <qrect.h>
00015 #include "qwt_global.h"
00016 #include "qwt_scale_map.h"
00017
00018 class QPainter;
00019 class QPen;
00020 class QColorGroup;
00021 class QPalette;
00022 class QFontMetrics;
00023 class QFont;
00024 class QwtScaleDiv;
00025
00041 class QWT_EXPORT QwtScaleDraw
00042 {
00043 public:
00048 enum Orientation { Bottom, Top, Left, Right, Round };
00049 enum Option { None = 0, Backbone = 1 };
00050
00051 QwtScaleDraw();
00052 QwtScaleDraw( const QwtScaleDraw & );
00053 virtual ~QwtScaleDraw();
00054
00055 QwtScaleDraw &operator=(const QwtScaleDraw &);
00056
00057 void setTransformation(const QwtScaleTransformation&);
00058 void setScaleDiv(const QwtScaleDiv &s);
00059
00060 const QwtScaleMap &map() const;
00061
00062 void setOptions(int opt);
00063 int options() const;
00064
00065 void setGeometry(int xorigin, int yorigin, int length, Orientation o);
00066 int x() const;
00067 int y() const;
00068 int length() const;
00069 Orientation orientation() const;
00070
00071 void setAngleRange(double angle1, double angle2);
00072 void setLabelFormat(char f, int prec, int fieldwidth = 0);
00073 void setLabelFlags(int flags);
00074 void setLabelRotation(double rotation);
00075 void setTickLength(unsigned int minLen,
00076 unsigned int medLen, unsigned int majLen);
00077
00078 void setMargin(uint hMargin, uint vMargin);
00079
00080 const QwtScaleDiv& scaleDiv() const;
00081 int maxWidth(const QPen &, const QFont &) const;
00082 int maxHeight(const QPen &, const QFont &) const;
00083
00084 void minBorderDist(const QFont &, int &start, int &end) const;
00085 int minLabelDist(const QFont &) const;
00086
00087 int minHeight(const QPen &, const QFont &) const;
00088 int minWidth(const QPen &, const QFont &) const;
00089 void labelFormat(char &f, int &prec, int &fieldwidth) const;
00090 int labelFlags() const;
00091 double labelRotation() const;
00092 void tickLength(unsigned int &minLen,
00093 unsigned int &medLen, unsigned int &majLen) const;
00094 unsigned int majTickLength() const;
00095
00096 #if QT_VERSION < 0x040000
00097 virtual void draw(QPainter *, const QColorGroup &) const;
00098 #else
00099 virtual void draw(QPainter *, const QPalette &) const;
00100 #endif
00101 virtual QString label(double) const;
00102
00103 protected:
00104 virtual void labelPlacement( const QFontMetrics &, double val,
00105 QPoint &pos, int &alignment, double &rotation) const;
00106 virtual int maxLabelHeight(const QFont &) const;
00107 virtual int maxLabelWidth(const QFont &) const;
00108 QRect labelBoundingRect(const QFont &, double val) const;
00109
00110 void drawTick(QPainter *p, double val, int len) const;
00111 void drawBackbone(QPainter *p) const;
00112 void drawLabel(QPainter *p, double val) const;
00113
00114 #if QT_VERSION < 0x040000
00115 QWMatrix labelWorldMatrix(const QFontMetrics &,
00116 const QPoint &, int alignment, double rotation,
00117 const QString &) const;
00118 #else
00119 QMatrix labelWorldMatrix(const QFontMetrics &,
00120 const QPoint &, int alignment, double rotation,
00121 const QString &) const;
00122 #endif
00123
00124 private:
00125 int operator==(const QwtScaleDraw &) const;
00126 int operator!=(const QwtScaleDraw &) const;
00127
00128 class PrivateData;
00129 PrivateData *d_data;
00130 };
00131
00132 #endif