QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
qwt_plot_curve.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *
9 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in
25 *src-amalgamate.
26 *****************************************************************************/
27
28#ifndef QWT_PLOT_CURVE_H
29#define QWT_PLOT_CURVE_H
30
31#include "qwt_global.h"
32#include "qwt_plot_seriesitem.h"
33
34#include <qstring.h>
35
36class QwtScaleMap;
37class QwtSymbol;
38class QwtCurveFitter;
39template< typename T >
40class QwtSeriesData;
41class QwtText;
42class QPainter;
43class QPolygonF;
44class QPen;
45
74class QWT_EXPORT QwtPlotCurve : public QwtPlotSeriesItem, public QwtSeriesStore< QPointF >
75{
76public:
82 {
86 NoCurve = -1,
87
94
100
107
115
121 UserCurve = 100
122 };
123
129 {
134 Inverted = 0x01,
135
146 Fitted = 0x02,
147
177 BreakAtNan = 0x04
178 };
179
180 Q_DECLARE_FLAGS(CurveAttributes, CurveAttribute)
181
182
189 {
194 LegendNoAttribute = 0x00,
195
200 LegendShowLine = 0x01,
201
205 LegendShowSymbol = 0x02,
206
211 LegendShowBrush = 0x04
212 };
213
214 Q_DECLARE_FLAGS(LegendAttributes, LegendAttribute)
215
216
222 {
228 ClipPolygons = 0x01,
229
236 FilterPoints = 0x02,
237
243 MinimizeMemory = 0x04,
244
252 ImageBuffer = 0x08,
253
281 FilterPointsAggressive = 0x10,
282
308 FilterPointsPixel = 0x20,
309
327 FilterPointsLTTB = 0x40,
328
346 FilterPointsMinMaxLTTB = 0x80,
347
378 FilterPointsAdaptive = 0x100,
379 };
380
381 Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute)
382
383
403 {
405 NoSmoothing = 0,
406
409
414 SavitzkyGolaySmoothing
415 };
416
417 // Constructor
418 explicit QwtPlotCurve(const QString& title = QString());
419
420 // Constructor with QwtText title
421 explicit QwtPlotCurve(const QwtText& title);
422
423 // Destructor
424 ~QwtPlotCurve() override;
425
426 // Get the runtime type information
427 virtual int rtti() const override;
428
429 // Attach the curve to a plot (applies color cycle if pen not user-set)
430 void attach(QwtPlot* plot) override;
431
432 // Set paint attribute
433 void setPaintAttribute(PaintAttribute, bool on = true);
434
435 // Test paint attribute
436 bool testPaintAttribute(PaintAttribute) const;
437
438 // Set legend attribute
439 void setLegendAttribute(LegendAttribute, bool on = true);
440
441 // Test legend attribute
442 bool testLegendAttribute(LegendAttribute) const;
443
444 // Set legend attributes
445 void setLegendAttributes(LegendAttributes);
446
447 // Get legend attributes
448 LegendAttributes legendAttributes() const;
449
450 // Set raw samples from double arrays
451 void setRawSamples(const double* xData, const double* yData, int size);
452
453 // Set raw samples from float arrays
454 void setRawSamples(const float* xData, const float* yData, int size);
455
456 // Set raw samples from double array (y-axis only)
457 void setRawSamples(const double* yData, int size);
458
459 // Set raw samples from float array (y-axis only)
460 void setRawSamples(const float* yData, int size);
461
462 // Set samples from double arrays
463 void setSamples(const double* xData, const double* yData, int size);
464
465 // Set samples from float arrays
466 void setSamples(const float* xData, const float* yData, int size);
467
468 // Set samples from double array (y-axis only)
469 void setSamples(const double* yData, int size);
470
471 // Set samples from float array (y-axis only)
472 void setSamples(const float* yData, int size);
473
474 // Set samples from QVector<double> (y-axis only)
475 void setSamples(const QVector< double >& yData);
476
477 // Set samples from QVector<float> (y-axis only)
478 void setSamples(const QVector< float >& yData);
479
480 // Set samples from QVector<double> arrays
481 void setSamples(const QVector< double >& xData, const QVector< double >& yData);
482
483 // Set samples from QVector<float> arrays
484 void setSamples(const QVector< float >& xData, const QVector< float >& yData);
485
486 // Set samples from rvalue QVector<double> arrays
487 void setSamples(QVector< double >&& xData, QVector< double >&& yData);
488
489 // Set samples from rvalue QVector<float> arrays
490 void setSamples(QVector< float >&& xData, QVector< float >&& yData);
491
492 // Set samples from rvalue QVector<QPointF>
493 void setSamples(QVector< QPointF >&&);
494
495 // Set samples from QVector<QPointF>
496 void setSamples(const QVector< QPointF >&);
497
498 // Set samples from QwtSeriesData
499 void setSamples(QwtSeriesData< QPointF >*);
500
501 // Find the closest point to a position
502 virtual int closestPoint(const QPointF& pos, double* dist = nullptr) const;
503
504 // Get minimum x value
505 double minXValue() const;
506
507 // Get maximum x value
508 double maxXValue() const;
509
510 // Get minimum y value
511 double minYValue() const;
512
513 // Get maximum y value
514 double maxYValue() const;
515
516 // Set curve attribute
517 void setCurveAttribute(CurveAttribute, bool on = true);
518
519 // Test curve attribute
520 bool testCurveAttribute(CurveAttribute) const;
521
522 // Set pen
523 void setPen(const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine);
524
525 // Set pen
526 void setPen(const QPen&);
527
528 // Get pen
529 const QPen& pen() const;
530
531 // Set brush
532 void setBrush(const QBrush&);
533
534 // Get brush
535 const QBrush& brush() const;
536
537 // Set baseline
538 void setBaseline(double);
539
540 // Get baseline
541 double baseline() const;
542
543 // Set curve style
544 void setStyle(CurveStyle style);
545
546 // Get curve style
547 CurveStyle style() const;
548
549 // Set symbol
550 void setSymbol(QwtSymbol*);
551
552 // Get symbol
553 const QwtSymbol* symbol() const;
554
555 // Set curve fitter
556 void setCurveFitter(QwtCurveFitter*);
557
558 // Get curve fitter
559 QwtCurveFitter* curveFitter() const;
560
561 // Set the render smoothing algorithm
562 void setSmoothAlgorithm(SmoothAlgorithm);
563
564 // Get the render smoothing algorithm
565 SmoothAlgorithm smoothAlgorithm() const;
566
567 // Set the smoothing window ( number of polyline points, odd values >= 3 )
568 void setSmoothWindow(int numPoints);
569
570 // Get the smoothing window
571 int smoothWindow() const;
572
573 // Set the polynomial order for SavitzkyGolaySmoothing
574 void setSmoothPolynomialOrder(int order);
575
576 // Get the polynomial order for SavitzkyGolaySmoothing
577 int smoothPolynomialOrder() const;
578
579 // Set the feature preservation threshold of the render smoothing
580 void setSmoothPreserveThreshold(double threshold);
581
582 // Get the feature preservation threshold of the render smoothing
583 double smoothPreserveThreshold() const;
584
585 // Draw the series
586 virtual void drawSeries(QPainter*,
587 const QwtScaleMap& xMap,
588 const QwtScaleMap& yMap,
589 const QRectF& canvasRect,
590 int from,
591 int to) const override;
592
593 // Get the legend icon
594 virtual QwtGraphic legendIcon(int index, const QSizeF&) const override;
595
596protected:
598 virtual void dataChanged() override;
599
601 void init();
602
604 virtual void drawCurve(QPainter*,
605 int style,
606 const QwtScaleMap& xMap,
607 const QwtScaleMap& yMap,
608 const QRectF& canvasRect,
609 int from,
610 int to) const;
611
613 virtual void drawSymbols(QPainter*,
614 const QwtSymbol&,
615 const QwtScaleMap& xMap,
616 const QwtScaleMap& yMap,
617 const QRectF& canvasRect,
618 int from,
619 int to) const;
620
622 virtual void
623 drawLines(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const;
624
626 virtual void
627 drawSticks(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const;
628
630 virtual void
631 drawDots(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const;
632
634 virtual void
635 drawSteps(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const;
636
638 virtual void fillCurve(QPainter*, const QwtScaleMap&, const QwtScaleMap&, const QRectF& canvasRect, QPolygonF&) const;
639
641 void closePolyline(QPainter*, const QwtScaleMap&, const QwtScaleMap&, QPolygonF&) const;
642
643private:
644 QWT_DECLARE_PRIVATE(QwtPlotCurve)
645};
646
648inline double QwtPlotCurve::minXValue() const
649{
650 return boundingRect().left();
651}
652
654inline double QwtPlotCurve::maxXValue() const
655{
656 return boundingRect().right();
657}
658
660inline double QwtPlotCurve::minYValue() const
661{
662 return boundingRect().top();
663}
664
666inline double QwtPlotCurve::maxYValue() const
667{
668 return boundingRect().bottom();
669}
670
671Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCurve::PaintAttributes)
672Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCurve::LegendAttributes)
673Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCurve::CurveAttributes)
674
675#endif
Abstract base class for curve fitting algorithms.
Definition qwt_curve_fitter.h:39
A paint device for scalable graphics.
Definition qwt_graphic.h:85
A plot item, that represents a series of points.
Definition qwt_plot_curve.h:75
CurveStyle
Curve styles.
Definition qwt_plot_curve.h:82
@ Steps
Definition qwt_plot_curve.h:106
@ Sticks
Definition qwt_plot_curve.h:99
@ Lines
Definition qwt_plot_curve.h:93
@ Dots
Definition qwt_plot_curve.h:114
double minXValue() const
boundingRect().left()
Definition qwt_plot_curve.h:648
CurveAttribute
Attribute for drawing the curve.
Definition qwt_plot_curve.h:129
double maxXValue() const
boundingRect().right()
Definition qwt_plot_curve.h:654
LegendAttribute
Attributes how to represent the curve on the legend.
Definition qwt_plot_curve.h:189
double minYValue() const
boundingRect().top()
Definition qwt_plot_curve.h:660
PaintAttribute
Attributes to modify the drawing algorithm.
Definition qwt_plot_curve.h:222
double maxYValue() const
boundingRect().bottom()
Definition qwt_plot_curve.h:666
SmoothAlgorithm
Algorithm for smoothing the rendered polyline.
Definition qwt_plot_curve.h:403
@ GaussianSmoothing
Gaussian weighted moving window: strong noise suppression.
Definition qwt_plot_curve.h:408
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
Return a legend icon.
Definition qwt_plot_item.cpp:420
virtual int rtti() const
Runtime type information.
Definition qwt_plot_item.cpp:155
virtual void attach(QwtPlot *plot)
Attach the item to a plot.
Definition qwt_plot_item.cpp:118
Base class for plot items representing a series of samples.
Definition qwt_plot_seriesitem.h:44
virtual void dataChanged() override
dataChanged() indicates, that the series has been changed.
Definition qwt_plot_seriesitem.cpp:131
virtual QRectF boundingRect() const override
Get the bounding rectangle.
Definition qwt_plot_seriesitem.cpp:114
virtual void drawSeries(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const =0
Draw a subset of the samples.
A 2-D plotting widget.
Definition qwt_plot.h:100
A scale map.
Definition qwt_scale_map.h:44
Abstract interface for iterating over samples.
Definition qwt_series_data.h:88
Class storing a QwtSeriesData object.
Definition qwt_series_store.h:91
A class for drawing symbols.
Definition qwt_symbol.h:51
A class representing a text.
Definition qwt_text.h:70