[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool SelectTool.java,1.14,1.15
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-09-02 13:29:53
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14367 Modified Files: SelectTool.java Log Message: Changed selection to select an entire list of objects with shift Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SelectTool.java 1 Sep 2005 06:05:15 -0000 1.14 --- SelectTool.java 2 Sep 2005 13:29:44 -0000 1.15 *************** *** 9,16 **** import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.view.View; - import net.sourceforge.bprocessor.gl.view.View3D; - import net.sourceforge.bprocessor.gl.view.ViewXY; - import net.sourceforge.bprocessor.gl.view.ViewXZ; - import net.sourceforge.bprocessor.gl.view.ViewYZ; import net.sourceforge.bprocessor.kernel.notification.Notification; --- 9,12 ---- *************** *** 19,32 **** import net.sourceforge.bprocessor.model.Edge; ! import net.sourceforge.bprocessor.model.EdgeFacade; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.VertexFacade; import net.sourceforge.bprocessor.model.Surface; ! import net.sourceforge.bprocessor.model.SurfaceFacade; import java.awt.event.MouseEvent; import java.awt.event.KeyEvent; import java.util.Iterator; import java.util.Set; --- 15,31 ---- import net.sourceforge.bprocessor.model.Edge; ! //import net.sourceforge.bprocessor.model.EdgeFacade; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.VertexFacade; import net.sourceforge.bprocessor.model.Surface; ! //import net.sourceforge.bprocessor.model.SurfaceFacade; import java.awt.event.MouseEvent; import java.awt.event.KeyEvent; + import java.awt.event.InputEvent; import java.util.Iterator; + import java.util.List; + import java.util.ArrayList; import java.util.Set; *************** *** 40,51 **** private static Logger log = Logger.getLogger(SelectTool.class); /** The selected vertex */ ! protected static Vertex selectedVertex = null; /** The selected edge */ ! protected static Edge selectedEdge = null; /** The selected surface */ ! protected static Surface selectedSurface = null; /** the Viewtype */ --- 39,53 ---- private static Logger log = Logger.getLogger(SelectTool.class); + /** The selected objects */ + protected static List selection; + /** The selected vertex */ ! //protected static Vertex selectedVertex = null; /** The selected edge */ ! //protected static Edge selectedEdge = null; /** The selected surface */ ! //protected static Surface selectedSurface = null; /** the Viewtype */ *************** *** 55,59 **** protected Object target; ! /** * The constructor --- 57,63 ---- protected Object target; ! static { ! selection = new ArrayList(); ! } /** * The constructor *************** *** 88,92 **** */ protected void dragged(MouseEvent e) { ! findTarget(e); } --- 92,96 ---- */ protected void dragged(MouseEvent e) { ! //findTarget(e); } *************** *** 95,147 **** * @param e The MouseEvent object */ ! protected void pressed(MouseEvent e) { ! if (e.getButton() == MouseEvent.BUTTON1) { findTarget(e); ! if (selectedVertex != null) { ! Notification n = new Notification(Notification.VERTEX_DESELECTED, ! selectedVertex.getId()); ! Notifier.getInstance().sendNotification(n); ! } ! if (selectedEdge != null) { ! Notification n = new Notification(Notification.EDGE_DESELECTED, ! selectedEdge.getId()); ! Notifier.getInstance().sendNotification(n); ! } ! if (selectedSurface != null) { ! Notification n = new Notification(Notification.SURFACE_DESELECTED, ! selectedSurface.getId()); ! Notifier.getInstance().sendNotification(n); ! } ! int x = e.getX(); ! int y = e.getY(); ! viewType = 0; ! View view = glv.getView(); ! if (view instanceof View3D) { ! viewType = View.VIEW_3D; ! } else if (view instanceof ViewXY) { ! viewType = View.VIEW_XY; ! } else if (view instanceof ViewXZ) { ! viewType = View.VIEW_XZ; ! } else if (view instanceof ViewYZ) { ! viewType = View.VIEW_YZ; ! } ! ! if (target instanceof Vertex) { ! Vertex v = (Vertex)target; ! Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (target instanceof Surface) { ! Surface surface = (Surface)target; ! Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (target instanceof Edge) { ! Edge edge = (Edge)target; ! Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); ! Notifier.getInstance().sendNotification(n); } } } /** --- 99,167 ---- * @param e The MouseEvent object */ ! protected void pressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { findTarget(e); ! if (target == null) { ! log.info("target was null"); ! Iterator it = selection.iterator(); ! while (it.hasNext()) { ! deselect(it.next()); ! } ! selection = new ArrayList(); ! } else if ((e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK) { ! select(target); ! if (!selection.contains(target)) { ! selection.add(target); ! } ! } else { ! Iterator it = selection.iterator(); ! while (it.hasNext()) { ! deselect(it.next()); ! } ! select(target); ! selection.add(target); } } } + /** + * Sends the notification for select + * @param obj The selected object + */ + private void select(Object obj) { + if (obj instanceof Vertex) { + Vertex v = (Vertex)obj; + Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); + Notifier.getInstance().sendNotification(n); + } else if (obj instanceof Surface) { + Surface surface = (Surface)obj; + Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); + Notifier.getInstance().sendNotification(n); + } else if (obj instanceof Edge) { + Edge edge = (Edge)obj; + Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); + Notifier.getInstance().sendNotification(n); + } + } + + /** + * Sends the notification for deselect + * @param obj The selected object + */ + private void deselect(Object obj) { + if (obj instanceof Vertex) { + Vertex v = (Vertex)obj; + Notification n = new Notification(Notification.VERTEX_DESELECTED, v.getId()); + Notifier.getInstance().sendNotification(n); + } else if (obj instanceof Surface) { + Surface surface = (Surface)obj; + Notification n = new Notification(Notification.SURFACE_DESELECTED, surface.getId()); + Notifier.getInstance().sendNotification(n); + } else if (obj instanceof Edge) { + Edge edge = (Edge)obj; + Notification n = new Notification(Notification.EDGE_DESELECTED, edge.getId()); + Notifier.getInstance().sendNotification(n); + } + } /** *************** *** 188,197 **** public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { ! if (selectedSurface != null) { Notification n = new Notification(Notification.SURFACE_DESELECTED, selectedSurface.getId()); Notifier.getInstance().sendNotification(n); deleteSurface(selectedSurface); ! } else if (selectedEdge != null) { if (selectedEdge.getSurfaces().size() < 1) { Notification n = new Notification(Notification.EDGE_DESELECTED, --- 208,219 ---- public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { ! if (target instanceof Surface) { ! Surface selectedSurface = (Surface)target; Notification n = new Notification(Notification.SURFACE_DESELECTED, selectedSurface.getId()); Notifier.getInstance().sendNotification(n); deleteSurface(selectedSurface); ! } else if (target instanceof Edge) { ! Edge selectedEdge = (Edge)target; if (selectedEdge.getSurfaces().size() < 1) { Notification n = new Notification(Notification.EDGE_DESELECTED, *************** *** 212,226 **** public void handleNotification(Notification n) { if (n.getType().equals(Notification.VERTEX_SELECTED)) { ! selectedVertex = VertexFacade.getInstance().findById(n.getObject()); } else if (n.getType().equals(Notification.VERTEX_DESELECTED)) { ! selectedVertex = null; } else if (n.getType().equals(Notification.EDGE_SELECTED)) { ! selectedEdge = EdgeFacade.getInstance().findById(n.getObject()); } else if (n.getType().equals(Notification.EDGE_DESELECTED)) { ! selectedEdge = null; } else if (n.getType().equals(Notification.SURFACE_SELECTED)) { ! selectedSurface = SurfaceFacade.getInstance().findById(n.getObject()); } else if (n.getType().equals(Notification.SURFACE_DESELECTED)) { ! selectedSurface = null; } } --- 234,248 ---- public void handleNotification(Notification n) { if (n.getType().equals(Notification.VERTEX_SELECTED)) { ! //selection.add(VertexFacade.getInstance().findById(n.getObject())); } else if (n.getType().equals(Notification.VERTEX_DESELECTED)) { ! //selectedVertex = null; } else if (n.getType().equals(Notification.EDGE_SELECTED)) { ! // selection.add(EdgeFacade.getInstance().findById(n.getObject())); } else if (n.getType().equals(Notification.EDGE_DESELECTED)) { ! //selectedEdge = null; } else if (n.getType().equals(Notification.SURFACE_SELECTED)) { ! //selection.add(SurfaceFacade.getInstance().findById(n.getObject())); } else if (n.getType().equals(Notification.SURFACE_DESELECTED)) { ! //selectedSurface = null; } } |