diff --git a/src/calng/CalibrationManager.py b/src/calng/CalibrationManager.py index ae009f0ea0915b58c680bb50dd4c9d069a68f3f1..b57da96757eec36a58bc6d69f63677ad9840c4be 100644 --- a/src/calng/CalibrationManager.py +++ b/src/calng/CalibrationManager.py @@ -320,7 +320,9 @@ class CalibrationManager(DeviceClientBase, Device): self.deviceId, self.getDeviceSchema(), self._correction_device_schema, - sorted(self._correction_device_ids)) + self._correction_device_ids, + self._domain_device_ids, + ) payload = Hash('success', True, 'name', name, 'data', scene_data) return Hash('type', 'deviceScene', 'origin', self.deviceId, diff --git a/src/calng/scenes.py b/src/calng/scenes.py index c39d584fb6fa5991403689f1b38949a43f94f2b7..c5e38373f2b10f9a859983ccc21a3ba48de46b70 100644 --- a/src/calng/scenes.py +++ b/src/calng/scenes.py @@ -53,67 +53,56 @@ class Align(enum.Enum): RIGHT = enum.auto() -def titled(title, width=8): +def titled(title, width=8 * NARROW_INC): def actual_decorator(component_class): - # should this create subclass instead of mutating? - orig_render = component_class.render - - def new_render(self, x, y, *args, **kwargs): - return [ - LabelModel( - frame_width=1, - text=title, - width=width * BASE_INC, - height=BASE_INC, - x=x, - y=y, - ) - ] + orig_render(self, x, y + BASE_INC, *args, **kwargs) - - component_class.render = new_render - - orig_height = component_class.height + class new_class(component_class): + def render(self, x, y, *args, **kwargs): + return [ + LabelModel( + frame_width=1, + text=title, + width=width, + height=NARROW_INC, + x=x, + y=y, + ) + ] + component_class.render(self, x, y + NARROW_INC, *args, **kwargs) - def new_height(self): - return orig_height.fget(self) + BASE_INC + @property + def width(self): + return max(component_class.width.fget(self), width) - component_class.height = property(fget=new_height) + @property + def height(self): + return component_class.height.fget(self) + NARROW_INC - return component_class + return new_class return actual_decorator def boxed(component_class): - # should this create subclass instead of mutating? - orig_render = component_class.render - orig_width = component_class.width - orig_height = component_class.height - - def new_render(self, x, y, *args, **kwargs): - return [ - RectangleModel( - x=x, - y=y, - width=orig_width.fget(self) + 2 * PADDING, - height=orig_height.fget(self) + 2 * PADDING, - stroke="#000000", - ) - ] + orig_render(self, x + PADDING, y + PADDING, *args, **kwargs) - - component_class.render = new_render - - def new_height(self): - return orig_height.fget(self) + 2 * PADDING - - component_class.height = property(fget=new_height) + class new_class(component_class): + def render(self, x, y, *args, **kwargs): + return [ + RectangleModel( + x=x, + y=y, + width=component_class.width.fget(self) + 2 * PADDING, + height=component_class.height.fget(self) + 2 * PADDING, + stroke="#000000", + ) + ] + component_class.render(self, x + PADDING, y + PADDING, *args, **kwargs) - def new_width(self): - return orig_width.fget(self) + 2 * PADDING + @property + def width(self): + return component_class.width.fget(self) + 2 * PADDING - component_class.width = property(fget=new_width) + @property + def height(self): + return component_class.height.fget(self) + 2 * PADDING - return component_class + return new_class class HorizontalLayout: @@ -240,7 +229,7 @@ class MaybeEditableRow(HorizontalLayout): ) -@titled("Parameters used for CalCat queries", width=10) +@titled("Parameters used for CalCat queries", width=10 * NARROW_INC) @boxed class ConstantParameterColumn(VerticalLayout): def __init__(self, device_id, schema_hash, prefix="constantParameters"): @@ -287,7 +276,7 @@ class ConstantNode(HorizontalLayout): ) -@titled("Found constants", width=6) +@titled("Found constants", width=6 * NARROW_INC) @boxed class FoundConstantsColumn(VerticalLayout): def __init__(self, device_id, schema_hash, prefix="foundConstants"): @@ -333,7 +322,7 @@ class CorrectionStepNode(HorizontalLayout): ) -@titled("Correction steps", width=6) +@titled("Correction steps", width=6 * NARROW_INC) @boxed class CorrectionStepsColumn(VerticalLayout): def __init__(self, device_id, schema_hash, prefix="corrections"): @@ -372,7 +361,7 @@ class ConstantLoadedAmpeln(HorizontalLayout): ) -@titled("Manager status", width=6) +@titled("Manager status", width=6 * NARROW_INC) @boxed class ManagerDeviceStatus(VerticalLayout): def __init__(self, device_id): @@ -406,7 +395,7 @@ class ManagerDeviceStatus(VerticalLayout): self.status_log = DisplayTextLogModel( keys=[f"{device_id}.status"], width=14 * BASE_INC, - height=7 * BASE_INC, + height=14 * BASE_INC, ) self.children.extend( [ @@ -427,7 +416,7 @@ class ManagerDeviceStatus(VerticalLayout): ) -@titled("Device status", width=6) +@titled("Device status", width=6 * NARROW_INC) @boxed class CorrectionDeviceStatus(VerticalLayout): def __init__(self, device_id): @@ -554,6 +543,7 @@ def manager_device_overview_scene( manager_device_schema, correction_device_schema, correction_device_ids, + domain_device_ids, ): mds_hash = schema_to_hash(manager_device_schema) cds_hash = schema_to_hash(correction_device_schema) @@ -563,18 +553,41 @@ def manager_device_overview_scene( HorizontalLayout( children=[ ManagerDeviceStatus(manager_device_id), - ConstantParameterColumn( - manager_device_id, mds_hash, prefix="managed.constantParameters" + VerticalLayout( + children=[ + ConstantParameterColumn( + manager_device_id, + mds_hash, + prefix="managed.constantParameters", + ), + CorrectionStepsColumn( + manager_device_id, + mds_hash, + prefix="managed.corrections", + ), + ] ), - CorrectionStepsColumn( - manager_device_id, mds_hash, prefix="managed.corrections" + titled("Other devices managed")(boxed(VerticalLayout))( + children=[ + DeviceSceneLinkModel( + text=device_id.split("/")[-1], + keys=[f"{device_id}.availableScenes"], + width=14 * BASE_INC, + height=BASE_INC, + ) + for device_id in sorted( + set(domain_device_ids) + - set(correction_device_ids) + - {manager_device_id} + ) + ] ), - ] + ], ), - VerticalLayout( + titled("Correction devices", width=8 * NARROW_INC)(boxed(VerticalLayout))( children=[ CompactCorrectionDeviceOverview(device_id, cds_hash) - for device_id in correction_device_ids + for device_id in sorted(correction_device_ids) ], padding=0, ),