Qwt User's Guide
|
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_text.h" 00015 #include "qwt_legend_data.h" 00016 #include "qwt_graphic.h" 00017 #include <qrect.h> 00018 #include <qlist.h> 00019 #include <qmetatype.h> 00020 00021 class QPainter; 00022 class QwtScaleMap; 00023 class QwtScaleDiv; 00024 class QwtPlot; 00025 00064 class QWT_EXPORT QwtPlotItem 00065 { 00066 public: 00073 enum RttiValues 00074 { 00076 Rtti_PlotItem = 0, 00077 00079 Rtti_PlotGrid, 00080 00082 Rtti_PlotScale, 00083 00085 Rtti_PlotLegend, 00086 00088 Rtti_PlotMarker, 00089 00091 Rtti_PlotCurve, 00092 00094 Rtti_PlotSpectroCurve, 00095 00097 Rtti_PlotIntervalCurve, 00098 00100 Rtti_PlotHistogram, 00101 00103 Rtti_PlotSpectrogram, 00104 00106 Rtti_PlotSVG, 00107 00109 Rtti_PlotTradingCurve, 00110 00112 Rtti_PlotBarChart, 00113 00115 Rtti_PlotMultiBarChart, 00116 00118 Rtti_PlotShape, 00119 00121 Rtti_PlotTextLabel, 00122 00124 Rtti_PlotZone, 00125 00130 Rtti_PlotUserItem = 1000 00131 }; 00132 00142 enum ItemAttribute 00143 { 00145 Legend = 0x01, 00146 00152 AutoScale = 0x02, 00153 00159 Margins = 0x04 00160 }; 00161 00163 typedef QFlags<ItemAttribute> ItemAttributes; 00164 00175 enum ItemInterest 00176 { 00181 ScaleInterest = 0x01, 00182 00193 LegendInterest = 0x02 00194 }; 00195 00197 typedef QFlags<ItemInterest> ItemInterests; 00198 00200 enum RenderHint 00201 { 00203 RenderAntialiased = 0x1 00204 }; 00205 00207 typedef QFlags<RenderHint> RenderHints; 00208 00209 explicit QwtPlotItem( const QwtText &title = QwtText() ); 00210 virtual ~QwtPlotItem(); 00211 00212 void attach( QwtPlot *plot ); 00213 void detach(); 00214 00215 QwtPlot *plot() const; 00216 00217 void setTitle( const QString &title ); 00218 void setTitle( const QwtText &title ); 00219 const QwtText &title() const; 00220 00221 virtual int rtti() const; 00222 00223 void setItemAttribute( ItemAttribute, bool on = true ); 00224 bool testItemAttribute( ItemAttribute ) const; 00225 00226 void setItemInterest( ItemInterest, bool on = true ); 00227 bool testItemInterest( ItemInterest ) const; 00228 00229 void setRenderHint( RenderHint, bool on = true ); 00230 bool testRenderHint( RenderHint ) const; 00231 00232 void setRenderThreadCount( uint numThreads ); 00233 uint renderThreadCount() const; 00234 00235 void setLegendIconSize( const QSize & ); 00236 QSize legendIconSize() const; 00237 00238 double z() const; 00239 void setZ( double z ); 00240 00241 void show(); 00242 void hide(); 00243 virtual void setVisible( bool ); 00244 bool isVisible () const; 00245 00246 void setAxes( int xAxis, int yAxis ); 00247 00248 void setXAxis( int axis ); 00249 int xAxis() const; 00250 00251 void setYAxis( int axis ); 00252 int yAxis() const; 00253 00254 virtual void itemChanged(); 00255 virtual void legendChanged(); 00256 00265 virtual void draw( QPainter *painter, 00266 const QwtScaleMap &xMap, const QwtScaleMap &yMap, 00267 const QRectF &canvasRect ) const = 0; 00268 00269 virtual QRectF boundingRect() const; 00270 00271 virtual void getCanvasMarginHint( 00272 const QwtScaleMap &xMap, const QwtScaleMap &yMap, 00273 const QRectF &canvasSize, 00274 double &left, double &top, double &right, double &bottom) const; 00275 00276 virtual void updateScaleDiv( 00277 const QwtScaleDiv&, const QwtScaleDiv& ); 00278 00279 virtual void updateLegend( const QwtPlotItem *, 00280 const QList<QwtLegendData> & ); 00281 00282 QRectF scaleRect( const QwtScaleMap &, const QwtScaleMap & ) const; 00283 QRectF paintRect( const QwtScaleMap &, const QwtScaleMap & ) const; 00284 00285 virtual QList<QwtLegendData> legendData() const; 00286 00287 virtual QwtGraphic legendIcon( int index, const QSizeF & ) const; 00288 00289 protected: 00290 QwtGraphic defaultIcon( const QBrush &, const QSizeF & ) const; 00291 00292 private: 00293 // Disabled copy constructor and operator= 00294 QwtPlotItem( const QwtPlotItem & ); 00295 QwtPlotItem &operator=( const QwtPlotItem & ); 00296 00297 class PrivateData; 00298 PrivateData *d_data; 00299 }; 00300 00301 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes ) 00302 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemInterests ) 00303 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints ) 00304 00305 Q_DECLARE_METATYPE( QwtPlotItem * ) 00306 00307 #endif