Skip to content

Commit

Permalink
all working with the new spec of everything going in the dataprep lyp…
Browse files Browse the repository at this point in the history
… file
  • Loading branch information
atait committed Jun 21, 2019
1 parent 586c46a commit 092ff50
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 34 deletions.
6 changes: 2 additions & 4 deletions lymask/invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from lymask.utilities import gui_view, gui_active_layout, \
active_technology, set_active_technology, \
tech_layer_properties, tech_dataprep_layer_properties, \
lys, insert_layer_tab
lys, load_dataprep_layers
from lymask.steps import all_func_dict


Expand All @@ -37,9 +37,7 @@ def _main(layout, ymlfile, tech_obj=None):
# todo: reload lys using technology
with open(ymlfile) as fx:
step_list = yaml.load(fx)
lys.clear()
lys.appendFile(tech_layer_properties(tech_obj))
insert_layer_tab(tech_dataprep_layer_properties(tech_obj), tab_name='Dataprep')
load_dataprep_layers(tech_obj)
for func_info in step_list:
func = all_func_dict[func_info[0]]
try:
Expand Down
9 changes: 2 additions & 7 deletions lymask/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os

from lymask.invocation import gui_main
from lymask.utilities import insert_layer_tab, tech_dataprep_layer_properties, reload_lys, gui_view
from lymask.utilities import load_dataprep_layers, tech_dataprep_layer_properties

DEFAULT_TECH = 'OLMAC'

Expand Down Expand Up @@ -71,12 +71,7 @@ def reload_dataprep_menu(tech_name=None):
dataprep_yml_to_menu(dataprep_file)
# Now put in the layers refresh
menu = pya.Application.instance().main_window().menu()
def refresh_layers():
reload_lys(tech_name)
lv = gui_view()
lv.load_layer_props(tech_dataprep_layer_properties())
lv.current_layer_list = 0
layer_action = _gen_new_action(refresh_layers)
layer_action = _gen_new_action(load_dataprep_layers)
layer_action.title = 'Refresh layer display'
layer_action.shortcut = 'Shift+Ctrl+P'
menu.insert_separator('soen_menu.dataprep.begin', 'SEP2')
Expand Down
32 changes: 16 additions & 16 deletions lymask/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,22 @@ def mask_map(cell, clear_others=False, **kwargs):
raise
cell.copy(comp_lay_info, lys[dest_layer])
mask_layer_index += 1
if isGUI():
try:
lv = gui_view()
add_tab = True
except UserWarning:
# No view is selected. We might be in batch mode
add_tab = False
if add_tab:
insert_layer_tab(tab_name='Masks')
for dest_layer in kwargs.keys():
lay_prop = pya.LayerProperties()
lay_prop.source_name = lys.get_as_LayerInfo(dest_layer).name
lay_prop.source_layer = lys.get_as_LayerInfo(dest_layer).layer
lay_prop.source_datatype = lys.get_as_LayerInfo(dest_layer).datatype
lv.init_layer_properties(lay_prop)
lv.insert_layer(lv.end_layers(), lay_prop)
# if isGUI():
# try:
# lv = gui_view()
# add_tab = True
# except UserWarning:
# # No view is selected. We might be in batch mode
# add_tab = False
# if add_tab:
# insert_layer_tab(tab_name='Masks')
# for dest_layer in kwargs.keys():
# lay_prop = pya.LayerProperties()
# lay_prop.source_name = lys.get_as_LayerInfo(dest_layer).name
# lay_prop.source_layer = lys.get_as_LayerInfo(dest_layer).layer
# lay_prop.source_datatype = lys.get_as_LayerInfo(dest_layer).datatype
# lv.init_layer_properties(lay_prop)
# lv.insert_layer(lv.end_layers(), lay_prop)
if clear_others:
for any_layer in lys.keys():
if any_layer not in kwargs.keys() and any_layer != 'FLOORPLAN':
Expand Down
32 changes: 25 additions & 7 deletions lymask/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def set_active_technology(tech_name):
raise ValueError('Technology not found. Available are {}'.format(Technology.technology_names()))
global _active_technology
_active_technology = Technology.technology_by_name(tech_name)
reload_lys(tech_name)
reload_lys(tech_name, clear=True)
# end deprecation


Expand Down Expand Up @@ -149,12 +149,13 @@ def fromFile(cls, filename):
return new_obj

def append(self, other, doubles_ok=False):
''' When doubles_ok is True and there is a collision, the other takes precedence '''
for layname in other.keys():
if layname in self.keys() and not doubles_ok:
raise ValueError('Layer is doubly defined: {}'.format(layname))
self[layname] = other.get_as_LayerInfo(layname)

def appendFile(self, filename):
def appendFile(self, filename, doubles_ok=False):
other = LayerSet.fromFile(filename)
other.active_layout = self.active_layout
self.append(other, doubles_ok=True)
Expand Down Expand Up @@ -184,10 +185,25 @@ def source2pyaLayerInfo(source_str):
return pya.LayerInfo(int(layer), int(datatype))


def insert_layer_tab(lyp_file=None, tab_name=None):
def load_dataprep_layers(technology=None):
''' Also updates lys, but if any of the layers are already there, it does nothing.
If lyp_file is None, creates an empty layer list or does nothing if not in GUI mode.
'''
if technology is None:
technology = active_technology()
reload_lys(technology, dataprep=True)
if isGUI():
lv = gui_view()
was_transacting = lv.is_transacting()
if was_transacting:
lv.commit()
lv.load_layer_props(tech_dataprep_layer_properties(technology))
if was_transacting:
lv.transaction('Bump transaction')
lv.current_layer_list = 0


def insert_layer_tab(lyp_file=None, tab_name=None):
if lyp_file is not None and lys is not None:
try:
lys.appendFile(lyp_file)
Expand All @@ -212,13 +228,15 @@ def insert_layer_tab(lyp_file=None, tab_name=None):


lys = LayerSet()
def reload_lys(technology=None):
lys.clear()
def reload_lys(technology=None, clear=False, dataprep=False):
if isinstance(technology, str):
technology = Technology.technology_by_name(technology)
try:
lyp_file = tech_layer_properties(Technology.technology_by_name(technology))
lys.appendFile(lyp_file)
lyp_file = tech_layer_properties(technology) if not dataprep else tech_dataprep_layer_properties(technology)
except (FileNotFoundError, AttributeError):
print('No lyp file found. Likely that technology hasn\'t loaded yet, or you don\'t have the standalone klayout')
if clear: lys.clear()
lys.appendFile(lyp_file, doubles_ok=True)


# reload_lys()
Expand Down

0 comments on commit 092ff50

Please sign in to comment.