SVGHMI: intermediate untested state. Excluded ForEach widget from pages handled widgets. svghmi
authorEdouard Tisserant
Wed, 18 Mar 2020 12:06:50 +0100
branchsvghmi
changeset 2885 f398896b7ebf
parent 2884 50b9832c51fc
child 2886 6c82fad8be65
SVGHMI: intermediate untested state. Excluded ForEach widget from pages handled widgets.
svghmi/detachable_pages.ysl2
svghmi/gen_index_xhtml.xslt
svghmi/hmi_tree.ysl2
--- a/svghmi/detachable_pages.ysl2	Wed Mar 18 09:37:26 2020 +0100
+++ b/svghmi/detachable_pages.ysl2	Wed Mar 18 12:06:50 2020 +0100
@@ -1,4 +1,4 @@
-// detachable_elements.ysl2
+// detachable_pages.ysl2
 //
 // compute what elements are required by pages
 // and decide where to cut when removing/attaching 
@@ -98,6 +98,7 @@
     result "string-length($ancest) > 0 and starts-with($descend,$ancest)";
 }
 
+
 template "svg:*", mode="page_desc" {
     const "desc", "func:parselabel(@inkscape:label)/widget";
     const "page", ".";
@@ -105,7 +106,7 @@
 
     const "page_all_elements", "func:all_related_elements($page)";
 
-    const "all_page_widgets","$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]";
+    const "all_page_widgets","$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id][not(func:parselabels(ancestor::svg:*)/widget/@type = 'ForEach')]";
 
     const "page_relative_widgets",
         "$all_page_widgets[func:is_descendant_path(func:parselabel(@inkscape:label)/widget/path/@value, $desc/path/@value)]";
--- a/svghmi/gen_index_xhtml.xslt	Wed Mar 18 09:37:26 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Wed Mar 18 12:06:50 2020 +0100
@@ -133,6 +133,17 @@
     </xsl:variable>
     <func:result select="exsl:node-set($ast)"/>
   </func:function>
+  <func:function name="func:parselabels">
+    <xsl:param name="nodes"/>
+    <xsl:choose>
+      <xsl:when test="$nodes">
+        <func:result select="func:parselabel($nodes[1]/@inkscape:label)&#10;                      | func:parselabels($nodes[position()!=1])"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <func:result select="/.."/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </func:function>
   <xsl:template mode="testtree" match="*">
     <xsl:param name="indent" select="''"/>
     <xsl:value-of select="$indent"/>
@@ -314,7 +325,7 @@
     <xsl:variable name="page" select="."/>
     <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/>
     <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/>
-    <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"/>
+    <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id][not(func:parselabels(ancestor::svg:*)/widget/@type = 'ForEach')]"/>
     <xsl:variable name="page_relative_widgets" select="$all_page_widgets[func:is_descendant_path(func:parselabel(@inkscape:label)/widget/path/@value, $desc/path/@value)]"/>
     <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)/&#10;           ancestor-or-self::*[@id = $detachable_elements/@id]"/>
     <xsl:text>  "</xsl:text>
--- a/svghmi/hmi_tree.ysl2	Wed Mar 18 09:37:26 2020 +0100
+++ b/svghmi/hmi_tree.ysl2	Wed Mar 18 12:06:50 2020 +0100
@@ -101,6 +101,18 @@
     result "exsl:node-set($ast)";
 }
 
+def "func:parselabels" {
+    param "nodes"; 
+    choose{
+        when "$nodes"{
+            result """func:parselabel($nodes[1]/@inkscape:label)
+                      | func:parselabels($nodes[position()!=1])""";
+        }otherwise{
+            result "/..";
+        }
+    }
+}
+
 // Debug data
 template "*", mode="testtree"{
     param "indent", "''";