svghmi/geometry.ysl2
author Edouard Tisserant
Thu, 20 Aug 2020 13:56:21 +0200
branchsvghmi
changeset 3031 440d74319a74
parent 2940 034b6ce4f885
child 3165 2db69e2c5673
permissions -rw-r--r--
SVGHMI: Refactor the way JsonTable generate javascript code to access json data. Now support multiple assignments, used in the case of text to change both content and style on the same element.
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">
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
     8
const "geometry", "ns:GetSVGGeometry()";
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
     9
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
    10
// 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
    11
emit "debug:geometry" {
2875
6a12e1084deb SVGHMI: created detachable_elements.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
    12
    | ID, x, y, w, h
2879
58e6a91dc37f SVGHMI: Cosmetic changes
Edouard Tisserant
parents: 2875
diff changeset
    13
    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
    14
        |  «@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
    15
}
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
    16
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    17
// 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
    18
// described respectively with a0,a1 and b0,b1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    19
def "func:intersect_1d" {
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    20
    // 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
    21
    param "a0";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    22
    param "a1";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    23
    param "b0";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    24
    param "b1";
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    25
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    26
    const "d0", "$a0 >= $b0";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    27
    const "d1", "$a1 >= $b1";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    28
    choose {
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    29
        when "not($d0) and $d1"
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    30
            // b contained in a
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    31
            //   a0<b0 b1<a1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    32
            // a +--------+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    33
            // b    +--+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    34
            result "3";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    35
        when "$d0 and not($d1)"
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    36
            // a contained in b
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    37
            //   b0<a0 a1<b1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    38
            // a    +--+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    39
            // b +--------+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    40
            result "2";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    41
        when "$d0 and $d1 and $a0 < $b1"
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    42
            // a and b are overlapped 
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    43
            //   b0<a0<b1<a1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    44
            // a    +-----+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    45
            // b +-----+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    46
            result "1";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    47
        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
    48
            // a and b are overlapped
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    49
            //   a0<b0<a1<b1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    50
            // a +-----+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    51
            // b    +-----+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    52
            result "1";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    53
            // since orientation doesn't matter,
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    54
            // rated same as previous symetrical overlapping
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    55
        otherwise
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    56
            result "0"; /* no intersection*/
2795
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    57
    }
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    58
}
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    59
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
    60
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    61
// 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
    62
// attributes passed as $a and $b parameters.
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    63
// 
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    64
// returns :
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    65
// 0 - no intersection
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    66
//            .-----.
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    67
//    .-----. |    b|
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
//    |     | '-----'
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    70
//    |a    |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    73
// 1 - overlapping
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
//    .---|--. b|
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
//    |   '-----'
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    78
//    |a     |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    81
// 2 - overlapping
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
//        |  a  |
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
//    |   '-----'   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    86
//    | b           |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    89
// 3 - overlapping
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
//        |  b  |
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
//    |   '-----'   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    94
//    | a           |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    97
// 4 - a contained in b
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
//    |   .-----.   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   100
//    |   |  a  |   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   101
//    |b  '-----'   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   102
//    '-------------'
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   103
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   104
// 6 - overlapping
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
//        |   b|
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
//    |a  |    |   |
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
//        '----'
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
// 9 - b contained in a
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
//    |   .-----.   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   115
//    |   |  b  |   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   116
//    |a  '-----'   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   117
//    '-------------'
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   118
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   119
def "func:intersect" {
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   120
    param "a";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   121
    param "b";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   122
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   123
    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
   124
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   125
    choose{
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   126
        when "$x_intersect != 0"{
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   127
            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
   128
            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
   129
        }
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   130
        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
   131
    }
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
   132
}
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
   133
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
   134
// 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
   135
// 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
   136
// 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
   137
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
   138
    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
   139
    const "groups", "/svg:svg | //svg:g";
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
    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
   141
    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
   142
    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
   143
                          (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
   144
}