author | Edouard Tisserant |
Fri, 21 Oct 2022 10:39:43 +0200 | |
changeset 3648 | ff42600fddd7 |
parent 3625 | bb1eff4091ab |
child 3690 | f41733be17a8 |
permissions | -rw-r--r-- |
2878 | 1 |
// inline_svg.ysl2 |
2 |
// |
|
3 |
// Produce Inline SVG element of resulting XHTML page. |
|
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2763
diff
changeset
|
4 |
|
2937
9226a830fbc3
SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2909
diff
changeset
|
5 |
// Since stylesheet output namespace is xhtml, templates that output svg have to be explicitely declared as such |
9226a830fbc3
SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2909
diff
changeset
|
6 |
in xsl decl svgtmpl(match, xmlns="http://www.w3.org/2000/svg") alias template; |
9226a830fbc3
SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2909
diff
changeset
|
7 |
in xsl decl svgfunc(name, xmlns="http://www.w3.org/2000/svg") alias template; |
9226a830fbc3
SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2909
diff
changeset
|
8 |
|
9226a830fbc3
SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2909
diff
changeset
|
9 |
|
2878 | 10 |
// Identity template : |
11 |
// - copy every attributes |
|
12 |
// - copy every sub-elements |
|
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
13 |
|
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
14 |
svgtmpl "@*", mode="inline_svg" xsl:copy; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
15 |
|
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
16 |
template "node()", mode="inline_svg" { |
2878 | 17 |
// use real xsl:copy instead copy-of alias from yslt.yml2 |
18 |
if "not(@id = $discardable_elements/@id)" |
|
19 |
xsl:copy apply "@* | node()", mode="inline_svg"; |
|
20 |
} |
|
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
21 |
|
2878 | 22 |
// replaces inkscape's height and width hints. forces fit |
23 |
template "svg:svg/@width", mode="inline_svg"; |
|
24 |
template "svg:svg/@height", mode="inline_svg"; |
|
25 |
svgtmpl "svg:svg", mode="inline_svg" svg { |
|
26 |
attrib "preserveAspectRatio" > none |
|
27 |
attrib "height" > 100vh |
|
28 |
attrib "width" > 100vw |
|
29 |
apply "@* | node()", mode="inline_svg"; |
|
30 |
} |
|
31 |
// ensure that coordinate in CSV file generated by inkscape are in default reference frame |
|
32 |
template "svg:svg[@viewBox!=concat('0 0 ', @width, ' ', @height)]", mode="inline_svg" { |
|
33 |
error > ViewBox settings other than X=0, Y=0 and Scale=1 are not supported |
|
34 |
} |
|
35 |
// ensure that coordinate in CSV file generated by inkscape match svg default unit |
|
36 |
template "sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']", mode="inline_svg" { |
|
37 |
error > All units must be set to "px" in Inkscape's document properties |
|
38 |
} |
|
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
39 |
|
3108
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3030
diff
changeset
|
40 |
// remove i18n markers, so that defs_by_labels can find text elements |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3030
diff
changeset
|
41 |
svgtmpl "svg:text/@inkscape:label[starts-with(., '_')]", mode="inline_svg" { |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3030
diff
changeset
|
42 |
attrib "{name()}" > «substring(., 2)» |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3030
diff
changeset
|
43 |
} |
079419e7228d
SVGHMI: Intermediate commit while implementing i18n. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3030
diff
changeset
|
44 |
|
3625
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
45 |
// remove "reference" and "frame" rectangles |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
46 |
svgtmpl "svg:rect[@inkscape:label='reference' or @inkscape:label='frame']", mode="inline_svg" { |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
47 |
// nothing |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
48 |
} |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
49 |
|
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
50 |
svgtmpl "svg:g[svg:rect/@inkscape:label='frame']", mode="inline_svg" { |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
51 |
const "reference_rect","(../svg:rect | ../svg:g/svg:rect)[@inkscape:label='reference']"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
52 |
const "frame_rect","svg:rect[@inkscape:label='frame']"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
53 |
const "offset","func:offset($frame_rect, $reference_rect)"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
54 |
|
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
55 |
xsl:copy { |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
56 |
attrib "svghmi_x_offset" value "$offset/vector/@x"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
57 |
attrib "svghmi_y_offset" value "$offset/vector/@y"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
58 |
apply "@* | node()", mode="inline_svg"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
59 |
} |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
60 |
} |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3393
diff
changeset
|
61 |
|
2941
ef13a4007538
SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
62 |
////// Clone unlinking |
ef13a4007538
SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
63 |
// |
2878 | 64 |
// svg:use (inkscape's clones) inside a widgets are |
65 |
// replaced by real elements they refer in order to : |
|
66 |
// - allow finding "needle" element in "meter" widget, |
|
67 |
// even if "needle" is in a group refered by a svg use. |
|
68 |
// - if "needle" is visible through a svg:use for |
|
69 |
// each instance of the widget, then needle would show |
|
70 |
// the same position in all instances |
|
71 |
// |
|
72 |
// For now, clone unlinkink applies to descendants of all widget except HMI:Page |
|
73 |
// TODO: narrow application of clone unlinking to active elements, |
|
74 |
// while keeping static decoration cloned |
|
3027
d660b1b6bf4f
SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2995
diff
changeset
|
75 |
const "targets_not_to_unlink", "$hmi_lists/descendant-or-self::svg:*"; |
3384
bd337d21f686
SVGHMI: changes that should fix some corner cases about unlinking and discardable element that still didn't show until now.
Edouard Tisserant
parents:
3186
diff
changeset
|
76 |
const "to_unlink", "$hmi_widgets/descendant-or-self::svg:use"; |
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
77 |
|
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
78 |
def "func:is_unlinkable" { |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
79 |
param "targetid"; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
80 |
param "eltid"; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
81 |
result "$eltid = $to_unlink/@id and not($targetid = $targets_not_to_unlink/@id)"; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
82 |
} |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
83 |
|
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
84 |
svgtmpl "svg:use", mode="inline_svg"{ |
2995
7769e7c7f925
SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2968
diff
changeset
|
85 |
const "targetid","substring-after(@xlink:href,'#')"; |
2878 | 86 |
choose { |
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
87 |
when "func:is_unlinkable($targetid, @id)" { |
3027
d660b1b6bf4f
SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2995
diff
changeset
|
88 |
call "unlink_clone" { |
d660b1b6bf4f
SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2995
diff
changeset
|
89 |
with "targetid", "$targetid"; |
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
90 |
} |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
91 |
} |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
92 |
otherwise xsl:copy apply "@*", mode="inline_svg"; |
2878 | 93 |
} |
94 |
} |
|
2877
682bce953795
SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents:
2876
diff
changeset
|
95 |
|
2878 | 96 |
// to unlink a clone, an group containing a copy of target element is created |
97 |
// that way, style and transforms can be preserved |
|
98 |
const "_excluded_use_attrs" { |
|
99 |
name > href |
|
100 |
name > width |
|
101 |
name > height |
|
102 |
name > x |
|
103 |
name > y |
|
3027
d660b1b6bf4f
SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2995
diff
changeset
|
104 |
name > id |
2878 | 105 |
} |
106 |
const "excluded_use_attrs","exsl:node-set($_excluded_use_attrs)"; |
|
2794
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
107 |
|
2968
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
108 |
const "_merge_use_attrs" { |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
109 |
name > transform |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
110 |
name > style |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
111 |
} |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
112 |
const "merge_use_attrs","exsl:node-set($_merge_use_attrs)"; |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
113 |
|
2878 | 114 |
svgfunc "unlink_clone"{ |
2995
7769e7c7f925
SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2968
diff
changeset
|
115 |
param "targetid"; |
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
116 |
param "seed","''"; |
2968
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
117 |
const "target", "//svg:*[@id = $targetid]"; |
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
118 |
const "seeded_id" choose { |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
119 |
when "string-length($seed) > 0" > «$seed»_«@id» |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
120 |
otherwise value "@id"; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
121 |
} |
2878 | 122 |
g{ |
3027
d660b1b6bf4f
SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2995
diff
changeset
|
123 |
attrib "id" value "$seeded_id"; |
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
124 |
attrib "original" value "@id"; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
125 |
|
2968
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
126 |
choose { |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
127 |
when "$target[self::svg:g]" { |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
128 |
foreach "@*[not(local-name() = $excluded_use_attrs/name | $merge_use_attrs)]" |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
129 |
attrib "{name()}" > «.» |
2853 | 130 |
|
2968
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
131 |
if "@style | $target/@style" |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
132 |
attrib "style" { |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
133 |
> «@style» |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
134 |
if "@style and $target/@style" > ; |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
135 |
> «$target/@style» |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
136 |
} |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
137 |
|
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
138 |
if "@transform | $target/@transform" |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
139 |
attrib "transform" { |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
140 |
> «@transform» |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
141 |
if "@transform and $target/@transform" > |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
142 |
> «$target/@transform» |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
143 |
} |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
144 |
|
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
145 |
apply "$target/*", mode="unlink_clone"{ |
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
146 |
with "seed","$seeded_id"; |
2968
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
147 |
} |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
148 |
} |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
149 |
otherwise { |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
150 |
// include non excluded attributes |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
151 |
foreach "@*[not(local-name() = $excluded_use_attrs/name)]" |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
152 |
attrib "{name()}" > «.» |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
153 |
|
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
154 |
apply "$target", mode="unlink_clone"{ |
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
155 |
with "seed","$seeded_id"; |
2968
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
156 |
} |
556ef07a7e31
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents:
2967
diff
changeset
|
157 |
} |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
158 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
159 |
} |
2878 | 160 |
} |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
161 |
|
2878 | 162 |
// clone unlinking is really similar to deep-copy |
163 |
// all nodes are sytematically copied |
|
164 |
svgtmpl "@id", mode="unlink_clone" { |
|
165 |
param "seed"; |
|
166 |
attrib "id" > «$seed»_«.» |
|
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
167 |
attrib "original" > «.» |
2878 | 168 |
} |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
169 |
|
2878 | 170 |
svgtmpl "@*", mode="unlink_clone" xsl:copy; |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
171 |
|
3027
d660b1b6bf4f
SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2995
diff
changeset
|
172 |
svgtmpl "svg:use", mode="unlink_clone" { |
d660b1b6bf4f
SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2995
diff
changeset
|
173 |
param "seed"; |
3030
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
174 |
const "targetid","substring-after(@xlink:href,'#')"; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
175 |
choose { |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
176 |
when "func:is_unlinkable($targetid, @id)" { |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
177 |
call "unlink_clone" { |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
178 |
with "targetid", "$targetid"; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
179 |
with "seed","$seed"; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
180 |
} |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
181 |
} |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
182 |
otherwise xsl:copy apply "@*", mode="unlink_clone" { |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
183 |
with "seed","$seed"; |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
184 |
} |
2d13a4379e2f
SVGHMI: Fix again clone unlinking, and this time add an "original" attribute to track the id of the original object before unlinking.
Edouard Tisserant
parents:
3027
diff
changeset
|
185 |
} |
3027
d660b1b6bf4f
SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2995
diff
changeset
|
186 |
} |
d660b1b6bf4f
SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2995
diff
changeset
|
187 |
|
2878 | 188 |
// copying widgets would have unwanted effect |
189 |
// instead widget is refered through a svg:use. |
|
190 |
svgtmpl "svg:*", mode="unlink_clone" { |
|
191 |
param "seed"; |
|
192 |
choose { |
|
193 |
// node recursive copy ends when finding a widget |
|
3393
a65bcbb6af20
SVGHMI: more accurate filtering of elements to unlink or not
Edouard Tisserant
parents:
3384
diff
changeset
|
194 |
when "@id = $hmi_widgets/@id" { |
2878 | 195 |
// place a clone instead of copying |
196 |
use{ |
|
197 |
attrib "xlink:href" > «concat('#',@id)» |
|
198 |
} |
|
199 |
} |
|
200 |
otherwise { |
|
201 |
xsl:copy apply "@* | node()", mode="unlink_clone" { |
|
202 |
with "seed","$seed"; |
|
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
203 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
204 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
205 |
} |
2878 | 206 |
} |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
207 |
|
2878 | 208 |
const "result_svg" apply "/", mode="inline_svg"; |
209 |
const "result_svg_ns", "exsl:node-set($result_svg)"; |
|
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
210 |
|
2941
ef13a4007538
SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
211 |
emit "preamble:inline-svg" { |
ef13a4007538
SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
212 |
| let id = document.getElementById.bind(document); |
ef13a4007538
SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
213 |
| var svg_root = id("«$svg/@id»"); |
ef13a4007538
SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
214 |
} |
ef13a4007538
SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
215 |
|
ef13a4007538
SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
216 |
emit "debug:clone-unlinking" { |
ef13a4007538
SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
217 |
| |
2904
92d115d8828d
SVGHMI: collect debug data through xslt reflectivity instead of yml2/python trick
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2878
diff
changeset
|
218 |
| Unlinked : |
2878 | 219 |
foreach "$to_unlink"{ |
220 |
| «@id» |
|
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
221 |
} |
2995
7769e7c7f925
SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2968
diff
changeset
|
222 |
| Not to unlink : |
7769e7c7f925
SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2968
diff
changeset
|
223 |
foreach "$targets_not_to_unlink"{ |
7769e7c7f925
SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2968
diff
changeset
|
224 |
| «@id» |
7769e7c7f925
SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2968
diff
changeset
|
225 |
} |
2753
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
226 |
} |