[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractTool.java,1.11,1.12 PencilTool
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-08-31 13:14:20
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24828/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java PencilTool.java SelectTool.java Log Message: Progress on PencilTool Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SelectTool.java 31 Aug 2005 12:49:40 -0000 1.12 --- SelectTool.java 31 Aug 2005 13:14:12 -0000 1.13 *************** *** 64,67 **** --- 64,78 ---- } + /** + * Find the object under the mouse and set target + * @param event The MouseEvent + */ + protected void findTarget(MouseEvent event) { + int x = event.getX(); + int y = event.getY(); + View view = glv.getView(); + target = view.getObjectAtPoint(x, y); + } + /** * Invoked when the mouse cursor has been moved *************** *** 69,72 **** --- 80,84 ---- */ protected void moved(MouseEvent e) { + //findTarget(e); } *************** *** 76,79 **** --- 88,92 ---- */ protected void dragged(MouseEvent e) { + //findTarget(e); } *************** *** 83,88 **** */ protected void pressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { ! target = null; if (selectedVertex != null) { Notification n = new Notification(Notification.VERTEX_DESELECTED, --- 96,102 ---- */ protected void pressed(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1) { ! findTarget(e); if (selectedVertex != null) { Notification n = new Notification(Notification.VERTEX_DESELECTED, *************** *** 114,130 **** } ! Object selectObject; ! selectObject = view.getObjectAtPoint(x, y); ! target = selectObject; ! if (selectObject instanceof Vertex) { ! Vertex v = (Vertex)selectObject; Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); Notifier.getInstance().sendNotification(n); ! } else if (selectObject instanceof Surface) { ! Surface surface = (Surface)selectObject; Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); Notifier.getInstance().sendNotification(n); ! } else if (selectObject instanceof Edge) { ! Edge edge = (Edge)selectObject; Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); Notifier.getInstance().sendNotification(n); --- 128,141 ---- } ! 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); *************** *** 139,142 **** --- 150,154 ---- */ protected void released(MouseEvent e) { + //findTarget(e); } Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PencilTool.java 31 Aug 2005 10:31:40 -0000 1.8 --- PencilTool.java 31 Aug 2005 13:14:12 -0000 1.9 *************** *** 9,12 **** --- 9,14 ---- import java.awt.event.MouseEvent; + import java.util.ArrayList; + import java.util.List; import net.sourceforge.bprocessor.gl.GLView; *************** *** 15,21 **** --- 17,26 ---- import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.EdgeFacade; import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Surface; + import net.sourceforge.bprocessor.model.SurfaceFacade; import net.sourceforge.bprocessor.model.Vertex; + import net.sourceforge.bprocessor.model.VertexFacade; /** *************** *** 24,27 **** --- 29,45 ---- public class PencilTool extends SelectTool { + /** The active */ + protected Edge active = null; + + /** The from */ + protected Vertex from = null; + + /** The to */ + protected Vertex to = null; + + /** The edges */ + + protected List edges = null; + /** * Constructor *************** *** 32,37 **** --- 50,84 ---- } + /** + * Intern the vertex + * @param vertex The vertex + */ + protected void intern(Vertex vertex) { + if (vertex.getId() == null) { + VertexFacade.getInstance().create(vertex); + } + } + + /** + * Intern the edge + * @param edge The edge + */ + protected void intern(Edge edge) { + if (edge.getId() == null) { + EdgeFacade.getInstance().create(edge); + edges.add(edge); + } + } /** + * Intern the surface + * @param surface The surface + */ + protected void intern(Surface surface) { + if (surface.getId() == null) { + SurfaceFacade.getInstance().create(surface); + } + } + /** * Called with the vertex that are clicked on - either: * - A vertex on the xy-plane *************** *** 43,46 **** --- 90,122 ---- void onVertex(Vertex vertex) { System.out.println(vertex); + if (active == null) { + edges = new ArrayList(); + intern(vertex); + from = vertex; + to = new Vertex("Mouse", vertex.getX(), vertex.getY(), vertex.getZ()); + active = new Edge("E" + edgeNum++, from, to); + glv.getView().setActiveEdge(active); + } else { + if (vertex.getId() == null) { + intern(vertex); + active.setTo(vertex); + intern(active); + + from = vertex; + active = new Edge("E" + edgeNum++, from, to); + + glv.getView().setActiveEdge(active); + } else { + active.setTo(vertex); + intern(active); + Surface surface = new Surface("S" + surfaceNum++, edges); + intern(surface); + edges = null; + active = null; + glv.getView().setActiveEdge(null); + from = null; + to = null; + } + } } *************** *** 68,71 **** --- 144,148 ---- Plane plane = surface.plane(); Vertex vertex = plane.intersection(ray); + vertex.setName("V" + vertexNum++); onVertex(vertex); } *************** *** 73,81 **** Edge edge = (Edge) target; Edge intersection = edge.intersection(ray); ! onVertex(intersection.getFrom()); } } else { Plane xy = new Plane(0, 0, 1, 0); Vertex vertex = xy.intersection(ray); onVertex(vertex); } --- 150,161 ---- Edge edge = (Edge) target; Edge intersection = edge.intersection(ray); ! Vertex vertex = intersection.getFrom(); ! vertex.setName("V" + vertexNum++); ! onVertex(vertex); } } else { Plane xy = new Plane(0, 0, 1, 0); Vertex vertex = xy.intersection(ray); + vertex.setName("V" + vertexNum++); onVertex(vertex); } *************** *** 89,93 **** int y = e.getY(); View v = glv.getView(); ! } --- 169,178 ---- int y = e.getY(); View v = glv.getView(); ! if (to != null) { ! double[] xyz = v.toCanvasCoords(new double[]{e.getX(), e.getY()}); ! to.setX(xyz[0]); ! to.setY(xyz[1]); ! to.setZ(xyz[2]); ! } } Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AbstractTool.java 30 Aug 2005 12:46:14 -0000 1.11 --- AbstractTool.java 31 Aug 2005 13:14:12 -0000 1.12 *************** *** 44,54 **** /** An vertex counter */ ! private static long vertexNum = 1; /** An edge counter */ ! private static long edgeNum = 1; /** An surface counter */ ! private static long surfaceNum = 1; /** The snap variable */ --- 44,54 ---- /** An vertex counter */ ! protected static long vertexNum = 1; /** An edge counter */ ! protected static long edgeNum = 1; /** An surface counter */ ! protected static long surfaceNum = 1; /** The snap variable */ |