[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool PencilTool.java,1.9,1.10 SelectTool.ja
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-09-01 06:05:23
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32458/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java SelectTool.java Log Message: Small improvements to PencilTool Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SelectTool.java 31 Aug 2005 13:14:12 -0000 1.13 --- SelectTool.java 1 Sep 2005 06:05:15 -0000 1.14 *************** *** 80,84 **** */ protected void moved(MouseEvent e) { ! //findTarget(e); } --- 80,84 ---- */ protected void moved(MouseEvent e) { ! findTarget(e); } *************** *** 88,92 **** */ protected void dragged(MouseEvent e) { ! //findTarget(e); } --- 88,92 ---- */ protected void dragged(MouseEvent e) { ! findTarget(e); } Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PencilTool.java 31 Aug 2005 13:14:12 -0000 1.9 --- PencilTool.java 1 Sep 2005 06:05:15 -0000 1.10 *************** *** 38,41 **** --- 38,45 ---- protected Vertex to = null; + /** The current */ + + protected Vertex current = null; + /** The edges */ *************** *** 120,132 **** } } - /** ! * Invoked when a mouse button has been pressed on a component. ! * @param e The MouseEvent object */ ! protected void pressed(MouseEvent e) { ! super.pressed(e); ! double x = e.getX(); ! double y = AbstractView.getHeight() - e.getY(); View v = glv.getView(); Transformation transformation = v.transformation(); --- 124,147 ---- } } /** ! * Round to grid ! * @param value The value ! * @return The rounded value */ ! protected double round(double value) { ! int i = (int) value; ! if (Math.abs(i - value) < 0.2) { ! return Math.round(value); ! } else { ! return value; ! } ! } ! /** ! * Set current vertex to an appropriate vertex ! * @param event Tne MouseEvent ! */ ! protected void findVertex(MouseEvent event) { ! double x = event.getX(); ! double y = AbstractView.getHeight() - event.getY(); View v = glv.getView(); Transformation transformation = v.transformation(); *************** *** 138,142 **** if (target != null) { if (target instanceof Vertex) { ! onVertex((Vertex) target); } if (target instanceof Surface) { --- 153,157 ---- if (target != null) { if (target instanceof Vertex) { ! current = (Vertex) target; } if (target instanceof Surface) { *************** *** 145,149 **** Vertex vertex = plane.intersection(ray); vertex.setName("V" + vertexNum++); ! onVertex(vertex); } if (target instanceof Edge) { --- 160,164 ---- Vertex vertex = plane.intersection(ray); vertex.setName("V" + vertexNum++); ! current = vertex; } if (target instanceof Edge) { *************** *** 152,156 **** Vertex vertex = intersection.getFrom(); vertex.setName("V" + vertexNum++); ! onVertex(vertex); } } else { --- 167,171 ---- Vertex vertex = intersection.getFrom(); vertex.setName("V" + vertexNum++); ! current = vertex; } } else { *************** *** 158,164 **** Vertex vertex = xy.intersection(ray); vertex.setName("V" + vertexNum++); ! onVertex(vertex); } } /** * Invoked when the mouse cursor has been moved --- 173,193 ---- Vertex vertex = xy.intersection(ray); vertex.setName("V" + vertexNum++); ! current = vertex; ! } ! if (current.getId() == null) { ! current.setX(round(current.getX())); ! current.setY(round(current.getY())); ! current.setZ(round(current.getZ())); } } + + /** + * Invoked when a mouse button has been pressed on a component. + * @param e The MouseEvent object + */ + protected void pressed(MouseEvent e) { + super.pressed(e); + onVertex(current); + } /** * Invoked when the mouse cursor has been moved *************** *** 166,177 **** */ protected void moved(MouseEvent e) { ! int x = e.getX(); ! 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]); } } --- 195,204 ---- */ protected void moved(MouseEvent e) { ! super.moved(e); ! findVertex(e); if (to != null) { ! to.setX(current.getX()); ! to.setY(current.getY()); ! to.setZ(current.getZ()); } } |