Qwt Polar User's Guide 0.1.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 <qframe.h>
00013 #include "qwt_polar_global.h"
00014 #include "qwt_double_interval.h"
00015 #include "qwt_scale_map.h"
00016 #include "qwt_polar.h"
00017 #include "qwt_polar_point.h"
00018 #include "qwt_polar_itemdict.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:
00076     enum LegendPosition
00077     {
00078         LeftLegend,
00079         RightLegend,
00080         BottomLegend,
00081         TopLegend,
00082 
00083         ExternalLegend
00084     };
00085 
00086     explicit QwtPolarPlot( QWidget *parent = NULL);
00087     QwtPolarPlot(const QwtText &title, QWidget *parent = NULL);
00088 
00089     virtual ~QwtPolarPlot();
00090 
00091     void setTitle(const QString &);
00092     void setTitle(const QwtText &);
00093 
00094     QwtText title() const;
00095 
00096     QwtTextLabel *titleLabel();
00097     const QwtTextLabel *titleLabel() const;
00098 
00099     void setAutoReplot(bool tf = true); 
00100     bool autoReplot() const;
00101 
00102     void setAutoScale(int scaleId);
00103     bool hasAutoScale(int scaleId) const;
00104 
00105     void setScaleMaxMinor(int scaleId, int maxMinor);
00106     int scaleMaxMinor(int scaleId) const;
00107 
00108     int scaleMaxMajor(int scaleId) const;
00109     void setScaleMaxMajor(int scaleId, int maxMajor);
00110 
00111     QwtScaleEngine *scaleEngine(int scaleId);
00112     const QwtScaleEngine *scaleEngine(int scaleId) const;
00113     void setScaleEngine(int scaleId, QwtScaleEngine *);
00114 
00115     void setScale(int scaleId, double min, double max, double step = 0);
00116 
00117     void setScaleDiv(int scaleId, const QwtScaleDiv &);
00118     const QwtScaleDiv *scaleDiv(int scaleId) const;
00119     QwtScaleDiv *scaleDiv(int scaleId);
00120 
00121     QwtScaleMap scaleMap(int scaleId, double radius) const;
00122     QwtScaleMap scaleMap(int scaleId) const;
00123 
00124     void updateScale(int scaleId);
00125 
00126     double azimuthOrigin() const;
00127 
00128     void zoom(const QwtPolarPoint&, double factor);
00129     void unzoom();
00130 
00131     QwtPolarPoint zoomPos() const;
00132     double zoomFactor() const;
00133 
00134     virtual void polish();
00135 
00136     // Canvas
00137 
00138     QwtPolarCanvas *canvas();
00139     const QwtPolarCanvas *canvas() const;
00140 
00141     void setPlotBackground (const QBrush &c);
00142     const QBrush& plotBackground() const;
00143 
00144     virtual void drawCanvas(QPainter *, const QwtDoubleRect &) const;
00145 
00146 
00147     // Legend
00148 
00149     void insertLegend(QwtLegend *, LegendPosition = QwtPolarPlot::RightLegend,
00150         double ratio = -1.0);
00151 
00152     QwtLegend *legend();
00153     const QwtLegend *legend() const;
00154 
00155     // Layout
00156     QwtPolarLayout *plotLayout();
00157     const QwtPolarLayout *plotLayout() const;
00158 
00159     QwtDoubleInterval visibleInterval() const;
00160     QwtDoubleRect plotRect() const;
00161     QwtDoubleRect plotRect(const QRect &) const;
00162 
00163     int plotMarginHint() const;
00164 
00165     void renderTo(QPaintDevice &) const;
00166     virtual void renderTo(QPainter *, const QRect &) const;
00167 
00168 signals:
00179     void legendClicked(QwtPolarItem *plotItem);
00180 
00192     void legendChecked(QwtPolarItem *plotItem, bool on);
00193 
00198     void layoutChanged();
00199 
00200 public slots:
00201     virtual void replot();
00202     void autoRefresh();
00203     void setAzimuthOrigin(double);
00204 
00205 protected slots:
00206     virtual void legendItemClicked();
00207     virtual void legendItemChecked(bool);
00208 
00209 protected:
00210     virtual bool event(QEvent *);
00211     virtual void resizeEvent(QResizeEvent *);
00212 
00213     virtual void updateLayout();
00214 
00215     virtual void drawItems(QPainter *painter, 
00216         const QwtScaleMap &radialMap, const QwtScaleMap &azimuthMap,
00217         const QwtDoublePoint &pole, double radius,
00218         const QwtDoubleRect &canvasRect) const;
00219 
00220     virtual void renderTitle(QPainter *, const QRect &) const;
00221     virtual void renderLegend(QPainter *, const QRect &) const;
00222     virtual void renderLegendItem(QPainter *,
00223         const QWidget *, const QRect &) const;
00224 
00225 private:
00226     void initPlot(const QwtText &);
00227 
00228     class ScaleData;
00229     class PrivateData;
00230     PrivateData *d_data;
00231 };
00232 
00233 #endif