Skip to content

Commit

Permalink
Issue 21 bugfixes, ported from V8
Browse files Browse the repository at this point in the history
  • Loading branch information
MitjaNemec committed Jan 29, 2024
1 parent d783a6a commit 8d49424
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
15 changes: 12 additions & 3 deletions action_place_footprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def __init__(self, parent, placer, ref_fp, user_units):

self.list_levels.Clear()
self.list_levels.AppendItems(self.ref_fp.filename)

self.logger.info("Ref fp:" + repr(self.ref_fp))
self.logger.info("Levels:" + repr(self.ref_fp.filename))
# by default select all items
self.logger.info("Selecting: " + repr(self.list_levels.GetCount()))
for i in range(self.list_levels.GetCount()):
Expand Down Expand Up @@ -277,7 +280,9 @@ def level_changed(self, event):
self.logger.info("Level_changed() invoked")

index = self.list_levels.GetSelection()
self.list_sheetsChoices = self.placer.get_sheets_to_replicate(self.ref_fp, self.ref_fp.sheet_id[index])
self.logger.info(f'self.ref_fp.sheet_id[index] = {repr(self.ref_fp.sheet_id[index])}')
self.logger.info(f'self.ref_fp.sheet_id = {repr(self.ref_fp.sheet_id)}')
self.list_sheetsChoices = self.placer.get_sheets_to_place(self.ref_fp, self.ref_fp.sheet_id[index])

# clear highlights
for ref in self.ref_list:
Expand All @@ -290,11 +295,15 @@ def level_changed(self, event):

# find matching anchors to matching sheets so that indices will match
self.ref_list = []
for sheet in self.list_sheetsChoices:
for fp in footprints_with_same_id:
self.logger.info(f'self.list_sheetsChoices: {repr(self.list_sheetsChoices)}')

for fp in footprints_with_same_id:
self.logger.info(f'fp.sheet_id: {repr(fp.sheet_id)}')
for sheet in self.list_sheetsChoices:
if "/".join(sheet) in "/".join(fp.sheet_id):
self.ref_list.append(fp.ref)
break
self.logger.info(f'self.ref_list: {repr(self.ref_list)}')

sheets_for_list = ['/'.join(x[0]) + " (" + x[1] + ")" for x in zip(self.list_sheetsChoices, self.ref_list)]

Expand Down
48 changes: 20 additions & 28 deletions place_footprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,48 +236,40 @@ def get_list_of_footprints_with_same_id(self, fp_id):
footprints_with_same_id.append(fp)
return footprints_with_same_id

def get_sheets_to_replicate(self, reference_footprint, level):
def get_sheets_to_place(self, reference_footprint, level):
sheet_id = reference_footprint.sheet_id
level_index = sheet_id.index(level)
sheet_depth = len(sheet_id)

sheet_file = reference_footprint.filename
# find level_id
level_file = sheet_file[sheet_id.index(level)]
logger.info('constructing a list of sheets suitable for replication on level:'
+ repr(level) + ", file:" + repr(level_file))

# construct complete hierarchy path up to the level of reference footprint
sheet_id_up_to_level = []
for i in range(len(sheet_id)):
sheet_id_up_to_level.append(sheet_id[i])
if sheet_id[i] == level:
break
up_to_level_file = sheet_file[:level_index+1]

# get all footprints with same ID
footprints_with_same_id = self.get_list_of_footprints_with_same_id(reference_footprint.fp_id)
# if hierarchy is deeper, match only the sheets with same hierarchy from root to -1
sheets_on_same_level = []

# go through all the footprints
sheets_up_to_same_level = []
for fp in footprints_with_same_id:
# if the footprint is on selected level, it's sheet is added to the list of sheets on this level
if level_file in fp.filename:
sheet_id_list = []
# create a hierarchy path only up to the level
for i in range(len(fp.filename)):
sheet_id_list.append(fp.sheet_id[i])
if fp.filename[i] == level_file:
break
sheets_on_same_level.append(sheet_id_list)

# remove duplicates
sheets_on_same_level.sort()
sheets_on_same_level = list(k for k, _ in itertools.groupby(sheets_on_same_level))
# match only if the filepath matches and all but the level sheetnames match
if len(fp.sheet_id) == len(sheet_id):
fp_id_level = "/".join(fp.sheet_id[:level_index] + fp.sheet_id[level_index+1:])
ref_fp_id_level = "/".join(sheet_id[:level_index] + sheet_id[level_index+1:])
if fp.filename[:level_index+1] == up_to_level_file and fp_id_level == ref_fp_id_level:
sheets_up_to_same_level.append(fp.sheet_id)

# sort
sheets_up_to_same_level.sort(key=lambda item: (len("".join(item)), item))

# remove the sheet path for reference footprint
if sheet_id_up_to_level in sheets_on_same_level:
index = sheets_on_same_level.index(sheet_id_up_to_level)
del sheets_on_same_level[index]
logger.info("suitable sheets are:"+repr(sheets_on_same_level))
return sheets_on_same_level
if sheet_id in sheets_up_to_same_level:
index = sheets_up_to_same_level.index(sheet_id)
del sheets_up_to_same_level[index]
logger.info("suitable sheets are:"+repr(sheets_up_to_same_level))
return sheets_up_to_same_level

def get_footprints_on_sheet(self, level):
footprints_on_sheet = []
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.3
2.1.4

0 comments on commit 8d49424

Please sign in to comment.