mirror of https://github.com/openXC7/prjxray.git
Make suggested overlay changes, still need tests
Signed-off-by: Andrew Butt <butta@seas.upenn.edu>
This commit is contained in:
parent
2bed3cc771
commit
9456bcded1
|
|
@ -1,3 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2017-2020 The Project X-Ray Authors.
|
||||
#
|
||||
# Use of this source code is governed by a ISC-style
|
||||
# license that can be found in the LICENSE file or at
|
||||
# https://opensource.org/licenses/ISC
|
||||
#
|
||||
# SPDX-License-Identifier: ISC
|
||||
class Overlay(object):
|
||||
""" Object that represents an overlay.
|
||||
|
||||
|
|
@ -5,8 +15,8 @@ class Overlay(object):
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, db, region_dict):
|
||||
self.grid = db.grid()
|
||||
def __init__(self, grid, region_dict):
|
||||
self.grid = grid
|
||||
self.region_dict = region_dict
|
||||
|
||||
def tile_in_roi(self, grid_loc):
|
||||
|
|
@ -18,43 +28,3 @@ class Overlay(object):
|
|||
if x1 <= x and x <= x2 and y1 <= y and y <= y2:
|
||||
return False
|
||||
return True
|
||||
|
||||
def gen_tiles(self, tile_types=None):
|
||||
''' Yield tile names within overlay.
|
||||
|
||||
tile_types: list of tile types to keep, or None for all
|
||||
'''
|
||||
|
||||
for tile_name in self.grid.tiles():
|
||||
loc = self.grid.loc_of_tilename(tile_name)
|
||||
|
||||
if not self.tile_in_roi(loc):
|
||||
continue
|
||||
|
||||
gridinfo = self.grid.gridinfo_at_loc(loc)
|
||||
|
||||
if tile_types is not None and gridinfo.tile_type not in tile_types:
|
||||
continue
|
||||
|
||||
yield tile_name
|
||||
|
||||
def gen_sites(self, site_types=None):
|
||||
''' Yield (tile_name, site_name, site_type) within overlay.
|
||||
|
||||
site_types: list of site types to keep, or None for all
|
||||
|
||||
'''
|
||||
|
||||
for tile_name in self.grid.tiles():
|
||||
loc = self.grid.loc_of_tilename(tile_name)
|
||||
|
||||
if not self.tile_in_roi(loc):
|
||||
continue
|
||||
|
||||
gridinfo = self.grid.gridinfo_at_loc(loc)
|
||||
|
||||
for site_name, site_type in gridinfo.sites.items():
|
||||
if site_types is not None and site_type not in site_types:
|
||||
continue
|
||||
|
||||
yield (tile_name, site_name, site_type)
|
||||
|
|
|
|||
Loading…
Reference in New Issue