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

Commit

Permalink
test fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoneiESS committed Oct 13, 2023
1 parent 090f3aa commit a9ba6df
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion nexus_constructor/json/transformation_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _find_attribute_in_list(
:return: The value of the attribute if is is found in the list, otherwise the failure value is returned.
"""
attribute = _find_attribute_from_list_or_dict(attribute_name, attributes_list)
if not attribute and attribute_name not in [CommonAttrs.OFFSET]:
if not attribute:
self.warnings.append(
TransformDependencyMissing(
f"Unable to find {attribute_name} attribute in transformation"
Expand Down
17 changes: 8 additions & 9 deletions nexus_constructor/model/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,22 @@ def qmatrix(self) -> QMatrix4x4:
"""
transform = Qt3DCore.QTransform()
transform.matrix()
offset = QVector3D() # self.attributes.get_attribute_value(CommonAttrs.OFFSET)
# if not offset:
# offset = 0.0
if self.transform_type == TransformationType.ROTATION:
# noramlise offset to get axis, then apply a rotation offset first to translate it, and then apply rotation
# try setTranslation (to modify ({}.4))
# ORRRR
# self.vector + offset
# apply offset first to translate it, and then apply rotation
transform.setTranslation(
self.offset_vector
)
quaternion = transform.fromAxisAndAngle(
self.vector, self.ui_value * self._ui_scale_factor #(self.ui_value + offset) * self._ui_scale_factor
self.vector, self.ui_value * self._ui_scale_factor
)

transform.setRotation(quaternion)
elif self.transform_type == TransformationType.TRANSLATION:
transform.setTranslation(
self.vector.normalized()
* (self.ui_value) # + offset)
* self.ui_value
* self._ui_scale_factor
+ self.offset_vector
)
else:
raise (
Expand Down
6 changes: 6 additions & 0 deletions tests/json/test_transformation_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ def test_GIVEN_all_information_present_WHEN_attempting_to_create_translation_THE
2.0,
3.0,
]
transformation_json["children"][0]["attributes"][2]["offset"] = offset_vector = [
4.0,
5.0,
6.0,
]
depends_on = None

values = _create_transformation_dataset(angle_or_magnitude, "double", name)
Expand All @@ -345,6 +350,7 @@ def test_GIVEN_all_information_present_WHEN_attempting_to_create_translation_THE
vector=QVector3D(*vector),
depends_on=depends_on,
values=values,
offset_vector=QVector3D(*offset_vector)
)


Expand Down

0 comments on commit a9ba6df

Please sign in to comment.