prefig 0.4.8__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {prefig-0.4.8 → prefig-0.5.1}/PKG-INFO +1 -1
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/annotations.py +8 -2
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/arrow.py +3 -3
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/axes.py +1 -1
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/clip.py +1 -1
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/diagram.py +23 -5
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/grid_axes.py +13 -6
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/legend.py +4 -4
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/line.py +92 -1
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/repeat.py +3 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/shape.py +12 -1
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/schema/pf_schema.rnc +3 -1
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/schema/pf_schema.rng +4 -0
- {prefig-0.4.8 → prefig-0.5.1}/pyproject.toml +1 -1
- {prefig-0.4.8 → prefig-0.5.1}/LICENSE +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/README.md +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/__init__.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/cli.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/CTM.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/__init__.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/area.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/calculus.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/circle.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/compat.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/coordinates.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/definition.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/diffeqs.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/graph.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/group.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/image.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/implicit.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/label.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/label_tools.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/math_utilities.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/network.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/parametric_curve.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/parse.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/path.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/point.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/polygon.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/read.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/rectangle.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/riemann_sum.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/slope_field.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/statistics.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/tags.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/tangent_line.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/user_namespace.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/utilities.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/core/vector.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/engine.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/diagcess/diagcess.html +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/diagcess/diagcess.js +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/examples/de-system.xml +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/examples/derivatives.xml +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/examples/diffeqs.xml +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/examples/implicit.xml +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/examples/projection.xml +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/examples/riemann.xml +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/examples/roots_of_unity.xml +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/examples/tangent.xml +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/fonts/Braille29.ttf +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/js/mj-sre-page.js +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/js/package.json +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/resources/template/pf_publication.xml +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/scripts/__init__.py +0 -0
- {prefig-0.4.8 → prefig-0.5.1}/prefig/scripts/install_mj.py +0 -0
|
@@ -33,14 +33,20 @@ def annotate(element, diagram, parent = None):
|
|
|
33
33
|
parent = diagram.get_annotations_root()
|
|
34
34
|
|
|
35
35
|
if element.get('ref', None) is not None:
|
|
36
|
-
|
|
36
|
+
ref = element.get('ref')
|
|
37
|
+
if not ref.startswith('pf__'):
|
|
38
|
+
ref = 'pf__' + ref
|
|
39
|
+
element.set('id', ref)
|
|
37
40
|
element.attrib.pop('ref')
|
|
38
41
|
else:
|
|
39
42
|
log.info(f"An annotation has an empty attribute ref")
|
|
40
43
|
element.attrib.pop('annotate', None)
|
|
41
44
|
|
|
42
45
|
# let's check to see if this is a reference to an annotation branch
|
|
43
|
-
|
|
46
|
+
id = element.get('id')
|
|
47
|
+
if not id.startswith('pf__'):
|
|
48
|
+
id = 'pf__' + id
|
|
49
|
+
annotation = diagram.get_annotation_branch(id)
|
|
44
50
|
if annotation is not None:
|
|
45
51
|
annotate(annotation, diagram, parent)
|
|
46
52
|
return
|
|
@@ -22,7 +22,7 @@ def add_tactile_arrowhead_marker(diagram, path, mid=False):
|
|
|
22
22
|
# get the stroke width from the graphical component
|
|
23
23
|
stroke_width_str = path.get('stroke-width', '1')
|
|
24
24
|
stroke_width = int(stroke_width_str)
|
|
25
|
-
id = '
|
|
25
|
+
id = 'pf__arrow-head-'+stroke_width_str
|
|
26
26
|
|
|
27
27
|
# if we've seen this already, there's no need to create it again
|
|
28
28
|
if diagram.has_reusable(id):
|
|
@@ -180,12 +180,12 @@ def add_arrowhead_marker(diagram,
|
|
|
180
180
|
# end or in the middle of a path
|
|
181
181
|
id_data = f"_{arrow_width}_{arrow_angles[0]}_{arrow_angles[1]}"
|
|
182
182
|
if not mid:
|
|
183
|
-
id = '
|
|
183
|
+
id = 'pf__arrow-head-end-'+stroke_width_str+id_data+'-'+stroke_color
|
|
184
184
|
if arrow_width is None:
|
|
185
185
|
arrow_width = 4
|
|
186
186
|
dims = (1, arrow_width)
|
|
187
187
|
else:
|
|
188
|
-
id = '
|
|
188
|
+
id = 'pf__arrow-head-mid-'+stroke_width_str+id_data+'-'+stroke_color
|
|
189
189
|
if arrow_width is None:
|
|
190
190
|
arrow_width = 13/3
|
|
191
191
|
dims = (1, arrow_width) #11/3)
|
|
@@ -60,7 +60,7 @@ class Diagram:
|
|
|
60
60
|
self.root = ET.Element("svg", nsmap = nsmap)
|
|
61
61
|
|
|
62
62
|
self.id_suffix = ['']
|
|
63
|
-
self.add_id(self.root, diagram_element.get('id', '
|
|
63
|
+
self.add_id(self.root, diagram_element.get('id', 'pf__figure'))
|
|
64
64
|
|
|
65
65
|
# prepare the XML tree for annotations, if there are any
|
|
66
66
|
self.annotations_root = None
|
|
@@ -79,6 +79,9 @@ class Diagram:
|
|
|
79
79
|
# a dictionary for holding shapes
|
|
80
80
|
self.shape_dict = {}
|
|
81
81
|
|
|
82
|
+
# dictionary for saving graphical data
|
|
83
|
+
self.saved_data = {}
|
|
84
|
+
|
|
82
85
|
# each SVG element will have an id, we'll store a count of ids here
|
|
83
86
|
self.ids = {}
|
|
84
87
|
|
|
@@ -192,9 +195,12 @@ class Diagram:
|
|
|
192
195
|
suffix = ''.join(self.id_suffix)
|
|
193
196
|
if id is None:
|
|
194
197
|
self.ids[element.tag] = self.ids.get(element.tag, -1) + 1
|
|
195
|
-
|
|
198
|
+
result_id = element.tag+'-'+str(self.ids[element.tag])+suffix
|
|
196
199
|
else:
|
|
197
|
-
|
|
200
|
+
result_id = id + suffix
|
|
201
|
+
if result_id.startswith('pf__'):
|
|
202
|
+
return result_id
|
|
203
|
+
return 'pf__' + result_id
|
|
198
204
|
|
|
199
205
|
def append_id_suffix(self, element):
|
|
200
206
|
return self.find_id(element, element.get('id', None))
|
|
@@ -235,6 +241,12 @@ class Diagram:
|
|
|
235
241
|
log.error(f"Unable to apply inverse coordinate transform to {p}")
|
|
236
242
|
return np.array([0,0])
|
|
237
243
|
|
|
244
|
+
def save_data(self, element, data):
|
|
245
|
+
self.saved_data[element] = data
|
|
246
|
+
|
|
247
|
+
def retrieve_data(self, element):
|
|
248
|
+
return self.saved_data.get(element, None)
|
|
249
|
+
|
|
238
250
|
def begin_figure(self):
|
|
239
251
|
# set up the dimensions of the diagram in SVG coordinates
|
|
240
252
|
dims = self.diagram_element.get('dimensions')
|
|
@@ -662,10 +674,16 @@ class Diagram:
|
|
|
662
674
|
|
|
663
675
|
def add_annotation_to_branch(self, annotation):
|
|
664
676
|
if len(self.annotation_branch_stack) == 0:
|
|
665
|
-
|
|
677
|
+
id = annotation.get('id')
|
|
678
|
+
if not id.startswith('pf__'):
|
|
679
|
+
id = 'pf__' + id
|
|
680
|
+
self.annotation_branches[id] = annotation
|
|
666
681
|
return
|
|
667
682
|
self.annotation_branch_stack[-1].append(annotation)
|
|
668
|
-
|
|
683
|
+
id = self.append_id_suffix(annotation)
|
|
684
|
+
if not id.startswith('pf__'):
|
|
685
|
+
id = 'pf__' + id
|
|
686
|
+
annotation.set('id', id)
|
|
669
687
|
|
|
670
688
|
def get_annotation_branch(self, id):
|
|
671
689
|
return self.annotation_branches.pop(id, None)
|
|
@@ -120,9 +120,14 @@ def grid(element, diagram, parent, outline_status):
|
|
|
120
120
|
|
|
121
121
|
thickness = element.get('thickness', '1')
|
|
122
122
|
stroke = element.get('stroke', r'#ccc')
|
|
123
|
+
id = element.get('id')
|
|
124
|
+
if id is None:
|
|
125
|
+
id = 'pf__grid'
|
|
126
|
+
if not id.startswith('pf__'):
|
|
127
|
+
id = 'pf__' + id
|
|
123
128
|
grid = ET.SubElement(parent, 'g',
|
|
124
129
|
attrib={
|
|
125
|
-
'id':
|
|
130
|
+
'id': id,
|
|
126
131
|
'stroke': stroke,
|
|
127
132
|
'stroke-width': thickness
|
|
128
133
|
}
|
|
@@ -251,12 +256,14 @@ def grid(element, diagram, parent, outline_status):
|
|
|
251
256
|
if x < bbox[0] or x > bbox[2]:
|
|
252
257
|
continue
|
|
253
258
|
line_el = line.mk_line((x,bbox[1]), (x,bbox[3]), diagram)
|
|
259
|
+
line_el.attrib.pop('id')
|
|
254
260
|
grid.append(line_el)
|
|
255
261
|
|
|
256
262
|
for y in y_positions:
|
|
257
263
|
if y < bbox[1] or y > bbox[3]:
|
|
258
264
|
continue
|
|
259
265
|
line_el = line.mk_line((bbox[0], y), (bbox[2], y), diagram)
|
|
266
|
+
line_el.attrib.pop('id')
|
|
260
267
|
grid.append(line_el)
|
|
261
268
|
|
|
262
269
|
|
|
@@ -266,27 +273,27 @@ def grid_axes(element, diagram, parent, outline_status):
|
|
|
266
273
|
group = ET.SubElement(parent, 'g',
|
|
267
274
|
attrib=
|
|
268
275
|
{
|
|
269
|
-
'id': '
|
|
276
|
+
'id': 'pf__grid-axes'
|
|
270
277
|
}
|
|
271
278
|
)
|
|
272
279
|
|
|
273
280
|
group_annotation = ET.Element('annotation')
|
|
274
|
-
group_annotation.set('ref', '
|
|
281
|
+
group_annotation.set('ref', 'pf__grid-axes')
|
|
275
282
|
group_annotation.set('text', 'The coordinate grid and axes')
|
|
276
283
|
diagram. add_default_annotation(group_annotation)
|
|
277
284
|
|
|
278
285
|
grid(element, diagram, group, outline_status)
|
|
279
286
|
|
|
280
287
|
annotation = ET.Element('annotation')
|
|
281
|
-
annotation.set('ref', '
|
|
288
|
+
annotation.set('ref', 'pf__grid')
|
|
282
289
|
annotation.set('text', 'The coordinate grid')
|
|
283
290
|
group_annotation.append(annotation)
|
|
284
291
|
|
|
285
|
-
element.set('id', '
|
|
292
|
+
element.set('id', 'pf__axes')
|
|
286
293
|
axes.axes(element, diagram, group, outline_status)
|
|
287
294
|
|
|
288
295
|
annotation = ET.Element('annotation')
|
|
289
|
-
annotation.set('ref', '
|
|
296
|
+
annotation.set('ref', 'pf__axes')
|
|
290
297
|
annotation.set('text', 'The coordinate axes')
|
|
291
298
|
group_annotation.append(annotation)
|
|
292
299
|
|
|
@@ -64,7 +64,7 @@ class Legend:
|
|
|
64
64
|
# first we'll create the label
|
|
65
65
|
label_el = copy.deepcopy(li)
|
|
66
66
|
label_el.tag = 'label'
|
|
67
|
-
label_el.set('id', f"
|
|
67
|
+
label_el.set('id', f"pf__legend-label-{num}")
|
|
68
68
|
label_el.set('alignment', 'se')
|
|
69
69
|
label_el.set('anchor', element.get('anchor', anchor_str))
|
|
70
70
|
label_el.set('abs-offset', '(0,0)')
|
|
@@ -87,7 +87,7 @@ class Legend:
|
|
|
87
87
|
key = copy.deepcopy(key)
|
|
88
88
|
key.set('p', anchor_str)
|
|
89
89
|
key.set('size', '4')
|
|
90
|
-
key.set('id', f"
|
|
90
|
+
key.set('id', f"pf__legend-point-{num}")
|
|
91
91
|
key_width = max(key_width, point_width)
|
|
92
92
|
else:
|
|
93
93
|
fill = key.get('fill')
|
|
@@ -219,11 +219,11 @@ class Legend:
|
|
|
219
219
|
id = group.get('id', 'none')
|
|
220
220
|
if id == 'background-group':
|
|
221
221
|
for rectangle in group:
|
|
222
|
-
if rectangle.get('id', 'none').startswith('
|
|
222
|
+
if rectangle.get('id', 'none').startswith('pf__legend-label'):
|
|
223
223
|
group.remove(rectangle)
|
|
224
224
|
if id == 'braille-group':
|
|
225
225
|
for label in group:
|
|
226
|
-
if label.get('id','none').startswith('
|
|
226
|
+
if label.get('id','none').startswith('pf__legend-label'):
|
|
227
227
|
label_groups.append(label)
|
|
228
228
|
group.remove(label)
|
|
229
229
|
|
|
@@ -5,7 +5,11 @@ import logging
|
|
|
5
5
|
from . import utilities as util
|
|
6
6
|
from . import math_utilities as math_util
|
|
7
7
|
from . import user_namespace as un
|
|
8
|
+
import copy
|
|
8
9
|
from . import arrow
|
|
10
|
+
from . import group
|
|
11
|
+
from . import label
|
|
12
|
+
from . import CTM
|
|
9
13
|
|
|
10
14
|
log = logging.getLogger('prefigure')
|
|
11
15
|
|
|
@@ -50,12 +54,24 @@ def line(element, diagram, parent, outline_status):
|
|
|
50
54
|
|
|
51
55
|
line = mk_line(p1, p2, diagram, element.get('id', None),
|
|
52
56
|
endpoint_offsets=endpoint_offsets)
|
|
57
|
+
|
|
58
|
+
# we need to hold on to the endpoints in case the line is labelled
|
|
59
|
+
# these are endpoints in SVG coordinates
|
|
60
|
+
x1 = float(line.get('x1'))
|
|
61
|
+
x2 = float(line.get('x2'))
|
|
62
|
+
y1 = float(line.get('y1'))
|
|
63
|
+
y2 = float(line.get('y2'))
|
|
64
|
+
|
|
65
|
+
q1 = np.array((x1, y1))
|
|
66
|
+
q2 = np.array((x2, y2))
|
|
67
|
+
diagram.save_data(element, {'q1': q1, 'q2': q2})
|
|
68
|
+
|
|
69
|
+
# now add the graphical attributes
|
|
53
70
|
util.set_attr(element, 'stroke', 'black')
|
|
54
71
|
util.set_attr(element, 'thickness', '2')
|
|
55
72
|
if diagram.output_format() == 'tactile':
|
|
56
73
|
element.set('stroke', 'black')
|
|
57
74
|
util.add_attr(line, util.get_1d_attr(element))
|
|
58
|
-
# line.set('type', 'line')
|
|
59
75
|
|
|
60
76
|
arrows = int(element.get('arrows', '0'))
|
|
61
77
|
forward = 'marker-end'
|
|
@@ -113,15 +129,38 @@ def line(element, diagram, parent, outline_status):
|
|
|
113
129
|
diagram.add_outline(element, line, parent)
|
|
114
130
|
finish_outline(element, diagram, parent)
|
|
115
131
|
else:
|
|
132
|
+
original_parent = parent
|
|
133
|
+
parent = add_label(element, diagram, parent)
|
|
116
134
|
parent.append(line)
|
|
117
135
|
|
|
136
|
+
# if no label has been added, then we're done
|
|
137
|
+
if original_parent == parent:
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
# if there is a label, then the id is on the outer <g> element
|
|
141
|
+
# so we need to remove it from the children
|
|
142
|
+
remove_id(parent)
|
|
143
|
+
|
|
118
144
|
def finish_outline(element, diagram, parent):
|
|
145
|
+
original_parent = parent
|
|
146
|
+
parent = add_label(element, diagram, parent)
|
|
147
|
+
|
|
148
|
+
# if we've added a label, remove the id's from element under the parent <g>
|
|
149
|
+
if original_parent != parent:
|
|
150
|
+
remove_id(parent)
|
|
151
|
+
|
|
119
152
|
diagram.finish_outline(element,
|
|
120
153
|
element.get('stroke'),
|
|
121
154
|
element.get('thickness'),
|
|
122
155
|
element.get('fill', 'none'),
|
|
123
156
|
parent)
|
|
124
157
|
|
|
158
|
+
def remove_id(el):
|
|
159
|
+
for child in el:
|
|
160
|
+
if child.get('id', None) is not None:
|
|
161
|
+
child.attrib.pop('id')
|
|
162
|
+
remove_id(child)
|
|
163
|
+
|
|
125
164
|
# We'll be adding lines in other places so we'll use this more widely
|
|
126
165
|
def mk_line(p0, p1, diagram, id = None, endpoint_offsets = None, user_coords = True):
|
|
127
166
|
line = ET.Element('line')
|
|
@@ -176,3 +215,55 @@ def infinite_line(p0, p1, diagram, slope = None):
|
|
|
176
215
|
if t_min > t_max:
|
|
177
216
|
return None, None
|
|
178
217
|
return [p + t * v for t in [t_min, t_max]]
|
|
218
|
+
|
|
219
|
+
def add_label(element, diagram, parent):
|
|
220
|
+
# Is there a label associated with point?
|
|
221
|
+
text = element.text
|
|
222
|
+
|
|
223
|
+
# is there a label here?
|
|
224
|
+
has_text = text is not None and len(text.strip()) > 0
|
|
225
|
+
all_comments = all([subel.tag is ET.Comment for subel in element])
|
|
226
|
+
if has_text or not all_comments:
|
|
227
|
+
# If there's a label, we'll bundle the label and point in a group
|
|
228
|
+
parent_group = ET.SubElement(parent, 'g')
|
|
229
|
+
diagram.add_id(parent_group, element.get('id'))
|
|
230
|
+
|
|
231
|
+
# Now we'll create a new XML element describing the label
|
|
232
|
+
el = copy.deepcopy(element)
|
|
233
|
+
el.tag = 'label'
|
|
234
|
+
|
|
235
|
+
data = diagram.retrieve_data(element)
|
|
236
|
+
q1 = data['q1']
|
|
237
|
+
q2 = data['q2']
|
|
238
|
+
|
|
239
|
+
label_location = un.valid_eval(element.get("label-location", "0.5"))
|
|
240
|
+
if label_location < 0:
|
|
241
|
+
label_location = -label_location
|
|
242
|
+
q1, q2 = q2, q1
|
|
243
|
+
|
|
244
|
+
el.set('user-coords', 'no')
|
|
245
|
+
diff = q2 - q1
|
|
246
|
+
d = math_util.length(diff)
|
|
247
|
+
angle = math.degrees(math.atan2(diff[1], diff[0]))
|
|
248
|
+
if diagram.output_format() == "tactile":
|
|
249
|
+
anchor = q1 + label_location * diff
|
|
250
|
+
el.set("anchor", f"({anchor[0]}, {anchor[1]})")
|
|
251
|
+
direction = (diff[1], diff[0])
|
|
252
|
+
alignment = label.get_alignment_from_direction(direction)
|
|
253
|
+
el.set("alignment", alignment)
|
|
254
|
+
label.label(el, diagram, parent_group)
|
|
255
|
+
else:
|
|
256
|
+
tform = CTM.translatestr(*q1)
|
|
257
|
+
tform += ' ' + CTM.rotatestr(-angle)
|
|
258
|
+
distance = d * label_location
|
|
259
|
+
g = ET.SubElement(parent_group, "g")
|
|
260
|
+
g.set("transform", tform)
|
|
261
|
+
el.set("anchor", f"({distance},0)")
|
|
262
|
+
el.set("alignment", "north")
|
|
263
|
+
label.label(el, diagram, g)
|
|
264
|
+
|
|
265
|
+
return parent_group
|
|
266
|
+
|
|
267
|
+
else:
|
|
268
|
+
return parent
|
|
269
|
+
|
|
@@ -55,12 +55,15 @@ def repeat(element, diagram, parent, outline_status):
|
|
|
55
55
|
element_cp = copy.deepcopy(element)
|
|
56
56
|
outline = element.get('outline')
|
|
57
57
|
id = element.get('id')
|
|
58
|
+
if not id.startswith('pf__'):
|
|
59
|
+
id = 'pf__' + id
|
|
58
60
|
element.clear()
|
|
59
61
|
element.tag = 'group'
|
|
60
62
|
if outline is not None:
|
|
61
63
|
element.set('outline', outline)
|
|
62
64
|
if id is not None:
|
|
63
65
|
element.set('id', id)
|
|
66
|
+
element_cp.set('id', id)
|
|
64
67
|
|
|
65
68
|
for num, k in enumerate(iterator):
|
|
66
69
|
if isinstance(k, np.ndarray):
|
|
@@ -36,7 +36,10 @@ def define(element, diagram, parent, outline_status):
|
|
|
36
36
|
log.error(f"In <define-shapes>, {child.tag} does not define a shape")
|
|
37
37
|
continue
|
|
38
38
|
if child.get('at', None) is not None:
|
|
39
|
-
|
|
39
|
+
id = child.get('at')
|
|
40
|
+
if not id.startswith('pf__'):
|
|
41
|
+
id = 'pf__' + id
|
|
42
|
+
child.set('id', id)
|
|
40
43
|
dummy_parent = ET.Element('group')
|
|
41
44
|
# this is kind of a hack, but we only need to construct the shape
|
|
42
45
|
# so we stash the format temporarily in case we're building a
|
|
@@ -69,6 +72,12 @@ def shape(element, diagram, parent, outline_status):
|
|
|
69
72
|
return
|
|
70
73
|
|
|
71
74
|
shape_refs = [r.strip() for r in reference.split(',')]
|
|
75
|
+
shape_edit = []
|
|
76
|
+
for shape_ref in shape_refs:
|
|
77
|
+
if not shape_ref.startswith('pf__'):
|
|
78
|
+
shape_ref = 'pf__' + shape_ref
|
|
79
|
+
shape_edit.append(shape_ref)
|
|
80
|
+
shape_refs = shape_edit
|
|
72
81
|
shapes = []
|
|
73
82
|
for ref in shape_refs:
|
|
74
83
|
shapes.append(diagram.recall_shape(ref))
|
|
@@ -82,6 +91,8 @@ def shape(element, diagram, parent, outline_status):
|
|
|
82
91
|
operation = 'union'
|
|
83
92
|
else:
|
|
84
93
|
path = ET.SubElement(parent, 'use')
|
|
94
|
+
if not reference.startswith('pf__'):
|
|
95
|
+
reference = 'pf__' + reference
|
|
85
96
|
path.set('href', r'#' + reference)
|
|
86
97
|
|
|
87
98
|
if operation is not None:
|
|
@@ -584,7 +584,9 @@ Line = element line {
|
|
|
584
584
|
attribute reverse {"yes"|"no"}?,
|
|
585
585
|
attribute additional-arrows {"yes"|"no"}?,
|
|
586
586
|
StrokeAttributes,
|
|
587
|
-
CommonAttributes
|
|
587
|
+
CommonAttributes,
|
|
588
|
+
LabelAttributes,
|
|
589
|
+
LabelText?
|
|
588
590
|
}
|
|
589
591
|
|
|
590
592
|
Network = element network {
|
|
@@ -1613,6 +1613,10 @@
|
|
|
1613
1613
|
</optional>
|
|
1614
1614
|
<ref name="StrokeAttributes"/>
|
|
1615
1615
|
<ref name="CommonAttributes"/>
|
|
1616
|
+
<ref name="LabelAttributes"/>
|
|
1617
|
+
<optional>
|
|
1618
|
+
<ref name="LabelText"/>
|
|
1619
|
+
</optional>
|
|
1616
1620
|
</element>
|
|
1617
1621
|
</define>
|
|
1618
1622
|
<define name="Network">
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|