From 07024386a19634c241995d87afa2fdbb528bd96a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 27 Mar 2010 20:13:28 -0400 Subject: [PATCH] Added virtual routes to template system to allow related islands --- pyrisk/graphics.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pyrisk/graphics.py b/pyrisk/graphics.py index 4a758cb..6ca4aa2 100644 --- a/pyrisk/graphics.py +++ b/pyrisk/graphics.py @@ -39,7 +39,7 @@ class TemplateLibrary (object): TODO: explain template data format. """ - def __init__(self, template_dir='/usr/share/pyrisk/templates/'): + def __init__(self, template_dir='share/templates/'): self.template_dir = os.path.abspath(os.path.expanduser(template_dir)) def get(self, name): region_pointlists,route_pointlists = self._get_pointlists(name) @@ -58,8 +58,9 @@ class TemplateLibrary (object): name,extension = filename.rsplit('.', 1) if extension == 'reg': region_pointlists[name] = self._read_file(path) - elif extension == 'rt': - route_pointlists[name] = self._read_file(path) + elif extension in ['rt', 'vrt']: + route_pointlists[name] = (self._read_file(path), + extension == 'vrt') return (region_pointlists, route_pointlists) def _read_file(self, filename): pointlist = [] @@ -85,11 +86,13 @@ class TemplateLibrary (object): all_boundaries, pointlist) regions.append(Region(name, boundaries, head_to_tail)) r = regions[-1] - for name,pointlist in route_pointlists.items(): + for name,v_pointlist in route_pointlists.items(): + pointlist,virtual = v_pointlist boundaries,head_to_tail = self._pointlist_to_array_of_boundaries( all_boundaries, pointlist) assert len(boundaries) == 1, boundaries route = boundaries[0] + route.virtual = virtual for terminal in [route[0], route[-1]]: for r in regions: for point in r.outline: @@ -299,7 +302,7 @@ class Region (ID_CmpMixin, list): self.starts.append(pos) for p in new: points.append(pos+p) - assert points[-1] == points[0], points + assert points[-1] == points[0], '%s: %s' % (self.name, points) self.outline = points def locate_routes(self): self.route_starts = [] @@ -359,7 +362,7 @@ class WorldRenderer (object): for p in r.outline[:-1]]) ]) for rt,rt_start in zip(r.routes, r.route_starts): - if id(rt) in drawn_rts: + if id(rt) in drawn_rts or rt.virtual == True: continue drawn_rts[id(rt)] = rt lines.extend([ -- 2.26.2