From 4333f72ed56aee24ba95fe5600b8ef1dad74cec5 Mon Sep 17 00:00:00 2001 From: cnmcdee Date: Tue, 1 Dec 2026 03:56:43 +0000 Subject: [PATCH] Phase 6: Stock (37) + Instrumentation (66) widgets -- drawing + property tables Cairo drawings for all 103 kinds in lightgui/xframe/stock.py and instruments.py (seeded 250-bar demo series so charts show their colours with no series data; ddaf4bd anchor guard: ParallelChannel / Pitchfork draw with 0-2 anchors; plot guard below 16px height). Property tables generated by tools/gen_props_phase6.py from the C Phase 4 tables (103 kinds, 1008 props, 116 distinct names; symbol model-only; corrected up/down rgb(0,150,0)/rgb(200,30,30)). Registry-name dispatch in core.lookup so kind-sharing entries (IndVWAP/IndAnchoredVWAP kind VWAP, TArrow kind Arrow) keep their own archetype drawings and generic-only tables. --- lightgui/props_phase6.py | 1367 +++++++++++++++++++++++ lightgui/xframe/core.py | 41 +- lightgui/xframe/instruments.py | 1861 ++++++++++++++++++++++++++++++++ lightgui/xframe/stock.py | 1606 +++++++++++++++++++++++++++ tools/gen_props_phase6.py | 216 ++++ 5 files changed, 5089 insertions(+), 2 deletions(-) create mode 100644 lightgui/props_phase6.py create mode 100644 lightgui/xframe/instruments.py create mode 100644 lightgui/xframe/stock.py create mode 100644 tools/gen_props_phase6.py diff --git a/lightgui/props_phase6.py b/lightgui/props_phase6.py new file mode 100644 index 0000000..da187ef --- /dev/null +++ b/lightgui/props_phase6.py @@ -0,0 +1,1367 @@ +"""Property tables for the Stock (37) + Instrumentation +(66) families -- Phase 6. + +GENERATED -- do not edit by hand. Run +tools/gen_props_phase6.py to regenerate from +/opt/lightgui/tools/gen_phase4_props.py (the C tables, +canonical) and lightgui/xframe/palette.py. + +103 widgets, 1008 props, 116 distinct prop names. +Generic set first (from lightgui.props.props_for), then +each widget's own props below (register_custom_table). +StockChart up/down defaults are the corrected values +up-color rgb(0,150,0) / down-color rgb(200,30,30). +Model-only: "symbol" only -- the ticker symbol stored on +chart widgets; in C symbol_ is never drawn, so it is +stored in the model and emitted by the generator as a +comment. Every other prop here is honoured by the draw +code and live-applies. +Shadowed registry names (empty tables, generic set +only): entries outside the Stock/Inst families whose +palette kind is a Phase 6 kind -- kinds are shared +across families, so without an explicit table +props._resolve_kind() would map them onto the Phase 6 +table (IndVWAP onto StockVWAP, TArrow onto +StockArrow). +""" + +from lightgui.props import PropDef, register_custom_table + + +# C class name -> palette kind, for reference. +PHASE6_CLASSES = { + 'AccumulationDistribution': 'StockAccumulationDistribution', + 'AnalogGauge': 'InstAnalogGauge', + 'AreaChart': 'StockAreaChart', + 'Arrow': 'StockArrow', + 'BarMeter': 'InstBarMeter', + 'BaselineChart': 'StockBaselineChart', + 'Beacon': 'InstBeacon', + 'Bezel': 'InstBezel', + 'Brush': 'StockBrush', + 'CandlestickChart': 'StockCandlestickChart', + 'CircuitBreaker': 'InstCircuitBreaker', + 'ControlPanel': 'InstControlPanel', + 'CorrelationView': 'StockCorrelationView', + 'DigitalReadout': 'InstDigitalReadout', + 'Ellipse': 'StockEllipse', + 'EmergencyStop': 'InstEmergencyStop', + 'FibExtension': 'StockFibExtension', + 'FibRetracement': 'StockFibRetracement', + 'FlowMeter': 'InstFlowMeter', + 'HeikinAshi': 'StockHeikinAshi', + 'HollowCandles': 'StockHollowCandles', + 'HorizontalLine': 'StockHorizontalLine', + 'HorizontalTankLevel': 'InstHorizontalTankLevel', + 'IndexedComparison': 'StockIndexedComparison', + 'KeySwitch': 'InstKeySwitch', + 'LampTestButton': 'InstLampTestButton', + 'LedBlue': 'InstLedBlue', + 'LedDigits1': 'InstLedDigits1', + 'LedDigits2': 'InstLedDigits2', + 'LedDigits3': 'InstLedDigits3', + 'LedDigits4': 'InstLedDigits4', + 'LedDigits5': 'InstLedDigits5', + 'LedDigits6': 'InstLedDigits6', + 'LedGreen': 'InstLedGreen', + 'LedRed': 'InstLedRed', + 'LevelColumnGauge': 'InstLevelColumnGauge', + 'LevelTransmitter': 'InstLevelTransmitter', + 'LineChart': 'StockLineChart', + 'Manometer': 'InstManometer', + 'MeasureTool': 'StockMeasureTool', + 'MoneyFlowChart': 'StockMoneyFlowChart', + 'MultiSymbolChart': 'StockMultiSymbolChart', + 'Nameplate': 'InstNameplate', + 'NeedleEdgewise': 'InstNeedleEdgewise', + 'NeedleKnifeEdge': 'InstNeedleKnifeEdge', + 'NeedleTapered': 'InstNeedleTapered', + 'NeedleVu': 'InstNeedleVu', + 'OBVChart': 'StockOBVChart', + 'OHLCBarChart': 'StockOHLCBarChart', + 'OpenChannelLevel': 'InstOpenChannelLevel', + 'OverlayChart': 'StockOverlayChart', + 'PanelLampAmber': 'InstPanelLampAmber', + 'PanelLampBlue': 'InstPanelLampBlue', + 'PanelLampGreen': 'InstPanelLampGreen', + 'PanelLampRed': 'InstPanelLampRed', + 'PanelLampWhite': 'InstPanelLampWhite', + 'PanelPlate': 'InstPanelPlate', + 'ParallelChannel': 'StockParallelChannel', + 'Pitchfork': 'StockPitchfork', + 'PressureGauge': 'InstPressureGauge', + 'Price': 'StockPriceLabel', + 'PushButton': 'InstPushButton', + 'PushButtonLatching': 'InstPushButtonLatching', + 'RatioChart': 'StockRatioChart', + 'Rectangle': 'StockRectangle', + 'RelativePerformance': 'StockRelativePerformance', + 'Renko': 'StockRenko', + 'RgbStatusLed': 'InstRgbStatusLed', + 'RockerSwitch': 'InstRockerSwitch', + 'RockerSwitchDouble': 'InstRockerSwitchDouble', + 'RockerSwitchIlluminated': 'InstRockerSwitchIlluminated', + 'Rotary': 'InstRotarySelector', + 'SectorComparison': 'StockSectorComparison', + 'Seg14Display1': 'InstSeg14Display1', + 'Seg14Display2': 'InstSeg14Display2', + 'Seg14Display3': 'InstSeg14Display3', + 'Seg14Display4': 'InstSeg14Display4', + 'Seg14Display5': 'InstSeg14Display5', + 'Seg14Display6': 'InstSeg14Display6', + 'Seg16Display1': 'InstSeg16Display1', + 'Seg16Display2': 'InstSeg16Display2', + 'Seg16Display3': 'InstSeg16Display3', + 'Seg16Display4': 'InstSeg16Display4', + 'Seg16Display5': 'InstSeg16Display5', + 'Seg16Display6': 'InstSeg16Display6', + 'SightGlassLevel': 'InstSightGlassLevel', + 'SlideSwitch': 'InstSlideSwitch', + 'SphericalTankLevel': 'InstSphericalTankLevel', + 'SpreadChart': 'StockSpreadChart', + 'StackLight': 'InstStackLight', + 'TankLevelAlarms': 'InstTankLevelAlarms', + 'TemperatureGauge': 'InstTemperatureGauge', + 'TextAnnotation': 'StockTextAnnotation', + 'ToggleSwitch': 'InstToggleSwitch', + 'ToggleSwitchIlluminated': 'InstToggleSwitchIlluminated', + 'Trendline': 'StockTrendline', + 'VWAP': 'StockVWAP', + 'VerticalLine': 'StockVerticalLine', + 'VerticalTankLevel': 'InstVerticalTankLevel', + 'VolumeBars': 'StockVolumeBars', + 'VolumeCandles': 'StockVolumeCandles', + 'VolumeProfile': 'StockVolumeProfile', + 'VuMeter': 'InstVuMeter', +} + +# Registry names outside the Stock/Inst families whose +# kind is a Phase 6 kind; generic set only (see above). +SHADOWED = ( + 'IndAnchoredVWAP', + 'IndVWAP', + 'TArrow', +) + +TABLES = { + 'AccumulationDistribution': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('line-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'LineColor', False), + PropDef('symbol', 'Str', 'SYM', 0, 0, (), (), 'Symbol', True), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'AnalogGauge': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('face-color', 'Color', 'rgb(245,245,240)', 0, 0, (), (), 'FaceColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('maximum', 'Double', '100', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '0', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('needle-line-width', 'Int', '3', 0.0, 100.0, (), (), 'NeedleLineWidth', False), + PropDef('value', 'Double', '62.0', 0.0, 100.0, (), (), 'Value', False), + ), + 'AreaChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('fill-color', 'Color', 'rgb(180,210,240)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('line-color', 'Color', 'rgb(0,100,200)', 0, 0, (), (), 'LineColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('auto-y', 'Bool', 'true', 0, 0, (), (), 'AutoY', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + PropDef('y-max', 'Double', '1', -1000000.0, 1000000.0, (), (), 'YMax', False), + PropDef('y-min', 'Double', '0', -1000000.0, 1000000.0, (), (), 'YMin', False), + ), + 'Arrow': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '3', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'BarMeter': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('face-color', 'Color', 'rgb(245,245,240)', 0, 0, (), (), 'FaceColor', False), + PropDef('green-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'GreenColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('horizontal', 'Bool', 'false', 0, 0, (), (), 'Horizontal', False), + PropDef('marker-line-width', 'Int', '3', 0.0, 100.0, (), (), 'MarkerLineWidth', False), + PropDef('maximum', 'Double', '100', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '0', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('value', 'Double', '55.0', 0.0, 100.0, (), (), 'Value', False), + ), + 'BaselineChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('baseline-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'BaselineColor', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('down-fill-color', 'Color', 'rgb(240,180,180)', 0, 0, (), (), 'DownFillColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('line-color', 'Color', 'rgb(0,100,200)', 0, 0, (), (), 'LineColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('up-fill-color', 'Color', 'rgb(170,220,170)', 0, 0, (), (), 'UpFillColor', False), + PropDef('auto-y', 'Bool', 'true', 0, 0, (), (), 'AutoY', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('baseline', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Baseline', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + PropDef('y-max', 'Double', '1', -1000000.0, 1000000.0, (), (), 'YMax', False), + PropDef('y-min', 'Double', '0', -1000000.0, 1000000.0, (), (), 'YMin', False), + ), + 'Beacon': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('beacon-color', 'Color', 'rgb(230,160,20)', 0, 0, (), (), 'BeaconColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('flash-rate', 'Double', '2', 0.0, 1000.0, (), (), 'FlashRate', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + PropDef('phase', 'Bool', 'true', 0, 0, (), (), 'Phase', False), + ), + 'Bezel': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('panel-color', 'Color', 'rgb(210,210,205)', 0, 0, (), (), 'PanelColor', False), + PropDef('screw-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'ScrewColor', False), + PropDef('screw-ring-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'ScrewRingColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + ), + 'Brush': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(200,30,200)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '4', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'CandlestickChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('auto-y', 'Bool', 'true', 0, 0, (), (), 'AutoY', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + PropDef('y-max', 'Double', '1', -1000000.0, 1000000.0, (), (), 'YMax', False), + PropDef('y-min', 'Double', '0', -1000000.0, 1000000.0, (), (), 'YMin', False), + ), + 'CircuitBreaker': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('green-color', 'Color', 'rgb(0,180,0)', 0, 0, (), (), 'GreenColor', False), + PropDef('panel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'PanelColor', False), + PropDef('plate-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'PlateColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('lever-line-width', 'Int', '12', 0.0, 100.0, (), (), 'LeverLineWidth', False), + ), + 'ControlPanel': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('face-color', 'Color', 'rgb(245,245,240)', 0, 0, (), (), 'FaceColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('panel-color', 'Color', 'rgb(210,210,205)', 0, 0, (), (), 'PanelColor', False), + PropDef('screw-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'ScrewColor', False), + PropDef('screw-ring-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'ScrewRingColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('grid-cols', 'Int', '2', 1.0, 100.0, (), (), 'GridCols', False), + PropDef('grid-rows', 'Int', '3', 1.0, 100.0, (), (), 'GridRows', False), + ), + 'CorrelationView': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('corr-color', 'Color', 'rgb(0,100,200)', 0, 0, (), (), 'CorrColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('scatter-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'ScatterColor', False), + PropDef('zero-line-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'ZeroLineColor', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + PropDef('window', 'Int', '20', 2.0, 100000.0, (), (), 'Window', False), + ), + 'DigitalReadout': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('dark-color', 'Color', 'rgb(30,30,30)', 0, 0, (), (), 'DarkColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('segment-off-color', 'Color', 'rgb(50,45,20)', 0, 0, (), (), 'SegmentOffColor', False), + PropDef('segment-on-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'SegmentOnColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('maximum', 'Double', '999.9', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '0', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('value', 'Double', '123.4', 0.0, 999.9, (), (), 'Value', False), + ), + 'Ellipse': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(0,140,120)', 0, 0, (), (), 'Color', False), + PropDef('fill-color', 'Color', 'rgb(220,235,255)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'EmergencyStop': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('redlit-color', 'Color', 'rgb(255,70,60)', 0, 0, (), (), 'RedlitColor', False), + PropDef('surround-color', 'Color', 'rgb(255,220,0)', 0, 0, (), (), 'SurroundColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'FibExtension': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(180,80,0)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('level-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'LevelColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + ), + 'FibRetracement': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(180,120,0)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('level-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'LevelColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + ), + 'FlowMeter': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('face-color', 'Color', 'rgb(245,245,240)', 0, 0, (), (), 'FaceColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('maximum', 'Double', '100', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '0', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('value', 'Double', '40.0', 0.0, 100.0, (), (), 'Value', False), + ), + 'HeikinAshi': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('auto-y', 'Bool', 'true', 0, 0, (), (), 'AutoY', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + PropDef('y-max', 'Double', '1', -1000000.0, 1000000.0, (), (), 'YMax', False), + PropDef('y-min', 'Double', '0', -1000000.0, 1000000.0, (), (), 'YMin', False), + ), + 'HollowCandles': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('auto-y', 'Bool', 'true', 0, 0, (), (), 'AutoY', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + PropDef('y-max', 'Double', '1', -1000000.0, 1000000.0, (), (), 'YMax', False), + PropDef('y-min', 'Double', '0', -1000000.0, 1000000.0, (), (), 'YMin', False), + ), + 'HorizontalLine': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'HorizontalTankLevel': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(220,150,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('fill-color', 'Color', 'rgb(40,120,200)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'GridColor', False), + PropDef('hover-color', 'Color', 'rgb(255,170,0)', 0, 0, (), (), 'HoverColor', False), + PropDef('ink-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'InkColor', False), + PropDef('pale-color', 'Color', 'rgb(235,242,248)', 0, 0, (), (), 'PaleColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('alarm-hi', 'Double', '80', 0.0, 100.0, (), (), 'AlarmHi', False), + PropDef('alarm-hi-hi', 'Double', '95', 0.0, 100.0, (), (), 'AlarmHiHi', False), + PropDef('alarm-lo', 'Double', '20', 0.0, 100.0, (), (), 'AlarmLo', False), + PropDef('alarm-lo-lo', 'Double', '5', 0.0, 100.0, (), (), 'AlarmLoLo', False), + PropDef('level', 'Double', '13.78', 0.0, 100.0, (), (), 'Level', False), + ), + 'IndexedComparison': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('base-line-color', 'Color', 'rgb(180,180,180)', 0, 0, (), (), 'BaseLineColor', False), + PropDef('base-value', 'Double', '100', -1000000.0, 1000000.0, (), (), 'BaseValue', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'KeySwitch': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('panel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'PanelColor', False), + PropDef('plate-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'PlateColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('key-in', 'Bool', 'false', 0, 0, (), (), 'KeyIn', False), + PropDef('pointer-line-width', 'Int', '10', 0.0, 100.0, (), (), 'PointerLineWidth', False), + PropDef('positions', 'Int', '3', 2.0, 4.0, (), (), 'Positions', False), + ), + 'LampTestButton': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(70,70,70)', 0, 0, (), (), 'BezelColor', False), + PropDef('face-color', 'Color', 'rgb(200,200,200)', 0, 0, (), (), 'FaceColor', False), + PropDef('face-down-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'FaceDownColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + ), + 'LedBlue': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('lead-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'LeadColor', False), + PropDef('lens-color', 'Color', 'rgb(40,120,230)', 0, 0, (), (), 'LensColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'LedDigits1': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(52,14,11)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,60,35)', 0, 0, (), (), 'LitColor', False), + PropDef('decimal-places', 'Int', '0', 0.0, 2.0, (), (), 'DecimalPlaces', False), + PropDef('value', 'Double', '6.8652', 0.0, 9.0, (), (), 'Value', False), + ), + 'LedDigits2': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(52,14,11)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,60,35)', 0, 0, (), (), 'LitColor', False), + PropDef('decimal-places', 'Int', '1', 0.0, 2.0, (), (), 'DecimalPlaces', False), + PropDef('value', 'Double', '7.55172', 0.0, 9.9, (), (), 'Value', False), + ), + 'LedDigits3': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(52,14,11)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,60,35)', 0, 0, (), (), 'LitColor', False), + PropDef('decimal-places', 'Int', '1', 0.0, 2.0, (), (), 'DecimalPlaces', False), + PropDef('value', 'Double', '76.20372', 0.0, 99.9, (), (), 'Value', False), + ), + 'LedDigits4': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(52,14,11)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,60,35)', 0, 0, (), (), 'LitColor', False), + PropDef('decimal-places', 'Int', '1', 0.0, 2.0, (), (), 'DecimalPlaces', False), + PropDef('value', 'Double', '762.72372', 0.0, 999.9, (), (), 'Value', False), + ), + 'LedDigits5': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(52,14,11)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,60,35)', 0, 0, (), (), 'LitColor', False), + PropDef('decimal-places', 'Int', '1', 0.0, 2.0, (), (), 'DecimalPlaces', False), + PropDef('value', 'Double', '7627.92372', 0.0, 9999.9, (), (), 'Value', False), + ), + 'LedDigits6': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(52,14,11)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,60,35)', 0, 0, (), (), 'LitColor', False), + PropDef('decimal-places', 'Int', '1', 0.0, 2.0, (), (), 'DecimalPlaces', False), + PropDef('value', 'Double', '76279.92372', 0.0, 99999.9, (), (), 'Value', False), + ), + 'LedGreen': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('lead-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'LeadColor', False), + PropDef('lens-color', 'Color', 'rgb(30,200,60)', 0, 0, (), (), 'LensColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'LedRed': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('lead-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'LeadColor', False), + PropDef('lens-color', 'Color', 'rgb(220,30,30)', 0, 0, (), (), 'LensColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'LevelColumnGauge': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(220,150,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('fill-color', 'Color', 'rgb(40,120,200)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'GridColor', False), + PropDef('hover-color', 'Color', 'rgb(255,170,0)', 0, 0, (), (), 'HoverColor', False), + PropDef('ink-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'InkColor', False), + PropDef('pale-color', 'Color', 'rgb(235,242,248)', 0, 0, (), (), 'PaleColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('alarm-hi', 'Double', '80', 0.0, 100.0, (), (), 'AlarmHi', False), + PropDef('alarm-hi-hi', 'Double', '95', 0.0, 100.0, (), (), 'AlarmHiHi', False), + PropDef('alarm-lo', 'Double', '20', 0.0, 100.0, (), (), 'AlarmLo', False), + PropDef('alarm-lo-lo', 'Double', '5', 0.0, 100.0, (), (), 'AlarmLoLo', False), + PropDef('level', 'Double', '58.45', 0.0, 100.0, (), (), 'Level', False), + ), + 'LevelTransmitter': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(220,150,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('fill-color', 'Color', 'rgb(40,120,200)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'GridColor', False), + PropDef('hover-color', 'Color', 'rgb(255,170,0)', 0, 0, (), (), 'HoverColor', False), + PropDef('ink-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'InkColor', False), + PropDef('pale-color', 'Color', 'rgb(235,242,248)', 0, 0, (), (), 'PaleColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('alarm-hi', 'Double', '80', 0.0, 100.0, (), (), 'AlarmHi', False), + PropDef('alarm-hi-hi', 'Double', '95', 0.0, 100.0, (), (), 'AlarmHiHi', False), + PropDef('alarm-lo', 'Double', '20', 0.0, 100.0, (), (), 'AlarmLo', False), + PropDef('alarm-lo-lo', 'Double', '5', 0.0, 100.0, (), (), 'AlarmLoLo', False), + PropDef('level', 'Double', '30.47', 0.0, 100.0, (), (), 'Level', False), + ), + 'LineChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('line-color', 'Color', 'rgb(0,100,200)', 0, 0, (), (), 'LineColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('auto-y', 'Bool', 'true', 0, 0, (), (), 'AutoY', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + PropDef('y-max', 'Double', '1', -1000000.0, 1000000.0, (), (), 'YMax', False), + PropDef('y-min', 'Double', '0', -1000000.0, 1000000.0, (), (), 'YMin', False), + ), + 'Manometer': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('blue-color', 'Color', 'rgb(30,120,200)', 0, 0, (), (), 'BlueColor', False), + PropDef('face-color', 'Color', 'rgb(245,245,240)', 0, 0, (), (), 'FaceColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('maximum', 'Double', '50', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '-50', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('value', 'Double', '12.0', -50.0, 50.0, (), (), 'Value', False), + ), + 'MeasureTool': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(0,140,120)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'MoneyFlowChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('zero-line-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'ZeroLineColor', False), + PropDef('symbol', 'Str', 'SYM', 0, 0, (), (), 'Symbol', True), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'MultiSymbolChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'Nameplate': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('dark-color', 'Color', 'rgb(30,30,30)', 0, 0, (), (), 'DarkColor', False), + PropDef('engraved-color', 'Color', 'rgb(240,220,160)', 0, 0, (), (), 'EngravedColor', False), + PropDef('grey-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'GreyColor', False), + PropDef('screw-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'ScrewColor', False), + PropDef('screw-ring-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'ScrewRingColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + ), + 'NeedleEdgewise': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(50,50,50)', 0, 0, (), (), 'BezelColor', False), + PropDef('face-color', 'Color', 'rgb(250,250,248)', 0, 0, (), (), 'FaceColor', False), + PropDef('needle-color', 'Color', 'rgb(15,15,15)', 0, 0, (), (), 'NeedleColor', False), + PropDef('panel-color', 'Color', 'rgb(232,232,232)', 0, 0, (), (), 'PanelColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('tick-color', 'Color', 'rgb(20,20,20)', 0, 0, (), (), 'TickColor', False), + PropDef('maximum', 'Double', '100', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '0', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('value', 'Double', '76.28', 0.0, 100.0, (), (), 'Value', False), + ), + 'NeedleKnifeEdge': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'BezelColor', False), + PropDef('face-color', 'Color', 'rgb(252,252,252)', 0, 0, (), (), 'FaceColor', False), + PropDef('mirror-color', 'Color', 'rgb(200,200,200)', 0, 0, (), (), 'MirrorColor', False), + PropDef('needle-color', 'Color', 'rgb(15,15,15)', 0, 0, (), (), 'NeedleColor', False), + PropDef('panel-color', 'Color', 'rgb(222,222,222)', 0, 0, (), (), 'PanelColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('tick-color', 'Color', 'rgb(20,20,20)', 0, 0, (), (), 'TickColor', False), + PropDef('maximum', 'Double', '100', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '0', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('value', 'Double', '76.28', 0.0, 100.0, (), (), 'Value', False), + ), + 'NeedleTapered': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'BezelColor', False), + PropDef('face-color', 'Color', 'rgb(250,246,230)', 0, 0, (), (), 'FaceColor', False), + PropDef('needle-color', 'Color', 'rgb(30,30,30)', 0, 0, (), (), 'NeedleColor', False), + PropDef('panel-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'PanelColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('tick-color', 'Color', 'rgb(30,30,30)', 0, 0, (), (), 'TickColor', False), + PropDef('maximum', 'Double', '100', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '0', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('value', 'Double', '76.28', 0.0, 100.0, (), (), 'Value', False), + ), + 'NeedleVu': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(50,50,50)', 0, 0, (), (), 'BezelColor', False), + PropDef('face-color', 'Color', 'rgb(248,238,205)', 0, 0, (), (), 'FaceColor', False), + PropDef('needle-color', 'Color', 'rgb(15,15,15)', 0, 0, (), (), 'NeedleColor', False), + PropDef('panel-color', 'Color', 'rgb(226,226,226)', 0, 0, (), (), 'PanelColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('tick-color', 'Color', 'rgb(20,20,20)', 0, 0, (), (), 'TickColor', False), + PropDef('maximum', 'Double', '3', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '-20', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('value', 'Double', '-2.4556', -20.0, 3.0, (), (), 'Value', False), + ), + 'OBVChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('line-color', 'Color', 'rgb(0,100,200)', 0, 0, (), (), 'LineColor', False), + PropDef('symbol', 'Str', 'SYM', 0, 0, (), (), 'Symbol', True), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'OHLCBarChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('auto-y', 'Bool', 'true', 0, 0, (), (), 'AutoY', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + PropDef('y-max', 'Double', '1', -1000000.0, 1000000.0, (), (), 'YMax', False), + PropDef('y-min', 'Double', '0', -1000000.0, 1000000.0, (), (), 'YMin', False), + ), + 'OpenChannelLevel': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(220,150,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('fill-color', 'Color', 'rgb(40,120,200)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'GridColor', False), + PropDef('hover-color', 'Color', 'rgb(255,170,0)', 0, 0, (), (), 'HoverColor', False), + PropDef('ink-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'InkColor', False), + PropDef('pale-color', 'Color', 'rgb(235,242,248)', 0, 0, (), (), 'PaleColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('surface-color', 'Color', 'rgb(20,80,160)', 0, 0, (), (), 'SurfaceColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('alarm-hi', 'Double', '80', 0.0, 100.0, (), (), 'AlarmHi', False), + PropDef('alarm-hi-hi', 'Double', '95', 0.0, 100.0, (), (), 'AlarmHiHi', False), + PropDef('alarm-lo', 'Double', '20', 0.0, 100.0, (), (), 'AlarmLo', False), + PropDef('alarm-lo-lo', 'Double', '5', 0.0, 100.0, (), (), 'AlarmLoLo', False), + PropDef('level', 'Double', '87.83', 0.0, 100.0, (), (), 'Level', False), + ), + 'OverlayChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'PanelLampAmber': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(70,70,70)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('lens-color', 'Color', 'rgb(230,160,20)', 0, 0, (), (), 'LensColor', False), + PropDef('ring-color', 'Color', 'rgb(160,160,160)', 0, 0, (), (), 'RingColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'PanelLampBlue': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(70,70,70)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('lens-color', 'Color', 'rgb(40,120,230)', 0, 0, (), (), 'LensColor', False), + PropDef('ring-color', 'Color', 'rgb(160,160,160)', 0, 0, (), (), 'RingColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'PanelLampGreen': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(70,70,70)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('lens-color', 'Color', 'rgb(30,200,60)', 0, 0, (), (), 'LensColor', False), + PropDef('ring-color', 'Color', 'rgb(160,160,160)', 0, 0, (), (), 'RingColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'PanelLampRed': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(70,70,70)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('lens-color', 'Color', 'rgb(220,30,30)', 0, 0, (), (), 'LensColor', False), + PropDef('ring-color', 'Color', 'rgb(160,160,160)', 0, 0, (), (), 'RingColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'PanelLampWhite': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(70,70,70)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('lens-color', 'Color', 'rgb(235,235,235)', 0, 0, (), (), 'LensColor', False), + PropDef('ring-color', 'Color', 'rgb(160,160,160)', 0, 0, (), (), 'RingColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'PanelPlate': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('panel-color', 'Color', 'rgb(210,210,205)', 0, 0, (), (), 'PanelColor', False), + PropDef('screw-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'ScrewColor', False), + PropDef('screw-ring-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'ScrewRingColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + ), + 'ParallelChannel': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'Pitchfork': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(120,60,180)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'PressureGauge': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('face-color', 'Color', 'rgb(245,245,240)', 0, 0, (), (), 'FaceColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('maximum', 'Double', '300', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '0', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('needle-line-width', 'Int', '3', 0.0, 100.0, (), (), 'NeedleLineWidth', False), + PropDef('value', 'Double', '180.0', 0.0, 300.0, (), (), 'Value', False), + ), + 'Price': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + ), + 'PushButton': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('green-color', 'Color', 'rgb(0,180,0)', 0, 0, (), (), 'GreenColor', False), + PropDef('greenlit-color', 'Color', 'rgb(60,255,90)', 0, 0, (), (), 'GreenlitColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('redlit-color', 'Color', 'rgb(255,70,60)', 0, 0, (), (), 'RedlitColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'PushButtonLatching': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('green-color', 'Color', 'rgb(0,180,0)', 0, 0, (), (), 'GreenColor', False), + PropDef('greenlit-color', 'Color', 'rgb(60,255,90)', 0, 0, (), (), 'GreenlitColor', False), + PropDef('redlit-color', 'Color', 'rgb(255,70,60)', 0, 0, (), (), 'RedlitColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'RatioChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('line-color', 'Color', 'rgb(120,60,180)', 0, 0, (), (), 'LineColor', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'Rectangle': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'Color', False), + PropDef('fill-color', 'Color', 'rgb(200,220,255)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'RelativePerformance': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('zero-line-color', 'Color', 'rgb(180,180,180)', 0, 0, (), (), 'ZeroLineColor', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'Renko': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('auto-y', 'Bool', 'true', 0, 0, (), (), 'AutoY', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('brick-size', 'Double', '1', 0.01, 100000.0, (), (), 'BrickSize', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + PropDef('y-max', 'Double', '1', -1000000.0, 1000000.0, (), (), 'YMax', False), + PropDef('y-min', 'Double', '0', -1000000.0, 1000000.0, (), (), 'YMin', False), + ), + 'RgbStatusLed': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('blue-channel-color', 'Color', 'rgb(40,120,230)', 0, 0, (), (), 'BlueChannelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('green-channel-color', 'Color', 'rgb(30,200,60)', 0, 0, (), (), 'GreenChannelColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('red-channel-color', 'Color', 'rgb(220,30,30)', 0, 0, (), (), 'RedChannelColor', False), + PropDef('swatch-outline-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'SwatchOutlineColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('all-on', 'Bool', 'false', 0, 0, (), (), 'AllOn', False), + PropDef('blue-on', 'Bool', 'false', 0, 0, (), (), 'BlueOn', False), + PropDef('brightness', 'Int', '100', 0.0, 100.0, (), (), 'Brightness', False), + PropDef('green-on', 'Bool', 'false', 0, 0, (), (), 'GreenOn', False), + PropDef('red-on', 'Bool', 'false', 0, 0, (), (), 'RedOn', False), + ), + 'RockerSwitch': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('dimred-color', 'Color', 'rgb(120,30,30)', 0, 0, (), (), 'DimredColor', False), + PropDef('green-color', 'Color', 'rgb(0,180,0)', 0, 0, (), (), 'GreenColor', False), + PropDef('panel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'PanelColor', False), + PropDef('rocker-color', 'Color', 'rgb(190,190,195)', 0, 0, (), (), 'RockerColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'RockerSwitchDouble': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('green-color', 'Color', 'rgb(0,180,0)', 0, 0, (), (), 'GreenColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('rocker-color', 'Color', 'rgb(190,190,195)', 0, 0, (), (), 'RockerColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('position', 'Int', '0', -1.0, 10.0, (), (), 'Position', False), + ), + 'RockerSwitchIlluminated': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('dimred-color', 'Color', 'rgb(120,30,30)', 0, 0, (), (), 'DimredColor', False), + PropDef('green-color', 'Color', 'rgb(0,180,0)', 0, 0, (), (), 'GreenColor', False), + PropDef('greenlit-color', 'Color', 'rgb(60,255,90)', 0, 0, (), (), 'GreenlitColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('rocker-color', 'Color', 'rgb(190,190,195)', 0, 0, (), (), 'RockerColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'Rotary': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('panel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'PanelColor', False), + PropDef('plate-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'PlateColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('pointer-line-width', 'Int', '8', 0.0, 100.0, (), (), 'PointerLineWidth', False), + PropDef('position', 'Int', '0', -1.0, 10.0, (), (), 'Position', False), + PropDef('positions', 'Int', '3', 2.0, 4.0, (), (), 'Positions', False), + ), + 'SectorComparison': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('labels', 'Str', 'Tech|Tech|Energy', 0, 0, (), (), 'Labels', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'Seg14Display1': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'A', 0, 0, (), (), 'Value', False), + ), + 'Seg14Display2': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', '42', 0, 0, (), (), 'Value', False), + ), + 'Seg14Display3': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'ABC', 0, 0, (), (), 'Value', False), + ), + 'Seg14Display4': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'HELL', 0, 0, (), (), 'Value', False), + ), + 'Seg14Display5': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'HELLO', 0, 0, (), (), 'Value', False), + ), + 'Seg14Display6': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'ABC123', 0, 0, (), (), 'Value', False), + ), + 'Seg16Display1': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'M', 0, 0, (), (), 'Value', False), + ), + 'Seg16Display2': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'MW', 0, 0, (), (), 'Value', False), + ), + 'Seg16Display3': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'MWM', 0, 0, (), (), 'Value', False), + ), + 'Seg16Display4': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'MWMW', 0, 0, (), (), 'Value', False), + ), + 'Seg16Display5': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'MWMWM', 0, 0, (), (), 'Value', False), + ), + 'Seg16Display6': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('bezel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'BezelColor', False), + PropDef('dim-color', 'Color', 'rgb(60,42,8)', 0, 0, (), (), 'DimColor', False), + PropDef('label-color', 'Color', 'rgb(170,170,170)', 0, 0, (), (), 'LabelColor', False), + PropDef('lit-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'LitColor', False), + PropDef('value', 'Str', 'MWMWMW', 0, 0, (), (), 'Value', False), + ), + 'SightGlassLevel': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(220,150,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('fill-color', 'Color', 'rgb(40,120,200)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'GridColor', False), + PropDef('hover-color', 'Color', 'rgb(255,170,0)', 0, 0, (), (), 'HoverColor', False), + PropDef('ink-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'InkColor', False), + PropDef('pale-color', 'Color', 'rgb(235,242,248)', 0, 0, (), (), 'PaleColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('steel-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'SteelColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('alarm-hi', 'Double', '80', 0.0, 100.0, (), (), 'AlarmHi', False), + PropDef('alarm-hi-hi', 'Double', '95', 0.0, 100.0, (), (), 'AlarmHiHi', False), + PropDef('alarm-lo', 'Double', '20', 0.0, 100.0, (), (), 'AlarmLo', False), + PropDef('alarm-lo-lo', 'Double', '5', 0.0, 100.0, (), (), 'AlarmLoLo', False), + PropDef('level', 'Double', '14.58', 0.0, 100.0, (), (), 'Level', False), + ), + 'SlideSwitch': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('green-color', 'Color', 'rgb(0,180,0)', 0, 0, (), (), 'GreenColor', False), + PropDef('panel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'PanelColor', False), + PropDef('rocker-color', 'Color', 'rgb(190,190,195)', 0, 0, (), (), 'RockerColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'SphericalTankLevel': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(220,150,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('fill-color', 'Color', 'rgb(40,120,200)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'GridColor', False), + PropDef('hover-color', 'Color', 'rgb(255,170,0)', 0, 0, (), (), 'HoverColor', False), + PropDef('ink-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'InkColor', False), + PropDef('pale-color', 'Color', 'rgb(235,242,248)', 0, 0, (), (), 'PaleColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('alarm-hi', 'Double', '80', 0.0, 100.0, (), (), 'AlarmHi', False), + PropDef('alarm-hi-hi', 'Double', '95', 0.0, 100.0, (), (), 'AlarmHiHi', False), + PropDef('alarm-lo', 'Double', '20', 0.0, 100.0, (), (), 'AlarmLo', False), + PropDef('alarm-lo-lo', 'Double', '5', 0.0, 100.0, (), (), 'AlarmLoLo', False), + PropDef('level', 'Double', '14.63', 0.0, 100.0, (), (), 'Level', False), + ), + 'SpreadChart': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('line-color', 'Color', 'rgb(0,100,200)', 0, 0, (), (), 'LineColor', False), + PropDef('zero-line-color', 'Color', 'rgb(120,120,120)', 0, 0, (), (), 'ZeroLineColor', False), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'StackLight': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(230,160,20)', 0, 0, (), (), 'AmberColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('green-color', 'Color', 'rgb(30,200,60)', 0, 0, (), (), 'GreenColor', False), + PropDef('hover-color', 'Color', 'rgb(0,120,200)', 0, 0, (), (), 'HoverColor', False), + PropDef('red-color', 'Color', 'rgb(220,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('tier-outline-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'TierOutlineColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('all-on', 'Bool', 'false', 0, 0, (), (), 'AllOn', False), + PropDef('amber-brightness', 'Int', '100', 0.0, 100.0, (), (), 'AmberBrightness', False), + PropDef('amber-on', 'Bool', 'false', 0, 0, (), (), 'AmberOn', False), + PropDef('green-brightness', 'Int', '100', 0.0, 100.0, (), (), 'GreenBrightness', False), + PropDef('green-on', 'Bool', 'false', 0, 0, (), (), 'GreenOn', False), + PropDef('red-brightness', 'Int', '100', 0.0, 100.0, (), (), 'RedBrightness', False), + PropDef('red-on', 'Bool', 'false', 0, 0, (), (), 'RedOn', False), + ), + 'TankLevelAlarms': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(220,150,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('fill-color', 'Color', 'rgb(40,120,200)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'GridColor', False), + PropDef('hover-color', 'Color', 'rgb(255,170,0)', 0, 0, (), (), 'HoverColor', False), + PropDef('ink-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'InkColor', False), + PropDef('pale-color', 'Color', 'rgb(235,242,248)', 0, 0, (), (), 'PaleColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('alarm-hi', 'Double', '80', 0.0, 100.0, (), (), 'AlarmHi', False), + PropDef('alarm-hi-hi', 'Double', '95', 0.0, 100.0, (), (), 'AlarmHiHi', False), + PropDef('alarm-lo', 'Double', '20', 0.0, 100.0, (), (), 'AlarmLo', False), + PropDef('alarm-lo-lo', 'Double', '5', 0.0, 100.0, (), (), 'AlarmLoLo', False), + PropDef('level', 'Double', '56.24', 0.0, 100.0, (), (), 'Level', False), + ), + 'TemperatureGauge': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('face-color', 'Color', 'rgb(245,245,240)', 0, 0, (), (), 'FaceColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('maximum', 'Double', '200', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '-20', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('needle-line-width', 'Int', '3', 0.0, 100.0, (), (), 'NeedleLineWidth', False), + PropDef('value', 'Double', '85.0', -20.0, 200.0, (), (), 'Value', False), + ), + 'TextAnnotation': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(160,90,0)', 0, 0, (), (), 'Color', False), + PropDef('fill-color', 'Color', 'rgb(255,248,200)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('text-color', 'Color', 'rgb(20,20,20)', 0, 0, (), (), 'TextColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('annotation-text', 'Str', 'Note', 0, 0, (), (), 'AnnotationText', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + ), + 'ToggleSwitch': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('greenlit-color', 'Color', 'rgb(60,255,90)', 0, 0, (), (), 'GreenlitColor', False), + PropDef('panel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'PanelColor', False), + PropDef('plate-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'PlateColor', False), + PropDef('redlit-color', 'Color', 'rgb(255,70,60)', 0, 0, (), (), 'RedlitColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('lever-line-width', 'Int', '10', 0.0, 100.0, (), (), 'LeverLineWidth', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'ToggleSwitchIlluminated': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(255,176,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('bezel-color', 'Color', 'rgb(38,38,42)', 0, 0, (), (), 'BezelColor', False), + PropDef('dark-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'DarkColor', False), + PropDef('dimred-color', 'Color', 'rgb(120,30,30)', 0, 0, (), (), 'DimredColor', False), + PropDef('greenlit-color', 'Color', 'rgb(60,255,90)', 0, 0, (), (), 'GreenlitColor', False), + PropDef('panel-color', 'Color', 'rgb(58,58,62)', 0, 0, (), (), 'PanelColor', False), + PropDef('plate-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'PlateColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('lever-line-width', 'Int', '10', 0.0, 100.0, (), (), 'LeverLineWidth', False), + PropDef('on', 'Bool', 'false', 0, 0, (), (), 'On', False), + ), + 'Trendline': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'VWAP': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('line-color', 'Color', 'rgb(0,100,200)', 0, 0, (), (), 'LineColor', False), + PropDef('vwap-color', 'Color', 'rgb(230,126,34)', 0, 0, (), (), 'VwapColor', False), + PropDef('symbol', 'Str', 'SYM', 0, 0, (), (), 'Symbol', True), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'VerticalLine': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('axis-color', 'Color', 'rgb(150,150,150)', 0, 0, (), (), 'AxisColor', False), + PropDef('candle-down-color', 'Color', 'rgb(200,120,120)', 0, 0, (), (), 'CandleDownColor', False), + PropDef('candle-up-color', 'Color', 'rgb(120,190,120)', 0, 0, (), (), 'CandleUpColor', False), + PropDef('color', 'Color', 'rgb(120,60,180)', 0, 0, (), (), 'Color', False), + PropDef('grid-color', 'Color', 'rgb(228,228,228)', 0, 0, (), (), 'GridColor', False), + PropDef('anchor-1-bar', 'Int', '0', 0.0, 100000.0, (), (), 'Anchor1Bar', False), + PropDef('anchor-1-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor1Price', False), + PropDef('anchor-2-bar', 'Int', '10', 0.0, 100000.0, (), (), 'Anchor2Bar', False), + PropDef('anchor-2-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor2Price', False), + PropDef('anchor-3-bar', 'Int', '20', 0.0, 100000.0, (), (), 'Anchor3Bar', False), + PropDef('anchor-3-price', 'Double', '100', -1000000.0, 1000000.0, (), (), 'Anchor3Price', False), + PropDef('axis-height', 'Int', '20', 0.0, 1000.0, (), (), 'AxisHeight', False), + PropDef('axis-width', 'Int', '56', 0.0, 1000.0, (), (), 'AxisWidth', False), + PropDef('line-width', 'Int', '2', 0.0, 100.0, (), (), 'LineWidth', False), + ), + 'VerticalTankLevel': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('amber-color', 'Color', 'rgb(220,150,0)', 0, 0, (), (), 'AmberColor', False), + PropDef('fill-color', 'Color', 'rgb(40,120,200)', 0, 0, (), (), 'FillColor', False), + PropDef('grid-color', 'Color', 'rgb(210,210,210)', 0, 0, (), (), 'GridColor', False), + PropDef('hover-color', 'Color', 'rgb(255,170,0)', 0, 0, (), (), 'HoverColor', False), + PropDef('ink-color', 'Color', 'rgb(60,60,60)', 0, 0, (), (), 'InkColor', False), + PropDef('pale-color', 'Color', 'rgb(235,242,248)', 0, 0, (), (), 'PaleColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('alarm-hi', 'Double', '80', 0.0, 100.0, (), (), 'AlarmHi', False), + PropDef('alarm-hi-hi', 'Double', '95', 0.0, 100.0, (), (), 'AlarmHiHi', False), + PropDef('alarm-lo', 'Double', '20', 0.0, 100.0, (), (), 'AlarmLo', False), + PropDef('alarm-lo-lo', 'Double', '5', 0.0, 100.0, (), (), 'AlarmLoLo', False), + PropDef('level', 'Double', '76.28', 0.0, 100.0, (), (), 'Level', False), + ), + 'VolumeBars': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('grid-color', 'Color', 'rgb(225,225,225)', 0, 0, (), (), 'GridColor', False), + PropDef('line-color', 'Color', 'rgb(0,100,200)', 0, 0, (), (), 'LineColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('symbol', 'Str', 'SYM', 0, 0, (), (), 'Symbol', True), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'VolumeCandles': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('down-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'DownColor', False), + PropDef('up-color', 'Color', 'rgb(0,150,0)', 0, 0, (), (), 'UpColor', False), + PropDef('symbol', 'Str', 'SYM', 0, 0, (), (), 'Symbol', True), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'VolumeProfile': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('line-color', 'Color', 'rgb(0,100,200)', 0, 0, (), (), 'LineColor', False), + PropDef('poc-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'PocColor', False), + PropDef('bins', 'Int', '20', 2.0, 100.0, (), (), 'Bins', False), + PropDef('symbol', 'Str', 'SYM', 0, 0, (), (), 'Symbol', True), + PropDef('view-count', 'Double', '0', 0.0, 100000.0, (), (), 'ViewCount', False), + PropDef('view-first', 'Double', '0', 0.0, 100000.0, (), (), 'ViewFirst', False), + ), + 'VuMeter': ( + PropDef('text', 'Str', '', 0, 0, (), (), 'Text', False), + PropDef('face-color', 'Color', 'rgb(245,245,240)', 0, 0, (), (), 'FaceColor', False), + PropDef('ink-color', 'Color', 'rgb(40,40,40)', 0, 0, (), (), 'InkColor', False), + PropDef('red-color', 'Color', 'rgb(200,30,30)', 0, 0, (), (), 'RedColor', False), + PropDef('white-color', 'Color', 'rgb(255,255,255)', 0, 0, (), (), 'WhiteColor', False), + PropDef('maximum', 'Double', '3', -100000.0, 100000.0, (), (), 'Maximum', False), + PropDef('minimum', 'Double', '-20', -100000.0, 100000.0, (), (), 'Minimum', False), + PropDef('needle-line-width', 'Int', '3', 0.0, 100.0, (), (), 'NeedleLineWidth', False), + PropDef('value', 'Double', '-6.0', -20.0, 3.0, (), (), 'Value', False), + ), +} + + +for _kind, _props in TABLES.items(): + register_custom_table(_kind, _props) +for _name in SHADOWED: + register_custom_table(_name, ()) diff --git a/lightgui/xframe/core.py b/lightgui/xframe/core.py index f0a45a7..cade819 100644 --- a/lightgui/xframe/core.py +++ b/lightgui/xframe/core.py @@ -23,8 +23,9 @@ scrollbars, scales, text views, containers, images, progress bars, spin edits, calendars, colour pickers, list/tree views, notebooks, menus/toolbars/statusbar/splitter/shape, dialogs/windows. Pixel parity with C is NOT required; drawings must be recognisable as the -widget. Stock / Instrumentation families keep the Phase 1 panel -drawing; their faithful rendering is Phase 6 work. +widget. Stock / Instrumentation families draw in their own modules +(lightgui/xframe/stock.py and instruments.py, Phase 6); the generic +panel drawing survives only as a fallback in those modules. Live-apply (Phase 2): ``Widget.set_prop`` validates against the property table in :mod:`lightgui.props`, updates state, marks the @@ -2380,6 +2381,16 @@ def lookup(kind): entry = _palette.find(kind) if entry is None: return None + # Phase 6: the Stock (37) + Instrumentation (66) registry names + # draw in their own modules (stock.py / instruments.py), not in + # the generic archetype classes. Dispatch is on the registry + # NAME, not the palette kind: kinds are shared across families + # (kind "VWAP" is IndAnchoredVWAP, IndVWAP and StockVWAP; kind + # "Arrow" is StockArrow and TArrow), so kind-keyed dispatch + # would hijack the Ind*/T* entries into the Phase 6 classes. + cls = _KIND_CLASSES.get(entry.name) + if cls is not None: + return cls return ARCHETYPE_CLASSES[entry.archetype] @@ -2403,3 +2414,29 @@ def create(kind, name, x=0, y=0, width=None, height=None, props=None, def is_known_kind(kind): return _palette.find(kind) is not None + + +# --- Phase 6: Stock + Instrumentation -------------------------------------- +# The two family modules live beside core.py; they import the Widget +# base + draw helpers from here, so they are imported at the bottom +# (after every name they need exists) rather than at the top, which +# would be circular. Their registry-name -> class map overrides the +# archetype dispatch in lookup() above. props_phase6 registers the 103 +# property tables on import, so set_prop validation and the +# generator's model-only comments work in the designer and in +# generated apps (which import only this module). +_KIND_CLASSES = {} + +from lightgui.xframe import stock as _stock_mod +from lightgui.xframe import instruments as _inst_mod +# Keyed by registry NAME (see lookup()): the Stock* names draw in +# StockWidget, the Inst* names in InstWidget. Everything else keeps +# the archetype dispatch -- in particular IndVWAP/IndAnchoredVWAP +# (kind "VWAP") stay IndicatorWidget and TArrow (kind "Arrow") +# stays a Button. +for _entry in _palette.PALETTE: + if _entry.name.startswith("Stock"): + _KIND_CLASSES[_entry.name] = _stock_mod.StockWidget + elif _entry.name.startswith("Inst"): + _KIND_CLASSES[_entry.name] = _inst_mod.InstWidget +from lightgui import props_phase6 # noqa: F401 diff --git a/lightgui/xframe/instruments.py b/lightgui/xframe/instruments.py new file mode 100644 index 0000000..a6db281 --- /dev/null +++ b/lightgui/xframe/instruments.py @@ -0,0 +1,1861 @@ +"""Instrumentation widgets (66): Cairo drawings in the archetype structure. + +Ports the C designer (widgets/components/Inst*, docs/instrumentation*.md) +to the Python XFrame archetype model: one InstWidget class, +parameterised by ``kind``, with kind-specific branches in _draw -- +the same pattern as the other archetypes in lightgui/xframe/core.py. + +Families: gauges (round dial + needle, bar meter, rotameter, +manometer), tanks (fill 0-100% + alarm bands hi-hi 95 / hi 80 / +lo 20 / lo-lo 5), lamps/LEDs (on/off + brightness 0-100), 7-segment +LED digits, 14/16-segment alphanumeric displays, switches, needles, +panel furniture. Draw fallbacks are the C member defaults from +tools/gen_phase4_props.py, so a freshly placed widget looks like +its C demo (e.g. VerticalTankLevel level 76.28, AnalogGauge value +62.0). ``set_level``/``set_value`` are live: editing level in the +Inspector repaints the fill immediately. +""" + +import math + +from lightgui.xframe.core import ( + Widget, + parse_color, + _bg, + _box, + _prop_bool, + _prop_float, + _prop_int, + _rgb, + _rounded_box, + _text_width, + _wtext, +) + +# Palette kinds (instruments.py covers the 66 Inst* registry names). +INST_KINDS = frozenset(( + "AnalogGauge", "BarMeter", "Beacon", "Bezel", "CircuitBreaker", + "ControlPanel", "DigitalReadout", "EmergencyStop", "FlowMeter", + "HorizontalTankLevel", "KeySwitch", "LampTestButton", "LedBlue", + "LedDigits1", "LedDigits2", "LedDigits3", "LedDigits4", + "LedDigits5", "LedDigits6", "LedGreen", "LedRed", + "LevelColumnGauge", "LevelTransmitter", "Manometer", "Nameplate", + "NeedleEdgewise", "NeedleKnifeEdge", "NeedleTapered", "NeedleVu", + "OpenChannelLevel", "PanelLampAmber", "PanelLampBlue", + "PanelLampGreen", "PanelLampRed", "PanelLampWhite", "PanelPlate", + "PressureGauge", "PushButton", "PushButtonLatching", "RgbStatusLed", + "RockerSwitch", "RockerSwitchDouble", "RockerSwitchIlluminated", + "Rotary", "Seg14Display1", "Seg14Display2", "Seg14Display3", + "Seg14Display4", "Seg14Display5", "Seg14Display6", + "Seg16Display1", "Seg16Display2", "Seg16Display3", + "Seg16Display4", "Seg16Display5", "Seg16Display6", + "SightGlassLevel", "SlideSwitch", "SphericalTankLevel", + "StackLight", "TankLevelAlarms", "TemperatureGauge", + "ToggleSwitch", "ToggleSwitchIlluminated", "VerticalTankLevel", + "VuMeter", +)) + +# C member defaults (tools/gen_phase4_props.py report) used as draw +# fallbacks, so a fresh widget shows its demo state. +_VALUE_DEFAULT = { + "AnalogGauge": 62.0, "PressureGauge": 180.0, + "TemperatureGauge": 85.0, "VuMeter": -6.0, "BarMeter": 55.0, + "FlowMeter": 40.0, "Manometer": 12.0, "DigitalReadout": 123.4, + "NeedleEdgewise": 76.28, "NeedleKnifeEdge": 76.28, + "NeedleTapered": 76.28, "NeedleVu": -2.4556, + "LedDigits1": 6.8652, "LedDigits2": 7.55172, + "LedDigits3": 76.20372, "LedDigits4": 762.72372, + "LedDigits5": 7627.92372, "LedDigits6": 76279.92372, +} +_RANGE_DEFAULT = { + "AnalogGauge": (0.0, 100.0), "PressureGauge": (0.0, 300.0), + "TemperatureGauge": (-20.0, 200.0), "VuMeter": (-20.0, 3.0), + "BarMeter": (0.0, 100.0), "FlowMeter": (0.0, 100.0), + "Manometer": (-50.0, 50.0), "DigitalReadout": (0.0, 999.9), + "NeedleEdgewise": (0.0, 100.0), "NeedleKnifeEdge": (0.0, 100.0), + "NeedleTapered": (0.0, 100.0), "NeedleVu": (-20.0, 3.0), +} +_LEVEL_DEFAULT = { + "VerticalTankLevel": 76.28, "HorizontalTankLevel": 13.78, + "SphericalTankLevel": 14.63, "SightGlassLevel": 14.58, + "LevelColumnGauge": 58.45, "LevelTransmitter": 30.47, + "OpenChannelLevel": 87.83, "TankLevelAlarms": 56.24, +} + + +def _color(widget, name, default): + return parse_color(widget.get_prop(name, ""), default) + + +def _value(widget): + """Gauge/digit value with the C demo default.""" + default = _VALUE_DEFAULT.get(widget.pkind, 0.0) + return _prop_float(widget, "value", default) + + +def _range(widget): + """(min, max) with the C demo default.""" + lo, hi = _RANGE_DEFAULT.get(widget.pkind, (0.0, 100.0)) + return (_prop_float(widget, "minimum", lo), + _prop_float(widget, "maximum", hi)) + + +def _frac(widget): + """Value as a 0..1 fraction of its range.""" + lo, hi = _range(widget) + value = _value(widget) + if hi <= lo: + return 0.5 + return max(0.0, min(1.0, (value - lo) / (hi - lo))) + + +def _level(widget): + """Tank level 0..100 with the C demo default.""" + default = _LEVEL_DEFAULT.get(widget.pkind, 50.0) + return max(0.0, min(100.0, _prop_float(widget, "level", default))) + + +def _alarms(widget): + """(hi-hi, hi, lo, lo-lo) alarm bands (C defaults 95/80/20/5).""" + return (_prop_float(widget, "alarm-hi-hi", 95.0), + _prop_float(widget, "alarm-hi", 80.0), + _prop_float(widget, "alarm-lo", 20.0), + _prop_float(widget, "alarm-lo-lo", 5.0)) + + +def _on(widget): + return _prop_bool(widget, "on", False) + + +def _brightness(widget): + return max(0, min(100, _prop_int(widget, "brightness", 100))) + + +def _screw(cr, x, y, r=4): + """One panel screw: grey disc + dark slot.""" + cr.save() + _rgb(cr, (150 / 255, 150 / 255, 150 / 255)) + cr.arc(x, y, r, 0, 2 * math.pi) + cr.fill_preserve() + _rgb(cr, (40 / 255, 40 / 255, 40 / 255)) + cr.set_line_width(1) + cr.stroke() + cr.move_to(x - r + 1, y) + cr.line_to(x + r - 1, y) + cr.stroke() + cr.restore() + + +def _panel_screws(cr, widget, margin=10): + w, h = widget.width, widget.height + for x, y in ((margin, margin), (w - margin, margin), + (margin, h - margin), (w - margin, h - margin)): + _screw(cr, x, y) + + +# --- gauges ------------------------------------------------------------------ + +def _dial_angle(frac): + """Needle angle (radians, Cairo coords): 270-degree sweep from + lower-left (0.75 pi) through top (1.5 pi) to lower-right.""" + return (0.75 + 1.5 * frac) * math.pi + + +def _draw_dial(cr, widget, red_from=None, unit="", fmt="%.0f"): + """Round dial gauge: face, ticks, numbers, red zone, needle, + hub, value readout. *red_from* is the fraction where the red + zone starts (None = no red zone).""" + w, h = widget.width, widget.height + face = _color(widget, "face-color", (245 / 255, 245 / 255, 240 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + red = _color(widget, "red-color", (200 / 255, 30 / 255, 30 / 255)) + lo, hi = _range(widget) + frac = _frac(widget) + cx, cy = w / 2, h / 2 + 4 + r = min(w, h) / 2 - 10 + if r < 4: + return + cr.save() + _rgb(cr, face) + cr.arc(cx, cy, r, 0, 2 * math.pi) + cr.fill_preserve() + _rgb(cr, ink) + cr.set_line_width(2) + cr.stroke() + if red_from is not None: + _rgb(cr, red) + cr.set_line_width(4) + cr.arc(cx, cy, r - 6, _dial_angle(red_from), + _dial_angle(1.0)) + cr.stroke() + # Ticks + numbers. + for i in range(11): + f = i / 10.0 + angle = _dial_angle(f) + major = i % 5 == 0 + r0 = r - (12 if major else 7) + cr.save() + _rgb(cr, ink) + cr.set_line_width(2 if major else 1) + cr.move_to(cx + r0 * math.cos(angle), cy + r0 * math.sin(angle)) + cr.line_to(cx + (r - 2) * math.cos(angle), + cy + (r - 2) * math.sin(angle)) + cr.stroke() + cr.restore() + 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) + # Needle. + angle = _dial_angle(frac) + width = _prop_int(widget, "needle-line-width", 3) + cr.save() + _rgb(cr, ink) + cr.set_line_width(max(1, width)) + cr.set_line_cap(1) + cr.move_to(cx, cy) + cr.line_to(cx + (r - 16) * math.cos(angle), + cy + (r - 16) * math.sin(angle)) + cr.stroke() + _rgb(cr, ink) + cr.arc(cx, cy, 5, 0, 2 * math.pi) + cr.fill() + cr.restore() + label = (fmt % _value(widget)) + (" " + unit if unit else "") + _wtext(cr, widget, label, cx, cy + r * 0.55 + 6, size=12, + 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) + cr.restore() + + +def _draw_analog_gauge(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + _draw_dial(cr, widget) + + +def _draw_pressure_gauge(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + _draw_dial(cr, widget, red_from=0.8, unit="psi") + + +def _draw_temperature_gauge(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + _draw_dial(cr, widget, red_from=170.0 / 220.0, unit="°C") + + +def _draw_vu_meter(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + _draw_dial(cr, widget, red_from=20.0 / 23.0, unit="VU", fmt="%.0f") + + +def _draw_bar_meter(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + face = _color(widget, "face-color", (245 / 255, 245 / 255, 240 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + green = _color(widget, "green-color", (0.0, 150 / 255, 0.0)) + amber = _color(widget, "amber-color", (255 / 255, 176 / 255, 0.0)) + red = _color(widget, "red-color", (200 / 255, 30 / 255, 30 / 255)) + frac = _frac(widget) + horizontal = _prop_bool(widget, "horizontal", False) + w, h = widget.width, widget.height + x0, y0 = 30, 10 + bw, bh = w - 44, h - 34 + if bw <= 0 or bh <= 0: + return + _box(cr, x0, y0, bw, bh, face, ink) + colour = green if frac < 0.6 else amber if frac < 0.8 else red + marker_w = _prop_int(widget, "marker-line-width", 3) + if horizontal: + fill_w = max(0, bw * frac) + _rgb(cr, colour) + cr.rectangle(x0, y0, fill_w, bh) + cr.fill() + cr.save() + _rgb(cr, ink) + cr.set_line_width(marker_w) + cr.move_to(x0 + fill_w, y0) + cr.line_to(x0 + fill_w, y0 + bh) + cr.stroke() + cr.restore() + else: + fill_h = max(0, bh * frac) + _rgb(cr, colour) + cr.rectangle(x0, y0 + bh - fill_h, bw, fill_h) + cr.fill() + cr.save() + _rgb(cr, ink) + cr.set_line_width(marker_w) + cr.move_to(x0, y0 + bh - fill_h) + cr.line_to(x0 + bw, y0 + bh - fill_h) + cr.stroke() + cr.restore() + lo, hi = _range(widget) + 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) + 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, + rgb=ink, align="center", bold=True, max_width=w - 8) + + +def _draw_flow_meter(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + face = _color(widget, "face-color", (245 / 255, 245 / 255, 240 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + red = _color(widget, "red-color", (200 / 255, 30 / 255, 30 / 255)) + frac = _frac(widget) + w, h = widget.width, widget.height + cx = w / 2 + top_w, bot_w = 26, 52 + top_y, bot_y = 12, h - 30 + if bot_y - top_y < 10: + return + # Tapered tube (narrow at the top, wide at the bottom). + cr.save() + _rgb(cr, face) + cr.move_to(cx - top_w / 2, top_y) + cr.line_to(cx + top_w / 2, top_y) + cr.line_to(cx + bot_w / 2, bot_y) + cr.line_to(cx - bot_w / 2, bot_y) + cr.close_path() + cr.fill_preserve() + _rgb(cr, ink) + cr.set_line_width(1.5) + cr.stroke() + cr.restore() + # Float rides at the flow level. + fy = bot_y - frac * (bot_y - top_y) + fw = top_w + (bot_w - top_w) * (1 - frac) + cr.save() + _rgb(cr, red) + cr.arc(cx, fy, max(3, fw / 2 - 3), 0, 2 * math.pi) + cr.fill_preserve() + _rgb(cr, ink) + cr.set_line_width(1) + cr.stroke() + cr.restore() + lo, hi = _range(widget) + 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) + _wtext(cr, widget, "%.0f L/min" % _value(widget), cx, h - 8, + size=12, rgb=ink, align="center", bold=True, + max_width=w - 8) + + +def _draw_manometer(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + face = _color(widget, "face-color", (245 / 255, 245 / 255, 240 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + blue = _color(widget, "blue-color", (30 / 255, 120 / 255, 200 / 255)) + lo, hi = _range(widget) + value = _value(widget) + frac = (value - lo) / (hi - lo) if hi > lo else 0.5 + frac = max(-1.0, min(1.0, frac)) + w, h = widget.width, widget.height + mid_y = h / 2 + amp = (h - 40) / 2 * 0.8 + left_x, right_x = w * 0.3, w * 0.7 + tube_w = 16 + top = 14 + bot = h - 26 + if bot - top < 10: + return + cr.save() + _rgb(cr, face) + cr.rectangle(left_x - tube_w / 2, top, tube_w, bot - top) + cr.rectangle(right_x - tube_w / 2, top, tube_w, bot - top) + cr.rectangle(left_x - tube_w / 2, bot - tube_w, right_x - left_x + + tube_w, tube_w) + cr.fill_preserve() + _rgb(cr, ink) + cr.set_line_width(1.5) + cr.stroke() + cr.restore() + # Liquid: levels move apart with differential pressure. + left_y = mid_y - frac * amp + right_y = mid_y + frac * amp + cr.save() + _rgb(cr, blue) + cr.rectangle(left_x - tube_w / 2 + 1, left_y, tube_w - 2, + bot - left_y) + cr.rectangle(right_x - tube_w / 2 + 1, right_y, tube_w - 2, + bot - right_y) + cr.rectangle(left_x - tube_w / 2 + 1, bot - tube_w + 1, + right_x - left_x + tube_w - 2, tube_w - 2) + cr.fill() + cr.restore() + for i in range(5): + 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, + rgb=ink, align="center", bold=True, max_width=w - 8) + + +# --- needles ----------------------------------------------------------------- + +def _draw_needle_tapered(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + face = _color(widget, "face-color", (250 / 255, 246 / 255, 230 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + needle = _color(widget, "needle-color", (30 / 255, 30 / 255, 30 / 255)) + red = _color(widget, "red-color", (200 / 255, 30 / 255, 30 / 255)) + w, h = widget.width, widget.height + cx, cy = w / 2, h * 0.62 + r = min(w, h) * 0.36 + if r < 4: + return + cr.save() + _rgb(cr, face) + cr.arc(cx, cy, r, 0, 2 * math.pi) + cr.fill_preserve() + _rgb(cr, ink) + cr.set_line_width(2) + cr.stroke() + _rgb(cr, red) + cr.set_line_width(3) + cr.arc(cx, cy, r - 5, _dial_angle(0.8), _dial_angle(1.0)) + cr.stroke() + frac = _frac(widget) + angle = _dial_angle(frac) + # Tapered needle: a triangle from the hub to the tip. + tip_x, tip_y = cx + (r - 8) * math.cos(angle), \ + cy + (r - 8) * math.sin(angle) + perp = angle + math.pi / 2 + base = 5 + cr.move_to(tip_x, tip_y) + cr.line_to(cx + base * math.cos(perp), cy + base * math.sin(perp)) + cr.line_to(cx - base * math.cos(perp), cy - base * math.sin(perp)) + cr.close_path() + _rgb(cr, needle) + cr.fill() + _rgb(cr, ink) + cr.arc(cx, cy, 4, 0, 2 * math.pi) + cr.fill() + cr.restore() + _wtext(cr, widget, "%.1f" % _value(widget), cx, h - 8, size=12, + rgb=ink, align="center", bold=True, max_width=w - 8) + + +def _draw_needle_knife(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + face = _color(widget, "face-color", (252 / 255, 252 / 255, 252 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + needle = _color(widget, "needle-color", (15 / 255, 15 / 255, 15 / 255)) + mirror = _color(widget, "mirror-color", (200 / 255, 200 / 255, 200 / 255)) + red = _color(widget, "red-color", (200 / 255, 30 / 255, 30 / 255)) + w, h = widget.width, widget.height + x0, y0 = 12, 12 + bw, bh = w - 24, h - 40 + if bw <= 0 or bh <= 0: + return + _box(cr, x0, y0, bw, bh, face, ink) + # Mirror strip under the scale arc. + _rgb(cr, mirror) + cr.rectangle(x0 + 6, y0 + bh * 0.42, bw - 12, 8) + cr.fill() + frac = _frac(widget) + # Knife-edge needle: a thin line pivoting at the bottom centre, + # sweeping from upper-left (frac 0, 1.25 pi) to upper-right + # (frac 1, 1.75 pi). + pivot_x, pivot_y = x0 + bw / 2, y0 + bh + angle = math.pi * (1.25 + 0.5 * frac) + tip_x = pivot_x + bh * 0.85 * math.cos(angle) + tip_y = pivot_y + bh * 0.85 * math.sin(angle) + cr.save() + _rgb(cr, red) + cr.set_line_width(2) + cr.arc(pivot_x, pivot_y, bh * 0.8, math.pi * 1.65, math.pi * 1.75) + cr.stroke() + _rgb(cr, needle) + cr.set_line_width(2) + cr.move_to(pivot_x, pivot_y) + cr.line_to(tip_x, tip_y) + cr.stroke() + _rgb(cr, ink) + cr.arc(pivot_x, pivot_y, 4, 0, 2 * math.pi) + cr.fill() + cr.restore() + lo, hi = _range(widget) + 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, + rgb=ink, align="center", bold=True, max_width=w - 8) + + +def _draw_needle_edgewise(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + face = _color(widget, "face-color", (250 / 255, 250 / 255, 248 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + needle = _color(widget, "needle-color", (15 / 255, 15 / 255, 15 / 255)) + red = _color(widget, "red-color", (200 / 255, 30 / 255, 30 / 255)) + tick = _color(widget, "tick-color", (20 / 255, 20 / 255, 20 / 255)) + w, h = widget.width, widget.height + x0, y0 = 12, 12 + bw, bh = w - 24, h - 40 + if bw <= 0 or bh <= 0: + return + _box(cr, x0, y0, bw, bh, face, ink) + frac = _frac(widget) + pivot_x, pivot_y = x0 + bw / 2, y0 + bh + 6 + # Edgewise: the needle sweeps a shallow arc; the scale is a + # horizontal band with a red zone at the right end. + cr.save() + _rgb(cr, red) + cr.set_line_width(3) + cr.move_to(x0 + bw * 0.85, y0 + 8) + cr.line_to(x0 + bw - 4, y0 + 8) + cr.stroke() + _rgb(cr, tick) + cr.set_line_width(1) + lo, hi = _range(widget) + for i in range(11): + f = i / 10.0 + x = x0 + 6 + f * (bw - 12) + cr.move_to(x, y0 + 6) + 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) + cr.stroke() + _rgb(cr, needle) + cr.set_line_width(2) + tip_x = x0 + 6 + frac * (bw - 12) + cr.move_to(pivot_x, pivot_y) + cr.line_to(tip_x, y0 + 8) + cr.stroke() + _rgb(cr, ink) + 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, + rgb=ink, align="center", bold=True, max_width=w - 8) + + +def _draw_needle_vu(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + face = _color(widget, "face-color", (248 / 255, 238 / 255, 205 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + needle = _color(widget, "needle-color", (15 / 255, 15 / 255, 15 / 255)) + red = _color(widget, "red-color", (200 / 255, 30 / 255, 30 / 255)) + w, h = widget.width, widget.height + x0, y0 = 12, 10 + bw, bh = w - 24, h - 36 + if bw <= 0 or bh <= 0: + return + _box(cr, x0, y0, bw, bh, face, ink) + frac = _frac(widget) + pivot_x, pivot_y = x0 + bw / 2, y0 + bh + 4 + cr.save() + _rgb(cr, red) + cr.set_line_width(2) + cr.arc(pivot_x, pivot_y, bh * 0.75, math.pi * 1.6, math.pi * 1.75) + cr.stroke() + _rgb(cr, ink) + cr.set_line_width(1) + lo, hi = _range(widget) + for i in range(11): + f = i / 10.0 + angle = math.pi * (1.25 + 0.5 * f) + r0 = bh * 0.72 + cr.move_to(pivot_x + r0 * math.cos(angle), + pivot_y + r0 * math.sin(angle)) + cr.line_to(pivot_x + (r0 + (8 if i % 5 == 0 else 4)) + * math.cos(angle), + pivot_y + (r0 + (8 if i % 5 == 0 else 4)) + * math.sin(angle)) + 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) + cr.stroke() + angle = math.pi * (1.25 + 0.5 * frac) + _rgb(cr, needle) + cr.set_line_width(2) + cr.move_to(pivot_x, pivot_y) + cr.line_to(pivot_x + bh * 0.8 * math.cos(angle), + pivot_y + bh * 0.8 * math.sin(angle)) + cr.stroke() + _rgb(cr, ink) + 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, + max_width=w - 8) + + +# --- tanks --------------------------------------------------------------------- + +def _tank_colours(widget): + return { + "fill": _color(widget, "fill-color", + (40 / 255, 120 / 255, 200 / 255)), + "amber": _color(widget, "amber-color", + (220 / 255, 150 / 255, 0.0)), + "red": _color(widget, "red-color", + (200 / 255, 30 / 255, 30 / 255)), + "ink": _color(widget, "ink-color", (60 / 255, 60 / 255, 60 / 255)), + "pale": _color(widget, "pale-color", + (235 / 255, 242 / 255, 248 / 255)), + "white": _color(widget, "white-color", (1.0, 1.0, 1.0)), + "grid": _color(widget, "grid-color", + (210 / 255, 210 / 255, 210 / 255)), + } + + +def _alarm_lines(cr, widget, x, top, bottom, vertical=False): + """Alarm markers: hi-hi/hi/lo/lo-lo (red/amber/amber/red).""" + 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"])): + y = bottom - level / 100.0 * (bottom - top) + cr.save() + _rgb(cr, colour) + cr.set_line_width(2) + if vertical: + cr.move_to(x, top) + cr.line_to(x, bottom) + else: + cr.move_to(x, y) + cr.line_to(x + 14, y) + cr.stroke() + cr.restore() + + +def _tank_readout(cr, widget, level, x, y, align="left"): + _wtext(cr, widget, "%.1f%%" % level, x, y, size=13, bold=True, + rgb=(0.12, 0.12, 0.12), align=align, + max_width=widget.width - 16) + + +def _draw_vertical_tank(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + cols = _tank_colours(widget) + level = _level(widget) + w, h = widget.width, widget.height + x0, y0 = 24, 16 + bw, bh = w - 62, h - 36 + if bw <= 0 or bh <= 0: + return + _box(cr, x0, y0, bw, bh, cols["pale"], cols["ink"]) + fill_h = bh * level / 100.0 + cr.save() + _rgb(cr, cols["fill"]) + cr.rectangle(x0 + 1, y0 + bh - fill_h, bw - 2, fill_h) + cr.fill() + _rgb(cr, cols["grid"]) + cr.set_line_width(0.5) + for i in range(1, 10): + y = y0 + bh * i / 10.0 + cr.move_to(x0, y) + cr.line_to(x0 + bw, y) + cr.stroke() + cr.restore() + _alarm_lines(cr, widget, x0 + bw + 2, y0, y0 + bh) + _tank_readout(cr, widget, level, x0 + bw / 2, h - 6, align="center") + + +def _draw_horizontal_tank(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + cols = _tank_colours(widget) + level = _level(widget) + w, h = widget.width, widget.height + x0, y0 = 16, 22 + bw, bh = w - 32, h - 48 + if bw <= 0 or bh <= 0: + return + _rounded_box(cr, x0, y0, bw, bh, cols["pale"], cols["ink"], + radius=bh / 2) + fill_w = bw * level / 100.0 + if fill_w > 0: + cr.save() + _rounded_box(cr, x0 + 1, y0 + 1, max(2, fill_w - 2), bh - 2, + cols["fill"], cols["fill"], radius=bh / 2 - 1) + cr.restore() + hi_hi, hi, lo, lo_lo = _alarms(widget) + for mark, colour in ((hi_hi, cols["red"]), (hi, cols["amber"]), + (lo, cols["amber"]), (lo_lo, cols["red"])): + x = x0 + bw * mark / 100.0 + cr.save() + _rgb(cr, colour) + cr.set_line_width(2) + cr.move_to(x, y0) + cr.line_to(x, y0 + bh) + cr.stroke() + cr.restore() + _tank_readout(cr, widget, level, x0 + bw / 2, h - 6, align="center") + + +def _draw_spherical_tank(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + cols = _tank_colours(widget) + level = _level(widget) + w, h = widget.width, widget.height + cx, cy = w / 2, h / 2 - 4 + r = min(w, h) / 2 - 14 + if r < 4: + return + # Legs. + cr.save() + _rgb(cr, cols["ink"]) + cr.set_line_width(2) + cr.move_to(cx - r * 0.6, cy + r * 0.7) + cr.line_to(cx - r * 0.8, h - 8) + cr.move_to(cx + r * 0.6, cy + r * 0.7) + cr.line_to(cx + r * 0.8, h - 8) + cr.stroke() + cr.restore() + cr.save() + _rgb(cr, cols["pale"]) + cr.arc(cx, cy, r, 0, 2 * math.pi) + cr.fill_preserve() + cr.clip() + fill_h = 2 * r * level / 100.0 + _rgb(cr, cols["fill"]) + cr.rectangle(cx - r, cy + r - fill_h, 2 * r, fill_h) + cr.fill() + cr.restore() + cr.save() + _rgb(cr, cols["ink"]) + cr.set_line_width(1.5) + cr.arc(cx, cy, r, 0, 2 * math.pi) + cr.stroke() + cr.restore() + _alarm_lines(cr, widget, cx + r + 2, cy - r, cy + r) + _tank_readout(cr, widget, level, cx, h - 4, align="center") + + +def _draw_sight_glass(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + cols = _tank_colours(widget) + steel = _color(widget, "steel-color", + (150 / 255, 150 / 255, 150 / 255)) + level = _level(widget) + w, h = widget.width, widget.height + cx = w / 2 + tube_w = 26 + x0 = cx - tube_w / 2 + top, bot = 20, h - 24 + if bot - top < 10: + return + # Top/bottom pipes. + _box(cr, cx - 4, 6, 8, 14, steel, cols["ink"]) + _box(cr, cx - 4, bot, 8, 14, steel, cols["ink"]) + _box(cr, x0, top, tube_w, bot - top, cols["white"], steel) + fill_h = (bot - top) * level / 100.0 + cr.save() + _rgb(cr, cols["fill"]) + cr.rectangle(x0 + 2, bot - fill_h, tube_w - 4, fill_h) + cr.fill() + cr.restore() + for i in range(11): + y = bot - (bot - top) * i / 10.0 + cr.save() + _rgb(cr, cols["ink"]) + cr.set_line_width(1 if i % 5 else 2) + cr.move_to(x0 - (6 if i % 5 else 10), y) + 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) + _alarm_lines(cr, widget, x0 + tube_w + 2, top, bot) + _tank_readout(cr, widget, level, cx, h - 6, align="center") + + +def _draw_level_column(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + cols = _tank_colours(widget) + level = _level(widget) + w, h = widget.width, widget.height + cx = w / 2 - 10 + col_w = 18 + x0 = cx - col_w / 2 + top, bot = 16, h - 24 + if bot - top < 10: + return + _box(cr, x0, top, col_w, bot - top, cols["pale"], cols["ink"]) + fill_h = (bot - top) * level / 100.0 + cr.save() + _rgb(cr, cols["fill"]) + cr.rectangle(x0 + 1, bot - fill_h, col_w - 2, fill_h) + cr.fill() + cr.restore() + # Float marker: a red bar at the level. + float_y = bot - fill_h + cr.save() + _rgb(cr, cols["red"]) + cr.rectangle(x0 - 6, float_y - 3, col_w + 12, 6) + cr.fill() + cr.restore() + 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) + _alarm_lines(cr, widget, x0 + col_w + 2, top, bot) + _tank_readout(cr, widget, level, cx + 44, top + 12, align="center") + + +def _draw_level_transmitter(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + cols = _tank_colours(widget) + level = _level(widget) + ma = 4.0 + 16.0 * level / 100.0 + w, h = widget.width, widget.height + x0, y0 = 16, 16 + bw, bh = 26, h - 48 + if bw <= 0 or bh <= 0: + return + _box(cr, x0, y0, bw, bh, cols["pale"], cols["ink"]) + fill_h = bh * level / 100.0 + cr.save() + _rgb(cr, cols["fill"]) + 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) + _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) + + +def _draw_open_channel(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + cols = _tank_colours(widget) + surface = _color(widget, "surface-color", + (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 + if bw <= 0 or bh <= 0: + return + fill_h = bh * level / 100.0 + cr.save() + _rgb(cr, cols["fill"], 0.75) + cr.rectangle(x0, y0 + bh - fill_h, bw, fill_h) + cr.fill() + _rgb(cr, surface) + cr.set_line_width(2) + cr.move_to(x0, y0 + bh - fill_h) + cr.line_to(x0 + bw, y0 + bh - fill_h) + cr.stroke() + _rgb(cr, cols["ink"]) + cr.set_line_width(1.5) + cr.move_to(x0, y0) + cr.line_to(x0, y0 + bh) + cr.line_to(x0 + bw, y0 + bh) + cr.line_to(x0 + bw, y0) + cr.stroke() + cr.restore() + 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) + _tank_readout(cr, widget, level, x0 + bw / 2, h - 6, align="center") + + +def _draw_tank_alarms(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + cols = _tank_colours(widget) + level = _level(widget) + hi_hi, hi, lo, lo_lo = _alarms(widget) + w, h = widget.width, widget.height + x0, y0 = 16, 16 + bw, bh = w - 84, h - 36 + if bw <= 0 or bh <= 0: + return + _box(cr, x0, y0, bw, bh, cols["pale"], cols["ink"]) + fill_h = bh * level / 100.0 + cr.save() + _rgb(cr, cols["fill"]) + 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) + 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 + 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.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 + _tank_readout(cr, widget, level, x0 + bw / 2, h - 6, align="center") + + +# --- lamps / LEDs -------------------------------------------------------------- + +def _lens_rgb(lens, on, brightness): + """Lens colour: dim tint when off, brighter with brightness.""" + dim = tuple(0.3 * c + 0.7 * (40 / 255) for c in lens) + if not on: + return dim + f = brightness / 100.0 + return tuple(dim[i] + (lens[i] - dim[i]) * (0.35 + 0.65 * f) + for i in range(3)) + + +def _draw_panel_lamp(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + bezel = _color(widget, "bezel-color", (70 / 255, 70 / 255, 70 / 255)) + ring = _color(widget, "ring-color", (160 / 255, 160 / 255, 160 / 255)) + lens = _color(widget, "lens-color", (220 / 255, 30 / 255, 30 / 255)) + on = _on(widget) + brightness = _brightness(widget) + w, h = widget.width, widget.height + cx, cy = w / 2, h / 2 - (6 if widget.text != widget.name else 0) + r = min(w, h) / 2 - 10 + if r < 4: + return + cr.save() + _rgb(cr, bezel) + cr.arc(cx, cy, r, 0, 2 * math.pi) + cr.fill() + _rgb(cr, ring) + cr.arc(cx, cy, r - 3, 0, 2 * math.pi) + cr.fill() + _rgb(cr, _lens_rgb(lens, on, brightness)) + cr.arc(cx, cy, r - 7, 0, 2 * math.pi) + cr.fill() + if on and brightness > 70: + _rgb(cr, (1.0, 1.0, 1.0), 0.35) + cr.arc(cx, cy, r - 2, 0, 2 * math.pi) + cr.set_line_width(2) + cr.stroke() + _rgb(cr, (1.0, 1.0, 1.0), 0.5) + cr.arc(cx - r * 0.3, cy - r * 0.35, r * 0.18, 0, 2 * math.pi) + cr.fill() + cr.restore() + if widget.text != widget.name: + _wtext(cr, widget, widget.text, cx, h - 6, size=11, + align="center", rgb=(0.25, 0.25, 0.25), + max_width=w - 8) + + +def _draw_led(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + dark = _color(widget, "dark-color", (40 / 255, 40 / 255, 40 / 255)) + lens = _color(widget, "lens-color", (220 / 255, 30 / 255, 30 / 255)) + lead = _color(widget, "lead-color", (120 / 255, 120 / 255, 120 / 255)) + on = _on(widget) + brightness = _brightness(widget) + w, h = widget.width, widget.height + cx = w / 2 + block_w, block_h = min(w - 16, 64), min(h - 30, 54) + bx, by = cx - block_w / 2, 10 + _rounded_box(cr, bx, by, block_w, block_h, dark, dark, radius=6) + r = min(block_w, block_h) / 2 - 6 + cr.save() + _rgb(cr, _lens_rgb(lens, on, brightness)) + cr.arc(cx, by + block_h / 2, max(r, 3), 0, 2 * math.pi) + cr.fill() + _rgb(cr, (1.0, 1.0, 1.0), 0.5) + cr.arc(cx - r * 0.3, by + block_h / 2 - r * 0.3, max(r * 0.2, 1), + 0, 2 * math.pi) + cr.fill() + cr.restore() + cr.save() + _rgb(cr, lead) + cr.set_line_width(3) + cr.move_to(cx - 10, by + block_h) + cr.line_to(cx - 10, h - 6) + cr.move_to(cx + 10, by + block_h) + cr.line_to(cx + 10, h - 6) + cr.stroke() + cr.restore() + if widget.text != widget.name: + _wtext(cr, widget, widget.text, cx, h - 4, size=11, + align="center", rgb=(0.25, 0.25, 0.25), + max_width=w - 8) + + +def _draw_rgb_led(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + dark = _color(widget, "dark-color", (40 / 255, 40 / 255, 40 / 255)) + red_c = _color(widget, "red-channel-color", + (220 / 255, 30 / 255, 30 / 255)) + green_c = _color(widget, "green-channel-color", + (30 / 255, 200 / 255, 60 / 255)) + blue_c = _color(widget, "blue-channel-color", + (40 / 255, 120 / 255, 230 / 255)) + outline = _color(widget, "swatch-outline-color", + (60 / 255, 60 / 255, 60 / 255)) + brightness = _brightness(widget) + all_on = _prop_bool(widget, "all-on", False) + red_on = all_on or _prop_bool(widget, "red-on", False) + green_on = all_on or _prop_bool(widget, "green-on", False) + blue_on = all_on or _prop_bool(widget, "blue-on", False) + w, h = widget.width, widget.height + cx = w / 2 + block_w, block_h = min(w - 16, 64), min(h - 34, 50) + bx, by = cx - block_w / 2, 8 + _rounded_box(cr, bx, by, block_w, block_h, dark, dark, radius=6) + combined = ( + red_c[0] if red_on else 0.12, + green_c[1] if green_on else 0.12, + blue_c[2] if blue_on else 0.12, + ) + r = min(block_w, block_h) / 2 - 6 + cr.save() + _rgb(cr, _lens_rgb(combined, red_on or green_on or blue_on, + brightness)) + cr.arc(cx, by + block_h / 2, max(r, 3), 0, 2 * math.pi) + cr.fill() + cr.restore() + sw = 14 + sx = cx - (3 * sw + 2 * 6) / 2 + sy = by + block_h + 6 + for on, colour in ((red_on, red_c), (green_on, green_c), + (blue_on, blue_c)): + _box(cr, sx, sy, sw, sw, + colour if on else (30 / 255, 30 / 255, 30 / 255), outline) + sx += sw + 6 + + +def _draw_stack_light(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + dark = _color(widget, "dark-color", (40 / 255, 40 / 255, 40 / 255)) + red = _color(widget, "red-color", (220 / 255, 30 / 255, 30 / 255)) + amber = _color(widget, "amber-color", (230 / 255, 160 / 255, 20 / 255)) + green = _color(widget, "green-color", (30 / 255, 200 / 255, 60 / 255)) + outline = _color(widget, "tier-outline-color", + (60 / 255, 60 / 255, 60 / 255)) + all_on = _prop_bool(widget, "all-on", False) + tiers = ( + ("red-on", "red-brightness", red), + ("amber-on", "amber-brightness", amber), + ("green-on", "green-brightness", green), + ) + w, h = widget.width, widget.height + cx = w / 2 + pole_h = 18 + tier_h = max(14, (h - pole_h - 26) / 3) + tier_w = min(54, w - 20) + x0 = cx - tier_w / 2 + y = 8 + for prop, bright_prop, colour in tiers: + on = all_on or _prop_bool(widget, prop, False) + bright = _prop_int(widget, bright_prop, 100) + _rounded_box(cr, x0, y, tier_w, tier_h - 3, + _lens_rgb(colour, on, bright), outline, radius=6) + y += tier_h + # Pole + base. + _box(cr, cx - 3, y, 6, pole_h, dark, dark) + _box(cr, cx - tier_w / 2 - 6, y + pole_h, tier_w + 12, 10, dark, + dark) + + +def _draw_beacon(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + dark = _color(widget, "dark-color", (40 / 255, 40 / 255, 40 / 255)) + beacon = _color(widget, "beacon-color", + (230 / 255, 160 / 255, 20 / 255)) + on = _on(widget) + phase = _prop_bool(widget, "phase", True) + brightness = _brightness(widget) + lit = on and phase + w, h = widget.width, widget.height + cx = w / 2 + base_y = h - 18 + dome_r = min(w / 2 - 12, (h - 30) / 2) + if dome_r < 4: + return + cy = base_y - dome_r + if lit: + cr.save() + _rgb(cr, beacon, 0.25) + cr.move_to(cx, cy) + cr.line_to(4, cy - dome_r * 0.4) + cr.line_to(4, cy + dome_r * 0.4) + cr.close_path() + cr.fill() + cr.move_to(cx, cy) + cr.line_to(w - 4, cy - dome_r * 0.4) + cr.line_to(w - 4, cy + dome_r * 0.4) + cr.close_path() + cr.fill() + cr.restore() + cr.save() + _rgb(cr, _lens_rgb(beacon, lit, brightness)) + cr.arc(cx, cy, dome_r, math.pi, 2 * math.pi) + cr.close_path() + cr.fill_preserve() + _rgb(cr, dark) + cr.set_line_width(2) + cr.stroke() + cr.restore() + _box(cr, cx - dome_r - 4, base_y, 2 * dome_r + 8, 10, dark, dark) + _wtext(cr, widget, "%.1f Hz" % _prop_float(widget, "flash-rate", 2.0), + cx, h - 4, size=11, align="center", rgb=(0.25, 0.25, 0.25), + max_width=w - 8) + + +def _draw_lamp_test_button(cr, widget): + face = _color(widget, "face-color", (200 / 255, 200 / 255, 200 / 255)) + bezel = _color(widget, "bezel-color", (70 / 255, 70 / 255, 70 / 255)) + w, h = widget.width, widget.height + _rounded_box(cr, 0, 0, w, h, bezel, bezel, radius=6) + _rounded_box(cr, 4, 4, w - 8, h - 8, face, bezel, radius=5) + _wtext(cr, widget, "TEST", w / 2, h / 2 + 5, size=12, bold=True, + align="center", rgb=(0.15, 0.15, 0.15), max_width=w - 16) + + +# --- segment displays ---------------------------------------------------------- + +_SEVEN_MAP = { + "0": "abcdef", "1": "bc", "2": "abged", "3": "abgcd", + "4": "fgbc", "5": "afgcd", "6": "afgedc", "7": "abc", + "8": "abcdefg", "9": "abcdfg", "-": "g", "_": "d", " ": "", +} + +# 14-segment: a top, b upper-right, c lower-right, d bottom, +# e lower-left, f upper-left, g1/g2 middle halves, h/i centre +# verticals, j/k/l/m diagonals (top-left, top-right, bottom-left, +# bottom-right). 16-segment splits a -> a1/a2 and d -> d1/d2. +_FOURTEEN_MAP = { + "0": "abcdef", "1": "bc", "2": "abg1g2ed", "3": "abg1g2cd", + "4": "fg1g2bc", "5": "afg1g2cd", "6": "afg1g2ecd", + "7": "abc", "8": "abcdefg1g2", "9": "abcdfg1g2", + "A": "abcfg1g2", "B": "abcdfg1g2hi", "C": "afed", + "D": "abcdhi", "E": "afg1g2ed", "F": "afg1g2e", + "G": "afg1g2cde", "H": "fg1g2bce", "I": "adhi", + "J": "bcde", "K": "fg1hkl", "L": "fed", "M": "febchi", + "N": "febcjm", "O": "abcdef", "P": "abfg1g2e", + "Q": "abcdefm", "R": "abfg1g2em", "S": "afg1g2cd", + "T": "ahi", "U": "febcd", "V": "lm", "W": "febci", + "X": "jklm", "Y": "fg1g2bi", "Z": "akld", + "-": "g1g2", "_": "d", "=": "g1g2d", "+": "g1g2hi", + "/": "kl", " ": "", +} +_SIXTEEN_MAP = dict(_FOURTEEN_MAP) +_SIXTEEN_MAP.update({"M": "febchi", "W": "febchi"}) + + +def _seg_thickness(w, h): + return max(2.0, min(w, h) / 7.0) + + +def _seg_rects(x, y, w, h, sixteen=False): + """Segment name -> rect (or line endpoints for diagonals).""" + t = _seg_thickness(w, h) + mid = y + h / 2 + cx = x + w / 2 + rects = { + "a": (x + 2, y, w - 4, t), + "b": (x + w - t, y + 2, t, h / 2 - 4), + "c": (x + w - t, mid + 2, t, h / 2 - 4), + "d": (x + 2, y + h - t, w - 4, t), + "e": (x, mid + 2, t, h / 2 - 4), + "f": (x, y + 2, t, h / 2 - 4), + "g": (x + 2, mid - t / 2, w - 4, t), + "g1": (x + 2, mid - t / 2, w / 2 - 3, t), + "g2": (cx + 1, mid - t / 2, w / 2 - 3, t), + "h": (cx - t / 2, y + 2, t, h / 2 - 4), + "i": (cx - t / 2, mid + 2, t, h / 2 - 4), + } + if sixteen: + rects["a1"] = (x + 2, y, w / 2 - 3, t) + rects["a2"] = (cx + 1, y, w / 2 - 3, t) + rects["d1"] = (x + 2, y + h - t, w / 2 - 3, t) + rects["d2"] = (cx + 1, y + h - t, w / 2 - 3, t) + lines = { + "j": (x + 2, y + 2, cx, mid), + "k": (x + w - 2, y + 2, cx, mid), + "l": (x + 2, y + h - 2, cx, mid), + "m": (x + w - 2, y + h - 2, cx, mid), + } + return rects, lines + + +def _draw_seg_digit(cr, x, y, w, h, ch, on_rgb, off_rgb, sixteen=False): + """One 7/14/16-segment digit; off segments stay faintly visible.""" + if sixteen: + raw = _SIXTEEN_MAP.get(ch.upper(), "") + lit = set() + i = 0 + while i < len(raw): + if raw[i:i + 2] in ("g1", "g2"): + lit.add(raw[i:i + 2]) + i += 2 + elif raw[i] == "a": + lit.update(("a1", "a2")) + i += 1 + elif raw[i] == "d": + lit.update(("d1", "d2")) + i += 1 + else: + lit.add(raw[i]) + i += 1 + universe = ("a1", "a2", "b", "c", "d1", "d2", "e", "f", "g1", + "g2", "h", "i", "j", "k", "l", "m") + else: + raw = _FOURTEEN_MAP.get(ch.upper(), _SEVEN_MAP.get(ch, "")) + lit = set() + i = 0 + while i < len(raw): + if raw[i:i + 2] in ("g1", "g2"): + lit.add(raw[i:i + 2]) + i += 2 + else: + lit.add(raw[i]) + i += 1 + if ch in _SEVEN_MAP and ch not in _FOURTEEN_MAP: + lit = set(_SEVEN_MAP[ch]) + universe = ("a", "b", "c", "d", "e", "f", "g") + else: + universe = ("a", "b", "c", "d", "e", "f", "g1", "g2", "h", + "i", "j", "k", "l", "m") + rects, lines = _seg_rects(x, y, w, h, sixteen=sixteen) + t = _seg_thickness(w, h) + for seg in universe: + colour = on_rgb if seg in lit else off_rgb + cr.save() + _rgb(cr, colour) + if seg in rects: + rx, ry, rw, rh = rects[seg] + cr.rectangle(rx, ry, rw, rh) + cr.fill() + else: + x0, y0, x1, y1 = lines[seg] + cr.set_line_width(t) + cr.set_line_cap(1) + cr.move_to(x0, y0) + cr.line_to(x1, y1) + cr.stroke() + cr.restore() + + +def _led_digits_text(value, digits, dp): + """Zero-padded digit string + decimal-point index (C shown_digits + / decimal_point_after). Returns (digits_str, point_after_index) + where point_after is -1 when there is no point.""" + max_value = (10.0 ** digits - 1.0) / (10.0 ** dp) if dp else \ + float(10 ** digits - 1) + value = max(0.0, min(max_value, value)) + text = "%.*f" % (dp, value) + bare = text.replace(".", "").replace("-", "") + if len(bare) < digits: + bare = "0" * (digits - len(bare)) + bare + else: + bare = bare[-digits:] + point_after = digits - dp - 1 if dp > 0 else -1 + return bare, point_after + + +def _draw_led_digits(cr, widget): + kind = widget.pkind + 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)) + lit = _color(widget, "lit-color", (255 / 255, 60 / 255, 35 / 255)) + _rounded_box(cr, 0, 0, widget.width, widget.height, bezel, bezel, + radius=6) + text, point_after = _led_digits_text(_value(widget), digits, dp) + pad = 10 + gap = 6 + avail_w = widget.width - 2 * pad - gap * (digits - 1) + dw = avail_w / digits if digits else avail_w + dh = widget.height - 20 + if dw <= 2 or dh <= 4: + return + for i, ch in enumerate(text): + x = pad + i * (dw + gap) + _draw_seg_digit(cr, x, 10, dw, dh, ch, lit, dim, + sixteen=False) + if i == point_after: + cr.save() + _rgb(cr, lit) + cr.arc(x + dw + gap / 2, 10 + dh, 2.5, 0, 2 * math.pi) + cr.fill() + cr.restore() + + +def _draw_digital_readout(cr, widget): + dark = _color(widget, "dark-color", (30 / 255, 30 / 255, 30 / 255)) + off = _color(widget, "segment-off-color", + (50 / 255, 45 / 255, 20 / 255)) + on = _color(widget, "segment-on-color", + (255 / 255, 176 / 255, 0.0)) + _rounded_box(cr, 0, 0, widget.width, widget.height, dark, dark, + radius=6) + digits = 4 + dp = 1 + text, point_after = _led_digits_text(_value(widget), digits, dp) + pad = 10 + gap = 6 + avail_w = widget.width - 2 * pad - gap * (digits - 1) + dw = avail_w / digits + dh = widget.height - 20 + if dw <= 2 or dh <= 4: + return + for i, ch in enumerate(text): + x = pad + i * (dw + gap) + _draw_seg_digit(cr, x, 10, dw, dh, ch, on, off, sixteen=False) + if i == point_after: + cr.save() + _rgb(cr, on) + cr.arc(x + dw + gap / 2, 10 + dh, 2.5, 0, 2 * math.pi) + cr.fill() + cr.restore() + + +def _draw_seg_display(cr, widget): + kind = widget.pkind + sixteen = kind.startswith("Seg16") + 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)) + lit = _color(widget, "lit-color", (255 / 255, 176 / 255, 0.0)) + _rounded_box(cr, 0, 0, widget.width, widget.height, bezel, bezel, + radius=6) + raw = widget.get_prop( + "value", + widget.prop_def("value").default + if widget.prop_def("value") is not None else "") + chars = [] + point_after = -1 + for ch in str(raw).upper(): + if ch in ".:": + point_after = len(chars) - 1 + continue + chars.append(ch) + if len(chars) >= digits: + break + while len(chars) < digits: + chars.append(" ") + pad = 10 + gap = 5 + avail_w = widget.width - 2 * pad - gap * (digits - 1) + dw = avail_w / digits if digits else avail_w + dh = widget.height - 20 + if dw <= 2 or dh <= 4: + return + for i, ch in enumerate(chars): + x = pad + i * (dw + gap) + _draw_seg_digit(cr, x, 10, dw, dh, ch, lit, dim, + sixteen=sixteen) + if i == point_after: + cr.save() + _rgb(cr, lit) + cr.arc(x + dw + gap / 2, 10 + dh, 2.5, 0, 2 * math.pi) + cr.fill() + cr.restore() + + +# --- switches ------------------------------------------------------------------ + +def _draw_rocker(cr, widget, illuminated=False, double=False): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + bezel = _color(widget, "bezel-color", (38 / 255, 38 / 255, 42 / 255)) + panel = _color(widget, "panel-color", (58 / 255, 58 / 255, 62 / 255)) + rocker = _color(widget, "rocker-color", + (190 / 255, 190 / 255, 195 / 255)) + green = _color(widget, "green-color", (0.0, 180 / 255, 0.0)) + dimred = _color(widget, "dimred-color", (120 / 255, 30 / 255, 30 / 255)) + greenlit = _color(widget, "greenlit-color", + (60 / 255, 255 / 255, 90 / 255)) + w, h = widget.width, widget.height + _rounded_box(cr, 6, 6, w - 12, h - 12, panel, bezel, radius=8) + if double: + position = _prop_int(widget, "position", 0) + tilt = 8 if position > 0 else -8 if position < 0 else 0 + else: + tilt = 8 if _on(widget) else -8 + x0, y0 = 16, 14 + rw, rh = w - 32, h - 28 + if rw <= 0 or rh <= 0: + return + # Rocker quad: top edge raised when on (up is on). + cr.save() + _rgb(cr, rocker) + cr.move_to(x0, y0 - tilt if tilt > 0 else y0) + cr.line_to(x0 + rw, y0 + tilt if tilt < 0 else y0) + cr.line_to(x0 + rw, y0 + rh + (tilt if tilt > 0 else 0)) + cr.line_to(x0, y0 + rh + (-tilt if tilt < 0 else 0)) + cr.close_path() + cr.fill_preserve() + _rgb(cr, bezel) + cr.set_line_width(1.5) + cr.stroke() + cr.restore() + _wtext(cr, widget, "I", w / 2, y0 + 12, size=11, align="center", + rgb=(0.15, 0.15, 0.15), max_width=20) + _wtext(cr, widget, "O", w / 2, y0 + rh - 4, size=11, + align="center", rgb=(0.15, 0.15, 0.15), max_width=20) + if illuminated: + on = _on(widget) + _rounded_box(cr, w / 2 - 12, y0 + rh / 2 - 5, 24, 10, + greenlit if on else dimred, + green if on else dimred, radius=4) + + +def _draw_toggle_switch(cr, widget, illuminated=False): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + bezel = _color(widget, "bezel-color", (38 / 255, 38 / 255, 42 / 255)) + panel = _color(widget, "panel-color", (58 / 255, 58 / 255, 62 / 255)) + plate = _color(widget, "plate-color", (210 / 255, 210 / 255, 210 / 255)) + greenlit = _color(widget, "greenlit-color", + (60 / 255, 255 / 255, 90 / 255)) + redlit = _color(widget, "redlit-color", + (255 / 255, 70 / 255, 60 / 255)) + dimred = _color(widget, "dimred-color", (120 / 255, 30 / 255, 30 / 255)) + on = _on(widget) + w, h = widget.width, widget.height + cx = w / 2 + _rounded_box(cr, 6, 6, w - 12, h - 12, panel, bezel, radius=8) + _rounded_box(cr, cx - 16, 10, 32, h - 20, plate, bezel, radius=6) + pivot_x, pivot_y = cx, h / 2 + lever_w = max(2, _prop_int(widget, "lever-line-width", 10)) + lever_len = h * 0.32 + angle = -math.pi / 2 if on else math.pi / 2 + tip_x = pivot_x + lever_len * math.cos(angle) + tip_y = pivot_y + lever_len * math.sin(angle) + cr.save() + _rgb(cr, bezel) + cr.set_line_width(lever_w) + cr.set_line_cap(1) + cr.move_to(pivot_x, pivot_y) + cr.line_to(tip_x, tip_y) + cr.stroke() + _rgb(cr, (230 / 255, 230 / 255, 230 / 255)) + cr.arc(tip_x, tip_y, lever_w / 2 + 2, 0, 2 * math.pi) + cr.fill() + _rgb(cr, bezel) + cr.arc(pivot_x, pivot_y, 6, 0, 2 * math.pi) + cr.fill() + cr.restore() + if illuminated: + _rgb(cr, greenlit if on else dimred) + cr.arc(cx + 22, 18, 5, 0, 2 * math.pi) + cr.fill() + else: + _rgb(cr, greenlit if on else redlit) + cr.arc(cx + 22, 18, 4, 0, 2 * math.pi) + cr.fill() + _wtext(cr, widget, "ON" if on else "OFF", cx, h - 8, size=10, + align="center", rgb=(0.9, 0.9, 0.9), max_width=40) + + +def _draw_slide_switch(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + bezel = _color(widget, "bezel-color", (38 / 255, 38 / 255, 42 / 255)) + panel = _color(widget, "panel-color", (58 / 255, 58 / 255, 62 / 255)) + rocker = _color(widget, "rocker-color", + (190 / 255, 190 / 255, 195 / 255)) + green = _color(widget, "green-color", (0.0, 180 / 255, 0.0)) + on = _on(widget) + w, h = widget.width, widget.height + _rounded_box(cr, 6, 6, w - 12, h - 12, panel, bezel, radius=8) + track_h = 16 + ty = h / 2 - track_h / 2 + _rounded_box(cr, 14, ty, w - 28, track_h, bezel, bezel, + radius=track_h / 2) + knob_w = 30 + kx = (w - 14 - knob_w) if on else 14 + _rounded_box(cr, kx, ty - 5, knob_w, track_h + 10, rocker, bezel, + radius=6) + _wtext(cr, widget, "ON" if on else "OFF", w / 2, h - 8, size=10, + align="center", rgb=(0.9, 0.9, 0.9), max_width=40) + + +def _draw_key_switch(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + bezel = _color(widget, "bezel-color", (38 / 255, 38 / 255, 42 / 255)) + panel = _color(widget, "panel-color", (58 / 255, 58 / 255, 62 / 255)) + 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) + w, h = widget.width, widget.height + cx, cy = w / 2, h / 2 + r = min(w, h) / 2 - 10 + if r < 4: + return + _rounded_box(cr, 6, 6, w - 12, h - 12, panel, bezel, radius=8) + cr.save() + _rgb(cr, plate) + cr.arc(cx, cy, r, 0, 2 * math.pi) + cr.fill_preserve() + _rgb(cr, bezel) + cr.set_line_width(2) + cr.stroke() + # Key slot pointing up; positions around it. + _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.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.stroke() + _rgb(cr, amber) + cr.arc(cx, cy - r - 6, 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) + + +def _draw_rotary(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + bezel = _color(widget, "bezel-color", (38 / 255, 38 / 255, 42 / 255)) + panel = _color(widget, "panel-color", (58 / 255, 58 / 255, 62 / 255)) + plate = _color(widget, "plate-color", (210 / 255, 210 / 255, 210 / 255)) + positions = max(2, _prop_int(widget, "positions", 3)) + position = max(0, min(positions - 1, + _prop_int(widget, "position", 0))) + w, h = widget.width, widget.height + cx, cy = w / 2, h / 2 + r = min(w, h) / 2 - 14 + if r < 4: + return + _rounded_box(cr, 6, 6, w - 12, h - 12, panel, bezel, radius=8) + for i in range(positions): + angle = -math.pi * 0.75 + i * (math.pi * 1.5 + / (positions - 1)) + tx = cx + (r + 8) * math.cos(angle) + ty = cy + (r + 8) * math.sin(angle) + _wtext(cr, widget, str(i), tx, ty + 4, size=10, + align="center", rgb=(0.9, 0.9, 0.9), max_width=16) + cr.save() + _rgb(cr, plate) + cr.arc(cx, cy, r, 0, 2 * math.pi) + cr.fill_preserve() + _rgb(cr, bezel) + cr.set_line_width(2) + cr.stroke() + angle = -math.pi * 0.75 + position * (math.pi * 1.5 + / (positions - 1)) + _rgb(cr, bezel) + cr.set_line_width(max(2, _prop_int(widget, "pointer-line-width", + 8))) + cr.set_line_cap(1) + cr.move_to(cx, cy) + cr.line_to(cx + (r - 6) * math.cos(angle), + cy + (r - 6) * math.sin(angle)) + cr.stroke() + _rgb(cr, bezel) + cr.arc(cx, cy, 5, 0, 2 * math.pi) + cr.fill() + cr.restore() + + +def _draw_push_button(cr, widget, latching=False): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + bezel = _color(widget, "bezel-color", (38 / 255, 38 / 255, 42 / 255)) + greenlit = _color(widget, "greenlit-color", + (60 / 255, 255 / 255, 90 / 255)) + redlit = _color(widget, "redlit-color", + (255 / 255, 70 / 255, 60 / 255)) + on = _on(widget) + w, h = widget.width, widget.height + cx, cy = w / 2, h / 2 + 4 + r = min(w, h) / 2 - 12 + if r < 4: + return + cr.save() + _rgb(cr, bezel) + cr.arc(cx, cy, r + 5, 0, 2 * math.pi) + cr.fill() + face = (0.75, 0.75, 0.78) if (on and latching) else \ + (0.9, 0.9, 0.92) + _rgb(cr, face) + cr.arc(cx, cy, r, 0, 2 * math.pi) + cr.fill_preserve() + _rgb(cr, bezel) + cr.set_line_width(2) + cr.stroke() + _rgb(cr, (1.0, 1.0, 1.0), 0.5) + cr.arc(cx - r * 0.3, cy - r * 0.35, r * 0.2, 0, 2 * math.pi) + cr.fill() + cr.restore() + _rgb(cr, greenlit if on else redlit) + cr.arc(cx, cy - r - 8, 5, 0, 2 * math.pi) + cr.fill() + _wtext(cr, widget, widget.text if widget.text != widget.name + else ("PUSH" if not latching else "LATCH"), cx, h - 6, + size=11, align="center", rgb=(0.25, 0.25, 0.25), + max_width=w - 8) + + +def _draw_emergency_stop(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + surround = _color(widget, "surround-color", + (255 / 255, 220 / 255, 0.0)) + red = _color(widget, "red-color", (200 / 255, 30 / 255, 30 / 255)) + redlit = _color(widget, "redlit-color", + (255 / 255, 70 / 255, 60 / 255)) + on = _on(widget) + w, h = widget.width, widget.height + cx, cy = w / 2, h / 2 + r = min(w, h) / 2 - 10 + if r < 4: + return + _rounded_box(cr, 8, 8, w - 16, h - 16, surround, surround, radius=8) + cr.save() + _rgb(cr, (40 / 255, 40 / 255, 40 / 255)) + cr.rectangle(cx - 8, cy - 4, 16, r) + cr.fill() + _rgb(cr, redlit if on else red) + cr.arc(cx, cy - (2 if on else 6), r * 0.8, 0, 2 * math.pi) + cr.fill_preserve() + _rgb(cr, (120 / 255, 20 / 255, 20 / 255)) + cr.set_line_width(2) + cr.stroke() + _rgb(cr, (1.0, 1.0, 1.0), 0.4) + cr.arc(cx - r * 0.25, cy - r * 0.35, r * 0.18, 0, 2 * math.pi) + cr.fill() + cr.restore() + _wtext(cr, widget, "STOP", cx, h - 6, size=11, bold=True, + align="center", rgb=(0.6, 0.1, 0.1), max_width=w - 8) + + +def _draw_circuit_breaker(cr, widget): + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + bezel = _color(widget, "bezel-color", (38 / 255, 38 / 255, 42 / 255)) + panel = _color(widget, "panel-color", (58 / 255, 58 / 255, 62 / 255)) + plate = _color(widget, "plate-color", (210 / 255, 210 / 255, 210 / 255)) + green = _color(widget, "green-color", (0.0, 180 / 255, 0.0)) + red = _color(widget, "red-color", (200 / 255, 30 / 255, 30 / 255)) + w, h = widget.width, widget.height + _rounded_box(cr, 6, 6, w - 12, h - 12, panel, bezel, radius=8) + bw, bh = min(64, w - 40), h - 36 + bx, by = (w - bw) / 2, 14 + if bw <= 0 or bh <= 0: + return + _rounded_box(cr, bx, by, bw, bh, plate, bezel, radius=6) + lever_w = max(4, _prop_int(widget, "lever-line-width", 12)) + cr.save() + _rgb(cr, bezel) + cr.set_line_width(lever_w) + cr.set_line_cap(1) + cr.move_to(bx + bw / 2, by + bh / 2 + 12) + cr.line_to(bx + bw / 2, by + 12) + cr.stroke() + cr.restore() + _rgb(cr, green) + cr.arc(bx + bw - 10, by + 12, 5, 0, 2 * math.pi) + cr.fill() + _rgb(cr, red) + cr.arc(bx + bw - 10, by + bh - 12, 5, 0, 2 * math.pi) + cr.fill() + _wtext(cr, widget, "ON", bx + bw / 2, by + bh - 4, size=10, + align="center", rgb=(0.25, 0.25, 0.25), max_width=bw) + + +# --- panel furniture ----------------------------------------------------------- + +def _draw_bezel(cr, widget): + panel = _color(widget, "panel-color", (210 / 255, 210 / 255, 205 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + _bg(cr, widget, panel, stroke=ink) + margin = 14 + cr.save() + _rgb(cr, (1.0, 1.0, 1.0)) + cr.rectangle(margin, margin, widget.width - 2 * margin, + widget.height - 2 * margin) + cr.fill_preserve() + _rgb(cr, ink) + cr.set_line_width(1.5) + cr.stroke() + cr.restore() + _panel_screws(cr, widget) + if widget.text != widget.name: + _wtext(cr, widget, widget.text, widget.width / 2, 12, size=11, + align="center", rgb=ink, max_width=widget.width - 40) + + +def _draw_panel_plate(cr, widget): + panel = _color(widget, "panel-color", (210 / 255, 210 / 255, 205 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + amber = _color(widget, "amber-color", (255 / 255, 176 / 255, 0.0)) + _bg(cr, widget, panel, stroke=ink) + _box(cr, 8, 8, widget.width - 16, 22, amber, amber) + _wtext(cr, widget, widget.text if widget.text != widget.name + else "PANEL", widget.width / 2, 24, size=12, bold=True, + align="center", rgb=(0.15, 0.15, 0.15), + max_width=widget.width - 32) + _panel_screws(cr, widget) + + +def _draw_nameplate(cr, widget): + dark = _color(widget, "dark-color", (30 / 255, 30 / 255, 30 / 255)) + engraved = _color(widget, "engraved-color", + (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, + max_width=widget.width - 40) + _screw(cr, 12, widget.height / 2) + _screw(cr, widget.width - 12, widget.height / 2) + + +def _draw_control_panel(cr, widget): + face = _color(widget, "face-color", (245 / 255, 245 / 255, 240 / 255)) + ink = _color(widget, "ink-color", (40 / 255, 40 / 255, 40 / 255)) + panel = _color(widget, "panel-color", (210 / 255, 210 / 255, 205 / 255)) + amber = _color(widget, "amber-color", (255 / 255, 176 / 255, 0.0)) + rows = max(1, _prop_int(widget, "grid-rows", 3)) + cols = max(1, _prop_int(widget, "grid-cols", 2)) + _bg(cr, widget, panel, stroke=ink) + _box(cr, 8, 8, widget.width - 16, 22, amber, amber) + _wtext(cr, widget, widget.text if widget.text != widget.name + else "CONTROL", widget.width / 2, 24, size=12, bold=True, + align="center", rgb=(0.15, 0.15, 0.15), + max_width=widget.width - 32) + _panel_screws(cr, widget) + grid_x, grid_y = 14, 38 + grid_w, grid_h = widget.width - 28, widget.height - 52 + if grid_w <= 0 or grid_h <= 0: + return + cell_w, cell_h = grid_w / cols, grid_h / rows + labels = ("PUMP", "VALVE", "MOTOR", "FAN", "LIGHT", "HEATER") + for r in range(rows): + for c in range(cols): + x, y = grid_x + c * cell_w, grid_y + r * cell_h + _box(cr, x + 2, y + 2, cell_w - 4, cell_h - 4, face, ink) + label = labels[(r * cols + c) % len(labels)] + _wtext(cr, widget, label, x + cell_w / 2, + y + cell_h / 2 + 4, size=11, align="center", + rgb=ink, max_width=cell_w - 8) + + +# --- widget class -------------------------------------------------------------- + +_INST_DRAW = { + "AnalogGauge": _draw_analog_gauge, + "BarMeter": _draw_bar_meter, + "Beacon": _draw_beacon, + "Bezel": _draw_bezel, + "CircuitBreaker": _draw_circuit_breaker, + "ControlPanel": _draw_control_panel, + "DigitalReadout": _draw_digital_readout, + "EmergencyStop": _draw_emergency_stop, + "FlowMeter": _draw_flow_meter, + "HorizontalTankLevel": _draw_horizontal_tank, + "KeySwitch": _draw_key_switch, + "LampTestButton": _draw_lamp_test_button, + "LedBlue": _draw_led, + "LedGreen": _draw_led, + "LedRed": _draw_led, + "LevelColumnGauge": _draw_level_column, + "LevelTransmitter": _draw_level_transmitter, + "Manometer": _draw_manometer, + "Nameplate": _draw_nameplate, + "NeedleEdgewise": _draw_needle_edgewise, + "NeedleKnifeEdge": _draw_needle_knife, + "NeedleTapered": _draw_needle_tapered, + "NeedleVu": _draw_needle_vu, + "OpenChannelLevel": _draw_open_channel, + "PanelLampAmber": _draw_panel_lamp, + "PanelLampBlue": _draw_panel_lamp, + "PanelLampGreen": _draw_panel_lamp, + "PanelLampRed": _draw_panel_lamp, + "PanelLampWhite": _draw_panel_lamp, + "PanelPlate": _draw_panel_plate, + "PressureGauge": _draw_pressure_gauge, + "PushButton": lambda cr, w: _draw_push_button(cr, w, False), + "PushButtonLatching": lambda cr, w: _draw_push_button(cr, w, True), + "RgbStatusLed": _draw_rgb_led, + "RockerSwitch": lambda cr, w: _draw_rocker(cr, w, False, False), + "RockerSwitchDouble": lambda cr, w: _draw_rocker(cr, w, False, True), + "RockerSwitchIlluminated": lambda cr, w: _draw_rocker(cr, w, True, + False), + "Rotary": _draw_rotary, + "SightGlassLevel": _draw_sight_glass, + "SlideSwitch": _draw_slide_switch, + "SphericalTankLevel": _draw_spherical_tank, + "StackLight": _draw_stack_light, + "TankLevelAlarms": _draw_tank_alarms, + "TemperatureGauge": _draw_temperature_gauge, + "ToggleSwitch": lambda cr, w: _draw_toggle_switch(cr, w, False), + "ToggleSwitchIlluminated": lambda cr, w: _draw_toggle_switch(cr, w, + True), + "VerticalTankLevel": _draw_vertical_tank, + "VuMeter": _draw_vu_meter, +} + + +def _draw_seg_kind(cr, widget): + kind = widget.pkind + if kind.startswith("LedDigits"): + _draw_led_digits(cr, widget) + else: + _draw_seg_display(cr, widget) + + +class InstWidget(Widget): + """One of the 66 Instrumentation widgets (any palette archetype + in the Instrumentation section, drawn here instead of the generic + archetype drawing).""" + + ARCHETYPE = "Instrument" + + def _draw(self, cr): + kind = self.pkind + if kind.startswith(("LedDigits", "Seg14Display", + "Seg16Display")): + _draw_seg_kind(cr, self) + return + draw = _INST_DRAW.get(kind) + if draw is not None: + draw(cr, self) + return + _bg(cr, self, (0.96, 0.97, 0.99), stroke=(0.5, 0.55, 0.65)) + _wtext(cr, self, kind, self.width / 2, self.height / 2 + 5, + size=12, align="center", rgb=(0.4, 0.4, 0.4), + max_width=self.width - 12) diff --git a/lightgui/xframe/stock.py b/lightgui/xframe/stock.py new file mode 100644 index 0000000..a67c727 --- /dev/null +++ b/lightgui/xframe/stock.py @@ -0,0 +1,1606 @@ +"""Stock Market widgets (37): Cairo drawings in the archetype structure. + +Ports the C designer (widgets/components/Stock*, docs/stock-market*.md) +and the Rust port (crates/xframe-indicators/src/{plot,generated}.rs) +to the Python XFrame archetype model: one StockWidget class, +parameterised by ``kind``, with kind-specific branches in _draw -- +the same pattern as the other archetypes in lightgui/xframe/core.py. + +Demo data: every chart renders from ``demo_series()``, an exact port +of C ``xframe::make_seeded_series(250)`` (StockData.h) -- a +deterministic xorshift64* random walk starting at 100.0 -- so chart +colours are visible in the designer without series data, like C +(seeds 250). ``set_series`` is a data source, not a scalar prop, so +it has no Inspector row (the C generator SKIPs it). + +Short-plot guard (the Rust plot.rs:250 clamp class): Rust clamps a +marker y into ``[area.y + 8, area.y + area.h - 8]``; when the plot is +shorter than 16px that clamp has min > max and panics. Here +``_frame()`` returns None for plots shorter than 16px (or with no +positive plot area) and the widget draws only its border + label. + +Anchor guard (C flag 13, ddaf4bd): ParallelChannel/Pitchfork +``draw()`` indexed ``anchors_[2]`` unconditionally while +``set_anchors()`` can leave only 2 anchors. The Python equivalent +is ``_anchors()``: only anchors the user has actually set (an +``anchor-i-bar`` prop present in ``widget.props``) count -- a freshly +placed tool has 0. Draw code never indexes past ``len(anchors)``: +with <2 anchors ParallelChannel draws no channel lines and +Pitchfork draws no fork (only the anchor dots present); with 2 +anchors ParallelChannel draws the main line + the dashed midline +(the outer line falls back to the midline, so it is not drawn twice) +and Pitchfork falls back to a trendline through the two anchors +(the tines need the third anchor); with 3 anchors both draw fully. +Other tools draw a centred default when they have 0 anchors so the +widget still reads as its kind in the palette. +""" + +import math + +from lightgui.xframe.core import ( + Widget, + parse_color, + _bg, + _box, + _prop_bool, + _prop_float, + _prop_int, + _rgb, + _text_width, + _wtext, +) + +# --- demo series: exact port of C make_seeded_series(n, seed) ----------- +_MASK64 = (1 << 64) - 1 +_XOR_MUL = 0x2545F4914F6CDD1D +_DEMO_N = 250 + + +def _stock_next(state): + """xorshift64* step; returns (output, new_state).""" + x = state + x ^= x >> 12 + x ^= (x << 25) & _MASK64 + x ^= x >> 27 + x &= _MASK64 + return (x * _XOR_MUL) & _MASK64, x + + +def _stock_uniform(state): + """Uniform double in [0, 1); returns (value, new_state).""" + out, state = _stock_next(state) + return (out >> 11) * (1.0 / 9007199254740992.0), state + + +def demo_series(n=_DEMO_N, seed=42): + """Deterministic synthetic OHLCV series: a random walk starting + at 100.0. Same (n, seed) gives identical bars on every run. + Each bar is (open, high, low, close, volume); every bar satisfies + high >= max(open, close) and low <= min(open, close).""" + out = [] + if n <= 0: + return out + state = (0x9E3779B97F4A7C15 ^ (seed * 0xBF58476D1CE4E5B9)) & _MASK64 + if state == 0: + state = _XOR_MUL + prev_close = 100.0 + for _i in range(n): + open_v = prev_close + shock, state = _stock_uniform(state) + close = open_v + 0.02 + (shock - 0.5) * 2.4 + if not close > 1.0: + extra, state = _stock_uniform(state) + close = 1.0 + extra + up, state = _stock_uniform(state) + high = max(open_v, close) + up * 0.9 + down, state = _stock_uniform(state) + low = min(open_v, close) - down * 0.9 + vol, state = _stock_uniform(state) + volume = 500000.0 + vol * 1500000.0 + out.append((open_v, high, low, close, volume)) + prev_close = close + return out + + +# Cached demo series (250 bars, like C) + a second symbol for the +# comparison / overlay / correlation charts. +DEMO_SERIES = demo_series() +DEMO_SERIES_2 = demo_series(seed=43) +DEMO_SERIES_3 = demo_series(seed=44) + +# Palette kinds (stock.py covers the 37 Stock* registry names). +STOCK_KINDS = frozenset(( + "AccumulationDistribution", "AreaChart", "Arrow", "BaselineChart", + "Brush", "CandlestickChart", "CorrelationView", "Ellipse", + "FibExtension", "FibRetracement", "HeikinAshi", "HollowCandles", + "HorizontalLine", "IndexedComparison", "LineChart", "MeasureTool", + "MoneyFlowChart", "MultiSymbolChart", "OBVChart", "OHLCBarChart", + "OverlayChart", "ParallelChannel", "Pitchfork", "Price", + "RatioChart", "Rectangle", "RelativePerformance", "Renko", + "SectorComparison", "SpreadChart", "TextAnnotation", "Trendline", + "VWAP", "VerticalLine", "VolumeBars", "VolumeCandles", + "VolumeProfile", +)) + +UP_RGB = (0.0, 150 / 255, 0.0) # corrected up default +DOWN_RGB = (200 / 255, 30 / 255, 30 / 255) # corrected down default +CANDLE_UP_RGB = (120 / 255, 190 / 255, 120 / 255) +CANDLE_DOWN_RGB = (200 / 255, 120 / 255, 120 / 255) +GRID_RGB = (225 / 255, 225 / 255, 225 / 255) +AXIS_RGB = (150 / 255, 150 / 255, 150 / 255) +LINE_RGB = (0.0, 100 / 255, 200 / 255) + + +def _color(widget, name, default): + return parse_color(widget.get_prop(name, ""), default) + + +# --- frame / view / scale -------------------------------------------------- + +def _frame(widget): + """Plot rect (px, py, pw, ph), or None when too small to plot. + + Mirrors C plot_x()/plot_y()/plot_w()/plot_h(): a left axis of + ``axis-width`` (56) and a bottom axis of ``axis-height`` (20) when + the table has those props, else a 4px margin all round. The + short-plot guard: height < 16px (or no positive plot area) means + no plot at all -- the Rust plot.rs:250 clamp (min > max) class. + """ + w, h = widget.width, widget.height + names = widget.prop_names() + if "axis-width" in names: + ax_w = _prop_int(widget, "axis-width", 56) + ax_h = _prop_int(widget, "axis-height", 20) + px, py = ax_w, 6 + pw, ph = w - ax_w - 8, h - ax_h - 12 + else: + px, py = 4, 4 + pw, ph = w - 8, h - 8 + if h < 16 or pw <= 0 or ph <= 0: + return None + return (px, py, pw, ph) + + +def _view(widget, total): + """(first, count) of the visible window (C effective_count).""" + names = widget.prop_names() + if "view-first" not in names: + return 0.0, float(total) + first = _prop_float(widget, "view-first", 0.0) + count = _prop_float(widget, "view-count", 0.0) + if count <= 0 or count > total: + count = float(total) + first = max(0.0, min(max(0.0, total - count), first)) + return first, count + + +def _y_range(widget, values, i0, i1): + """(lo, hi) for *values* over [i0, i1): auto range with the C 6% + padding, or the manual y-min/y-max when auto-y is off.""" + lo, hi = None, None + for v in values[i0:i1]: + if v is None: + continue + lo = v if lo is None else min(lo, v) + hi = v if hi is None else max(hi, v) + if lo is None or hi is None: + return 0.0, 1.0 + if "auto-y" in widget.prop_names() \ + and not _prop_bool(widget, "auto-y", True): + return (_prop_float(widget, "y-min", 0.0), + _prop_float(widget, "y-max", 1.0)) + pad = (hi - lo) * 0.06 + 1e-9 + return lo - pad, hi + pad + + +def _nice_step(span, target=6): + """C nice_step: 1/2/5/10 x a power of ten.""" + if span <= 0: + return 1.0 + raw = span / target + mag = 10.0 ** math.floor(math.log10(raw)) + norm = raw / mag + step = 1.0 if norm < 1.5 else 2.0 if norm < 3.5 \ + else 5.0 if norm < 7.5 else 10.0 + return step * mag + + +def _fmt(value): + """C fmt(): two decimals, trailing zeroes stripped.""" + text = "%.2f" % value + return text.rstrip("0").rstrip(".") if "." in text else text + + +class _Plot: + """Plot geometry + scale for one chart draw.""" + + def __init__(self, widget, frame, lo, hi, first, count, total): + px, py, pw, ph = frame + self.px, self.py, self.pw, self.ph = px, py, pw, ph + self.lo, self.hi = (lo, hi) if hi > lo else (lo, lo + 1.0) + self.first, self.count, self.total = first, count, total + + def x(self, i): + """Centre x of bar *i*.""" + item_w = self.pw / self.count if self.count else self.pw + return self.px + (i - self.first + 0.5) * item_w + + def item_w(self): + return self.pw / self.count if self.count else self.pw + + def y(self, value): + return self.py + (self.hi - value) / (self.hi - self.lo) * self.ph + + def x_at_bar(self, bar): + return self.x(bar) + + +def _draw_grid(cr, widget, plot): + """Horizontal gridlines + left price labels (C draw loop).""" + if "grid-color" not in widget.prop_names(): + return + grid = _color(widget, "grid-color", GRID_RGB) + axis = _color(widget, "axis-color", AXIS_RGB) + step = _nice_step(plot.hi - plot.lo, 6) + start = math.ceil(plot.lo / step) * step + value = start + while value <= plot.hi: + gy = plot.y(value) + cr.save() + _rgb(cr, grid) + cr.set_line_width(1) + cr.move_to(plot.px, gy) + cr.line_to(plot.px + plot.pw, gy) + cr.stroke() + cr.restore() + _wtext(cr, widget, _fmt(value), plot.px - 6, gy + 4, size=11, + rgb=axis, align="right", max_width=plot.px - 8) + value += step + + +def _draw_x_axis(cr, widget, plot): + """Bottom axis line + index ticks (C draw loop).""" + if "axis-width" not in widget.prop_names(): + return + axis = _color(widget, "axis-color", AXIS_RGB) + bottom = plot.py + plot.ph + cr.save() + _rgb(cr, axis) + cr.set_line_width(1) + cr.move_to(plot.px, bottom) + cr.line_to(plot.px + plot.pw, bottom) + target = max(1, plot.pw // 90) + istep = int(math.ceil(plot.count / max(1, target))) + i0 = int(math.floor(plot.first)) + i1 = int(math.ceil(plot.first + plot.count)) + for i in range(i0, i1, max(1, istep)): + if i < 0 or i >= plot.total: + continue + cx = plot.x(i) + cr.move_to(cx, bottom) + cr.line_to(cx, bottom + 4) + cr.stroke() + cr.restore() + if plot.ph > 28: + for i in range(i0, i1, max(1, istep)): + if i < 0 or i >= plot.total: + continue + _wtext(cr, widget, str(i), plot.x(i), bottom + 16, size=11, + rgb=axis, align="center", max_width=40) + cr.save() + _rgb(cr, axis) + cr.set_line_width(1) + cr.rectangle(plot.px + 0.5, plot.py + 0.5, + plot.pw - 1, plot.ph - 1) + cr.stroke() + cr.restore() + + +def _draw_title(cr, widget, plot, suffix=""): + """Title text + last close at the top-left of the plot (C).""" + if plot.ph < 18: + return + label = widget.text + if suffix: + label = label + " " + suffix + _wtext(cr, widget, label, plot.px + 8, plot.py + 14, size=12, + rgb=(0.12, 0.12, 0.12), max_width=plot.pw - 16) + + +def _chart_base(cr, widget, bars): + """Common chart setup: background, frame, view window, y-range + over the visible bars, grid + x axis. Returns (plot, i0, i1) or + (None, 0, 0) when too small to plot.""" + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + frame = _frame(widget) + if frame is None: + _wtext(cr, widget, widget.pkind, widget.width / 2, + widget.height / 2 + 5, size=12, align="center", + rgb=(0.4, 0.4, 0.4), max_width=widget.width - 12) + return None, 0, 0 + total = len(bars) + first, count = _view(widget, total) + i0 = int(math.floor(first)) + i1 = int(math.ceil(first + count)) + if "auto-y" not in widget.prop_names() or _prop_bool( + widget, "auto-y", True): + vis_lo = min((b[2] for b in bars[i0:i1]), default=0.0) + vis_hi = max((b[1] for b in bars[i0:i1]), default=1.0) + pad = (vis_hi - vis_lo) * 0.06 + 1e-9 + lo, hi = vis_lo - pad, vis_hi + pad + else: + lo = _prop_float(widget, "y-min", 0.0) + hi = _prop_float(widget, "y-max", 1.0) + plot = _Plot(widget, frame, lo, hi, first, count, total) + _draw_grid(cr, widget, plot) + return plot, i0, i1 + + +def _draw_candles(cr, widget, plot, bars, i0, i1, hollow=False): + """Candle bodies + wicks (C StockCandlestickChart draw).""" + up = _color(widget, "up-color", UP_RGB) + down = _color(widget, "down-color", DOWN_RGB) + if "up-color" not in widget.prop_names(): + up = _color(widget, "candle-up-color", CANDLE_UP_RGB) + down = _color(widget, "candle-down-color", CANDLE_DOWN_RGB) + bw = max(1, int(plot.item_w() * 0.6)) + for i in range(i0, min(i1, len(bars))): + if i < 0: + continue + open_v, high, low, close, _vol = bars[i] + cx = plot.x(i) + is_up = close >= open_v + colour = up if is_up else down + cr.save() + _rgb(cr, colour) + cr.set_line_width(1) + cr.move_to(cx, plot.y(high)) + cr.line_to(cx, plot.y(low)) + cr.stroke() + top = plot.y(max(open_v, close)) + bot = plot.y(min(open_v, close)) + if hollow and is_up: + cr.set_line_width(1) + cr.rectangle(cx - bw / 2, top, bw, max(1, bot - top)) + cr.stroke() + else: + cr.rectangle(cx - bw / 2, top, bw, max(1, bot - top)) + cr.fill() + cr.restore() + + +def _draw_line_values(cr, plot, values, i0, i1, rgb, width=2.0): + """Polyline of *values* over [i0, i1) (None gaps break it).""" + cr.save() + _rgb(cr, rgb) + cr.set_line_width(width) + started = False + for i in range(i0, min(i1, len(values))): + if i < 0 or values[i] is None: + started = False + continue + x, y = plot.x(i), plot.y(values[i]) + if not started: + cr.move_to(x, y) + started = True + else: + cr.line_to(x, y) + cr.stroke() + cr.restore() + + +def _draw_ohlc_bars(cr, widget, plot, bars, i0, i1): + """OHLC bars: vertical high-low line with open/close ticks.""" + up = _color(widget, "up-color", UP_RGB) + down = _color(widget, "down-color", DOWN_RGB) + tick = max(2, int(plot.item_w() * 0.3)) + for i in range(i0, min(i1, len(bars))): + if i < 0: + continue + open_v, high, low, close, _vol = bars[i] + cx = plot.x(i) + cr.save() + _rgb(cr, up if close >= open_v else down) + cr.set_line_width(1) + cr.move_to(cx, plot.y(high)) + cr.line_to(cx, plot.y(low)) + cr.move_to(cx - tick, plot.y(open_v)) + cr.line_to(cx, plot.y(open_v)) + cr.move_to(cx, plot.y(close)) + cr.line_to(cx + tick, plot.y(close)) + cr.stroke() + cr.restore() + + +def _anchors(widget): + """Anchors the user has set, in order (see module docstring: + Flag 13 guard). Each is (bar, price); price falls back to the + table default 100 when only the bar was set.""" + out = [] + for i in (1, 2, 3): + if "anchor-%d-bar" % i in widget.props: + bar = _prop_int(widget, "anchor-%d-bar" % i, 0) + price = _prop_float(widget, "anchor-%d-price" % i, 100.0) + out.append((bar, price)) + return out + + +def _draw_anchor_dots(cr, plot, anchors, rgb=(0.12, 0.12, 0.12)): + """Filled 8px anchor dots (C draws XFillArc 8x8 per anchor).""" + cr.save() + _rgb(cr, rgb) + for bar, price in anchors: + cx, cy = plot.x(bar), plot.y(price) + cr.arc(cx, cy, 4, 0, 2 * math.pi) + cr.fill() + cr.restore() + + +def _line_through(cr, plot, b0, p0, b1, p1, rgb, width=2.0, dashed=False): + """Line through (b0, p0)-(b1, p1) extended across the plot.""" + if b1 == b0: + slope = 0.0 + else: + slope = (p1 - p0) / (b1 - b0) + v_left = p0 + slope * (-0.5 - b0 + plot.first) + v_right = p0 + slope * (plot.first + plot.count - 0.5 - b0) + cr.save() + _rgb(cr, rgb) + cr.set_line_width(width) + if dashed: + cr.set_dash([6.0, 4.0]) + cr.move_to(plot.px, plot.y(v_left)) + cr.line_to(plot.px + plot.pw, plot.y(v_right)) + cr.stroke() + cr.restore() + + +# --- chart kinds ------------------------------------------------------------- +# Each _draw_ takes (cr, widget); the series is DEMO_SERIES +# unless noted. Derived series (Heikin-Ashi, Renko, VWAP, OBV, ...) +# are rebuilt from the demo bars, like C set_series does. + +def _closes(bars): + return [b[3] for b in bars] + + +def _line_chart_base(cr, widget, values, line_rgb=None): + """Frame + y-range over *values* + grid + line + title. Used by + the derived-line charts (OBV, A/D, correlation, ...).""" + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + frame = _frame(widget) + if frame is None: + _wtext(cr, widget, widget.pkind, widget.width / 2, + widget.height / 2 + 5, size=12, align="center", + rgb=(0.4, 0.4, 0.4), max_width=widget.width - 12) + return None, 0, 0 + total = len(values) + first, count = _view(widget, total) + i0 = int(math.floor(first)) + i1 = int(math.ceil(first + count)) + lo, hi = _y_range(widget, values, i0, i1) + plot = _Plot(widget, frame, lo, hi, first, count, total) + _draw_grid(cr, widget, plot) + _draw_x_axis(cr, widget, plot) + if line_rgb is not None: + width = _prop_int(widget, "line-width", 2) \ + if "line-width" in widget.prop_names() else 2 + _draw_line_values(cr, plot, values, i0, i1, line_rgb, width) + return plot, i0, i1 + + +def _draw_candlestick(cr, widget): + plot, i0, i1 = _chart_base(cr, widget, DEMO_SERIES) + if plot is None: + return + _draw_candles(cr, widget, plot, DEMO_SERIES, i0, i1) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(DEMO_SERIES[-1][3])) + + +def _draw_hollow(cr, widget): + plot, i0, i1 = _chart_base(cr, widget, DEMO_SERIES) + if plot is None: + return + _draw_candles(cr, widget, plot, DEMO_SERIES, i0, i1, hollow=True) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(DEMO_SERIES[-1][3])) + + +def _heikin_ashi(bars): + """Heikin-Ashi candles from OHLC bars (C StockHeikinAshi).""" + out = [] + ha_open = bars[0][0] + for open_v, high, low, close, vol in bars: + ha_close = (open_v + high + low + close) / 4.0 + ha_high = max(high, ha_open, ha_close) + ha_low = min(low, ha_open, ha_close) + out.append((ha_open, ha_high, ha_low, ha_close, vol)) + ha_open = (ha_open + ha_close) / 2.0 + return out + + +def _draw_heikin_ashi(cr, widget): + bars = _heikin_ashi(DEMO_SERIES) + plot, i0, i1 = _chart_base(cr, widget, bars) + if plot is None: + return + _draw_candles(cr, widget, plot, bars, i0, i1) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(bars[-1][3])) + + +def _draw_ohlc(cr, widget): + plot, i0, i1 = _chart_base(cr, widget, DEMO_SERIES) + if plot is None: + return + _draw_ohlc_bars(cr, widget, plot, DEMO_SERIES, i0, i1) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(DEMO_SERIES[-1][3])) + + +def _draw_line(cr, widget): + plot, i0, i1 = _chart_base(cr, widget, DEMO_SERIES) + if plot is None: + return + line = _color(widget, "line-color", LINE_RGB) + width = _prop_int(widget, "line-width", 2) + _draw_line_values(cr, plot, _closes(DEMO_SERIES), i0, i1, line, + width) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(DEMO_SERIES[-1][3])) + + +def _draw_area(cr, widget): + plot, i0, i1 = _chart_base(cr, widget, DEMO_SERIES) + if plot is None: + return + line = _color(widget, "line-color", LINE_RGB) + fill = _color(widget, "fill-color", (180 / 255, 210 / 255, 240 / 255)) + width = _prop_int(widget, "line-width", 2) + closes = _closes(DEMO_SERIES) + bottom = plot.py + plot.ph + cr.save() + _rgb(cr, fill, 0.55) + started = False + for i in range(i0, min(i1, len(closes))): + if i < 0: + continue + x, y = plot.x(i), plot.y(closes[i]) + if not started: + cr.move_to(x, bottom) + cr.line_to(x, y) + started = True + else: + cr.line_to(x, y) + if started: + cr.line_to(plot.x(min(i1, len(closes)) - 1), bottom) + cr.close_path() + cr.fill() + cr.restore() + _draw_line_values(cr, plot, closes, i0, i1, line, width) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(DEMO_SERIES[-1][3])) + + +def _draw_baseline(cr, widget): + plot, i0, i1 = _chart_base(cr, widget, DEMO_SERIES) + if plot is None: + return + baseline = _prop_float(widget, "baseline", 100.0) + up_fill = _color(widget, "up-fill-color", + (170 / 255, 220 / 255, 170 / 255)) + down_fill = _color(widget, "down-fill-color", + (240 / 255, 180 / 255, 180 / 255)) + line = _color(widget, "line-color", LINE_RGB) + base_rgb = _color(widget, "baseline-color", + (120 / 255, 120 / 255, 120 / 255)) + closes = _closes(DEMO_SERIES) + base_y = plot.y(baseline) + bottom = plot.py + plot.ph + cr.save() + _rgb(cr, up_fill, 0.6) + cr.rectangle(plot.px, plot.py, plot.pw, max(0, base_y - plot.py)) + cr.fill() + _rgb(cr, down_fill, 0.6) + cr.rectangle(plot.px, base_y, plot.pw, max(0, bottom - base_y)) + cr.fill() + _rgb(cr, base_rgb) + cr.set_line_width(1) + cr.set_dash([6.0, 4.0]) + cr.move_to(plot.px, base_y) + cr.line_to(plot.px + plot.pw, base_y) + cr.stroke() + cr.restore() + _draw_line_values(cr, plot, closes, i0, i1, line, + _prop_int(widget, "line-width", 2)) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(DEMO_SERIES[-1][3])) + + +def _renko_bricks(bars, brick_size): + """Renko bricks from closes (C StockRenko): +1 up / -1 down.""" + closes = _closes(bars) + bricks = [] + level = math.floor(closes[0] / brick_size) * brick_size + for close in closes[1:]: + while close >= level + brick_size: + level += brick_size + bricks.append(1) + while close <= level - brick_size: + level -= brick_size + bricks.append(-1) + return bricks + + +def _draw_renko(cr, widget): + brick_size = max(0.01, _prop_float(widget, "brick-size", 1.0)) + bricks = _renko_bricks(DEMO_SERIES, brick_size) + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + frame = _frame(widget) + if frame is None: + _wtext(cr, widget, widget.pkind, widget.width / 2, + widget.height / 2 + 5, size=12, align="center", + rgb=(0.4, 0.4, 0.4), max_width=widget.width - 12) + return + total = len(bricks) + first, count = _view(widget, total) + i0 = int(math.floor(first)) + i1 = int(math.ceil(first + count)) + levels = [] + level = 0 + for brick in bricks: + level += brick + levels.append(level) + lo = min([0] + levels[i0:i1]) - 1 + hi = max([0] + levels[i0:i1]) + 1 + plot = _Plot(widget, frame, lo, hi, first, count, total) + _draw_grid(cr, widget, plot) + up = _color(widget, "up-color", UP_RGB) + down = _color(widget, "down-color", DOWN_RGB) + bw = max(1, int(plot.item_w() * 0.8)) + for i in range(i0, min(i1, total)): + if i < 0: + continue + level = levels[i] + prev = levels[i - 1] if i > 0 else 0 + cx = plot.x(i) + top = plot.y(max(level, prev)) + bot = plot.y(min(level, prev)) + cr.save() + _rgb(cr, up if bricks[i] > 0 else down) + cr.rectangle(cx - bw / 2, top, bw, max(1, bot - top)) + cr.fill_preserve() + _rgb(cr, (0.12, 0.12, 0.12)) + cr.set_line_width(0.5) + cr.stroke() + cr.restore() + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, "%d bricks" % total) + + +def _volume_values(bars): + return [b[4] for b in bars] + + +def _draw_volume_bars(cr, widget): + volumes = _volume_values(DEMO_SERIES) + plot, i0, i1 = _line_chart_base( + cr, widget, volumes, line_rgb=None) + if plot is None: + return + up = _color(widget, "up-color", UP_RGB) + down = _color(widget, "down-color", DOWN_RGB) + vmax = max(volumes[i0:i1], default=1.0) or 1.0 + bw = max(1, int(plot.item_w() * 0.6)) + bottom = plot.py + plot.ph + for i in range(i0, min(i1, len(volumes))): + if i < 0: + continue + h = volumes[i] / vmax * plot.ph + cx = plot.x(i) + cr.save() + _rgb(cr, up if DEMO_SERIES[i][3] >= DEMO_SERIES[i][0] else down) + cr.rectangle(cx - bw / 2, bottom - h, bw, h) + cr.fill() + cr.restore() + _draw_title(cr, widget, plot, "") + + +def _draw_volume_candles(cr, widget): + plot, i0, i1 = _chart_base(cr, widget, DEMO_SERIES) + if plot is None: + return + # Candles on the top 2/3, volume bars on the bottom 1/3. + top_h = plot.ph * 2 / 3 + sub = _Plot(widget, (plot.px, plot.py, plot.pw, top_h), + plot.lo, plot.hi, plot.first, plot.count, plot.total) + _draw_candles(cr, widget, sub, DEMO_SERIES, i0, i1) + volumes = _volume_values(DEMO_SERIES) + vmax = max(volumes[i0:i1], default=1.0) or 1.0 + up = _color(widget, "up-color", UP_RGB) + down = _color(widget, "down-color", DOWN_RGB) + bw = max(1, int(plot.item_w() * 0.6)) + bottom = plot.py + plot.ph + vol_h = plot.ph / 3 + for i in range(i0, min(i1, len(volumes))): + if i < 0: + continue + h = volumes[i] / vmax * vol_h + cx = plot.x(i) + cr.save() + _rgb(cr, up if DEMO_SERIES[i][3] >= DEMO_SERIES[i][0] else down) + cr.rectangle(cx - bw / 2, bottom - h, bw, h) + cr.fill() + cr.restore() + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(DEMO_SERIES[-1][3])) + + +def _draw_volume_profile(cr, widget): + plot, i0, i1 = _chart_base(cr, widget, DEMO_SERIES) + if plot is None: + return + _draw_candles(cr, widget, plot, DEMO_SERIES, i0, i1) + bins = max(2, _prop_int(widget, "bins", 20)) + poc_rgb = _color(widget, "poc-color", DOWN_RGB) + line = _color(widget, "line-color", LINE_RGB) + vis = DEMO_SERIES[i0:i1] + if vis: + lo = min(b[2] for b in vis) + hi = max(b[1] for b in vis) + span = (hi - lo) or 1.0 + counts = [0.0] * bins + for _o, _h, _l, _c, vol in vis: + idx = min(bins - 1, int((_c - lo) / span * bins)) + counts[idx] += vol + vmax = max(counts) or 1.0 + poc = counts.index(vmax) + prof_w = plot.pw * 0.3 + for idx, count in enumerate(counts): + w = count / vmax * prof_w + y_top = plot.y(lo + (idx + 1) / bins * span) + y_bot = plot.y(lo + idx / bins * span) + cr.save() + _rgb(cr, line, 0.45) + cr.rectangle(plot.px + plot.pw - w, y_top, w, + max(1, y_bot - y_top)) + cr.fill() + cr.restore() + poc_y = plot.y(lo + (poc + 0.5) / bins * span) + cr.save() + _rgb(cr, poc_rgb) + cr.set_line_width(2) + cr.move_to(plot.px, poc_y) + cr.line_to(plot.px + plot.pw, poc_y) + cr.stroke() + cr.restore() + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(DEMO_SERIES[-1][3])) + + +def _vwap_values(bars): + out = [] + cum_tp_vol = 0.0 + cum_vol = 0.0 + for open_v, high, low, close, vol in bars: + tp = (high + low + close) / 3.0 + cum_tp_vol += tp * vol + cum_vol += vol + out.append(cum_tp_vol / cum_vol if cum_vol else close) + return out + + +def _draw_vwap(cr, widget): + values = _vwap_values(DEMO_SERIES) + closes = _closes(DEMO_SERIES) + plot, i0, i1 = _line_chart_base(cr, widget, values, line_rgb=None) + if plot is None: + return + line = _color(widget, "line-color", LINE_RGB) + vwap = _color(widget, "vwap-color", (230 / 255, 126 / 255, 34 / 255)) + _draw_line_values(cr, plot, closes, i0, i1, line, 1.5) + _draw_line_values(cr, plot, values, i0, i1, vwap, 2.5) + _draw_title(cr, widget, plot, _fmt(values[-1])) + + +def _obv_values(bars): + out = [] + obv = 0.0 + prev = None + for open_v, high, low, close, vol in bars: + if prev is not None: + if close > prev: + obv += vol + elif close < prev: + obv -= vol + out.append(obv) + prev = close + return out + + +def _draw_obv(cr, widget): + line = _color(widget, "line-color", LINE_RGB) + plot, i0, i1 = _line_chart_base(cr, widget, _obv_values(DEMO_SERIES), + line_rgb=line) + if plot is None: + return + _draw_title(cr, widget, plot, "") + + +def _accum_dist_values(bars): + out = [] + ad = 0.0 + for open_v, high, low, close, vol in bars: + if high != low: + mult = ((close - low) - (high - close)) / (high - low) + else: + mult = 0.0 + ad += mult * vol + out.append(ad) + return out + + +def _draw_accum_dist(cr, widget): + line = _color(widget, "line-color", (0.0, 150 / 255, 0.0)) + plot, i0, i1 = _line_chart_base( + cr, widget, _accum_dist_values(DEMO_SERIES), line_rgb=line) + if plot is None: + return + _draw_title(cr, widget, plot, "") + + +def _money_flow_values(bars): + out = [] + flow = 0.0 + prev = None + for open_v, high, low, close, vol in bars: + tp = (high + low + close) / 3.0 + raw = tp * vol + if prev is not None: + flow += raw if close > prev else -raw if close < prev else 0.0 + out.append(flow) + prev = close + return out + + +def _draw_money_flow(cr, widget): + values = _money_flow_values(DEMO_SERIES) + plot, i0, i1 = _line_chart_base(cr, widget, values, line_rgb=None) + if plot is None: + return + zero = _color(widget, "zero-line-color", + (120 / 255, 120 / 255, 120 / 255)) + up = _color(widget, "up-color", UP_RGB) + down = _color(widget, "down-color", DOWN_RGB) + zero_y = plot.y(0.0) + cr.save() + _rgb(cr, zero) + cr.set_line_width(1) + cr.set_dash([6.0, 4.0]) + cr.move_to(plot.px, zero_y) + cr.line_to(plot.px + plot.pw, zero_y) + cr.stroke() + cr.restore() + _draw_line_values(cr, plot, values, i0, i1, + up if values[-1] >= 0 else down, 2.0) + _draw_title(cr, widget, plot, "") + + +def _rolling_corr(a, b, window): + out = [] + for i in range(len(a)): + if i + 1 < window: + out.append(0.0) + continue + wa, wb = a[i - window + 1:i + 1], b[i - window + 1:i + 1] + ma, mb = sum(wa) / window, sum(wb) / window + num = sum((x - ma) * (y - mb) for x, y in zip(wa, wb)) + den = math.sqrt(sum((x - ma) ** 2 for x in wa) + * sum((y - mb) ** 2 for y in wb)) + out.append(num / den if den else 0.0) + return out + + +def _draw_correlation(cr, widget): + window = max(2, _prop_int(widget, "window", 20)) + values = _rolling_corr(_closes(DEMO_SERIES), + _closes(DEMO_SERIES_2), window) + plot, i0, i1 = _line_chart_base(cr, widget, values, line_rgb=None) + if plot is None: + return + zero = _color(widget, "zero-line-color", + (120 / 255, 120 / 255, 120 / 255)) + corr = _color(widget, "corr-color", LINE_RGB) + scatter = _color(widget, "scatter-color", DOWN_RGB) + zero_y = plot.y(0.0) + cr.save() + _rgb(cr, zero) + cr.set_line_width(1) + cr.move_to(plot.px, zero_y) + cr.line_to(plot.px + plot.pw, zero_y) + cr.stroke() + _rgb(cr, scatter) + for i in range(i0, min(i1, len(values)), 5): + if i >= 0: + cr.arc(plot.x(i), plot.y(values[i]), 2, 0, 2 * math.pi) + cr.fill() + cr.restore() + _draw_line_values(cr, plot, values, i0, i1, corr, 2.0) + _draw_title(cr, widget, plot, _fmt(values[-1])) + + +def _indexed(bars, base_value=100.0): + first = bars[0][3] + return [c / first * base_value for c in _closes(bars)] + + +def _draw_indexed(cr, widget): + base = _prop_float(widget, "base-value", 100.0) + first, count = _view(widget, len(DEMO_SERIES)) + i0, i1 = int(math.floor(first)), int(math.ceil(first + count)) + series = [_indexed(DEMO_SERIES, base), + _indexed(DEMO_SERIES_2, base)] + lo = min(min(s[i0:i1]) for s in series) + hi = max(max(s[i0:i1]) for s in series) + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + frame = _frame(widget) + if frame is None: + _wtext(cr, widget, widget.pkind, widget.width / 2, + widget.height / 2 + 5, size=12, align="center", + rgb=(0.4, 0.4, 0.4), max_width=widget.width - 12) + return + plot = _Plot(widget, frame, lo - 1, hi + 1, first, count, + len(DEMO_SERIES)) + _draw_grid(cr, widget, plot) + base_rgb = _color(widget, "base-line-color", + (180 / 255, 180 / 255, 180 / 255)) + base_y = plot.y(base) + cr.save() + _rgb(cr, base_rgb) + cr.set_line_width(1) + cr.set_dash([6.0, 4.0]) + cr.move_to(plot.px, base_y) + cr.line_to(plot.px + plot.pw, base_y) + cr.stroke() + cr.restore() + for values, rgb in ((series[0], LINE_RGB), + (series[1], DOWN_RGB)): + _draw_line_values(cr, plot, values, i0, i1, rgb, 2.0) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, "") + + +def _draw_relative_perf(cr, widget): + first, count = _view(widget, len(DEMO_SERIES)) + i0, i1 = int(math.floor(first)), int(math.ceil(first + count)) + series = [] + for bars in (DEMO_SERIES, DEMO_SERIES_2, DEMO_SERIES_3): + base = bars[0][3] + series.append([(c - base) / base * 100.0 + for c in _closes(bars)]) + lo = min(min(s[i0:i1]) for s in series) + hi = max(max(s[i0:i1]) for s in series) + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + frame = _frame(widget) + if frame is None: + _wtext(cr, widget, widget.pkind, widget.width / 2, + widget.height / 2 + 5, size=12, align="center", + rgb=(0.4, 0.4, 0.4), max_width=widget.width - 12) + return + plot = _Plot(widget, frame, lo - 1, hi + 1, first, count, + len(DEMO_SERIES)) + _draw_grid(cr, widget, plot) + zero = _color(widget, "zero-line-color", + (180 / 255, 180 / 255, 180 / 255)) + zero_y = plot.y(0.0) + cr.save() + _rgb(cr, zero) + cr.set_line_width(1) + cr.move_to(plot.px, zero_y) + cr.line_to(plot.px + plot.pw, zero_y) + cr.stroke() + cr.restore() + for values, rgb in ((series[0], LINE_RGB), + (series[1], DOWN_RGB), + (series[2], (0.0, 150 / 255, 0.0))): + _draw_line_values(cr, plot, values, i0, i1, rgb, 2.0) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, "") + + +def _draw_ratio(cr, widget): + a, b = _closes(DEMO_SERIES), _closes(DEMO_SERIES_2) + values = [x / y if y else 0.0 for x, y in zip(a, b)] + line = _color(widget, "line-color", (120 / 255, 60 / 255, 180 / 255)) + plot, i0, i1 = _line_chart_base(cr, widget, values, line_rgb=line) + if plot is None: + return + _draw_title(cr, widget, plot, _fmt(values[-1])) + + +def _draw_spread(cr, widget): + a, b = _closes(DEMO_SERIES), _closes(DEMO_SERIES_2) + values = [x - y for x, y in zip(a, b)] + plot, i0, i1 = _line_chart_base(cr, widget, values, line_rgb=None) + if plot is None: + return + zero = _color(widget, "zero-line-color", + (120 / 255, 120 / 255, 120 / 255)) + line = _color(widget, "line-color", LINE_RGB) + zero_y = plot.y(0.0) + cr.save() + _rgb(cr, zero) + cr.set_line_width(1) + cr.set_dash([6.0, 4.0]) + cr.move_to(plot.px, zero_y) + cr.line_to(plot.px + plot.pw, zero_y) + cr.stroke() + cr.restore() + _draw_line_values(cr, plot, values, i0, i1, line, 2.0) + _draw_title(cr, widget, plot, _fmt(values[-1])) + + +def _draw_sector(cr, widget): + labels = [s for s in widget.get_prop("labels", "Tech|Tech|Energy") + .split("|") if s] + seen = [] + for label in labels: + if label not in seen: + seen.append(label) + series = [_indexed(DEMO_SERIES), _indexed(DEMO_SERIES_2), + _indexed(DEMO_SERIES_3)] + first, count = _view(widget, len(DEMO_SERIES)) + i0, i1 = int(math.floor(first)), int(math.ceil(first + count)) + lo = min(min(s[i0:i1]) for s in series) + hi = max(max(s[i0:i1]) for s in series) + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + frame = _frame(widget) + if frame is None: + _wtext(cr, widget, widget.pkind, widget.width / 2, + widget.height / 2 + 5, size=12, align="center", + rgb=(0.4, 0.4, 0.4), max_width=widget.width - 12) + return + plot = _Plot(widget, frame, lo - 1, hi + 1, first, count, + len(DEMO_SERIES)) + _draw_grid(cr, widget, plot) + colours = (LINE_RGB, DOWN_RGB, (0.0, 150 / 255, 0.0)) + for values, rgb in zip(series, colours): + _draw_line_values(cr, plot, values, i0, i1, rgb, 2.0) + _draw_x_axis(cr, widget, plot) + x = plot.px + 8 + for label, rgb in zip(seen, colours): + cr.save() + _rgb(cr, rgb) + cr.rectangle(x, plot.py + 6, 10, 4) + cr.fill() + cr.restore() + _wtext(cr, widget, label, x + 14, plot.py + 14, size=11, + max_width=80) + x += _text_width(cr, widget, label, size=11) + 34 + _draw_title(cr, widget, plot, "") + + +def _draw_multi_symbol(cr, widget): + series = [_indexed(DEMO_SERIES), _indexed(DEMO_SERIES_2), + _indexed(DEMO_SERIES_3)] + first, count = _view(widget, len(DEMO_SERIES)) + i0, i1 = int(math.floor(first)), int(math.ceil(first + count)) + lo = min(min(s[i0:i1]) for s in series) + hi = max(max(s[i0:i1]) for s in series) + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + frame = _frame(widget) + if frame is None: + _wtext(cr, widget, widget.pkind, widget.width / 2, + widget.height / 2 + 5, size=12, align="center", + rgb=(0.4, 0.4, 0.4), max_width=widget.width - 12) + return + plot = _Plot(widget, frame, lo - 1, hi + 1, first, count, + len(DEMO_SERIES)) + _draw_grid(cr, widget, plot) + for values, rgb in zip(series, (LINE_RGB, DOWN_RGB, + (0.0, 150 / 255, 0.0))): + _draw_line_values(cr, plot, values, i0, i1, rgb, 2.0) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, "") + + +def _draw_overlay(cr, widget): + first, count = _view(widget, len(DEMO_SERIES)) + i0, i1 = int(math.floor(first)), int(math.ceil(first + count)) + main = _closes(DEMO_SERIES) + other = _closes(DEMO_SERIES_2) + lo = min(min(main[i0:i1]), min(other[i0:i1])) + hi = max(max(main[i0:i1]), max(other[i0:i1])) + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + frame = _frame(widget) + if frame is None: + _wtext(cr, widget, widget.pkind, widget.width / 2, + widget.height / 2 + 5, size=12, align="center", + rgb=(0.4, 0.4, 0.4), max_width=widget.width - 12) + return + plot = _Plot(widget, frame, lo - 1, hi + 1, first, count, + len(DEMO_SERIES)) + _draw_grid(cr, widget, plot) + _draw_line_values(cr, plot, main, i0, i1, LINE_RGB, 2.0) + cr.save() + _rgb(cr, DOWN_RGB) + cr.set_line_width(1.5) + cr.set_dash([5.0, 3.0]) + started = False + for i in range(i0, min(i1, len(other))): + if i < 0: + continue + x, y = plot.x(i), plot.y(other[i]) + if not started: + cr.move_to(x, y) + started = True + else: + cr.line_to(x, y) + cr.stroke() + cr.restore() + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, _fmt(main[-1])) + + +def _draw_price(cr, widget): + """Price label: big last close + day change (kind "Price").""" + _bg(cr, widget, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + last = DEMO_SERIES[-1][3] + prev = DEMO_SERIES[-2][3] + change = last - prev + rgb = UP_RGB if change >= 0 else DOWN_RGB + sign = "+" if change >= 0 else "" + _wtext(cr, widget, widget.text, 8, 16, size=12, bold=True, + max_width=widget.width - 16) + _wtext(cr, widget, _fmt(last), 8, widget.height / 2 + 12, size=20, + rgb=rgb, bold=True, max_width=widget.width - 16) + _wtext(cr, widget, "%s%s (%s%.2f%%)" % (sign, _fmt(change), sign, + change / prev * 100.0), + 8, widget.height - 8, size=11, rgb=rgb, + max_width=widget.width - 16) + + +# --- drawing tools ----------------------------------------------------------- +# Tools draw over the candle chart. Anchors come from _anchors() +# (only user-set ones count); see the module docstring for the +# Flag 13 (ddaf4bd) guard semantics. + +def _tool_base(cr, widget): + """Candle background + plot for a tool; (plot, i0, i1).""" + plot, i0, i1 = _chart_base(cr, widget, DEMO_SERIES) + if plot is None: + return None, 0, 0 + _draw_candles(cr, widget, plot, DEMO_SERIES, i0, i1) + return plot, i0, i1 + + +def _tool_finish(cr, widget, plot, anchors): + _draw_anchor_dots(cr, plot, anchors) + _draw_x_axis(cr, widget, plot) + _draw_title(cr, widget, plot, "") + + +def _draw_trendline(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", DOWN_RGB) + width = _prop_int(widget, "line-width", 2) + if len(anchors) >= 2: + (b0, p0), (b1, p1) = anchors[0], anchors[1] + _line_through(cr, plot, b0, p0, b1, p1, colour, width) + elif len(anchors) == 1: + bar, price = anchors[0] + cr.save() + _rgb(cr, colour) + cr.set_line_width(width) + cr.move_to(plot.px, plot.y(price)) + cr.line_to(plot.px + plot.pw, plot.y(price)) + cr.stroke() + cr.restore() + else: + _line_through(cr, plot, 0, plot.lo + (plot.hi - plot.lo) * 0.25, + len(DEMO_SERIES) - 1, + plot.lo + (plot.hi - plot.lo) * 0.75, colour, width) + _tool_finish(cr, widget, plot, anchors) + + +def _draw_horizontal_line(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", LINE_RGB) + width = _prop_int(widget, "line-width", 2) + price = anchors[0][1] if anchors \ + else (plot.lo + plot.hi) / 2.0 + cr.save() + _rgb(cr, colour) + cr.set_line_width(width) + cr.move_to(plot.px, plot.y(price)) + cr.line_to(plot.px + plot.pw, plot.y(price)) + cr.stroke() + cr.restore() + _tool_finish(cr, widget, plot, anchors) + + +def _draw_vertical_line(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", (120 / 255, 60 / 255, 180 / 255)) + width = _prop_int(widget, "line-width", 2) + bar = anchors[0][0] if anchors else len(DEMO_SERIES) // 2 + cr.save() + _rgb(cr, colour) + cr.set_line_width(width) + cr.move_to(plot.x(bar), plot.py) + cr.line_to(plot.x(bar), plot.py + plot.ph) + cr.stroke() + cr.restore() + _tool_finish(cr, widget, plot, anchors) + + +def _draw_rectangle(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", LINE_RGB) + fill = _color(widget, "fill-color", + (200 / 255, 220 / 255, 255 / 255)) + width = _prop_int(widget, "line-width", 2) + if len(anchors) >= 2: + (b0, p0), (b1, p1) = anchors[0], anchors[1] + x0, x1 = sorted((plot.x(b0), plot.x(b1))) + y0, y1 = sorted((plot.y(p0), plot.y(p1))) + else: + x0 = plot.px + plot.pw * 0.25 + x1 = plot.px + plot.pw * 0.75 + y0 = plot.py + plot.ph * 0.25 + y1 = plot.py + plot.ph * 0.75 + cr.save() + _rgb(cr, fill, 0.5) + cr.rectangle(x0, y0, x1 - x0, y1 - y0) + cr.fill_preserve() + _rgb(cr, colour) + cr.set_line_width(width) + cr.stroke() + cr.restore() + _tool_finish(cr, widget, plot, anchors) + + +def _draw_ellipse(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", (0.0, 140 / 255, 120 / 255)) + fill = _color(widget, "fill-color", + (220 / 255, 235 / 255, 255 / 255)) + width = _prop_int(widget, "line-width", 2) + if len(anchors) >= 2: + (b0, p0), (b1, p1) = anchors[0], anchors[1] + x0, x1 = sorted((plot.x(b0), plot.x(b1))) + y0, y1 = sorted((plot.y(p0), plot.y(p1))) + else: + x0 = plot.px + plot.pw * 0.25 + x1 = plot.px + plot.pw * 0.75 + y0 = plot.py + plot.ph * 0.25 + y1 = plot.py + plot.ph * 0.75 + cx, cy = (x0 + x1) / 2, (y0 + y1) / 2 + rx, ry = max(1, (x1 - x0) / 2), max(1, (y1 - y0) / 2) + cr.save() + cr.translate(cx, cy) + cr.scale(rx, ry) + cr.arc(0, 0, 1, 0, 2 * math.pi) + cr.restore() + cr.save() + _rgb(cr, fill, 0.5) + cr.fill_preserve() + _rgb(cr, colour) + cr.set_line_width(width) + cr.stroke() + cr.restore() + _tool_finish(cr, widget, plot, anchors) + + +def _draw_arrow(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", DOWN_RGB) + width = _prop_int(widget, "line-width", 3) + if len(anchors) >= 2: + (b0, p0), (b1, p1) = anchors[0], anchors[1] + x0, y0 = plot.x(b0), plot.y(p0) + x1, y1 = plot.x(b1), plot.y(p1) + else: + x0, y0 = plot.px + plot.pw * 0.2, plot.py + plot.ph * 0.7 + x1, y1 = plot.px + plot.pw * 0.8, plot.py + plot.ph * 0.3 + angle = math.atan2(y1 - y0, x1 - x0) + head = 12 + cr.save() + _rgb(cr, colour) + cr.set_line_width(width) + cr.move_to(x0, y0) + cr.line_to(x1, y1) + cr.stroke() + cr.move_to(x1, y1) + cr.line_to(x1 - head * math.cos(angle - 0.45), + y1 - head * math.sin(angle - 0.45)) + cr.line_to(x1 - head * math.cos(angle + 0.45), + y1 - head * math.sin(angle + 0.45)) + cr.close_path() + cr.fill() + cr.restore() + _tool_finish(cr, widget, plot, anchors) + + +def _fib_levels(cr, widget, plot, anchors, ratios, colour, level_rgb): + """Horizontal fib lines between the two anchor prices.""" + if len(anchors) >= 2: + (b0, p0), (b1, p1) = anchors[0], anchors[1] + else: + p0, p1 = plot.hi, plot.lo + lo_p, hi_p = min(p0, p1), max(p0, p1) + span = hi_p - lo_p + for ratio in ratios: + price = hi_p - ratio * span + y = plot.y(price) + cr.save() + _rgb(cr, colour if ratio in (0.0, 1.0) else level_rgb) + cr.set_line_width(1) + if ratio not in (0.0, 1.0): + cr.set_dash([5.0, 3.0]) + cr.move_to(plot.px, y) + cr.line_to(plot.px + plot.pw, y) + cr.stroke() + cr.restore() + _wtext(cr, widget, "%.1f%%" % (ratio * 100), plot.px + 4, + y - 3, size=11, rgb=level_rgb, max_width=60) + + +def _draw_fib_retracement(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", (180 / 255, 120 / 255, 0.0)) + level_rgb = _color(widget, "level-color", + (120 / 255, 120 / 255, 120 / 255)) + _fib_levels(cr, widget, plot, anchors, + (0.0, 0.236, 0.382, 0.5, 0.618, 1.0), colour, level_rgb) + _tool_finish(cr, widget, plot, anchors) + + +def _draw_fib_extension(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", (180 / 255, 80 / 255, 0.0)) + level_rgb = _color(widget, "level-color", + (120 / 255, 120 / 255, 120 / 255)) + if len(anchors) >= 2: + (b0, p0), (b1, p1) = anchors[0], anchors[1] + else: + p0, p1 = plot.hi, plot.lo + span = abs(p1 - p0) + base = min(p0, p1) + for ratio in (1.0, 1.272, 1.618): + price = base + ratio * span if p1 >= p0 \ + else base - ratio * span + y = plot.y(price) + cr.save() + _rgb(cr, colour if ratio == 1.0 else level_rgb) + cr.set_line_width(1) + if ratio != 1.0: + cr.set_dash([5.0, 3.0]) + cr.move_to(plot.px, y) + cr.line_to(plot.px + plot.pw, y) + cr.stroke() + cr.restore() + _wtext(cr, widget, "%.1f%%" % (ratio * 100), plot.px + 4, + y - 3, size=11, rgb=level_rgb, max_width=60) + _tool_finish(cr, widget, plot, anchors) + + +def _draw_parallel_channel(cr, widget): + """Flag 13 (ddaf4bd): with 2 anchors the outer line falls back + to the midline (so it is not drawn twice); with <2 anchors no + channel lines at all -- only the dots present.""" + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", LINE_RGB) + width = _prop_int(widget, "line-width", 2) + if len(anchors) >= 2: + (b0, p0), (b1, p1) = anchors[0], anchors[1] + mid = (p0 + p1) / 2.0 + _line_through(cr, plot, b0, p0, b1, p1, colour, width) + _line_through(cr, plot, b0, mid, b1, mid, colour, 1.0, + dashed=True) + if len(anchors) > 2: + _b2, off = anchors[2] + _line_through(cr, plot, b0, off, b1, off, colour, width) + _tool_finish(cr, widget, plot, anchors) + + +def _draw_pitchfork(cr, widget): + """Flag 13 (ddaf4bd): with 2 anchors the fork falls back to a + trendline through them (the handle); the tines need the third + anchor. With <2 anchors no fork lines at all.""" + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", (120 / 255, 60 / 255, 180 / 255)) + width = _prop_int(widget, "line-width", 2) + if len(anchors) >= 2: + (b0, p0), (b1, p1) = anchors[0], anchors[1] + x0, y0 = plot.x(b0), plot.y(p0) + x1, y1 = plot.x(b1), plot.y(p1) + if len(anchors) > 2: + b2, p2 = anchors[2] + x2, y2 = plot.x(b2), plot.y(p2) + else: + x2, y2 = x1, y1 + mx, my = (x1 + x2) / 2, (y1 + y2) / 2 + run = max(1, mx - x0) + slope = (my - y0) / run + end_x = plot.px + plot.pw + cr.save() + _rgb(cr, colour) + cr.set_line_width(width) + cr.move_to(x0, y0) + cr.line_to(end_x, my + (end_x - x0) * slope) + cr.stroke() + cr.set_line_width(1) + cr.set_dash([5.0, 3.0]) + if len(anchors) > 2: + cr.move_to(x1, y1) + cr.line_to(end_x, y1 + (end_x - x1) * slope) + cr.move_to(x2, y2) + cr.line_to(end_x, y2 + (end_x - x2) * slope) + cr.stroke() + cr.restore() + _tool_finish(cr, widget, plot, anchors) + + +def _draw_measure(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", (0.0, 140 / 255, 120 / 255)) + width = _prop_int(widget, "line-width", 2) + if len(anchors) >= 2: + (b0, p0), (b1, p1) = anchors[0], anchors[1] + x0, y0 = plot.x(b0), plot.y(p0) + x1, y1 = plot.x(b1), plot.y(p1) + cr.save() + _rgb(cr, colour) + cr.set_line_width(width) + cr.set_dash([6.0, 3.0]) + cr.move_to(x0, y0) + cr.line_to(x1, y1) + cr.stroke() + cr.restore() + label = "%+d bars %s" % (b1 - b0, _fmt(p1 - p0)) + _wtext(cr, widget, label, (x0 + x1) / 2, (y0 + y1) / 2 - 6, + size=12, align="center", rgb=colour, max_width=160) + _tool_finish(cr, widget, plot, anchors) + + +def _draw_brush(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", (200 / 255, 30 / 255, 200 / 255)) + width = _prop_int(widget, "line-width", 4) + cr.save() + _rgb(cr, colour) + cr.set_line_width(width) + cr.set_line_cap(1) + steps = 24 + for s in range(steps + 1): + frac = s / steps + x = plot.px + frac * plot.pw + y = plot.py + plot.ph * (0.5 + 0.3 * math.sin(frac * 9.0)) + if s == 0: + cr.move_to(x, y) + else: + cr.line_to(x, y) + cr.stroke() + cr.restore() + _tool_finish(cr, widget, plot, anchors) + + +def _draw_text_annotation(cr, widget): + plot, i0, i1 = _tool_base(cr, widget) + if plot is None: + return + anchors = _anchors(widget) + colour = _color(widget, "color", (160 / 255, 90 / 255, 0.0)) + fill = _color(widget, "fill-color", + (255 / 255, 248 / 255, 200 / 255)) + text_rgb = _color(widget, "text-color", (20 / 255, 20 / 255, 20 / 255)) + note = widget.get_prop("annotation-text", "Note") + if anchors: + x = plot.x(anchors[0][0]) + y = plot.y(anchors[0][1]) + else: + x, y = plot.px + plot.pw * 0.3, plot.py + plot.ph * 0.3 + w = _text_width(cr, widget, note, size=12) + 16 + h = 24 + _box(cr, x, y, w, h, fill, colour) + _wtext(cr, widget, note, x + 8, y + 17, size=12, rgb=text_rgb, + max_width=w - 16) + _tool_finish(cr, widget, plot, anchors) + + +# --- widget class ------------------------------------------------------------ + +_CHART_DRAW = { + "AccumulationDistribution": _draw_accum_dist, + "AreaChart": _draw_area, + "Arrow": _draw_arrow, + "BaselineChart": _draw_baseline, + "Brush": _draw_brush, + "CandlestickChart": _draw_candlestick, + "CorrelationView": _draw_correlation, + "Ellipse": _draw_ellipse, + "FibExtension": _draw_fib_extension, + "FibRetracement": _draw_fib_retracement, + "HeikinAshi": _draw_heikin_ashi, + "HollowCandles": _draw_hollow, + "HorizontalLine": _draw_horizontal_line, + "IndexedComparison": _draw_indexed, + "LineChart": _draw_line, + "MeasureTool": _draw_measure, + "MoneyFlowChart": _draw_money_flow, + "MultiSymbolChart": _draw_multi_symbol, + "OBVChart": _draw_obv, + "OHLCBarChart": _draw_ohlc, + "OverlayChart": _draw_overlay, + "ParallelChannel": _draw_parallel_channel, + "Pitchfork": _draw_pitchfork, + "Price": _draw_price, + "RatioChart": _draw_ratio, + "Rectangle": _draw_rectangle, + "RelativePerformance": _draw_relative_perf, + "Renko": _draw_renko, + "SectorComparison": _draw_sector, + "SpreadChart": _draw_spread, + "TextAnnotation": _draw_text_annotation, + "Trendline": _draw_trendline, + "VWAP": _draw_vwap, + "VerticalLine": _draw_vertical_line, + "VolumeBars": _draw_volume_bars, + "VolumeCandles": _draw_volume_candles, + "VolumeProfile": _draw_volume_profile, +} + + +class StockWidget(Widget): + """One of the 37 Stock Market widgets (archetype Chart/Label in + the palette, drawn here instead of the generic panel).""" + + ARCHETYPE = "Chart" + + def _draw(self, cr): + draw = _CHART_DRAW.get(self.pkind) + if draw is not None: + draw(cr, self) + return + _bg(cr, self, (1.0, 1.0, 1.0), stroke=(0.55, 0.55, 0.55)) + _wtext(cr, self, self.pkind, self.width / 2, + self.height / 2 + 5, size=12, align="center", + rgb=(0.4, 0.4, 0.4), max_width=self.width - 12) diff --git a/tools/gen_props_phase6.py b/tools/gen_props_phase6.py new file mode 100644 index 0000000..31a9d69 --- /dev/null +++ b/tools/gen_props_phase6.py @@ -0,0 +1,216 @@ +#!/usr/bin/env python3 +"""Generate lightgui/props_phase6.py from the C Phase 4 tables. + +Sources (read, never modified): + /opt/lightgui/tools/gen_phase4_props.py + -- the single source of truth the C work used: it parses the + Stock*/Inst* widget headers under + /opt/lightgui/widgets/components and derives one property + table per widget (103 widgets, 1008 props, 116 distinct + names, 0 missing defaults). + /opt/lightgui_python/lightgui/xframe/palette.py + -- the 547 palette kinds; the C class name maps to a palette + kind through the palette's own registry-name table (mostly + stripping the "Stock"/"Inst" prefix, but StockPriceLabel -> + Price and InstRotarySelector -> Rotary, so the palette is + the authority, not the prefix rule). + +The generated file keeps the C tables verbatim (internal prop names, +kinds, defaults, ranges) and adds: + * a Lazarus display name per prop (mechanical CamelCase of the + internal name, e.g. up-color -> UpColor, anchor-1-bar -> + Anchor1Bar), matching the style of the Phase 2 tables, + * a model_only flag: only "symbol" (the ticker symbol stored on + chart widgets; in C symbol_ is settable/readable but never drawn, + so it is stored in the model and emitted by the generator as a + comment). Every other Phase 6 prop is honoured by the draw code + (colours, ranges, levels, values, anchors, view window, alarm + bands, brick-size, bins, labels, ...) and live-applies. + * registration via props.register_custom_table() on import, so the + Inspector and the generator pick the tables up with no other + change (props.py's register_custom_table() is the Phase 6 hook). + +StockChart up/down defaults are the corrected values from the C +tables: up-color rgb(0,150,0), down-color rgb(200,30,30). + +Re-run: python3 tools/gen_props_phase6.py (from the repo root) +""" +import sys +from pathlib import Path + +REPO = Path(__file__).resolve().parent.parent +C_TOOLS = Path("/opt/lightgui/tools") +WIDGETS_DIR = Path("/opt/lightgui/widgets/components") + +sys.path.insert(0, str(C_TOOLS)) +import gen_phase4_props as c_gen # noqa: E402 + +# Palette kind -> C class name is the reverse of this strip; verified +# against palette.py at generation time (must be exactly the 37 Stock +# + 66 Instrumentation kinds, no duplicates, no strays). +MODEL_ONLY = frozenset({"symbol"}) + + +def _display_name(prop): + """Mechanical Lazarus display name: up-color -> UpColor, + anchor-1-bar -> Anchor1Bar, y-min -> YMin.""" + parts = prop.replace("-", " ").split() + return "".join(p[:1].upper() + p[1:] for p in parts) + + +def _kind_of(class_name): + return _REGISTRY_KIND[class_name] + + +def _parse_palette_kinds(): + """Registry name -> palette kind for the Stock/Inst entries, + parsed statically from palette.py (no package import: importing + the palette would import core, which imports the file being + generated). Most names map by stripping the Stock/Inst prefix, + but not all (StockPriceLabel -> Price, InstRotarySelector -> + Rotary), so the palette table is the authority.""" + import re + palette_text = (REPO / "lightgui" / "xframe" / "palette.py") \ + .read_text(encoding="utf-8") + out = {} + for match in re.finditer( + r"PaletteEntry\(\d+, '((?:Stock|Inst)\w+)', '\w+', " + r"'(?:Stock Market|Instrumentation)', \d+, \d+, \d+, " + r"'\w+', '([^']+)'\)", palette_text): + out[match.group(1)] = match.group(2) + return out + + +def _parse_all_palette_kinds(): + """Registry name -> palette kind for ALL 547 entries, parsed + statically (see _parse_palette_kinds). Used to find the + shadowed names: entries outside the Stock/Inst families whose + kind is a Phase 6 kind (kinds are shared across families).""" + import re + palette_text = (REPO / "lightgui" / "xframe" / "palette.py") \ + .read_text(encoding="utf-8") + out = {} + for match in re.finditer( + r"PaletteEntry\(\d+, '(\w+)', '\w+', '[^']+', \d+, \d+, " + r"\d+, '\w+', '([^']+)'\)", palette_text): + out[match.group(1)] = match.group(2) + return out + + +_REGISTRY_KIND = _parse_palette_kinds() + + +def main(): + widgets = c_gen.parse_widgets(str(WIDGETS_DIR)) + assert len(widgets) == 103, "expected 103 widgets, got %d" \ + % len(widgets) + tables = {} + total = 0 + for class_name in sorted(widgets): + props, missing = c_gen.props_for_widget(widgets, class_name) + assert not missing, "missing defaults for %s: %s" \ + % (class_name, missing) + kind = _kind_of(class_name) + assert kind not in tables, "duplicate kind %r" % kind + tables[kind] = (class_name, props) + total += len(props) + assert total == 1008, "expected 1008 props, got %d" % total + distinct = {p[0] for _c, props in tables.values() for p in props} + assert len(distinct) == 116, "expected 116 distinct names, got %d" \ + % len(distinct) + + # Cross-check against the palette: exactly the Stock + Inst kinds. + palette_kinds = set(_REGISTRY_KIND.values()) + assert palette_kinds == set(tables), \ + "palette/generator kind mismatch: %s" % ( + palette_kinds ^ set(tables),) + + # Shadowed names: entries outside the Stock/Inst families whose + # kind is a Phase 6 kind. props._resolve_kind() maps a registry + # name to its kind, so without an explicit table these would + # inherit the Phase 6 table (IndVWAP would get StockVWAP's + # props; TArrow would get StockArrow's). They keep the generic + # set only, as in Phase 2 -- register them with empty tables so + # _resolve_kind() keeps the registry name. + all_kinds = _parse_all_palette_kinds() + shadowed = sorted(name for name, kind in all_kinds.items() + if kind in tables and name not in _REGISTRY_KIND) + assert shadowed, "expected shadowed names, found none" + assert not (set(shadowed) & set(tables)), \ + "shadowed name collides with a Phase 6 kind: %s" % shadowed + + lines = [] + lines.append('"""Property tables for the Stock (37) + Instrumentation') + lines.append('(66) families -- Phase 6.') + lines.append('') + lines.append('GENERATED -- do not edit by hand. Run') + lines.append('tools/gen_props_phase6.py to regenerate from') + lines.append('/opt/lightgui/tools/gen_phase4_props.py (the C tables,') + lines.append('canonical) and lightgui/xframe/palette.py.') + lines.append('') + lines.append('103 widgets, 1008 props, 116 distinct prop names.') + lines.append('Generic set first (from lightgui.props.props_for), then') + lines.append('each widget\'s own props below (register_custom_table).') + lines.append('StockChart up/down defaults are the corrected values') + lines.append('up-color rgb(0,150,0) / down-color rgb(200,30,30).') + lines.append('Model-only: "symbol" only -- the ticker symbol stored on') + lines.append('chart widgets; in C symbol_ is never drawn, so it is') + lines.append('stored in the model and emitted by the generator as a') + lines.append('comment. Every other prop here is honoured by the draw') + lines.append('code and live-applies.') + lines.append('Shadowed registry names (empty tables, generic set') + lines.append('only): entries outside the Stock/Inst families whose') + lines.append('palette kind is a Phase 6 kind -- kinds are shared') + lines.append('across families, so without an explicit table') + lines.append('props._resolve_kind() would map them onto the Phase 6') + lines.append('table (IndVWAP onto StockVWAP, TArrow onto') + lines.append('StockArrow).') + lines.append('"""') + lines.append('') + lines.append('from lightgui.props import PropDef, register_custom_table') + lines.append('') + lines.append('') + lines.append('# C class name -> palette kind, for reference.') + lines.append('PHASE6_CLASSES = {') + for kind in sorted(tables): + class_name, _props = tables[kind] + lines.append(' %r: %r,' % (kind, class_name)) + lines.append('}') + lines.append('') + lines.append('# Registry names outside the Stock/Inst families whose') + lines.append('# kind is a Phase 6 kind; generic set only (see above).') + lines.append('SHADOWED = (') + for name in shadowed: + lines.append(' %r,' % name) + lines.append(')') + lines.append('') + lines.append('TABLES = {') + for kind in sorted(tables): + _class_name, props = tables[kind] + lines.append(' %r: (' % kind) + for (prop, pkind, lo, hi, default, _setter) in props: + lo_s = "0" if lo is None else repr(lo) + hi_s = "0" if hi is None else repr(hi) + model_only = "True" if prop in MODEL_ONLY else "False" + lines.append( + ' PropDef(%r, %r, %r, %s, %s, (), (), %r, %s),' + % (prop, pkind, default, lo_s, hi_s, + _display_name(prop), model_only)) + lines.append(' ),') + lines.append('}') + lines.append('') + lines.append('') + lines.append('for _kind, _props in TABLES.items():') + lines.append(' register_custom_table(_kind, _props)') + lines.append('for _name in SHADOWED:') + lines.append(' register_custom_table(_name, ())') + lines.append('') + + out = REPO / "lightgui" / "props_phase6.py" + out.write_text("\n".join(lines), encoding="utf-8") + print("wrote %s: %d kinds, %d props, %d distinct names, %d shadowed" + % (out, len(tables), total, len(distinct), len(shadowed))) + + +if __name__ == "__main__": + main()