Qwt User's Guide  6.2.0
qwt_plot_item.h
1 /******************************************************************************
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_ITEM_H
11 #define QWT_PLOT_ITEM_H
12 
13 #include "qwt_global.h"
14 #include "qwt_axis_id.h"
15 #include <qmetatype.h>
16 
17 class QwtScaleMap;
18 class QwtScaleDiv;
19 class QwtPlot;
20 class QwtText;
21 class QwtGraphic;
22 class QwtLegendData;
23 class QRectF;
24 class QPainter;
25 class QString;
26 template< typename T > class QList;
27 
66 class QWT_EXPORT QwtPlotItem
67 {
68  public:
76  {
78  Rtti_PlotItem = 0,
79 
82 
85 
88 
91 
94 
97 
100 
103 
106 
109 
112 
115 
118 
121 
124 
127 
130 
135  Rtti_PlotUserItem = 1000
136  };
137 
148  {
150  Legend = 0x01,
151 
157  AutoScale = 0x02,
158 
164  Margins = 0x04
165  };
166 
167  Q_DECLARE_FLAGS( ItemAttributes, ItemAttribute )
168 
169 
180  {
185  ScaleInterest = 0x01,
186 
197  LegendInterest = 0x02
198  };
199 
200  Q_DECLARE_FLAGS( ItemInterests, ItemInterest )
201 
202 
204  {
206  RenderAntialiased = 0x1
207  };
208 
209  Q_DECLARE_FLAGS( RenderHints, RenderHint )
210 
211  explicit QwtPlotItem();
212  explicit QwtPlotItem( const QString& title );
213  explicit QwtPlotItem( const QwtText& title );
214 
215  virtual ~QwtPlotItem();
216 
217  void attach( QwtPlot* plot );
218  void detach();
219 
220  QwtPlot* plot() const;
221 
222  void setTitle( const QString& title );
223  void setTitle( const QwtText& title );
224  const QwtText& title() const;
225 
226  virtual int rtti() const;
227 
228  void setItemAttribute( ItemAttribute, bool on = true );
229  bool testItemAttribute( ItemAttribute ) const;
230 
231  void setItemInterest( ItemInterest, bool on = true );
232  bool testItemInterest( ItemInterest ) const;
233 
234  void setRenderHint( RenderHint, bool on = true );
235  bool testRenderHint( RenderHint ) const;
236 
237  void setRenderThreadCount( uint numThreads );
238  uint renderThreadCount() const;
239 
240  void setLegendIconSize( const QSize& );
241  QSize legendIconSize() const;
242 
243  double z() const;
244  void setZ( double z );
245 
246  void show();
247  void hide();
248  virtual void setVisible( bool );
249  bool isVisible () const;
250 
251  void setAxes( QwtAxisId xAxis, QwtAxisId yAxis );
252 
253  void setXAxis( QwtAxisId );
254  QwtAxisId xAxis() const;
255 
256  void setYAxis( QwtAxisId );
257  QwtAxisId yAxis() const;
258 
259  virtual void itemChanged();
260  virtual void legendChanged();
261 
270  virtual void draw( QPainter* painter,
271  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
272  const QRectF& canvasRect ) const = 0;
273 
274  virtual QRectF boundingRect() const;
275 
276  virtual void getCanvasMarginHint(
277  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
278  const QRectF& canvasRect,
279  double& left, double& top, double& right, double& bottom) const;
280 
281  virtual void updateScaleDiv(
282  const QwtScaleDiv&, const QwtScaleDiv& );
283 
284  virtual void updateLegend( const QwtPlotItem*,
285  const QList< QwtLegendData >& );
286 
287  QRectF scaleRect( const QwtScaleMap&, const QwtScaleMap& ) const;
288  QRectF paintRect( const QwtScaleMap&, const QwtScaleMap& ) const;
289 
290  virtual QList< QwtLegendData > legendData() const;
291 
292  virtual QwtGraphic legendIcon( int index, const QSizeF& ) const;
293 
294  protected:
295  QwtGraphic defaultIcon( const QBrush&, const QSizeF& ) const;
296 
297  private:
298  Q_DISABLE_COPY(QwtPlotItem)
299 
300  class PrivateData;
301  PrivateData* m_data;
302 };
303 
304 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes )
305 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemInterests )
306 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints )
307 
308 Q_DECLARE_METATYPE( QwtPlotItem* )
309 
310 #endif
A paint device for scalable graphics.
Definition: qwt_graphic.h:76
Attributes of an entry on a legend.
A 2-D plotting widget.
Definition: qwt_plot.h:79
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:67
QFlags< ItemInterest > ItemInterests
virtual void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const =0
Draw the item.
QFlags< RenderHint > RenderHints
QFlags< ItemAttribute > ItemAttributes
RttiValues
Runtime type information.
Definition: qwt_plot_item.h:76
@ Rtti_PlotVectorField
For QwtPlotVectorField.
@ Rtti_PlotLegend
For QwtPlotLegendItem.
Definition: qwt_plot_item.h:87
@ Rtti_PlotMarker
For QwtPlotMarker.
Definition: qwt_plot_item.h:90
@ Rtti_PlotSpectroCurve
For QwtPlotSpectroCurve.
Definition: qwt_plot_item.h:96
@ Rtti_PlotScale
For QwtPlotScaleItem.
Definition: qwt_plot_item.h:84
@ Rtti_PlotHistogram
For QwtPlotHistogram.
@ Rtti_PlotZone
For QwtPlotZoneItem.
@ Rtti_PlotIntervalCurve
For QwtPlotIntervalCurve.
Definition: qwt_plot_item.h:99
@ Rtti_PlotMultiBarChart
For QwtPlotMultiBarChart.
@ Rtti_PlotBarChart
For QwtPlotBarChart.
@ Rtti_PlotTradingCurve
For QwtPlotTradingCurve.
@ Rtti_PlotSpectrogram
For QwtPlotSpectrogram.
@ Rtti_PlotTextLabel
For QwtPlotTextLabel.
@ Rtti_PlotShape
For QwtPlotShapeItem.
@ Rtti_PlotGrid
For QwtPlotGrid.
Definition: qwt_plot_item.h:81
@ Rtti_PlotCurve
For QwtPlotCurve.
Definition: qwt_plot_item.h:93
@ Rtti_PlotGraphic
For QwtPlotGraphicItem, QwtPlotSvgItem.
RenderHint
Render hints.
ItemAttribute
Plot Item Attributes.
ItemInterest
Plot Item Interests.
A class representing a scale division.
Definition: qwt_scale_div.h:34
A scale map.
Definition: qwt_scale_map.h:27
A class representing a text.
Definition: qwt_text.h:52