X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Feditor%2FPlant3DEditor.java;h=d3f3c5e47e11d199b838225ee16f7afa6a0fd4e0;hb=9070983be64f9f107e0a6388549aad475fcd9d76;hp=273e1062d15ae6e805fbf1507007000df30a6673;hpb=43b9a071783377f64924bb0c2f1930fb49316f6f;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java index 273e1062..d3f3c5e4 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java @@ -23,6 +23,7 @@ import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.g3d.scenegraph.IG3DNode; import org.simantics.g3d.scenegraph.NodeMap; +import org.simantics.g3d.scenegraph.RenderListener; import org.simantics.g3d.scenegraph.base.INode; import org.simantics.g3d.vtk.action.RemoveAction; import org.simantics.g3d.vtk.common.HoverHighlighter; @@ -45,6 +46,7 @@ import org.simantics.plant3d.actions.AddNozzleAction; import org.simantics.plant3d.actions.RemoveAndSplitAction; import org.simantics.plant3d.actions.RoutePipeAction; import org.simantics.plant3d.actions.TranslateInlineAction; +import org.simantics.plant3d.ontology.Plant3D; import org.simantics.plant3d.scenegraph.EndComponent; import org.simantics.plant3d.scenegraph.Equipment; import org.simantics.plant3d.scenegraph.IP3DNode; @@ -138,7 +140,7 @@ public class Plant3DEditor extends ResourceEditorPart { panel.setPickType(4); try { - ControlPointFactory.preloadCache(); + ControlPointFactory.preloadCache(getLibraryUri()); ComponentUtils.preloadCache(); } catch (Exception e) { ExceptionUtils.logAndShowError("Cannot open Plant3D editor",e); @@ -151,19 +153,25 @@ public class Plant3DEditor extends ResourceEditorPart { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void run(ReadGraph graph) throws DatabaseException { + System.out.println("START PLANT3D LOAD"); PipingRules.setEnabled(false); IMappingSchema schema = getSchema(graph); mapping = Mappings.createWithListening(schema); rootNode = (P3DRootNode)mapping.map(graph, input); // update control points. // TODO : this should be optimized. + + + try { - P3DUtil.finalizeDBLoad(rootNode); - - } catch (Exception e) { - throw new DatabaseException(e); - } - nodeMap = createNodeMap(getSession(), mapping, panel,rootNode); + P3DUtil.finalizeDBLoad(rootNode); + nodeMap = createNodeMap(getSession(), mapping, panel,rootNode); + + } catch (Exception e) { + throw new DatabaseException(e); + } + + System.out.println("END PLANT3D LOAD"); } }); @@ -220,8 +228,12 @@ public class Plant3DEditor extends ResourceEditorPart { return new HoverHighlighter(panel,nodeMap); } - protected SelectionHighlighter createSelectionHighlighter() { - return new SelectionHighlighter(panel,nodeMap); + protected SelectionHighlighter createSelectionHighlighter() { + return new SelectionHighlighter(panel,nodeMap); + } + + protected String getLibraryUri() { + return Plant3D.URIs.Builtin; } protected void createActions() { @@ -236,7 +248,7 @@ public class Plant3DEditor extends ResourceEditorPart { removeSplitAction = new RemoveAndSplitAction(nodeMap); routePipeAction = new RoutePipeAction(panel,rootNode); - addComponentAction = new AddComponentAction(panel, rootNode); + addComponentAction = new AddComponentAction(panel, rootNode, getLibraryUri()); } public void populate() { @@ -245,6 +257,27 @@ public class Plant3DEditor extends ResourceEditorPart { @Override public void run() { nodeMap.populate(); + panel.addListener(new RenderListener() { + + @Override + public void preRender() { + + } + + @Override + public void postRender() { + try { + P3DUtil.finalizeDBLoad2(rootNode); + if (nodeMap.isRangeModified()); + nodeMap.commit("Load sync"); + } catch (Exception e) { + //throw new DatabaseException(e); + } + panel.removeListener(this); + + } + }); + } }); @@ -328,7 +361,7 @@ public class Plant3DEditor extends ResourceEditorPart { List selected = selectionProvider.getSelectedNodes(); try { if (selected.size() == 0) { - for (Item eq : P3DUtil.getEquipments()) { + for (Item eq : P3DUtil.getEquipments(getLibraryUri())) { m.add(new AddEquipmentAction(rootNode, eq)); } } else if (selected.size() == 1) { @@ -336,7 +369,7 @@ public class Plant3DEditor extends ResourceEditorPart { if (node instanceof Equipment) { m.add(translateAction); m.add(rotateAction); - for (Item eq : P3DUtil.getNozzles()) { + for (Item eq : P3DUtil.getNozzles(getLibraryUri())) { AddNozzleAction add = new AddNozzleAction(rootNode, eq); add.setEquipment((Equipment)node); m.add(add);