Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_curve.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_curve.h

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1313#include "qwt_global.h"
    1414#include "qwt_plot_seriesitem.h"
    15 #include "qwt_series_data.h"
    16 #include "qwt_text.h"
    17 #include <qpen.h>
     15
    1816#include <qstring.h>
    1917
    20 class QPainter;
    21 class QPolygonF;
    2218class QwtScaleMap;
    2319class QwtSymbol;
    2420class QwtCurveFitter;
     21template< typename T > class QwtSeriesData;
     22class QwtText;
     23class QPainter;
     24class QPolygonF;
     25class QPen;
    2526
    2627/*!
    27   \brief A plot item, that represents a series of points
    28 
    29   A curve is the representation of a series of points in the x-y plane.
    30   It supports different display styles, interpolation ( f.e. spline )
    31   and symbols.
    32 
    33   \par Usage
    34   <dl><dt>a) Assign curve properties</dt>
    35   <dd>When a curve is created, it is configured to draw black solid lines
    36   with in QwtPlotCurve::Lines style and no symbols.
    37   You can change this by calling
    38   setPen(), setStyle() and setSymbol().</dd>
    39   <dt>b) Connect/Assign data.</dt>
    40   <dd>QwtPlotCurve gets its points using a QwtSeriesData object offering
    41   a bridge to the real storage of the points ( like QAbstractItemModel ).
    42   There are several convenience classes derived from QwtSeriesData, that also store
    43   the points inside ( like QStandardItemModel ). QwtPlotCurve also offers
    44   a couple of variations of setSamples(), that build QwtSeriesData objects from
    45   arrays internally.</dd>
    46   <dt>c) Attach the curve to a plot</dt>
    47   <dd>See QwtPlotItem::attach()
    48   </dd></dl>
    49 
    50   \par Example:
    51   see examples/bode
    52 
    53   \sa QwtPointSeriesData, QwtSymbol, QwtScaleMap
    54 */
    55 class QWT_EXPORT QwtPlotCurve:
    56     public QwtPlotSeriesItem, public QwtSeriesStore<QPointF>
    57 {
    58 public:
     28   \brief A plot item, that represents a series of points
     29
     30   A curve is the representation of a series of points in the x-y plane.
     31   It supports different display styles, interpolation ( f.e. spline )
     32   and symbols.
     33
     34   \par Usage
     35   <dl><dt>a) Assign curve properties</dt>
     36   <dd>When a curve is created, it is configured to draw black solid lines
     37   with in QwtPlotCurve::Lines style and no symbols.
     38   You can change this by calling
     39   setPen(), setStyle() and setSymbol().</dd>
     40   <dt>b) Connect/Assign data.</dt>
     41   <dd>QwtPlotCurve gets its points using a QwtSeriesData object offering
     42   a bridge to the real storage of the points ( like QAbstractItemModel ).
     43   There are several convenience classes derived from QwtSeriesData, that also store
     44   the points inside ( like QStandardItemModel ). QwtPlotCurve also offers
     45   a couple of variations of setSamples(), that build QwtSeriesData objects from
     46   arrays internally.</dd>
     47   <dt>c) Attach the curve to a plot</dt>
     48   <dd>See QwtPlotItem::attach()
     49   </dd></dl>
     50
     51   \par Example:
     52   see examples/bode
     53
     54   \sa QwtPointSeriesData, QwtSymbol, QwtScaleMap
     55 */
     56class QWT_EXPORT QwtPlotCurve
     57    : public QwtPlotSeriesItem
     58    , public QwtSeriesStore< QPointF >
     59{
     60  public:
    5961    /*!
    6062        Curve styles.
    6163        \sa setStyle(), style()
    62     */
     64     */
    6365    enum CurveStyle
    6466    {
    6567        /*!
    6668           Don't draw a curve. Note: This doesn't affect the symbols.
    67         */
     69         */
    6870        NoCurve = -1,
    6971
    … …  
    7274           be interpolated depending on the 'Fitted' attribute. Curve
    7375           fitting can be configured using setCurveFitter().
    74         */
     76         */
    7577        Lines,
    7678
    … …  
    7880           Draw vertical or horizontal sticks ( depending on the
    7981           orientation() ) from a baseline which is defined by setBaseline().
    80         */
     82         */
    8183        Sticks,
    8284
    … …  
    8587           is drawn from the left to the right or vice versa,
    8688           depending on the QwtPlotCurve::Inverted attribute.
    87         */
     89         */
    8890        Steps,
    8991
    … …  
    9395           as a curve in QwtPlotCurve::NoStyle style and a symbol
    9496           painting a point.
    95         */
     97         */
    9698        Dots,
    9799
    … …  
    100102           classes of QwtPlotCurve that overload drawCurve() with
    101103           additional application specific curve types.
    102         */
     104         */
    103105        UserCurve = 100
    104106    };
    105107
    106108    /*!
    107       Attribute for drawing the curve
    108       \sa setCurveAttribute(), testCurveAttribute(), curveFitter()
    109     */
     109       Attribute for drawing the curve
     110       \sa setCurveAttribute(), testCurveAttribute(), curveFitter()
     111     */
    110112    enum CurveAttribute
    111113    {
    … …  
    117119
    118120        /*!
    119           Only in combination with QwtPlotCurve::Lines
    120           A QwtCurveFitter tries to
    121           interpolate/smooth the curve, before it is painted.
    122 
    123           \note Curve fitting requires temporary memory
    124           for calculating coefficients and additional points.
    125           If painting in QwtPlotCurve::Fitted mode is slow it might be better
    126           to fit the points, before they are passed to QwtPlotCurve.
     121           Only in combination with QwtPlotCurve::Lines
     122           A QwtCurveFitter tries to
     123           interpolate/smooth the curve, before it is painted.
     124
     125           \note Curve fitting requires temporary memory
     126           for calculating coefficients and additional points.
     127           If painting in QwtPlotCurve::Fitted mode is slow it might be better
     128           to fit the points, before they are passed to QwtPlotCurve.
    127129         */
    128130        Fitted = 0x02
    129131    };
    130132
    131     //! Curve attributes
    132     typedef QFlags<CurveAttribute> CurveAttributes;
     133    Q_DECLARE_FLAGS( CurveAttributes, CurveAttribute )
    133134
    134135    /*!
    … …  
    142143    {
    143144        /*!
    144           QwtPlotCurve tries to find a color representing the curve
    145           and paints a rectangle with it.
     145           QwtPlotCurve tries to find a color representing the curve
     146           and paints a rectangle with it.
    146147         */
    147148        LegendNoAttribute = 0x00,
    148149
    149150        /*!
    150           If the style() is not QwtPlotCurve::NoCurve a line
    151           is painted with the curve pen().
     151           If the style() is not QwtPlotCurve::NoCurve a line
     152           is painted with the curve pen().
    152153         */
    153154        LegendShowLine = 0x01,
    154155
    155156        /*!
    156           If the curve has a valid symbol it is painted.
     157           If the curve has a valid symbol it is painted.
    157158         */
    158159        LegendShowSymbol = 0x02,
    159160
    160161        /*!
    161           If the curve has a brush a rectangle filled with the
    162           curve brush() is painted.
     162           If the curve has a brush a rectangle filled with the
     163           curve brush() is painted.
    163164         */
    164165        LegendShowBrush = 0x04
    165166    };
    166167
    167     //! Legend attributes
    168     typedef QFlags<LegendAttribute> LegendAttributes;
     168    Q_DECLARE_FLAGS( LegendAttributes, LegendAttribute )
    169169
    170170    /*!
    … …  
    173173
    174174        \sa setPaintAttribute(), testPaintAttribute()
    175     */
     175     */
    176176    enum PaintAttribute
    177177    {
    178178        /*!
    179           Clip polygons before painting them. In situations, where points
    180           are far outside the visible area (f.e when zooming deep) this
    181           might be a substantial improvement for the painting performance
     179           Clip polygons before painting them. In situations, where points
     180           are far outside the visible area (f.e when zooming deep) this
     181           might be a substantial improvement for the painting performance
    182182         */
    183183        ClipPolygons = 0x01,
    184184
    185185        /*!
    186           Tries to reduce the data that has to be painted, by sorting out
    187           duplicates, or paintings outside the visible area. Might have a
    188           notable impact on curves with many close points.
    189           Only a couple of very basic filtering algorithms are implemented.
     186           Tries to reduce the data that has to be painted, by sorting out
     187           duplicates, or paintings outside the visible area. Might have a
     188           notable impact on curves with many close points.
     189           Only a couple of very basic filtering algorithms are implemented.
    190190         */
    191191        FilterPoints = 0x02,
    192192
    193193        /*!
    194           Minimize memory usage that is temporarily needed for the
    195           translated points, before they get painted.
    196           This might slow down the performance of painting
     194           Minimize memory usage that is temporarily needed for the
     195           translated points, before they get painted.
     196           This might slow down the performance of painting
    197197         */
    198198        MinimizeMemory = 0x04,
    199199
    200200        /*!
    201           Render the points to a temporary image and paint the image.
    202           This is a very special optimization for Dots style, when
    203           having a huge amount of points.
    204           With a reasonable number of points QPainter::drawPoints()
    205           will be faster.
    206          */
    207         ImageBuffer = 0x08
     201           Render the points to a temporary image and paint the image.
     202           This is a very special optimization for Dots style, when
     203           having a huge amount of points.
     204           With a reasonable number of points QPainter::drawPoints()
     205           will be faster.
     206         */
     207        ImageBuffer = 0x08,
     208
     209        /*!
     210           More aggressive point filtering trying to filter out
     211           intermediate points, accepting minor visual differences.
     212
     213           Has only an effect, when drawing the curve to a paint device
     214           in integer coordinates ( f.e. all widgets on screen ) using the fact,
     215           that consecutive points are often mapped to the same x or y coordinate.
     216           Each chunk of samples mapped to the same coordinate can be reduced to
     217           4 points ( first, min, max last ).
     218
     219           In the worst case the polygon to be rendered will be 4 times the width
     220           of the plot canvas.
     221
     222           The algorithm is very fast and effective for huge datasets, and can be used
     223           inside a replot cycle.
     224
     225           \note Implemented for QwtPlotCurve::Lines only
     226           \note As this algo replaces many small lines by a long one
     227                a nasty bug of the raster paint engine ( Qt 4.8, Qt 5.1 - 5.3 )
     228                becomes more dominant. For these versions the bug can be
     229                worked around by enabling the QwtPainter::polylineSplitting() mode.
     230         */
     231        FilterPointsAggressive = 0x10,
    208232    };
    209233
    210     //! Paint attributes
    211     typedef QFlags<PaintAttribute> PaintAttributes;
    212 
    213     explicit QwtPlotCurve( const QString &title = QString() );
    214     explicit QwtPlotCurve( const QwtText &title );
     234    Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
     235
     236    explicit QwtPlotCurve( const QString& title = QString() );
     237    explicit QwtPlotCurve( const QwtText& title );
    215238
    216239    virtual ~QwtPlotCurve();
    217240
    218     virtual int rtti() const;
     241    virtual int rtti() const QWT_OVERRIDE;
    219242
    220243    void setPaintAttribute( PaintAttribute, bool on = true );
    … …  
    224247    bool testLegendAttribute( LegendAttribute ) const;
    225248
    226 #ifndef QWT_NO_COMPAT
    227     void setRawSamples( const double *xData, const double *yData, int size );
    228     void setSamples( const double *xData, const double *yData, int size );
    229     void setSamples( const QVector<double> &xData, const QVector<double> &yData );
    230 #endif
    231     void setSamples( const QVector<QPointF> & );
    232     void setSamples( QwtSeriesData<QPointF> * );
    233 
    234     int closestPoint( const QPoint &pos, double *dist = NULL ) const;
     249    void setLegendAttributes( LegendAttributes );
     250    LegendAttributes legendAttributes() const;
     251
     252    void setRawSamples( const double* xData, const double* yData, int size );
     253    void setRawSamples( const float* xData, const float* yData, int size );
     254
     255    void setRawSamples( const double* yData, int size );
     256    void setRawSamples( const float* yData, int size );
     257
     258    void setSamples( const double* xData, const double* yData, int size );
     259    void setSamples( const float* xData, const float* yData, int size );
     260
     261    void setSamples( const double* yData, int size );
     262    void setSamples( const float* yData, int size );
     263
     264    void setSamples( const QVector< double >& yData );
     265    void setSamples( const QVector< float >& yData );
     266
     267    void setSamples( const QVector< double >& xData, const QVector< double >& yData );
     268    void setSamples( const QVector< float >& xData, const QVector< float >& yData );
     269
     270    void setSamples( const QVector< QPointF >& );
     271    void setSamples( QwtSeriesData< QPointF >* );
     272
     273    virtual int closestPoint( const QPointF& pos, double* dist = NULL ) const;
     274    virtual int adjacentPoint( Qt::Orientation orientation, qreal value ) const;
     275
     276    qreal interpolatedValueAt( Qt::Orientation, double ) const;
    235277
    236278    double minXValue() const;
    … …  
    242284    bool testCurveAttribute( CurveAttribute ) const;
    243285
    244     void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
    245     void setPen( const QPen & );
    246     const QPen &pen() const;
    247 
    248     void setBrush( const QBrush & );
    249     const QBrush &brush() const;
     286    void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
     287    void setPen( const QPen& );
     288    const QPen& pen() const;
     289
     290    void setBrush( const QBrush& );
     291    const QBrush& brush() const;
    250292
    251293    void setBaseline( double );
    … …  
    255297    CurveStyle style() const;
    256298
    257     void setSymbol( QwtSymbol * );
    258     const QwtSymbol *symbol() const;
    259 
    260     void setCurveFitter( QwtCurveFitter * );
    261     QwtCurveFitter *curveFitter() const;
    262 
    263     virtual void drawSeries( QPainter *,
    264         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    265         const QRectF &canvasRect, int from, int to ) const;
    266 
    267     virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
    268 
    269 protected:
     299    void setSymbol( QwtSymbol* );
     300    const QwtSymbol* symbol() const;
     301
     302    void setCurveFitter( QwtCurveFitter* );
     303    QwtCurveFitter* curveFitter() const;
     304
     305    virtual void drawSeries( QPainter*,
     306        const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     307        const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
     308
     309    virtual QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE;
     310
     311  protected:
    270312
    271313    void init();
    272314
    273     virtual void drawCurve( QPainter *, int style,
    274         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    275         const QRectF &canvasRect, int from, int to ) const;
    276 
    277     virtual void drawSymbols( QPainter *, const QwtSymbol &,
    278         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    279         const QRectF &canvasRect, int from, int to ) const;
    280 
    281     virtual void drawLines( QPainter *,
    282         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    283         const QRectF &canvasRect, int from, int to ) const;
    284 
    285     virtual void drawSticks( QPainter *,
    286         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    287         const QRectF &canvasRect, int from, int to ) const;
    288 
    289     virtual void drawDots( QPainter *,
    290         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    291         const QRectF &canvasRect, int from, int to ) const;
    292 
    293     virtual void drawSteps( QPainter *,
    294         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    295         const QRectF &canvasRect, int from, int to ) const;
    296 
    297     virtual void fillCurve( QPainter *,
    298         const QwtScaleMap &, const QwtScaleMap &,
    299         const QRectF &canvasRect, QPolygonF & ) const;
    300 
    301     void closePolyline( QPainter *,
    302         const QwtScaleMap &, const QwtScaleMap &, QPolygonF & ) const;
    303 
    304 private:
     315    virtual void drawCurve( QPainter*, int style,
     316        const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     317        const QRectF& canvasRect, int from, int to ) const;
     318
     319    virtual void drawSymbols( QPainter*, const QwtSymbol&,
     320        const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     321        const QRectF& canvasRect, int from, int to ) const;
     322
     323    virtual void drawLines( QPainter*,
     324        const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     325        const QRectF& canvasRect, int from, int to ) const;
     326
     327    virtual void drawSticks( QPainter*,
     328        const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     329        const QRectF& canvasRect, int from, int to ) const;
     330
     331    virtual void drawDots( QPainter*,
     332        const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     333        const QRectF& canvasRect, int from, int to ) const;
     334
     335    virtual void drawSteps( QPainter*,
     336        const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     337        const QRectF& canvasRect, int from, int to ) const;
     338
     339    virtual void fillCurve( QPainter*,
     340        const QwtScaleMap&, const QwtScaleMap&,
     341        const QRectF& canvasRect, QPolygonF& ) const;
     342
     343    void closePolyline( QPainter*,
     344        const QwtScaleMap&, const QwtScaleMap&, QPolygonF& ) const;
     345
     346  private:
    305347    class PrivateData;
    306     PrivateData *d_data;
     348    PrivateData* m_data;
    307349};
    308350
Note: See TracChangeset for help on using the changeset viewer.