Qwt User's Guide: qwt_plot.h Source File

Qwt User's Guide 5.2.3

- Main Page
- Related Pages
- Classes

qwt_plot.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10 #ifndef QWT_PLOT_H
11 #define QWT_PLOT_H
12
13 #include <qframe.h>
14 #include "qwt_global.h"
15 #include "qwt_array.h"
16 #include "qwt_text.h"
17 #include "qwt_plot_dict.h"
18 #include "qwt_scale_map.h"
19 #include "qwt_plot_printfilter.h"
20
21 class QwtPlotLayout;
22 class QwtLegend;
23 class QwtScaleWidget;
24 class QwtScaleEngine;
25 class QwtScaleDiv;
26 class QwtScaleDraw;
27 class QwtTextLabel;
28 class QwtPlotCanvas;
29 class QwtPlotPrintFilter;
30
72 class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict
73 {
74 Q_OBJECT
75 Q_PROPERTY( QString propertiesDocument
76 READ grabProperties WRITE applyProperties )
77
78 public:
87 enum Axis
88 {
89 yLeft,
90 yRight,
91 xBottom,
92 xTop,
93
94 axisCnt
95 };
96
119 enum LegendPosition
120 {
121 LeftLegend,
122 RightLegend,
123 BottomLegend,
124 TopLegend,
125
126 ExternalLegend
127 };
128
129 explicit QwtPlot(QWidget * = NULL);
130 explicit QwtPlot(const QwtText &title, QWidget *p = NULL);
131 #if QT_VERSION < 0x040000
132 explicit QwtPlot(QWidget *, const char* name);
133 #endif
134
135 virtual ~QwtPlot();
136
137 void applyProperties(const QString &);
138 QString grabProperties() const;
139
140 void setAutoReplot(bool tf = true);
141 bool autoReplot() const;
142
143 void print(QPaintDevice &p,
144 const QwtPlotPrintFilter & = QwtPlotPrintFilter()) const;
145 virtual void print(QPainter *, const QRect &rect,
146 const QwtPlotPrintFilter & = QwtPlotPrintFilter()) const;
147
148 // Layout
149
150 QwtPlotLayout *plotLayout();
151 const QwtPlotLayout *plotLayout() const;
152
153 void setMargin(int margin);
154 int margin() const;
155
156 // Title
157
158 void setTitle(const QString &);
159 void setTitle(const QwtText &t);
160 QwtText title() const;
161
162 QwtTextLabel *titleLabel();
163 const QwtTextLabel *titleLabel() const;
164
165 // Canvas
166
167 QwtPlotCanvas *canvas();
168 const QwtPlotCanvas *canvas() const;
169
170 void setCanvasBackground (const QColor &c);
171 const QColor& canvasBackground() const;
172
173 void setCanvasLineWidth(int w);
174 int canvasLineWidth() const;
175
176 virtual QwtScaleMap canvasMap(int axisId) const;
177
178 double invTransform(int axisId, int pos) const;
179 int transform(int axisId, double value) const;
180
181 // Axes
182
183 QwtScaleEngine *axisScaleEngine(int axisId);
184 const QwtScaleEngine *axisScaleEngine(int axisId) const;
185 void setAxisScaleEngine(int axisId, QwtScaleEngine *);
186
187 void setAxisAutoScale(int axisId);
188 bool axisAutoScale(int axisId) const;
189
190 void enableAxis(int axisId, bool tf = true);
191 bool axisEnabled(int axisId) const;
192
193 void setAxisFont(int axisId, const QFont &f);
194 QFont axisFont(int axisId) const;
195
196 void setAxisScale(int axisId, double min, double max, double step = 0);
197 void setAxisScaleDiv(int axisId, const QwtScaleDiv &);
198 void setAxisScaleDraw(int axisId, QwtScaleDraw *);
199
200 double axisStepSize(int axisId) const;
201
202 const QwtScaleDiv *axisScaleDiv(int axisId) const;
203 QwtScaleDiv *axisScaleDiv(int axisId);
204
205 const QwtScaleDraw *axisScaleDraw(int axisId) const;
206 QwtScaleDraw *axisScaleDraw(int axisId);
207
208 const QwtScaleWidget *axisWidget(int axisId) const;
209 QwtScaleWidget *axisWidget(int axisId);
210
211 #if QT_VERSION < 0x040000
212 void setAxisLabelAlignment(int axisId, int);
213 #else
214 void setAxisLabelAlignment(int axisId, Qt::Alignment);
215 #endif
216 void setAxisLabelRotation(int axisId, double rotation);
217
218 void setAxisTitle(int axisId, const QString &);
219 void setAxisTitle(int axisId, const QwtText &);
220 QwtText axisTitle(int axisId) const;
221
222 void setAxisMaxMinor(int axisId, int maxMinor);
223 int axisMaxMajor(int axisId) const;
224 void setAxisMaxMajor(int axisId, int maxMajor);
225 int axisMaxMinor(int axisId) const;
226
227 // Legend
228
229 void insertLegend(QwtLegend *, LegendPosition = QwtPlot::RightLegend,
230 double ratio = -1.0);
231
232 QwtLegend *legend();
233 const QwtLegend *legend() const;
234
235 // Misc
236
237 virtual void polish();
238 virtual QSize sizeHint() const;
239 virtual QSize minimumSizeHint() const;
240
241 virtual void updateLayout();
242 virtual void drawCanvas(QPainter *);
243
244 void updateAxes();
245
246 virtual bool event(QEvent *);
247
248 signals:
259 void legendClicked(QwtPlotItem *plotItem);
260
273 void legendChecked(QwtPlotItem *plotItem, bool on);
274
275 public slots:
276 virtual void clear();
277
278 virtual void replot();
279 void autoRefresh();
280
281 protected slots:
282 virtual void legendItemClicked();
283 virtual void legendItemChecked(bool);
284
285 protected:
286 static bool axisValid(int axisId);
287
288 virtual void drawItems(QPainter *, const QRect &,
289 const QwtScaleMap maps[axisCnt],
290 const QwtPlotPrintFilter &) const;
291
292 virtual void updateTabOrder();
293
294 virtual void resizeEvent(QResizeEvent *e);
295
296 virtual void printLegendItem(QPainter *,
297 const QWidget *, const QRect &) const;
298
299 virtual void printTitle(QPainter *, const QRect &) const;
300
301 virtual void printScale(QPainter *, int axisId, int startDist, int endDist,
302 int baseDist, const QRect &) const;
303
304 virtual void printCanvas(QPainter *,
305 const QRect &boundingRect, const QRect &canvasRect,
306 const QwtScaleMap maps[axisCnt], const QwtPlotPrintFilter &) const;
307
308 virtual void printLegend(QPainter *, const QRect &) const;
309
310 private:
311 void initAxesData();
312 void deleteAxesData();
313 void updateScaleDiv();
314
315 void initPlot(const QwtText &title);
316
317 class AxisData;
318 AxisData *d_axisData[axisCnt];
319
320 class PrivateData;
321 PrivateData *d_data;
322 };
323
324 #endif