Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool SelectStrategy.java, 1.15, 1.16
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-08-10 11:20:12
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3175/src/net/sourceforge/bprocessor/gl/tool Modified Files: SelectStrategy.java Log Message: Changed the select strategy to be able to drag select on objects Index: SelectStrategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectStrategy.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SelectStrategy.java 28 Jun 2007 00:37:48 -0000 1.15 --- SelectStrategy.java 10 Aug 2007 11:20:11 -0000 1.16 *************** *** 10,15 **** import java.util.Collection; import java.util.HashSet; - import java.util.Iterator; - import java.util.List; import java.util.Set; --- 10,13 ---- *************** *** 102,188 **** */ public void pressed(MouseEvent e) { Transformation t = glv.getView().transformation(); Vertex first = t.unProject(new Vertex(e.getX(), View.getHeight() - e.getY(), 0.001)); e1.setFrom(first); e4.setTo(first); - Selection selection = Selection.primary(); x = e.getX(); y = e.getY(); View view = glv.getView(); target = view.getObjectAtPoint(x, y, View.OBJECTS); - - if (e.getClickCount() >= 2) { - if (e.getClickCount() == 2) { - Collection<Geometric> extended = new HashSet(); - extended.addAll(Selection.primary()); - for (Geometric current : Selection.primary()) { - if (current instanceof Edge) { - Edge edge = (Edge) current; - extended.addAll(edge.getSurfaces()); - } - if (current instanceof Surface) { - Surface surface = (Surface) current; - extended.addAll(surface.getEdges()); - } - } - Selection.primary().clear(); - Selection.primary().addAll(extended); - } else { - Collection<Geometric> geometrics = - Geometric.connected(Selection.primary()); - Selection.primary().set(geometrics); - } - - if (1 < 0) { - if (target instanceof Space) { - Space space = (Space) target; - space.edit(); - } else if (target instanceof Surface) { - Surface surface = (Surface) target; - if (surface.getBackDomain() != null) { - selection.addAll(surface.getBackDomain().getEnvelope()); - } - if (surface.getFrontDomain() != null) { - selection.addAll(surface.getFrontDomain().getEnvelope()); - } - } else if (target instanceof Constructor) { - Constructor c = (Constructor)target; - c.setActive(!c.isActive()); - } else if (target instanceof ClippingPlane) { - ClippingPlane cp = (ClippingPlane)target; - cp.setActive(!cp.isActive()); - } else if (target instanceof GlCamera) { - GlCamera glcam = (GlCamera)target; - Project.getInstance().setCurrentCamera(glcam.getCamera()); - } - } - } else { - if (target == null) { - selection.clear(); - multipleSelection = true; - } else if (e.isShiftDown()) { - if (target instanceof Geometric) { - Geometric g = (Geometric)target; - if (!selection.contains(g)) { - selection.add(g); - } else { - selection.remove(g); - } - } else { - log.error("Tried to insert something different from Geometric in selection"); - } - } else if (target instanceof GlCamera) { - GlCamera glcam = (GlCamera)target; - Project.getInstance().setCurrentCamera(glcam.getCamera()); - } else { - if (target instanceof Geometric) { - if (!selection.contains(target)) { - selection.set((Geometric)target); - } - } else { - log.warn("Target weren't a Geometric"); - } - } - } } --- 100,112 ---- */ public void pressed(MouseEvent e) { + log.info("pressed"); Transformation t = glv.getView().transformation(); Vertex first = t.unProject(new Vertex(e.getX(), View.getHeight() - e.getY(), 0.001)); e1.setFrom(first); e4.setTo(first); x = e.getX(); y = e.getY(); View view = glv.getView(); target = view.getObjectAtPoint(x, y, View.OBJECTS); } *************** *** 192,212 **** */ public void dragged(MouseEvent e) { ! if (multipleSelection) { ! Transformation t = glv.getView().transformation(); ! Vertex last = t.unProject(new Vertex(e.getX(), View.getHeight() - e.getY(), 0.001)); ! Vertex temp1 = t.unProject(new Vertex(e.getX(), View.getHeight() - y, 0.001)); ! Vertex temp2 = t.unProject(new Vertex(x, View.getHeight() - e.getY(), 0.001)); ! e1.setTo(temp1); ! e2.setFrom(temp1); ! e2.setTo(last); ! e3.setFrom(last); ! e3.setTo(temp2); ! e4.setFrom(temp2); ! Iterator it = box.iterator(); ! while (it.hasNext()) { ! Edge constructor = (Edge)it.next(); ! glv.getView().addTempEdge(constructor); } } } --- 116,156 ---- */ public void dragged(MouseEvent e) { ! log.info("dragged"); ! multipleSelection = true; ! Transformation t = glv.getView().transformation(); ! Vertex last = t.unProject(new Vertex(e.getX(), View.getHeight() - e.getY(), 0.001)); ! Vertex temp1 = t.unProject(new Vertex(e.getX(), View.getHeight() - y, 0.001)); ! Vertex temp2 = t.unProject(new Vertex(x, View.getHeight() - e.getY(), 0.001)); ! e1.setTo(temp1); ! e2.setFrom(temp1); ! e2.setTo(last); ! e3.setFrom(last); ! e3.setTo(temp2); ! e4.setFrom(temp2); ! for (Edge constructor : box) { ! glv.getView().addTempEdge(constructor); ! } ! Collection selection = Selection.primary(); ! selection.clear(); ! int newX = e.getX(); ! Set l = new HashSet(glv.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); } + glv.getView().makeTarget(null); + selection.addAll(l); } *************** *** 216,248 **** */ public void released(MouseEvent e) { if (multipleSelection) { ! Collection selection = Selection.primary(); ! selection.clear(); ! Iterator it = box.iterator(); ! while (it.hasNext()) { ! Edge constructor = (Edge)it.next(); glv.getView().removeTempEdge(constructor); } ! int newX = e.getX(); ! List l = glv.getView().getObjectInArea(x, y, ! e.getX(), e.getY()); ! 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); } - glv.getView().makeTarget(null); - selection.addAll(l); - multipleSelection = false; } } } --- 160,245 ---- */ public void released(MouseEvent e) { + log.debug("released with event:" + e.toString()); if (multipleSelection) { ! for (Edge constructor : box) { glv.getView().removeTempEdge(constructor); } ! multipleSelection = false; ! } else { ! Selection selection = Selection.primary(); ! if (e.getClickCount() >= 2) { ! if (e.getClickCount() == 2) { ! Collection<Geometric> extended = new HashSet(); ! extended.addAll(Selection.primary()); ! for (Geometric current : Selection.primary()) { ! if (current instanceof Edge) { ! Edge edge = (Edge) current; ! extended.addAll(edge.getSurfaces()); ! } ! if (current instanceof Surface) { ! Surface surface = (Surface) current; ! extended.addAll(surface.getEdges()); } } + Selection.primary().clear(); + Selection.primary().addAll(extended); + } else { + Collection<Geometric> geometrics = + Geometric.connected(Selection.primary()); + Selection.primary().set(geometrics); + } + + if (1 < 0) { + if (target instanceof Space) { + Space space = (Space) target; + space.edit(); + } else if (target instanceof Surface) { + Surface surface = (Surface) target; + if (surface.getBackDomain() != null) { + selection.addAll(surface.getBackDomain().getEnvelope()); + } + if (surface.getFrontDomain() != null) { + selection.addAll(surface.getFrontDomain().getEnvelope()); + } + } else if (target instanceof Constructor) { + Constructor c = (Constructor)target; + c.setActive(!c.isActive()); + } else if (target instanceof ClippingPlane) { + ClippingPlane cp = (ClippingPlane)target; + cp.setActive(!cp.isActive()); + } else if (target instanceof GlCamera) { + GlCamera glcam = (GlCamera)target; + Project.getInstance().setCurrentCamera(glcam.getCamera()); + } + } + } else { + if (target == null) { + selection.clear(); + } else if (e.isShiftDown()) { + if (target instanceof Geometric) { + Geometric g = (Geometric)target; + if (!selection.contains(g)) { + selection.add(g); + } else { + selection.remove(g); + } + } else { + log.error("Tried to insert something different from Geometric in selection"); + } + } else if (target instanceof GlCamera) { + GlCamera glcam = (GlCamera)target; + Project.getInstance().setCurrentCamera(glcam.getCamera()); + } else { + if (target instanceof Geometric) { + if (!selection.contains(target)) { + selection.set((Geometric)target); + } + } else { + log.warn("Target weren't a Geometric"); + } } } } + target = null; } } |