-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rotation first steps #66
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start! The tests aren't working because you're missing the code which actually plugs the new values into the underlying Qt objects. For example, TextInterface._get_path
should pass the transform origin into QClippingPath
, and QClippingPath
should call self.setTransformOriginPoint
in its init (like how it does for self.setRotation
). Similarly, ImageInterface._apply_common_properties
should apply the transform origin values like it does for rotation and scale.
# text = TextInterface( | ||
# ORIGIN, self.brush, self.pen, "foo", self.font, rotation=(Unit(12),Unit(12)) | ||
# ) | ||
# assert text._create_qt_object().transform_origin() == (Unit(12),Unit(12)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qt points are expressed as QPointF
values. neoscore.interface.qt.converters
has some convenience methods for converting neoscore points to Qt points.
@@ -55,6 +55,14 @@ def test_rotation(self): | |||
) | |||
assert text._create_qt_object().rotation() == 123 | |||
|
|||
# def test_rotation_about_transform_origin(self): | |||
# text = TextInterface(ORIGIN, self.brush, self.pen, "foo", self.font) | |||
# assert text._create_qt_object().transform_origin() == ORIGIN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Qt field is called transformOriginPoint
# text = TextInterface(ORIGIN, self.brush, self.pen, "foo", self.font) | ||
# assert text._create_qt_object().transform_origin() == ORIGIN | ||
# text = TextInterface( | ||
# ORIGIN, self.brush, self.pen, "foo", self.font, rotation=(Unit(12),Unit(12)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mean to set transform_origin=(Unit(12), Unit(12))
here
@@ -36,6 +38,9 @@ class ImageInterface(PositionedObjectInterface): | |||
z_index: int = 0 | |||
"""Z-index controlling draw order.""" | |||
|
|||
transform_origin: Point = ORIGIN | |||
"""Axis of rotation""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't just the rotation axis, it's the axis for all transformations. For our purposes, that means scaling and rotation. A better docstring would be something like "The origin point for rotation and scaling transforms"
Made some progress today in understanding how all this works. I still have not figured out how to add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should work! you just need to apply the described change. this also needs unit tests for all the other interface classes with the new field, not just TextInterface
neoscore/interface/path_interface.py
Outdated
@@ -123,6 +128,7 @@ def _create_qt_object(self) -> QClippingPath: | |||
self.rotation, | |||
self.background_brush.qt_object if self.background_brush else None, | |||
defer_geometry_calculation=True, | |||
# self.transform_origin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just need to uncomment this line and bind it
# self.transform_origin, | |
transform_origin=self.transform_origin, |
@@ -55,6 +56,21 @@ def test_rotation(self): | |||
) | |||
assert text._create_qt_object().rotation() == 123 | |||
|
|||
def test_transformOriginPoint(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this name should be test_transform_origin_point
(following typical python naming conventions, where snake case is used for most things)
also, please run the cleanup scripts before committing, as I see the import cleanup wasn't run. I recommend doing this in a pre-commit hook so you can't forget. check out the guide for this. (we temporarily disabled the build check on imports, but I'm going to re-enable it soon) |
Thanks for the assistance! Tests should all be made, and they are all passing.
Otherwise, Black seems to handle a lot of the formatting just fine. |
Hm yeah seems like some WSL integration issue. The step that seems to not be running on your end is |
btw, for future PRs I recommend creating your own separate branch off of |
Added
transform_origin
field to interface classes.Attempted to test the field but ran into some issues. The relevant code is commented out in
path_interface.py
andtest_text_interface.py.
Things should be formatted correctly now.