qwt_plot.h
Go to the documentation of this file.
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_plot_dict.h"
15 
16 #include <qframe.h>
17 
18 class QwtPlotLayout;
19 class QwtAbstractLegend;
20 class QwtScaleWidget;
21 class QwtScaleEngine;
22 class QwtScaleDiv;
23 class QwtScaleMap;
24 class QwtScaleDraw;
25 class QwtTextLabel;
26 class QwtInterval;
27 class QwtText;
28 template <typename T> class QList;
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  {
98 
101 
104 
107 
109  axisCnt
110  };
111 
118  {
121 
124 
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 QWT_OVERRIDE;
240  virtual QSize minimumSizeHint() const QWT_OVERRIDE;
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 * ) QWT_OVERRIDE;
253  virtual bool eventFilter( QObject *, QEvent * ) QWT_OVERRIDE;
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 * ) QWT_OVERRIDE;
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
enum MQTTPropertyCodes value
LegendPosition
Definition: qwt_plot.h:117
X axis above the canvas.
Definition: qwt_plot.h:106
lu_byte right
Definition: lparser.c:1229
A Widget which displays a QwtText.
A class representing an interval.
Definition: qwt_interval.h:22
#define QWT_EXPORT
Definition: qwt_global.h:38
lu_byte left
Definition: lparser.c:1228
Y axis right of the canvas.
Definition: qwt_plot.h:100
A class representing a scale division.
Definition: qwt_scale_div.h:33
A 2-D plotting widget.
Definition: qwt_plot.h:75
Y axis left of the canvas.
Definition: qwt_plot.h:97
A dictionary for plot items.
Definition: qwt_plot_dict.h:32
The legend will be below the footer.
Definition: qwt_plot.h:126
#define min(A, B)
Definition: Log.c:64
#define max(A, B)
Definition: Socket.h:88
A Widget which contains a scale.
Axis
Axis index.
Definition: qwt_plot.h:94
A class representing a text.
Definition: qwt_text.h:51
The legend will be right from the QwtPlot::yRight axis.
Definition: qwt_plot.h:123
The legend will be left from the QwtPlot::yLeft axis.
Definition: qwt_plot.h:120
A scale map.
Definition: qwt_scale_map.h:26
int top(lua_State *L)
Definition: sol.hpp:10543
Abstract base class for legend widgets.
Layout engine for QwtPlot.
A class for drawing scales.
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:65
dictionary data
Definition: mqtt_test.py:22
Attributes of an entry on a legend.
#define QWT_OVERRIDE
Definition: qwt_global.h:53
X axis below the canvas.
Definition: qwt_plot.h:103
Base class for scale engines.


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:10