Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot.h


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (3 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_plot.h

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1212
    1313#include "qwt_global.h"
    14 #include "qwt_text.h"
     14#include "qwt_axis_id.h"
    1515#include "qwt_plot_dict.h"
    16 #include "qwt_scale_map.h"
    17 #include "qwt_interval.h"
     16
    1817#include <qframe.h>
    19 #include <qlist.h>
    20 #include <qvariant.h>
    2118
    2219class QwtPlotLayout;
    … …  
    2522class QwtScaleEngine;
    2623class QwtScaleDiv;
     24class QwtScaleMap;
    2725class QwtScaleDraw;
    2826class QwtTextLabel;
     27class QwtInterval;
     28class QwtText;
     29template< typename T > class QList;
     30
     31// 6.1 compatibility definitions
     32#define QWT_AXIS_COMPAT 1
    2933
    3034/*!
    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
    4953    The following example shows (schematically) the most simple
    5054    way to use QwtPlot. By default, only the left and bottom axes are
    5155    visible and their scales are computed automatically.
    5256    \code
    53       #include <qwt_plot.h>
    54       #include <qwt_plot_curve.h>
     57 #include <qwt_plot.h>
     58 #include <qwt_plot_curve.h>
    5559
    5660      QwtPlot *myPlot = new QwtPlot( "Two Curves", parent );
    … …  
    7074      myPlot->replot();
    7175    \endcode
    72   \endpar
    73 */
    74 
    75 class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict
     76 */
     77
     78class QWT_EXPORT QwtPlot : public QFrame, public QwtPlotDict
    7679{
    7780    Q_OBJECT
    … …  
    7982    Q_PROPERTY( QBrush canvasBackground
    8083        READ canvasBackground WRITE setCanvasBackground )
     84
    8185    Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot )
    8286
    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:
    11288    /*!
    11389        Position of the legend, relative to the canvas.
    … …  
    11793    enum LegendPosition
    11894    {
    119         //! The legend will be left from the QwtPlot::yLeft axis.
     95        //! The legend will be left from the QwtAxis::YLeft axis.
    12096        LeftLegend,
    12197
    122         //! The legend will be right from the QwtPlot::yRight axis.
     98        //! The legend will be right from the QwtAxis::YRight axis.
    12399        RightLegend,
    124100
    … …  
    130106    };
    131107
    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 );
    134110
    135111    virtual ~QwtPlot();
    136 
    137     void applyProperties( const QString & );
    138     QString grabProperties() const;
    139112
    140113    void setAutoReplot( bool = true );
    … …  
    143116    // Layout
    144117
    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;
    149122
    150123    // Title
    151124
    152     void setTitle( const QString & );
    153     void setTitle( const QwtText & );
     125    void setTitle( const QString& );
     126    void setTitle( const QwtText& );
    154127    QwtText title() const;
    155128
    156     QwtTextLabel *titleLabel();
    157     const QwtTextLabel *titleLabel() const;
     129    QwtTextLabel* titleLabel();
     130    const QwtTextLabel* titleLabel() const;
    158131
    159132    // Footer
    160133
    161     void setFooter( const QString & );
    162     void setFooter( const QwtText & );
     134    void setFooter( const QString& );
     135    void setFooter( const QwtText& );
    163136    QwtText footer() const;
    164137
    165     QwtTextLabel *footerLabel();
    166     const QwtTextLabel *footerLabel() const;
     138    QwtTextLabel* footerLabel();
     139    const QwtTextLabel* footerLabel() const;
    167140
    168141    // Canvas
    169142
    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& );
    176149    QBrush canvasBackground() const;
    177150
    178     virtual QwtScaleMap canvasMap( int axisId ) const;
    179 
    180     double invTransform( int axisId, int pos ) 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;
    182155
    183156    // Axes
    184157
    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;
    225201
    226202    // Legend
    227203
    228     void insertLegend( QwtAbstractLegend *,
     204    void insertLegend( QwtAbstractLegend*,
    229205        LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 );
    230206
    231     QwtAbstractLegend *legend();
    232     const QwtAbstractLegend *legend() const;
     207    QwtAbstractLegend* legend();
     208    const QwtAbstractLegend* legend() const;
    233209
    234210    void updateLegend();
    235     void updateLegend( const QwtPlotItem * );
     211    void updateLegend( const QwtPlotItem* );
    236212
    237213    // Misc
    238214
    239     virtual QSize sizeHint() const;
    240     virtual QSize minimumSizeHint() const;
     215    virtual QSize sizeHint() const QWT_OVERRIDE;
     216    virtual QSize minimumSizeHint() const QWT_OVERRIDE;
    241217
    242218    virtual void updateLayout();
    243     virtual void drawCanvas( QPainter * );
     219    virtual void drawCanvas( QPainter* );
    244220
    245221    void updateAxes();
    … …  
    247223
    248224    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:
    262260    /*!
    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
    267265     */
    268     void itemAttached( QwtPlotItem *plotItem, bool on );
     266    void itemAttached( QwtPlotItem* plotItem, bool on );
    269267
    270268    /*!
    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
    276274                  the plot item.
    277275
    278       \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
     276       \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
    279277     */
    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:
    284282    virtual void replot();
    285283    void autoRefresh();
    286284
    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:
    297294    friend class QwtPlotItem;
    298     void attachItem( QwtPlotItem *, bool );
     295    void attachItem( QwtPlotItem*, bool );
    299296
    300297    void initAxesData();
    … …  
    302299    void updateScaleDiv();
    303300
    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;
    308305
    309306    class PrivateData;
    310     PrivateData *d_data;
     307    PrivateData* m_data;
    311308};
    312309
Note: See TracChangeset for help on using the changeset viewer.