From: Marko Luukkainen Date: Mon, 1 Feb 2021 16:15:29 +0000 (+0200) Subject: Export Connection's children as child SVG elements. X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=2d2faa8fa89c174e70dc5bd63fb5d56acc1925c1;p=simantics%2Fplatform.git Export Connection's children as child SVG elements. gitlab #673 Change-Id: Ic0e4deaa9ffb982ef21674c6d6016d0c47c15255 --- diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java index c8fd242a2..675c4e525 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java @@ -893,7 +893,8 @@ public class SCLScenegraph { parentBuilder.append(SELECTION_MASK_SECTION, "\n"); parentBuilder.append(SELECTION_SECTION, "\n"); - parentBuilder.append(MAIN_SECTION, "\n"); + senBuilders.put((ConnectionNode)node, new RenderSVGContext()); + } else if (isSelection0(node)) { @@ -1097,8 +1098,28 @@ public class SCLScenegraph { @Override public void leave(IG2DNode node) { - if(node instanceof ConnectionNode || node instanceof SVGNode) { + if( node instanceof SVGNode) { // We are done + } else if (node instanceof ConnectionNode) { + RenderSVGContext parentBuilder = getParentBuilder(node); + SingleElementNode sen = (SingleElementNode)node; + RenderSVGContext b = senBuilders.get(sen); + String content = b.get(MAIN_SECTION); + if(content.isEmpty()) { + if(sen.getKey() != null) { + + for(SelectionNode n : NodeUtil.collectNodes(node, SelectionNode.class)) { + n.setIgnore(true); + } + + Element doc = renderSVGNode(svgGenerator, (IG2DNode)node); + String svg = printSVGDocument(doc); + parentBuilder.append(MAIN_SECTION, svg); + } + } else { + parentBuilder.append(b); + } + parentBuilder.append(MAIN_SECTION, "\n"); } else if (node instanceof G2DParentNode) { RenderSVGContext parentBuilder = getParentBuilder(node);