From: Marko Luukkainen Date: Wed, 21 Aug 2019 15:02:27 +0000 (+0300) Subject: Plant3D customization X-Git-Tag: v1.43.0~207 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=d00bd5522f6a92bbfeb2a72a7d28ba25c3f36fed;p=simantics%2F3d.git Plant3D customization * Expose packages * Allow equipment to be loaded from non-default location * Fixed ontology errors gitlab #29 Change-Id: Id82c78edf353aec643a65c6304eb12a664b36778 --- diff --git a/org.simantics.plant3d.ontology/graph/plant3d.pgraph b/org.simantics.plant3d.ontology/graph/plant3d.pgraph index f589bf37..591a34ca 100644 --- a/org.simantics.plant3d.ontology/graph/plant3d.pgraph +++ b/org.simantics.plant3d.ontology/graph/plant3d.pgraph @@ -19,9 +19,10 @@ P3D.Node P3D.Builtin : L0.Library -P3D.Builtin.GeometryProvider implements IG3DNode, NodeMapProvider { - @RelatedElementsAdd(Plant3D.URIs.childen) + @RelatedElementsAdd(Plant3D.URIs.children) public void addChild(INode node) { //public void addChild(IP3DVisualNode node) { - addNode(Plant3D.URIs.childen,node); + addNode(Plant3D.URIs.children,node); } - @RelatedElementsGet(Plant3D.URIs.childen) + @RelatedElementsGet(Plant3D.URIs.children) public Collection getChild() { - return getNodes(Plant3D.URIs.childen); + return getNodes(Plant3D.URIs.children); } - @RelatedElementsRem(Plant3D.URIs.childen) + @RelatedElementsRem(Plant3D.URIs.children) public void remChild(INode node) { //public void remChild(IP3DNode node) { - removeNode(Plant3D.URIs.childen, node); + removeNode(Plant3D.URIs.children, node); } private P3DNodeMap nodeMap; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java index 0bd02830..9e163c2e 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java @@ -77,29 +77,29 @@ public class PipeRun extends P3DParentNode { firePropertyChanged(Plant3D.URIs.HasPipeDiameter); } - @RelatedElementsAdd(Plant3D.URIs.childen) + @RelatedElementsAdd(Plant3D.URIs.children) public void addChild(PipelineComponent node) { - addNode(Plant3D.URIs.childen,node); + addNode(Plant3D.URIs.children,node); } - @RelatedElementsGet(Plant3D.URIs.childen) + @RelatedElementsGet(Plant3D.URIs.children) public Collection getChild() { Collection coll = new ArrayList(); - for (IG3DNode n : getNodes(Plant3D.URIs.childen)) { + for (IG3DNode n : getNodes(Plant3D.URIs.children)) { coll.add((PipelineComponent)n); } return coll; } - @RelatedElementsRem(Plant3D.URIs.childen) + @RelatedElementsRem(Plant3D.URIs.children) public void remChild(PipelineComponent node) { - removeNode(Plant3D.URIs.childen, node); + removeNode(Plant3D.URIs.children, node); } public List getSortedChild() { List coll = new ArrayList(); - for (IG3DNode n : getNodes(Plant3D.URIs.childen)) { + for (IG3DNode n : getNodes(Plant3D.URIs.children)) { coll.add((PipelineComponent)n); } Collections.sort(coll, new ComponentComparator()); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/SchemaBuilder.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/SchemaBuilder.java index dd28e585..5b761a11 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/SchemaBuilder.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/SchemaBuilder.java @@ -33,7 +33,7 @@ public class SchemaBuilder { schema.addLinkType(MappingSchemas.fromAnnotations(g, P3DRootNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, PipeRun.class)); - schema.addLinkType(MappingSchemas.fromAdaptable(g, Plant3D.URIs.Builtin_GeometryProvider, GeometryProvider.class)); + schema.addLinkType(MappingSchemas.fromAdaptable(g, Plant3D.URIs.GeometryProvider, GeometryProvider.class)); return schema; } catch (IllegalAccessException e) { throw new DatabaseException(e); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java b/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java index 7ba42b8f..0d656b05 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java @@ -23,14 +23,18 @@ import org.simantics.plant3d.scenegraph.controlpoint.PipingRules; import org.simantics.plant3d.utils.Item.Type; public class P3DUtil { + + public static List getEquipments() throws DatabaseException { + return getEquipments(Plant3D.URIs.Builtin); + } - public static List getEquipments() throws DatabaseException { + public static List getEquipments(final String libUri) throws DatabaseException { return Simantics.getSession().syncRequest(new Read>() { @Override public List perform(ReadGraph graph) throws DatabaseException { Plant3D p3d = Plant3D.getInstance(graph); Resource project = Simantics.getProject().get(); - Resource builtins = graph.getResource(Plant3D.URIs.Builtin); + Resource builtins = graph.getResource(libUri); List actions = getItems(graph, project,p3d.Equipment); actions.addAll(getItems(graph, builtins,p3d.Equipment)); return actions; @@ -45,26 +49,43 @@ public class P3DUtil { @Override public List perform(ReadGraph graph) throws DatabaseException { Plant3D p3d = Plant3D.getInstance(graph); - ItemQuery query = new ItemQuery(p3d.Nozzle); + ItemQuery query = new ItemQuery(p3d.Nozzle, Plant3D.URIs.Builtin); return graph.syncRequest(query); } }); } - private static class ItemQuery implements Read> { + public static class ItemQuery implements Read> { private Resource type; - public ItemQuery(Resource type) { + private String libUri; + public ItemQuery(Resource type, String libUri) { this.type = type; + this.libUri = libUri; } @Override public List perform(ReadGraph graph) throws DatabaseException { Resource project = Simantics.getProject().get(); - Resource builtins = graph.getResource(Plant3D.URIs.Builtin); + Resource builtins = graph.getResource(libUri); List actions = getItems(graph, project,type); actions.addAll(getItems(graph, builtins,type)); return actions; } + + @Override + public boolean equals(Object obj) { + if (obj.getClass() != this.getClass()) + return false; + ItemQuery other = (ItemQuery)obj; + if (!type.equals(other.type)) + return false; + return libUri.equals(other.libUri); + } + + @Override + public int hashCode() { + return type.hashCode() + libUri.hashCode(); + } } public static List getEnds() throws DatabaseException { @@ -72,7 +93,7 @@ public class P3DUtil { @Override public List perform(ReadGraph graph) throws DatabaseException { Plant3D p3d = Plant3D.getInstance(graph); - ItemQuery query = new ItemQuery(p3d.EndComponent); + ItemQuery query = new ItemQuery(p3d.EndComponent, Plant3D.URIs.Builtin); return graph.syncRequest(query); } }); @@ -83,7 +104,7 @@ public class P3DUtil { @Override public List perform(ReadGraph graph) throws DatabaseException { Plant3D p3d = Plant3D.getInstance(graph); - ItemQuery query = new ItemQuery(p3d.TurnComponent); + ItemQuery query = new ItemQuery(p3d.TurnComponent, Plant3D.URIs.Builtin); return graph.syncRequest(query); } }); @@ -94,7 +115,7 @@ public class P3DUtil { @Override public List perform(ReadGraph graph) throws DatabaseException { Plant3D p3d = Plant3D.getInstance(graph); - ItemQuery query = new ItemQuery(p3d.InlineComponent); + ItemQuery query = new ItemQuery(p3d.InlineComponent, Plant3D.URIs.Builtin); return graph.syncRequest(query); } });