Skip to content

Commit

Permalink
Plot components in EDB plots (#1983)
Browse files Browse the repository at this point in the history
* first implementation of components plot in edb plot

* tested circle and rectangles, options to plot only top or bottom components

* added maximum number of elements in the legend, outline is now contour type

* plot all types of components

* Update pyaedt/edb_core/edb_data/components_data.py

* Update pyaedt/edb_core/nets.py

* Update pyaedt/edb_core/nets.py

* fixed bug and docstring

* added and improved unit tests

Co-authored-by: Massimo Capodiferro <[email protected]>
Co-authored-by: Maxime Rey <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2022
1 parent 85ccad2 commit 1433388
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 130 deletions.
Binary file not shown.
42 changes: 35 additions & 7 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def setup_class(self):
example_project2 = os.path.join(local_path, "example_models", test_subfolder, "simple.aedb")
self.target_path2 = os.path.join(self.local_scratch.path, "simple_00.aedb")
self.local_scratch.copyfolder(example_project2, self.target_path2)
example_project3 = os.path.join(local_path, "example_models", test_subfolder, "Galileo_edb_plot.aedb")
self.target_path3 = os.path.join(self.local_scratch.path, "Galileo_edb_plot_00.aedb")
self.local_scratch.copyfolder(example_project3, self.target_path3)

def teardown_class(self):
self.edbapp.close_edb()
Expand Down Expand Up @@ -772,14 +775,39 @@ def test_67_add_void(self):
def test_69_create_solder_balls_on_component(self):
assert self.edbapp.core_components.set_solder_ball("U2A5")

@pytest.mark.skipif(
is_ironpython,
reason="This test uses Matplotlib, which is not supported by IronPython.",
)
@pytest.mark.skipif(is_ironpython, reason="This test uses Matplotlib, which is not supported by IronPython.")
def test_70_plot_on_matplotlib(self):
local_png = os.path.join(self.local_scratch.path, "test.png")
self.edbapp.core_nets.plot(None, None, save_plot=local_png)
assert os.path.exists(local_png)
edb_plot = Edb(self.target_path3, edbversion=desktop_version)
local_png1 = os.path.join(self.local_scratch.path, "test1.png")
edb_plot.core_nets.plot(
nets=None,
layers=None,
save_plot=local_png1,
plot_components_on_top=True,
plot_components_on_bottom=True,
outline=[[-10e-3, -10e-3], [110e-3, -10e-3], [110e-3, 70e-3], [-10e-3, 70e-3]],
)
assert os.path.exists(local_png1)

local_png2 = os.path.join(self.local_scratch.path, "test2.png")
edb_plot.core_nets.plot(
nets="V3P3_S5",
layers=None,
save_plot=local_png2,
plot_components_on_top=True,
plot_components_on_bottom=True,
)
assert os.path.exists(local_png2)
local_png3 = os.path.join(self.local_scratch.path, "test3.png")
edb_plot.core_nets.plot(
nets=["LVL_I2C_SCL", "V3P3_S5", "GATE_V5_USB"],
layers="TOP",
color_by_net=True,
save_plot=local_png3,
plot_components_on_top=True,
plot_components_on_bottom=True,
)
assert os.path.exists(local_png3)

def test_71_fix_circle_voids(self):
assert self.edbapp.core_primitives.fix_circle_void_for_clipping()
Expand Down
36 changes: 14 additions & 22 deletions pyaedt/edb_core/edb_data/components_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ def netlist(self):
def __init__(self, components, cmp):
self._pcomponents = components
self.edbcomponent = cmp
self._layout_instance = None

@property
def layout_instance(self):
"""Edb layout instance object."""
if self._layout_instance is None:
self._layout_instance = self.edbcomponent.GetLayout().GetLayoutInstance()
return self._layout_instance

@property
def _pedb(self): # pragma: no cover
Expand Down Expand Up @@ -529,8 +537,7 @@ def center(self):
-------
list
"""
layinst = self.edbcomponent.GetLayout().GetLayoutInstance()
cmpinst = layinst.GetLayoutObjInstance(self.edbcomponent, None)
cmpinst = self.layout_instance.GetLayoutObjInstance(self.edbcomponent, None)
center = cmpinst.GetCenter()
return [center.X.ToDouble(), center.Y.ToDouble()]

Expand All @@ -545,11 +552,11 @@ def bounding_box(self):
coordinates in this order: [X lower left corner, Y lower left corner,
X upper right corner, Y upper right corner].
"""
layinst = self.edbcomponent.GetLayout().GetLayoutInstance()
_bbox = layinst.GetLayoutObjInstance(self.edbcomponent, None).GetBBox()
_pt1 = _bbox.Item1
_pt2 = _bbox.Item2
return [_pt1.X.ToDouble(), _pt1.Y.ToDouble(), _pt2.X.ToDouble(), _pt2.Y.ToDouble()]
cmpinst = self.layout_instance.GetLayoutObjInstance(self.edbcomponent, None)
bbox = cmpinst.GetBBox()
pt1 = bbox.Item1
pt2 = bbox.Item2
return [pt1.X.ToDouble(), pt1.Y.ToDouble(), pt2.X.ToDouble(), pt2.Y.ToDouble()]

@property
def rotation(self):
Expand All @@ -561,21 +568,6 @@ def rotation(self):
"""
return self.edbcomponent.GetTransform().Rotation.ToDouble()

@property
def bounding_box(self):
"""Return the component bounding box.
Returns
-------
List[float]
[X lower left corner, Y lower left corner, X upper right corner, Y upper right corner].
"""
layinst = self.edbcomponent.GetLayout().GetLayoutInstance()
_bbox = layinst.GetLayoutObjInstance(self.edbcomponent, None).GetBBox()
_pt1 = _bbox.Item1
_pt2 = _bbox.Item2
return [_pt1.X.ToDouble(), _pt1.Y.ToDouble(), _pt2.X.ToDouble(), _pt2.Y.ToDouble()]

@property
def pinlist(self):
"""Pins of the component.
Expand Down
Loading

0 comments on commit 1433388

Please sign in to comment.