]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Creating equipment with typeURI 24/3124/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 20 Aug 2019 11:59:10 +0000 (14:59 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 20 Aug 2019 11:59:10 +0000 (14:59 +0300)
gitlab #28

Change-Id: I568f47f22bcc53649cd6fada4c179fcd9a3841d3

org.simantics.plant3d/scl/Plant3d/Utils/ComponentUtils.scl [new file with mode: 0644]
org.simantics.plant3d/scl/Plant3d/Utils/P3DScriptNodeMap.scl
org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java

diff --git a/org.simantics.plant3d/scl/Plant3d/Utils/ComponentUtils.scl b/org.simantics.plant3d/scl/Plant3d/Utils/ComponentUtils.scl
new file mode 100644 (file)
index 0000000..8778eed
--- /dev/null
@@ -0,0 +1,20 @@
+import "Plant3d/Scenegraph/PipelineComponent"
+import "Plant3d/Scenegraph/Equipment"
+import "Plant3d/Scenegraph/Nozzle"
+import "Plant3d/Scenegraph/P3DRootNode"
+import "./P3DUtil"
+
+importJava "org.simantics.plant3d.utils.ComponentUtils" where
+
+   @JavaName createComponent
+   createComponentWithURI :: P3DRootNode -> String -> <Proc> PipelineComponent
+   @JavaName createEquipment
+   createEquipmentWithURI :: P3DRootNode -> String -> <Proc> Equipment
+   
+   createStraight :: P3DRootNode -> <Proc> PipelineComponent
+   createTurn :: P3DRootNode -> <Proc> PipelineComponent
+   createReducer :: P3DRootNode -> <Proc> PipelineComponent
+   createBranchSplit :: P3DRootNode -> <Proc> PipelineComponent
+   createEquipment :: P3DRootNode -> Item -> <Proc> Equipment
+   createDefaultNozzle :: P3DRootNode -> Equipment -> <Proc> Nozzle
+   
\ No newline at end of file
index 9f3569fe951bf8d6b4a332323cabf1016c7f4500..131b560f0d99bb3547af50606d66f4388e1c6e41 100644 (file)
@@ -1,2 +1,16 @@
+import "G3D/Scenegraph/Node"
+
 importJava "org.simantics.plant3d.scl.P3DScriptNodeMap" where
-   data P3DScriptNodeMap
\ No newline at end of file
+   data P3DScriptNodeMap
+   
+   commit :: P3DScriptNodeMap -> String -> <Proc>()
+   update ::  P3DScriptNodeMap -> <Proc> ()
+   
+   populate :: P3DScriptNodeMap -> <Proc> ()
+   getRootNode :: P3DScriptNodeMap -> ParentNode
+   
+   isChangeTracking :: P3DScriptNodeMap -> Boolean
+   setChangeTracking :: P3DScriptNodeMap -> Boolean -> <Proc> ()
+   
+   
+   
\ No newline at end of file
index fdd5b5bbe8d89c3c4c8a3f4204ae6c618a36186d..800b6fde93479bc7c11a6468359a1f43d26f0d34 100644 (file)
@@ -87,7 +87,8 @@ public class ComponentUtils {
                GeometryProvider provider = getProvider(graph, type);
                if (provider != null || graph.hasStatement(type,p3d.NonVisibleComponent)) {
                        providers.put(typeURI, provider);
-                       clazzes.put(typeURI,getClazz(graph, type));
+                       if (graph.isInheritedFrom(type, p3d.PipelineComponent))
+                           clazzes.put(typeURI,getClazz(graph, type));
                        return;
                }
                throw new DatabaseException("Cannot find component for " + typeURI);
@@ -103,6 +104,15 @@ public class ComponentUtils {
                });
        }
        
+       /**
+        * Creates a component
+        * 
+        * Does not set the name or add the component to a piperun.
+        * @param root
+        * @param typeURI
+        * @return
+        * @throws Exception
+        */
        public static PipelineComponent createComponent(P3DRootNode root, String typeURI) throws Exception {
                Class<? extends PipelineComponent> type = clazzes.get(typeURI);
                GeometryProvider provider = providers.get(typeURI);
@@ -127,6 +137,30 @@ public class ComponentUtils {
                return component;
        }
        
+       /**
+        * Creates a equipment
+        * 
+        * Does not set the name
+        * 
+        * @param root
+        * @param typeURI
+        * @return
+        * @throws Exception
+        */
+       
+       public static Equipment createEquipment(P3DRootNode root, String typeURI) throws Exception {
+           GeometryProvider provider = providers.get(typeURI);
+        if (provider == null) {
+            load(typeURI);
+            provider = providers.get(typeURI);
+        }
+        Equipment equipment = root.createEquipment();
+        equipment.setType(typeURI);
+        equipment.setGeometry(provider);
+        root.addChild(equipment);
+        return equipment;
+    }
+       
        public static InlineComponent createStraight(P3DRootNode root) throws Exception{
                InlineComponent component = root.createInline();
                component.setType(Plant3D.URIs.Builtin_Straight);
@@ -163,6 +197,8 @@ public class ComponentUtils {
         return equipment;
        }
        
+       
+       
        public static Nozzle createDefaultNozzle(P3DRootNode root, Equipment equipment) throws Exception {
            return createNozzle(root, equipment, new Item(Plant3D.URIs.Builtin_Nozzle, "Nozzle"));
        }