SVGHMI: Filter unseen geometry from inkscape CSV output. svghmi
authorEdouard Tisserant
Thu, 25 Mar 2021 10:13:12 +0100
branchsvghmi
changeset 3199 1582753e409b
parent 3198 d9c8f8789fc8
child 3200 75cb73b4a606
SVGHMI: Filter unseen geometry from inkscape CSV output.

When inkscape exports geometry form all objects, then it also includes objects from svg:defs. This makes problems when deciding if an object is part of a page, since coordinate of objects in svg:defs can eventualy be contained in a page. In the end, those objects where getting detached when leaving pages where they where found, leading for exemple to non working text on clipping when the clipped text was cloned in multiple page.
svghmi/detachable_pages.ysl2
svghmi/gen_index_xhtml.xslt
svghmi/geometry.ysl2
--- a/svghmi/detachable_pages.ysl2	Tue Mar 23 14:09:55 2021 +0100
+++ b/svghmi/detachable_pages.ysl2	Thu Mar 25 10:13:12 2021 +0100
@@ -93,10 +93,7 @@
 
 const "required_list_elements", "func:refered_elements($hmi_lists[@id = $required_page_elements/@id])";
 
-const "required_elements",
-    """//svg:defs/descendant-or-self::svg:*
-       | $required_list_elements
-       | $required_page_elements""";
+const "required_elements", "$defs | $required_list_elements | $required_page_elements";
 
 const "discardable_elements", "//svg:*[not(@id = $required_elements/@id)]";
 
--- a/svghmi/gen_index_xhtml.xslt	Tue Mar 23 14:09:55 2021 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Thu Mar 25 10:13:12 2021 +0100
@@ -303,7 +303,9 @@
     <xsl:text>
 </xsl:text>
   </xsl:template>
-  <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
+  <xsl:variable name="all_geometry" select="ns:GetSVGGeometry()"/>
+  <xsl:variable name="defs" select="//svg:defs/descendant-or-self::svg:*"/>
+  <xsl:variable name="geometry" select="$all_geometry[not(@Id = $defs/@id)]"/>
   <debug:geometry/>
   <xsl:template match="debug:geometry">
     <xsl:text>
@@ -476,7 +478,7 @@
   <xsl:variable name="hmi_lists_descs" select="$parsed_widgets/widget[@type = 'List']"/>
   <xsl:variable name="hmi_lists" select="$hmi_elements[@id = $hmi_lists_descs/@id]"/>
   <xsl:variable name="required_list_elements" select="func:refered_elements($hmi_lists[@id = $required_page_elements/@id])"/>
-  <xsl:variable name="required_elements" select="//svg:defs/descendant-or-self::svg:*&#10;       | $required_list_elements&#10;       | $required_page_elements"/>
+  <xsl:variable name="required_elements" select="$defs | $required_list_elements | $required_page_elements"/>
   <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
   <func:function name="func:sumarized_elements">
     <xsl:param name="elements"/>
--- a/svghmi/geometry.ysl2	Tue Mar 23 14:09:55 2021 +0100
+++ b/svghmi/geometry.ysl2	Thu Mar 25 10:13:12 2021 +0100
@@ -5,7 +5,9 @@
 // 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 "all_geometry", "ns:GetSVGGeometry()";
+const "defs", "//svg:defs/descendant-or-self::svg:*";
+const "geometry", "$all_geometry[not(@Id = $defs/@id)]";
 
 // Debug data
 emit "debug:geometry" {