Inst*: proportions fix (audit Dec 2026) — worst offenders + level gauges
Seg14/16 + LedDigits fill widget (dark face so dim segments read faint, diagonals thinned); DigitalReadout off-segments slightly more visible; dial numerals 7-8% of diameter bold just inside the tick ring with titles inside below top numerals; NeedleVu numerals 4% of width bold, red in red zone, VU below arc centre; tank scale 16 / alarms 14 bold / % 18 bold with clearance; horizontal tank capsule ends inside widget with alarm labels above; sight-glass tube widened; KeySwitch NO KEY light-on-dark with position numerals, slot at the current position; Nameplate engraving fit to 45% of plate width. Scaled-font helpers _cap_size/_fs/_fit_size (cap-height convention, as C inst_cap_font).
This commit is contained in:
1 parent
03065d35bf
commit
80a1698f7a
1 file changed
+269
-80
+269
-80
@@ -20,6 +20,7 @@ import math
|
||||
|
||||
from lightgui.xframe.core import (
|
||||
Widget,
|
||||
_apply_font,
|
||||
parse_color,
|
||||
_bg,
|
||||
_box,
|
||||
@@ -131,6 +132,36 @@ def _brightness(widget):
|
||||
return max(0, min(100, _prop_int(widget, "brightness", 100)))
|
||||
|
||||
|
||||
# --- proportions fix (Dec 2026 audit, G1-G7) ---------------------------------
|
||||
# Text scales from the widget's drawn size, mirroring the C
|
||||
# inst_cap_font helpers (cap-height convention: a Cairo Sans bold
|
||||
# cap is ~0.72 of the em size). Audit sizes are cap heights at the
|
||||
# C demo scale (600 px tall window): dial numerals 7-8% of dial
|
||||
# diameter, scale labels 16 px, titles 16-20 px, state labels
|
||||
# 14-16 px, values 18 px. Fractions below are those sizes / 600.
|
||||
|
||||
def _cap_size(cap):
|
||||
"""Cairo font size (em) for a target cap height in px."""
|
||||
return max(4.0, cap / 0.72)
|
||||
|
||||
|
||||
def _fs(frac, dim):
|
||||
"""Font size for text whose cap height is frac of dim."""
|
||||
return _cap_size(frac * dim)
|
||||
|
||||
|
||||
def _fit_size(cr, widget, text, target_w, size, bold=True):
|
||||
"""Shrink *size* so *text* fits *target_w* (nameplate rule:
|
||||
engraving fills 40-50% of the plate width)."""
|
||||
cr.save()
|
||||
_apply_font(cr, widget, size=size, bold=bold)
|
||||
w = cr.text_extents(text)[2]
|
||||
cr.restore()
|
||||
if w > 0:
|
||||
size = size * target_w / w
|
||||
return max(4.0, size)
|
||||
|
||||
|
||||
def _screw(cr, x, y, r=4):
|
||||
"""One panel screw: grey disc + dark slot."""
|
||||
cr.save()
|
||||
@@ -188,7 +219,13 @@ def _draw_dial(cr, widget, red_from=None, unit="", fmt="%.0f"):
|
||||
cr.arc(cx, cy, r - 6, _dial_angle(red_from),
|
||||
_dial_angle(1.0))
|
||||
cr.stroke()
|
||||
# Ticks + numbers.
|
||||
# Ticks + numbers (audit G1: numerals 7-8% of dial diameter,
|
||||
# bold, just inside the tick ring).
|
||||
num_cap = 0.075 * 2 * r
|
||||
num_size = _cap_size(num_cap)
|
||||
# Numeral centre radius mirrors C (R - numCap - 12): the glyph
|
||||
# tops clear the tick ring instead of touching the rim.
|
||||
num_r = r - num_cap - 12
|
||||
for i in range(11):
|
||||
f = i / 10.0
|
||||
angle = _dial_angle(f)
|
||||
@@ -205,10 +242,11 @@ def _draw_dial(cr, widget, red_from=None, unit="", fmt="%.0f"):
|
||||
if major:
|
||||
value = lo + f * (hi - lo)
|
||||
label = fmt % value
|
||||
tx = cx + (r - 24) * math.cos(angle)
|
||||
ty = cy + (r - 24) * math.sin(angle)
|
||||
_wtext(cr, widget, label, tx, ty + 4, size=11,
|
||||
rgb=ink, align="center", max_width=44)
|
||||
tx = cx + num_r * math.cos(angle)
|
||||
ty = cy + num_r * math.sin(angle)
|
||||
_wtext(cr, widget, label, tx, ty + num_cap * 0.35,
|
||||
size=num_size, bold=True,
|
||||
rgb=ink, align="center", max_width=2 * num_r)
|
||||
# Needle.
|
||||
angle = _dial_angle(frac)
|
||||
width = _prop_int(widget, "needle-line-width", 3)
|
||||
@@ -225,11 +263,14 @@ def _draw_dial(cr, widget, red_from=None, unit="", fmt="%.0f"):
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
label = (fmt % _value(widget)) + (" " + unit if unit else "")
|
||||
_wtext(cr, widget, label, cx, cy + r * 0.55 + 6, size=12,
|
||||
_wtext(cr, widget, label, cx, cy + r * 0.55 + 6,
|
||||
size=_fs(0.030, h),
|
||||
rgb=ink, align="center", bold=True, max_width=w - 16)
|
||||
if widget.text != widget.name:
|
||||
_wtext(cr, widget, widget.text, cx, cy - r * 0.55, size=11,
|
||||
rgb=ink, align="center", max_width=w - 16)
|
||||
# Title inside the dial, below the top numerals (audit G3).
|
||||
_wtext(cr, widget, widget.text, cx, cy - r * 0.55,
|
||||
size=_fs(0.028, h),
|
||||
rgb=ink, align="center", bold=True, max_width=w - 16)
|
||||
cr.restore()
|
||||
|
||||
|
||||
@@ -295,16 +336,25 @@ def _draw_bar_meter(cr, widget):
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
lo, hi = _range(widget)
|
||||
scale_cap = 0.027 * h
|
||||
scale_size = _cap_size(scale_cap)
|
||||
for i in range(6):
|
||||
f = i / 5.0
|
||||
label = "%.0f" % (lo + f * (hi - lo))
|
||||
if horizontal:
|
||||
_wtext(cr, widget, label, x0 + f * bw, y0 + bh + 14,
|
||||
size=10, rgb=ink, align="center", max_width=36)
|
||||
size=scale_size, bold=True, rgb=ink, align="center",
|
||||
max_width=36)
|
||||
else:
|
||||
_wtext(cr, widget, label, x0 - 4, y0 + bh - f * bh + 4,
|
||||
size=10, rgb=ink, align="right", max_width=26)
|
||||
_wtext(cr, widget, "%.1f" % _value(widget), w / 2, h - 4, size=12,
|
||||
# Top label inset clear of the border (audit G7).
|
||||
ly = y0 + bh - f * bh + scale_cap * 0.35
|
||||
if i == 5:
|
||||
ly = y0 + scale_cap + 2
|
||||
_wtext(cr, widget, label, x0 - 4, ly,
|
||||
size=scale_size, bold=True, rgb=ink, align="right",
|
||||
max_width=40)
|
||||
_wtext(cr, widget, "%.1f" % _value(widget), w / 2, h - 4,
|
||||
size=_fs(0.030, h),
|
||||
rgb=ink, align="center", bold=True, max_width=w - 8)
|
||||
|
||||
|
||||
@@ -345,14 +395,15 @@ def _draw_flow_meter(cr, widget):
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
lo, hi = _range(widget)
|
||||
scale_size = _fs(0.027, h)
|
||||
for i in range(6):
|
||||
f = i / 5.0
|
||||
y = bot_y - f * (bot_y - top_y)
|
||||
_wtext(cr, widget, "%.0f" % (lo + f * (hi - lo)),
|
||||
cx - bot_w / 2 - 4, y + 4, size=10, rgb=ink,
|
||||
align="right", max_width=30)
|
||||
cx - bot_w / 2 - 4, y + 4, size=scale_size, bold=True,
|
||||
rgb=ink, align="right", max_width=44)
|
||||
_wtext(cr, widget, "%.0f L/min" % _value(widget), cx, h - 8,
|
||||
size=12, rgb=ink, align="center", bold=True,
|
||||
size=_fs(0.030, h), rgb=ink, align="center", bold=True,
|
||||
max_width=w - 8)
|
||||
|
||||
|
||||
@@ -402,9 +453,10 @@ def _draw_manometer(cr, widget):
|
||||
f = i / 4.0
|
||||
y = top + f * (bot - top)
|
||||
_wtext(cr, widget, "%+.0f" % (lo + f * (hi - lo)),
|
||||
left_x - tube_w / 2 - 4, y + 4, size=10, rgb=ink,
|
||||
align="right", max_width=34)
|
||||
_wtext(cr, widget, "%.1f mm" % value, w / 2, h - 8, size=12,
|
||||
left_x - tube_w / 2 - 4, y + 4, size=_fs(0.027, h),
|
||||
bold=True, rgb=ink, align="right", max_width=48)
|
||||
_wtext(cr, widget, "%.1f mm" % value, w / 2, h - 8,
|
||||
size=_fs(0.030, h),
|
||||
rgb=ink, align="center", bold=True, max_width=w - 8)
|
||||
|
||||
|
||||
@@ -449,7 +501,22 @@ def _draw_needle_tapered(cr, widget):
|
||||
cr.arc(cx, cy, 4, 0, 2 * math.pi)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
_wtext(cr, widget, "%.1f" % _value(widget), cx, h - 8, size=12,
|
||||
# Audit G1: numerals 7-8% of dial diameter, bold, just inside
|
||||
# the tick ring (mirrors the C dial numerals).
|
||||
lo, hi = _range(widget)
|
||||
num_cap = 0.075 * 2 * r
|
||||
num_r = r - num_cap - 12
|
||||
for i in range(0, 11, 5):
|
||||
f = i / 10.0
|
||||
a = _dial_angle(f)
|
||||
tx = cx + num_r * math.cos(a)
|
||||
ty = cy + num_r * math.sin(a)
|
||||
_wtext(cr, widget, "%.0f" % (lo + f * (hi - lo)), tx,
|
||||
ty + num_cap * 0.35, size=_cap_size(num_cap),
|
||||
bold=True, rgb=ink, align="center",
|
||||
max_width=2 * num_r)
|
||||
_wtext(cr, widget, "%.1f" % _value(widget), cx, h - 8,
|
||||
size=_fs(0.030, h),
|
||||
rgb=ink, align="center", bold=True, max_width=w - 8)
|
||||
|
||||
|
||||
@@ -493,12 +560,16 @@ def _draw_needle_knife(cr, widget):
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
lo, hi = _range(widget)
|
||||
num_cap = 0.030 * bw
|
||||
num_size = _cap_size(num_cap)
|
||||
for i in range(6):
|
||||
f = i / 5.0
|
||||
x = x0 + 8 + f * (bw - 16)
|
||||
_wtext(cr, widget, "%.0f" % (lo + f * (hi - lo)), x,
|
||||
y0 + 14, size=10, rgb=ink, align="center", max_width=36)
|
||||
_wtext(cr, widget, "%.1f" % _value(widget), w / 2, h - 8, size=12,
|
||||
y0 + 14 + num_cap * 0.35, size=num_size, bold=True,
|
||||
rgb=ink, align="center", max_width=48)
|
||||
_wtext(cr, widget, "%.1f" % _value(widget), w / 2, h - 8,
|
||||
size=_fs(0.030, h),
|
||||
rgb=ink, align="center", bold=True, max_width=w - 8)
|
||||
|
||||
|
||||
@@ -516,7 +587,8 @@ def _draw_needle_edgewise(cr, widget):
|
||||
return
|
||||
_box(cr, x0, y0, bw, bh, face, ink)
|
||||
frac = _frac(widget)
|
||||
pivot_x, pivot_y = x0 + bw / 2, y0 + bh + 6
|
||||
# Audit: pivot attached to the scale (was 6 px below the box).
|
||||
pivot_x, pivot_y = x0 + bw / 2, y0 + bh
|
||||
# Edgewise: the needle sweeps a shallow arc; the scale is a
|
||||
# horizontal band with a red zone at the right end.
|
||||
cr.save()
|
||||
@@ -528,6 +600,8 @@ def _draw_needle_edgewise(cr, widget):
|
||||
_rgb(cr, tick)
|
||||
cr.set_line_width(1)
|
||||
lo, hi = _range(widget)
|
||||
num_cap = 0.030 * bw
|
||||
num_size = _cap_size(num_cap)
|
||||
for i in range(11):
|
||||
f = i / 10.0
|
||||
x = x0 + 6 + f * (bw - 12)
|
||||
@@ -535,8 +609,8 @@ def _draw_needle_edgewise(cr, widget):
|
||||
cr.line_to(x, y0 + 14 if i % 5 == 0 else y0 + 10)
|
||||
if i % 5 == 0:
|
||||
_wtext(cr, widget, "%.0f" % (lo + f * (hi - lo)), x,
|
||||
y0 + 28, size=10, rgb=ink, align="center",
|
||||
max_width=36)
|
||||
y0 + 28 + num_cap * 0.35, size=num_size, bold=True,
|
||||
rgb=ink, align="center", max_width=56)
|
||||
cr.stroke()
|
||||
_rgb(cr, needle)
|
||||
cr.set_line_width(2)
|
||||
@@ -548,7 +622,8 @@ def _draw_needle_edgewise(cr, widget):
|
||||
cr.arc(pivot_x, pivot_y, 4, 0, 2 * math.pi)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
_wtext(cr, widget, "%.1f" % _value(widget), w / 2, h - 8, size=12,
|
||||
_wtext(cr, widget, "%.1f" % _value(widget), w / 2, h - 8,
|
||||
size=_fs(0.030, h),
|
||||
rgb=ink, align="center", bold=True, max_width=w - 8)
|
||||
|
||||
|
||||
@@ -574,6 +649,9 @@ def _draw_needle_vu(cr, widget):
|
||||
_rgb(cr, ink)
|
||||
cr.set_line_width(1)
|
||||
lo, hi = _range(widget)
|
||||
# Audit G1: numerals 4% of width, bold, red in the red zone.
|
||||
num_cap = 0.040 * w
|
||||
num_size = _cap_size(num_cap)
|
||||
for i in range(11):
|
||||
f = i / 10.0
|
||||
angle = math.pi * (1.25 + 0.5 * f)
|
||||
@@ -587,9 +665,11 @@ def _draw_needle_vu(cr, widget):
|
||||
if i % 5 == 0:
|
||||
tx = pivot_x + (r0 + 16) * math.cos(angle)
|
||||
ty = pivot_y + (r0 + 16) * math.sin(angle)
|
||||
_wtext(cr, widget, "%+.0f" % (lo + f * (hi - lo)), tx,
|
||||
ty + 4, size=10, rgb=ink, align="center",
|
||||
max_width=36)
|
||||
lab = "%+.0f" % (lo + f * (hi - lo))
|
||||
_wtext(cr, widget, lab, tx, ty + num_cap * 0.35,
|
||||
size=num_size, bold=True,
|
||||
rgb=red if (lo + f * (hi - lo)) >= 0 else ink,
|
||||
align="center", max_width=64)
|
||||
cr.stroke()
|
||||
angle = math.pi * (1.25 + 0.5 * frac)
|
||||
_rgb(cr, needle)
|
||||
@@ -602,8 +682,14 @@ def _draw_needle_vu(cr, widget):
|
||||
cr.arc(pivot_x, pivot_y, 4, 0, 2 * math.pi)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
_wtext(cr, widget, "VU %.1f" % _value(widget), w / 2, h - 8,
|
||||
size=12, rgb=ink, align="center", bold=True,
|
||||
# "VU" below the arc centre, clear of the numerals (audit G2:
|
||||
# no class-name caption on the scale).
|
||||
_wtext(cr, widget, "VU", w / 2, y0 + bh * 0.68,
|
||||
size=_fs(0.033, h), rgb=ink, align="center", bold=True,
|
||||
max_width=w - 8)
|
||||
_wtext(cr, widget, "%.1f" % _value(widget), w / 2, h - 8,
|
||||
size=_fs(0.030, h),
|
||||
rgb=ink, align="center", bold=True,
|
||||
max_width=w - 8)
|
||||
|
||||
|
||||
@@ -626,12 +712,21 @@ def _tank_colours(widget):
|
||||
}
|
||||
|
||||
|
||||
def _alarm_lines(cr, widget, x, top, bottom, vertical=False):
|
||||
"""Alarm markers: hi-hi/hi/lo/lo-lo (red/amber/amber/red)."""
|
||||
def _alarm_lines(cr, widget, x, top, bottom, vertical=False,
|
||||
labels=True):
|
||||
"""Alarm markers: hi-hi/hi/lo/lo-lo (red/amber/amber/red).
|
||||
With labels, the word labels sit right of each line (audit:
|
||||
alarm labels 14 px bold) -- callers must leave room on the
|
||||
right; pass labels=False where a legend already names them."""
|
||||
cols = _tank_colours(widget)
|
||||
hi_hi, hi, lo, lo_lo = _alarms(widget)
|
||||
for level, colour in ((hi_hi, cols["red"]), (hi, cols["amber"]),
|
||||
(lo, cols["amber"]), (lo_lo, cols["red"])):
|
||||
h = widget.height
|
||||
lab_cap = 0.023 * h
|
||||
lab_size = _cap_size(lab_cap)
|
||||
for level, colour, lab in ((hi_hi, cols["red"], "HI-HI"),
|
||||
(hi, cols["amber"], "HI"),
|
||||
(lo, cols["amber"], "LO"),
|
||||
(lo_lo, cols["red"], "LO-LO")):
|
||||
y = bottom - level / 100.0 * (bottom - top)
|
||||
cr.save()
|
||||
_rgb(cr, colour)
|
||||
@@ -644,10 +739,15 @@ def _alarm_lines(cr, widget, x, top, bottom, vertical=False):
|
||||
cr.line_to(x + 14, y)
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
if labels and not vertical:
|
||||
_wtext(cr, widget, lab, x + 20, y + lab_cap * 0.35,
|
||||
size=lab_size, bold=True, rgb=cols["ink"],
|
||||
max_width=64)
|
||||
|
||||
|
||||
def _tank_readout(cr, widget, level, x, y, align="left"):
|
||||
_wtext(cr, widget, "%.1f%%" % level, x, y, size=13, bold=True,
|
||||
_wtext(cr, widget, "%.1f%%" % level, x, y, size=_fs(0.030, widget.height),
|
||||
bold=True,
|
||||
rgb=(0.12, 0.12, 0.12), align=align,
|
||||
max_width=widget.width - 16)
|
||||
|
||||
@@ -658,7 +758,9 @@ def _draw_vertical_tank(cr, widget):
|
||||
level = _level(widget)
|
||||
w, h = widget.width, widget.height
|
||||
x0, y0 = 24, 16
|
||||
bw, bh = w - 62, h - 36
|
||||
# Narrowed to leave room for the alarm word labels right of
|
||||
# the alarm lines (audit: alarms 14 px bold).
|
||||
bw, bh = w - 116, h - 36
|
||||
if bw <= 0 or bh <= 0:
|
||||
return
|
||||
_box(cr, x0, y0, bw, bh, cols["pale"], cols["ink"])
|
||||
@@ -707,6 +809,17 @@ def _draw_horizontal_tank(cr, widget):
|
||||
cr.line_to(x, y0 + bh)
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
# Alarm word labels above the tank, clear of the capsule ends
|
||||
# (audit: alarms 14 px bold; % clear of the curve, G7).
|
||||
lab_cap = 0.023 * h
|
||||
lab_size = _cap_size(lab_cap)
|
||||
for mark, colour, lab in ((hi_hi, cols["red"], "HI-HI"),
|
||||
(hi, cols["amber"], "HI"),
|
||||
(lo, cols["amber"], "LO"),
|
||||
(lo_lo, cols["red"], "LO-LO")):
|
||||
x = x0 + bw * mark / 100.0
|
||||
_wtext(cr, widget, lab, x, y0 - 4, size=lab_size, bold=True,
|
||||
rgb=cols["ink"], align="center", max_width=44)
|
||||
_tank_readout(cr, widget, level, x0 + bw / 2, h - 6, align="center")
|
||||
|
||||
|
||||
@@ -757,7 +870,8 @@ def _draw_sight_glass(cr, widget):
|
||||
level = _level(widget)
|
||||
w, h = widget.width, widget.height
|
||||
cx = w / 2
|
||||
tube_w = 26
|
||||
# Audit: widen the tube so the fill is visible.
|
||||
tube_w = max(26, int(0.06 * w))
|
||||
x0 = cx - tube_w / 2
|
||||
top, bot = 20, h - 24
|
||||
if bot - top < 10:
|
||||
@@ -772,6 +886,8 @@ def _draw_sight_glass(cr, widget):
|
||||
cr.rectangle(x0 + 2, bot - fill_h, tube_w - 4, fill_h)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
scale_cap = 0.027 * h
|
||||
scale_size = _cap_size(scale_cap)
|
||||
for i in range(11):
|
||||
y = bot - (bot - top) * i / 10.0
|
||||
cr.save()
|
||||
@@ -781,10 +897,11 @@ def _draw_sight_glass(cr, widget):
|
||||
cr.line_to(x0, y)
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
if i % 5 == 0 and i:
|
||||
_wtext(cr, widget, "%d" % (i * 10), x0 - 14, y + 4,
|
||||
size=10, rgb=cols["ink"], align="right",
|
||||
max_width=26)
|
||||
if i % 5 == 0:
|
||||
_wtext(cr, widget, "%d" % (i * 10), x0 - 14,
|
||||
y + scale_cap * 0.35,
|
||||
size=scale_size, bold=True, rgb=cols["ink"],
|
||||
align="right", max_width=40)
|
||||
_alarm_lines(cr, widget, x0 + tube_w + 2, top, bot)
|
||||
_tank_readout(cr, widget, level, cx, h - 6, align="center")
|
||||
|
||||
@@ -814,10 +931,13 @@ def _draw_level_column(cr, widget):
|
||||
cr.rectangle(x0 - 6, float_y - 3, col_w + 12, 6)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
scale_cap = 0.027 * h
|
||||
scale_size = _cap_size(scale_cap)
|
||||
for i in range(11):
|
||||
y = bot - (bot - top) * i / 10.0
|
||||
_wtext(cr, widget, "%d" % (i * 10), x0 - 8, y + 4, size=10,
|
||||
rgb=cols["ink"], align="right", max_width=26)
|
||||
_wtext(cr, widget, "%d" % (i * 10), x0 - 8,
|
||||
y + scale_cap * 0.35, size=scale_size, bold=True,
|
||||
rgb=cols["ink"], align="right", max_width=40)
|
||||
_alarm_lines(cr, widget, x0 + col_w + 2, top, bot)
|
||||
_tank_readout(cr, widget, level, cx + 44, top + 12, align="center")
|
||||
|
||||
@@ -840,16 +960,30 @@ def _draw_level_transmitter(cr, widget):
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
_alarm_lines(cr, widget, x0 + bw + 2, y0, y0 + bh)
|
||||
_wtext(cr, widget, "%.1f%%" % level, x0 + bw + 22, y0 + 14,
|
||||
size=13, bold=True, rgb=(0.12, 0.12, 0.12),
|
||||
max_width=w - x0 - bw - 26)
|
||||
_wtext(cr, widget, "%.2f mA" % ma, x0 + bw + 22, y0 + 32, size=12,
|
||||
rgb=cols["ink"], max_width=w - x0 - bw - 26)
|
||||
# Loop terminals.
|
||||
_box(cr, x0 + bw + 22, y0 + 48, 14, 10, cols["white"], cols["ink"])
|
||||
_box(cr, x0 + bw + 42, y0 + 48, 14, 10, cols["white"], cols["ink"])
|
||||
_wtext(cr, widget, "+ -", x0 + bw + 22, y0 + 72, size=11,
|
||||
rgb=cols["ink"], max_width=40)
|
||||
# Data block right of the alarm labels (audit: 16 px data).
|
||||
data_cap = 0.027 * h
|
||||
data_size = _cap_size(data_cap)
|
||||
dx = x0 + bw + 66
|
||||
_wtext(cr, widget, "%.1f%%" % level, dx, y0 + 14,
|
||||
size=data_size, bold=True, rgb=(0.12, 0.12, 0.12),
|
||||
max_width=w - dx - 4)
|
||||
_wtext(cr, widget, "%.2f mA" % ma, dx, y0 + 32,
|
||||
size=_fs(0.020, h),
|
||||
rgb=cols["ink"], max_width=w - dx - 4)
|
||||
# Loop terminals: (+)(-) buttons, 24 px at demo scale, with
|
||||
# legible signs (audit).
|
||||
btn = max(14.0, 0.040 * h)
|
||||
_box(cr, dx, y0 + 48, btn, btn, cols["white"], cols["ink"])
|
||||
_box(cr, dx + btn + 6, y0 + 48, btn, btn, cols["white"],
|
||||
cols["ink"])
|
||||
btn_cap = 0.023 * h
|
||||
_wtext(cr, widget, "+", dx + btn / 2, y0 + 48 + btn / 2
|
||||
+ btn_cap * 0.35, size=_cap_size(btn_cap), bold=True,
|
||||
rgb=cols["ink"], align="center", max_width=btn)
|
||||
_wtext(cr, widget, "-", dx + btn * 1.5 + 6,
|
||||
y0 + 48 + btn / 2 + btn_cap * 0.35,
|
||||
size=_cap_size(btn_cap), bold=True, rgb=cols["ink"],
|
||||
align="center", max_width=btn)
|
||||
|
||||
|
||||
def _draw_open_channel(cr, widget):
|
||||
@@ -859,8 +993,10 @@ def _draw_open_channel(cr, widget):
|
||||
(20 / 255, 80 / 255, 160 / 255))
|
||||
level = _level(widget)
|
||||
w, h = widget.width, widget.height
|
||||
x0, y0 = 16, 16
|
||||
bw, bh = w - 48, h - 40
|
||||
# Left margin widened so the alarm word labels fit left of the
|
||||
# channel (audit: alarms 14 px bold).
|
||||
x0, y0 = 64, 16
|
||||
bw, bh = w - 112, h - 40
|
||||
if bw <= 0 or bh <= 0:
|
||||
return
|
||||
fill_h = bh * level / 100.0
|
||||
@@ -881,10 +1017,24 @@ def _draw_open_channel(cr, widget):
|
||||
cr.line_to(x0 + bw, y0)
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
# Alarm word labels, right-aligned left of the channel.
|
||||
lab_cap = 0.023 * h
|
||||
lab_size = _cap_size(lab_cap)
|
||||
hi_hi, hi, lo, lo_lo = _alarms(widget)
|
||||
for mark, colour, lab in ((hi_hi, cols["red"], "HI-HI"),
|
||||
(hi, cols["amber"], "HI"),
|
||||
(lo, cols["amber"], "LO"),
|
||||
(lo_lo, cols["red"], "LO-LO")):
|
||||
y = y0 + bh - bh * mark / 100.0
|
||||
_wtext(cr, widget, lab, x0 - 6, y + lab_cap * 0.35,
|
||||
size=lab_size, bold=True, rgb=colour,
|
||||
align="right", max_width=52)
|
||||
scale_size = _fs(0.027, h)
|
||||
for i in range(6):
|
||||
y = y0 + bh - bh * i / 5.0
|
||||
_wtext(cr, widget, "%d" % (i * 20), x0 + bw + 4, y + 4,
|
||||
size=10, rgb=cols["ink"], max_width=26)
|
||||
size=scale_size, bold=True, rgb=cols["ink"],
|
||||
max_width=40)
|
||||
_tank_readout(cr, widget, level, x0 + bw / 2, h - 6, align="center")
|
||||
|
||||
|
||||
@@ -905,25 +1055,30 @@ def _draw_tank_alarms(cr, widget):
|
||||
cr.rectangle(x0 + 1, y0 + bh - fill_h, bw - 2, fill_h)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
_alarm_lines(cr, widget, x0 + bw + 2, y0, y0 + bh)
|
||||
_alarm_lines(cr, widget, x0 + bw + 2, y0, y0 + bh, labels=False)
|
||||
lamps = (("HI-HI", cols["red"], level >= hi_hi),
|
||||
("HI", cols["amber"], level >= hi),
|
||||
("LO", cols["amber"], level <= lo),
|
||||
("LO-LO", cols["red"], level <= lo_lo))
|
||||
lx = x0 + bw + 20
|
||||
ly = y0 + 8
|
||||
# Audit: legend 14 px bold with 16 px swatches.
|
||||
sw = max(6.0, 0.027 * h)
|
||||
leg_cap = 0.023 * h
|
||||
leg_size = _cap_size(leg_cap)
|
||||
for label, colour, lit in lamps:
|
||||
cr.save()
|
||||
_rgb(cr, colour if lit else (60 / 255, 60 / 255, 60 / 255))
|
||||
cr.arc(lx + 6, ly + 6, 6, 0, 2 * math.pi)
|
||||
cr.arc(lx + sw / 2, ly + sw / 2, sw / 2, 0, 2 * math.pi)
|
||||
cr.fill_preserve()
|
||||
_rgb(cr, cols["ink"])
|
||||
cr.set_line_width(1)
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
_wtext(cr, widget, label, lx + 16, ly + 10, size=10,
|
||||
rgb=cols["ink"], max_width=40)
|
||||
ly += 20
|
||||
_wtext(cr, widget, label, lx + sw + 4, ly + sw / 2
|
||||
+ leg_cap * 0.35, size=leg_size, bold=True,
|
||||
rgb=cols["ink"], max_width=48)
|
||||
ly += max(20.0, sw + 6)
|
||||
_tank_readout(cr, widget, level, x0 + bw / 2, h - 6, align="center")
|
||||
|
||||
|
||||
@@ -1340,7 +1495,9 @@ def _draw_seg_digit(cr, x, y, w, h, ch, on_rgb, off_rgb,
|
||||
cr.fill()
|
||||
else:
|
||||
x0, y0, x1, y1 = lines[seg]
|
||||
_draw_diag(cr, x0, y0, x1, y1, t)
|
||||
# Audit G5: diagonals thinned (2/3) so they read as
|
||||
# strokes, not a dark X blob over the glyph.
|
||||
_draw_diag(cr, x0, y0, x1, y1, t * 2 / 3)
|
||||
cr.restore()
|
||||
def _led_digits_text(value, digits, dp):
|
||||
"""Zero-padded digit string + decimal-point index (C shown_digits
|
||||
@@ -1364,10 +1521,13 @@ def _draw_led_digits(cr, widget):
|
||||
digits = int(kind.replace("LedDigits", ""))
|
||||
dp = _prop_int(widget, "decimal-places", 0 if digits == 1 else 1)
|
||||
bezel = _color(widget, "bezel-color", (58 / 255, 58 / 255, 62 / 255))
|
||||
dim = _color(widget, "dim-color", (52 / 255, 14 / 255, 11 / 255))
|
||||
# Audit G5: unlit segments barely visible, never a ghost "8".
|
||||
dim = _color(widget, "dim-color", (24 / 255, 15 / 255, 13 / 255))
|
||||
lit = _color(widget, "lit-color", (255 / 255, 60 / 255, 35 / 255))
|
||||
_rounded_box(cr, 0, 0, widget.width, widget.height, bezel, bezel,
|
||||
radius=6)
|
||||
# Dark face (C bg) so the dim colour reads faintly lighter than
|
||||
# the background, not as black shapes on a grey panel.
|
||||
_rounded_box(cr, 0, 0, widget.width, widget.height,
|
||||
(12 / 255, 12 / 255, 14 / 255), bezel, radius=6)
|
||||
text, point_after = _led_digits_text(_value(widget), digits, dp)
|
||||
pad = 10
|
||||
gap = 6
|
||||
@@ -1390,8 +1550,9 @@ def _draw_led_digits(cr, widget):
|
||||
|
||||
def _draw_digital_readout(cr, widget):
|
||||
dark = _color(widget, "dark-color", (30 / 255, 30 / 255, 30 / 255))
|
||||
# Audit G5: unlit segments slightly more visible, uniform dim.
|
||||
off = _color(widget, "segment-off-color",
|
||||
(50 / 255, 45 / 255, 20 / 255))
|
||||
(70 / 255, 62 / 255, 30 / 255))
|
||||
on = _color(widget, "segment-on-color",
|
||||
(255 / 255, 176 / 255, 0.0))
|
||||
_rounded_box(cr, 0, 0, widget.width, widget.height, dark, dark,
|
||||
@@ -1423,10 +1584,13 @@ def _draw_seg_display(cr, widget):
|
||||
digits = int(kind.replace("Seg14Display", "")
|
||||
.replace("Seg16Display", ""))
|
||||
bezel = _color(widget, "bezel-color", (58 / 255, 58 / 255, 62 / 255))
|
||||
dim = _color(widget, "dim-color", (60 / 255, 42 / 255, 8 / 255))
|
||||
# Audit G5: unlit segments uniform very dim, never brown blocks.
|
||||
dim = _color(widget, "dim-color", (26 / 255, 20 / 255, 10 / 255))
|
||||
lit = _color(widget, "lit-color", (255 / 255, 176 / 255, 0.0))
|
||||
_rounded_box(cr, 0, 0, widget.width, widget.height, bezel, bezel,
|
||||
radius=6)
|
||||
# Dark face (C bg) so the dim colour reads faintly lighter than
|
||||
# the background, not as black shapes on a grey panel.
|
||||
_rounded_box(cr, 0, 0, widget.width, widget.height,
|
||||
(12 / 255, 12 / 255, 14 / 255), bezel, radius=6)
|
||||
raw = widget.get_prop(
|
||||
"value",
|
||||
widget.prop_def("value").default
|
||||
@@ -1584,9 +1748,12 @@ def _draw_key_switch(cr, widget):
|
||||
plate = _color(widget, "plate-color", (210 / 255, 210 / 255, 210 / 255))
|
||||
amber = _color(widget, "amber-color", (255 / 255, 176 / 255, 0.0))
|
||||
key_in = _prop_bool(widget, "key-in", False)
|
||||
position = max(0, min(2, _prop_int(widget, "position", 0)))
|
||||
w, h = widget.width, widget.height
|
||||
cx, cy = w / 2, h / 2
|
||||
r = min(w, h) / 2 - 10
|
||||
# Plate leaves a band at the bottom for the state text (audit
|
||||
# G7: "NO KEY" was clipped by the plate edge).
|
||||
r = min(w, h) / 2 - 34
|
||||
if r < 4:
|
||||
return
|
||||
_rounded_box(cr, 6, 6, w - 12, h - 12, panel, bezel, radius=8)
|
||||
@@ -1597,28 +1764,46 @@ def _draw_key_switch(cr, widget):
|
||||
_rgb(cr, bezel)
|
||||
cr.set_line_width(2)
|
||||
cr.stroke()
|
||||
# Key slot pointing up; positions around it.
|
||||
# Key slot points at the current position (C: -120 deg + pos).
|
||||
pa = -2.094 + position * (4.188 / 2)
|
||||
_rgb(cr, bezel)
|
||||
cr.set_line_width(max(2, _prop_int(widget, "pointer-line-width",
|
||||
10) // 2))
|
||||
cr.move_to(cx, cy)
|
||||
cr.line_to(cx, cy - r + 8)
|
||||
cr.line_to(cx + (r - 8) * math.cos(pa),
|
||||
cy + (r - 8) * math.sin(pa))
|
||||
cr.stroke()
|
||||
if key_in:
|
||||
_rgb(cr, amber)
|
||||
cr.set_line_width(4)
|
||||
cr.move_to(cx, cy - r + 8)
|
||||
cr.line_to(cx, cy - r - 6)
|
||||
cr.move_to(cx + (r - 8) * math.cos(pa),
|
||||
cy + (r - 8) * math.sin(pa))
|
||||
cr.line_to(cx + (r + 6) * math.cos(pa),
|
||||
cy + (r + 6) * math.sin(pa))
|
||||
cr.stroke()
|
||||
_rgb(cr, amber)
|
||||
cr.arc(cx, cy - r - 6, 5, 0, 2 * math.pi)
|
||||
cr.arc(cx + (r + 6) * math.cos(pa),
|
||||
cy + (r + 6) * math.sin(pa), 5, 0, 2 * math.pi)
|
||||
cr.fill()
|
||||
_rgb(cr, bezel)
|
||||
cr.arc(cx, cy, 5, 0, 2 * math.pi)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
_wtext(cr, widget, "KEY", cx, h - 8, size=10, align="center",
|
||||
rgb=(0.9, 0.9, 0.9), max_width=40)
|
||||
# Audit: position numerals 16 px bold; state light-on-dark
|
||||
# ("NO KEY" was dark-on-dark, nearly invisible, G6).
|
||||
num_cap = 0.027 * h
|
||||
num_size = _cap_size(num_cap)
|
||||
for i in range(3):
|
||||
# C: -120 deg + i * 120 deg (positions around the dial).
|
||||
angle = -2.094 + i * (4.188 / 2)
|
||||
tx = cx + (r + 8) * math.cos(angle)
|
||||
ty = cy + (r + 8) * math.sin(angle)
|
||||
_wtext(cr, widget, str(i), tx, ty + num_cap * 0.35,
|
||||
size=num_size, bold=True, align="center",
|
||||
rgb=(0.9, 0.9, 0.9), max_width=16)
|
||||
_wtext(cr, widget, "KEY IN" if key_in else "NO KEY", cx, h - 8,
|
||||
size=_fs(0.023, h), bold=True, align="center",
|
||||
rgb=(0.9, 0.9, 0.9), max_width=80)
|
||||
|
||||
|
||||
def _draw_rotary(cr, widget):
|
||||
@@ -1809,9 +1994,13 @@ def _draw_nameplate(cr, widget):
|
||||
(240 / 255, 220 / 255, 160 / 255))
|
||||
_rounded_box(cr, 0, 0, widget.width, widget.height, dark, dark,
|
||||
radius=6)
|
||||
_wtext(cr, widget, widget.text if widget.text != widget.name
|
||||
else "NAMEPLATE", widget.width / 2, widget.height / 2 + 5,
|
||||
size=13, bold=True, align="center", rgb=engraved,
|
||||
# Audit: engraving fills 40-50% of the plate width, bold.
|
||||
label = widget.text if widget.text != widget.name else "NAMEPLATE"
|
||||
size = _fit_size(cr, widget, label, 0.45 * widget.width,
|
||||
_cap_size(0.45 * widget.height), bold=True)
|
||||
_wtext(cr, widget, label, widget.width / 2,
|
||||
widget.height / 2 + size * 0.72 * 0.35,
|
||||
size=size, bold=True, align="center", rgb=engraved,
|
||||
max_width=widget.width - 40)
|
||||
_screw(cr, 12, widget.height / 2)
|
||||
_screw(cr, widget.width - 12, widget.height / 2)
|
||||
|
||||
Reference in new issue
Block a user