Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
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 #include <qlist.h>
00020 #include <qvariant.h>
00021
00022 class QwtPlotLayout;
00023 class QwtAbstractLegend;
00024 class QwtScaleWidget;
00025 class QwtScaleEngine;
00026 class QwtScaleDiv;
00027 class QwtScaleDraw;
00028 class QwtTextLabel;
00029
00074 class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict
00075 {
00076 Q_OBJECT
00077
00078 Q_PROPERTY( QBrush canvasBackground
00079 READ canvasBackground WRITE setCanvasBackground )
00080 Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot )
00081
00082 #if 0
00083
00084
00085
00086
00087 Q_PROPERTY( QString propertiesDocument
00088 READ grabProperties WRITE applyProperties )
00089 #endif
00090
00091 public:
00093 enum Axis
00094 {
00096 yLeft,
00097
00099 yRight,
00100
00102 xBottom,
00103
00105 xTop,
00106
00108 axisCnt
00109 };
00110
00116 enum LegendPosition
00117 {
00119 LeftLegend,
00120
00122 RightLegend,
00123
00125 BottomLegend,
00126
00128 TopLegend
00129 };
00130
00131 explicit QwtPlot( QWidget * = NULL );
00132 explicit QwtPlot( const QwtText &title, QWidget * = NULL );
00133
00134 virtual ~QwtPlot();
00135
00136 void applyProperties( const QString & );
00137 QString grabProperties() const;
00138
00139 void setAutoReplot( bool = true );
00140 bool autoReplot() const;
00141
00142
00143
00144 void setPlotLayout( QwtPlotLayout * );
00145
00146 QwtPlotLayout *plotLayout();
00147 const QwtPlotLayout *plotLayout() const;
00148
00149
00150
00151 void setTitle( const QString & );
00152 void setTitle( const QwtText &t );
00153 QwtText title() const;
00154
00155 QwtTextLabel *titleLabel();
00156 const QwtTextLabel *titleLabel() const;
00157
00158
00159
00160 void setFooter( const QString & );
00161 void setFooter( const QwtText &t );
00162 QwtText footer() const;
00163
00164 QwtTextLabel *footerLabel();
00165 const QwtTextLabel *footerLabel() const;
00166
00167
00168
00169 void setCanvas( QWidget * );
00170
00171 QWidget *canvas();
00172 const QWidget *canvas() const;
00173
00174 void setCanvasBackground( const QBrush & );
00175 QBrush canvasBackground() const;
00176
00177 virtual QwtScaleMap canvasMap( int axisId ) const;
00178
00179 double invTransform( int axisId, int pos ) const;
00180 double transform( int axisId, double value ) const;
00181
00182
00183
00184 QwtScaleEngine *axisScaleEngine( int axisId );
00185 const QwtScaleEngine *axisScaleEngine( int axisId ) const;
00186 void setAxisScaleEngine( int axisId, QwtScaleEngine * );
00187
00188 void setAxisAutoScale( int axisId, bool on = true );
00189 bool axisAutoScale( int axisId ) const;
00190
00191 void enableAxis( int axisId, bool tf = true );
00192 bool axisEnabled( int axisId ) const;
00193
00194 void setAxisFont( int axisId, const QFont &f );
00195 QFont axisFont( int axisId ) const;
00196
00197 void setAxisScale( int axisId, double min, double max, double step = 0 );
00198 void setAxisScaleDiv( int axisId, const QwtScaleDiv & );
00199 void setAxisScaleDraw( int axisId, QwtScaleDraw * );
00200
00201 double axisStepSize( int axisId ) const;
00202 QwtInterval axisInterval( int axisId ) const;
00203
00204 const QwtScaleDiv &axisScaleDiv( int axisId ) const;
00205
00206 const QwtScaleDraw *axisScaleDraw( int axisId ) const;
00207 QwtScaleDraw *axisScaleDraw( int axisId );
00208
00209 const QwtScaleWidget *axisWidget( int axisId ) const;
00210 QwtScaleWidget *axisWidget( int axisId );
00211
00212 void setAxisLabelAlignment( int axisId, Qt::Alignment );
00213 void setAxisLabelRotation( int axisId, double rotation );
00214
00215 void setAxisTitle( int axisId, const QString & );
00216 void setAxisTitle( int axisId, const QwtText & );
00217 QwtText axisTitle( int axisId ) const;
00218
00219 void setAxisMaxMinor( int axisId, int maxMinor );
00220 int axisMaxMinor( int axisId ) const;
00221
00222 void setAxisMaxMajor( int axisId, int maxMajor );
00223 int axisMaxMajor( int axisId ) const;
00224
00225
00226
00227 void insertLegend( QwtAbstractLegend *,
00228 LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 );
00229
00230 QwtAbstractLegend *legend();
00231 const QwtAbstractLegend *legend() const;
00232
00233 void updateLegend();
00234 void updateLegend( const QwtPlotItem * );
00235
00236
00237
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 void updateCanvasMargins();
00246
00247 virtual void getCanvasMarginsHint(
00248 const QwtScaleMap maps[], const QRectF &canvasRect,
00249 double &left, double &top, double &right, double &bottom) const;
00250
00251 virtual bool event( QEvent * );
00252 virtual bool eventFilter( QObject *, QEvent * );
00253
00254 virtual void drawItems( QPainter *, const QRectF &,
00255 const QwtScaleMap maps[axisCnt] ) const;
00256
00257 virtual QVariant itemToInfo( QwtPlotItem * ) const;
00258 virtual QwtPlotItem *infoToItem( const QVariant & ) const;
00259
00260 Q_SIGNALS:
00267 void itemAttached( QwtPlotItem *plotItem, bool on );
00268
00279 void legendDataChanged( const QVariant &itemInfo,
00280 const QList<QwtLegendData> &data );
00281
00282 public Q_SLOTS:
00283 virtual void replot();
00284 void autoRefresh();
00285
00286 protected:
00287 static bool axisValid( int axisId );
00288
00289 virtual void resizeEvent( QResizeEvent *e );
00290
00291 private Q_SLOTS:
00292 void updateLegendItems( const QVariant &itemInfo,
00293 const QList<QwtLegendData> &data );
00294
00295 private:
00296 friend class QwtPlotItem;
00297 void attachItem( QwtPlotItem *, bool );
00298
00299 void initAxesData();
00300 void deleteAxesData();
00301 void updateScaleDiv();
00302
00303 void initPlot( const QwtText &title );
00304
00305 class AxisData;
00306 AxisData *d_axisData[axisCnt];
00307
00308 class PrivateData;
00309 PrivateData *d_data;
00310 };
00311
00312 #endif