QT-PyQt-PySide-Custom-Widgets 0.2.0__tar.gz → 0.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- usr/lib/python3.9/site-packages/Custom_Widgets/AnalogGaugeWidget.py +1496 -0
- usr/lib/python3.9/site-packages/Custom_Widgets/ProgressIndicator/__pycache__/__init__.cpython-39.pyc +0 -0
- usr/lib/python3.9/site-packages/Custom_Widgets/ProgressIndicator/__pycache__/test.cpython-39.pyc +0 -0
- usr/lib/python3.9/site-packages/Custom_Widgets/ProgressIndicator/__pycache__/ui_interface.cpython-39.pyc +0 -0
- {QT-PyQt-PySide-Custom-Widgets-0.2.0 → usr/lib/python3.9/site-packages}/Custom_Widgets/Widgets.py +661 -114
- usr/lib/python3.9/site-packages/Custom_Widgets/__pycache__/AnalogGaugeWidget.cpython-39.pyc +0 -0
- usr/lib/python3.9/site-packages/Custom_Widgets/__pycache__/Widgets.cpython-39.pyc +0 -0
- usr/lib/python3.9/site-packages/Custom_Widgets/__pycache__/__init__.cpython-39.pyc +0 -0
- {QT-PyQt-PySide-Custom-Widgets-0.2.0 → usr/lib/python3.9/site-packages/QT_PyQt_PySide_Custom_Widgets-0.2.7-py3.9.egg-info}/PKG-INFO +14 -2
- {QT-PyQt-PySide-Custom-Widgets-0.2.0/QT_PyQt_PySide_Custom_Widgets.egg-info → usr/lib/python3.9/site-packages/QT_PyQt_PySide_Custom_Widgets-0.2.7-py3.9.egg-info}/SOURCES.txt +1 -0
- QT-PyQt-PySide-Custom-Widgets-0.2.0/LICENSE +0 -674
- QT-PyQt-PySide-Custom-Widgets-0.2.0/MANIFEST.in +0 -0
- QT-PyQt-PySide-Custom-Widgets-0.2.0/QT_PyQt_PySide_Custom_Widgets.egg-info/PKG-INFO +0 -49
- QT-PyQt-PySide-Custom-Widgets-0.2.0/README.md +0 -26
- QT-PyQt-PySide-Custom-Widgets-0.2.0/setup.cfg +0 -4
- QT-PyQt-PySide-Custom-Widgets-0.2.0/setup.py +0 -45
- {QT-PyQt-PySide-Custom-Widgets-0.2.0 → usr/lib/python3.9/site-packages}/Custom_Widgets/ProgressIndicator/__init__.py +0 -0
- {QT-PyQt-PySide-Custom-Widgets-0.2.0 → usr/lib/python3.9/site-packages}/Custom_Widgets/ProgressIndicator/test.py +0 -0
- {QT-PyQt-PySide-Custom-Widgets-0.2.0 → usr/lib/python3.9/site-packages}/Custom_Widgets/ProgressIndicator/ui_interface.py +0 -0
- {QT-PyQt-PySide-Custom-Widgets-0.2.0 → usr/lib/python3.9/site-packages}/Custom_Widgets/__init__.py +0 -0
- {QT-PyQt-PySide-Custom-Widgets-0.2.0/QT_PyQt_PySide_Custom_Widgets.egg-info → usr/lib/python3.9/site-packages/QT_PyQt_PySide_Custom_Widgets-0.2.7-py3.9.egg-info}/dependency_links.txt +0 -0
- {QT-PyQt-PySide-Custom-Widgets-0.2.0/QT_PyQt_PySide_Custom_Widgets.egg-info → usr/lib/python3.9/site-packages/QT_PyQt_PySide_Custom_Widgets-0.2.7-py3.9.egg-info}/requires.txt +0 -0
- {QT-PyQt-PySide-Custom-Widgets-0.2.0/QT_PyQt_PySide_Custom_Widgets.egg-info → usr/lib/python3.9/site-packages/QT_PyQt_PySide_Custom_Widgets-0.2.7-py3.9.egg-info}/top_level.txt +0 -0
|
@@ -0,0 +1,1496 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
###
|
|
4
|
+
# Author: Stefan Holstein
|
|
5
|
+
# inspired by: https://github.com/Werkov/PyQt4/blob/master/examples/widgets/analogclock.py
|
|
6
|
+
# Thanks to https://stackoverflow.com/
|
|
7
|
+
|
|
8
|
+
# Updated by
|
|
9
|
+
########################################################################
|
|
10
|
+
## SPINN DESIGN CODE
|
|
11
|
+
# YOUTUBE: (SPINN TV) https://www.youtube.com/spinnTv
|
|
12
|
+
# WEBSITE: spinndesign.com
|
|
13
|
+
# GitHub : https://github.com/KhamisiKibet
|
|
14
|
+
########################################################################
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
########################################################################
|
|
18
|
+
## IMPORTS
|
|
19
|
+
########################################################################
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
import sys
|
|
23
|
+
import math
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
from PySide2.QtWidgets import QMainWindow, QWidget, QApplication
|
|
27
|
+
|
|
28
|
+
from PySide2.QtGui import QPolygon, QPolygonF, QColor, QPen, QFont, QPainter, QFontMetrics, QConicalGradient, QRadialGradient, QFontDatabase
|
|
29
|
+
|
|
30
|
+
from PySide2.QtCore import Qt ,QTime, QTimer, QPoint, QPointF, QRect, QSize, QObject
|
|
31
|
+
|
|
32
|
+
from PySide2.QtCore import Signal
|
|
33
|
+
|
|
34
|
+
except:
|
|
35
|
+
print("Error while importing PySide2")
|
|
36
|
+
exit()
|
|
37
|
+
|
|
38
|
+
################################################################################################
|
|
39
|
+
# AnalogGaugeWidget CLASS
|
|
40
|
+
################################################################################################
|
|
41
|
+
class AnalogGaugeWidget(QWidget):
|
|
42
|
+
"""Fetches rows from a Bigtable.
|
|
43
|
+
Args:
|
|
44
|
+
none
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
valueChanged = Signal(int)
|
|
48
|
+
|
|
49
|
+
def __init__(self, parent=None):
|
|
50
|
+
super(AnalogGaugeWidget, self).__init__(parent)
|
|
51
|
+
|
|
52
|
+
################################################################################################
|
|
53
|
+
# DEFAULT TIMER VALUE
|
|
54
|
+
################################################################################################
|
|
55
|
+
self.use_timer_event = False
|
|
56
|
+
|
|
57
|
+
################################################################################################
|
|
58
|
+
# DEFAULT NEEDLE COLOR
|
|
59
|
+
################################################################################################
|
|
60
|
+
self.setNeedleColor(0, 0, 0, 255)
|
|
61
|
+
|
|
62
|
+
################################################################################################
|
|
63
|
+
# DEFAULT NEEDLE WHEN RELEASED
|
|
64
|
+
################################################################################################
|
|
65
|
+
self.NeedleColorReleased = self.NeedleColor
|
|
66
|
+
|
|
67
|
+
################################################################################################
|
|
68
|
+
# DEFAULT NEEDLE COLOR ON DRAG
|
|
69
|
+
################################################################################################
|
|
70
|
+
# self.NeedleColorDrag = QColor(255, 0, 00, 255)
|
|
71
|
+
self.setNeedleColorOnDrag(255, 0, 00, 255)
|
|
72
|
+
|
|
73
|
+
################################################################################################
|
|
74
|
+
# DEFAULT SCALE TEXT COLOR
|
|
75
|
+
################################################################################################
|
|
76
|
+
self.setScaleValueColor(0, 0, 0, 255)
|
|
77
|
+
|
|
78
|
+
################################################################################################
|
|
79
|
+
# DEFAULT VALUE COLOR
|
|
80
|
+
################################################################################################
|
|
81
|
+
self.setDisplayValueColor(0, 0, 0, 255)
|
|
82
|
+
|
|
83
|
+
################################################################################################
|
|
84
|
+
# DEFAULT CENTER POINTER COLOR
|
|
85
|
+
################################################################################################
|
|
86
|
+
# self.CenterPointColor = QColor(50, 50, 50, 255)
|
|
87
|
+
self.set_CenterPointColor(0, 0, 0, 255)
|
|
88
|
+
|
|
89
|
+
################################################################################################
|
|
90
|
+
# DEFAULT NEEDLE COUNT
|
|
91
|
+
################################################################################################
|
|
92
|
+
self.value_needle_count = 1
|
|
93
|
+
|
|
94
|
+
self.value_needle = QObject
|
|
95
|
+
|
|
96
|
+
################################################################################################
|
|
97
|
+
# DEFAULT MINIMUM AND MAXIMUM VALUE
|
|
98
|
+
################################################################################################
|
|
99
|
+
self.minValue = 0
|
|
100
|
+
self.maxValue = 1000
|
|
101
|
+
################################################################################################
|
|
102
|
+
# DEFAULT START VALUE
|
|
103
|
+
################################################################################################
|
|
104
|
+
self.value = self.minValue
|
|
105
|
+
|
|
106
|
+
################################################################################################
|
|
107
|
+
# DEFAULT OFFSET
|
|
108
|
+
################################################################################################
|
|
109
|
+
self.value_offset = 0
|
|
110
|
+
|
|
111
|
+
self.valueNeedleSnapzone = 0.05
|
|
112
|
+
self.last_value = 0
|
|
113
|
+
|
|
114
|
+
# self.value2 = 0
|
|
115
|
+
# self.value2Color = QColor(0, 0, 0, 255)
|
|
116
|
+
|
|
117
|
+
################################################################################################
|
|
118
|
+
# DEFAULT RADIUS
|
|
119
|
+
################################################################################################
|
|
120
|
+
self.gauge_color_outer_radius_factor = 1
|
|
121
|
+
self.gauge_color_inner_radius_factor = 0.9
|
|
122
|
+
|
|
123
|
+
self.center_horizontal_value = 0
|
|
124
|
+
self.center_vertical_value = 0
|
|
125
|
+
|
|
126
|
+
################################################################################################
|
|
127
|
+
# DEFAULT SCALE VALUE
|
|
128
|
+
################################################################################################
|
|
129
|
+
self.scale_angle_start_value = 135
|
|
130
|
+
self.scale_angle_size = 270
|
|
131
|
+
|
|
132
|
+
self.angle_offset = 0
|
|
133
|
+
|
|
134
|
+
self.setScalaCount(10)
|
|
135
|
+
self.scala_subdiv_count = 5
|
|
136
|
+
|
|
137
|
+
self.pen = QPen(QColor(0, 0, 0))
|
|
138
|
+
|
|
139
|
+
################################################################################################
|
|
140
|
+
# LOAD CUSTOM FONT
|
|
141
|
+
################################################################################################
|
|
142
|
+
QFontDatabase.addApplicationFont(os.path.join(os.path.dirname(__file__), 'fonts/Orbitron/Orbitron-VariableFont_wght.ttf') )
|
|
143
|
+
|
|
144
|
+
################################################################################################
|
|
145
|
+
# DEFAULT POLYGON COLOR
|
|
146
|
+
################################################################################################
|
|
147
|
+
self.scale_polygon_colors = []
|
|
148
|
+
|
|
149
|
+
################################################################################################
|
|
150
|
+
# BIG SCALE COLOR
|
|
151
|
+
################################################################################################
|
|
152
|
+
self.bigScaleMarker = Qt.black
|
|
153
|
+
|
|
154
|
+
################################################################################################
|
|
155
|
+
# FINE SCALE COLOR
|
|
156
|
+
################################################################################################
|
|
157
|
+
self.fineScaleColor = Qt.black
|
|
158
|
+
|
|
159
|
+
################################################################################################
|
|
160
|
+
# DEFAULT SCALE TEXT STATUS
|
|
161
|
+
################################################################################################
|
|
162
|
+
self.setEnableScaleText(True)
|
|
163
|
+
self.scale_fontname = "Orbitron"
|
|
164
|
+
self.initial_scale_fontsize = 14
|
|
165
|
+
self.scale_fontsize = self.initial_scale_fontsize
|
|
166
|
+
|
|
167
|
+
################################################################################################
|
|
168
|
+
# DEFAULT VALUE TEXT STATUS
|
|
169
|
+
################################################################################################
|
|
170
|
+
self.enable_value_text = True
|
|
171
|
+
self.value_fontname = "Orbitron"
|
|
172
|
+
self.initial_value_fontsize = 40
|
|
173
|
+
self.value_fontsize = self.initial_value_fontsize
|
|
174
|
+
self.text_radius_factor = 0.5
|
|
175
|
+
|
|
176
|
+
################################################################################################
|
|
177
|
+
# ENABLE BAR GRAPH BY DEFAULT
|
|
178
|
+
################################################################################################
|
|
179
|
+
self.setEnableBarGraph(True)
|
|
180
|
+
################################################################################################
|
|
181
|
+
# FILL POLYGON COLOR BY DEFAULT
|
|
182
|
+
################################################################################################
|
|
183
|
+
self.setEnableScalePolygon(True)
|
|
184
|
+
################################################################################################
|
|
185
|
+
# ENABLE CENTER POINTER BY DEFAULT
|
|
186
|
+
################################################################################################
|
|
187
|
+
self.enable_CenterPoint = True
|
|
188
|
+
################################################################################################
|
|
189
|
+
# ENABLE FINE SCALE BY DEFAULT
|
|
190
|
+
################################################################################################
|
|
191
|
+
self.enable_fine_scaled_marker = True
|
|
192
|
+
################################################################################################
|
|
193
|
+
# ENABLE BIG SCALE BY DEFAULT
|
|
194
|
+
################################################################################################
|
|
195
|
+
self.enable_big_scaled_marker = True
|
|
196
|
+
|
|
197
|
+
################################################################################################
|
|
198
|
+
# NEEDLE SCALE FACTOR/LENGTH
|
|
199
|
+
################################################################################################
|
|
200
|
+
self.needle_scale_factor = 0.8
|
|
201
|
+
################################################################################################
|
|
202
|
+
# ENABLE NEEDLE POLYGON BY DEFAULT
|
|
203
|
+
################################################################################################
|
|
204
|
+
self.enable_Needle_Polygon = True
|
|
205
|
+
|
|
206
|
+
################################################################################################
|
|
207
|
+
# ENABLE NEEDLE MOUSE TRACKING BY DEFAULT
|
|
208
|
+
################################################################################################
|
|
209
|
+
self.setMouseTracking(True)
|
|
210
|
+
|
|
211
|
+
################################################################################################
|
|
212
|
+
# SET GAUGE UNITS
|
|
213
|
+
################################################################################################
|
|
214
|
+
self.units = "℃"
|
|
215
|
+
|
|
216
|
+
# QTimer sorgt für neu Darstellung alle X ms
|
|
217
|
+
# evtl performance hier verbessern mit self.update() und self.use_timer_event = False
|
|
218
|
+
# todo: self.update als default ohne ueberpruefung, ob self.use_timer_event gesetzt ist oder nicht
|
|
219
|
+
# Timer startet alle 10ms das event paintEvent
|
|
220
|
+
if self.use_timer_event:
|
|
221
|
+
timer = QTimer(self)
|
|
222
|
+
timer.timeout.connect(self.update)
|
|
223
|
+
timer.start(10)
|
|
224
|
+
else:
|
|
225
|
+
self.update()
|
|
226
|
+
|
|
227
|
+
################################################################################################
|
|
228
|
+
# SET DEFAULT THEME
|
|
229
|
+
################################################################################################
|
|
230
|
+
self.setGaugeTheme(0)
|
|
231
|
+
|
|
232
|
+
################################################################################################
|
|
233
|
+
# RESIZE GAUGE
|
|
234
|
+
################################################################################################
|
|
235
|
+
self.rescale_method()
|
|
236
|
+
|
|
237
|
+
################################################################################################
|
|
238
|
+
# SET SCALE FONT FAMILY
|
|
239
|
+
################################################################################################
|
|
240
|
+
def setScaleFontFamily(self, font):
|
|
241
|
+
self.scale_fontname = str(font)
|
|
242
|
+
|
|
243
|
+
################################################################################################
|
|
244
|
+
# SET VALUE FONT FAMILY
|
|
245
|
+
################################################################################################
|
|
246
|
+
def setValueFontFamily(self, font):
|
|
247
|
+
self.value_fontname = str(font)
|
|
248
|
+
|
|
249
|
+
################################################################################################
|
|
250
|
+
# SET BIG SCALE COLOR
|
|
251
|
+
################################################################################################
|
|
252
|
+
def setBigScaleColor(self, color):
|
|
253
|
+
self.bigScaleMarker = QColor(color)
|
|
254
|
+
|
|
255
|
+
################################################################################################
|
|
256
|
+
# SET FINE SCALE COLOR
|
|
257
|
+
################################################################################################
|
|
258
|
+
def setFineScaleColor(self, color):
|
|
259
|
+
self.fineScaleColor = QColor(color)
|
|
260
|
+
|
|
261
|
+
################################################################################################
|
|
262
|
+
# GAUGE THEMES
|
|
263
|
+
################################################################################################
|
|
264
|
+
def setGaugeTheme(self, Theme = 1):
|
|
265
|
+
if Theme == 0 or Theme == None:
|
|
266
|
+
self.set_scale_polygon_colors([[.00, Qt.red],
|
|
267
|
+
[.1, Qt.yellow],
|
|
268
|
+
[.15, Qt.green],
|
|
269
|
+
[1, Qt.transparent]])
|
|
270
|
+
|
|
271
|
+
self.needle_center_bg = [
|
|
272
|
+
[0, QColor(35, 40, 3, 255)],
|
|
273
|
+
[0.16, QColor(30, 36, 45, 255)],
|
|
274
|
+
[0.225, QColor(36, 42, 54, 255)],
|
|
275
|
+
[0.423963, QColor(19, 23, 29, 255)],
|
|
276
|
+
[0.580645, QColor(45, 53, 68, 255)],
|
|
277
|
+
[0.792627, QColor(59, 70, 88, 255)],
|
|
278
|
+
[0.935, QColor(30, 35, 45, 255)],
|
|
279
|
+
[1, QColor(35, 40, 3, 255)]
|
|
280
|
+
]
|
|
281
|
+
|
|
282
|
+
self.outer_circle_bg = [
|
|
283
|
+
[0.0645161, QColor(30, 35, 45, 255)],
|
|
284
|
+
[0.37788, QColor(57, 67, 86, 255)],
|
|
285
|
+
[1, QColor(30, 36, 45, 255)]
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
if Theme == 1:
|
|
289
|
+
self.set_scale_polygon_colors([[.75, Qt.red],
|
|
290
|
+
[.5, Qt.yellow],
|
|
291
|
+
[.25, Qt.green]])
|
|
292
|
+
|
|
293
|
+
self.needle_center_bg = [
|
|
294
|
+
[0, QColor(35, 40, 3, 255)],
|
|
295
|
+
[0.16, QColor(30, 36, 45, 255)],
|
|
296
|
+
[0.225, QColor(36, 42, 54, 255)],
|
|
297
|
+
[0.423963, QColor(19, 23, 29, 255)],
|
|
298
|
+
[0.580645, QColor(45, 53, 68, 255)],
|
|
299
|
+
[0.792627, QColor(59, 70, 88, 255)],
|
|
300
|
+
[0.935, QColor(30, 35, 45, 255)],
|
|
301
|
+
[1, QColor(35, 40, 3, 255)]
|
|
302
|
+
]
|
|
303
|
+
|
|
304
|
+
self.outer_circle_bg = [
|
|
305
|
+
[0.0645161, QColor(30, 35, 45, 255)],
|
|
306
|
+
[0.37788, QColor(57, 67, 86, 255)],
|
|
307
|
+
[1, QColor(30, 36, 45, 255)]
|
|
308
|
+
]
|
|
309
|
+
|
|
310
|
+
if Theme == 2:
|
|
311
|
+
self.set_scale_polygon_colors([[.25, Qt.red],
|
|
312
|
+
[.5, Qt.yellow],
|
|
313
|
+
[.75, Qt.green]])
|
|
314
|
+
|
|
315
|
+
self.needle_center_bg = [
|
|
316
|
+
[0, QColor(35, 40, 3, 255)],
|
|
317
|
+
[0.16, QColor(30, 36, 45, 255)],
|
|
318
|
+
[0.225, QColor(36, 42, 54, 255)],
|
|
319
|
+
[0.423963, QColor(19, 23, 29, 255)],
|
|
320
|
+
[0.580645, QColor(45, 53, 68, 255)],
|
|
321
|
+
[0.792627, QColor(59, 70, 88, 255)],
|
|
322
|
+
[0.935, QColor(30, 35, 45, 255)],
|
|
323
|
+
[1, QColor(35, 40, 3, 255)]
|
|
324
|
+
]
|
|
325
|
+
|
|
326
|
+
self.outer_circle_bg = [
|
|
327
|
+
[0.0645161, QColor(30, 35, 45, 255)],
|
|
328
|
+
[0.37788, QColor(57, 67, 86, 255)],
|
|
329
|
+
[1, QColor(30, 36, 45, 255)]
|
|
330
|
+
]
|
|
331
|
+
|
|
332
|
+
elif Theme == 3:
|
|
333
|
+
self.set_scale_polygon_colors([[.00, Qt.white]])
|
|
334
|
+
|
|
335
|
+
self.needle_center_bg = [
|
|
336
|
+
[0, Qt.white],
|
|
337
|
+
]
|
|
338
|
+
|
|
339
|
+
self.outer_circle_bg = [
|
|
340
|
+
[0, Qt.white],
|
|
341
|
+
]
|
|
342
|
+
|
|
343
|
+
self.bigScaleMarker = Qt.black
|
|
344
|
+
self.fineScaleColor = Qt.black
|
|
345
|
+
|
|
346
|
+
elif Theme == 4:
|
|
347
|
+
self.set_scale_polygon_colors([[1, Qt.black]])
|
|
348
|
+
|
|
349
|
+
self.needle_center_bg = [
|
|
350
|
+
[0, Qt.black],
|
|
351
|
+
]
|
|
352
|
+
|
|
353
|
+
self.outer_circle_bg = [
|
|
354
|
+
[0, Qt.black],
|
|
355
|
+
]
|
|
356
|
+
|
|
357
|
+
self.bigScaleMarker = Qt.white
|
|
358
|
+
self.fineScaleColor = Qt.white
|
|
359
|
+
|
|
360
|
+
elif Theme == 5:
|
|
361
|
+
self.set_scale_polygon_colors([[1, QColor("#029CDE")]])
|
|
362
|
+
|
|
363
|
+
self.needle_center_bg = [
|
|
364
|
+
[0, QColor("#029CDE")],
|
|
365
|
+
]
|
|
366
|
+
|
|
367
|
+
self.outer_circle_bg = [
|
|
368
|
+
[0, QColor("#029CDE")],
|
|
369
|
+
]
|
|
370
|
+
|
|
371
|
+
elif Theme == 6:
|
|
372
|
+
self.set_scale_polygon_colors([[.75, QColor("#01ADEF")],
|
|
373
|
+
[.5, QColor("#0086BF")],
|
|
374
|
+
[.25, QColor("#005275")]])
|
|
375
|
+
|
|
376
|
+
self.needle_center_bg = [
|
|
377
|
+
[0, QColor(0, 46, 61, 255)],
|
|
378
|
+
[0.322581, QColor(1, 173, 239, 255)],
|
|
379
|
+
[0.571429, QColor(0, 73, 99, 255)],
|
|
380
|
+
[1, QColor(0, 46, 61, 255)]
|
|
381
|
+
]
|
|
382
|
+
|
|
383
|
+
self.outer_circle_bg = [
|
|
384
|
+
[0.0645161, QColor(0, 85, 116, 255)],
|
|
385
|
+
[0.37788, QColor(1, 173, 239, 255)],
|
|
386
|
+
[1, QColor(0, 69, 94, 255)]
|
|
387
|
+
]
|
|
388
|
+
|
|
389
|
+
self.bigScaleMarker = Qt.black
|
|
390
|
+
self.fineScaleColor = Qt.black
|
|
391
|
+
|
|
392
|
+
elif Theme == 7:
|
|
393
|
+
self.set_scale_polygon_colors([[.25, QColor("#01ADEF")],
|
|
394
|
+
[.5, QColor("#0086BF")],
|
|
395
|
+
[.75, QColor("#005275")]])
|
|
396
|
+
|
|
397
|
+
self.needle_center_bg = [
|
|
398
|
+
[0, QColor(0, 46, 61, 255)],
|
|
399
|
+
[0.322581, QColor(1, 173, 239, 255)],
|
|
400
|
+
[0.571429, QColor(0, 73, 99, 255)],
|
|
401
|
+
[1, QColor(0, 46, 61, 255)]
|
|
402
|
+
]
|
|
403
|
+
|
|
404
|
+
self.outer_circle_bg = [
|
|
405
|
+
[0.0645161, QColor(0, 85, 116, 255)],
|
|
406
|
+
[0.37788, QColor(1, 173, 239, 255)],
|
|
407
|
+
[1, QColor(0, 69, 94, 255)]
|
|
408
|
+
]
|
|
409
|
+
|
|
410
|
+
self.bigScaleMarker = Qt.black
|
|
411
|
+
self.fineScaleColor = Qt.black
|
|
412
|
+
|
|
413
|
+
elif Theme == 8:
|
|
414
|
+
self.setCustomGaugeTheme(
|
|
415
|
+
color1 = "#ffaa00",
|
|
416
|
+
color2= "#7d5300",
|
|
417
|
+
color3 = "#3e2900"
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
self.bigScaleMarker = Qt.black
|
|
421
|
+
self.fineScaleColor = Qt.black
|
|
422
|
+
|
|
423
|
+
elif Theme == 9:
|
|
424
|
+
self.setCustomGaugeTheme(
|
|
425
|
+
color1 = "#3e2900",
|
|
426
|
+
color2= "#7d5300",
|
|
427
|
+
color3 = "#ffaa00"
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
self.bigScaleMarker = Qt.white
|
|
431
|
+
self.fineScaleColor = Qt.white
|
|
432
|
+
|
|
433
|
+
elif Theme == 10:
|
|
434
|
+
self.setCustomGaugeTheme(
|
|
435
|
+
color1 = "#ff007f",
|
|
436
|
+
color2= "#aa0055",
|
|
437
|
+
color3 = "#830042"
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
self.bigScaleMarker = Qt.black
|
|
442
|
+
self.fineScaleColor = Qt.black
|
|
443
|
+
|
|
444
|
+
elif Theme == 11:
|
|
445
|
+
self.setCustomGaugeTheme(
|
|
446
|
+
color1 = "#830042",
|
|
447
|
+
color2= "#aa0055",
|
|
448
|
+
color3 = "#ff007f"
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
self.bigScaleMarker = Qt.white
|
|
452
|
+
self.fineScaleColor = Qt.white
|
|
453
|
+
|
|
454
|
+
elif Theme == 12:
|
|
455
|
+
self.setCustomGaugeTheme(
|
|
456
|
+
color1 = "#ffe75d",
|
|
457
|
+
color2= "#896c1a",
|
|
458
|
+
color3 = "#232803"
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
self.bigScaleMarker = Qt.black
|
|
462
|
+
self.fineScaleColor = Qt.black
|
|
463
|
+
|
|
464
|
+
elif Theme == 13:
|
|
465
|
+
self.setCustomGaugeTheme(
|
|
466
|
+
color1 = "#ffe75d",
|
|
467
|
+
color2= "#896c1a",
|
|
468
|
+
color3 = "#232803"
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
self.bigScaleMarker = Qt.black
|
|
472
|
+
self.fineScaleColor = Qt.black
|
|
473
|
+
|
|
474
|
+
elif Theme == 14:
|
|
475
|
+
self.setCustomGaugeTheme(
|
|
476
|
+
color1 = "#232803",
|
|
477
|
+
color2= "#821600",
|
|
478
|
+
color3 = "#ffe75d"
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
self.bigScaleMarker = Qt.white
|
|
482
|
+
self.fineScaleColor = Qt.white
|
|
483
|
+
|
|
484
|
+
elif Theme == 15:
|
|
485
|
+
self.setCustomGaugeTheme(
|
|
486
|
+
color1 = "#00FF11",
|
|
487
|
+
color2= "#00990A",
|
|
488
|
+
color3 = "#002603"
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
self.bigScaleMarker = Qt.black
|
|
492
|
+
self.fineScaleColor = Qt.black
|
|
493
|
+
|
|
494
|
+
elif Theme == 16:
|
|
495
|
+
self.setCustomGaugeTheme(
|
|
496
|
+
color1 = "#002603",
|
|
497
|
+
color2= "#00990A",
|
|
498
|
+
color3 = "#00FF11"
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
self.bigScaleMarker = Qt.white
|
|
502
|
+
self.fineScaleColor = Qt.white
|
|
503
|
+
|
|
504
|
+
elif Theme == 17:
|
|
505
|
+
self.setCustomGaugeTheme(
|
|
506
|
+
color1 = "#00FFCC",
|
|
507
|
+
color2= "#00876C",
|
|
508
|
+
color3 = "#00211B"
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
self.bigScaleMarker = Qt.black
|
|
512
|
+
self.fineScaleColor = Qt.black
|
|
513
|
+
|
|
514
|
+
elif Theme == 18:
|
|
515
|
+
self.setCustomGaugeTheme(
|
|
516
|
+
color1 = "#00211B",
|
|
517
|
+
color2= "#00876C",
|
|
518
|
+
color3 = "#00FFCC"
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
self.bigScaleMarker = Qt.white
|
|
522
|
+
self.fineScaleColor = Qt.white
|
|
523
|
+
|
|
524
|
+
elif Theme == 19:
|
|
525
|
+
self.setCustomGaugeTheme(
|
|
526
|
+
color1 = "#001EFF",
|
|
527
|
+
color2= "#001299",
|
|
528
|
+
color3 = "#000426"
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
self.bigScaleMarker = Qt.black
|
|
532
|
+
self.fineScaleColor = Qt.black
|
|
533
|
+
|
|
534
|
+
elif Theme == 20:
|
|
535
|
+
self.setCustomGaugeTheme(
|
|
536
|
+
color1 = "#000426",
|
|
537
|
+
color2= "#001299",
|
|
538
|
+
color3 = "#001EFF"
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
self.bigScaleMarker = Qt.white
|
|
542
|
+
self.fineScaleColor = Qt.white
|
|
543
|
+
|
|
544
|
+
elif Theme == 21:
|
|
545
|
+
self.setCustomGaugeTheme(
|
|
546
|
+
color1 = "#F200FF",
|
|
547
|
+
color2= "#85008C",
|
|
548
|
+
color3 = "#240026"
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
self.bigScaleMarker = Qt.black
|
|
552
|
+
self.fineScaleColor = Qt.black
|
|
553
|
+
|
|
554
|
+
elif Theme == 22:
|
|
555
|
+
self.setCustomGaugeTheme(
|
|
556
|
+
color1 = "#240026",
|
|
557
|
+
color2= "#85008C",
|
|
558
|
+
color3 = "#F200FF"
|
|
559
|
+
)
|
|
560
|
+
|
|
561
|
+
self.bigScaleMarker = Qt.white
|
|
562
|
+
self.fineScaleColor = Qt.white
|
|
563
|
+
|
|
564
|
+
elif Theme == 23:
|
|
565
|
+
self.setCustomGaugeTheme(
|
|
566
|
+
color1 = "#FF0022",
|
|
567
|
+
color2= "#080001",
|
|
568
|
+
color3 = "#009991"
|
|
569
|
+
)
|
|
570
|
+
|
|
571
|
+
self.bigScaleMarker = Qt.white
|
|
572
|
+
self.fineScaleColor = Qt.white
|
|
573
|
+
|
|
574
|
+
elif Theme == 24:
|
|
575
|
+
self.setCustomGaugeTheme(
|
|
576
|
+
color1 = "#009991",
|
|
577
|
+
color2= "#080001",
|
|
578
|
+
color3 = "#FF0022"
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
self.bigScaleMarker = Qt.white
|
|
582
|
+
self.fineScaleColor = Qt.white
|
|
583
|
+
|
|
584
|
+
################################################################################################
|
|
585
|
+
# SET CUSTOM GAUGE THEME
|
|
586
|
+
################################################################################################
|
|
587
|
+
def setCustomGaugeTheme(self, **colors):
|
|
588
|
+
if "color1" in colors and len(str(colors['color1'])) > 0:
|
|
589
|
+
if "color2" in colors and len(str(colors['color2'])) > 0:
|
|
590
|
+
if "color3" in colors and len(str(colors['color3'])) > 0:
|
|
591
|
+
|
|
592
|
+
self.set_scale_polygon_colors([[.25, QColor(str(colors['color1']))],
|
|
593
|
+
[.5, QColor(str(colors['color2']))],
|
|
594
|
+
[.75, QColor(str(colors['color3']))]])
|
|
595
|
+
|
|
596
|
+
self.needle_center_bg = [
|
|
597
|
+
[0, QColor(str(colors['color3']))],
|
|
598
|
+
[0.322581, QColor(str(colors['color1']))],
|
|
599
|
+
[0.571429, QColor(str(colors['color2']))],
|
|
600
|
+
[1, QColor(str(colors['color3']))]
|
|
601
|
+
]
|
|
602
|
+
|
|
603
|
+
self.outer_circle_bg = [
|
|
604
|
+
[0.0645161, QColor(str(colors['color3']))],
|
|
605
|
+
[0.36, QColor(str(colors['color1']))],
|
|
606
|
+
[1, QColor(str(colors['color2']))]
|
|
607
|
+
]
|
|
608
|
+
|
|
609
|
+
else:
|
|
610
|
+
|
|
611
|
+
self.set_scale_polygon_colors([[.5, QColor(str(colors['color1']))],
|
|
612
|
+
[1, QColor(str(colors['color2']))]])
|
|
613
|
+
|
|
614
|
+
self.needle_center_bg = [
|
|
615
|
+
[0, QColor(str(colors['color2']))],
|
|
616
|
+
[1, QColor(str(colors['color1']))]
|
|
617
|
+
]
|
|
618
|
+
|
|
619
|
+
self.outer_circle_bg = [
|
|
620
|
+
[0, QColor(str(colors['color2']))],
|
|
621
|
+
[1, QColor(str(colors['color2']))]
|
|
622
|
+
]
|
|
623
|
+
|
|
624
|
+
else:
|
|
625
|
+
|
|
626
|
+
self.set_scale_polygon_colors([[1, QColor(str(colors['color1']))]])
|
|
627
|
+
|
|
628
|
+
self.needle_center_bg = [
|
|
629
|
+
[1, QColor(str(colors['color1']))]
|
|
630
|
+
]
|
|
631
|
+
|
|
632
|
+
self.outer_circle_bg = [
|
|
633
|
+
[1, QColor(str(colors['color1']))]
|
|
634
|
+
]
|
|
635
|
+
|
|
636
|
+
else:
|
|
637
|
+
|
|
638
|
+
self.setGaugeTheme(0)
|
|
639
|
+
print("color1 is not defined")
|
|
640
|
+
|
|
641
|
+
################################################################################################
|
|
642
|
+
# SET SCALE POLYGON COLOR
|
|
643
|
+
################################################################################################
|
|
644
|
+
def setScalePolygonColor(self, **colors):
|
|
645
|
+
if "color1" in colors and len(str(colors['color1'])) > 0:
|
|
646
|
+
if "color2" in colors and len(str(colors['color2'])) > 0:
|
|
647
|
+
if "color3" in colors and len(str(colors['color3'])) > 0:
|
|
648
|
+
|
|
649
|
+
self.set_scale_polygon_colors([[.25, QColor(str(colors['color1']))],
|
|
650
|
+
[.5, QColor(str(colors['color2']))],
|
|
651
|
+
[.75, QColor(str(colors['color3']))]])
|
|
652
|
+
|
|
653
|
+
else:
|
|
654
|
+
|
|
655
|
+
self.set_scale_polygon_colors([[.5, QColor(str(colors['color1']))],
|
|
656
|
+
[1, QColor(str(colors['color2']))]])
|
|
657
|
+
|
|
658
|
+
else:
|
|
659
|
+
|
|
660
|
+
self.set_scale_polygon_colors([[1, QColor(str(colors['color1']))]])
|
|
661
|
+
|
|
662
|
+
else:
|
|
663
|
+
print("color1 is not defined")
|
|
664
|
+
|
|
665
|
+
################################################################################################
|
|
666
|
+
# SET NEEDLE CENTER COLOR
|
|
667
|
+
################################################################################################
|
|
668
|
+
def setNeedleCenterColor(self, **colors):
|
|
669
|
+
if "color1" in colors and len(str(colors['color1'])) > 0:
|
|
670
|
+
if "color2" in colors and len(str(colors['color2'])) > 0:
|
|
671
|
+
if "color3" in colors and len(str(colors['color3'])) > 0:
|
|
672
|
+
|
|
673
|
+
self.needle_center_bg = [
|
|
674
|
+
[0, QColor(str(colors['color3']))],
|
|
675
|
+
[0.322581, QColor(str(colors['color1']))],
|
|
676
|
+
[0.571429, QColor(str(colors['color2']))],
|
|
677
|
+
[1, QColor(str(colors['color3']))]
|
|
678
|
+
]
|
|
679
|
+
|
|
680
|
+
else:
|
|
681
|
+
|
|
682
|
+
self.needle_center_bg = [
|
|
683
|
+
[0, QColor(str(colors['color2']))],
|
|
684
|
+
[1, QColor(str(colors['color1']))]
|
|
685
|
+
]
|
|
686
|
+
|
|
687
|
+
else:
|
|
688
|
+
|
|
689
|
+
self.needle_center_bg = [
|
|
690
|
+
[1, QColor(str(colors['color1']))]
|
|
691
|
+
]
|
|
692
|
+
else:
|
|
693
|
+
print("color1 is not defined")
|
|
694
|
+
|
|
695
|
+
################################################################################################
|
|
696
|
+
# SET OUTER CIRCLE COLOR
|
|
697
|
+
################################################################################################
|
|
698
|
+
def setOuterCircleColor(self, **colors):
|
|
699
|
+
if "color1" in colors and len(str(colors['color1'])) > 0:
|
|
700
|
+
if "color2" in colors and len(str(colors['color2'])) > 0:
|
|
701
|
+
if "color3" in colors and len(str(colors['color3'])) > 0:
|
|
702
|
+
|
|
703
|
+
self.outer_circle_bg = [
|
|
704
|
+
[0.0645161, QColor(str(colors['color3']))],
|
|
705
|
+
[0.37788, QColor(str(colors['color1']))],
|
|
706
|
+
[1, QColor(str(colors['color2']))]
|
|
707
|
+
]
|
|
708
|
+
|
|
709
|
+
else:
|
|
710
|
+
|
|
711
|
+
self.outer_circle_bg = [
|
|
712
|
+
[0, QColor(str(colors['color2']))],
|
|
713
|
+
[1, QColor(str(colors['color2']))]
|
|
714
|
+
]
|
|
715
|
+
|
|
716
|
+
else:
|
|
717
|
+
|
|
718
|
+
self.outer_circle_bg = [
|
|
719
|
+
[1, QColor(str(colors['color1']))]
|
|
720
|
+
]
|
|
721
|
+
|
|
722
|
+
else:
|
|
723
|
+
print("color1 is not defined")
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
################################################################################################
|
|
728
|
+
# RESCALE
|
|
729
|
+
################################################################################################
|
|
730
|
+
def rescale_method(self):
|
|
731
|
+
# print("slotMethod")
|
|
732
|
+
################################################################################################
|
|
733
|
+
# SET WIDTH AND HEIGHT
|
|
734
|
+
################################################################################################
|
|
735
|
+
if self.width() <= self.height():
|
|
736
|
+
self.widget_diameter = self.width()
|
|
737
|
+
else:
|
|
738
|
+
self.widget_diameter = self.height()
|
|
739
|
+
|
|
740
|
+
################################################################################################
|
|
741
|
+
# SET NEEDLE SIZE
|
|
742
|
+
################################################################################################
|
|
743
|
+
self.change_value_needle_style([QPolygon([
|
|
744
|
+
QPoint(4, 30),
|
|
745
|
+
QPoint(-4, 30),
|
|
746
|
+
QPoint(-2, - self.widget_diameter / 2 * self.needle_scale_factor),
|
|
747
|
+
QPoint(0, - self.widget_diameter / 2 * self.needle_scale_factor - 6),
|
|
748
|
+
QPoint(2, - self.widget_diameter / 2 * self.needle_scale_factor)
|
|
749
|
+
])])
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
################################################################################################
|
|
753
|
+
# SET FONT SIZE
|
|
754
|
+
################################################################################################
|
|
755
|
+
self.scale_fontsize = self.initial_scale_fontsize * self.widget_diameter / 400
|
|
756
|
+
self.value_fontsize = self.initial_value_fontsize * self.widget_diameter / 400
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
def change_value_needle_style(self, design):
|
|
760
|
+
# prepared for multiple needle instrument
|
|
761
|
+
self.value_needle = []
|
|
762
|
+
for i in design:
|
|
763
|
+
self.value_needle.append(i)
|
|
764
|
+
if not self.use_timer_event:
|
|
765
|
+
self.update()
|
|
766
|
+
|
|
767
|
+
################################################################################################
|
|
768
|
+
# UPDATE VALUE
|
|
769
|
+
################################################################################################
|
|
770
|
+
def updateValue(self, value, mouse_controlled = False):
|
|
771
|
+
# if not mouse_controlled:
|
|
772
|
+
# self.value = value
|
|
773
|
+
#
|
|
774
|
+
# if mouse_controlled:
|
|
775
|
+
# self.valueChanged.emit(int(value))
|
|
776
|
+
|
|
777
|
+
if value <= self.minValue:
|
|
778
|
+
self.value = self.minValue
|
|
779
|
+
elif value >= self.maxValue:
|
|
780
|
+
self.value = self.maxValue
|
|
781
|
+
else:
|
|
782
|
+
self.value = value
|
|
783
|
+
# self.paintEvent("")
|
|
784
|
+
self.valueChanged.emit(int(value))
|
|
785
|
+
# print(self.value)
|
|
786
|
+
|
|
787
|
+
# ohne timer: aktiviere self.update()
|
|
788
|
+
if not self.use_timer_event:
|
|
789
|
+
self.update()
|
|
790
|
+
|
|
791
|
+
def updateAngleOffset(self, offset):
|
|
792
|
+
self.angle_offset = offset
|
|
793
|
+
if not self.use_timer_event:
|
|
794
|
+
self.update()
|
|
795
|
+
|
|
796
|
+
def center_horizontal(self, value):
|
|
797
|
+
self.center_horizontal_value = value
|
|
798
|
+
# print("horizontal: " + str(self.center_horizontal_value))
|
|
799
|
+
|
|
800
|
+
def center_vertical(self, value):
|
|
801
|
+
self.center_vertical_value = value
|
|
802
|
+
# print("vertical: " + str(self.center_vertical_value))
|
|
803
|
+
|
|
804
|
+
################################################################################################
|
|
805
|
+
# SET NEEDLE COLOR
|
|
806
|
+
################################################################################################
|
|
807
|
+
def setNeedleColor(self, R=50, G=50, B=50, Transparency=255):
|
|
808
|
+
# Red: R = 0 - 255
|
|
809
|
+
# Green: G = 0 - 255
|
|
810
|
+
# Blue: B = 0 - 255
|
|
811
|
+
# Transparency = 0 - 255
|
|
812
|
+
self.NeedleColor = QColor(R, G, B, Transparency)
|
|
813
|
+
self.NeedleColorReleased = self.NeedleColor
|
|
814
|
+
|
|
815
|
+
if not self.use_timer_event:
|
|
816
|
+
self.update()
|
|
817
|
+
################################################################################################
|
|
818
|
+
# SET NEEDLE COLOR ON DRAG
|
|
819
|
+
################################################################################################
|
|
820
|
+
def setNeedleColorOnDrag(self, R=50, G=50, B=50, Transparency=255):
|
|
821
|
+
# Red: R = 0 - 255
|
|
822
|
+
# Green: G = 0 - 255
|
|
823
|
+
# Blue: B = 0 - 255
|
|
824
|
+
# Transparency = 0 - 255
|
|
825
|
+
self.NeedleColorDrag = QColor(R, G, B, Transparency)
|
|
826
|
+
|
|
827
|
+
if not self.use_timer_event:
|
|
828
|
+
self.update()
|
|
829
|
+
|
|
830
|
+
################################################################################################
|
|
831
|
+
# SET SCALE VALUE COLOR
|
|
832
|
+
################################################################################################
|
|
833
|
+
def setScaleValueColor(self, R=50, G=50, B=50, Transparency=255):
|
|
834
|
+
# Red: R = 0 - 255
|
|
835
|
+
# Green: G = 0 - 255
|
|
836
|
+
# Blue: B = 0 - 255
|
|
837
|
+
# Transparency = 0 - 255
|
|
838
|
+
self.ScaleValueColor = QColor(R, G, B, Transparency)
|
|
839
|
+
|
|
840
|
+
if not self.use_timer_event:
|
|
841
|
+
self.update()
|
|
842
|
+
|
|
843
|
+
################################################################################################
|
|
844
|
+
# SET DISPLAY VALUE COLOR
|
|
845
|
+
################################################################################################
|
|
846
|
+
def setDisplayValueColor(self, R=50, G=50, B=50, Transparency=255):
|
|
847
|
+
# Red: R = 0 - 255
|
|
848
|
+
# Green: G = 0 - 255
|
|
849
|
+
# Blue: B = 0 - 255
|
|
850
|
+
# Transparency = 0 - 255
|
|
851
|
+
self.DisplayValueColor = QColor(R, G, B, Transparency)
|
|
852
|
+
|
|
853
|
+
if not self.use_timer_event:
|
|
854
|
+
self.update()
|
|
855
|
+
|
|
856
|
+
################################################################################################
|
|
857
|
+
# SET CENTER POINTER COLOR
|
|
858
|
+
################################################################################################
|
|
859
|
+
def set_CenterPointColor(self, R=50, G=50, B=50, Transparency=255):
|
|
860
|
+
self.CenterPointColor = QColor(R, G, B, Transparency)
|
|
861
|
+
|
|
862
|
+
if not self.use_timer_event:
|
|
863
|
+
self.update()
|
|
864
|
+
|
|
865
|
+
################################################################################################
|
|
866
|
+
# SHOW HIDE NEEDLE POLYGON
|
|
867
|
+
################################################################################################
|
|
868
|
+
def setEnableNeedlePolygon(self, enable = True):
|
|
869
|
+
self.enable_Needle_Polygon = enable
|
|
870
|
+
|
|
871
|
+
if not self.use_timer_event:
|
|
872
|
+
self.update()
|
|
873
|
+
|
|
874
|
+
################################################################################################
|
|
875
|
+
# SHOW HIDE SCALE TEXT
|
|
876
|
+
################################################################################################
|
|
877
|
+
def setEnableScaleText(self, enable = True):
|
|
878
|
+
self.enable_scale_text = enable
|
|
879
|
+
|
|
880
|
+
if not self.use_timer_event:
|
|
881
|
+
self.update()
|
|
882
|
+
|
|
883
|
+
################################################################################################
|
|
884
|
+
# SHOW HIDE BAR GRAPH
|
|
885
|
+
################################################################################################
|
|
886
|
+
def setEnableBarGraph(self, enable = True):
|
|
887
|
+
self.enableBarGraph = enable
|
|
888
|
+
|
|
889
|
+
if not self.use_timer_event:
|
|
890
|
+
self.update()
|
|
891
|
+
|
|
892
|
+
################################################################################################
|
|
893
|
+
# SHOW HIDE VALUE TEXT
|
|
894
|
+
################################################################################################
|
|
895
|
+
def setEnableValueText(self, enable = True):
|
|
896
|
+
self.enable_value_text = enable
|
|
897
|
+
|
|
898
|
+
if not self.use_timer_event:
|
|
899
|
+
self.update()
|
|
900
|
+
|
|
901
|
+
################################################################################################
|
|
902
|
+
# SHOW HIDE CENTER POINTER
|
|
903
|
+
################################################################################################
|
|
904
|
+
def setEnableCenterPoint(self, enable = True):
|
|
905
|
+
self.enable_CenterPoint = enable
|
|
906
|
+
|
|
907
|
+
if not self.use_timer_event:
|
|
908
|
+
self.update()
|
|
909
|
+
|
|
910
|
+
################################################################################################
|
|
911
|
+
# SHOW HIDE FILLED POLYGON
|
|
912
|
+
################################################################################################
|
|
913
|
+
def setEnableScalePolygon(self, enable = True):
|
|
914
|
+
self.enable_filled_Polygon = enable
|
|
915
|
+
|
|
916
|
+
if not self.use_timer_event:
|
|
917
|
+
self.update()
|
|
918
|
+
|
|
919
|
+
################################################################################################
|
|
920
|
+
# SHOW HIDE BIG SCALE
|
|
921
|
+
################################################################################################
|
|
922
|
+
def setEnableBigScaleGrid(self, enable = True):
|
|
923
|
+
self.enable_big_scaled_marker = enable
|
|
924
|
+
|
|
925
|
+
if not self.use_timer_event:
|
|
926
|
+
self.update()
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
################################################################################################
|
|
930
|
+
# SHOW HIDE FINE SCALE
|
|
931
|
+
################################################################################################
|
|
932
|
+
def setEnableFineScaleGrid(self, enable = True):
|
|
933
|
+
self.enable_fine_scaled_marker = enable
|
|
934
|
+
|
|
935
|
+
if not self.use_timer_event:
|
|
936
|
+
self.update()
|
|
937
|
+
|
|
938
|
+
################################################################################################
|
|
939
|
+
# SHOW HIDE SCALA MAIN CONT
|
|
940
|
+
################################################################################################
|
|
941
|
+
def setScalaCount(self, count):
|
|
942
|
+
if count < 1:
|
|
943
|
+
count = 1
|
|
944
|
+
self.scalaCount = count
|
|
945
|
+
|
|
946
|
+
if not self.use_timer_event:
|
|
947
|
+
self.update()
|
|
948
|
+
|
|
949
|
+
################################################################################################
|
|
950
|
+
# SET MINIMUM VALUE
|
|
951
|
+
################################################################################################
|
|
952
|
+
def setMinValue(self, min):
|
|
953
|
+
if self.value < min:
|
|
954
|
+
self.value = min
|
|
955
|
+
if min >= self.maxValue:
|
|
956
|
+
self.minValue = self.maxValue - 1
|
|
957
|
+
else:
|
|
958
|
+
self.minValue = min
|
|
959
|
+
|
|
960
|
+
if not self.use_timer_event:
|
|
961
|
+
self.update()
|
|
962
|
+
|
|
963
|
+
################################################################################################
|
|
964
|
+
# SET MAXIMUM VALUE
|
|
965
|
+
################################################################################################
|
|
966
|
+
def setMaxValue(self, max):
|
|
967
|
+
if self.value > max:
|
|
968
|
+
self.value = max
|
|
969
|
+
if max <= self.minValue:
|
|
970
|
+
self.maxValue = self.minValue + 1
|
|
971
|
+
else:
|
|
972
|
+
self.maxValue = max
|
|
973
|
+
|
|
974
|
+
if not self.use_timer_event:
|
|
975
|
+
self.update()
|
|
976
|
+
|
|
977
|
+
################################################################################################
|
|
978
|
+
# SET SCALE ANGLE
|
|
979
|
+
################################################################################################
|
|
980
|
+
def setScaleStartAngle(self, value):
|
|
981
|
+
# Value range in DEG: 0 - 360
|
|
982
|
+
self.scale_angle_start_value = value
|
|
983
|
+
# print("startFill: " + str(self.scale_angle_start_value))
|
|
984
|
+
|
|
985
|
+
if not self.use_timer_event:
|
|
986
|
+
self.update()
|
|
987
|
+
|
|
988
|
+
################################################################################################
|
|
989
|
+
# SET SCALE SIZE
|
|
990
|
+
################################################################################################
|
|
991
|
+
def setTotalScaleAngleSize(self, value):
|
|
992
|
+
self.scale_angle_size = value
|
|
993
|
+
# print("stopFill: " + str(self.scale_angle_size))
|
|
994
|
+
|
|
995
|
+
if not self.use_timer_event:
|
|
996
|
+
self.update()
|
|
997
|
+
|
|
998
|
+
################################################################################################
|
|
999
|
+
# SET GAUGE COLOR OUTER RADIUS
|
|
1000
|
+
################################################################################################
|
|
1001
|
+
def setGaugeColorOuterRadiusFactor(self, value):
|
|
1002
|
+
self.gauge_color_outer_radius_factor = float(value) / 1000
|
|
1003
|
+
# print(self.gauge_color_outer_radius_factor)
|
|
1004
|
+
|
|
1005
|
+
if not self.use_timer_event:
|
|
1006
|
+
self.update()
|
|
1007
|
+
|
|
1008
|
+
################################################################################################
|
|
1009
|
+
# SET GAUGE COLOR INNER RADIUS
|
|
1010
|
+
################################################################################################
|
|
1011
|
+
def setGaugeColorInnerRadiusFactor(self, value):
|
|
1012
|
+
self.gauge_color_inner_radius_factor = float(value) / 1000
|
|
1013
|
+
# print(self.gauge_color_inner_radius_factor)
|
|
1014
|
+
|
|
1015
|
+
if not self.use_timer_event:
|
|
1016
|
+
self.update()
|
|
1017
|
+
|
|
1018
|
+
################################################################################################
|
|
1019
|
+
# SET SCALE POLYGON COLOR
|
|
1020
|
+
################################################################################################
|
|
1021
|
+
def set_scale_polygon_colors(self, color_array):
|
|
1022
|
+
# print(type(color_array))
|
|
1023
|
+
if 'list' in str(type(color_array)):
|
|
1024
|
+
self.scale_polygon_colors = color_array
|
|
1025
|
+
elif color_array == None:
|
|
1026
|
+
self.scale_polygon_colors = [[.0, Qt.transparent]]
|
|
1027
|
+
else:
|
|
1028
|
+
self.scale_polygon_colors = [[.0, Qt.transparent]]
|
|
1029
|
+
|
|
1030
|
+
if not self.use_timer_event:
|
|
1031
|
+
self.update()
|
|
1032
|
+
|
|
1033
|
+
################################################################################################
|
|
1034
|
+
# GET MAXIMUM VALUE
|
|
1035
|
+
################################################################################################
|
|
1036
|
+
def get_value_max(self):
|
|
1037
|
+
return self.maxValue
|
|
1038
|
+
|
|
1039
|
+
###############################################################################################
|
|
1040
|
+
# SCALE PAINTER
|
|
1041
|
+
###############################################################################################
|
|
1042
|
+
|
|
1043
|
+
################################################################################################
|
|
1044
|
+
# CREATE PIE
|
|
1045
|
+
################################################################################################
|
|
1046
|
+
def create_polygon_pie(self, outer_radius, inner_raduis, start, lenght, bar_graph = True):
|
|
1047
|
+
polygon_pie = QPolygonF()
|
|
1048
|
+
# start = self.scale_angle_start_value
|
|
1049
|
+
# start = 0
|
|
1050
|
+
# lenght = self.scale_angle_size
|
|
1051
|
+
# lenght = 180
|
|
1052
|
+
# inner_raduis = self.width()/4
|
|
1053
|
+
# print(start)
|
|
1054
|
+
n = 360 # angle steps size for full circle
|
|
1055
|
+
# changing n value will causes drawing issues
|
|
1056
|
+
w = 360 / n # angle per step
|
|
1057
|
+
# create outer circle line from "start"-angle to "start + lenght"-angle
|
|
1058
|
+
x = 0
|
|
1059
|
+
y = 0
|
|
1060
|
+
|
|
1061
|
+
# todo enable/disable bar graf here
|
|
1062
|
+
if not self.enableBarGraph and bar_graph:
|
|
1063
|
+
# float_value = ((lenght / (self.maxValue - self.minValue)) * (self.value - self.minValue))
|
|
1064
|
+
lenght = int(round((lenght / (self.maxValue - self.minValue)) * (self.value - self.minValue)))
|
|
1065
|
+
# print("f: %s, l: %s" %(float_value, lenght))
|
|
1066
|
+
pass
|
|
1067
|
+
|
|
1068
|
+
# mymax = 0
|
|
1069
|
+
|
|
1070
|
+
for i in range(lenght+1): # add the points of polygon
|
|
1071
|
+
t = w * i + start - self.angle_offset
|
|
1072
|
+
x = outer_radius * math.cos(math.radians(t))
|
|
1073
|
+
y = outer_radius * math.sin(math.radians(t))
|
|
1074
|
+
polygon_pie.append(QPointF(x, y))
|
|
1075
|
+
# create inner circle line from "start + lenght"-angle to "start"-angle
|
|
1076
|
+
for i in range(lenght+1): # add the points of polygon
|
|
1077
|
+
# print("2 " + str(i))
|
|
1078
|
+
t = w * (lenght - i) + start - self.angle_offset
|
|
1079
|
+
x = inner_raduis * math.cos(math.radians(t))
|
|
1080
|
+
y = inner_raduis * math.sin(math.radians(t))
|
|
1081
|
+
polygon_pie.append(QPointF(x, y))
|
|
1082
|
+
|
|
1083
|
+
# close outer line
|
|
1084
|
+
polygon_pie.append(QPointF(x, y))
|
|
1085
|
+
return polygon_pie
|
|
1086
|
+
|
|
1087
|
+
def draw_filled_polygon(self, outline_pen_with=0):
|
|
1088
|
+
if not self.scale_polygon_colors == None:
|
|
1089
|
+
painter_filled_polygon = QPainter(self)
|
|
1090
|
+
painter_filled_polygon.setRenderHint(QPainter.Antialiasing)
|
|
1091
|
+
# Koordinatenursprung in die Mitte der Flaeche legen
|
|
1092
|
+
painter_filled_polygon.translate(self.width() / 2, self.height() / 2)
|
|
1093
|
+
|
|
1094
|
+
painter_filled_polygon.setPen(Qt.NoPen)
|
|
1095
|
+
|
|
1096
|
+
self.pen.setWidth(outline_pen_with)
|
|
1097
|
+
if outline_pen_with > 0:
|
|
1098
|
+
painter_filled_polygon.setPen(self.pen)
|
|
1099
|
+
|
|
1100
|
+
colored_scale_polygon = self.create_polygon_pie(
|
|
1101
|
+
((self.widget_diameter / 2) - (self.pen.width() / 2)) * self.gauge_color_outer_radius_factor,
|
|
1102
|
+
(((self.widget_diameter / 2) - (self.pen.width() / 2)) * self.gauge_color_inner_radius_factor),
|
|
1103
|
+
self.scale_angle_start_value, self.scale_angle_size)
|
|
1104
|
+
|
|
1105
|
+
gauge_rect = QRect(QPoint(0, 0), QSize(self.widget_diameter / 2 - 1, self.widget_diameter - 1))
|
|
1106
|
+
grad = QConicalGradient(QPointF(0, 0), - self.scale_angle_size - self.scale_angle_start_value +
|
|
1107
|
+
self.angle_offset - 1)
|
|
1108
|
+
|
|
1109
|
+
# todo definition scale color as array here
|
|
1110
|
+
for eachcolor in self.scale_polygon_colors:
|
|
1111
|
+
grad.setColorAt(eachcolor[0], eachcolor[1])
|
|
1112
|
+
# grad.setColorAt(.00, Qt.red)
|
|
1113
|
+
# grad.setColorAt(.1, Qt.yellow)
|
|
1114
|
+
# grad.setColorAt(.15, Qt.green)
|
|
1115
|
+
# grad.setColorAt(1, Qt.transparent)
|
|
1116
|
+
# self.brush = QBrush(QColor(255, 0, 255, 255))
|
|
1117
|
+
# grad.setStyle(Qt.Dense6Pattern)
|
|
1118
|
+
# painter_filled_polygon.setBrush(self.brush)
|
|
1119
|
+
painter_filled_polygon.setBrush(grad)
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
painter_filled_polygon.drawPolygon(colored_scale_polygon)
|
|
1123
|
+
# return painter_filled_polygon
|
|
1124
|
+
|
|
1125
|
+
def draw_icon_image(self):
|
|
1126
|
+
pass
|
|
1127
|
+
|
|
1128
|
+
###############################################################################################
|
|
1129
|
+
# BIG SCALE MARKERS
|
|
1130
|
+
###############################################################################################
|
|
1131
|
+
def draw_big_scaled_marker(self):
|
|
1132
|
+
my_painter = QPainter(self)
|
|
1133
|
+
my_painter.setRenderHint(QPainter.Antialiasing)
|
|
1134
|
+
# Koordinatenursprung in die Mitte der Flaeche legen
|
|
1135
|
+
my_painter.translate(self.width() / 2, self.height() / 2)
|
|
1136
|
+
|
|
1137
|
+
# my_painter.setPen(Qt.NoPen)
|
|
1138
|
+
self.pen = QPen(self.bigScaleMarker)
|
|
1139
|
+
self.pen.setWidth(2)
|
|
1140
|
+
# # if outline_pen_with > 0:
|
|
1141
|
+
my_painter.setPen(self.pen)
|
|
1142
|
+
|
|
1143
|
+
my_painter.rotate(self.scale_angle_start_value - self.angle_offset)
|
|
1144
|
+
steps_size = (float(self.scale_angle_size) / float(self.scalaCount))
|
|
1145
|
+
scale_line_outer_start = self.widget_diameter/2
|
|
1146
|
+
scale_line_lenght = (self.widget_diameter / 2) - (self.widget_diameter / 20)
|
|
1147
|
+
# print(stepszize)
|
|
1148
|
+
for i in range(self.scalaCount+1):
|
|
1149
|
+
my_painter.drawLine(scale_line_lenght, 0, scale_line_outer_start, 0)
|
|
1150
|
+
my_painter.rotate(steps_size)
|
|
1151
|
+
|
|
1152
|
+
def create_scale_marker_values_text(self):
|
|
1153
|
+
painter = QPainter(self)
|
|
1154
|
+
# painter.setRenderHint(QPainter.HighQualityAntialiasing)
|
|
1155
|
+
painter.setRenderHint(QPainter.Antialiasing)
|
|
1156
|
+
|
|
1157
|
+
# Koordinatenursprung in die Mitte der Flaeche legen
|
|
1158
|
+
painter.translate(self.width() / 2, self.height() / 2)
|
|
1159
|
+
# painter.save()
|
|
1160
|
+
font = QFont(self.scale_fontname, self.scale_fontsize, QFont.Bold)
|
|
1161
|
+
fm = QFontMetrics(font)
|
|
1162
|
+
|
|
1163
|
+
pen_shadow = QPen()
|
|
1164
|
+
|
|
1165
|
+
pen_shadow.setBrush(self.ScaleValueColor)
|
|
1166
|
+
painter.setPen(pen_shadow)
|
|
1167
|
+
|
|
1168
|
+
text_radius_factor = 0.8
|
|
1169
|
+
text_radius = self.widget_diameter/2 * text_radius_factor
|
|
1170
|
+
|
|
1171
|
+
scale_per_div = int((self.maxValue - self.minValue) / self.scalaCount)
|
|
1172
|
+
|
|
1173
|
+
angle_distance = (float(self.scale_angle_size) / float(self.scalaCount))
|
|
1174
|
+
for i in range(self.scalaCount + 1):
|
|
1175
|
+
# text = str(int((self.maxValue - self.minValue) / self.scalaCount * i))
|
|
1176
|
+
text = str(int(self.minValue + scale_per_div * i))
|
|
1177
|
+
w = fm.width(text) + 1
|
|
1178
|
+
h = fm.height()
|
|
1179
|
+
painter.setFont(QFont(self.scale_fontname, self.scale_fontsize, QFont.Bold))
|
|
1180
|
+
angle = angle_distance * i + float(self.scale_angle_start_value - self.angle_offset)
|
|
1181
|
+
x = text_radius * math.cos(math.radians(angle))
|
|
1182
|
+
y = text_radius * math.sin(math.radians(angle))
|
|
1183
|
+
# print(w, h, x, y, text)
|
|
1184
|
+
|
|
1185
|
+
text = [x - int(w/2), y - int(h/2), int(w), int(h), Qt.AlignCenter, text]
|
|
1186
|
+
painter.drawText(text[0], text[1], text[2], text[3], text[4], text[5])
|
|
1187
|
+
# painter.restore()
|
|
1188
|
+
|
|
1189
|
+
################################################################################################
|
|
1190
|
+
# FINE SCALE MARKERS
|
|
1191
|
+
################################################################################################
|
|
1192
|
+
def create_fine_scaled_marker(self):
|
|
1193
|
+
# Description_dict = 0
|
|
1194
|
+
my_painter = QPainter(self)
|
|
1195
|
+
|
|
1196
|
+
my_painter.setRenderHint(QPainter.Antialiasing)
|
|
1197
|
+
# Koordinatenursprung in die Mitte der Flaeche legen
|
|
1198
|
+
my_painter.translate(self.width() / 2, self.height() / 2)
|
|
1199
|
+
|
|
1200
|
+
my_painter.setPen(self.fineScaleColor)
|
|
1201
|
+
my_painter.rotate(self.scale_angle_start_value - self.angle_offset)
|
|
1202
|
+
steps_size = (float(self.scale_angle_size) / float(self.scalaCount * self.scala_subdiv_count))
|
|
1203
|
+
scale_line_outer_start = self.widget_diameter/2
|
|
1204
|
+
scale_line_lenght = (self.widget_diameter / 2) - (self.widget_diameter / 40)
|
|
1205
|
+
for i in range((self.scalaCount * self.scala_subdiv_count)+1):
|
|
1206
|
+
my_painter.drawLine(scale_line_lenght, 0, scale_line_outer_start, 0)
|
|
1207
|
+
my_painter.rotate(steps_size)
|
|
1208
|
+
|
|
1209
|
+
################################################################################################
|
|
1210
|
+
# VALUE TEXT
|
|
1211
|
+
################################################################################################
|
|
1212
|
+
def create_values_text(self):
|
|
1213
|
+
painter = QPainter(self)
|
|
1214
|
+
painter.setRenderHint(QPainter.HighQualityAntialiasing)
|
|
1215
|
+
# painter.setRenderHint(QPainter.Antialiasing)
|
|
1216
|
+
|
|
1217
|
+
painter.translate(self.width() / 2, self.height() / 2)
|
|
1218
|
+
# painter.save()
|
|
1219
|
+
# xShadow = 3.0
|
|
1220
|
+
# yShadow = 3.0
|
|
1221
|
+
font = QFont(self.value_fontname, self.value_fontsize, QFont.Bold)
|
|
1222
|
+
fm = QFontMetrics(font)
|
|
1223
|
+
|
|
1224
|
+
pen_shadow = QPen()
|
|
1225
|
+
|
|
1226
|
+
pen_shadow.setBrush(self.DisplayValueColor)
|
|
1227
|
+
painter.setPen(pen_shadow)
|
|
1228
|
+
|
|
1229
|
+
text_radius = self.widget_diameter / 2 * self.text_radius_factor
|
|
1230
|
+
|
|
1231
|
+
# angle_distance = (float(self.scale_angle_size) / float(self.scalaCount))
|
|
1232
|
+
# for i in range(self.scalaCount + 1):
|
|
1233
|
+
text = str(int(self.value))
|
|
1234
|
+
w = fm.width(text) + 1
|
|
1235
|
+
h = fm.height()
|
|
1236
|
+
painter.setFont(QFont(self.value_fontname, self.value_fontsize, QFont.Bold))
|
|
1237
|
+
|
|
1238
|
+
# Mitte zwischen Skalenstart und Skalenende:
|
|
1239
|
+
# Skalenende = Skalenanfang - 360 + Skalenlaenge
|
|
1240
|
+
# Skalenmitte = (Skalenende - Skalenanfang) / 2 + Skalenanfang
|
|
1241
|
+
angle_end = float(self.scale_angle_start_value + self.scale_angle_size - 360)
|
|
1242
|
+
angle = (angle_end - self.scale_angle_start_value) / 2 + self.scale_angle_start_value
|
|
1243
|
+
|
|
1244
|
+
x = text_radius * math.cos(math.radians(angle))
|
|
1245
|
+
y = text_radius * math.sin(math.radians(angle))
|
|
1246
|
+
# print(w, h, x, y, text)
|
|
1247
|
+
text = [x - int(w/2), y - int(h/2), int(w), int(h), Qt.AlignCenter, text]
|
|
1248
|
+
painter.drawText(text[0], text[1], text[2], text[3], text[4], text[5])
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
################################################################################################
|
|
1252
|
+
# UNITS TEXT
|
|
1253
|
+
################################################################################################
|
|
1254
|
+
def create_units_text(self):
|
|
1255
|
+
painter = QPainter(self)
|
|
1256
|
+
painter.setRenderHint(QPainter.HighQualityAntialiasing)
|
|
1257
|
+
# painter.setRenderHint(QPainter.Antialiasing)
|
|
1258
|
+
|
|
1259
|
+
painter.translate(self.width() / 2, self.height() / 2)
|
|
1260
|
+
font = QFont(self.value_fontname, int(self.value_fontsize / 2.5), QFont.Bold)
|
|
1261
|
+
fm = QFontMetrics(font)
|
|
1262
|
+
|
|
1263
|
+
pen_shadow = QPen()
|
|
1264
|
+
|
|
1265
|
+
pen_shadow.setBrush(self.DisplayValueColor)
|
|
1266
|
+
painter.setPen(pen_shadow)
|
|
1267
|
+
|
|
1268
|
+
text_radius = self.widget_diameter / 2 * self.text_radius_factor
|
|
1269
|
+
|
|
1270
|
+
text = str(self.units)
|
|
1271
|
+
w = fm.width(text) + 1
|
|
1272
|
+
h = fm.height()
|
|
1273
|
+
painter.setFont(QFont(self.value_fontname, int(self.value_fontsize / 2.5), QFont.Bold))
|
|
1274
|
+
|
|
1275
|
+
|
|
1276
|
+
angle_end = float(self.scale_angle_start_value + self.scale_angle_size + 180)
|
|
1277
|
+
angle = (angle_end - self.scale_angle_start_value) / 2 + self.scale_angle_start_value
|
|
1278
|
+
|
|
1279
|
+
x = text_radius * math.cos(math.radians(angle))
|
|
1280
|
+
y = text_radius * math.sin(math.radians(angle))
|
|
1281
|
+
# print(w, h, x, y, text)
|
|
1282
|
+
text = [x - int(w/2), y - int(h/2), int(w), int(h), Qt.AlignCenter, text]
|
|
1283
|
+
painter.drawText(text[0], text[1], text[2], text[3], text[4], text[5])
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
################################################################################################
|
|
1287
|
+
# CENTER POINTER
|
|
1288
|
+
################################################################################################
|
|
1289
|
+
def draw_big_needle_center_point(self, diameter=30):
|
|
1290
|
+
painter = QPainter(self)
|
|
1291
|
+
# painter.setRenderHint(QtGui.QPainter.HighQualityAntialiasing)
|
|
1292
|
+
painter.setRenderHint(QPainter.Antialiasing)
|
|
1293
|
+
|
|
1294
|
+
# Koordinatenursprung in die Mitte der Flaeche legen
|
|
1295
|
+
painter.translate(self.width() / 2, self.height() / 2)
|
|
1296
|
+
painter.setPen(Qt.NoPen)
|
|
1297
|
+
# painter.setPen(Qt.NoPen)
|
|
1298
|
+
|
|
1299
|
+
# painter.setBrush(self.CenterPointColor)
|
|
1300
|
+
# diameter = diameter # self.widget_diameter/6
|
|
1301
|
+
# painter.drawEllipse(int(-diameter / 2), int(-diameter / 2), int(diameter), int(diameter))
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
# create_polygon_pie(self, outer_radius, inner_raduis, start, lenght)
|
|
1305
|
+
colored_scale_polygon = self.create_polygon_pie(
|
|
1306
|
+
((self.widget_diameter / 8) - (self.pen.width() / 2)),
|
|
1307
|
+
0,
|
|
1308
|
+
self.scale_angle_start_value, 360, False)
|
|
1309
|
+
|
|
1310
|
+
# 150.0 0.0 131 360
|
|
1311
|
+
|
|
1312
|
+
grad = QConicalGradient(QPointF(0, 0), 0)
|
|
1313
|
+
|
|
1314
|
+
# todo definition scale color as array here
|
|
1315
|
+
for eachcolor in self.needle_center_bg:
|
|
1316
|
+
grad.setColorAt(eachcolor[0], eachcolor[1])
|
|
1317
|
+
# grad.setColorAt(.00, Qt.red)
|
|
1318
|
+
# grad.setColorAt(.1, Qt.yellow)
|
|
1319
|
+
# grad.setColorAt(.15, Qt.green)
|
|
1320
|
+
# grad.setColorAt(1, Qt.transparent)
|
|
1321
|
+
painter.setBrush(grad)
|
|
1322
|
+
# self.brush = QBrush(QColor(255, 0, 255, 255))
|
|
1323
|
+
# painter_filled_polygon.setBrush(self.brush)
|
|
1324
|
+
|
|
1325
|
+
painter.drawPolygon(colored_scale_polygon)
|
|
1326
|
+
# return painter_filled_polygon
|
|
1327
|
+
|
|
1328
|
+
################################################################################################
|
|
1329
|
+
# CREATE OUTER COVER
|
|
1330
|
+
################################################################################################
|
|
1331
|
+
def draw_outer_circle(self, diameter=30):
|
|
1332
|
+
painter = QPainter(self)
|
|
1333
|
+
painter.setRenderHint(QPainter.Antialiasing)
|
|
1334
|
+
|
|
1335
|
+
painter.translate(self.width() / 2, self.height() / 2)
|
|
1336
|
+
painter.setPen(Qt.NoPen)
|
|
1337
|
+
colored_scale_polygon = self.create_polygon_pie(
|
|
1338
|
+
((self.widget_diameter / 2) - (self.pen.width())),
|
|
1339
|
+
(self.widget_diameter / 6),
|
|
1340
|
+
self.scale_angle_start_value / 10, 360, False)
|
|
1341
|
+
|
|
1342
|
+
radialGradient = QRadialGradient(QPointF(0, 0), self.width())
|
|
1343
|
+
|
|
1344
|
+
for eachcolor in self.outer_circle_bg:
|
|
1345
|
+
radialGradient.setColorAt(eachcolor[0], eachcolor[1])
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
painter.setBrush(radialGradient)
|
|
1349
|
+
|
|
1350
|
+
painter.drawPolygon(colored_scale_polygon)
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
################################################################################################
|
|
1354
|
+
# NEEDLE POINTER
|
|
1355
|
+
################################################################################################
|
|
1356
|
+
def draw_needle(self):
|
|
1357
|
+
painter = QPainter(self)
|
|
1358
|
+
# painter.setRenderHint(QtGui.QPainter.HighQualityAntialiasing)
|
|
1359
|
+
painter.setRenderHint(QPainter.Antialiasing)
|
|
1360
|
+
# Koordinatenursprung in die Mitte der Flaeche legen
|
|
1361
|
+
painter.translate(self.width() / 2, self.height() / 2)
|
|
1362
|
+
painter.setPen(Qt.NoPen)
|
|
1363
|
+
painter.setBrush(self.NeedleColor)
|
|
1364
|
+
painter.rotate(((self.value - self.value_offset - self.minValue) * self.scale_angle_size /
|
|
1365
|
+
(self.maxValue - self.minValue)) + 90 + self.scale_angle_start_value)
|
|
1366
|
+
|
|
1367
|
+
painter.drawConvexPolygon(self.value_needle[0])
|
|
1368
|
+
|
|
1369
|
+
###############################################################################################
|
|
1370
|
+
# EVENTS
|
|
1371
|
+
###############################################################################################
|
|
1372
|
+
|
|
1373
|
+
################################################################################################
|
|
1374
|
+
# ON WINDOW RESIZE
|
|
1375
|
+
################################################################################################
|
|
1376
|
+
def resizeEvent(self, event):
|
|
1377
|
+
# self.resized.emit()
|
|
1378
|
+
# return super(self.parent, self).resizeEvent(event)
|
|
1379
|
+
# print("resized")
|
|
1380
|
+
# print(self.width())
|
|
1381
|
+
self.rescale_method()
|
|
1382
|
+
# self.emit(QtCore.SIGNAL("resize()"))
|
|
1383
|
+
# print("resizeEvent")
|
|
1384
|
+
|
|
1385
|
+
################################################################################################
|
|
1386
|
+
# ON PAINT EVENT
|
|
1387
|
+
################################################################################################
|
|
1388
|
+
def paintEvent(self, event):
|
|
1389
|
+
# Main Drawing Event:
|
|
1390
|
+
# Will be executed on every change
|
|
1391
|
+
# vgl http://doc.qt.io/qt-4.8/qt-demos-affine-xform-cpp.html
|
|
1392
|
+
# print("event", event)
|
|
1393
|
+
|
|
1394
|
+
self.draw_outer_circle()
|
|
1395
|
+
self.draw_icon_image()
|
|
1396
|
+
# colored pie area
|
|
1397
|
+
if self.enable_filled_Polygon:
|
|
1398
|
+
self.draw_filled_polygon()
|
|
1399
|
+
|
|
1400
|
+
# draw scale marker lines
|
|
1401
|
+
if self.enable_fine_scaled_marker:
|
|
1402
|
+
self.create_fine_scaled_marker()
|
|
1403
|
+
if self.enable_big_scaled_marker:
|
|
1404
|
+
self.draw_big_scaled_marker()
|
|
1405
|
+
|
|
1406
|
+
# draw scale marker value text
|
|
1407
|
+
if self.enable_scale_text:
|
|
1408
|
+
self.create_scale_marker_values_text()
|
|
1409
|
+
|
|
1410
|
+
# Display Value
|
|
1411
|
+
if self.enable_value_text:
|
|
1412
|
+
self.create_values_text()
|
|
1413
|
+
self.create_units_text()
|
|
1414
|
+
|
|
1415
|
+
# draw needle 1
|
|
1416
|
+
if self.enable_Needle_Polygon:
|
|
1417
|
+
self.draw_needle()
|
|
1418
|
+
|
|
1419
|
+
# Draw Center Point
|
|
1420
|
+
if self.enable_CenterPoint:
|
|
1421
|
+
self.draw_big_needle_center_point(diameter=(self.widget_diameter / 6))
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
###############################################################################################
|
|
1425
|
+
# MOUSE EVENTS
|
|
1426
|
+
###############################################################################################
|
|
1427
|
+
|
|
1428
|
+
def setMouseTracking(self, flag):
|
|
1429
|
+
def recursive_set(parent):
|
|
1430
|
+
for child in parent.findChildren(QObject):
|
|
1431
|
+
try:
|
|
1432
|
+
child.setMouseTracking(flag)
|
|
1433
|
+
except:
|
|
1434
|
+
pass
|
|
1435
|
+
recursive_set(child)
|
|
1436
|
+
|
|
1437
|
+
QWidget.setMouseTracking(self, flag)
|
|
1438
|
+
recursive_set(self)
|
|
1439
|
+
|
|
1440
|
+
def mouseReleaseEvent(self, QMouseEvent):
|
|
1441
|
+
self.NeedleColor = self.NeedleColorReleased
|
|
1442
|
+
|
|
1443
|
+
if not self.use_timer_event:
|
|
1444
|
+
self.update()
|
|
1445
|
+
pass
|
|
1446
|
+
|
|
1447
|
+
########################################################################
|
|
1448
|
+
## MOUSE LEAVE EVENT
|
|
1449
|
+
########################################################################
|
|
1450
|
+
def leaveEvent(self, event):
|
|
1451
|
+
self.NeedleColor = self.NeedleColorReleased
|
|
1452
|
+
self.update()
|
|
1453
|
+
|
|
1454
|
+
def mouseMoveEvent(self, event):
|
|
1455
|
+
x, y = event.x() - (self.width() / 2), event.y() - (self.height() / 2)
|
|
1456
|
+
# print(event.x(), event.y(), self.width(), self.height())
|
|
1457
|
+
if not x == 0:
|
|
1458
|
+
angle = math.atan2(y, x) / math.pi * 180
|
|
1459
|
+
# winkellaenge der anzeige immer positiv 0 - 360deg
|
|
1460
|
+
# min wert + umskalierter wert
|
|
1461
|
+
value = (float(math.fmod(angle - self.scale_angle_start_value + 720, 360)) / \
|
|
1462
|
+
(float(self.scale_angle_size) / float(self.maxValue - self.minValue))) + self.minValue
|
|
1463
|
+
temp = value
|
|
1464
|
+
fmod = float(math.fmod(angle - self.scale_angle_start_value + 720, 360))
|
|
1465
|
+
state = 0
|
|
1466
|
+
if (self.value - (self.maxValue - self.minValue) * self.valueNeedleSnapzone) <= \
|
|
1467
|
+
value <= \
|
|
1468
|
+
(self.value + (self.maxValue - self.minValue) * self.valueNeedleSnapzone):
|
|
1469
|
+
self.NeedleColor = self.NeedleColorDrag
|
|
1470
|
+
# todo: evtl ueberpruefen
|
|
1471
|
+
#
|
|
1472
|
+
state = 9
|
|
1473
|
+
# if value >= self.maxValue and self.last_value < (self.maxValue - self.minValue) / 2:
|
|
1474
|
+
if value >= self.maxValue and self.last_value < (self.maxValue - self.minValue) / 2:
|
|
1475
|
+
state = 1
|
|
1476
|
+
value = self.maxValue
|
|
1477
|
+
self.last_value = self.minValue
|
|
1478
|
+
self.valueChanged.emit(int(value))
|
|
1479
|
+
|
|
1480
|
+
elif value >= self.maxValue >= self.last_value:
|
|
1481
|
+
state = 2
|
|
1482
|
+
value = self.maxValue
|
|
1483
|
+
self.last_value = self.maxValue
|
|
1484
|
+
self.valueChanged.emit(int(value))
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
else:
|
|
1488
|
+
state = 3
|
|
1489
|
+
self.last_value = value
|
|
1490
|
+
self.valueChanged.emit(int(value))
|
|
1491
|
+
|
|
1492
|
+
self.updateValue(value)
|
|
1493
|
+
|
|
1494
|
+
################################################################################################
|
|
1495
|
+
# END ==>
|
|
1496
|
+
################################################################################################
|