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


Ignore:
Timestamp:
May 10, 2017, 3:20:54 PM (7 years ago)
Author:
stoecker
Message:

update qwt and qwtpolar, many QT5 fixes (unfinished)

File:
1 edited

Legend:

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

    r4271 r8127  
    1717#include "qwt_interval.h"
    1818#include <qframe.h>
     19#include <qlist.h>
     20#include <qvariant.h>
    1921
    2022class QwtPlotLayout;
    21 class QwtLegend;
     23class QwtAbstractLegend;
    2224class QwtScaleWidget;
    2325class QwtScaleEngine;
     
    2527class QwtScaleDraw;
    2628class QwtTextLabel;
    27 class QwtPlotCanvas;
    2829
    2930/*!
     
    3637  from QwtPlotItem.
    3738  A plot can have up to four axes, with each plot item attached to an x- and
    38   a y axis. The scales at the axes can be explicitely set (QwtScaleDiv), or
     39  a y axis. The scales at the axes can be explicitly set (QwtScaleDiv), or
    3940  are calculated from the plot items, using algorithms (QwtScaleEngine) which
    4041  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.
    4145
    4246  \image html plot.png
     
    5660QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2");
    5761
    58 // copy the data into the curves
     62// connect or copy the data to the curves
    5963curve1->setData(...);
    6064curve2->setData(...);
     
    7175{
    7276    Q_OBJECT
     77
     78    Q_PROPERTY( QBrush canvasBackground
     79        READ canvasBackground WRITE setCanvasBackground )
     80    Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot )
     81
     82#if 0
     83    // This property is intended to configure the plot
     84    // widget from a special dialog in the deigner plugin.
     85    // Disabled until such a dialog has been implemented.
     86
    7387    Q_PROPERTY( QString propertiesDocument
    7488        READ grabProperties WRITE applyProperties )
     89#endif
    7590
    7691public:
     
    98113
    99114        \sa insertLegend()
    100         \note In case of ExternalLegend, the legend is not
    101               handled by QwtPlotRenderer
    102115     */
    103116    enum LegendPosition
     
    109122        RightLegend,
    110123
    111         //! The legend will be below QwtPlot::xBottom axis.
     124        //! The legend will be below the footer
    112125        BottomLegend,
    113126
    114         //! The legend will be between QwtPlot::xTop axis and the title.
    115         TopLegend,
    116 
    117         /*!
    118           External means that only the content of the legend
    119           will be handled by QwtPlot, but not its geometry.
    120           This type can be used to have a legend in an
    121           external window ( or on the canvas ).
    122          */
    123         ExternalLegend
     127        //! The legend will be above the title
     128        TopLegend
    124129    };
    125130
    126131    explicit QwtPlot( QWidget * = NULL );
    127     explicit QwtPlot( const QwtText &title, QWidget *p = NULL );
     132    explicit QwtPlot( const QwtText &title, QWidget * = NULL );
    128133
    129134    virtual ~QwtPlot();
     
    132137    QString grabProperties() const;
    133138
    134     void setAutoReplot( bool tf = true );
     139    void setAutoReplot( bool = true );
    135140    bool autoReplot() const;
    136141
    137142    // Layout
     143
     144    void setPlotLayout( QwtPlotLayout * );
    138145
    139146    QwtPlotLayout *plotLayout();
     
    149156    const QwtTextLabel *titleLabel() const;
    150157
     158    // Footer
     159
     160    void setFooter( const QString & );
     161    void setFooter( const QwtText &t );
     162    QwtText footer() const;
     163
     164    QwtTextLabel *footerLabel();
     165    const QwtTextLabel *footerLabel() const;
     166
    151167    // Canvas
    152168
    153     QwtPlotCanvas *canvas();
    154     const QwtPlotCanvas *canvas() const;
     169    void setCanvas( QWidget * );
     170
     171    QWidget *canvas();
     172    const QWidget *canvas() const;
    155173
    156174    void setCanvasBackground( const QBrush & );
    157175    QBrush canvasBackground() const;
    158 
    159     void setCanvasLineWidth( int w );
    160     int canvasLineWidth() const;
    161176
    162177    virtual QwtScaleMap canvasMap( int axisId ) const;
     
    187202    QwtInterval axisInterval( int axisId ) const;
    188203
    189     const QwtScaleDiv *axisScaleDiv( int axisId ) const;
    190     QwtScaleDiv *axisScaleDiv( int axisId );
     204    const QwtScaleDiv &axisScaleDiv( int axisId ) const;
    191205
    192206    const QwtScaleDraw *axisScaleDraw( int axisId ) const;
     
    211225    // Legend
    212226
    213     void insertLegend( QwtLegend *, LegendPosition = QwtPlot::RightLegend,
    214         double ratio = -1.0 );
    215 
    216     QwtLegend *legend();
    217     const QwtLegend *legend() const;
     227    void insertLegend( QwtAbstractLegend *,
     228        LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 );
     229
     230    QwtAbstractLegend *legend();
     231    const QwtAbstractLegend *legend() const;
     232
     233    void updateLegend();
     234    void updateLegend( const QwtPlotItem * );
    218235
    219236    // Misc
     
    226243
    227244    void updateAxes();
     245    void updateCanvasMargins();
     246
     247    virtual void getCanvasMarginsHint(
     248        const QwtScaleMap maps[], const QRectF &canvasRect,
     249        double &left, double &top, double &right, double &bottom) const;
    228250
    229251    virtual bool event( QEvent * );
     252    virtual bool eventFilter( QObject *, QEvent * );
    230253
    231254    virtual void drawItems( QPainter *, const QRectF &,
    232255        const QwtScaleMap maps[axisCnt] ) const;
    233256
     257    virtual QVariant itemToInfo( QwtPlotItem * ) const;
     258    virtual QwtPlotItem *infoToItem( const QVariant & ) const;
     259
    234260Q_SIGNALS:
    235261    /*!
    236       A signal which is emitted when the user has clicked on
    237       a legend item, which is in QwtLegend::ClickableItem mode.
    238 
    239       \param plotItem Corresponding plot item of the
    240                  selected legend item
    241 
    242       \note clicks are disabled as default
    243       \sa QwtLegend::setItemMode(), QwtLegend::itemMode()
     262      A signal indicating, that an item has been attached/detached
     263
     264      \param plotItem Plot item
     265      \param on Attached/Detached
    244266     */
    245     void legendClicked( QwtPlotItem *plotItem );
     267    void itemAttached( QwtPlotItem *plotItem, bool on );
    246268
    247269    /*!
    248       A signal which is emitted when the user has clicked on
    249       a legend item, which is in QwtLegend::CheckableItem mode
    250 
    251       \param plotItem Corresponding plot item of the
    252                  selected legend item
    253       \param on True when the legen item is checked
    254 
    255       \note clicks are disabled as default
    256       \sa QwtLegend::setItemMode(), QwtLegend::itemMode()
     270      A signal with the attributes how to update
     271      the legend entries for a plot item.
     272
     273      \param itemInfo Info about a plot item, build from itemToInfo()
     274      \param data Attributes of the entries ( usually <= 1 ) for
     275                  the plot item.
     276
     277      \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
    257278     */
    258 
    259     void legendChecked( QwtPlotItem *plotItem, bool on );
     279    void legendDataChanged( const QVariant &itemInfo,
     280        const QList<QwtLegendData> &data );
    260281
    261282public Q_SLOTS:
     
    263284    void autoRefresh();
    264285
    265 protected Q_SLOTS:
    266     virtual void legendItemClicked();
    267     virtual void legendItemChecked( bool );
    268 
    269286protected:
    270287    static bool axisValid( int axisId );
    271288
    272     virtual void updateTabOrder();
    273 
    274289    virtual void resizeEvent( QResizeEvent *e );
    275290
     291private Q_SLOTS:
     292    void updateLegendItems( const QVariant &itemInfo,
     293        const QList<QwtLegendData> &data );
     294
    276295private:
     296    friend class QwtPlotItem;
     297    void attachItem( QwtPlotItem *, bool );
     298
    277299    void initAxesData();
    278300    void deleteAxesData();
Note: See TracChangeset for help on using the changeset viewer.