[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool RelationTool.java, 1.2, 1.3 AltMoveTo
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-03-12 08:32:51
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9251/src/net/sourceforge/bprocessor/gl/tool Modified Files: RelationTool.java AltMoveTool.java Log Message: Relation demo ready Index: RelationTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/RelationTool.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RelationTool.java 8 Feb 2007 12:23:13 -0000 1.2 --- RelationTool.java 12 Mar 2007 08:32:43 -0000 1.3 *************** *** 14,17 **** --- 14,19 ---- import java.net.URL; import java.util.ArrayList; + import java.util.Collection; + import java.util.LinkedList; import java.util.List; *************** *** 19,22 **** --- 21,25 ---- import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.model.Constructor; + import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Edge; *************** *** 28,31 **** --- 31,35 ---- */ public class RelationTool extends AbstractPencil { + private Geometric source; private Constructor constructor; private Edge edge; *************** *** 50,59 **** */ private void updateFeedback() { ! if (constructor != null) { if (edge != null) { edge.setTo(current.vertex()); } else { // make new feedback ! edge = new Edge(constructor.center(), current.vertex()); edge.setStrippled(true); List<Edge> es = new ArrayList<Edge>(1); --- 54,63 ---- */ private void updateFeedback() { ! if (source != null) { if (edge != null) { edge.setTo(current.vertex()); } else { // make new feedback ! edge = new Edge(source.center(), current.vertex()); edge.setStrippled(true); List<Edge> es = new ArrayList<Edge>(1); *************** *** 94,97 **** --- 98,102 ---- edge = null; constructor = null; + source = null; } *************** *** 101,108 **** */ public void onVertex(MouseEvent e) { ! if (constructor == null) { if (target != null) { ! if (target instanceof Constructor) { ! constructor = (Constructor) target; start = current; active = true; --- 106,113 ---- */ public void onVertex(MouseEvent e) { ! if (source == null) { if (target != null) { ! if (target instanceof Geometric) { ! source = (Geometric) target; start = current; active = true; *************** *** 114,128 **** } } else { ! if (target != null && target != constructor) { if (target instanceof Geometric) { ! Geometric g = (Geometric) target; ! if (metaPressed) { ! // remove the connection ! constructor.disconnect(g); } else { ! // add a connection ! constructor.connect(g); } ! Project.getInstance().changed(constructor); Project.getInstance().checkpoint(); cleanUp(); --- 119,141 ---- } } else { ! if (target != null && target != source) { if (target instanceof Geometric) { ! Geometric geometric = (Geometric) target; ! if (source instanceof Constructor) { ! constructor = (Constructor) source; ! if (metaPressed) { ! // remove the connection ! constructor.disconnect(geometric); ! } else { ! // add a connection ! constructor.connect(geometric); ! } } else { ! Collection<Geometric> geometrics = new LinkedList(); ! geometrics.add(source); ! geometrics.add(geometric); ! CoordinateSystem.relate(geometrics); } ! Project.getInstance().changed(source); Project.getInstance().checkpoint(); cleanUp(); Index: AltMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AltMoveTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AltMoveTool.java 8 Mar 2007 10:05:14 -0000 1.7 --- AltMoveTool.java 12 Mar 2007 08:32:43 -0000 1.8 *************** *** 24,27 **** --- 24,28 ---- import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; + import net.sourceforge.bprocessor.model.Relation; import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Space; *************** *** 52,68 **** private void move(Vertex to) { ! system.setOrigin(to); ! for (Vertex vertex : vertices) { ! Vertex vector = system.getN(); ! Collection<Edge> binding = map.get(vertex); ! if (!binding.isEmpty()) { ! Edge bind = binding.iterator().next(); ! vector = bind.getDirection(); ! vector.normalize(); } ! Vertex project = system.slide(vertex, vector); ! vertex.set(project); } - system.update(); } --- 53,73 ---- private void move(Vertex to) { ! if (to == null) { ! System.out.println("move-to null"); ! } else { ! system.setOrigin(to); ! for (Vertex vertex : vertices) { ! Vertex vector = system.getN(); ! Collection<Edge> binding = map.get(vertex); ! if (!binding.isEmpty()) { ! Edge bind = binding.iterator().next(); ! vector = bind.getDirection(); ! vector.normalize(); ! } ! Vertex project = system.slide(vertex, vector); ! vertex.set(project); } ! system.update(); } } *************** *** 99,111 **** glv.getView().makeTarget(target); if (target instanceof Surface) { ! surface = (Surface) target; Space space = surface.getOwner(); vertices = surface.collect(); map = space.edgeMap(vertices); Selection.primary().set(surface); ! system = surface.coordinateSystem(); ! system.onlyPlane(true); ! system.setActive(true); ! } else if (target instanceof CoordinateSystem) { system = (CoordinateSystem) target; --- 104,128 ---- glv.getView().makeTarget(target); if (target instanceof Surface) { ! surface = (Surface) target; Space space = surface.getOwner(); + + Collection<CoordinateSystem> systems = space.getCoordinateSystems(); + for (CoordinateSystem current : systems) { + Collection<Relation> relations = current.relations(); + for (Relation relation : relations) { + if (relation.geometric() == surface) { + system = current; + } + } + } + vertices = surface.collect(); map = space.edgeMap(vertices); Selection.primary().set(surface); ! if (system == null) { ! system = surface.coordinateSystem(); ! system.onlyPlane(true); ! system.setActive(true); ! } } else if (target instanceof CoordinateSystem) { system = (CoordinateSystem) target; |