author | Edouard Tisserant |
Fri, 21 Oct 2022 10:39:43 +0200 | |
changeset 3648 | ff42600fddd7 |
parent 3625 | bb1eff4091ab |
permissions | -rw-r--r-- |
2873
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
1 |
// geometry.ysl2 |
2872
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
2 |
// |
2873
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
3 |
// Geometry (bounding box intersection) definitions |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
4 |
|
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
5 |
// This retrieves geometry obtained through "inkscape -S" |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
6 |
// already parsed by python and presented as a list of |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
7 |
// <bbox x="0" y="0" w="42" h="42"> |
3199
1582753e409b
SVGHMI: Filter unseen geometry from inkscape CSV output.
Edouard Tisserant
parents:
3165
diff
changeset
|
8 |
const "all_geometry", "ns:GetSVGGeometry()"; |
1582753e409b
SVGHMI: Filter unseen geometry from inkscape CSV output.
Edouard Tisserant
parents:
3165
diff
changeset
|
9 |
const "defs", "//svg:defs/descendant-or-self::svg:*"; |
1582753e409b
SVGHMI: Filter unseen geometry from inkscape CSV output.
Edouard Tisserant
parents:
3165
diff
changeset
|
10 |
const "geometry", "$all_geometry[not(@Id = $defs/@id)]"; |
2873
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
11 |
|
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
12 |
// Debug data |
2940
034b6ce4f885
SVGHMI: Introduced "emit" to simplify producing per-topic code and content from anywhere in code. Applied to debug output, next to JS.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2939
diff
changeset
|
13 |
emit "debug:geometry" { |
2875
6a12e1084deb
SVGHMI: created detachable_elements.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2873
diff
changeset
|
14 |
| ID, x, y, w, h |
2879 | 15 |
foreach "$geometry" |
2873
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
16 |
| «@Id» «@x» «@y» «@w» «@h» |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
17 |
} |
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
|
18 |
|
2872
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
19 |
// Rates 1D intersection of 2 segments A and B |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
20 |
// described respectively with a0,a1 and b0,b1 |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
21 |
def "func:intersect_1d" { |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
22 |
// it is assumed that a1 > a0 and b1 > b0 |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
23 |
param "a0"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
24 |
param "a1"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
25 |
param "b0"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
26 |
param "b1"; |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
27 |
|
2872
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
28 |
const "d0", "$a0 >= $b0"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
29 |
const "d1", "$a1 >= $b1"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
30 |
choose { |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
31 |
when "not($d0) and $d1" |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
32 |
// b contained in a |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
33 |
// a0<b0 b1<a1 |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
34 |
// a +--------+ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
35 |
// b +--+ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
36 |
result "3"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
37 |
when "$d0 and not($d1)" |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
38 |
// a contained in b |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
39 |
// b0<a0 a1<b1 |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
40 |
// a +--+ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
41 |
// b +--------+ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
42 |
result "2"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
43 |
when "$d0 and $d1 and $a0 < $b1" |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
44 |
// a and b are overlapped |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
45 |
// b0<a0<b1<a1 |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
46 |
// a +-----+ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
47 |
// b +-----+ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
48 |
result "1"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
49 |
when "not($d0) and not($d1) and $b0 < $a1" |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
50 |
// a and b are overlapped |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
51 |
// a0<b0<a1<b1 |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
52 |
// a +-----+ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
53 |
// b +-----+ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
54 |
result "1"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
55 |
// since orientation doesn't matter, |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
56 |
// rated same as previous symetrical overlapping |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
57 |
otherwise |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
58 |
result "0"; /* no intersection*/ |
2795 | 59 |
} |
2872
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
60 |
} |
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
61 |
|
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
|
62 |
|
2872
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
63 |
// Rates intersection A and B areas described with x,y,w and h |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
64 |
// attributes passed as $a and $b parameters. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
65 |
// |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
66 |
// returns : |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
67 |
// 0 - no intersection |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
68 |
// .-----. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
69 |
// .-----. | b| |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
70 |
// | | | | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
71 |
// | | '-----' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
72 |
// |a | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
73 |
// '-----' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
74 |
// |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
75 |
// 1 - overlapping |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
76 |
// .-----. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
77 |
// .---|--. b| |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
78 |
// | | | | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
79 |
// | '-----' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
80 |
// |a | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
81 |
// '------' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
82 |
// |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
83 |
// 2 - overlapping |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
84 |
// .-----. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
85 |
// | a | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
86 |
// .---|-----|---. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
87 |
// | '-----' | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
88 |
// | b | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
89 |
// '-------------' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
90 |
// |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
91 |
// 3 - overlapping |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
92 |
// .-----. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
93 |
// | b | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
94 |
// .---|-----|---. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
95 |
// | '-----' | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
96 |
// | a | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
97 |
// '-------------' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
98 |
// |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
99 |
// 4 - a contained in b |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
100 |
// .-------------. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
101 |
// | .-----. | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
102 |
// | | a | | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
103 |
// |b '-----' | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
104 |
// '-------------' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
105 |
// |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
106 |
// 6 - overlapping |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
107 |
// .----. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
108 |
// | b| |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
109 |
// .---|----|---. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
110 |
// |a | | | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
111 |
// '---|----|---' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
112 |
// '----' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
113 |
// |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
114 |
// 9 - b contained in a |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
115 |
// .-------------. |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
116 |
// | .-----. | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
117 |
// | | b | | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
118 |
// |a '-----' | |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
119 |
// '-------------' |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
120 |
// |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
121 |
def "func:intersect" { |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
122 |
param "a"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
123 |
param "b"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
124 |
|
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
125 |
const "x_intersect", "func:intersect_1d($a/@x, $a/@x+$a/@w, $b/@x, $b/@x+$b/@w)"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
126 |
|
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
127 |
choose{ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
128 |
when "$x_intersect != 0"{ |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
129 |
const "y_intersect", "func:intersect_1d($a/@y, $a/@y+$a/@h, $b/@y, $b/@y+$b/@h)"; |
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
130 |
result "$x_intersect * $y_intersect"; |
2844
eee5dcd9fc92
SVGHMI: detachable and discardable elements sets, Reworked geometric intersection, toward more accurate page content detection.
Edouard Tisserant
parents:
2843
diff
changeset
|
131 |
} |
2872
83adf8859c55
SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2870
diff
changeset
|
132 |
otherwise result "0"; |
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
|
133 |
} |
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
|
134 |
} |
2873
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
135 |
|
3165
2db69e2c5673
SVGHMI: Optimized overlapping geometry (widget ot page belonging) computation. Added human readable messages for progress. Includes updated XSLT.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
136 |
const "groups", "/svg:svg | //svg:g"; |
2db69e2c5673
SVGHMI: Optimized overlapping geometry (widget ot page belonging) computation. Added human readable messages for progress. Includes updated XSLT.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2940
diff
changeset
|
137 |
|
2873
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
138 |
// return overlapping geometry for a given element |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
139 |
// all intersercting element are returned |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
140 |
// except groups, that must be contained to be counted in |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
141 |
def "func:overlapping_geometry" { |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
142 |
param "elt"; |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
143 |
const "g", "$geometry[@Id = $elt/@id]"; |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
144 |
const "candidates", "$geometry[@Id != $elt/@id]"; |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
145 |
result """$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
146 |
(not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"""; |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
147 |
} |
3625
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
148 |
|
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
149 |
def "func:offset" { |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
150 |
param "elt1"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
151 |
param "elt2"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
152 |
const "g1", "$geometry[@Id = $elt1/@id]"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
153 |
const "g2", "$geometry[@Id = $elt2/@id]"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
154 |
const "result" vector { |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
155 |
attrib "x" value "$g2/@x - $g1/@x"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
156 |
attrib "y" value "$g2/@y - $g1/@y"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
157 |
} |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
158 |
result "exsl:node-set($result)"; |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
159 |
} |
bb1eff4091ab
SVGHMI: add support for "reference" and "frame" rectangles to spread-out ovelapping elements.
Edouard Tisserant
parents:
3199
diff
changeset
|
160 |