Xcos decoding: manage mixed xcos files 85/17485/1
Clément DAVID [Fri, 20 Nov 2015 14:28:08 +0000 (15:28 +0100)]
Some Xcos / Zcos files store partially decoded sub-diagrams. This commit
manage such sub-diagrams contained into such a sub-diagrams.

After this conversion, the saved xcos / zcos files will contain
a complete XML representation.

Change-Id: Ia7dc4168405c8716c73c52461272b02c3117589d

scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/BlockModelElement.java

index 3728d5b..244aa48 100644 (file)
@@ -199,7 +199,13 @@ final class BlockModelElement extends BlockPartsElement {
 
         // rpar
         field++;
-        controller.setObjectProperty(into.getUID(), into.getKind(), ObjectProperties.RPAR, toVectorOfDouble((ScilabDouble) data.get(field)));
+        if (data.get(field) instanceof ScilabMList) {
+            try {
+                new DiagramElement(new JavaController()).decode((ScilabMList) data.get(field), new XcosDiagram(into.getUID(), into.getKind()));
+            } catch (ScicosFormatException e) {}
+        } else if (data.get(field) instanceof ScilabDouble ) {
+            controller.setObjectProperty(into.getUID(), into.getKind(), ObjectProperties.RPAR, toVectorOfDouble((ScilabDouble) data.get(field)));
+        }
 
         // ipar
         field++;