Qwt User's Guide: qwt_plot.h Source File

Qwt User's Guide 6.0.1

- 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 "qwt_global.h"
    00014 #include "qwt_text.h"
    00015 #include "qwt_plot_dict.h"
    00016 #include "qwt_scale_map.h"
    00017 #include "qwt_interval.h"
    00018 #include <qframe.h>
    00019
    00020 class QwtPlotLayout;
    00021 class QwtLegend;
    00022 class QwtScaleWidget;
    00023 class QwtScaleEngine;
    00024 class QwtScaleDiv;
    00025 class QwtScaleDraw;
    00026 class QwtTextLabel;
    00027 class QwtPlotCanvas;
    00028
    00070 class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict
    00071 {
    00072     Q_OBJECT
    00073     Q_PROPERTY( QString propertiesDocument
    00074         READ grabProperties WRITE applyProperties )
    00075
    00076 public:
    00078     enum Axis
    00079     {
    00081         yLeft,
    00082
    00084         yRight,
    00085
    00087         xBottom,
    00088
    00090         xTop,
    00091
    00093         axisCnt
    00094     };
    00095
    00103     enum LegendPosition
    00104     {
    00106         LeftLegend,
    00107
    00109         RightLegend,
    00110
    00112         BottomLegend,
    00113
    00115         TopLegend,
    00116
    00123         ExternalLegend
    00124     };
    00125
    00126     explicit QwtPlot( QWidget * = NULL );
    00127     explicit QwtPlot( const QwtText &title, QWidget *p = NULL );
    00128
    00129     virtual ~QwtPlot();
    00130
    00131     void applyProperties( const QString & );
    00132     QString grabProperties() const;
    00133
    00134     void setAutoReplot( bool tf = true );
    00135     bool autoReplot() const;
    00136
    00137     // Layout
    00138
    00139     QwtPlotLayout *plotLayout();
    00140     const QwtPlotLayout *plotLayout() const;
    00141
    00142     // Title
    00143
    00144     void setTitle( const QString & );
    00145     void setTitle( const QwtText &t );
    00146     QwtText title() const;
    00147
    00148     QwtTextLabel *titleLabel();
    00149     const QwtTextLabel *titleLabel() const;
    00150
    00151     // Canvas
    00152
    00153     QwtPlotCanvas *canvas();
    00154     const QwtPlotCanvas *canvas() const;
    00155
    00156     void setCanvasBackground( const QBrush & );
    00157     QBrush canvasBackground() const;
    00158
    00159     void setCanvasLineWidth( int w );
    00160     int canvasLineWidth() const;
    00161
    00162     virtual QwtScaleMap canvasMap( int axisId ) const;
    00163
    00164     double invTransform( int axisId, int pos ) const;
    00165     double transform( int axisId, double value ) const;
    00166
    00167     // Axes
    00168
    00169     QwtScaleEngine *axisScaleEngine( int axisId );
    00170     const QwtScaleEngine *axisScaleEngine( int axisId ) const;
    00171     void setAxisScaleEngine( int axisId, QwtScaleEngine * );
    00172
    00173     void setAxisAutoScale( int axisId, bool on = true );
    00174     bool axisAutoScale( int axisId ) const;
    00175
    00176     void enableAxis( int axisId, bool tf = true );
    00177     bool axisEnabled( int axisId ) const;
    00178
    00179     void setAxisFont( int axisId, const QFont &f );
    00180     QFont axisFont( int axisId ) const;
    00181
    00182     void setAxisScale( int axisId, double min, double max, double step = 0 );
    00183     void setAxisScaleDiv( int axisId, const QwtScaleDiv & );
    00184     void setAxisScaleDraw( int axisId, QwtScaleDraw * );
    00185
    00186     double axisStepSize( int axisId ) const;
    00187     QwtInterval axisInterval( int axisId ) const;
    00188
    00189     const QwtScaleDiv *axisScaleDiv( int axisId ) const;
    00190     QwtScaleDiv *axisScaleDiv( int axisId );
    00191
    00192     const QwtScaleDraw *axisScaleDraw( int axisId ) const;
    00193     QwtScaleDraw *axisScaleDraw( int axisId );
    00194
    00195     const QwtScaleWidget *axisWidget( int axisId ) const;
    00196     QwtScaleWidget *axisWidget( int axisId );
    00197
    00198     void setAxisLabelAlignment( int axisId, Qt::Alignment );
    00199     void setAxisLabelRotation( int axisId, double rotation );
    00200
    00201     void setAxisTitle( int axisId, const QString & );
    00202     void setAxisTitle( int axisId, const QwtText & );
    00203     QwtText axisTitle( int axisId ) const;
    00204
    00205     void setAxisMaxMinor( int axisId, int maxMinor );
    00206     int axisMaxMinor( int axisId ) const;
    00207
    00208     void setAxisMaxMajor( int axisId, int maxMajor );
    00209     int axisMaxMajor( int axisId ) const;
    00210
    00211     // Legend
    00212
    00213     void insertLegend( QwtLegend *, LegendPosition = QwtPlot::RightLegend,
    00214         double ratio = -1.0 );
    00215
    00216     QwtLegend *legend();
    00217     const QwtLegend *legend() const;
    00218
    00219     // Misc
    00220
    00221     virtual QSize sizeHint() const;
    00222     virtual QSize minimumSizeHint() const;
    00223
    00224     virtual void updateLayout();
    00225     virtual void drawCanvas( QPainter * );
    00226
    00227     void updateAxes();
    00228
    00229     virtual bool event( QEvent * );
    00230
    00231     virtual void drawItems( QPainter *, const QRectF &,
    00232         const QwtScaleMap maps[axisCnt] ) const;
    00233
    00234 Q_SIGNALS:
    00245     void legendClicked( QwtPlotItem *plotItem );
    00246
    00259     void legendChecked( QwtPlotItem *plotItem, bool on );
    00260
    00261 public Q_SLOTS:
    00262     virtual void replot();
    00263     void autoRefresh();
    00264
    00265 protected Q_SLOTS:
    00266     virtual void legendItemClicked();
    00267     virtual void legendItemChecked( bool );
    00268
    00269 protected:
    00270     static bool axisValid( int axisId );
    00271
    00272     virtual void updateTabOrder();
    00273
    00274     virtual void resizeEvent( QResizeEvent *e );
    00275
    00276 private:
    00277     void initAxesData();
    00278     void deleteAxesData();
    00279     void updateScaleDiv();
    00280
    00281     void initPlot( const QwtText &title );
    00282
    00283     class AxisData;
    00284     AxisData *d_axisData[axisCnt];
    00285
    00286     class PrivateData;
    00287     PrivateData *d_data;
    00288 };
    00289
    00290 #endif