public abstract class AbstractVTKNodeMap<E extends INode> implements VTKNodeMap<E>, IMappingListener, RenderListener, NodeListener, UndoRedoSupport.ChangeListener{
- private static final boolean DEBUG = true;
+ private static final boolean DEBUG = false;
protected Session session;
protected IMapping<Object,E> mapping;
private boolean rangeModified = false;
+ public boolean isRangeModified() {
+ return rangeModified;
+ }
+
@Override
public void onChanged() {
try {
E n = stack.pop();
boolean conflict = filterChange(removed, n);
if (conflict) {
- filterChange(added, n);
+ System.out.println("Prevent removing " + n);
+ //filterChange(added, n)
+ if (filterChange(added, n))
+ System.out.println("Prevent adding " + n);
}
if (n instanceof ParentNode) {
ParentNode<INode> pn = (ParentNode<INode>)n;
} else if (graph.isInstanceOf(r, P3D.PipeRun)) {
pipeRuns.add(r);
} else {
- throw new DatabaseException("Unknown resource " + r);
+ throw new DatabaseException("Unknown resource " + r+ " " + mapping.get(r));
}
}
Set<Resource> nozzles = new HashSet<>();
if (graph.isInstanceOf(n, P3D.Nozzle)) {
nozzles.add(n);
} else {
- throw new DatabaseException("Unknown nozzle resource " + n);
+ throw new DatabaseException("Unknown nozzle resource " + n+ " " + mapping.get(n));
}
}
}
if (graph.isInstanceOf(c, P3D.PipelineComponent)) {
components.add(c);
} else {
- throw new DatabaseException("Unknown component resource " + c);
+ throw new DatabaseException("Unknown component resource " + c + " " + mapping.get(c));
}
}
}
for (Resource c : components) {
for (Resource connected : graph.getObjects(c, P3D.Connects)) {
if (!components.contains(connected) && !nozzles.contains(connected)) {
- throw new DatabaseException("Unbrowsable component resource " + connected + " connected to " + c);
+ throw new DatabaseException("Unbrowsable component resource " + connected + " " + mapping.get(connected) +" connected to " + c + " " + mapping.get(c));
}
Collection<Resource> connectedConnected = graph.getObjects(connected, P3D.Connects);
if (!connectedConnected.contains(c)) {
- throw new DatabaseException("Component resource " + c + " is connected to " + connected +", but its has no connection back.");
+ throw new DatabaseException("Component resource " + c + " " + mapping.get(c) + " is connected to " + connected + " " + mapping.get(connected) +", but its has no connection back.");
}
}
}
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;
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void run(ReadGraph graph) throws DatabaseException {
+ System.out.println("START PLANT3D LOAD");
PipingRules.setEnabled(false);
IMappingSchema<Resource, Object> 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");
}
});
@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);
+
+ }
+ });
+
}
});
PipingRules.validate((PipeRun)node);
}
}
- PipingRules.setEnabled(true);
- for (INode node : rootNode.getChild()) {
- if (node instanceof PipeRun) {
- PipeRun run = (PipeRun)node;
- for (PipeControlPoint pcp : run.getControlPoints())
- PipingRules.positionUpdate(pcp);
- }
- }
}
+
+ public static void finalizeDBLoad2(P3DRootNode rootNode) throws Exception{
+ PipingRules.setEnabled(true);
+ for (INode node : rootNode.getChild()) {
+ if (node instanceof PipeRun) {
+ PipeRun run = (PipeRun)node;
+ for (PipeControlPoint pcp : run.getControlPoints())
+ PipingRules.positionUpdate(pcp);
+ //PipingRules.requestUpdate(pcp);
+ }
+ }
+ }
}