Qwt User's Guide: qwt_plot.h Source File

Qwt User's Guide 6.1.6

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 "qwt_global.h"
14 #include "qwt_text.h"
15 #include "qwt_plot_dict.h"
16 #include "qwt_scale_map.h"
17 #include "qwt_interval.h"
18 #include <qframe.h>
19 #include <qlist.h>
20 #include <qvariant.h>
21
22 class QwtPlotLayout;
23 class QwtAbstractLegend;
24 class QwtScaleWidget;
25 class QwtScaleEngine;
26 class QwtScaleDiv;
27 class QwtScaleDraw;
28 class QwtTextLabel;
29
75 class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict
76 {
77 Q_OBJECT
78
79 Q_PROPERTY( QBrush canvasBackground
80 READ canvasBackground WRITE setCanvasBackground )
81 Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot )
82
83 #if 0
84 // This property is intended to configure the plot
85 // widget from a special dialog in the deigner plugin.
86 // Disabled until such a dialog has been implemented.
87
88 Q_PROPERTY( QString propertiesDocument
89 READ grabProperties WRITE applyProperties )
90 #endif
91
92 public:
94 enum Axis
95 {
97 yLeft,
98
100 yRight,
101
103 xBottom,
104
106 xTop,
107
109 axisCnt
110 };
111
117 enum LegendPosition
118 {
120 LeftLegend,
121
123 RightLegend,
124
126 BottomLegend,
127
129 TopLegend
130 };
131
132 explicit QwtPlot( QWidget * = NULL );
133 explicit QwtPlot( const QwtText &title, QWidget * = NULL );
134
135 virtual ~QwtPlot();
136
137 void applyProperties( const QString & );
138 QString grabProperties() const;
139
140 void setAutoReplot( bool = true );
141 bool autoReplot() const;
142
143 // Layout
144
145 void setPlotLayout( QwtPlotLayout * );
146
147 QwtPlotLayout *plotLayout();
148 const QwtPlotLayout *plotLayout() const;
149
150 // Title
151
152 void setTitle( const QString & );
153 void setTitle( const QwtText & );
154 QwtText title() const;
155
156 QwtTextLabel *titleLabel();
157 const QwtTextLabel *titleLabel() const;
158
159 // Footer
160
161 void setFooter( const QString & );
162 void setFooter( const QwtText & );
163 QwtText footer() const;
164
165 QwtTextLabel *footerLabel();
166 const QwtTextLabel *footerLabel() const;
167
168 // Canvas
169
170 void setCanvas( QWidget * );
171
172 QWidget *canvas();
173 const QWidget *canvas() const;
174
175 void setCanvasBackground( const QBrush & );
176 QBrush canvasBackground() const;
177
178 virtual QwtScaleMap canvasMap( int axisId ) const;
179
180 double invTransform( int axisId, int pos ) const;
181 double transform( int axisId, double value ) const;
182
183 // Axes
184
185 QwtScaleEngine *axisScaleEngine( int axisId );
186 const QwtScaleEngine *axisScaleEngine( int axisId ) const;
187 void setAxisScaleEngine( int axisId, QwtScaleEngine * );
188
189 void setAxisAutoScale( int axisId, bool on = true );
190 bool axisAutoScale( int axisId ) const;
191
192 void enableAxis( int axisId, bool tf = true );
193 bool axisEnabled( int axisId ) const;
194
195 void setAxisFont( int axisId, const QFont & );
196 QFont axisFont( int axisId ) const;
197
198 void setAxisScale( int axisId, double min, double max, double stepSize = 0 );
199 void setAxisScaleDiv( int axisId, const QwtScaleDiv & );
200 void setAxisScaleDraw( int axisId, QwtScaleDraw * );
201
202 double axisStepSize( int axisId ) const;
203 QwtInterval axisInterval( int axisId ) const;
204
205 const QwtScaleDiv &axisScaleDiv( int axisId ) const;
206
207 const QwtScaleDraw *axisScaleDraw( int axisId ) const;
208 QwtScaleDraw *axisScaleDraw( int axisId );
209
210 const QwtScaleWidget *axisWidget( int axisId ) const;
211 QwtScaleWidget *axisWidget( int axisId );
212
213 void setAxisLabelAlignment( int axisId, Qt::Alignment );
214 void setAxisLabelRotation( int axisId, double rotation );
215
216 void setAxisTitle( int axisId, const QString & );
217 void setAxisTitle( int axisId, const QwtText & );
218 QwtText axisTitle( int axisId ) const;
219
220 void setAxisMaxMinor( int axisId, int maxMinor );
221 int axisMaxMinor( int axisId ) const;
222
223 void setAxisMaxMajor( int axisId, int maxMajor );
224 int axisMaxMajor( int axisId ) const;
225
226 // Legend
227
228 void insertLegend( QwtAbstractLegend *,
229 LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 );
230
231 QwtAbstractLegend *legend();
232 const QwtAbstractLegend *legend() const;
233
234 void updateLegend();
235 void updateLegend( const QwtPlotItem * );
236
237 // Misc
238
239 virtual QSize sizeHint() const;
240 virtual QSize minimumSizeHint() const;
241
242 virtual void updateLayout();
243 virtual void drawCanvas( QPainter * );
244
245 void updateAxes();
246 void updateCanvasMargins();
247
248 virtual void getCanvasMarginsHint(
249 const QwtScaleMap maps[], const QRectF &canvasRect,
250 double &left, double &top, double &right, double &bottom) const;
251
252 virtual bool event( QEvent * );
253 virtual bool eventFilter( QObject *, QEvent * );
254
255 virtual void drawItems( QPainter *, const QRectF &,
256 const QwtScaleMap maps[axisCnt] ) const;
257
258 virtual QVariant itemToInfo( QwtPlotItem * ) const;
259 virtual QwtPlotItem *infoToItem( const QVariant & ) const;
260
261 Q_SIGNALS:
268 void itemAttached( QwtPlotItem *plotItem, bool on );
269
280 void legendDataChanged( const QVariant &itemInfo,
281 const QList<QwtLegendData> &data );
282
283 public Q_SLOTS:
284 virtual void replot();
285 void autoRefresh();
286
287 protected:
288 static bool axisValid( int axisId );
289
290 virtual void resizeEvent( QResizeEvent *e );
291
292 private Q_SLOTS:
293 void updateLegendItems( const QVariant &itemInfo,
294 const QList<QwtLegendData> &legendData );
295
296 private:
297 friend class QwtPlotItem;
298 void attachItem( QwtPlotItem *, bool );
299
300 void initAxesData();
301 void deleteAxesData();
302 void updateScaleDiv();
303
304 void initPlot( const QwtText &title );
305
306 class AxisData;
307 AxisData *d_axisData[axisCnt];
308
309 class PrivateData;
310 PrivateData *d_data;
311 };
312
313 #endif
QwtPlot::BottomLegend
@ BottomLegend
The legend will be below the footer.
Definition: qwt_plot.h:126
QwtPlot
A 2-D plotting widget.
Definition: qwt_plot.h:76
QwtScaleWidget
A Widget which contains a scale.
Definition: qwt_scale_widget.h:34
QwtPlot::yLeft
@ yLeft
Y axis left of the canvas.
Definition: qwt_plot.h:97
QwtPlot::legendDataChanged
void legendDataChanged(const QVariant &itemInfo, const QList< QwtLegendData > &data)
QwtPlotItem
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:65
QwtScaleDraw
A class for drawing scales.
Definition: qwt_scale_draw.h:32
QwtText
A class representing a text.
Definition: qwt_text.h:52
QwtPlot::xBottom
@ xBottom
X axis below the canvas.
Definition: qwt_plot.h:103
QwtPlot::Axis
Axis
Axis index.
Definition: qwt_plot.h:95
QwtPlotItem::title
const QwtText & title() const
Definition: qwt_plot_item.cpp:199
QwtScaleEngine
Base class for scale engines.
Definition: qwt_scale_engine.h:46
QwtPlotLayout
Layout engine for QwtPlot.
Definition: qwt_plot_layout.h:27
QwtPlot::LegendPosition
LegendPosition
Definition: qwt_plot.h:118
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:31
QwtPlot::RightLegend
@ RightLegend
The legend will be right from the QwtPlot::yRight axis.
Definition: qwt_plot.h:123
QwtPlot::LeftLegend
@ LeftLegend
The legend will be left from the QwtPlot::yLeft axis.
Definition: qwt_plot.h:120
QwtAbstractLegend
Abstract base class for legend widgets.
Definition: qwt_abstract_legend.h:35
QwtPlot::itemAttached
void itemAttached(QwtPlotItem *plotItem, bool on)
QwtPlot::yRight
@ yRight
Y axis right of the canvas.
Definition: qwt_plot.h:100
QwtPlotItem::updateScaleDiv
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &)
Update the item to changes of the axes scale division.
Definition: qwt_plot_item.cpp:636
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:27
QwtTextLabel
A Widget which displays a QwtText.
Definition: qwt_text_label.h:26
QwtPlotDict
A dictionary for plot items.
Definition: qwt_plot_dict.h:35
QwtPlot::xTop
@ xTop
X axis above the canvas.
Definition: qwt_plot.h:106
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:37