Qwt User's Guide svn
qwt_plot_item.h
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #ifndef QWT_PLOT_ITEM_H
00011 #define QWT_PLOT_ITEM_H
00012 
00013 #include "qwt_global.h"
00014 #include "qwt_legend_itemmanager.h"
00015 #include "qwt_text.h"
00016 #include <qrect.h>
00017 
00018 class QString;
00019 class QPainter;
00020 class QWidget;
00021 class QwtPlot;
00022 class QwtLegend;
00023 class QwtScaleMap;
00024 class QwtScaleDiv;
00025 
00064 class QWT_EXPORT QwtPlotItem: public QwtLegendItemManager
00065 {
00066 public:
00073     enum RttiValues
00074     {
00076         Rtti_PlotItem = 0,
00077 
00079         Rtti_PlotGrid,
00080 
00082         Rtti_PlotScale,
00083 
00085         Rtti_PlotMarker,
00086 
00088         Rtti_PlotCurve,
00089 
00091         Rtti_PlotSpectroCurve,
00092 
00094         Rtti_PlotIntervalCurve,
00095 
00097         Rtti_PlotHistogram,
00098 
00100         Rtti_PlotSpectrogram,
00101 
00103         Rtti_PlotSVG,
00104 
00109         Rtti_PlotUserItem = 1000
00110     };
00111 
00116     enum ItemAttribute
00117     {
00119         Legend = 0x01,
00120 
00125         AutoScale = 0x02
00126     };
00127 
00129     typedef QFlags<ItemAttribute> ItemAttributes;
00130 
00132     enum RenderHint
00133     {
00135         RenderAntialiased = 1
00136     };
00137 
00139     typedef QFlags<RenderHint> RenderHints;
00140 
00141     explicit QwtPlotItem( const QwtText &title = QwtText() );
00142     virtual ~QwtPlotItem();
00143 
00144     void attach( QwtPlot *plot );
00145     void detach();
00146 
00147     QwtPlot *plot() const;
00148 
00149     void setTitle( const QString &title );
00150     void setTitle( const QwtText &title );
00151     const QwtText &title() const;
00152 
00153     virtual int rtti() const;
00154 
00155     void setItemAttribute( ItemAttribute, bool on = true );
00156     bool testItemAttribute( ItemAttribute ) const;
00157 
00158     void setRenderHint( RenderHint, bool on = true );
00159     bool testRenderHint( RenderHint ) const;
00160 
00161     double z() const;
00162     void setZ( double z );
00163 
00164     void show();
00165     void hide();
00166     virtual void setVisible( bool );
00167     bool isVisible () const;
00168 
00169     void setAxes( int xAxis, int yAxis );
00170 
00171     void setXAxis( int axis );
00172     int xAxis() const;
00173 
00174     void setYAxis( int axis );
00175     int yAxis() const;
00176 
00177     virtual void itemChanged();
00178 
00187     virtual void draw( QPainter *painter,
00188         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00189         const QRectF &canvasRect ) const = 0;
00190 
00191     virtual QRectF boundingRect() const;
00192 
00193     virtual void updateLegend( QwtLegend * ) const;
00194     virtual void updateScaleDiv( 
00195         const QwtScaleDiv&, const QwtScaleDiv& );
00196 
00197     virtual QWidget *legendItem() const;
00198 
00199     QRectF scaleRect( const QwtScaleMap &, const QwtScaleMap & ) const;
00200     QRectF paintRect( const QwtScaleMap &, const QwtScaleMap & ) const;
00201 
00202 private:
00203     // Disabled copy constructor and operator=
00204     QwtPlotItem( const QwtPlotItem & );
00205     QwtPlotItem &operator=( const QwtPlotItem & );
00206 
00207     class PrivateData;
00208     PrivateData *d_data;
00209 };
00210 
00211 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes )
00212 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints )
00213 
00214 #endif
qmi style