Qwt User's Guide  6.0.2
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_legend_itemmanager.h"
15 #include "qwt_text.h"
16 #include <qrect.h>
17 
18 class QString;
19 class QPainter;
20 class QWidget;
21 class QwtPlot;
22 class QwtLegend;
23 class QwtScaleMap;
24 class QwtScaleDiv;
25 
64 class QWT_EXPORT QwtPlotItem: public QwtLegendItemManager
65 {
66 public:
74  {
76  Rtti_PlotItem = 0,
77 
80 
83 
86 
89 
92 
95 
98 
101 
104 
109  Rtti_PlotUserItem = 1000
110  };
111 
117  {
119  Legend = 0x01,
120 
125  AutoScale = 0x02
126  };
127 
129  typedef QFlags<ItemAttribute> ItemAttributes;
130 
133  {
135  RenderAntialiased = 1
136  };
137 
139  typedef QFlags<RenderHint> RenderHints;
140 
141  explicit QwtPlotItem( const QwtText &title = QwtText() );
142  virtual ~QwtPlotItem();
143 
144  void attach( QwtPlot *plot );
145  void detach();
146 
147  QwtPlot *plot() const;
148 
149  void setTitle( const QString &title );
150  void setTitle( const QwtText &title );
151  const QwtText &title() const;
152 
153  virtual int rtti() const;
154 
155  void setItemAttribute( ItemAttribute, bool on = true );
156  bool testItemAttribute( ItemAttribute ) const;
157 
158  void setRenderHint( RenderHint, bool on = true );
159  bool testRenderHint( RenderHint ) const;
160 
161  double z() const;
162  void setZ( double z );
163 
164  void show();
165  void hide();
166  virtual void setVisible( bool );
167  bool isVisible () const;
168 
169  void setAxes( int xAxis, int yAxis );
170 
171  void setXAxis( int axis );
172  int xAxis() const;
173 
174  void setYAxis( int axis );
175  int yAxis() const;
176 
177  virtual void itemChanged();
178 
187  virtual void draw( QPainter *painter,
188  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
189  const QRectF &canvasRect ) const = 0;
190 
191  virtual QRectF boundingRect() const;
192 
193  virtual void updateLegend( QwtLegend * ) const;
194  virtual void updateScaleDiv(
195  const QwtScaleDiv&, const QwtScaleDiv& );
196 
197  virtual QWidget *legendItem() const;
198 
199  QRectF scaleRect( const QwtScaleMap &, const QwtScaleMap & ) const;
200  QRectF paintRect( const QwtScaleMap &, const QwtScaleMap & ) const;
201 
202 private:
203  // Disabled copy constructor and operator=
204  QwtPlotItem( const QwtPlotItem & );
205  QwtPlotItem &operator=( const QwtPlotItem & );
206 
207  class PrivateData;
208  PrivateData *d_data;
209 };
210 
211 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes )
212 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints )
213 
214 #endif