svghmi/geometry.ysl2
author Edouard Tisserant
Tue, 17 Mar 2020 13:34:07 +0100
branchsvghmi
changeset 2879 58e6a91dc37f
parent 2875 6a12e1084deb
child 2904 92d115d8828d
permissions -rw-r--r--
SVGHMI: Cosmetic changes
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
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
function "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
}
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
!debug_output_calls.append("debug_geometry")
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
    17
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    18
// 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
    19
// described respectively with a0,a1 and b0,b1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    20
def "func:intersect_1d" {
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    21
    // 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
    22
    param "a0";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    23
    param "a1";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    24
    param "b0";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    25
    param "b1";
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    26
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    27
    const "d0", "$a0 >= $b0";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    28
    const "d1", "$a1 >= $b1";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    29
    choose {
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    30
        when "not($d0) and $d1"
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    31
            // b contained in a
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    32
            //   a0<b0 b1<a1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    33
            // a +--------+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    34
            // b    +--+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    35
            result "3";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    36
        when "$d0 and not($d1)"
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    37
            // a contained in b
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    38
            //   b0<a0 a1<b1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    39
            // a    +--+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    40
            // b +--------+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    41
            result "2";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    42
        when "$d0 and $d1 and $a0 < $b1"
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    43
            // a and b are overlapped 
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    44
            //   b0<a0<b1<a1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    45
            // a    +-----+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    46
            // b +-----+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    47
            result "1";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    48
        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
    49
            // a and b are overlapped
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    50
            //   a0<b0<a1<b1
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    51
            // a +-----+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    52
            // b    +-----+
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    53
            result "1";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    54
            // since orientation doesn't matter,
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    55
            // rated same as previous symetrical overlapping
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    56
        otherwise
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    57
            result "0"; /* no intersection*/
2795
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    58
    }
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    59
}
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    60
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
    61
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    62
// 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
    63
// attributes passed as $a and $b parameters.
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    64
// 
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    65
// returns :
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    66
// 0 - no intersection
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    67
//            .-----.
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    68
//    .-----. |    b|
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
//    |     | '-----'
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    71
//    |a    |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    74
// 1 - overlapping
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    75
//        .-----.
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    76
//    .---|--. b|
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
//    |   '-----'
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    79
//    |a     |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    82
// 2 - overlapping
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    83
//        .-----.
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    84
//        |  a  |
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
//    |   '-----'   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    87
//    | b           |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    90
// 3 - overlapping
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    91
//        .-----.
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    92
//        |  b  |
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
//    |   '-----'   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    95
//    | a           |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
    98
// 4 - a contained in b
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
//    |   .-----.   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   101
//    |   |  a  |   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   102
//    |b  '-----'   |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   105
// 6 - overlapping
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   106
//        .----.
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   107
//        |   b|
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   108
//    .---|----|---.
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   109
//    |a  |    |   |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   113
// 9 - b contained in a
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
//    |   .-----.   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   116
//    |   |  b  |   |
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   117
//    |a  '-----'   |
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
//
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   120
def "func:intersect" {
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   121
    param "a";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   122
    param "b";
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   123
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   124
    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
   125
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   126
    choose{
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   127
        when "$x_intersect != 0"{
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   128
            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
   129
            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
   130
        }
2872
83adf8859c55 SVGHMI: created bbox_intersect.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2870
diff changeset
   131
        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
   132
    }
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
   133
}
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
   134
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
// 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
   136
// 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
   137
// 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
   138
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
   139
    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
   140
    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
   141
    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
   142
    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
   143
    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
   144
                          (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
   145
}