Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot.h
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot.h
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 12 12 13 13 #include "qwt_global.h" 14 #include "qwt_ text.h"14 #include "qwt_axis_id.h" 15 15 #include "qwt_plot_dict.h" 16 #include "qwt_scale_map.h" 17 #include "qwt_interval.h" 16 18 17 #include <qframe.h> 19 #include <qlist.h>20 #include <qvariant.h>21 18 22 19 class QwtPlotLayout; … … 25 22 class QwtScaleEngine; 26 23 class QwtScaleDiv; 24 class QwtScaleMap; 27 25 class QwtScaleDraw; 28 26 class QwtTextLabel; 27 class QwtInterval; 28 class QwtText; 29 template< typename T > class QList; 30 31 // 6.1 compatibility definitions 32 #define QWT_AXIS_COMPAT 1 29 33 30 34 /*! 31 \brief A 2-D plotting widget 32 33 QwtPlot is a widget for plotting two-dimensional graphs. 34 An unlimited number of plot items can be displayed on 35 its canvas. Plot items might be curves (QwtPlotCurve), markers 36 (QwtPlotMarker), the grid (QwtPlotGrid), or anything else derived 37 from QwtPlotItem. 38 A plot can have up to four axes, with each plot item attached to an x- and 39 a y axis. The scales at the axes can be explicitly set (QwtScaleDiv), or 40 are calculated from the plot items, using algorithms (QwtScaleEngine) which 41 can be configured separately for each axis. 42 43 The simpleplot example is a good starting point to see how to set up a 44 plot widget. 45 46 \image html plot.png 47 48 \par Example 35 \brief A 2-D plotting widget 36 37 QwtPlot is a widget for plotting two-dimensional graphs. 38 An unlimited number of plot items can be displayed on 39 its canvas. Plot items might be curves (QwtPlotCurve), markers 40 (QwtPlotMarker), the grid (QwtPlotGrid), or anything else derived 41 from QwtPlotItem. 42 A plot can have up to four axes, with each plot item attached to an x- and 43 a y axis. The scales at the axes can be explicitly set (QwtScaleDiv), or 44 are calculated from the plot items, using algorithms (QwtScaleEngine) which 45 can be configured separately for each axis. 46 47 The simpleplot example is a good starting point to see how to set up a 48 plot widget. 49 50 \image html plot.png 51 52 \par Example 49 53 The following example shows (schematically) the most simple 50 54 way to use QwtPlot. By default, only the left and bottom axes are 51 55 visible and their scales are computed automatically. 52 56 \code 53 #include <qwt_plot.h>54 #include <qwt_plot_curve.h>57 #include <qwt_plot.h> 58 #include <qwt_plot_curve.h> 55 59 56 60 QwtPlot *myPlot = new QwtPlot( "Two Curves", parent ); … … 70 74 myPlot->replot(); 71 75 \endcode 72 \endpar 73 */ 74 75 class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict 76 */ 77 78 class QWT_EXPORT QwtPlot : public QFrame, public QwtPlotDict 76 79 { 77 80 Q_OBJECT … … 79 82 Q_PROPERTY( QBrush canvasBackground 80 83 READ canvasBackground WRITE setCanvasBackground ) 84 81 85 Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot ) 82 86 83 #if 0 84 // This property is intended to configure the plot 85 // widget from a special dialog in the deigner plugin. 86 // Disabled until such a dialog has been implemented. 87 88 Q_PROPERTY( QString propertiesDocument 89 READ grabProperties WRITE applyProperties ) 90 #endif 91 92 public: 93 //! \brief Axis index 94 enum Axis 95 { 96 //! Y axis left of the canvas 97 yLeft, 98 99 //! Y axis right of the canvas 100 yRight, 101 102 //! X axis below the canvas 103 xBottom, 104 105 //! X axis above the canvas 106 xTop, 107 108 //! Number of axes 109 axisCnt 110 }; 111 87 public: 112 88 /*! 113 89 Position of the legend, relative to the canvas. … … 117 93 enum LegendPosition 118 94 { 119 //! The legend will be left from the Qwt Plot::yLeft axis.95 //! The legend will be left from the QwtAxis::YLeft axis. 120 96 LeftLegend, 121 97 122 //! The legend will be right from the Qwt Plot::yRight axis.98 //! The legend will be right from the QwtAxis::YRight axis. 123 99 RightLegend, 124 100 … … 130 106 }; 131 107 132 explicit QwtPlot( QWidget * = NULL );133 explicit QwtPlot( const QwtText &title, QWidget* = NULL );108 explicit QwtPlot( QWidget* = NULL ); 109 explicit QwtPlot( const QwtText& title, QWidget* = NULL ); 134 110 135 111 virtual ~QwtPlot(); 136 137 void applyProperties( const QString & );138 QString grabProperties() const;139 112 140 113 void setAutoReplot( bool = true ); … … 143 116 // Layout 144 117 145 void setPlotLayout( QwtPlotLayout * );146 147 QwtPlotLayout *plotLayout();148 const QwtPlotLayout *plotLayout() const;118 void setPlotLayout( QwtPlotLayout* ); 119 120 QwtPlotLayout* plotLayout(); 121 const QwtPlotLayout* plotLayout() const; 149 122 150 123 // Title 151 124 152 void setTitle( const QString & );153 void setTitle( const QwtText & );125 void setTitle( const QString& ); 126 void setTitle( const QwtText& ); 154 127 QwtText title() const; 155 128 156 QwtTextLabel *titleLabel();157 const QwtTextLabel *titleLabel() const;129 QwtTextLabel* titleLabel(); 130 const QwtTextLabel* titleLabel() const; 158 131 159 132 // Footer 160 133 161 void setFooter( const QString & );162 void setFooter( const QwtText & );134 void setFooter( const QString& ); 135 void setFooter( const QwtText& ); 163 136 QwtText footer() const; 164 137 165 QwtTextLabel *footerLabel();166 const QwtTextLabel *footerLabel() const;138 QwtTextLabel* footerLabel(); 139 const QwtTextLabel* footerLabel() const; 167 140 168 141 // Canvas 169 142 170 void setCanvas( QWidget * );171 172 QWidget *canvas();173 const QWidget *canvas() const;174 175 void setCanvasBackground( const QBrush & );143 void setCanvas( QWidget* ); 144 145 QWidget* canvas(); 146 const QWidget* canvas() const; 147 148 void setCanvasBackground( const QBrush& ); 176 149 QBrush canvasBackground() const; 177 150 178 virtual QwtScaleMap canvasMap( int axisId ) const;179 180 double invTransform( int axisId,intpos ) const;181 double transform( int axisId, double value ) const;151 virtual QwtScaleMap canvasMap( QwtAxisId ) const; 152 153 double invTransform( QwtAxisId, double pos ) const; 154 double transform( QwtAxisId, double value ) const; 182 155 183 156 // Axes 184 157 185 QwtScaleEngine *axisScaleEngine( int axisId ); 186 const QwtScaleEngine *axisScaleEngine( int axisId ) const; 187 void setAxisScaleEngine( int axisId, QwtScaleEngine * ); 188 189 void setAxisAutoScale( int axisId, bool on = true ); 190 bool axisAutoScale( int axisId ) const; 191 192 void enableAxis( int axisId, bool tf = true ); 193 bool axisEnabled( int axisId ) const; 194 195 void setAxisFont( int axisId, const QFont & ); 196 QFont axisFont( int axisId ) const; 197 198 void setAxisScale( int axisId, double min, double max, double stepSize = 0 ); 199 void setAxisScaleDiv( int axisId, const QwtScaleDiv & ); 200 void setAxisScaleDraw( int axisId, QwtScaleDraw * ); 201 202 double axisStepSize( int axisId ) const; 203 QwtInterval axisInterval( int axisId ) const; 204 205 const QwtScaleDiv &axisScaleDiv( int axisId ) const; 206 207 const QwtScaleDraw *axisScaleDraw( int axisId ) const; 208 QwtScaleDraw *axisScaleDraw( int axisId ); 209 210 const QwtScaleWidget *axisWidget( int axisId ) const; 211 QwtScaleWidget *axisWidget( int axisId ); 212 213 void setAxisLabelAlignment( int axisId, Qt::Alignment ); 214 void setAxisLabelRotation( int axisId, double rotation ); 215 216 void setAxisTitle( int axisId, const QString & ); 217 void setAxisTitle( int axisId, const QwtText & ); 218 QwtText axisTitle( int axisId ) const; 219 220 void setAxisMaxMinor( int axisId, int maxMinor ); 221 int axisMaxMinor( int axisId ) const; 222 223 void setAxisMaxMajor( int axisId, int maxMajor ); 224 int axisMaxMajor( int axisId ) const; 158 bool isAxisValid( QwtAxisId ) const; 159 160 void setAxisVisible( QwtAxisId, bool on = true ); 161 bool isAxisVisible( QwtAxisId ) const; 162 163 // Axes data 164 165 QwtScaleEngine* axisScaleEngine( QwtAxisId ); 166 const QwtScaleEngine* axisScaleEngine( QwtAxisId ) const; 167 void setAxisScaleEngine( QwtAxisId, QwtScaleEngine* ); 168 169 void setAxisAutoScale( QwtAxisId, bool on = true ); 170 bool axisAutoScale( QwtAxisId ) const; 171 172 void setAxisFont( QwtAxisId, const QFont& ); 173 QFont axisFont( QwtAxisId ) const; 174 175 void setAxisScale( QwtAxisId, double min, double max, double stepSize = 0 ); 176 void setAxisScaleDiv( QwtAxisId, const QwtScaleDiv& ); 177 void setAxisScaleDraw( QwtAxisId, QwtScaleDraw* ); 178 179 double axisStepSize( QwtAxisId ) const; 180 QwtInterval axisInterval( QwtAxisId ) const; 181 const QwtScaleDiv& axisScaleDiv( QwtAxisId ) const; 182 183 const QwtScaleDraw* axisScaleDraw( QwtAxisId ) const; 184 QwtScaleDraw* axisScaleDraw( QwtAxisId ); 185 186 const QwtScaleWidget* axisWidget( QwtAxisId ) const; 187 QwtScaleWidget* axisWidget( QwtAxisId ); 188 189 void setAxisLabelAlignment( QwtAxisId, Qt::Alignment ); 190 void setAxisLabelRotation( QwtAxisId, double rotation ); 191 192 void setAxisTitle( QwtAxisId, const QString& ); 193 void setAxisTitle( QwtAxisId, const QwtText& ); 194 QwtText axisTitle( QwtAxisId ) const; 195 196 void setAxisMaxMinor( QwtAxisId, int maxMinor ); 197 int axisMaxMinor( QwtAxisId ) const; 198 199 void setAxisMaxMajor( QwtAxisId, int maxMajor ); 200 int axisMaxMajor( QwtAxisId ) const; 225 201 226 202 // Legend 227 203 228 void insertLegend( QwtAbstractLegend *,204 void insertLegend( QwtAbstractLegend*, 229 205 LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 ); 230 206 231 QwtAbstractLegend *legend();232 const QwtAbstractLegend *legend() const;207 QwtAbstractLegend* legend(); 208 const QwtAbstractLegend* legend() const; 233 209 234 210 void updateLegend(); 235 void updateLegend( const QwtPlotItem * );211 void updateLegend( const QwtPlotItem* ); 236 212 237 213 // Misc 238 214 239 virtual QSize sizeHint() const; 240 virtual QSize minimumSizeHint() const; 215 virtual QSize sizeHint() const QWT_OVERRIDE; 216 virtual QSize minimumSizeHint() const QWT_OVERRIDE; 241 217 242 218 virtual void updateLayout(); 243 virtual void drawCanvas( QPainter * );219 virtual void drawCanvas( QPainter* ); 244 220 245 221 void updateAxes(); … … 247 223 248 224 virtual void getCanvasMarginsHint( 249 const QwtScaleMap maps[], const QRectF &canvasRect, 250 double &left, double &top, double &right, double &bottom) const; 251 252 virtual bool event( QEvent * ); 253 virtual bool eventFilter( QObject *, QEvent * ); 254 255 virtual void drawItems( QPainter *, const QRectF &, 256 const QwtScaleMap maps[axisCnt] ) const; 257 258 virtual QVariant itemToInfo( QwtPlotItem * ) const; 259 virtual QwtPlotItem *infoToItem( const QVariant & ) const; 260 261 Q_SIGNALS: 225 const QwtScaleMap maps[], const QRectF& canvasRect, 226 double& left, double& top, double& right, double& bottom) const; 227 228 virtual bool event( QEvent* ) QWT_OVERRIDE; 229 virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE; 230 231 virtual void drawItems( QPainter*, const QRectF&, 232 const QwtScaleMap maps[ QwtAxis::AxisPositions ] ) const; 233 234 virtual QVariant itemToInfo( QwtPlotItem* ) const; 235 virtual QwtPlotItem* infoToItem( const QVariant& ) const; 236 237 #if QWT_AXIS_COMPAT 238 enum Axis 239 { 240 yLeft = QwtAxis::YLeft, 241 yRight = QwtAxis::YRight, 242 xBottom = QwtAxis::XBottom, 243 xTop = QwtAxis::XTop, 244 245 axisCnt = QwtAxis::AxisPositions 246 }; 247 248 void enableAxis( int axisId, bool on = true ) 249 { 250 setAxisVisible( axisId, on ); 251 } 252 253 bool axisEnabled( int axisId ) const 254 { 255 return isAxisVisible( axisId ); 256 } 257 #endif 258 259 Q_SIGNALS: 262 260 /*! 263 A signal indicating, that an item has been attached/detached 264 265 \param plotItem Plot item 266 \param on Attached/Detached 261 A signal indicating, that an item has been attached/detached 262 263 \param plotItem Plot item 264 \param on Attached/Detached 267 265 */ 268 void itemAttached( QwtPlotItem *plotItem, bool on );266 void itemAttached( QwtPlotItem* plotItem, bool on ); 269 267 270 268 /*! 271 A signal with the attributes how to update 272 the legend entries for a plot item. 273 274 \param itemInfo Info about a plot item, build from itemToInfo() 275 \param data Attributes of the entries ( usually <= 1 ) for 269 A signal with the attributes how to update 270 the legend entries for a plot item. 271 272 \param itemInfo Info about a plot item, build from itemToInfo() 273 \param data Attributes of the entries ( usually <= 1 ) for 276 274 the plot item. 277 275 278 \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend() 276 \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend() 279 277 */ 280 void legendDataChanged( const QVariant &itemInfo,281 const QList<QwtLegendData > &data );282 283 public Q_SLOTS: 278 void legendDataChanged( const QVariant& itemInfo, 279 const QList< QwtLegendData >& data ); 280 281 public Q_SLOTS: 284 282 virtual void replot(); 285 283 void autoRefresh(); 286 284 287 protected: 288 static bool axisValid( int axisId ); 289 290 virtual void resizeEvent( QResizeEvent *e ); 291 292 private Q_SLOTS: 293 void updateLegendItems( const QVariant &itemInfo, 294 const QList<QwtLegendData> &legendData ); 295 296 private: 285 protected: 286 287 virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE; 288 289 private Q_SLOTS: 290 void updateLegendItems( const QVariant& itemInfo, 291 const QList< QwtLegendData >& legendData ); 292 293 private: 297 294 friend class QwtPlotItem; 298 void attachItem( QwtPlotItem *, bool );295 void attachItem( QwtPlotItem*, bool ); 299 296 300 297 void initAxesData(); … … 302 299 void updateScaleDiv(); 303 300 304 void initPlot( const QwtText &title );305 306 class AxisData;307 AxisData *d_axisData[axisCnt];301 void initPlot( const QwtText& title ); 302 303 class ScaleData; 304 ScaleData* m_scaleData; 308 305 309 306 class PrivateData; 310 PrivateData *d_data;307 PrivateData* m_data; 311 308 }; 312 309
Note:
See TracChangeset
for help on using the changeset viewer.
