--- a/svghmi/Makefile Mon Mar 16 17:09:23 2020 +0100
+++ b/svghmi/Makefile Mon Mar 16 18:27:49 2020 +0100
@@ -11,7 +11,7 @@
yml2path ?= $(abspath ../../yml2)
-ysl2files := $(wildcard *.ysl2)
+ysl2files := gen_index_xhtml.ysl2
xsltfiles := $(patsubst %.ysl2, %.xslt, $(ysl2files))
all:$(xsltfiles)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/svghmi/bbox_intersect.ysl2 Mon Mar 16 18:27:49 2020 +0100
@@ -0,0 +1,120 @@
+// bbox_intersect.ysl2
+//
+// bounding boxes intersection tests
+
+// Rates 1D intersection of 2 segments A and B
+// described respectively with a0,a1 and b0,b1
+def "func:intersect_1d" {
+ // it is assumed that a1 > a0 and b1 > b0
+ param "a0";
+ param "a1";
+ param "b0";
+ param "b1";
+
+ const "d0", "$a0 >= $b0";
+ const "d1", "$a1 >= $b1";
+ choose {
+ when "not($d0) and $d1"
+ // b contained in a
+ // a0<b0 b1<a1
+ // a +--------+
+ // b +--+
+ result "3";
+ when "$d0 and not($d1)"
+ // a contained in b
+ // b0<a0 a1<b1
+ // a +--+
+ // b +--------+
+ result "2";
+ when "$d0 and $d1 and $a0 < $b1"
+ // a and b are overlapped
+ // b0<a0<b1<a1
+ // a +-----+
+ // b +-----+
+ result "1";
+ when "not($d0) and not($d1) and $b0 < $a1"
+ // a and b are overlapped
+ // a0<b0<a1<b1
+ // a +-----+
+ // b +-----+
+ result "1";
+ // since orientation doesn't matter,
+ // rated same as previous symetrical overlapping
+ otherwise
+ result "0"; /* no intersection*/
+ }
+}
+
+
+// Rates intersection A and B areas described with x,y,w and h
+// attributes passed as $a and $b parameters.
+//
+// returns :
+// 0 - no intersection
+// .-----.
+// .-----. | b|
+// | | | |
+// | | '-----'
+// |a |
+// '-----'
+//
+// 1 - overlapping
+// .-----.
+// .---|--. b|
+// | | | |
+// | '-----'
+// |a |
+// '------'
+//
+// 2 - overlapping
+// .-----.
+// | a |
+// .---|-----|---.
+// | '-----' |
+// | b |
+// '-------------'
+//
+// 3 - overlapping
+// .-----.
+// | b |
+// .---|-----|---.
+// | '-----' |
+// | a |
+// '-------------'
+//
+// 4 - a contained in b
+// .-------------.
+// | .-----. |
+// | | a | |
+// |b '-----' |
+// '-------------'
+//
+// 6 - overlapping
+// .----.
+// | b|
+// .---|----|---.
+// |a | | |
+// '---|----|---'
+// '----'
+//
+// 9 - b contained in a
+// .-------------.
+// | .-----. |
+// | | b | |
+// |a '-----' |
+// '-------------'
+//
+def "func:intersect" {
+ param "a";
+ param "b";
+
+ const "x_intersect", "func:intersect_1d($a/@x, $a/@x+$a/@w, $b/@x, $b/@x+$b/@w)";
+
+ choose{
+ when "$x_intersect != 0"{
+ const "y_intersect", "func:intersect_1d($a/@y, $a/@y+$a/@h, $b/@y, $b/@y+$b/@h)";
+ result "$x_intersect * $y_intersect";
+ }
+ otherwise result "0";
+ }
+}
--- a/svghmi/gen_index_xhtml.xslt Mon Mar 16 17:09:23 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt Mon Mar 16 18:27:49 2020 +0100
@@ -690,15 +690,11 @@
</xsl:text>
<xsl:text> }
</xsl:text>
- <xsl:text> /* TODO deal with multiple paths
-</xsl:text>
- <xsl:text> and dispatch according to index+page_offset */
-</xsl:text>
- <xsl:text> /*else if(typeof(d) == "object" && d.length >= idxidx){
+ <xsl:text> else if(typeof(d) == "object" && d.length >= idxidx){
</xsl:text>
<xsl:text> d[idxidx].call(widget, value, oldval);
</xsl:text>
- <xsl:text> }*/
+ <xsl:text> }
</xsl:text>
<xsl:text> /* else dispatch_0, ..., dispatch_n ? */
</xsl:text>
--- a/svghmi/gen_index_xhtml.ysl2 Mon Mar 16 17:09:23 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2 Mon Mar 16 18:27:49 2020 +0100
@@ -85,114 +85,7 @@
}
}
- def "func:intersect_1d" {
- // it is assumed that a1 > a0 and b1 > b0
- param "a0";
- param "a1";
- param "b0";
- param "b1";
-
- const "d0", "$a0 >= $b0";
- const "d1", "$a1 >= $b1";
- choose {
- when "not($d0) and $d1"
- // b contained in a
- // a0<b0 b1<a1
- // a +--------+
- // b +--+
- result "3";
- when "$d0 and not($d1)"
- // a contained in b
- // b0<a0 a1<b1
- // a +--+
- // b +--------+
- result "2";
- when "$d0 and $d1 and $a0 < $b1"
- // a and b are overlapped
- // b0<a0<b1<a1
- // a +-----+
- // b +-----+
- result "1";
- when "not($d0) and not($d1) and $b0 < $a1"
- // a and b are overlapped
- // a0<b0<a1<b1
- // a +-----+
- // b +-----+
- result "1";
- otherwise
- result "0"; /* no intersection*/
- }
- }
-
- // returns :
- // 0 - no intersection
- // .-----.
- // .-----. | b|
- // | | | |
- // | | '-----'
- // |a |
- // '-----'
- //
- // 1 - overlapping
- // .-----.
- // .---|--. b|
- // | | | |
- // | '-----'
- // |a |
- // '------'
- //
- // 2 - overlapping
- // .-----.
- // | a |
- // .---|-----|---.
- // | '-----' |
- // | b |
- // '-------------'
- //
- // 3 - overlapping
- // .-----.
- // | b |
- // .---|-----|---.
- // | '-----' |
- // | a |
- // '-------------'
- //
- // 4 - a contained in b
- // .-------------.
- // | .-----. |
- // | | a | |
- // |b '-----' |
- // '-------------'
- //
- // 6 - overlapping
- // .----.
- // | b|
- // .---|----|---.
- // |a | | |
- // '---|----|---'
- // '----'
- //
- // 9 - b contained in a
- // .-------------.
- // | .-----. |
- // | | b | |
- // |a '-----' |
- // '-------------'
- //
- def "func:intersect" {
- param "a";
- param "b";
-
- const "x_intersect", "func:intersect_1d($a/@x, $a/@x+$a/@w, $b/@x, $b/@x+$b/@w)";
-
- choose{
- when "$x_intersect != 0"{
- const "y_intersect", "func:intersect_1d($a/@y, $a/@y+$a/@h, $b/@y, $b/@y+$b/@h)";
- result "$x_intersect * $y_intersect";
- }
- otherwise result "0";
- }
- }
+ include bbox_intersect.ysl2
// return overlapping geometry for a given element
// all intersercting element are returned