[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool SelectStrategy.java, 1.24, 1.25
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2008-01-15 15:43:40
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15194/src/net/sourceforge/bprocessor/gl/tool Modified Files: SelectStrategy.java Log Message: new selection impl Index: SelectStrategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectStrategy.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** SelectStrategy.java 13 Dec 2007 12:00:49 -0000 1.24 --- SelectStrategy.java 15 Jan 2008 15:43:36 -0000 1.25 *************** *** 10,13 **** --- 10,15 ---- import java.util.Collection; import java.util.HashSet; + import java.util.LinkedList; + import java.util.List; import java.util.Set; *************** *** 20,23 **** --- 22,26 ---- import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.model.ClippingPlane; + import net.sourceforge.bprocessor.model.Command; import net.sourceforge.bprocessor.model.Constructor; import net.sourceforge.bprocessor.model.Edge; *************** *** 36,39 **** --- 39,45 ---- private static Logger log = Logger.getLogger(SelectStrategy.class); + + private Collection<Geometric> initial; + /** The GLView **/ private Editor editor; *************** *** 96,101 **** */ public void moved(MouseEvent e) { - // target = glv.getView().getObjectAtPoint(e.getX(), e.getY(), View.OBJECTS); - // glv.getView().makeTarget(target); } --- 102,105 ---- *************** *** 116,119 **** --- 120,124 ---- activated = true; } + initial = new HashSet(Selection.primary()); } *************** *** 140,165 **** } int newX = e.getX(); ! Set l = editor.getView().getObjectInArea(x, y, e.getX(), e.getY()); ! l.removeAll(box); ! l.remove(Project.getInstance().getActiveCoordinateSystem()); ! if (newX > x) { ! Set<Geometric> remove = new HashSet<Geometric>(); ! for (Object o : l) { ! if (o instanceof Geometric) { ! Geometric geo = (Geometric)o; ! Set<Vertex> vertices = geo.collect(); ! if (!l.containsAll(vertices)) { ! remove.add(geo); } } } ! l.removeAll(remove); ! } ! editor.getView().makeTarget(null); ! if (!e.isShiftDown()) { ! Selection.primary().set(l); ! } else { ! Selection.primary().addAll(l); } } --- 145,240 ---- } int newX = e.getX(); ! Collection geometrics = editor.getView().getObjectInArea(x, y, e.getX(), e.getY()); ! geometrics.removeAll(box); ! geometrics.remove(Project.getInstance().getActiveCoordinateSystem()); ! ! { ! Set<Vertex> vertices = new HashSet(); ! Set<Edge> edges = new HashSet(); ! Set<Surface> surfaces = new HashSet(); ! Container owner = Project.getInstance().getActiveSpace(); ! ! if (newX > x) { ! for (Object current : geometrics) { ! if (current instanceof Vertex) { ! Vertex vertex = (Vertex) current; ! if (vertex.getOwner() == owner) { ! vertices.add(vertex); ! } ! } ! } ! } else { ! for (Object current : geometrics) { ! if (current instanceof Edge) { ! Edge edge = (Edge) current; ! if (edge.getOwner() == owner) { ! edges.add(edge); ! } } } } ! ! Command.Inverse inv = new Command.Inverse(new LinkedList(owner.getSurfaces())); ! ! for (Vertex current : vertices) { ! List<Edge> adjacent = inv.edges(current); ! for (Edge edge : adjacent) { ! if (vertices.contains(edge.otherVertex(current))) { ! edges.add(edge); ! } ! } ! } ! ! for (Edge current : edges) { ! List<Surface> adjacent = inv.surfaces(current); ! for (Surface surface : adjacent) { ! if (edges.containsAll(surface.getEdges())) { ! surfaces.add(surface); ! } ! } ! } ! ! edges.addAll(Surface.edges(surfaces)); ! vertices.addAll(Edge.vertices(edges)); ! ! Collection<Geometric> objects = new LinkedList(); ! objects.addAll(surfaces); ! objects.addAll(edges); ! objects.addAll(vertices); ! ! if (!e.isShiftDown()) { ! Selection.primary().set(objects); ! } else { ! Collection<Geometric> tentative = new HashSet(initial); ! ! for (Geometric current : objects) { ! if (initial.contains(current)) { ! tentative.remove(current); ! } else { ! tentative.add(current); ! } ! } ! ! surfaces.clear(); ! edges.clear(); ! vertices.clear(); ! for (Geometric current : tentative) { ! if (current instanceof Surface) { ! surfaces.add((Surface) current); ! } else if (current instanceof Edge) { ! edges.add((Edge) current); ! } else if (current instanceof Vertex) { ! vertices.add((Vertex) current); ! } ! } ! edges.addAll(Surface.edges(surfaces)); ! vertices.addAll(Edge.vertices(edges)); ! tentative.clear(); ! tentative.addAll(surfaces); ! tentative.addAll(edges); ! tentative.addAll(vertices); ! Selection.primary().set(tentative); ! } } } *************** *** 178,181 **** --- 253,257 ---- } multipleSelection = false; + initial = null; } else { Selection selection = Selection.primary(); |