Qwt User's Guide: qwt_plot.h Source File

- Main Page
- Related Pages
- Classes
- Files

- File List

# qwt_plot.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_PLOT_H
    00011 #define QWT_PLOT_H
    00012
    00013 #include <qframe.h>
    00014 #include "qwt_global.h"
    00015 #include "qwt_array.h"
    00016 #include "qwt_text.h"
    00017 #include "qwt_plot_dict.h"
    00018 #include "qwt_scale_map.h"
    00019 #include "qwt_plot_printfilter.h"
    00020
    00021 class QwtPlotLayout;
    00022 class QwtLegend;
    00023 class QwtScaleWidget;
    00024 class QwtScaleEngine;
    00025 class QwtScaleDiv;
    00026 class QwtScaleDraw;
    00027 class QwtTextLabel;
    00028 class QwtPlotCanvas;
    00029 class QwtPlotPrintFilter;
    00030
    00072 class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict
    00073 {
    00074     Q_OBJECT
    00075     Q_PROPERTY( QString propertiesDocument
    00076         READ grabProperties WRITE applyProperties )
    00077
    00078 public:
    00087     enum Axis
    00088     {
    00089         yLeft,
    00090         yRight,
    00091         xBottom,
    00092         xTop,
    00093
    00094         axisCnt
    00095     };
    00096
    00119     enum LegendPosition
    00120     {
    00121         LeftLegend,
    00122         RightLegend,
    00123         BottomLegend,
    00124         TopLegend,
    00125
    00126         ExternalLegend
    00127     };
    00128
    00129     explicit QwtPlot(QWidget * = NULL);
    00130     explicit QwtPlot(const QwtText &title, QWidget *p = NULL);
    00131 #if QT_VERSION < 0x040000
    00132     explicit QwtPlot(QWidget *, const char* name);
    00133 #endif
    00134
    00135     virtual ~QwtPlot();
    00136
    00137     void applyProperties(const QString &);
    00138     QString grabProperties() const;
    00139
    00140     void setAutoReplot(bool tf = true);
    00141     bool autoReplot() const;
    00142
    00143     void print(QPaintDevice &p,
    00144         const QwtPlotPrintFilter & = QwtPlotPrintFilter()) const;
    00145     virtual void print(QPainter *, const QRect &rect,
    00146         const QwtPlotPrintFilter & = QwtPlotPrintFilter()) const;
    00147
    00148     // Layout
    00149
    00150     QwtPlotLayout *plotLayout();
    00151     const QwtPlotLayout *plotLayout() const;
    00152
    00153     void setMargin(int margin);
    00154     int margin() const;
    00155
    00156     // Title
    00157
    00158     void setTitle(const QString &);
    00159     void setTitle(const QwtText &t);
    00160     QwtText title() const;
    00161
    00162     QwtTextLabel *titleLabel();
    00163     const QwtTextLabel *titleLabel() const;
    00164
    00165     // Canvas
    00166
    00167     QwtPlotCanvas *canvas();
    00168     const QwtPlotCanvas *canvas() const;
    00169
    00170     void setCanvasBackground (const QColor &c);
    00171     const QColor& canvasBackground() const;
    00172
    00173     void setCanvasLineWidth(int w);
    00174     int canvasLineWidth() const;
    00175
    00176     virtual QwtScaleMap canvasMap(int axisId) const;
    00177
    00178     double invTransform(int axisId, int pos) const;
    00179     int transform(int axisId, double value) const;
    00180
    00181     // Axes
    00182
    00183     QwtScaleEngine *axisScaleEngine(int axisId);
    00184     const QwtScaleEngine *axisScaleEngine(int axisId) const;
    00185     void setAxisScaleEngine(int axisId, QwtScaleEngine *);
    00186
    00187     void setAxisAutoScale(int axisId);
    00188     bool axisAutoScale(int axisId) const;
    00189
    00190     void enableAxis(int axisId, bool tf = true);
    00191     bool axisEnabled(int axisId) const;
    00192
    00193     void setAxisFont(int axisId, const QFont &f);
    00194     QFont axisFont(int axisId) const;
    00195
    00196     void setAxisScale(int axisId, double min, double max, double step = 0);
    00197     void setAxisScaleDiv(int axisId, const QwtScaleDiv &);
    00198     void setAxisScaleDraw(int axisId, QwtScaleDraw *);
    00199
    00200     double axisStepSize(int axisId) const;
    00201
    00202     const QwtScaleDiv *axisScaleDiv(int axisId) const;
    00203     QwtScaleDiv *axisScaleDiv(int axisId);
    00204
    00205     const QwtScaleDraw *axisScaleDraw(int axisId) const;
    00206     QwtScaleDraw *axisScaleDraw(int axisId);
    00207
    00208     const QwtScaleWidget *axisWidget(int axisId) const;
    00209     QwtScaleWidget *axisWidget(int axisId);
    00210
    00211 #if QT_VERSION < 0x040000
    00212     void setAxisLabelAlignment(int axisId, int);
    00213 #else
    00214     void setAxisLabelAlignment(int axisId, Qt::Alignment);
    00215 #endif
    00216     void setAxisLabelRotation(int axisId, double rotation);
    00217
    00218     void setAxisTitle(int axisId, const QString &);
    00219     void setAxisTitle(int axisId, const QwtText &);
    00220     QwtText axisTitle(int axisId) const;
    00221
    00222     void setAxisMaxMinor(int axisId, int maxMinor);
    00223     int axisMaxMajor(int axisId) const;
    00224     void setAxisMaxMajor(int axisId, int maxMajor);
    00225     int axisMaxMinor(int axisId) const;
    00226
    00227     // Legend
    00228
    00229     void insertLegend(QwtLegend *, LegendPosition = QwtPlot::RightLegend,
    00230         double ratio = -1.0);
    00231
    00232     QwtLegend *legend();
    00233     const QwtLegend *legend() const;
    00234
    00235     // Misc
    00236
    00237     virtual void polish();
    00238     virtual QSize sizeHint() const;
    00239     virtual QSize minimumSizeHint() const;
    00240
    00241     virtual void updateLayout();
    00242     virtual void drawCanvas(QPainter *);
    00243
    00244     void updateAxes();
    00245
    00246     virtual bool event(QEvent *);
    00247
    00248 signals:
    00259     void legendClicked(QwtPlotItem *plotItem);
    00260
    00273     void legendChecked(QwtPlotItem *plotItem, bool on);
    00274
    00275 public slots:
    00276     virtual void clear();
    00277
    00278     virtual void replot();
    00279     void autoRefresh();
    00280
    00281 protected slots:
    00282     virtual void legendItemClicked();
    00283     virtual void legendItemChecked(bool);
    00284
    00285 protected:
    00286     static bool axisValid(int axisId);
    00287
    00288     virtual void drawItems(QPainter *, const QRect &,
    00289         const QwtScaleMap maps[axisCnt],
    00290         const QwtPlotPrintFilter &) const;
    00291
    00292     virtual void updateTabOrder();
    00293
    00294     virtual void resizeEvent(QResizeEvent *e);
    00295
    00296     virtual void printLegendItem(QPainter *,
    00297         const QWidget *, const QRect &) const;
    00298
    00299     virtual void printTitle(QPainter *, const QRect &) const;
    00300
    00301     virtual void printScale(QPainter *, int axisId, int startDist, int endDist,
    00302         int baseDist, const QRect &) const;
    00303
    00304     virtual void printCanvas(QPainter *,
    00305         const QRect &boundingRect, const QRect &canvasRect,
    00306         const QwtScaleMap maps[axisCnt], const QwtPlotPrintFilter &) const;
    00307
    00308     virtual void printLegend(QPainter *, const QRect &) const;
    00309
    00310 private:
    00311     void initAxesData();
    00312     void deleteAxesData();
    00313     void updateScaleDiv();
    00314
    00315     void initPlot(const QwtText &title);
    00316
    00317     class AxisData;
    00318     AxisData *d_axisData[axisCnt];
    00319
    00320     class PrivateData;
    00321     PrivateData *d_data;
    00322 };
    00323
    00324 #endif