├── .gitignore
├── EEIoT
├── Knob.png
├── Knob.qml
├── Linear.png
├── Linear.qml
├── WaterLevel.png
├── WaterLevel.qml
└── qmldir
├── LICENSE
├── README.md
├── com_indeema_EEIoT.qrc
├── com_indeema_eeiot.pri
└── qpm.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Compiled Dynamic libraries
15 | *.so
16 | *.dylib
17 | *.dll
18 |
19 | # Fortran module files
20 | *.mod
21 | *.smod
22 |
23 | # Compiled Static libraries
24 | *.lai
25 | *.la
26 | *.a
27 | *.lib
28 |
29 | # Executables
30 | *.exe
31 | *.out
32 | *.app
33 |
--------------------------------------------------------------------------------
/EEIoT/Knob.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IndeemaSoftware/EEIoT/e54597fa665b07a1ecb5a4b41a1ac9e7d1bfbc0e/EEIoT/Knob.png
--------------------------------------------------------------------------------
/EEIoT/Knob.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 |
3 | //all the automatic meagurements are made from height of Item
4 | Item {
5 | id: knob
6 | transformOrigin: Item.Center
7 |
8 | property var metaData : ["from", "to", "value",
9 | "reverse",
10 | "fromAngle", "toAngle",
11 | "lineWidth", "fontSize",
12 | "knobBackgroundColor", "knobColor",
13 | "title", "titleFont", "titleFontSize", "titleFontColor"]
14 |
15 | //value parameters
16 | property double from:0
17 | property double value: 1
18 | property double to: 100
19 |
20 | //progress from right to left
21 | property bool reverse: false
22 |
23 | //progress circle angle
24 | property double fromAngle: Math.PI - 1
25 | property double toAngle: Math.PI *2 + 1
26 |
27 | property int lineWidth: height / 10
28 | property int fontSize: height / 7
29 |
30 | property color knobBackgroundColor: Qt.rgba(0.1, 0.1, 0.1, 0.1)
31 | property color knobColor: Qt.rgba(1, 0, 0, 1)
32 |
33 | property string title: ""
34 | property alias titleFont: labelTitle.font.family
35 | property alias titleFontSize: labelTitle.font.pointSize
36 | property alias titleFontColor: labelTitle.color
37 |
38 | function update(value) {
39 | knob.value = value
40 | canvas.requestPaint()
41 | background.requestPaint()
42 | label.text = value.toFixed(2);
43 | }
44 |
45 | Text {
46 | id: labelTitle
47 | y: 0
48 | text: knob.title
49 | color: Qt.rgba(0, 0, 0., 0.5)
50 | horizontalAlignment: Text.AlignHCenter
51 | anchors.horizontalCenter: parent.horizontalCenter
52 | }
53 |
54 | Canvas {
55 | id: background
56 | width: parent.height
57 | height: parent.height
58 | antialiasing: true
59 |
60 | property int radius: background.width/2
61 |
62 | onPaint: {
63 |
64 | if (knob.title !== "") {
65 | background.y = labelTitle.height
66 | background.x = labelTitle.height/2
67 | background.height = parent.height - labelTitle.height/2
68 | background.width = parent.height - labelTitle.height/2
69 | background.radius = background.height /2
70 | }
71 |
72 | var centreX = background.width / 2.0;
73 | var centreY = background.height / 2.0;
74 |
75 | var ctx = background.getContext('2d');
76 | ctx.strokeStyle = knob.knobBackgroundColor;
77 | ctx.lineWidth = knob.lineWidth;
78 | ctx.lineCap = "round"
79 | ctx.beginPath();
80 | ctx.clearRect(0, 0, background.width, background.height);
81 | ctx.arc(centreX, centreY, radius - knob.lineWidth, knob.fromAngle, knob.toAngle, false);
82 | ctx.stroke();
83 | }
84 | }
85 |
86 | Canvas {
87 | id:canvas
88 | width: parent.height
89 | height: parent.height
90 | antialiasing: true
91 |
92 | property double step: knob.value / (knob.to - knob.from) * (knob.toAngle - knob.fromAngle)
93 | property int radius: height/2
94 |
95 | Text {
96 | id: label
97 | width: 40
98 | height: 12
99 | font.bold: true
100 | z: 1
101 | font.pointSize: knob.fontSize
102 | text: knob.value.toFixed(2)
103 | horizontalAlignment: Text.AlignHCenter
104 | verticalAlignment: Text.AlignVCenter
105 | anchors.fill: parent
106 | }
107 |
108 | onPaint: {
109 |
110 | if (knob.title !== "") {
111 | canvas.y = labelTitle.height
112 | canvas.x = labelTitle.height/2
113 | canvas.height = parent.height - labelTitle.height/2
114 | canvas.width = parent.height - labelTitle.height/2
115 | canvas.radius = canvas.height /2
116 | }
117 |
118 | var centreX = canvas.width / 2.0;
119 | var centreY = canvas.height / 2.0;
120 |
121 | var ctx = canvas.getContext('2d');
122 | ctx.strokeStyle = knob.knobColor;
123 | ctx.lineWidth = knob.lineWidth;
124 | ctx.lineCap = "round"
125 | ctx.beginPath();
126 | ctx.clearRect(0, 0, canvas.width, canvas.height);
127 | if (knob.reverse) {
128 | ctx.arc(centreX, centreY, radius - knob.lineWidth, knob.toAngle, knob.toAngle - step, true);
129 | } else {
130 | ctx.arc(centreX, centreY, radius - knob.lineWidth, knob.fromAngle, knob.fromAngle + step, false);
131 | }
132 | ctx.stroke();
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/EEIoT/Linear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IndeemaSoftware/EEIoT/e54597fa665b07a1ecb5a4b41a1ac9e7d1bfbc0e/EEIoT/Linear.png
--------------------------------------------------------------------------------
/EEIoT/Linear.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 |
3 | Item {
4 | id: linear
5 |
6 | property var metaData : ["from", "to", "value",
7 | "labelFont",
8 | "scaleColor",
9 | "warningStart", "dangerStart",
10 | "okColor", "warningColor", "dengerColor",
11 | "okBackColor", "warningColor", "warningBackColor", "dangerBackColor",
12 | "fontSize", "labelFontSize", "labelFontColor",
13 | "barWidth", "barShift", "pointerSize",
14 | "scaleNum",
15 | "startX", "startY", "shift",
16 | "title", "titleFont", "titleFontSize", "titleFontColor"]
17 |
18 | property double from: 0
19 | property double value: 1
20 | property double to: 100
21 |
22 | property alias labelFont: label.font
23 | property alias labelFontSize: label.font.pointSize
24 | property alias labelFontColor: label.color
25 |
26 | property color scaleColor: "black"
27 |
28 | property double warningStart: 80
29 | property double dangerStart: 90
30 |
31 | property color okColor: "green"
32 | property color warningColor: "yellow"
33 | property color dengerColor: "red"
34 |
35 | property color okBackColor: Qt.rgba(0, 1, 0, 0.2);
36 | property color warningBackColor: Qt.rgba(0.5, 0.5, 0, 0.2);
37 | property color dangerBackColor: Qt.rgba(1, 0, 0, 0.2);
38 |
39 | property int fontSize: 10
40 |
41 | property double barWidth: 20
42 | property double barShift: 10
43 | property double pointerSize: 5
44 |
45 | property int scaleNum: 4
46 |
47 | readonly property int startX: width / 4
48 | readonly property int startY: 10
49 | readonly property double shift: 70
50 |
51 | property string title: ""
52 | property alias titleFont: labelTitle.font.family
53 | property alias titleFontSize: labelTitle.font.pointSize
54 | property alias titleFontColor: labelTitle.color
55 |
56 | function update(value) {
57 | linear.value = value
58 | canvas.requestPaint()
59 | background.requestPaint();
60 | label.text = value.toFixed(2);
61 | label.y = background.y + background.height + (value / (from - to) *background.height) - label.height/2;
62 | pointer.y = background.y + background.height + (value / (from - to) *background.height) - pointer.height/2;
63 | }
64 |
65 | Text {
66 | id: labelTitle
67 | y: 0
68 | text: linear.title
69 | color: Qt.rgba(0, 0, 0., 0.5)
70 | horizontalAlignment: Text.AlignHCenter
71 | anchors.horizontalCenter: parent.horizontalCenter
72 | }
73 |
74 | Repeater {
75 | id: rep
76 | y: labelTitle.height
77 | objectName:"level"
78 | model: scaleNum
79 |
80 | property double step: canvas.height / (linear.scaleNum - 1)
81 |
82 | delegate: Text{
83 | id: scaleLabel
84 | color: linear.scaleColor
85 | y: (canvas.height - index * rep.step) - height/2 + labelTitle.height*2
86 | x: linear.shift - width - 5
87 | text: ((linear.to - linear.from) / (scaleNum - 1) * index).toFixed(2);
88 | }
89 | }
90 |
91 | Text {
92 | id: label
93 | x: shift + barShift + barWidth + pointerSize
94 | y: canvas.height + (value / (from - to) *canvas.height) - label.height/2;
95 | width: 40
96 | height: 12
97 | color: Qt.rgba(0, 0, 0., 0.7)
98 | font.bold: true
99 | font.pointSize: linear.fontSize
100 | text: linear.value.toFixed(2)
101 | z: 1
102 | }
103 |
104 | Rectangle {
105 | id: pointer
106 | x: shift + barShift + barWidth
107 | y: canvas.height + (value / (from - to) *canvas.height) - pointer.height/2
108 | width: pointerSize
109 | height: pointerSize
110 | color: "transparent"
111 |
112 | Canvas {
113 | id: pointerCanvas
114 | width: pointer.width
115 | height: pointer.height
116 | antialiasing: true
117 | z:1
118 |
119 | onPaint: {
120 | var ctx = getContext('2d');
121 | ctx.fillStyle = "darkGray";
122 | ctx.lineWidth = linear.lineWidth;
123 | ctx.beginPath();
124 | ctx.moveTo(0, height/2);
125 | ctx.lineTo(width, height);
126 | ctx.lineTo(width, 0);
127 | ctx.lineTo(0, height/2);
128 | ctx.fill();
129 | }
130 | }
131 | }
132 |
133 | Canvas {
134 | id: canvas
135 | width: parent.width - linear.startX
136 | height: parent.height - linear.startY
137 | antialiasing: true
138 | z:1
139 |
140 | property double pX: shift + barShift + barWidth
141 | property double pY: 0
142 |
143 | property double warningStart: 0
144 | property double dangerStart: 0
145 | property double value: 0
146 |
147 | onPaint: {
148 | if (linear.title !== "") {
149 | canvas.y = labelTitle.height
150 | canvas.height = parent.height - linear.startY - labelTitle.height
151 | canvas.width = parent.width - linear.startX
152 | }
153 |
154 | canvas.pY = canvas.height + (linear.value / (linear.from - linear.to) *height)
155 |
156 | canvas.warningStart = canvas.height*((linear.warningStart - linear.from)/(linear.to - linear.from))
157 | canvas.dangerStart = canvas.height*((linear.dangerStart - linear.from)/(linear.to - linear.from))
158 | canvas.value = canvas.height*linear.value/(linear.to - linear.from)
159 |
160 | var ctx = getContext('2d');
161 | ctx.lineWidth = linear.lineWidth;
162 | ctx.clearRect(0, 0, width, height);
163 |
164 | if (value < warningStart) {
165 | ctx.fillStyle = linear.okColor;
166 | } else if (value < dangerStart) {
167 | ctx.fillStyle = linear.warningColor;
168 | } else {
169 | ctx.fillStyle = linear.dengerColor;
170 | }
171 |
172 | ctx.beginPath();
173 | ctx.fillRect(linear.shift + linear.barShift, height - value, linear.barWidth, value);
174 | ctx.fill();
175 | }
176 | }
177 |
178 | Canvas {
179 | id: background
180 | width: parent.width - linear.startX
181 | height: parent.height - linear.startY
182 | antialiasing: true
183 |
184 | property double warningStart: 0
185 | property double dangerStart: 0
186 |
187 | onPaint: {
188 | if (linear.title !== "") {
189 | background.y = labelTitle.height
190 |
191 | background.height = parent.height - linear.startY - labelTitle.height
192 | background.width = parent.width - linear.startX
193 | }
194 |
195 | background.warningStart = background.height*((linear.warningStart - linear.from)/(linear.to - linear.from))
196 | background.dangerStart = background.height*((linear.dangerStart - linear.from)/(linear.to - linear.from))
197 |
198 | var ctx = getContext('2d');
199 | ctx.strokeStyle = linear.scaleColor;
200 | ctx.lineWidth = linear.lineWidth;
201 | ctx.lineCap = "round"
202 | ctx.beginPath();
203 | ctx.clearRect(0, 0, background.width, background.height);
204 | ctx.moveTo(shift, 0);
205 | ctx.lineTo(shift, background.height);
206 | ctx.stroke();
207 |
208 | ctx.fillStyle = linear.okBackColor;
209 | ctx.beginPath();
210 | ctx.fillRect(linear.shift + linear.barShift, background.height - warningStart, linear.barWidth, background.height*warningStart);
211 | ctx.fill();
212 |
213 | ctx.fillStyle = linear.warningBackColor;
214 | ctx.beginPath();
215 | ctx.fillRect(linear.shift + linear.barShift, background.height - background.dangerStart, linear.barWidth, background.dangerStart - background.warningStart);
216 | ctx.fill();
217 |
218 | ctx.fillStyle = linear.dangerBackColor;
219 | ctx.beginPath();
220 | ctx.fillRect(linear.shift + linear.barShift, 0, linear.barWidth, background.height - background.dangerStart);
221 | ctx.fill();
222 | }
223 | }
224 | }
225 |
--------------------------------------------------------------------------------
/EEIoT/WaterLevel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IndeemaSoftware/EEIoT/e54597fa665b07a1ecb5a4b41a1ac9e7d1bfbc0e/EEIoT/WaterLevel.png
--------------------------------------------------------------------------------
/EEIoT/WaterLevel.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtCharts 2.0
3 |
4 |
5 | //all the automatic meagurements are made from height of Item
6 | Item {
7 | id: waterProgress
8 |
9 | property var metaData : ["from", "to", "value",
10 | "levelAsWave", "lineWidth",
11 | "color", "textColor",
12 | "fontSize",
13 | "title", "titleFont", "titleFontSize", "titleFontColor"]
14 |
15 | property double from:0 //min value
16 | property double value: 1 //current value
17 | property double to: 100 // max value
18 |
19 | property bool levelAsWave: true //show level as wave or simple line
20 | property int lineWidth: height / 50 //component lines width
21 |
22 | property color color: Qt.rgba(0.2, 0.62, 0.93, 0.7) // component color
23 | property color textColor: Qt.rgba(0.03, 0.3, 0.5, 1) //inner text color
24 |
25 | property int fontSize: height / 6
26 |
27 | property string title: ""
28 | property alias titleFont: labelTitle.font.family
29 | property alias titleFontSize: labelTitle.font.pointSize
30 | property alias titleFontColor: labelTitle.color
31 |
32 | function update(value) {
33 | waterProgress.value = value
34 | canvas.requestPaint()
35 | label.text = value.toFixed(2)
36 | label.transformOrigin = Item.Center
37 | }
38 |
39 | Text {
40 | id: labelTitle
41 | y: 0
42 | text: waterProgress.title
43 | color: Qt.rgba(0, 0, 0., 0.5)
44 | horizontalAlignment: Text.AlignHCenter
45 | anchors.horizontalCenter: parent.horizontalCenter
46 | }
47 |
48 | function getWave(x, w, a)
49 | {
50 | return a* Math.sin(w*x)
51 | }
52 |
53 | function drawWave(ctx, centreX, centreY, radius, border, heightT)
54 | {
55 | var leftX = 0
56 | var rightX = 2 * radius
57 |
58 | var distance = rightX - leftX
59 | var w = distance/Math.PI/5
60 | var waveMaxHeight = 0.08*(2*radius)//9% from circle diameter
61 | var a = (1.0 - Math.abs((centreX - heightT)) / radius) * waveMaxHeight
62 | var x1 = centreX - Math.sqrt(Math.pow(radius, 2) - Math.pow(radius - heightT, 2))
63 | var x2 = centreX + Math.sqrt(Math.pow(radius, 2) - Math.pow(radius - heightT, 2))
64 |
65 | ctx.beginPath()
66 | ctx.fillStyle = waterProgress.color;
67 | ctx.strokeStyle = waterProgress.color;
68 |
69 | var iter = 0
70 | var y11 = 0
71 | var y = 0
72 | var x11 = 0;
73 | var stepW = 0.0002*(radius)
74 | var totalY = (centreY + radius) - heightT
75 | var amp = 0
76 | var dist = 0
77 | var startX = 0
78 | var startY = 0
79 | var finishX = 0
80 | var finishY = 0
81 | var isFirst = true
82 | var wave = 0
83 |
84 | if (x1 === x2 )
85 | {
86 | colsole.log("shit");
87 | }
88 | for (var i=x1;i<=x2;i+=stepW)
89 | {
90 | if (levelAsWave)
91 | {
92 | wave = getWave(i,1/distance*w,a)
93 | }
94 |
95 | amp = 1.0 - Math.abs(Math.abs(centreX - i) - radius) *a
96 | y = wave + (centreY + radius) - heightT
97 | dist = Math.sqrt(Math.pow(centreX - i, 2) + Math.pow(centreY - y, 2))
98 |
99 | if (dist <= radius || !levelAsWave) {
100 | if (isFirst) {
101 | ctx.moveTo(i, y);
102 | startX = i;
103 | startY = y
104 | }
105 |
106 | ctx.lineTo(i,y);
107 |
108 | finishX = i
109 | finishY = y
110 |
111 | isFirst = false
112 | }
113 |
114 | if (!levelAsWave)
115 | {
116 | break
117 | }
118 | }
119 |
120 | iter = heightT
121 |
122 | while(iter >= 0) {
123 | y11 = (centreY + radius) - iter
124 | x11 = centreX + Math.sqrt(Math.pow(radius, 2) - Math.pow(radius - iter, 2))
125 | if (y11 > finishY) {
126 | ctx.lineTo(x11, y11);
127 | }
128 | iter -= 0.1
129 | }
130 |
131 | while(iter <= heightT) {
132 | y11 = (centreY + radius) - iter
133 | x11 = centreX - Math.sqrt(Math.pow(radius, 2) - Math.pow(radius - iter, 2))
134 |
135 | if (y11 > startY) {
136 | ctx.lineTo(x11, y11);
137 | }
138 |
139 | iter+=0.1
140 | }
141 |
142 | ctx.lineTo(startX, startY);
143 |
144 | ctx.fill()
145 | ctx.stroke()
146 | }
147 |
148 | function drawLine(ctx, centreX, centreY, radius, border,start, step )
149 | {
150 | ctx.beginPath();
151 | ctx.fillStyle = waterProgress.color;
152 | ctx.arc(centreX, centreY, radius - border, start + step, start - step, true);
153 | ctx.fill();
154 | }
155 |
156 | Canvas {
157 | id: canvas
158 | width: parent.height
159 | height: parent.height
160 | antialiasing: true
161 |
162 | property double radius: height/2.0
163 | property int border: 5
164 | readonly property double start: Math.PI*2.5
165 | readonly property double coef: waterProgress.value / (waterProgress.to - waterProgress.from)
166 | property double step: coef * Math.PI
167 |
168 | Text {
169 | id: label
170 | color: waterProgress.textColor
171 | font.bold: true
172 | font.pointSize: waterProgress.fontSize
173 | text: waterProgress.value.toFixed(2)
174 | z: 1
175 | horizontalAlignment: Text.AlignHCenter
176 | verticalAlignment: Text.AlignVCenter
177 | anchors.fill: parent
178 | }
179 |
180 |
181 | onPaint: {
182 | var ctx = canvas.getContext("2d");
183 | ctx.reset();
184 |
185 | if (waterProgress.title !== "") {
186 | canvas.y = labelTitle.height
187 | canvas.x = labelTitle.height/2
188 | canvas.height = parent.height - labelTitle.height
189 | canvas.width = parent.height - labelTitle.height
190 | canvas.radius = canvas.height /2
191 | }
192 |
193 | var centreX = canvas.height / 2.0;
194 | var centreY = canvas.height / 2.0;
195 |
196 | var innerRadius = canvas.radius - canvas.border - waterProgress.lineWidth
197 | var heightT = innerRadius*2.0*coef
198 |
199 | ctx.lineWidth = 1;
200 | ctx.strokeStyle = Qt.rgba(0, 0, 0, 1)
201 |
202 | drawWave(ctx, centreY, centreX, innerRadius, border, heightT)
203 |
204 | ctx.beginPath();
205 | ctx.strokeStyle = waterProgress.color;
206 | ctx.lineWidth = waterProgress.lineWidth;
207 | ctx.arc(centreX, centreY, radius - waterProgress.lineWidth, 0, 2*Math.PI, false);
208 | ctx.stroke();
209 | }
210 | }
211 | }
212 |
--------------------------------------------------------------------------------
/EEIoT/qmldir:
--------------------------------------------------------------------------------
1 |
2 | module com.indeema.eeiot
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.