Qwt User's Guide  6.1.5
qwt_plot_item.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_ITEM_H
11 #define QWT_PLOT_ITEM_H
12 
13 #include "qwt_global.h"
14 #include "qwt_text.h"
15 #include "qwt_legend_data.h"
16 #include "qwt_graphic.h"
17 #include <qrect.h>
18 #include <qlist.h>
19 #include <qmetatype.h>
20 
21 class QPainter;
22 class QwtScaleMap;
23 class QwtScaleDiv;
24 class QwtPlot;
25 
64 class QWT_EXPORT QwtPlotItem
65 {
66 public:
74  {
76  Rtti_PlotItem = 0,
77 
80 
83 
86 
89 
92 
95 
98 
101 
104 
107 
110 
113 
116 
119 
122 
125 
130  Rtti_PlotUserItem = 1000
131  };
132 
143  {
145  Legend = 0x01,
146 
152  AutoScale = 0x02,
153 
159  Margins = 0x04
160  };
161 
163  typedef QFlags<ItemAttribute> ItemAttributes;
164 
176  {
181  ScaleInterest = 0x01,
182 
193  LegendInterest = 0x02
194  };
195 
197  typedef QFlags<ItemInterest> ItemInterests;
198 
201  {
203  RenderAntialiased = 0x1
204  };
205 
207  typedef QFlags<RenderHint> RenderHints;
208 
209  explicit QwtPlotItem( const QwtText &title = QwtText() );
210  virtual ~QwtPlotItem();
211 
212  void attach( QwtPlot *plot );
213  void detach();
214 
215  QwtPlot *plot() const;
216 
217  void setTitle( const QString &title );
218  void setTitle( const QwtText &title );
219  const QwtText &title() const;
220 
221  virtual int rtti() const;
222 
223  void setItemAttribute( ItemAttribute, bool on = true );
224  bool testItemAttribute( ItemAttribute ) const;
225 
226  void setItemInterest( ItemInterest, bool on = true );
227  bool testItemInterest( ItemInterest ) const;
228 
229  void setRenderHint( RenderHint, bool on = true );
230  bool testRenderHint( RenderHint ) const;
231 
232  void setRenderThreadCount( uint numThreads );
233  uint renderThreadCount() const;
234 
235  void setLegendIconSize( const QSize & );
236  QSize legendIconSize() const;
237 
238  double z() const;
239  void setZ( double z );
240 
241  void show();
242  void hide();
243  virtual void setVisible( bool );
244  bool isVisible () const;
245 
246  void setAxes( int xAxis, int yAxis );
247 
248  void setXAxis( int axis );
249  int xAxis() const;
250 
251  void setYAxis( int axis );
252  int yAxis() const;
253 
254  virtual void itemChanged();
255  virtual void legendChanged();
256 
265  virtual void draw( QPainter *painter,
266  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
267  const QRectF &canvasRect ) const = 0;
268 
269  virtual QRectF boundingRect() const;
270 
271  virtual void getCanvasMarginHint(
272  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
273  const QRectF &canvasRect,
274  double &left, double &top, double &right, double &bottom) const;
275 
276  virtual void updateScaleDiv(
277  const QwtScaleDiv&, const QwtScaleDiv& );
278 
279  virtual void updateLegend( const QwtPlotItem *,
280  const QList<QwtLegendData> & );
281 
282  QRectF scaleRect( const QwtScaleMap &, const QwtScaleMap & ) const;
283  QRectF paintRect( const QwtScaleMap &, const QwtScaleMap & ) const;
284 
285  virtual QList<QwtLegendData> legendData() const;
286 
287  virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
288 
289 protected:
290  QwtGraphic defaultIcon( const QBrush &, const QSizeF & ) const;
291 
292 private:
293  // Disabled copy constructor and operator=
294  QwtPlotItem( const QwtPlotItem & );
295  QwtPlotItem &operator=( const QwtPlotItem & );
296 
297  class PrivateData;
298  PrivateData *d_data;
299 };
300 
301 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes )
302 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemInterests )
303 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints )
304 
305 Q_DECLARE_METATYPE( QwtPlotItem * )
306 
307 #endif
QwtPlot
A 2-D plotting widget.
Definition: qwt_plot.h:75
QwtPlotItem::Rtti_PlotZone
For QwtPlotZoneItem.
Definition: qwt_plot_item.h:124
QwtPlotItem::RenderHint
RenderHint
Render hints.
Definition: qwt_plot_item.h:200
QwtPlotItem::Rtti_PlotSpectrogram
For QwtPlotSpectrogram.
Definition: qwt_plot_item.h:103
QwtPlotItem::Rtti_PlotCurve
For QwtPlotCurve.
Definition: qwt_plot_item.h:91
QwtPlotItem::Rtti_PlotTextLabel
For QwtPlotTextLabel.
Definition: qwt_plot_item.h:121
QwtPlotItem::Rtti_PlotIntervalCurve
For QwtPlotIntervalCurve.
Definition: qwt_plot_item.h:97
QwtPlotItem::Rtti_PlotBarChart
For QwtPlotBarChart.
Definition: qwt_plot_item.h:112
QwtPlotItem::Rtti_PlotLegend
For QwtPlotLegendItem.
Definition: qwt_plot_item.h:85
QwtPlotItem
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:64
QwtPlotItem::Rtti_PlotSVG
For QwtPlotSvgItem.
Definition: qwt_plot_item.h:106
QwtText
A class representing a text.
Definition: qwt_text.h:51
QwtPlotItem::Rtti_PlotMarker
For QwtPlotMarker.
Definition: qwt_plot_item.h:88
QwtPlotItem::ItemAttributes
QFlags< ItemAttribute > ItemAttributes
Plot Item Attributes.
Definition: qwt_plot_item.h:163
QwtPlotItem::ItemInterest
ItemInterest
Plot Item Interests.
Definition: qwt_plot_item.h:175
QwtPlotItem::RttiValues
RttiValues
Runtime type information.
Definition: qwt_plot_item.h:73
QwtGraphic
A paint device for scalable graphics.
Definition: qwt_graphic.h:74
QwtPlotItem::ItemAttribute
ItemAttribute
Plot Item Attributes.
Definition: qwt_plot_item.h:142
QwtPlotItem::Rtti_PlotMultiBarChart
For QwtPlotMultiBarChart.
Definition: qwt_plot_item.h:115
QwtPlotItem::Rtti_PlotScale
For QwtPlotScaleItem.
Definition: qwt_plot_item.h:82
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:30
QwtPlotItem::Rtti_PlotSpectroCurve
For QwtPlotSpectroCurve.
Definition: qwt_plot_item.h:94
QwtPlotItem::Rtti_PlotGrid
For QwtPlotGrid.
Definition: qwt_plot_item.h:79
QwtPlotItem::Rtti_PlotShape
For QwtPlotShapeItem.
Definition: qwt_plot_item.h:118
QwtPlotItem::RenderHints
QFlags< RenderHint > RenderHints
Render hints.
Definition: qwt_plot_item.h:207
QwtPlotItem::Rtti_PlotHistogram
For QwtPlotHistogram.
Definition: qwt_plot_item.h:100
QwtPlotItem::Rtti_PlotTradingCurve
For QwtPlotTradingCurve.
Definition: qwt_plot_item.h:109
QwtPlotItem::ItemInterests
QFlags< ItemInterest > ItemInterests
Plot Item Interests.
Definition: qwt_plot_item.h:197
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:36