From 2d2faa8fa89c174e70dc5bd63fb5d56acc1925c1 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Mon, 1 Feb 2021 18:15:29 +0200 Subject: [PATCH] Export Connection's children as child SVG elements. gitlab #673 Change-Id: Ic0e4deaa9ffb982ef21674c6d6016d0c47c15255 --- .../org/simantics/modeling/SCLScenegraph.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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); -- 2.47.1