LeechCraft 0.6.70-14794-g33744ae6ce
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
plotitem.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <memory>
12#include <optional>
13#include <QtGlobal>
14#include <QQuickPaintedItem>
15#include "qmlconfig.h"
16
17class QwtPlot;
18
19namespace LC::Util
20{
21 class UTIL_QML_API PlotItem : public QQuickPaintedItem
22 {
23 Q_OBJECT
24
25 Q_PROPERTY (QList<QPointF> points READ GetPoints WRITE SetPoints NOTIFY pointsChanged)
26
27 Q_PROPERTY (QVariant multipoints READ GetMultipoints WRITE SetMultipoints NOTIFY multipointsChanged)
28
29 Q_PROPERTY (double minXValue READ GetMinXValue WRITE SetMinXValue NOTIFY minXValueChanged)
30 Q_PROPERTY (double maxXValue READ GetMaxXValue WRITE SetMaxXValue NOTIFY maxXValueChanged)
31 Q_PROPERTY (double minYValue READ GetMinYValue WRITE SetMinYValue NOTIFY minYValueChanged)
32 Q_PROPERTY (double maxYValue READ GetMaxYValue WRITE SetMaxYValue NOTIFY maxYValueChanged)
33
34 Q_PROPERTY (bool yGridEnabled READ GetYGridEnabled WRITE SetYGridEnabled NOTIFY yGridChanged)
35 Q_PROPERTY (bool yMinorGridEnabled READ GetYMinorGridEnabled WRITE SetYMinorGridEnabled NOTIFY yMinorGridChanged)
36
37 Q_PROPERTY (double alpha READ GetAlpha WRITE SetAlpha NOTIFY alphaChanged)
38 Q_PROPERTY (QColor color READ GetColor WRITE SetColor NOTIFY colorChanged)
39 Q_PROPERTY (bool leftAxisEnabled READ GetLeftAxisEnabled WRITE SetLeftAxisEnabled NOTIFY leftAxisEnabledChanged)
40 Q_PROPERTY (bool bottomAxisEnabled READ GetBottomAxisEnabled WRITE SetBottomAxisEnabled NOTIFY bottomAxisEnabledChanged)
41 Q_PROPERTY (QString leftAxisTitle READ GetLeftAxisTitle WRITE SetLeftAxisTitle NOTIFY leftAxisTitleChanged)
42 Q_PROPERTY (QString bottomAxisTitle READ GetBottomAxisTitle WRITE SetBottomAxisTitle NOTIFY bottomAxisTitleChanged)
43
44 Q_PROPERTY (QString plotTitle READ GetPlotTitle WRITE SetPlotTitle NOTIFY plotTitleChanged)
45
46 Q_PROPERTY (QColor background READ GetBackground WRITE SetBackground NOTIFY backgroundChanged)
47 Q_PROPERTY (QColor textColor READ GetTextColor WRITE SetTextColor NOTIFY textColorChanged)
48 Q_PROPERTY (QColor gridLinesColor READ GetGridLinesColor WRITE SetGridLinesColor NOTIFY gridLinesColorChanged)
49
50 Q_PROPERTY (int xExtent READ GetXExtent NOTIFY extentsChanged)
51 Q_PROPERTY (int yExtent READ GetYExtent NOTIFY extentsChanged)
52
53 QList<QPointF> Points_;
54
55 struct PointsSet
56 {
57 QColor Color_;
58 std::optional<QColor> BrushColor_;
59 QList<QPointF> Points_;
60 };
61 QList<PointsSet> Multipoints_;
62
63 double MinXValue_ = -1;
64 double MaxXValue_ = -1;
65 double MinYValue_ = -1;
66 double MaxYValue_ = -1;
67
68 bool YGridEnabled_ = false;
69 bool YMinorGridEnabled_ = false;
70
71 double Alpha_ = 0.3;
72
73 QColor Color_;
74
75 bool LeftAxisEnabled_ = false;
76 bool BottomAxisEnabled_ = false;
77
78 QString LeftAxisTitle_;
79 QString BottomAxisTitle_;
80
81 QString PlotTitle_;
82
83 QColor BackgroundColor_;
84 QColor TextColor_;
85 QColor GridLinesColor_;
86
87 int XExtent_ = 0;
88 int YExtent_ = 0;
89
90 std::shared_ptr<QwtPlot> Plot_;
91 public:
92 explicit PlotItem (QQuickItem* = nullptr);
93
94 QList<QPointF> GetPoints () const;
95 void SetPoints (const QList<QPointF>&);
96
97 QVariant GetMultipoints () const;
98 void SetMultipoints (const QVariant&);
99
100 double GetMinXValue () const;
101 void SetMinXValue (double);
102 double GetMaxXValue () const;
103 void SetMaxXValue (double);
104 double GetMinYValue () const;
105 void SetMinYValue (double);
106 double GetMaxYValue () const;
107 void SetMaxYValue (double);
108
109 bool GetYGridEnabled () const;
110 void SetYGridEnabled (bool);
111 bool GetYMinorGridEnabled () const;
112 void SetYMinorGridEnabled (bool);
113
114 double GetAlpha () const;
115 void SetAlpha (double);
116
117 QColor GetColor () const;
118 void SetColor (const QColor&);
119
120 bool GetLeftAxisEnabled () const;
121 void SetLeftAxisEnabled (bool);
122 bool GetBottomAxisEnabled () const;
123 void SetBottomAxisEnabled (bool);
124
125 QString GetLeftAxisTitle () const;
126 void SetLeftAxisTitle (const QString&);
127 QString GetBottomAxisTitle () const;
128 void SetBottomAxisTitle (const QString&);
129
130 QString GetPlotTitle () const;
131 void SetPlotTitle (const QString&);
132
133 QColor GetBackground () const;
134 void SetBackground (const QColor&);
135 QColor GetTextColor () const;
136 void SetTextColor (const QColor&);
137 QColor GetGridLinesColor () const;
138 void SetGridLinesColor (const QColor&);
139
140 int GetXExtent () const;
141 int GetYExtent () const;
142
143 void paint (QPainter*) override;
144 private:
145 template<typename T, typename Notifier>
146 void SetNewValue (T val, T& ourVal, Notifier&& notifier);
147
148 int CalcXExtent (QwtPlot&) const;
149 int CalcYExtent (QwtPlot&) const;
150 signals:
153
158
161
163
165
168
171
173
177
179 };
180}
void bottomAxisEnabledChanged()
void leftAxisTitleChanged()
void leftAxisEnabledChanged()
void gridLinesColorChanged()
void bottomAxisTitleChanged()
#define UTIL_QML_API
Definition: qmlconfig.h:16