LeechCraft 0.6.70-16373-g319c272718
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)
36
37 Q_PROPERTY (double alpha READ GetAlpha WRITE SetAlpha NOTIFY alphaChanged)
38 Q_PROPERTY (QColor color READ GetColor WRITE SetColor NOTIFY colorChanged)
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)
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}
int GetYExtent() const
Definition plotitem.cpp:298
void bottomAxisEnabledChanged()
void SetLeftAxisTitle(const QString &)
Definition plotitem.cpp:238
bool GetYGridEnabled() const
Definition plotitem.cpp:172
QColor GetBackground() const
Definition plotitem.cpp:263
double GetMaxYValue() const
Definition plotitem.cpp:162
double GetAlpha() const
Definition plotitem.cpp:192
void leftAxisTitleChanged()
void SetPlotTitle(const QString &)
Definition plotitem.cpp:258
void SetBottomAxisEnabled(bool)
Definition plotitem.cpp:228
void SetMinYValue(double)
Definition plotitem.cpp:157
double GetMinYValue() const
Definition plotitem.cpp:152
bool GetLeftAxisEnabled() const
Definition plotitem.cpp:213
void SetMaxXValue(double)
Definition plotitem.cpp:147
void SetMinXValue(double)
Definition plotitem.cpp:137
QColor GetColor() const
Definition plotitem.cpp:203
bool GetYMinorGridEnabled() const
Definition plotitem.cpp:182
QString GetLeftAxisTitle() const
Definition plotitem.cpp:233
QList< QPointF > GetPoints() const
Definition plotitem.cpp:35
void SetMaxYValue(double)
Definition plotitem.cpp:167
void SetTextColor(const QColor &)
Definition plotitem.cpp:278
QString GetBottomAxisTitle() const
Definition plotitem.cpp:243
QString GetPlotTitle() const
Definition plotitem.cpp:253
void leftAxisEnabledChanged()
QString leftAxisTitle
Definition plotitem.h:41
void SetBackground(const QColor &)
Definition plotitem.cpp:268
double GetMinXValue() const
Definition plotitem.cpp:132
QVariant multipoints
Definition plotitem.h:27
int GetXExtent() const
Definition plotitem.cpp:293
void SetMultipoints(const QVariant &)
Definition plotitem.cpp:78
QString plotTitle
Definition plotitem.h:44
QString bottomAxisTitle
Definition plotitem.h:42
void SetPoints(const QList< QPointF > &)
Definition plotitem.cpp:40
PlotItem(QQuickItem *=nullptr)
Definition plotitem.cpp:28
bool GetBottomAxisEnabled() const
Definition plotitem.cpp:223
QColor GetGridLinesColor() const
Definition plotitem.cpp:283
void SetLeftAxisEnabled(bool)
Definition plotitem.cpp:218
void SetBottomAxisTitle(const QString &)
Definition plotitem.cpp:248
QColor GetTextColor() const
Definition plotitem.cpp:273
QList< QPointF > points
Definition plotitem.h:25
void gridLinesColorChanged()
void SetGridLinesColor(const QColor &)
Definition plotitem.cpp:288
void SetYMinorGridEnabled(bool)
Definition plotitem.cpp:187
QColor gridLinesColor
Definition plotitem.h:48
QVariant GetMultipoints() const
Definition plotitem.cpp:50
void SetColor(const QColor &)
Definition plotitem.cpp:208
double GetMaxXValue() const
Definition plotitem.cpp:142
void bottomAxisTitleChanged()
void SetAlpha(double)
Definition plotitem.cpp:197
void SetYGridEnabled(bool)
Definition plotitem.cpp:177
#define UTIL_QML_API
Definition qmlconfig.h:16