From 2c9eb8a16907e3b86aab245b5f34b9c0eb63d8de Mon Sep 17 00:00:00 2001 From: George O'Neill Date: Tue, 24 Oct 2023 09:29:43 +0100 Subject: [PATCH] offset_units read correctly --- nexus_constructor/json/transformation_reader.py | 5 +++++ nexus_constructor/model/component.py | 2 ++ nexus_constructor/transformation_view.py | 1 + ui/transformation.py | 7 ++++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/nexus_constructor/json/transformation_reader.py b/nexus_constructor/json/transformation_reader.py index 92ebd708a..f20becd6e 100644 --- a/nexus_constructor/json/transformation_reader.py +++ b/nexus_constructor/json/transformation_reader.py @@ -285,6 +285,10 @@ def _create_transformations(self, json_transformations: list): if not units: continue + offset_units = self._find_attribute_in_list(CommonAttrs.OFFSET_UNITS, name, attributes) + if not offset_units: + continue + transformation_type = self._find_attribute_in_list( CommonAttrs.TRANSFORMATION_TYPE, name, @@ -341,6 +345,7 @@ def _create_transformations(self, json_transformations: list): depends_on=None, values=values, offset_vector=QVector3D(*offset_vector), + offset_units=offset_units ) if depends_on not in DEPENDS_ON_IGNORE: depends_on_id = TransformId( diff --git a/nexus_constructor/model/component.py b/nexus_constructor/model/component.py index f68863864..055611156 100644 --- a/nexus_constructor/model/component.py +++ b/nexus_constructor/model/component.py @@ -278,6 +278,7 @@ def _create_and_add_transform( values: Union[Dataset, Group, StreamModule], target_pos: int = -1, offset_vector: Optional[QVector3D] = None, + offset_units: str = "" ) -> Transformation: if name is None: name = _generate_incremental_name(transformation_type, self.transforms) @@ -299,6 +300,7 @@ def _create_and_add_transform( transform.transform_type = transformation_type transform.ui_value = angle_or_magnitude transform.units = units + transform.offset_units = offset_units transform.vector = vector transform.offset_vector = ( offset_vector if offset_vector is not None else QVector3D(0.0, 0.0, 0.0) diff --git a/nexus_constructor/transformation_view.py b/nexus_constructor/transformation_view.py index 14d94165a..fe0eebfc0 100644 --- a/nexus_constructor/transformation_view.py +++ b/nexus_constructor/transformation_view.py @@ -72,6 +72,7 @@ def _fill_in_existing_fields(self, current_vector): self.transformation_frame.x_spinbox_offset.setValue(offset[0]) self.transformation_frame.y_spinbox_offset.setValue(offset[1]) self.transformation_frame.z_spinbox_offset.setValue(offset[2]) + self.transformation_frame.offset_units_line_edit.setText(self.transformation.offset_units) self.update_depends_on_ui() def disable(self): diff --git a/ui/transformation.py b/ui/transformation.py index 935422ebb..9c4027c71 100644 --- a/ui/transformation.py +++ b/ui/transformation.py @@ -112,7 +112,12 @@ def setup_offset_layout(self, transformation): offset_unit_size_policy.setHorizontalPolicy(QSizePolicy.Preferred) offset_unit_size_policy.setHorizontalStretch(1) self.offset_units_line_edit.setSizePolicy(offset_unit_size_policy) - self.offset_units_line_edit.setText("m") + if self.offset_units: + self.offset_units_line_edit.setText( + self.offset_units + ) + else: + self.offset_units_line_edit.setText("m") self.offset_unit_validator.is_valid.connect( partial(validate_line_edit, self.offset_units_line_edit) )