Skip to content
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

add Instance setter and getter for center #191

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/190.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add Instance setter and getter for center
30 changes: 30 additions & 0 deletions src/kfactory/kcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -3347,6 +3347,36 @@ def ymax(self, __val: int) -> None:
"""Moves the instance so that the bbox's left x-coordinate."""
self.transform(kdb.Trans(0, __val - self._instance.bbox().top))

@property
def x(self) -> int:
"""Returns the x-coordinate center of the bounding box."""
return self._instance.bbox().center().x

@x.setter
def x(self, __val: int) -> None:
"""Moves the instance so that the bbox's center x-coordinate."""
self.transform(kdb.Trans(__val - self.bbox().center().x, 0))

@property
def y(self) -> int:
"""Returns the x-coordinate center of the bounding box."""
return self._instance.bbox().center().y

@y.setter
def y(self, __val: int) -> None:
"""Moves the instance so that the bbox's center x-coordinate."""
self.transform(kdb.Trans(__val - self.bbox().center().y, 0))

@property
def center(self) -> kdb.Point:
"""Returns the coordinate center of the bounding box."""
return self._instance.bbox().center()

@center.setter
def center(self, __val: kdb.Point) -> None:
"""Moves the instance so that the bbox's center coordinate."""
self.transform(kdb.Trans(__val - self.bbox().center()))


class UMInstance:
"""Make the port able to dynamically give um based info."""
Expand Down
Loading