From: Marko Luukkainen Date: Tue, 20 Aug 2019 11:59:10 +0000 (+0300) Subject: Creating equipment with typeURI X-Git-Tag: v1.43.0~212 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F3124%2F1;p=simantics%2F3d.git Creating equipment with typeURI gitlab #28 Change-Id: I568f47f22bcc53649cd6fada4c179fcd9a3841d3 --- diff --git a/org.simantics.plant3d/scl/Plant3d/Utils/ComponentUtils.scl b/org.simantics.plant3d/scl/Plant3d/Utils/ComponentUtils.scl new file mode 100644 index 00000000..8778eed0 --- /dev/null +++ b/org.simantics.plant3d/scl/Plant3d/Utils/ComponentUtils.scl @@ -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 -> PipelineComponent + @JavaName createEquipment + createEquipmentWithURI :: P3DRootNode -> String -> Equipment + + createStraight :: P3DRootNode -> PipelineComponent + createTurn :: P3DRootNode -> PipelineComponent + createReducer :: P3DRootNode -> PipelineComponent + createBranchSplit :: P3DRootNode -> PipelineComponent + createEquipment :: P3DRootNode -> Item -> Equipment + createDefaultNozzle :: P3DRootNode -> Equipment -> Nozzle + \ No newline at end of file diff --git a/org.simantics.plant3d/scl/Plant3d/Utils/P3DScriptNodeMap.scl b/org.simantics.plant3d/scl/Plant3d/Utils/P3DScriptNodeMap.scl index 9f3569fe..131b560f 100644 --- a/org.simantics.plant3d/scl/Plant3d/Utils/P3DScriptNodeMap.scl +++ b/org.simantics.plant3d/scl/Plant3d/Utils/P3DScriptNodeMap.scl @@ -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 -> () + update :: P3DScriptNodeMap -> () + + populate :: P3DScriptNodeMap -> () + getRootNode :: P3DScriptNodeMap -> ParentNode + + isChangeTracking :: P3DScriptNodeMap -> Boolean + setChangeTracking :: P3DScriptNodeMap -> Boolean -> () + + + \ No newline at end of file diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java b/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java index fdd5b5bb..800b6fde 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java @@ -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 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")); }