[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AltMoveTool.java, 1.2, 1.3
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-03-04 23:34:29
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10265/src/net/sourceforge/bprocessor/gl/tool Modified Files: AltMoveTool.java Log Message: Improved hitdetection of surface/edge intersections slightly. Fixed problem with overlarge CoordinateSystems in hitdetection. Implemented an alternative movetool that is an experiment in moving vertices to a plane, sliding on binding edges. Started implementation of relations, that contains an offset in the form of an expression. Index: AltMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AltMoveTool.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AltMoveTool.java 1 Mar 2007 14:53:56 -0000 1.2 --- AltMoveTool.java 4 Mar 2007 23:14:40 -0000 1.3 *************** *** 10,15 **** --- 10,18 ---- import java.awt.Cursor; import java.awt.event.MouseEvent; + import java.util.Collection; + import java.util.HashMap; import java.util.LinkedList; import java.util.List; + import java.util.Map; import net.sourceforge.bprocessor.gl.GLView; *************** *** 20,24 **** --- 23,29 ---- import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Plane; + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; + import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; *************** *** 32,35 **** --- 37,43 ---- private CoordinateSystem system; private Plane dragplane; + private Vertex origin; + private Collection<Vertex> vertices; + private Map<Vertex, Collection<Edge>> map; /** *************** *** 40,44 **** --- 48,87 ---- super(glv, cursor); } + + private Map<Vertex, Collection<Edge>> + edgeMap(Space space, Collection<Vertex> vertices) { + HashMap<Vertex, Collection<Edge>> map = new HashMap<Vertex, Collection<Edge>>(); + for (Vertex vertex : vertices) { + map.put(vertex, new LinkedList<Edge>()); + } + Collection<Edge> edges = space.getEdges(); + for (Edge edge : edges) { + Collection<Edge> from = map.get(edge.getFrom()); + Collection<Edge> to = map.get(edge.getTo()); + if (from != null && to == null) { + from.add(edge); + } + if (to != null && from == null) { + to.add(edge); + } + } + return map; + } + 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); + } + } + /** {@inheritDoc} */ @Override *************** *** 61,64 **** --- 104,108 ---- edge.setStrippled(true); edges.add(edge); + move(origin.add(normal)); } feedback(edges); *************** *** 69,80 **** protected void pressed(MouseEvent e) { if (system == null) { - System.out.println("Alternative Moving!"); findTarget(e, View.OBJECTS); glv.getView().makeTarget(target); if (target instanceof Surface) { - System.out.println(" Surface"); surface = (Surface) target; Selection.primary().set(surface); system = surface.coordinateSystem(); system.onlyPlane(true); system.setActive(true); --- 113,127 ---- protected void pressed(MouseEvent e) { if (system == null) { findTarget(e, View.OBJECTS); glv.getView().makeTarget(target); if (target instanceof Surface) { surface = (Surface) target; + Space space = surface.getOwner(); + vertices = surface.collect(); + map = edgeMap(space, vertices); + Selection.primary().set(surface); system = surface.coordinateSystem(); + origin = system.getOrigin().copy(); system.onlyPlane(true); system.setActive(true); *************** *** 95,99 **** } } else { ! System.out.println("clean up."); cleanUp(); moved(e); --- 142,147 ---- } } else { ! Project.getInstance().checkpoint(); ! origin = null; cleanUp(); moved(e); *************** *** 104,110 **** --- 152,166 ---- @Override public void cleanUp() { + if (origin != null) { + move(origin); + } glv.getView().removeTempConstructor(system); surface = null; system = null; + dragplane = null; + origin = null; + vertices = null; + map = null; + Selection.primary().clear(); super.cleanUp(); |