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


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17