Qwt User's Guide 6.0.2

- 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 "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
20 class QwtPlotLayout;
21 class QwtLegend;
22 class QwtScaleWidget;
23 class QwtScaleEngine;
24 class QwtScaleDiv;
25 class QwtScaleDraw;
26 class QwtTextLabel;
27 class QwtPlotCanvas;
28
70 class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict
71 {
72 Q_OBJECT
73 Q_PROPERTY( QString propertiesDocument
74 READ grabProperties WRITE applyProperties )
75
76 public:
78 enum Axis
79 {
81 yLeft,
82
84 yRight,
85
87 xBottom,
88
90 xTop,
91
93 axisCnt
94 };
95
103 enum LegendPosition
104 {
106 LeftLegend,
107
109 RightLegend,
110
112 BottomLegend,
113
115 TopLegend,
116
123 ExternalLegend
124 };
125
126 explicit QwtPlot( QWidget * = NULL );
127 explicit QwtPlot( const QwtText &title, QWidget *p = NULL );
128
129 virtual ~QwtPlot();
130
131 void applyProperties( const QString & );
132 QString grabProperties() const;
133
134 void setAutoReplot( bool tf = true );
135 bool autoReplot() const;
136
137 // Layout
138
139 QwtPlotLayout *plotLayout();
140 const QwtPlotLayout *plotLayout() const;
141
142 // Title
143
144 void setTitle( const QString & );
145 void setTitle( const QwtText &t );
146 QwtText title() const;
147
148 QwtTextLabel *titleLabel();
149 const QwtTextLabel *titleLabel() const;
150
151 // Canvas
152
153 QwtPlotCanvas *canvas();
154 const QwtPlotCanvas *canvas() const;
155
156 void setCanvasBackground( const QBrush & );
157 QBrush canvasBackground() const;
158
159 void setCanvasLineWidth( int w );
160 int canvasLineWidth() const;
161
162 virtual QwtScaleMap canvasMap( int axisId ) const;
163
164 double invTransform( int axisId, int pos ) const;
165 double transform( int axisId, double value ) const;
166
167 // Axes
168
169 QwtScaleEngine *axisScaleEngine( int axisId );
170 const QwtScaleEngine *axisScaleEngine( int axisId ) const;
171 void setAxisScaleEngine( int axisId, QwtScaleEngine * );
172
173 void setAxisAutoScale( int axisId, bool on = true );
174 bool axisAutoScale( int axisId ) const;
175
176 void enableAxis( int axisId, bool tf = true );
177 bool axisEnabled( int axisId ) const;
178
179 void setAxisFont( int axisId, const QFont &f );
180 QFont axisFont( int axisId ) const;
181
182 void setAxisScale( int axisId, double min, double max, double step = 0 );
183 void setAxisScaleDiv( int axisId, const QwtScaleDiv & );
184 void setAxisScaleDraw( int axisId, QwtScaleDraw * );
185
186 double axisStepSize( int axisId ) const;
187 QwtInterval axisInterval( int axisId ) const;
188
189 const QwtScaleDiv *axisScaleDiv( int axisId ) const;
190 QwtScaleDiv *axisScaleDiv( int axisId );
191
192 const QwtScaleDraw *axisScaleDraw( int axisId ) const;
193 QwtScaleDraw *axisScaleDraw( int axisId );
194
195 const QwtScaleWidget *axisWidget( int axisId ) const;
196 QwtScaleWidget *axisWidget( int axisId );
197
198 void setAxisLabelAlignment( int axisId, Qt::Alignment );
199 void setAxisLabelRotation( int axisId, double rotation );
200
201 void setAxisTitle( int axisId, const QString & );
202 void setAxisTitle( int axisId, const QwtText & );
203 QwtText axisTitle( int axisId ) const;
204
205 void setAxisMaxMinor( int axisId, int maxMinor );
206 int axisMaxMinor( int axisId ) const;
207
208 void setAxisMaxMajor( int axisId, int maxMajor );
209 int axisMaxMajor( int axisId ) const;
210
211 // Legend
212
213 void insertLegend( QwtLegend *, LegendPosition = QwtPlot::RightLegend,
214 double ratio = -1.0 );
215
216 QwtLegend *legend();
217 const QwtLegend *legend() const;
218
219 // Misc
220
221 virtual QSize sizeHint() const;
222 virtual QSize minimumSizeHint() const;
223
224 virtual void updateLayout();
225 virtual void drawCanvas( QPainter * );
226
227 void updateAxes();
228
229 virtual bool event( QEvent * );
230
231 virtual void drawItems( QPainter *, const QRectF &,
232 const QwtScaleMap maps[axisCnt] ) const;
233
234 Q_SIGNALS:
245 void legendClicked( QwtPlotItem *plotItem );
246
259 void legendChecked( QwtPlotItem *plotItem, bool on );
260
261 public Q_SLOTS:
262 virtual void replot();
263 void autoRefresh();
264
265 protected Q_SLOTS:
266 virtual void legendItemClicked();
267 virtual void legendItemChecked( bool );
268
269 protected:
270 static bool axisValid( int axisId );
271
272 virtual void updateTabOrder();
273
274 virtual void resizeEvent( QResizeEvent *e );
275
276 private:
277 void initAxesData();
278 void deleteAxesData();
279 void updateScaleDiv();
280
281 void initPlot( const QwtText &title );
282
283 class AxisData;
284 AxisData *d_axisData[axisCnt];
285
286 class PrivateData;
287 PrivateData *d_data;
288 };
289
290 #endif