Skip to content

Commit

Permalink
Merge pull request #191 from gdsfactory/add_instance_center_setter_ge…
Browse files Browse the repository at this point in the history
…tter

add Instance setter and getter for center
  • Loading branch information
sebastian-goeldi authored Oct 6, 2023
2 parents 731ae1c + ddd43d1 commit 04264ff
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
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

0 comments on commit 04264ff

Please sign in to comment.