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

Commit

Permalink
json complete but units written twice
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoneiESS committed Oct 18, 2023
1 parent 674e553 commit 43bedad
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions nexus_constructor/common_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CommonAttrs:
NX_CLASS = "NX_class"
DEPENDS_ON = "depends_on"
TRANSFORMATION_TYPE = "transformation_type"
OFFSET_UNITS = "offset_units"
VECTOR = "vector"
UNITS = "units"
VERTICES = "vertices"
Expand Down
9 changes: 9 additions & 0 deletions nexus_constructor/model/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ def units(self, new_units):
self._evaluate_ui_scale_factor(new_units)
self.attributes.set_attribute_value(CommonAttrs.UNITS, new_units)

@property
def offset_units(self):
return self.attributes.get_attribute_value(CommonAttrs.OFFSET_UNITS)

@offset_units.setter
def offset_units(self, new_units):
self._evaluate_ui_scale_factor(new_units)
self.attributes.set_attribute_value(CommonAttrs.OFFSET_UNITS, new_units)

def _evaluate_ui_scale_factor(self, units):
try:
if self.transform_type == TransformationType.TRANSLATION:
Expand Down
4 changes: 4 additions & 0 deletions nexus_constructor/transformation_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def _init_connections(self):
self.transformation_frame.magnitude_widget.units_line_edit.textChanged.connect(
self.save_magnitude
)
self.transformation_frame.offset_units_line_edit.textChanged.connect(
self.save_offset
)
if self.model:
self.model.signals.transformation_changed.connect(self.update_depends_on_ui)

Expand Down Expand Up @@ -119,6 +122,7 @@ def save_offset(self):
self.transformation.offset_vector = QVector3D(
*[spinbox.value() for spinbox in self.transformation_frame.offset_spinboxes]
)
self.transformation.offset_units = self.transformation_frame.offset_units
self.model.signals.transformation_changed.emit()

def save_all_changes(self):
Expand Down
10 changes: 9 additions & 1 deletion ui/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def setup_offset_layout(self, transformation):
self.offset_unit_validator.is_valid.connect(
partial(validate_line_edit, self.offset_units_line_edit)
)
self.offset_units_line_edit.setPlaceholderText(CommonAttrs.UNITS)
self.offset_units_line_edit.setPlaceholderText(CommonAttrs.OFFSET_UNITS)
self.main_layout.addWidget(self.offset_units_line_edit)
self._add_line()

Expand Down Expand Up @@ -187,6 +187,14 @@ def set_spinbox_ranges(self):
spinbox.setRange(-10000000, 10000000)
spinbox.setDecimals(5)

@property
def offset_units(self) -> str:
return self.offset_units_line_edit.text()

@offset_units.setter
def offset_units(self, new_units: str):
self.offset_units_line_edit.setText(new_units)

@staticmethod
def _make_text_bold(label: QLabel):
font = label.font()
Expand Down

0 comments on commit 43bedad

Please sign in to comment.