Qwt Polar User's Guide  0.1.0
qwt_polar_plot.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * QwtPolar Widget Library
3  * Copyright (C) 2008 Uwe Rathmann
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the Qwt License, Version 1.0
7  *****************************************************************************/
8 
9 #ifndef QWT_POLAR_PLOT_H
10 #define QWT_POLAR_PLOT_H 1
11 
12 #include <qframe.h>
13 #include "qwt_polar_global.h"
14 #include "qwt_double_interval.h"
15 #include "qwt_scale_map.h"
16 #include "qwt_polar.h"
17 #include "qwt_polar_point.h"
18 #include "qwt_polar_itemdict.h"
19 
20 class QwtRoundScaleDraw;
21 class QwtScaleEngine;
22 class QwtScaleDiv;
23 class QwtTextLabel;
24 class QwtPolarCanvas;
25 class QwtPolarLayout;
26 
45 class QWT_POLAR_EXPORT QwtPolarPlot: public QFrame, public QwtPolarItemDict
46 {
47  Q_OBJECT
48 
49  Q_PROPERTY(QBrush plotBackground READ plotBackground WRITE setPlotBackground)
50  Q_PROPERTY(double azimuthOrigin READ azimuthOrigin WRITE setAzimuthOrigin)
51 
52 
53 public:
77  {
78  LeftLegend,
79  RightLegend,
80  BottomLegend,
81  TopLegend,
82 
83  ExternalLegend
84  };
85 
86  explicit QwtPolarPlot( QWidget *parent = NULL);
87  QwtPolarPlot(const QwtText &title, QWidget *parent = NULL);
88 
89  virtual ~QwtPolarPlot();
90 
91  void setTitle(const QString &);
92  void setTitle(const QwtText &);
93 
94  QwtText title() const;
95 
96  QwtTextLabel *titleLabel();
97  const QwtTextLabel *titleLabel() const;
98 
99  void setAutoReplot(bool tf = true);
100  bool autoReplot() const;
101 
102  void setAutoScale(int scaleId);
103  bool hasAutoScale(int scaleId) const;
104 
105  void setScaleMaxMinor(int scaleId, int maxMinor);
106  int scaleMaxMinor(int scaleId) const;
107 
108  int scaleMaxMajor(int scaleId) const;
109  void setScaleMaxMajor(int scaleId, int maxMajor);
110 
111  QwtScaleEngine *scaleEngine(int scaleId);
112  const QwtScaleEngine *scaleEngine(int scaleId) const;
113  void setScaleEngine(int scaleId, QwtScaleEngine *);
114 
115  void setScale(int scaleId, double min, double max, double step = 0);
116 
117  void setScaleDiv(int scaleId, const QwtScaleDiv &);
118  const QwtScaleDiv *scaleDiv(int scaleId) const;
119  QwtScaleDiv *scaleDiv(int scaleId);
120 
121  QwtScaleMap scaleMap(int scaleId, double radius) const;
122  QwtScaleMap scaleMap(int scaleId) const;
123 
124  void updateScale(int scaleId);
125 
126  double azimuthOrigin() const;
127 
128  void zoom(const QwtPolarPoint&, double factor);
129  void unzoom();
130 
131  QwtPolarPoint zoomPos() const;
132  double zoomFactor() const;
133 
134  virtual void polish();
135 
136  // Canvas
137 
138  QwtPolarCanvas *canvas();
139  const QwtPolarCanvas *canvas() const;
140 
141  void setPlotBackground (const QBrush &c);
142  const QBrush& plotBackground() const;
143 
144  virtual void drawCanvas(QPainter *, const QwtDoubleRect &) const;
145 
146 
147  // Legend
148 
149  void insertLegend(QwtLegend *, LegendPosition = QwtPolarPlot::RightLegend,
150  double ratio = -1.0);
151 
152  QwtLegend *legend();
153  const QwtLegend *legend() const;
154 
155  // Layout
156  QwtPolarLayout *plotLayout();
157  const QwtPolarLayout *plotLayout() const;
158 
159  QwtDoubleInterval visibleInterval() const;
160  QwtDoubleRect plotRect() const;
161  QwtDoubleRect plotRect(const QRect &) const;
162 
163  int plotMarginHint() const;
164 
165  void renderTo(QPaintDevice &) const;
166  virtual void renderTo(QPainter *, const QRect &) const;
167 
168 signals:
179  void legendClicked(QwtPolarItem *plotItem);
180 
192  void legendChecked(QwtPolarItem *plotItem, bool on);
193 
198  void layoutChanged();
199 
200 public slots:
201  virtual void replot();
202  void autoRefresh();
203  void setAzimuthOrigin(double);
204 
205 protected slots:
206  virtual void legendItemClicked();
207  virtual void legendItemChecked(bool);
208 
209 protected:
210  virtual bool event(QEvent *);
211  virtual void resizeEvent(QResizeEvent *);
212 
213  virtual void updateLayout();
214 
215  virtual void drawItems(QPainter *painter,
216  const QwtScaleMap &radialMap, const QwtScaleMap &azimuthMap,
217  const QwtDoublePoint &pole, double radius,
218  const QwtDoubleRect &canvasRect) const;
219 
220  virtual void renderTitle(QPainter *, const QRect &) const;
221  virtual void renderLegend(QPainter *, const QRect &) const;
222  virtual void renderLegendItem(QPainter *,
223  const QWidget *, const QRect &) const;
224 
225 private:
226  void initPlot(const QwtText &);
227 
228  class ScaleData;
229  class PrivateData;
230  PrivateData *d_data;
231 };
232 
233 #endif