blob: 3354619d269c2b147daa8f1a0f902a9cc14285c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#pragma once
#include <QQuickPaintedItem>
#include <qcustomplot.h>
//class QCustomPlot;
//class QCPAbstractPlottable;
//class QCPItemPixmap;
//class QCPGraph;
using Points2D = QVector<QVector2D>;
class QmlCustomPlot : public QQuickPaintedItem
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QCustomPlot* plot READ plot WRITE setPlot NOTIFY plotChanged)
Q_PROPERTY(int fps READ fps WRITE setFps NOTIFY fpsChanged)
public:
QmlCustomPlot(QQuickItem* parent = nullptr);
~QmlCustomPlot() Q_DECL_OVERRIDE;
void paint(QPainter* painter) Q_DECL_OVERRIDE;
Q_INVOKABLE void initCustomPlot();
public:
QCustomPlot* plot() const;
int fps() const;
public slots:
void setPlot(QCustomPlot *plot);
void setPoints(const QVector<QVector2D> points);
void setLines(const QVector<QLineF> lines);
void setContours(const QVector<Points2D> contours);
void setFps(int fps);
void setRange(const QRectF &range);
signals:
void plotChanged();
void fpsChanged();
protected:
void routeMouseEvents(QMouseEvent* event);
void routeWheelEvents(QWheelEvent* event);
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mouseDoubleClickEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent *event) override;
void timerEvent(QTimerEvent *event) override;
private:
QCustomPlot* m_plot = nullptr;
int m_timerId;
QCPItemPixmap* m_bg = nullptr;
int m_fps = 0;
int m_fpsCounter = 0;
QCPGraph * m_profileGraph = nullptr;
QVector<QCPGraph *> m_contourGraphs;
QVector<QCPItemLine *> m_lineItems;
private slots:
void graphClicked(QCPAbstractPlottable * plottable);
void onCustomReplot();
void updateCustomPlotSize();
};
//Q_DECLARE_METATYPE(QCustomPlot)
|