Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
offset_units read correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoneiESS committed Oct 24, 2023
1 parent 6db3e97 commit 2c9eb8a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions nexus_constructor/json/transformation_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions nexus_constructor/model/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions nexus_constructor/transformation_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 6 additions & 1 deletion ui/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down

0 comments on commit 2c9eb8a

Please sign in to comment.