[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool PencilTool.java,1.7,1.8 SelectTool.jav
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-08-31 10:31:54
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6461/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java SelectTool.java Log Message: Target added to SelectTool (target is object under mouse) PencilTool implemented to find a Vertex Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SelectTool.java 30 Aug 2005 12:59:36 -0000 1.10 --- SelectTool.java 31 Aug 2005 10:31:40 -0000 1.11 *************** *** 47,50 **** --- 47,54 ---- /** the Viewtype */ protected int viewType; + + /** the object corresponding to the mouse */ + protected Object target; + /** *************** *** 76,79 **** --- 80,84 ---- protected void pressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { + target = null; if (selectedVertex != null) { Notification n = new Notification(Notification.VERTEX_DESELECTED, *************** *** 115,118 **** --- 120,124 ---- Object selectObject; selectObject = view.getObjectAtPoint(x, y); + target = selectObject; if (selectObject instanceof Vertex) { Vertex v = (Vertex)selectObject; Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PencilTool.java 31 Aug 2005 08:33:55 -0000 1.7 --- PencilTool.java 31 Aug 2005 10:31:40 -0000 1.8 *************** *** 9,15 **** import java.awt.event.MouseEvent; - import java.util.ArrayList; - import java.util.LinkedList; - import java.util.List; import net.sourceforge.bprocessor.gl.GLView; --- 9,12 ---- *************** *** 27,43 **** public class PencilTool extends SelectTool { - /** The height */ - private int height = 0; - - /** The current number of surfaces */ - private int number = 0; - - /** The current factor */ - private int factor = 0; - - /** The current Edge list */ - protected List edges; - - /** * Constructor --- 24,27 ---- *************** *** 46,87 **** public PencilTool(GLView glv) { super(glv); - edges = new ArrayList(); } /** ! * Create n surfaces to test performance. ! * @param n The number of surfaces to create */ ! void createSurfaces(int n) { ! double coords[] = new double[3]; ! coords[0] = -1; ! coords[1] = height; ! coords[2] = -1; ! Vertex a = createVertex(coords); ! coords[0] = 1; ! coords[1] = height; ! coords[2] = -1; ! Vertex b = createVertex(coords); ! coords[0] = 1; ! coords[1] = height; ! coords[2] = 1; ! Vertex c = createVertex(coords); ! coords[0] = -1; ! coords[1] = height; ! coords[2] = 1; ! height++; ! Vertex d = createVertex(coords); ! Edge e1 = createEdge(a, b); ! Edge e2 = createEdge(b, c); ! Edge e3 = createEdge(c, d); ! Edge e4 = createEdge(d, a); ! LinkedList edges = new LinkedList(); ! edges.add(e1); ! edges.add(e2); ! edges.add(e3); ! edges.add(e4); ! Surface s = createSurface(edges); } /** * Invoked when a mouse button has been pressed on a component. --- 30,48 ---- public PencilTool(GLView glv) { super(glv); } /** ! * Called with the vertex that are clicked on - either: ! * - A vertex on the xy-plane ! * - A vertex in the model ! * - A vertex that lies on an edge from the model ! * - A vertex that lies on a surface from the model ! * @param vertex The vertex */ ! void onVertex(Vertex vertex) { ! System.out.println(vertex); } + /** * Invoked when a mouse button has been pressed on a component. *************** *** 94,106 **** View v = glv.getView(); Transformation transformation = v.transformation(); ! if (selectedVertex != null) { ! System.out.println(selectedVertex); } else { Plane xy = new Plane(0, 0, 1, 0); - Vertex near = new Vertex("near", x, y, 0.0); - Vertex far = new Vertex("far", x, y, 1.0); - Edge ray = new Edge("ray", near, far); - ray = transformation.unProject(ray); Vertex vertex = xy.intersection(ray); } } --- 55,82 ---- View v = glv.getView(); Transformation transformation = v.transformation(); ! Vertex near = new Vertex("near", x, y, 0.0); ! Vertex far = new Vertex("far", x, y, 1.0); ! Edge ray = new Edge("ray", near, far); ! ray = transformation.unProject(ray); ! ! if (target != null) { ! if (target instanceof Vertex) { ! onVertex((Vertex) target); ! } ! if (target instanceof Surface) { ! Surface surface = (Surface) target; ! Plane plane = surface.plane(); ! Vertex vertex = plane.intersection(ray); ! onVertex(vertex); ! } ! if (target instanceof Edge) { ! 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); } } |