QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
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 };
148
149 Q_DECLARE_FLAGS(CurveAttributes, CurveAttribute)
150
151
158 {
163 LegendNoAttribute = 0x00,
164
169 LegendShowLine = 0x01,
170
174 LegendShowSymbol = 0x02,
175
180 LegendShowBrush = 0x04
181 };
182
183 Q_DECLARE_FLAGS(LegendAttributes, LegendAttribute)
184
185
191 {
197 ClipPolygons = 0x01,
198
205 FilterPoints = 0x02,
206
212 MinimizeMemory = 0x04,
213
221 ImageBuffer = 0x08,
222
245 FilterPointsAggressive = 0x10,
246
260 FilterPointsPixel = 0x20,
261
276 FilterPointsLTTB = 0x40,
277 };
278
279 Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute)
280
281 // Constructor
282 explicit QwtPlotCurve(const QString& title = QString());
283
284 // Constructor with QwtText title
285 explicit QwtPlotCurve(const QwtText& title);
286
287 // Destructor
288 ~QwtPlotCurve() override;
289
290 // Get the runtime type information
291 virtual int rtti() const override;
292
293 // Attach the curve to a plot (applies color cycle if pen not user-set)
294 void attach(QwtPlot* plot) override;
295
296 // Set paint attribute
297 void setPaintAttribute(PaintAttribute, bool on = true);
298
299 // Test paint attribute
300 bool testPaintAttribute(PaintAttribute) const;
301
302 // Set legend attribute
303 void setLegendAttribute(LegendAttribute, bool on = true);
304
305 // Test legend attribute
306 bool testLegendAttribute(LegendAttribute) const;
307
308 // Set legend attributes
309 void setLegendAttributes(LegendAttributes);
310
311 // Get legend attributes
312 LegendAttributes legendAttributes() const;
313
314 // Set raw samples from double arrays
315 void setRawSamples(const double* xData, const double* yData, int size);
316
317 // Set raw samples from float arrays
318 void setRawSamples(const float* xData, const float* yData, int size);
319
320 // Set raw samples from double array (y-axis only)
321 void setRawSamples(const double* yData, int size);
322
323 // Set raw samples from float array (y-axis only)
324 void setRawSamples(const float* yData, int size);
325
326 // Set samples from double arrays
327 void setSamples(const double* xData, const double* yData, int size);
328
329 // Set samples from float arrays
330 void setSamples(const float* xData, const float* yData, int size);
331
332 // Set samples from double array (y-axis only)
333 void setSamples(const double* yData, int size);
334
335 // Set samples from float array (y-axis only)
336 void setSamples(const float* yData, int size);
337
338 // Set samples from QVector<double> (y-axis only)
339 void setSamples(const QVector< double >& yData);
340
341 // Set samples from QVector<float> (y-axis only)
342 void setSamples(const QVector< float >& yData);
343
344 // Set samples from QVector<double> arrays
345 void setSamples(const QVector< double >& xData, const QVector< double >& yData);
346
347 // Set samples from QVector<float> arrays
348 void setSamples(const QVector< float >& xData, const QVector< float >& yData);
349
350 // Set samples from rvalue QVector<double> arrays
351 void setSamples(QVector< double >&& xData, QVector< double >&& yData);
352
353 // Set samples from rvalue QVector<float> arrays
354 void setSamples(QVector< float >&& xData, QVector< float >&& yData);
355
356 // Set samples from rvalue QVector<QPointF>
357 void setSamples(QVector< QPointF >&&);
358
359 // Set samples from QVector<QPointF>
360 void setSamples(const QVector< QPointF >&);
361
362 // Set samples from QwtSeriesData
363 void setSamples(QwtSeriesData< QPointF >*);
364
365 // Find the closest point to a position
366 virtual int closestPoint(const QPointF& pos, double* dist = nullptr) const;
367
368 // Get minimum x value
369 double minXValue() const;
370
371 // Get maximum x value
372 double maxXValue() const;
373
374 // Get minimum y value
375 double minYValue() const;
376
377 // Get maximum y value
378 double maxYValue() const;
379
380 // Set curve attribute
381 void setCurveAttribute(CurveAttribute, bool on = true);
382
383 // Test curve attribute
384 bool testCurveAttribute(CurveAttribute) const;
385
386 // Set pen
387 void setPen(const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine);
388
389 // Set pen
390 void setPen(const QPen&);
391
392 // Get pen
393 const QPen& pen() const;
394
395 // Set brush
396 void setBrush(const QBrush&);
397
398 // Get brush
399 const QBrush& brush() const;
400
401 // Set baseline
402 void setBaseline(double);
403
404 // Get baseline
405 double baseline() const;
406
407 // Set curve style
408 void setStyle(CurveStyle style);
409
410 // Get curve style
411 CurveStyle style() const;
412
413 // Set symbol
414 void setSymbol(QwtSymbol*);
415
416 // Get symbol
417 const QwtSymbol* symbol() const;
418
419 // Set curve fitter
420 void setCurveFitter(QwtCurveFitter*);
421
422 // Get curve fitter
423 QwtCurveFitter* curveFitter() const;
424
425 // Draw the series
426 virtual void drawSeries(QPainter*,
427 const QwtScaleMap& xMap,
428 const QwtScaleMap& yMap,
429 const QRectF& canvasRect,
430 int from,
431 int to) const override;
432
433 // Get the legend icon
434 virtual QwtGraphic legendIcon(int index, const QSizeF&) const override;
435
436protected:
438 void init();
439
441 virtual void drawCurve(QPainter*,
442 int style,
443 const QwtScaleMap& xMap,
444 const QwtScaleMap& yMap,
445 const QRectF& canvasRect,
446 int from,
447 int to) const;
448
450 virtual void drawSymbols(QPainter*,
451 const QwtSymbol&,
452 const QwtScaleMap& xMap,
453 const QwtScaleMap& yMap,
454 const QRectF& canvasRect,
455 int from,
456 int to) const;
457
459 virtual void
460 drawLines(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const;
461
463 virtual void
464 drawSticks(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const;
465
467 virtual void
468 drawDots(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const;
469
471 virtual void
472 drawSteps(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const;
473
475 virtual void fillCurve(QPainter*, const QwtScaleMap&, const QwtScaleMap&, const QRectF& canvasRect, QPolygonF&) const;
476
478 void closePolyline(QPainter*, const QwtScaleMap&, const QwtScaleMap&, QPolygonF&) const;
479
480private:
481 QWT_DECLARE_PRIVATE(QwtPlotCurve)
482};
483
485inline double QwtPlotCurve::minXValue() const
486{
487 return boundingRect().left();
488}
489
491inline double QwtPlotCurve::maxXValue() const
492{
493 return boundingRect().right();
494}
495
497inline double QwtPlotCurve::minYValue() const
498{
499 return boundingRect().top();
500}
501
503inline double QwtPlotCurve::maxYValue() const
504{
505 return boundingRect().bottom();
506}
507
508Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCurve::PaintAttributes)
509Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCurve::LegendAttributes)
510Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCurve::CurveAttributes)
511
512#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:485
CurveAttribute
Attribute for drawing the curve
Definition qwt_plot_curve.h:129
double maxXValue() const
boundingRect().right()
Definition qwt_plot_curve.h:491
LegendAttribute
Attributes how to represent the curve on the legend
Definition qwt_plot_curve.h:158
double minYValue() const
boundingRect().top()
Definition qwt_plot_curve.h:497
PaintAttribute
Attributes to modify the drawing algorithm
Definition qwt_plot_curve.h:191
double maxYValue() const
boundingRect().bottom()
Definition qwt_plot_curve.h:503
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 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:99
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