[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractTool.java,1.23,1.24 PencilTool
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-10-30 15:55:59
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19988/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java PencilTool.java Log Message: Improved hit detection of vertices Uses different colors for back and front of surfaces in LIGHTING_MODE Added snap-functionality in PencilTool when drawing holes on surfaces Length is now millimeter (because the . is not accepted in length field) Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PencilTool.java 28 Oct 2005 12:15:55 -0000 1.28 --- PencilTool.java 30 Oct 2005 15:55:40 -0000 1.29 *************** *** 17,20 **** --- 17,21 ---- import net.sourceforge.bprocessor.gl.view.Transformation; import net.sourceforge.bprocessor.gl.view.View; + import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Plane; *************** *** 53,56 **** --- 54,58 ---- protected Surface exterior = null; + /** The candidates are the Set of surfaces that could be the exterior * for a hole being defined. *************** *** 245,248 **** --- 247,273 ---- /** + * Snaps within a coordinate system + * @param system The coordinate system + * @param vertex The vertex to snap + */ + protected void snapInSystem(CoordinateSystem system, Vertex vertex) { + if (alignVertex != null) { + Vertex v1 = system.translate(alignVertex); + Vertex v2 = system.translate(vertex); + // It should be the case that v1.z = v2.z = 0.0 + if (Math.abs(v1.getX() - v2.getX()) < 0.3) { + v2.setX(v1.getX()); + } + if (Math.abs(v1.getY() - v2.getY()) < 0.3) { + v2.setY(v1.getY()); + } + v2 = system.unTranslate(v2); + vertex.setX(v2.getX()); + vertex.setY(v2.getY()); + vertex.setZ(v2.getZ()); + } + } + + /** * Set current vertex to an appropriate vertex * @param event The MouseEvent *************** *** 260,263 **** --- 285,289 ---- Edge ray = new Edge("ray", near, far); ray = transformation.unProject(ray); + CoordinateSystem system = null; if (target != null) { *************** *** 269,272 **** --- 295,299 ---- Plane plane = surface.plane(); Vertex vertex = plane.intersection(ray); + system = surface.coordinateSystem(); vertex.setName("current"); current = vertex; *************** *** 279,282 **** --- 306,312 ---- } } + if (exterior != null) { + system = exterior.coordinateSystem(); + } } if (target instanceof Edge) { *************** *** 299,302 **** --- 329,338 ---- if (snap) { snap(current); + } else { + if (legal) { + if (system != null) { + snapInSystem(system, current); + } + } } Set vertices = Project.getInstance().findByLocation *************** *** 420,424 **** if (current != null) { Vertex temp = new Vertex("temp", to.getX(), to.getY(), to.getZ()); ! active.setLength(d); current.setX(to.getX()); current.setY(to.getY()); --- 456,460 ---- if (current != null) { Vertex temp = new Vertex("temp", to.getX(), to.getY(), to.getZ()); ! active.setLength(d / 1000); current.setX(to.getX()); current.setY(to.getY()); *************** *** 449,453 **** if (active != null) { double d = Double.parseDouble(number); ! glv.setLength(d); } } catch (NumberFormatException exp) { --- 485,489 ---- if (active != null) { double d = Double.parseDouble(number); ! glv.setLength(d / 1000); } } catch (NumberFormatException exp) { Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** AbstractTool.java 21 Oct 2005 11:57:10 -0000 1.23 --- AbstractTool.java 30 Oct 2005 15:55:40 -0000 1.24 *************** *** 164,167 **** --- 164,172 ---- */ public void mouseMoved(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + + AbstractTool.dx = x - pressPos[0]; + AbstractTool.dy = y - pressPos[1]; moved(e); glv.repaint(true); *************** *** 197,206 **** pressPos[0] = e.getX(); pressPos[1] = e.getY(); ! int rotamask = InputEvent.ALT_DOWN_MASK; ! if (currentButton == MouseEvent.BUTTON3 || (e.getModifiersEx() & rotamask) == rotamask) { timer.addActionListener(moveAction); ! } ! ! pressed(e); glv.repaint(true); } --- 202,211 ---- pressPos[0] = e.getX(); pressPos[1] = e.getY(); ! int rotamask = InputEvent.CTRL_DOWN_MASK; ! if (currentButton == MouseEvent.BUTTON3 || e.isControlDown()) { timer.addActionListener(moveAction); ! } else { ! pressed(e); ! } glv.repaint(true); } |