author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Fri, 06 Mar 2020 09:35:08 +0100 | |
branch | svghmi |
changeset 2859 | 517583e21bfd |
parent 2858 | 39c8d6079f0f |
child 2861 | 84c16ece8e10 |
permissions | -rw-r--r-- |
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
|
1 |
include yslt_noindent.yml2 |
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
|
2 |
|
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
|
3 |
// overrides yslt's output function to set CDATA |
2798
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
4 |
decl output(method, cdata-section-elements="xhtml:script"); |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
5 |
|
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
|
6 |
in xsl decl labels(*ptr, name="defs_by_labels") alias call-template { |
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
|
7 |
with "hmi_element", "$hmi_element"; |
2810
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
8 |
with "labels"{text *ptr}; |
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
|
9 |
}; |
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
|
10 |
|
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
11 |
in xsl decl optional_labels(*ptr, name="defs_by_labels") alias call-template { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
12 |
with "hmi_element", "$hmi_element"; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
13 |
with "labels"{text *ptr}; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
14 |
with "mandatory","'no'"; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
15 |
}; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
16 |
|
2840
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
17 |
in xsl decl svgtmpl(match, xmlns="http://www.w3.org/2000/svg") alias template; |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
18 |
in xsl decl svgfunc(name, xmlns="http://www.w3.org/2000/svg") alias template; |
2840
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
19 |
|
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
20 |
istylesheet |
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
|
21 |
/* From Inkscape */ |
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
|
22 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
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
|
23 |
xmlns:cc="http://creativecommons.org/ns#" |
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
|
24 |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
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
|
25 |
xmlns:svg="http://www.w3.org/2000/svg" |
2838
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
26 |
xmlns:xlink="http://www.w3.org/1999/xlink" |
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
|
27 |
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
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
|
28 |
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
2798
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
29 |
xmlns:xhtml="http://www.w3.org/1999/xhtml" |
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
|
30 |
|
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
|
31 |
/* Our namespace to invoke python code */ |
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
|
32 |
xmlns:ns="beremiz" |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
33 |
extension-element-prefixes="ns func exsl regexp str dyn" |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
34 |
exclude-result-prefixes="ns str regexp exsl func dyn" { |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
35 |
|
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
36 |
/* This retrieves geometry obtained through "inkscape -S" |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
37 |
* already parsed by python and presented as a list of |
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
|
38 |
* <bbox x="0" y="0" w="42" h="42"> |
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
|
39 |
*/ |
2791
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
40 |
const "geometry", "ns:GetSVGGeometry()"; |
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
41 |
const "hmitree", "ns:GetHMITree()"; |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
42 |
|
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
|
43 |
const "svg_root_id", "/svg:svg/@id"; |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
44 |
const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]"; |
2794
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
45 |
const "hmi_geometry", "$geometry[@Id = $hmi_elements/@id]"; |
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
46 |
|
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
47 |
const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"; |
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
48 |
|
2795 | 49 |
const "default_page" choose { |
50 |
when "count($hmi_pages) > 1" { |
|
51 |
const "Home_page", |
|
52 |
"$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']"; |
|
53 |
choose { |
|
54 |
when "$Home_page" > Home |
|
55 |
otherwise { |
|
56 |
error "No Home page defined!"; |
|
57 |
} |
|
58 |
} |
|
59 |
} |
|
60 |
when "count($hmi_pages) = 0" { |
|
61 |
error "No page defined!"; |
|
62 |
} |
|
63 |
otherwise > «func:parselabel($hmi_pages/@inkscape:label)/widget/arg[1]/@value» |
|
64 |
} |
|
65 |
||
2791
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
66 |
const "_categories" { |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
67 |
noindex > HMI_ROOT |
2814
2cabc4773885
SVGHMI: HMI_LABEL and HMI_CLASS become HMI_NODE.
Edouard Tisserant
parents:
2810
diff
changeset
|
68 |
noindex > HMI_NODE |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
69 |
noindex > HMI_PLC_STATUS |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
70 |
noindex > HMI_CURRENT_PAGE |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
71 |
} |
2791
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
72 |
const "categories", "exsl:node-set($_categories)"; |
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
73 |
const "_indexed_hmitree" apply "$hmitree", mode="index"; |
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
74 |
const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)"; |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
75 |
|
2843
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
76 |
|
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
77 |
// returns all directly or indirectly refered elements |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
78 |
def "func:refered_elements" { |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
79 |
param "elems"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
80 |
const "descend", "$elems/descendant-or-self::svg:*"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
81 |
const "clones", "$descend[self::svg:use]"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
82 |
const "originals", "//svg:*[concat('#',@id) = $clones/@xlink:href]"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
83 |
choose { |
2853 | 84 |
when "$originals" |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
85 |
result "$descend | func:refered_elements($originals)"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
86 |
otherwise |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
87 |
result "$descend"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
88 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
89 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
90 |
|
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
91 |
def "func:intersect_1d" { |
2853 | 92 |
// it is assumed that a1 > a0 and b1 > b0 |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
93 |
param "a0"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
94 |
param "a1"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
95 |
param "b0"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
96 |
param "b1"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
97 |
|
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
98 |
const "d0", "$a0 >= $b0"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
99 |
const "d1", "$a1 >= $b1"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
100 |
choose { |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
101 |
when "not($d0) and $d1" |
2845
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
102 |
// b contained in a |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
103 |
// a0<b0 b1<a1 |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
104 |
// a +--------+ |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
105 |
// b +--+ |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
106 |
result "3"; |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
107 |
when "$d0 and not($d1)" |
2845
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
108 |
// a contained in b |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
109 |
// b0<a0 a1<b1 |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
110 |
// a +--+ |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
111 |
// b +--------+ |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
112 |
result "2"; |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
113 |
when "$d0 and $d1 and $a0 < $b1" |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
114 |
// a and b are overlapped |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
115 |
// b0<a0<b1<a1 |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
116 |
// a +-----+ |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
117 |
// b +-----+ |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
118 |
result "1"; |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
119 |
when "not($d0) and not($d1) and $b0 < $a1" |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
120 |
// a and b are overlapped |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
121 |
// a0<b0<a1<b1 |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
122 |
// a +-----+ |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
123 |
// b +-----+ |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
124 |
result "1"; |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
125 |
otherwise |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
126 |
result "0"; /* no intersection*/ |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
127 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
128 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
129 |
|
2845
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
130 |
// returns : |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
131 |
// 0 - no intersection |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
132 |
// .-----. |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
133 |
// .-----. | b| |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
134 |
// | | | | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
135 |
// | | '-----' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
136 |
// |a | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
137 |
// '-----' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
138 |
// |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
139 |
// 1 - overlapping |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
140 |
// .-----. |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
141 |
// .---|--. b| |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
142 |
// | | | | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
143 |
// | '-----' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
144 |
// |a | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
145 |
// '------' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
146 |
// |
2853 | 147 |
// 2 - overlapping |
148 |
// .-----. |
|
2845
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
149 |
// | a | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
150 |
// .---|-----|---. |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
151 |
// | '-----' | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
152 |
// | b | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
153 |
// '-------------' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
154 |
// |
2853 | 155 |
// 3 - overlapping |
156 |
// .-----. |
|
157 |
// | b | |
|
2845
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
158 |
// .---|-----|---. |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
159 |
// | '-----' | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
160 |
// | a | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
161 |
// '-------------' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
162 |
// |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
163 |
// 4 - a contained in b |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
164 |
// .-------------. |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
165 |
// | .-----. | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
166 |
// | | a | | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
167 |
// |b '-----' | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
168 |
// '-------------' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
169 |
// |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
170 |
// 6 - overlapping |
2853 | 171 |
// .----. |
172 |
// | b| |
|
2845
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
173 |
// .---|----|---. |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
174 |
// |a | | | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
175 |
// '---|----|---' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
176 |
// '----' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
177 |
// |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
178 |
// 9 - b contained in a |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
179 |
// .-------------. |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
180 |
// | .-----. | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
181 |
// | | b | | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
182 |
// |a '-----' | |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
183 |
// '-------------' |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
184 |
// |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
185 |
def "func:intersect" { |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
186 |
param "a"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
187 |
param "b"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
188 |
|
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
189 |
const "x_intersect", "func:intersect_1d($a/@x, $a/@x+$a/@w, $b/@x, $b/@x+$b/@w)"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
190 |
|
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
191 |
choose{ |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
192 |
when "$x_intersect != 0"{ |
2845
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
193 |
const "y_intersect", "func:intersect_1d($a/@y, $a/@y+$a/@h, $b/@y, $b/@y+$b/@h)"; |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
194 |
result "$x_intersect * $y_intersect"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
195 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
196 |
otherwise result "0"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
197 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
198 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
199 |
|
2845
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
200 |
// return overlapping geometry for a given element |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
201 |
// all intersercting element are returned |
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
202 |
// except groups, that must be contained to be counted in |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
203 |
def "func:overlapping_geometry" { |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
204 |
param "elt"; |
2853 | 205 |
const "groups", "/svg:svg | //svg:g"; |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
206 |
const "g", "$geometry[@Id = $elt/@id]"; |
2845
61548f7d1bef
SVGHMI : documentation for new geometry intersection computation code + little fixes...
Edouard Tisserant
parents:
2844
diff
changeset
|
207 |
const "candidates", "$geometry[@Id != $elt/@id]"; |
2846
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
208 |
result """$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
209 |
(not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"""; |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
210 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
211 |
|
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
212 |
def "func:all_related_elements" { |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
213 |
param "page"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
214 |
const "page_overlapping_geometry", "func:overlapping_geometry($page)"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
215 |
const "page_overlapping_elements", "//svg:*[@id = $page_overlapping_geometry/@Id]"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
216 |
const "page_sub_elements", "func:refered_elements($page | $page_overlapping_elements)"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
217 |
result "$page_sub_elements"; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
218 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
219 |
|
2846
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
220 |
def "func:required_elements" { |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
221 |
param "pages"; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
222 |
choose{ |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
223 |
when "$pages"{ |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
224 |
result """func:all_related_elements($pages[1]) |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
225 |
| func:required_elements($pages[position()!=1])"""; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
226 |
}otherwise{ |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
227 |
result "/.."; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
228 |
} |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
229 |
} |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
230 |
} |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
231 |
|
2853 | 232 |
const "required_elements", |
2846
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
233 |
"""//svg:defs/descendant-or-self::svg:* |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
234 |
| func:required_elements($hmi_pages)/ancestor-or-self::svg:*"""; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
235 |
|
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
236 |
const "discardable_elements", "//svg:*[not(@id = $required_elements/@id)]"; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
237 |
|
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
238 |
def "func:sumarized_elements" { |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
239 |
param "elements"; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
240 |
const "short_list", "$elements[not(ancestor::*/@id = $elements/@id)]"; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
241 |
const "filled_groups", """$short_list/parent::svg:*[ |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
242 |
not(descendant::*[ |
2853 | 243 |
not(self::svg:g) and |
2846
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
244 |
not(@id = $discardable_elements/@id) and |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
245 |
not(@id = $short_list/descendant-or-self::*[not(self::svg:g)]/@id) |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
246 |
])]"""; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
247 |
const "groups_to_add", "$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
248 |
result "$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"; |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
249 |
} |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
250 |
|
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
251 |
def "func:detachable_elements" { |
2853 | 252 |
param "pages"; |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
253 |
choose{ |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
254 |
when "$pages"{ |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
255 |
result """func:sumarized_elements(func:all_related_elements($pages[1])) |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
256 |
| func:detachable_elements($pages[position()!=1])"""; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
257 |
}otherwise{ |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
258 |
result "/.."; |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
259 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
260 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
261 |
} |
2853 | 262 |
|
2858
39c8d6079f0f
SVGHMI: Fix disapearing elements in case of nested detachable elements.
Edouard Tisserant
parents:
2857
diff
changeset
|
263 |
// Avoid nested detachables |
39c8d6079f0f
SVGHMI: Fix disapearing elements in case of nested detachable elements.
Edouard Tisserant
parents:
2857
diff
changeset
|
264 |
const "_detachable_elements", "func:detachable_elements($hmi_pages)"; |
39c8d6079f0f
SVGHMI: Fix disapearing elements in case of nested detachable elements.
Edouard Tisserant
parents:
2857
diff
changeset
|
265 |
const "detachable_elements", "$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]"; |
2853 | 266 |
|
267 |
//////////////// HMI Tree Index |
|
2843
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
268 |
|
2794
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
269 |
template "*", mode="index" { |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
270 |
param "index", "0"; |
2791
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
271 |
param "parentpath", "''"; |
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
272 |
const "content" { |
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
273 |
const "path" |
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
274 |
choose { |
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
275 |
when "local-name() = 'HMI_ROOT'" > «$parentpath» |
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
276 |
otherwise > «$parentpath»/«@name» |
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
277 |
} |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
278 |
choose { |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
279 |
when "not(local-name() = $categories/noindex)" { |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
280 |
xsl:copy { |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
281 |
attrib "index" > «$index» |
2791
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
282 |
attrib "hmipath" > «$path» |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
283 |
foreach "@*" xsl:copy; |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
284 |
} |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
285 |
/* no node expected below value nodes */ |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
286 |
} |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
287 |
otherwise { |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
288 |
apply "*[1]", mode="index"{ |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
289 |
with "index", "$index"; |
2791
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
290 |
with "parentpath" > «$path» |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
291 |
} |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
292 |
} |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
293 |
} |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
294 |
} |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
295 |
|
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
296 |
copy "$content"; |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
297 |
apply "following-sibling::*[1]", mode="index" { |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
298 |
with "index", "$index + count(exsl:node-set($content)/*)"; |
2791
d022523cb621
SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents:
2790
diff
changeset
|
299 |
with "parentpath" > «$parentpath» |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
300 |
} |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
301 |
} |
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
302 |
|
2853 | 303 |
|
304 |
||
305 |
//////////////// Inline SVG |
|
306 |
||
307 |
// Identity template : |
|
308 |
// - copy every attributes |
|
309 |
// - copy every sub-elements |
|
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
|
310 |
template "@* | node()", mode="inline_svg" { |
2853 | 311 |
// use real xsl:copy instead copy-of alias from yslt.yml2 |
2846
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
312 |
if "not(@id = $discardable_elements/@id)" |
7b1db17287b6
SVGHMI: now compute discardable elements first so that we can do better grouping of required elements when sumarizing.
Edouard Tisserant
parents:
2845
diff
changeset
|
313 |
xsl:copy apply "@* | node()", mode="inline_svg"; |
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
|
314 |
} |
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
|
315 |
|
2853 | 316 |
// replaces inkscape's height and width hints. forces fit |
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
|
317 |
template "svg:svg/@width", mode="inline_svg"; |
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
|
318 |
template "svg:svg/@height", mode="inline_svg"; |
2840
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
319 |
svgtmpl "svg:svg", mode="inline_svg" svg { |
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
|
320 |
attrib "preserveAspectRatio" > none |
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
|
321 |
attrib "height" > 100vh |
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
|
322 |
attrib "width" > 100vw |
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
|
323 |
apply "@* | node()", mode="inline_svg"; |
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
|
324 |
} |
2853 | 325 |
// ensure that coordinate in CSV file generated by inkscape are in default reference frame |
2837
53d9eb6a7498
SVGHMI: ensure that coordinate in CSV file generated by inkscape are both matching svg default unit and in default reference frame
Edouard Tisserant
parents:
2836
diff
changeset
|
326 |
template "svg:svg[@viewBox!=concat('0 0 ', @width, ' ', @height)]", mode="inline_svg" { |
53d9eb6a7498
SVGHMI: ensure that coordinate in CSV file generated by inkscape are both matching svg default unit and in default reference frame
Edouard Tisserant
parents:
2836
diff
changeset
|
327 |
error > ViewBox settings other than X=0, Y=0 and Scale=1 are not supported |
53d9eb6a7498
SVGHMI: ensure that coordinate in CSV file generated by inkscape are both matching svg default unit and in default reference frame
Edouard Tisserant
parents:
2836
diff
changeset
|
328 |
} |
2853 | 329 |
// ensure that coordinate in CSV file generated by inkscape match svg default unit |
2837
53d9eb6a7498
SVGHMI: ensure that coordinate in CSV file generated by inkscape are both matching svg default unit and in default reference frame
Edouard Tisserant
parents:
2836
diff
changeset
|
330 |
template "sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']", mode="inline_svg" { |
53d9eb6a7498
SVGHMI: ensure that coordinate in CSV file generated by inkscape are both matching svg default unit and in default reference frame
Edouard Tisserant
parents:
2836
diff
changeset
|
331 |
error > All units must be set to "px" in Inkscape's document properties |
53d9eb6a7498
SVGHMI: ensure that coordinate in CSV file generated by inkscape are both matching svg default unit and in default reference frame
Edouard Tisserant
parents:
2836
diff
changeset
|
332 |
} |
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
|
333 |
|
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
334 |
|
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
335 |
//////////////// Clone Unlinking |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
336 |
|
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
337 |
// svg:use (inkscape's clones) inside a widgets are |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
338 |
// replaced by real elements they refer in order to : |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
339 |
// - allow finding "needle" element in "meter" widget, |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
340 |
// even if "needle" is in a group refered by a svg use. |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
341 |
// - if "needle" is visible through a svg:use for |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
342 |
// each instance of the widget, then needle would show |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
343 |
// the same position in all instances |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
344 |
// |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
345 |
// For now, clone unlinkink applies to descendants of all widget except HMI:Page |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
346 |
// TODO: narrow application of clone unlinking to active elements, |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
347 |
// while keeping static decoration cloned |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
348 |
const "to_unlink", "$hmi_elements[not(@id = $hmi_pages)]//svg:use"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
349 |
svgtmpl "svg:use", mode="inline_svg" |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
350 |
{ |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
351 |
choose { |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
352 |
when "@id = $to_unlink/@id" |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
353 |
call "unlink_clone"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
354 |
otherwise |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
355 |
xsl:copy apply "@* | node()", mode="inline_svg"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
356 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
357 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
358 |
|
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
359 |
// to unlink a clone, an group containing a copy of target element is created |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
360 |
// that way, style and transforms can be preserved |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
361 |
const "_excluded_use_attrs" { |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
362 |
name > href |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
363 |
name > width |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
364 |
name > height |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
365 |
name > x |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
366 |
name > y |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
367 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
368 |
const "excluded_use_attrs","exsl:node-set($_excluded_use_attrs)"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
369 |
|
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
370 |
svgfunc "unlink_clone"{ |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
371 |
g{ |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
372 |
// include non excluded attributes |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
373 |
foreach "@*[not(local-name() = $excluded_use_attrs/name)]" |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
374 |
attrib "{name()}" > «.» |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
375 |
|
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
376 |
const "targetid","substring-after(@xlink:href,'#')"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
377 |
apply "//svg:*[@id = $targetid]", mode="unlink_clone"{ |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
378 |
with "seed","@id"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
379 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
380 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
381 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
382 |
|
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
383 |
// clone unlinking is really similar to deep-copy |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
384 |
// all nodes are sytematically copied |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
385 |
svgtmpl "@id", mode="unlink_clone" { |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
386 |
param "seed"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
387 |
attrib "id" > «$seed»_«.» |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
388 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
389 |
|
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
390 |
svgtmpl "@*", mode="unlink_clone" xsl:copy; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
391 |
|
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
392 |
// copying widgets would have unwanted effect |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
393 |
// instead widget is refered through a svg:use. |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
394 |
svgtmpl "svg:*", mode="unlink_clone" { |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
395 |
param "seed"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
396 |
choose { |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
397 |
// node recursive copy ends when finding a widget |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
398 |
when "@id = $hmi_elements/@id" { |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
399 |
// place a clone instead of copying |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
400 |
use{ |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
401 |
attrib "xlink:href" > «concat('#',@id)» |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
402 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
403 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
404 |
otherwise { |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
405 |
xsl:copy apply "@* | node()", mode="unlink_clone" { |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
406 |
with "seed","$seed"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
407 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
408 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
409 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
410 |
} |
2842
2f73f001955a
SVGHMI: attempt to optimize for webkit, because of really slow style recompute in svg:use : "unlink clones" (as in inkscape) but stop deep-copy when meeting a widget, and create a new clone instead.
Edouard Tisserant
parents:
2841
diff
changeset
|
411 |
|
2794
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
412 |
/*const "mark" > =HMI=\n*/ |
2782
723e420dfe72
SVGHMI: added transformation of code given in inkscape's description fields into javascript functions
Edouard Tisserant
parents:
2780
diff
changeset
|
413 |
|
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
414 |
const "result_svg" apply "/", mode="inline_svg"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
415 |
const "result_svg_ns", "exsl:node-set($result_svg)"; |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
416 |
|
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
|
417 |
/* copy root node and add geometry as comment for a test */ |
2853 | 418 |
template "/" { |
2793
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
419 |
comment > Made with SVGHMI. https://beremiz.org |
2814
2cabc4773885
SVGHMI: HMI_LABEL and HMI_CLASS become HMI_NODE.
Edouard Tisserant
parents:
2810
diff
changeset
|
420 |
/* DEBUG DATA */ |
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
|
421 |
comment { |
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
|
422 |
apply "$hmi_geometry", mode="testgeo"; |
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
|
423 |
} |
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
|
424 |
comment { |
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
|
425 |
apply "$hmitree", mode="testtree"; |
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
|
426 |
} |
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
|
427 |
comment { |
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
|
428 |
apply "$indexed_hmitree", mode="testtree"; |
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
|
429 |
} |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
430 |
comment { |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
431 |
| Detachable : |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
432 |
foreach "$detachable_elements"{ |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
433 |
| «@id» |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
434 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
435 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
436 |
comment { |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
437 |
| Discardable : |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
438 |
foreach "$discardable_elements"{ |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
439 |
| «@id» |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
440 |
} |
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
441 |
} |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
442 |
comment { |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
443 |
| Unlinked : |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
444 |
foreach "$to_unlink"{ |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
445 |
| «@id» |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
446 |
} |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
447 |
} |
2814
2cabc4773885
SVGHMI: HMI_LABEL and HMI_CLASS become HMI_NODE.
Edouard Tisserant
parents:
2810
diff
changeset
|
448 |
/**/ |
2840
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
449 |
html xmlns="http://www.w3.org/1999/xhtml" |
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
450 |
xmlns:svg="http://www.w3.org/2000/svg" |
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
451 |
xmlns:xlink="http://www.w3.org/1999/xlink" { |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
452 |
head; |
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
|
453 |
body style="margin:0;overflow:hidden;" { |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
454 |
copy "$result_svg"; |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
455 |
script{ |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
456 |
call "scripts"; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
457 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
458 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
459 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
460 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
461 |
|
2810
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
462 |
/* |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
463 |
Parses: |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
464 |
"HMI:WidgetType:param1:param2@path1@path2" |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
465 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
466 |
Into: |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
467 |
widget type="WidgetType" { |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
468 |
arg value="param1"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
469 |
arg value="param2"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
470 |
path value="path1"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
471 |
path value="path2"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
472 |
} |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
473 |
*/ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
474 |
|
2843
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
475 |
def "func:parselabel" { |
2793
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
476 |
param "label"; |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
477 |
const "description", "substring-after($label,'HMI:')"; |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
478 |
|
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
479 |
const "_args", "substring-before($description,'@')"; |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
480 |
const "args" choose { |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
481 |
when "$_args" value "$_args"; |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
482 |
otherwise value "$description"; |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
483 |
} |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
484 |
|
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
485 |
const "_type", "substring-before($args,':')"; |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
486 |
const "type" choose { |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
487 |
when "$_type" value "$_type"; |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
488 |
otherwise value "$args"; |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
489 |
} |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
490 |
|
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
491 |
const "ast" if "$type" widget { |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
492 |
attrib "type" > «$type» |
2794
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
493 |
foreach "str:split(substring-after($args, ':'), ':')" { |
2793
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
494 |
arg { |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
495 |
attrib "value" > «.» |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
496 |
} |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
497 |
} |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
498 |
const "paths", "substring-after($description,'@')"; |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
499 |
foreach "str:split($paths, '@')" { |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
500 |
path { |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
501 |
attrib "value" > «.» |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
502 |
} |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
503 |
} |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
504 |
} |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
505 |
|
2843
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
506 |
result "exsl:node-set($ast)"; |
2793
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
507 |
} |
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
508 |
|
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
509 |
function "scripts" |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
510 |
{ |
2799
f5da343b9b63
SVGHMI: Many fixes. Subscriptions to HMItree seems to be working, and dispatch function is called in JS with good data. Bidirectional communication now really working.
Edouard Tisserant
parents:
2798
diff
changeset
|
511 |
| //(function(){ |
2798
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
512 |
| |
2847
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
513 |
| id = idstr => document.getElementById(idstr); |
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
514 |
| |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
515 |
| var hmi_hash = [«$hmitree/@hash»]; |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
516 |
|
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
517 |
/* TODO re-enable |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
518 |
|| |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
519 |
function evaluate_js_from_descriptions() { |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
520 |
var Page; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
521 |
var Input; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
522 |
var Display; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
523 |
var res = []; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
524 |
|| |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
525 |
const "midmark" > \n«$mark» |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
526 |
apply """//*[contains(child::svg:desc, $midmark) or \ |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
527 |
starts-with(child::svg:desc, $mark)]""",2 |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
528 |
mode="code_from_descs"; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
529 |
|| |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
530 |
return res; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
531 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
532 |
|| |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
533 |
*/ |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
534 |
|
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
535 |
| var hmi_widgets = { |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
536 |
foreach "$hmi_elements" { |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
537 |
const "widget", "func:parselabel(@inkscape:label)/widget"; |
2856
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
538 |
const "eltid","@id"; |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
539 |
| "«@id»": { |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
540 |
| type: "«$widget/@type»", |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
541 |
| args: [ |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
542 |
foreach "$widget/arg" |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
543 |
| "«@value»"`if "position()!=last()" > ,` |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
544 |
| ], |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
545 |
| indexes: [ |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
546 |
foreach "$widget/path" { |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
547 |
const "hmipath","@value"; |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
548 |
const "hmitree_match","$indexed_hmitree/*[@hmipath = $hmipath]"; |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
549 |
choose { |
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
550 |
when "count($hmitree_match) = 0" { |
2856
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
551 |
warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«$hmipath»" in HMI tree |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
552 |
} |
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
553 |
otherwise { |
2849
bb89a2fbb4e0
SVGHMI: re-indenting
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2848
diff
changeset
|
554 |
| «$hmitree_match/@index»`if "position()!=last()" > ,` |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
555 |
} |
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
556 |
} |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
557 |
} |
2855 | 558 |
| ], |
559 |
| element: id("«@id»"), |
|
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
560 |
apply "$widget", mode="widget_defs" with "hmi_element","."; |
2855 | 561 |
| }`if "position()!=last()" > ,` |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
562 |
} |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
563 |
| } |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
564 |
| |
2822
9101a72a1da0
SVGHMI: added a watchdog. To ensure that the whole chain is checked, watchdog use a periodic echo of a hearteat variable. JS client code systematically register /HEARTBEAT at 1s update freq, and reacts on updates of /HEARTBEAT by systematically incrementing it. C code catch /HEARTBEAT update and feeds python-implemented watchdog. For now, watchdog does nothing when tiggered
Edouard Tisserant
parents:
2814
diff
changeset
|
565 |
| var heartbeat_index = «$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index»; |
9101a72a1da0
SVGHMI: added a watchdog. To ensure that the whole chain is checked, watchdog use a periodic echo of a hearteat variable. JS client code systematically register /HEARTBEAT at 1s update freq, and reacts on updates of /HEARTBEAT by systematically incrementing it. C code catch /HEARTBEAT update and feeds python-implemented watchdog. For now, watchdog does nothing when tiggered
Edouard Tisserant
parents:
2814
diff
changeset
|
566 |
| |
2798
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
567 |
| var hmitree_types = [ |
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
568 |
|
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
569 |
foreach "$indexed_hmitree/*" { |
2849
bb89a2fbb4e0
SVGHMI: re-indenting
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2848
diff
changeset
|
570 |
| /* «@index» «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,` |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
571 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
572 |
|
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
573 |
| ] |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
574 |
| |
2843
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
575 |
|
2847
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
576 |
| var detachable_elements = { |
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
577 |
foreach "$detachable_elements"{ |
2850
e38654ec6281
SVGHMI: detach/re-attach elements required by pages on page switch
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2849
diff
changeset
|
578 |
| "«@id»":[id("«@id»"), id("«../@id»")]`if "position()!=last()" > ,` |
2847
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
579 |
} |
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
580 |
| } |
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
581 |
|
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
582 |
| |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
583 |
| var page_desc = { |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
584 |
|
2794
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
585 |
foreach "$hmi_pages" { |
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
586 |
const "desc", "func:parselabel(@inkscape:label)/widget"; |
2843
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
587 |
const "page", "."; |
2855 | 588 |
const "p", "$geometry[@Id = $page/@id]"; |
2843
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
589 |
|
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
590 |
const "page_all_elements", "func:all_related_elements($page)"; |
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
591 |
|
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
592 |
const "all_page_ids","$page_all_elements[@id = $hmi_elements/@id and @id != $page/@id]/@id"; |
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
593 |
|
2858
39c8d6079f0f
SVGHMI: Fix disapearing elements in case of nested detachable elements.
Edouard Tisserant
parents:
2857
diff
changeset
|
594 |
// Take closest ancestor in detachable_elements |
39c8d6079f0f
SVGHMI: Fix disapearing elements in case of nested detachable elements.
Edouard Tisserant
parents:
2857
diff
changeset
|
595 |
// since nested detachable elements are filtered out |
39c8d6079f0f
SVGHMI: Fix disapearing elements in case of nested detachable elements.
Edouard Tisserant
parents:
2857
diff
changeset
|
596 |
const "required_detachables", |
39c8d6079f0f
SVGHMI: Fix disapearing elements in case of nested detachable elements.
Edouard Tisserant
parents:
2857
diff
changeset
|
597 |
"""func:sumarized_elements($page_all_elements)/ |
39c8d6079f0f
SVGHMI: Fix disapearing elements in case of nested detachable elements.
Edouard Tisserant
parents:
2857
diff
changeset
|
598 |
ancestor-or-self::*[@id = $detachable_elements/@id]"""; |
2843
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
599 |
|
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
600 |
| "«$desc/arg[1]/@value»": { |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
601 |
| widget: hmi_widgets["«@id»"], |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
602 |
| bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»], |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
603 |
| widgets: [ |
2838
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
604 |
foreach "$all_page_ids" { |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
605 |
| hmi_widgets["«.»"]`if "position()!=last()" > ,` |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
606 |
} |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
607 |
| ], |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
608 |
| required_detachables: { |
2847
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
609 |
foreach "$required_detachables" { |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
610 |
| "«@id»": detachable_elements["«@id»"]`if "position()!=last()" > ,` |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
611 |
} |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
612 |
| } |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
613 |
| }`if "position()!=last()" > ,` |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
614 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
615 |
| } |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
616 |
|
2795 | 617 |
| |
618 |
| var default_page = "«$default_page»"; |
|
2847
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
619 |
| var svg_root = id("«$svg_root_id»"); |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
620 |
include text svghmi.js |
2799
f5da343b9b63
SVGHMI: Many fixes. Subscriptions to HMItree seems to be working, and dispatch function is called in JS with good data. Bidirectional communication now really working.
Edouard Tisserant
parents:
2798
diff
changeset
|
621 |
| //})(); |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
622 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
623 |
|
2810
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
624 |
// template "*", mode="code_from_descs" { |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
625 |
// || |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
626 |
// { |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
627 |
// var path, role, name, priv; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
628 |
// var id = "«@id»"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
629 |
// || |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
630 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
631 |
// /* if label is used, use it as default name */ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
632 |
// if "@inkscape:label" |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
633 |
// |> name = "«@inkscape:label»"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
634 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
635 |
// | /* -------------- */ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
636 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
637 |
// // this breaks indent, but fixing indent could break string literals |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
638 |
// value "substring-after(svg:desc, $mark)"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
639 |
// // nobody reads generated code anyhow... |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
640 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
641 |
// || |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
642 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
643 |
// /* -------------- */ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
644 |
// res.push({ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
645 |
// path:path, |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
646 |
// role:role, |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
647 |
// name:name, |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
648 |
// priv:priv |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
649 |
// }) |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
650 |
// } |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
651 |
// || |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
652 |
// } |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
653 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
654 |
|
2814
2cabc4773885
SVGHMI: HMI_LABEL and HMI_CLASS become HMI_NODE.
Edouard Tisserant
parents:
2810
diff
changeset
|
655 |
/**/ |
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
|
656 |
template "bbox", mode="testgeo"{ |
2763
ce04d79b8e57
Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents:
2756
diff
changeset
|
657 |
| ID: «@Id» x: «@x» y: «@y» w: «@w» h: «@h» |
ce04d79b8e57
Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents:
2756
diff
changeset
|
658 |
} |
ce04d79b8e57
Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents:
2756
diff
changeset
|
659 |
|
ce04d79b8e57
Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents:
2756
diff
changeset
|
660 |
template "*", mode="testtree"{ |
ce04d79b8e57
Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents:
2756
diff
changeset
|
661 |
param "indent", "''"; |
2855 | 662 |
> «$indent» «local-name()» |
663 |
foreach "@*" > «local-name()»=«.» |
|
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
664 |
> \n |
2763
ce04d79b8e57
Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents:
2756
diff
changeset
|
665 |
apply "*", mode="testtree" { |
ce04d79b8e57
Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents:
2756
diff
changeset
|
666 |
with "indent" value "concat($indent,'>')" |
ce04d79b8e57
Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents:
2756
diff
changeset
|
667 |
}; |
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
|
668 |
} |
2814
2cabc4773885
SVGHMI: HMI_LABEL and HMI_CLASS become HMI_NODE.
Edouard Tisserant
parents:
2810
diff
changeset
|
669 |
/**/ |
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
|
670 |
|
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
|
671 |
function "defs_by_labels" { |
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
|
672 |
param "labels","''"; |
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
|
673 |
param "mandatory","'yes'"; |
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
|
674 |
param "hmi_element"; |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
675 |
const "widget_type","@type"; |
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
|
676 |
foreach "str:split($labels)" { |
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
|
677 |
const "name","."; |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
678 |
const "elt_id","$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]/@id"; |
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
679 |
choose { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
680 |
when "not($elt_id)" { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
681 |
if "$mandatory='yes'" { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
682 |
// TODO FIXME error > «$widget_type» widget must have a «$name» element |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
683 |
warning > «$widget_type» widget must have a «$name» element |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
684 |
} |
2853 | 685 |
// otherwise produce nothing |
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
686 |
} |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
687 |
otherwise { |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
688 |
| «$name»_elt: id("«$elt_id»"), |
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
689 |
} |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
690 |
} |
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
|
691 |
} |
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
|
692 |
} |
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
|
693 |
|
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
|
694 |
|
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
695 |
template "widget[@type='Display']", mode="widget_defs" { |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
696 |
param "hmi_element"; |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
697 |
| frequency: 5, |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
698 |
| dispatch: function(value) { |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
699 |
choose { |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
700 |
when "$hmi_element[self::svg:text]"{ |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
701 |
// TODO : care about <tspan> ? |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
702 |
| this.element.textContent = String(value); |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
703 |
} |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
704 |
otherwise { |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
705 |
warning > Display widget as a group not implemented |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
706 |
} |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
707 |
} |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
708 |
| }, |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
709 |
|
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
710 |
} |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
711 |
template "widget[@type='Meter']", mode="widget_defs" { |
2807 | 712 |
param "hmi_element"; |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
713 |
| frequency: 10, |
2856
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
714 |
labels("needle range"); |
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
715 |
optional_labels("value min max"); |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
716 |
| dispatch: function(value) { |
2856
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
717 |
| if(this.value_elt) |
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
718 |
| this.value_elt.textContent = String(value); |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
719 |
| let [min,max,totallength] = this.range; |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
720 |
| let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min))); |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
721 |
| let tip = this.range_elt.getPointAtLength(length); |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
722 |
| this.needle_elt.setAttribute('d', "M "+this.origin.x+","+this.origin.y+" "+tip.x+","+tip.y); |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
723 |
| }, |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
724 |
| origin: undefined, |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
725 |
| range: undefined, |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
726 |
| init: function() { |
2857
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
727 |
| let min = this.min_elt ? |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
728 |
| Number(this.min_elt.textContent) : |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
729 |
| this.args.length >= 1 ? this.args[0] : 0; |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
730 |
| let max = this.max_elt ? |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
731 |
| Number(this.max_elt.textContent) : |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
732 |
| this.args.length >= 2 ? this.args[1] : 100; |
2856
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
733 |
| this.range = [min, max, this.range_elt.getTotalLength()] |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
734 |
| this.origin = this.needle_elt.getPointAtLength(0); |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
735 |
| }, |
2807 | 736 |
} |
737 |
||
2829
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
738 |
def "func:escape_quotes" { |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
739 |
param "txt"; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
740 |
// have to use a python string to enter escaped quote |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
741 |
const "frst", !"substring-before($txt,'\"')"!; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
742 |
const "frstln", "string-length($frst)"; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
743 |
choose { |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
744 |
when "$frstln > 0 and string-length($txt) > $frstln" { |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
745 |
result !"concat($frst,'\\\"',func:escape_quotes(substring-after($txt,'\"')))"!; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
746 |
} |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
747 |
otherwise { |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
748 |
result "$txt"; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
749 |
} |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
750 |
} |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
751 |
} |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
752 |
|
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
753 |
template "widget[@type='Input']", mode="widget_defs" { |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
754 |
param "hmi_element"; |
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
755 |
const "value_elt" { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
756 |
optional_labels("value"); |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
757 |
} |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
758 |
value "$value_elt"; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
759 |
if "$value_elt" |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
760 |
| frequency: 5, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
761 |
|
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
762 |
| dispatch: function(value) { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
763 |
|
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
764 |
if "$value_elt" |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
765 |
| this.value_elt.textContent = String(value); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
766 |
|
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
767 |
| }, |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
768 |
const "edit_elt_id","$hmi_element/*[@inkscape:label='edit'][1]/@id"; |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
769 |
| init: function() { |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
770 |
if "$edit_elt_id" { |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
771 |
| id("«$edit_elt_id»").addEventListener( |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
772 |
| "click", |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
773 |
| evt => alert('XXX TODO : Edit value')); |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
774 |
} |
2829
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
775 |
foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" { |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
776 |
| id("«@id»").addEventListener( |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
777 |
| "click", |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
778 |
| evt => {let new_val = change_hmi_value(this.indexes[0], "«func:escape_quotes(@inkscape:label)»"); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
779 |
| this.value_elt.textContent = String(new_val);}); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
780 |
/* TODO gray out value until refreshed */ |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
781 |
} |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
782 |
| }, |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
783 |
} |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
784 |
template "widget[@type='Button']", mode="widget_defs" { |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
785 |
} |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
786 |
template "widget[@type='Toggle']", mode="widget_defs" { |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
787 |
| frequency: 5, |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
788 |
} |
2839
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
789 |
template "widget[@type='Switch']", mode="widget_defs" { |
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
790 |
param "hmi_element"; |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
791 |
| frequency: 5, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
792 |
| dispatch: function(value) { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
793 |
| for(let choice of this.choices){ |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
794 |
| if(value != choice.value){ |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
795 |
| choice.elt.setAttribute("style", "display:none"); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
796 |
| } else { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
797 |
| choice.elt.setAttribute("style", choice.style); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
798 |
| } |
2839
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
799 |
| } |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
800 |
| }, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
801 |
| init: function() { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
802 |
| // Hello Switch |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
803 |
| }, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
804 |
| choices: [ |
2839
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
805 |
const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+)(#.*)?$'"!; |
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
806 |
foreach "$hmi_element/*[regexp:test(@inkscape:label,$regex)]" { |
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
807 |
const "literal", "regexp:match(@inkscape:label,$regex)[2]"; |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
808 |
| { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
809 |
| elt:id("«@id»"), |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
810 |
| style:"«@style»", |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
811 |
| value:«$literal» |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
812 |
| }`if "position()!=last()" > ,` |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
813 |
} |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
814 |
| ], |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
815 |
} |
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
|
816 |
template "widget[@type='Jump']", mode="widget_defs" { |
2838
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
817 |
param "hmi_element"; |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
818 |
| on_click: function(evt) { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
819 |
| console.log(evt); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
820 |
| switch_page(this.args[0]); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
821 |
| }, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
822 |
| init: function() { |
2838
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
823 |
/* registering event this way doies not "click" through svg:use |
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
824 |
| this.element.onclick = evt => switch_page(this.args[0]); |
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
825 |
event must be registered by adding attribute to element instead |
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
826 |
TODO : generalize mouse event handling by global event capture + getElementsAtPoint() |
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
827 |
*/ |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
828 |
| this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)"); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
829 |
| }, |
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
|
830 |
} |
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
|
831 |
} |