Use lt.property/setting validatiors to set numerical input range and step

This commit is contained in:
Julian Stirling 2026-02-18 23:43:25 +00:00
parent 4326bb2075
commit cd14f470f6
2 changed files with 21 additions and 6 deletions

View file

@ -173,13 +173,13 @@ class RectGridWorkflow(ScanWorkflow[SettingModelType], Generic[SettingModelType]
# Redefine _csm Thing Slot, as CSM is required for any RectGridWorkflow # Redefine _csm Thing Slot, as CSM is required for any RectGridWorkflow
_csm: CameraStageMapper = lt.thing_slot() _csm: CameraStageMapper = lt.thing_slot()
overlap: float = lt.setting(default=0.45, ge=0.1, le=0.7) overlap: float = lt.setting(default=0.45, ge=0.1, le=0.7, multiple_of=0.05)
"""The fraction that adjacent images should overlap in x and y. """The fraction that adjacent images should overlap in x and y.
This must be between 0.1 and 0.7. This must be between 0.1 and 0.7.
""" """
autofocus_dz: int = lt.setting(default=1000, ge=400, le=3000) autofocus_dz: int = lt.setting(default=1000, ge=400, le=3000, multiple_of=200)
"""The z distance to perform an autofocus in steps. """The z distance to perform an autofocus in steps.
Must be greater than or equal to 400, and less than or equal to 3000. Must be greater than or equal to 400, and less than or equal to 3000.
@ -290,18 +290,18 @@ class HistoScanWorkflow(RectGridWorkflow[HistoScanSettingsModel]):
This uses the settings from the ``BackgroundDetectThing``. This uses the settings from the ``BackgroundDetectThing``.
""" """
max_range: int = lt.setting(default=45000) max_range: int = lt.setting(default=45000, multiple_of=1000)
"""The maximum distance in steps from the centre of the scan.""" """The maximum distance in steps from the centre of the scan."""
# Stacking settings # Stacking settings
stack_images_to_save: int = lt.setting(default=1) stack_images_to_save: int = lt.setting(default=1, ge=1, le=9)
"""The number of images to save in a stack. """The number of images to save in a stack.
Defaults to 1 unless you need to see either side of focus Defaults to 1 unless you need to see either side of focus
""" """
stack_min_images_to_test: int = lt.setting(default=9) stack_min_images_to_test: int = lt.setting(default=9, ge=5, le=13)
"""The minimum number of images to capture in a stack. """The minimum number of images to capture in a stack.
This many images are captures and tested for focus, if the focus is not central This many images are captures and tested for focus, if the focus is not central
@ -311,7 +311,7 @@ class HistoScanWorkflow(RectGridWorkflow[HistoScanSettingsModel]):
Defaults to 9 which balances reliability and speed. Defaults to 9 which balances reliability and speed.
""" """
stack_dz: int = lt.setting(default=50) stack_dz: int = lt.setting(default=50, ge=20, le=400, multiple_of=10)
"""Distance in steps between images in a z-stack. """Distance in steps between images in a z-stack.
Suggested values: Suggested values:

View file

@ -25,6 +25,9 @@
:class="{ edited: isEdited, flash: animateUpdate }" :class="{ edited: isEdited, flash: animateUpdate }"
:disabled="isDisabled" :disabled="isDisabled"
type="number" type="number"
:min="minimum"
:max="maximum"
:step="step"
@input="grabFocus" @input="grabFocus"
@focusout="focusOut" @focusout="focusOut"
@keydown="keyDown" @keydown="keyDown"
@ -242,6 +245,18 @@ export default {
} }
return "other"; return "other";
}, },
maximum() {
if (this.dataType !== "number") return undefined;
return this.dataSchema.maximum;
},
minimum() {
if (this.dataType !== "number") return undefined;
return this.dataSchema.minimum;
},
step() {
if (this.dataType !== "number") return undefined;
return this.dataSchema.multipleOf;
},
}, },
watch: { watch: {