svghmi/gen_index_xhtml.ysl2
branchsvghmi
changeset 2873 022db76c3bff
parent 2872 83adf8859c55
child 2874 b67af0b8dc72
--- a/svghmi/gen_index_xhtml.ysl2	Mon Mar 16 18:27:49 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2	Tue Mar 17 07:39:50 2020 +0100
@@ -17,6 +17,8 @@
 in xsl decl svgtmpl(match, xmlns="http://www.w3.org/2000/svg") alias template;
 in xsl decl svgfunc(name, xmlns="http://www.w3.org/2000/svg") alias template;
 
+!debug_output_calls = []
+
 istylesheet
             /* From Inkscape */
             xmlns:dc="http://purl.org/dc/elements/1.1/"
@@ -33,16 +35,9 @@
             extension-element-prefixes="ns func exsl regexp str dyn"
             exclude-result-prefixes="ns str regexp exsl func dyn" {
 
-    /* This retrieves geometry obtained through "inkscape -S"
-     * already parsed by python and presented as a list of
-     * <bbox x="0" y="0" w="42" h="42">
-     */
-    const "geometry", "ns:GetSVGGeometry()";
-    const "hmitree", "ns:GetHMITree()";
 
     const "svg_root_id", "/svg:svg/@id";
     const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]";
-    const "hmi_geometry", "$geometry[@Id = $hmi_elements/@id]";
 
     const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']";
 
@@ -85,19 +80,8 @@
         }
     }
 
-    include bbox_intersect.ysl2
-
-    // return overlapping geometry for a given element
-    // all intersercting element are returned
-    // except groups, that must be contained to be counted in
-    def "func:overlapping_geometry" {
-        param "elt";
-        const "groups", "/svg:svg | //svg:g";
-        const "g", "$geometry[@Id = $elt/@id]"; 
-        const "candidates", "$geometry[@Id != $elt/@id]";
-        result """$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or 
-                              (not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]""";
-    }
+    include geometry.ysl2
+
 
     def "func:all_related_elements" {
         param "page";
@@ -155,47 +139,7 @@
     const "detachable_elements", "$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]";
 
 
-    //////////////// HMI Tree Index
-
-    const "_indexed_hmitree" apply "$hmitree", mode="index";
-    const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)";
-
-    template "*", mode="index" {
-        param "index", "0";
-        param "parentpath", "''";
-        const "content" {
-            const "path"
-                choose {
-                    when "local-name() = 'HMI_ROOT'" > «$parentpath»
-                    otherwise > «$parentpath»/«@name»
-                }
-            choose {
-                when "not(local-name() = $categories/noindex)" {
-                    xsl:copy {
-                        attrib "index" > «$index»
-                        attrib "hmipath" > «$path»
-                        foreach "@*" xsl:copy;
-                    }
-                    apply "*[1]", mode="index"{
-                         with "index", "$index + 1";
-                         with "parentpath" > «$path»
-                    }
-                }
-                otherwise {
-                    apply "*[1]", mode="index"{
-                        with "index", "$index";
-                        with "parentpath" > «$path»
-                    }
-                }
-            }
-        }
-
-        copy "$content";
-        apply "following-sibling::*[1]", mode="index" {
-            with "index", "$index + count(exsl:node-set($content)/*)";
-            with "parentpath" > «$parentpath»
-        }
-    }
+    include hmi_tree.ysl2
 
 
     def "func:is_descendant_path" {
@@ -316,13 +260,14 @@
     const "result_svg" apply "/", mode="inline_svg";
     const "result_svg_ns", "exsl:node-set($result_svg)";
 
-    /* copy root node and add geometry as comment for a test */
     template "/" {
         comment > Made with SVGHMI. https://beremiz.org
-        /* DEBUG DATA */
-        comment {
-            apply "$hmi_geometry", mode="testgeo";
-        }
+
+        // use python to call all debug output from included definitions
+        // '&bug' is a workaround for old pyPEG that choke on empty python results
+        !"&bug "+"\n".join(["comment {|\n| %s:\n call \"%s\";\n| \n}"%(n,n) for n in debug_output_calls])!
+
+        // TODO
         comment {
             apply "$hmitree", mode="testtree";
         }
@@ -570,10 +515,6 @@
 
 
     /**/
-    template "bbox", mode="testgeo"{
-        | ID: «@Id» x: «@x» y: «@y» w: «@w» h: «@h»
-    }
-
     template "*", mode="testtree"{
         param "indent", "''";
         > «$indent» «local-name()»