Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# qwt_scldraw.h

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    00008  *****************************************************************************/
    00009
    00010 #ifndef QWT_SCLDRAW_H
    00011 #define QWT_SCLDRAW_H
    00012
    00013 #include <qstring.h>
    00014 #include <qfont.h>
    00015 #include <qrect.h>
    00016 #include <qcolor.h>
    00017 #include "qwt_global.h"
    00018 #include "qwt_dimap.h"
    00019 #include "qwt_scldiv.h"
    00020
    00021 class QPainter;
    00022
    00038 class QWT_EXPORT QwtScaleDraw: public QwtDiMap
    00039 {
    00040 public:
    00045     enum Orientation { Bottom, Top, Left, Right, Round };
    00046     enum Option { None = 0, Backbone = 1 };
    00047
    00048     QwtScaleDraw();
    00049     virtual ~QwtScaleDraw();
    00050
    00051     void setScale(const QwtScaleDiv &s);
    00052     void setScale(double vmin, double vmax, int maxMajIntv, int maxMinIntv,
    00053                   double step = 0.0, int logarithmic = 0);
    00054
    00055     void setOptions(int opt);
    00056     int options() const;
    00057
    00058     void setGeometry(int xorigin, int yorigin, int length, Orientation o);
    00059     int x() const;
    00060     int y() const;
    00061     int length() const;
    00062     Orientation orientation() const;
    00063
    00064     void setAngleRange(double angle1, double angle2);
    00065     void setLabelFormat(char f, int prec, int fieldwidth = 0);
    00066     void setLabelAlignment(int align);
    00067     void setLabelRotation(double rotation);
    00068     void setTickLength(unsigned int minLen,
    00069         unsigned int medLen, unsigned int majLen);
    00070
    00071     void setMargin(uint hMargin, uint vMargin);
    00072
    00074     const QwtScaleDiv& scaleDiv() const { return d_scldiv; }
    00075     int maxWidth(const QPen &pen, const QFontMetrics &fm) const;
    00076     int maxHeight(const QPen &pen, const QFontMetrics &fm) const;
    00077
    00078     void minBorderDist(const QFontMetrics &fm, int &start, int &end) const;
    00079     int minLabelDist(const QFontMetrics &fm) const;
    00080
    00081     int minHeight(const QPen &pen, const QFontMetrics &fm) const;
    00082     int minWidth(const QPen &pen, const QFontMetrics &fm) const;
    00083     void labelFormat(char &f, int &prec, int &fieldwidth) const;
    00084     int labelAlignment() const;
    00085     double labelRotation() const;
    00086     void tickLength(unsigned int &minLen,
    00087         unsigned int &medLen, unsigned int &majLen) const;
    00088     unsigned int majTickLength() const;
    00089
    00090     virtual void draw(QPainter *p) const;
    00091     virtual QString label(double) const;
    00092
    00093 protected:
    00094     virtual void labelPlacement( const QFontMetrics &, double val,
    00095         QPoint &pos, int &alignment, double &rotation) const;
    00096     virtual int maxLabelHeight(const QFontMetrics &) const;
    00097     virtual int maxLabelWidth(const QFontMetrics &) const;
    00098     QRect labelBoundingRect(
    00099         const QFontMetrics &, double val) const;
    00100
    00101     void drawTick(QPainter *p, double val, int len) const;
    00102     void drawBackbone(QPainter *p) const;
    00103     void drawLabel(QPainter *p, double val) const;
    00104
    00105     QWMatrix labelWorldMatrix(const QFontMetrics &,
    00106         const QPoint &, int alignment, double rotation,
    00107         const QString &) const;
    00108
    00109 private:
    00110     int d_options;
    00111
    00112     QwtScaleDiv d_scldiv;
    00113     Orientation d_orient;
    00114
    00115     int d_xorg;
    00116     int d_yorg;
    00117     int d_len;
    00118
    00119     unsigned int d_hpad;
    00120     unsigned int d_vpad;
    00121
    00122     unsigned int d_medLen;
    00123     unsigned int d_majLen;
    00124     unsigned int d_minLen;
    00125
    00126     int d_minAngle;
    00127     int d_maxAngle;
    00128
    00129     double d_xCenter;
    00130     double d_yCenter;
    00131     double d_radius;
    00132
    00133     char d_fmt;
    00134     int d_prec;
    00135     int d_fieldwidth;
    00136
    00137     int d_labelAlignment;
    00138     double d_labelRotation;
    00139
    00140     // d_formatBuffer must be able to hold:
    00141     // - a percent sign a '%'
    00142     // - a two digit positive fieldwidth
    00143     // - a point
    00144     // - a two digit positive precision
    00145     // - a format character ('e', 'f', 'g', 'E', 'F, 'G')
    00146     // - a terminating '/0' character
    00147     char d_formatBuffer[8];
    00148 };
    00149
    00150 #endif