]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Export Connection's children as child SVG elements. 41/4641/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 1 Feb 2021 16:15:29 +0000 (18:15 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 1 Feb 2021 16:15:29 +0000 (18:15 +0200)
gitlab #673

Change-Id: Ic0e4deaa9ffb982ef21674c6d6016d0c47c15255

bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java

index c8fd242a2f7a1d61adf99ae4629de350e1159c48..675c4e52581eb81995e4888246011f59b0e30b74 100644 (file)
@@ -893,7 +893,8 @@ public class SCLScenegraph {
 
                 parentBuilder.append(SELECTION_MASK_SECTION, "\n</g>");
                 parentBuilder.append(SELECTION_SECTION, "\n</g>");
-                parentBuilder.append(MAIN_SECTION, "\n</g>");
+                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</g>");
             } else if (node instanceof G2DParentNode) {
                 
                RenderSVGContext parentBuilder = getParentBuilder(node);