Qwt Polar User's Guide 1.0.0

qwt_polar_plot.h

00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * QwtPolar Widget Library
00003  * Copyright (C) 2008   Uwe Rathmann
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the Qwt License, Version 1.0
00007  *****************************************************************************/
00008 
00009 #ifndef QWT_POLAR_PLOT_H
00010 #define QWT_POLAR_PLOT_H 1
00011 
00012 #include "qwt_polar_global.h"
00013 #include "qwt_polar.h"
00014 #include "qwt_polar_itemdict.h"
00015 #include <qwt_interval.h>
00016 #include <qwt_scale_map.h>
00017 #include <qwt_point_polar.h>
00018 #include <qframe.h>
00019 
00020 class QwtRoundScaleDraw;
00021 class QwtScaleEngine;
00022 class QwtScaleDiv;
00023 class QwtTextLabel;
00024 class QwtPolarCanvas;
00025 class QwtPolarLayout;
00026 
00045 class QWT_POLAR_EXPORT QwtPolarPlot: public QFrame, public QwtPolarItemDict
00046 {
00047     Q_OBJECT
00048 
00049     Q_PROPERTY( QBrush plotBackground READ plotBackground WRITE setPlotBackground )
00050     Q_PROPERTY( double azimuthOrigin READ azimuthOrigin WRITE setAzimuthOrigin )
00051 
00052 
00053 public:
00058     enum LegendPosition
00059     {
00061         LeftLegend,
00062 
00064         RightLegend,
00065 
00067         BottomLegend,
00068 
00070         TopLegend,
00071 
00080         ExternalLegend
00081     };
00082 
00083     explicit QwtPolarPlot( QWidget *parent = NULL );
00084     QwtPolarPlot( const QwtText &title, QWidget *parent = NULL );
00085 
00086     virtual ~QwtPolarPlot();
00087 
00088     void setTitle( const QString & );
00089     void setTitle( const QwtText & );
00090 
00091     QwtText title() const;
00092 
00093     QwtTextLabel *titleLabel();
00094     const QwtTextLabel *titleLabel() const;
00095 
00096     void setAutoReplot( bool tf = true );
00097     bool autoReplot() const;
00098 
00099     void setAutoScale( int scaleId );
00100     bool hasAutoScale( int scaleId ) const;
00101 
00102     void setScaleMaxMinor( int scaleId, int maxMinor );
00103     int scaleMaxMinor( int scaleId ) const;
00104 
00105     int scaleMaxMajor( int scaleId ) const;
00106     void setScaleMaxMajor( int scaleId, int maxMajor );
00107 
00108     QwtScaleEngine *scaleEngine( int scaleId );
00109     const QwtScaleEngine *scaleEngine( int scaleId ) const;
00110     void setScaleEngine( int scaleId, QwtScaleEngine * );
00111 
00112     void setScale( int scaleId, double min, double max, double step = 0 );
00113 
00114     void setScaleDiv( int scaleId, const QwtScaleDiv & );
00115     const QwtScaleDiv *scaleDiv( int scaleId ) const;
00116     QwtScaleDiv *scaleDiv( int scaleId );
00117 
00118     QwtScaleMap scaleMap( int scaleId, double radius ) const;
00119     QwtScaleMap scaleMap( int scaleId ) const;
00120 
00121     void updateScale( int scaleId );
00122 
00123     double azimuthOrigin() const;
00124 
00125     void zoom( const QwtPointPolar&, double factor );
00126     void unzoom();
00127 
00128     QwtPointPolar zoomPos() const;
00129     double zoomFactor() const;
00130 
00131     // Canvas
00132 
00133     QwtPolarCanvas *canvas();
00134     const QwtPolarCanvas *canvas() const;
00135 
00136     void setPlotBackground ( const QBrush &c );
00137     const QBrush& plotBackground() const;
00138 
00139     virtual void drawCanvas( QPainter *, const QRectF & ) const;
00140 
00141     // Legend
00142 
00143     void insertLegend( QwtLegend *,
00144         LegendPosition = RightLegend, double ratio = -1.0 );
00145 
00146     QwtLegend *legend();
00147     const QwtLegend *legend() const;
00148 
00149     // Layout
00150     QwtPolarLayout *plotLayout();
00151     const QwtPolarLayout *plotLayout() const;
00152 
00153     QwtInterval visibleInterval() const;
00154     QRectF plotRect() const;
00155     QRectF plotRect( const QRectF & ) const;
00156 
00157     int plotMarginHint() const;
00158 
00159 Q_SIGNALS:
00170     void legendClicked( QwtPolarItem *plotItem );
00171 
00183     void legendChecked( QwtPolarItem *plotItem, bool on );
00184 
00189     void layoutChanged();
00190 
00191 public Q_SLOTS:
00192     virtual void replot();
00193     void autoRefresh();
00194     void setAzimuthOrigin( double );
00195 
00196 protected Q_SLOTS:
00197     virtual void legendItemClicked();
00198     virtual void legendItemChecked( bool );
00199 
00200 protected:
00201     virtual bool event( QEvent * );
00202     virtual void resizeEvent( QResizeEvent * );
00203 
00204     virtual void updateLayout();
00205 
00206     virtual void drawItems( QPainter *painter,
00207         const QwtScaleMap &radialMap, const QwtScaleMap &azimuthMap,
00208         const QPointF &pole, double radius,
00209         const QRectF &canvasRect ) const;
00210 
00211 private:
00212     void initPlot( const QwtText & );
00213 
00214     class ScaleData;
00215     class PrivateData;
00216     PrivateData *d_data;
00217 };
00218 
00219 #endif