Merge lp:~boegholm/pyuppaal/nicelayout into lp:pyuppaal

Proposed by Thomas Bøgholm
Status: Merged
Merged at revision: 97
Proposed branch: lp:~boegholm/pyuppaal/nicelayout
Merge into: lp:pyuppaal
Diff against target: 66 lines (+11/-5)
2 files modified
bin/layout_uppaal (+3/-1)
pyuppaal/pyuppaal.py (+8/-4)
To merge this branch: bzr merge lp:~boegholm/pyuppaal/nicelayout
Reviewer Review Type Date Requested Status
pyuppaal developers Pending
Review via email: mp+60899@code.launchpad.net

Description of the change

added arguments and modified Template/Transition functions

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/layout_uppaal'
2--- bin/layout_uppaal 2011-05-10 11:53:58 +0000
3+++ bin/layout_uppaal 2011-05-13 11:02:27 +0000
4@@ -5,6 +5,8 @@
5 parser = argparse.ArgumentParser(description='layout_uppaal')
6 parser.add_argument('--templates', '-T', action='store', type=lambda x: x.split(','), dest='templates', help='Set template list: template_1,...,template_n', default=[])
7 parser.add_argument('--template', '-t', action='append', default=[], dest='templates', help='Append to template list')
8+parser.add_argument('--nail-angle', '-a', action='store', type=float, help='Transition-sharpening parameter: angle threshold. Default: 110.0', default=110.0, dest='nailangle')
9+parser.add_argument('--nail-inter-distance', '-d', action='store', help='Transition-sharpening parameter: inter-nail-distance threshold. Default: 1.0', default=1.0, dest='nailinterdistance', type=float)
10 parser.add_argument('infile', type=argparse.FileType('r'), help='input file or \'-\' for stdin')
11 parser.add_argument('outfile', type=argparse.FileType('w'), help='output file or \'-\' for stdout')
12 parser.add_argument('--version', action='version', version='%(prog)s 1.1')
13@@ -16,7 +18,7 @@
14 for template in nta.templates:
15 if template.name in result.templates or not result.templates:
16 print >> sys.stderr,'updating template: ', template.name
17- template.layout(auto_nails=True)
18+ template.layout(auto_nails=True, nailAngleThreshold=result.nailangle, nailInterDistanceThreshold=result.nailinterdistance)
19
20 result.outfile.write(nta.to_xml())
21
22
23=== modified file 'pyuppaal/pyuppaal.py'
24--- pyuppaal/pyuppaal.py 2011-05-13 08:36:05 +0000
25+++ pyuppaal/pyuppaal.py 2011-05-13 11:02:27 +0000
26@@ -79,8 +79,12 @@
27
28 def dot2uppaalcoord(self, coord):
29 return int(-float(coord)*1.5)
30+
31+ def sharpenTransitions(self, nailAngleThreshold, nailInterDistanceThreshold):
32+ for transition in self.transitions:
33+ transition.sharpen(nailAngleThreshold, nailInterDistanceThreshold)
34
35- def layout(self, auto_nails=False):
36+ def layout(self, auto_nails=False, nailAngleThreshold=110.0, nailInterDistanceThreshold=1.0):
37 self.assign_ids()
38
39 G = pygraphviz.AGraph(strict=False)
40@@ -125,7 +129,6 @@
41 for nailpos in edge.attr['pos'].split(" "):
42 xpos, ypos = map(self.dot2uppaalcoord, nailpos.split(","))
43 t.nails += [Nail(xpos, ypos)]
44- t.sharpen()
45 ydelta = 0
46 for a in ['select', 'guard', 'synchronisation', 'assignment']:
47 label = getattr(t, a)
48@@ -134,7 +137,8 @@
49 label.xpos = x
50 label.ypos = y+ydelta
51 ydelta += UPPAAL_LINEHEIGHT
52-
53+ self.sharpenTransitions(nailAngleThreshold, nailInterDistanceThreshold)
54+
55
56 def _parameter_to_xml(self):
57 if self.parameter:
58@@ -275,7 +279,7 @@
59 assignment=self.assignment.value)
60 return newone
61
62- def sharpen(self, angleThreshold=110.0, lengthThreshold=1.0):
63+ def sharpen(self, angleThreshold, lengthThreshold):
64 count = 0
65 while True: # do while?
66 removed = False

Subscribers

People subscribed via source and target branches