X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fproconf%2Fg3d%2Factions%2FTranslateActionConstraints.java;fp=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fproconf%2Fg3d%2Factions%2FTranslateActionConstraints.java;h=7bbaed6a33358e958df1ff51256203ce55088dc0;hb=10f144a2bb2d7bec98b812b83acecb333fd098ea;hp=0000000000000000000000000000000000000000;hpb=3055b543aa5afc0cca4bb3b341704e7c5103fa6a;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/proconf/g3d/actions/TranslateActionConstraints.java b/org.simantics.g3d/src/org/simantics/proconf/g3d/actions/TranslateActionConstraints.java new file mode 100644 index 00000000..7bbaed6a --- /dev/null +++ b/org.simantics.g3d/src/org/simantics/proconf/g3d/actions/TranslateActionConstraints.java @@ -0,0 +1,147 @@ +/******************************************************************************* + * Copyright (c) 2007- VTT Technical Research Centre of Finland. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.proconf.g3d.actions; + +import org.simantics.db.Resource; +import org.simantics.proconf.g3d.base.ConstraintDetector; + + +/** + * Temporary class to handle "Automatic" constraints for translation + * TODO : create extension point / extension that can provide constraints + * TODO : how to override previously added constraints ? + * + * @author Marko Luukkainen + * + */ +public class TranslateActionConstraints { + + + public static void addConstraints(Resource translated[], ConstraintDetector detector) { + detector.clearConstraints(); + // these must be provided through extension point ! +// if (isElbow(translated)) { +// addElbowConstraints(translated, detector); +// } else if (isPipeControlPoint(translated)) { +// addPipeControlPointConstraints(translated, detector); +// } else if (isEndComponent(translated)) { +// addEndComponentConstraints(translated, detector); +// } + + + } + + /* + * These methods must be inserted into extension + */ + +// private static boolean isElbow(Resource translated[]) { +// for (Resource r : translated) { +// if (!r.isInstanceOf(GlobalIdMap.get(PSK3DModelingOntologyMapping.ELBOW))) { +// return false; +// } +// } +// return true; +// } +// +// private static boolean isEndComponent(Resource translated[]) { +// for (Resource r : translated) { +// if (!r.isInstanceOf(GlobalIdMap.get(PSK3DModelingOntologyMapping.END_COMPONENT))) { +// return false; +// } +// } +// return true; +// } +// +// private static boolean isPipeControlPoint(Resource translated[]) { +// for (Resource r : translated) { +// if (!r.isInstanceOf(GlobalIdMap.get(PSK3DModelingOntologyMapping.PIPE_CONTROL_POINT))) { +// return false; +// } +// } +// return true; +// } +// +// private static void addElbowConstraints(Resource translated[], ConstraintDetector detector) { +// Set res = new HashSet(); +// // add all controlpoints connected to every elbow's controlpoint +// for (Resource r : translated) { +// Elbow elbow = ElbowFactory.create(r); +// PipeControlPoint p = elbow.getHasControlPoint(); +// PipeControlPoint next = PipingTools.findNextEnd(p); +// PipeControlPoint previous = PipingTools.findPreviousEnd(p); +// if (next != null) +// res.add(next.getResource()); +// if (previous != null) +// res.add(previous.getResource()); +// +// } +// // remove all controlpoints that are elbows' controlpoints +// for (Resource r : translated) { +// Elbow elbow = ElbowFactory.create(r); +// res.remove(elbow.getHasControlPoint().getResource()); +// } +// for (Resource r : res) { +// PipeControlPoint p = PipeControlPointFactory.create(r); +// detector.addContraintPoint(GraphicsNodeTools.getPoint(p.getLocalPosition())); +// } +// } +// +// private static void addEndComponentConstraints(Resource translated[], ConstraintDetector detector) { +// Set res = new HashSet(); +// // add all controlpoints connected to every elbow's controlpoint +// for (Resource r : translated) { +// EndComponent elbow = EndComponentFactory.create(r); +// PipeControlPoint p = elbow.getHasControlPoint(); +// PipeControlPoint next = PipingTools.findNextEnd(p); +// PipeControlPoint previous = PipingTools.findPreviousEnd(p); +// if (next != null) +// res.add(next.getResource()); +// if (previous != null) +// res.add(previous.getResource()); +// +// } +// // remove all controlpoints that are elbows' controlpoints +// for (Resource r : translated) { +// EndComponent elbow = EndComponentFactory.create(r); +// res.remove(elbow.getHasControlPoint().getResource()); +// } +// for (Resource r : res) { +// PipeControlPoint p = PipeControlPointFactory.create(r); +// detector.addContraintPoint(GraphicsNodeTools.getPoint(p.getLocalPosition())); +// } +// } +// +// +// private static void addPipeControlPointConstraints(Resource translated[], ConstraintDetector detector) { +// Set res = new HashSet(); +// // add all controlpoints connected to every elbow's controlpoint +// for (Resource r : translated) { +// PipeControlPoint p = PipeControlPointFactory.create(r); +// PipeControlPoint next = PipingTools.findNextEnd(p); +// PipeControlPoint previous = PipingTools.findPreviousEnd(p); +// if (next != null) +// res.add(next.getResource()); +// if (previous != null) +// res.add(previous.getResource()); +// +// } +// // remove all controlpoints that are elbows' controlpoints +// for (Resource r : translated) { +// res.remove(r); +// } +// for (Resource r : res) { +// PipeControlPoint p = PipeControlPointFactory.create(r); +// detector.addContraintPoint(GraphicsNodeTools.getPoint(p.getLocalPosition())); +// } +// } + +}