# HG changeset patch # User Edouard Tisserant # Date 1618340686 -7200 # Node ID c5be4fd425e710c9a49994d3e3963e332cf56be7 # Parent 80f96db773bda7997049aa5cfc455e1a3eb6405c SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation. Multiple widget DnD and mutiple variable still make no sense because all path are replaced with same path, but atleast min/max value are preserved... diff -r 80f96db773bd -r c5be4fd425e7 svghmi/gen_dnd_widget_svg.xslt --- a/svghmi/gen_dnd_widget_svg.xslt Tue Apr 13 21:00:34 2021 +0200 +++ b/svghmi/gen_dnd_widget_svg.xslt Tue Apr 13 21:04:46 2021 +0200 @@ -1,5 +1,5 @@ - + @@ -77,47 +77,69 @@ - - - - PAGE_LOCAL - - - - - HMI_LOCAL - - - - - - - - Widget id: - - label: - - path section - - use min and max on non mumeric value - - - - - + + + + + PAGE_LOCAL + + - + HMI_LOCAL - - - + + + + + + + Widget id: + + label: + + path section + + use min and max on non mumeric value + + + + + + + + + + + + + + + : + + + + @ + + + : + + : + + + + + HMI: + + + + @@ -127,18 +149,34 @@ + + + + + + + + + + - - - - @ - - - + + + + + + + + + + + + + diff -r 80f96db773bd -r c5be4fd425e7 svghmi/gen_dnd_widget_svg.ysl2 --- a/svghmi/gen_dnd_widget_svg.ysl2 Tue Apr 13 21:00:34 2021 +0200 +++ b/svghmi/gen_dnd_widget_svg.ysl2 Tue Apr 13 21:04:46 2021 +0200 @@ -30,22 +30,39 @@ const "parsed_widgets","exsl:node-set($_parsed_widgets)"; const "selected_node_type","local-name($subhmitree)"; - const "svg_widget", "$parsed_widgets/widget[1]"; + const "svg_widget", "$parsed_widgets/widget[1]"; // TODO take all widgets const "svg_widget_type", "$svg_widget/@type"; const "svg_widget_path", "$svg_widget/@path"; const "svg_widget_count", "count($parsed_widgets/widget)"; + // Templates to change label paths(s) + template "@* | node()", mode="replace_path" { + xsl:copy apply "@* | node()", mode="replace_path"; + } + + template "path/@value", mode="replace_path" { + attrib "value" > «$hmi_path» + } + + // all attribs are usually copied svgtmpl "@*", mode="inline_svg" xsl:copy; - svgtmpl "@inkscape:label[starts-with(., 'HMI:')]", mode="inline_svg" { - attrib "inkscape:label" > «substring-before(., '@')»@«$hmi_path» + // except labels, ignored + svgtmpl "@inkscape:label[starts-with(., 'HMI:')]", mode="inline_svg"; + + template "node()", mode="inline_svg" xsl:copy { + + // in case this node widget's main element inject label + if "@id = $svg_widget/@id" { + const "substituted_widget" apply "$svg_widget", mode="replace_path"; + const "substituted_widget_ns", "exsl:node-set($substituted_widget)"; + const "new_label" apply "$substituted_widget_ns", mode="genlabel"; + attrib "inkscape:label" > «$new_label» + } + // all nodes are copied as well + apply "@* | node()", mode="inline_svg"; } - template "node()", mode="inline_svg" { - xsl:copy apply "@* | node()", mode="inline_svg"; - } - - const "NODES_TYPES","str:split('HMI_ROOT HMI_NODE')"; const "HMI_NODES_COMPAT","str:split('Page Jump Foreach')"; template "/" { diff -r 80f96db773bd -r c5be4fd425e7 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Tue Apr 13 21:00:34 2021 +0200 +++ b/svghmi/gen_index_xhtml.xslt Tue Apr 13 21:04:46 2021 +0200 @@ -207,47 +207,69 @@ - - - - PAGE_LOCAL - - - - - HMI_LOCAL - - - - - - - - Widget id: - - label: - - path section - - use min and max on non mumeric value - - - - - + + + + + PAGE_LOCAL + + - + HMI_LOCAL - - - + + + + + + + Widget id: + + label: + + path section + + use min and max on non mumeric value + + + + + + + + + + + + + + + : + + + + @ + + + : + + : + + + + + HMI: + + + + diff -r 80f96db773bd -r c5be4fd425e7 svghmi/parse_labels.ysl2 --- a/svghmi/parse_labels.ysl2 Tue Apr 13 21:00:34 2021 +0200 +++ b/svghmi/parse_labels.ysl2 Tue Apr 13 21:04:46 2021 +0200 @@ -54,7 +54,7 @@ error > Widget id:«$id» label:«$label» has wrong syntax of path section «$pathminmax» } } - choose { + if "$indexed_hmitree" choose { when "regexp:test($path,'^\.[a-zA-Z0-9_]+$')" { attrib "type" > PAGE_LOCAL } @@ -78,3 +78,18 @@ } } + +// Templates to generate label back from parsed tree +template "arg", mode="genlabel" > :«@value» + +template "path", mode="genlabel" { + > @«@value» + if "string-length(@min)>0 or string-length(@max)>0" > :«@min»:«@max» +} + +template "widget", mode="genlabel" { + > HMI:«@type» + apply "arg", mode="genlabel"; + apply "path", mode="genlabel"; +} + diff -r 80f96db773bd -r c5be4fd425e7 svghmi/widgetlib/voltmeter.svg --- a/svghmi/widgetlib/voltmeter.svg Tue Apr 13 21:00:34 2021 +0200 +++ b/svghmi/widgetlib/voltmeter.svg Tue Apr 13 21:04:46 2021 +0200 @@ -93,16 +93,16 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="0.35" - inkscape:cx="-64.606209" - inkscape:cy="537.51037" + inkscape:zoom="3.312923" + inkscape:cx="554.2857" + inkscape:cy="554.2857" inkscape:document-units="mm" inkscape:current-layer="svg2354" showgrid="false" - inkscape:window-width="1452" - inkscape:window-height="940" - inkscape:window-x="1645" - inkscape:window-y="72" + inkscape:window-width="1605" + inkscape:window-height="1099" + inkscape:window-x="3543" + inkscape:window-y="375" inkscape:window-maximized="0" /> @@ -112,7 +112,7 @@ image/svg+xml - + @@ -438,7 +438,7 @@ id="path4304" />