[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ExtrudeTool.java,1.16,1.17
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-04-10 15:34:22
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31474/src/net/sourceforge/bprocessor/gl/tool Modified Files: ExtrudeTool.java Log Message: Now the extrude tool have both click-click and drag mouse support Index: ExtrudeTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrudeTool.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ExtrudeTool.java 10 Apr 2006 07:55:09 -0000 1.16 --- ExtrudeTool.java 10 Apr 2006 15:34:19 -0000 1.17 *************** *** 33,36 **** --- 33,48 ---- static final boolean LIMIT = false; + /** If the mode has not been decided */ + static final int UNDICIDED = 0; + + /** If the input mode is dragging */ + static final int DRAG_MODE = 1; + + /** If the input mode is press - press */ + static final int MOVE_MODE = 2; + + /** Tool mode */ + private int mode = UNDICIDED; + /** The dragSurface */ private Surface top; *************** *** 91,111 **** */ protected void pressed(MouseEvent e) { - cleanUp(); prevX = e.getX(); prevY = e.getY(); ! findTarget(e); ! ! if (target instanceof Surface) { ! sides = new HashSet(); ! extrudeSurface = (Surface) target; ! View view = glv.getView(); ! Transformation trans = view.transformation(); ! double x = prevX; ! double y = View.getHeight() - prevY; ! Vertex near = new Vertex(x, y, 0.0); ! Vertex far = new Vertex(x, y, 1.0); ! Edge ray = new Edge(near, far); ! ray = trans.unProject(ray); ! dragplane = extrudeSurface.plane().orthogonalPlane(ray); } } --- 103,129 ---- */ protected void pressed(MouseEvent e) { prevX = e.getX(); prevY = e.getY(); ! if (mode == UNDICIDED) { ! cleanUp(); ! findTarget(e); ! if (target instanceof Surface) { ! sides = new HashSet(); ! extrudeSurface = (Surface) target; ! View view = glv.getView(); ! Transformation trans = view.transformation(); ! double x = prevX; ! double y = View.getHeight() - prevY; ! Vertex near = new Vertex(x, y, 0.0); ! Vertex far = new Vertex(x, y, 1.0); ! Edge ray = new Edge(near, far); ! ray = trans.unProject(ray); ! dragplane = extrudeSurface.plane().orthogonalPlane(ray); ! mode = MOVE_MODE; ! } ! } else { ! if (mode == MOVE_MODE) { ! finishExtrusion(); ! } } } *************** *** 171,174 **** --- 189,193 ---- sides = null; } + mode = UNDICIDED; } *************** *** 185,188 **** --- 204,208 ---- length = -length; } + t = length; top = extrudeSurface.extrude(length, sides); if (extrudeAll) { *************** *** 210,220 **** */ private void finishExtrusion() { ! holeAnalysis(top); ! Iterator iter = sides.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! holeAnalysis(current); } ! Project.getInstance().checkpoint(); } --- 230,245 ---- */ private void finishExtrusion() { ! if (Math.abs(t) > 0.00000001) { ! holeAnalysis(top); ! Iterator iter = sides.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! holeAnalysis(current); ! } ! Project.getInstance().checkpoint(); ! } else { ! removeExtrusion(); } ! mode = UNDICIDED; } *************** *** 304,318 **** */ protected void moved(MouseEvent e) { ! findTarget(e); ! if (target instanceof Surface) { ! glv.getView().makeTarget(target); } } ! /** ! * Invoked when the mouse is held pressed and moved ! * @param e The MouseEvent object */ ! protected void dragged(MouseEvent e) { if (extrudeSurface != null) { Vertex normal; --- 329,347 ---- */ protected void moved(MouseEvent e) { ! if (mode == UNDICIDED) { ! findTarget(e); ! if (target instanceof Surface) { ! glv.getView().makeTarget(target); ! } ! } else if (mode == MOVE_MODE) { ! doThing(e); } } ! /** ! * Do the common extrusion check / extrusion ! * @param e The event */ ! private void doThing(MouseEvent e) { if (extrudeSurface != null) { Vertex normal; *************** *** 393,396 **** --- 422,438 ---- } } + + /** + * Invoked when the mouse is held pressed and moved + * @param e The MouseEvent object + */ + protected void dragged(MouseEvent e) { + if (Math.abs(prevX - e.getX()) + Math.abs(prevY - e.getY()) > 10) { + mode = DRAG_MODE; + } + if (mode == DRAG_MODE) { + doThing(e); + } + } /** *************** *** 399,405 **** */ protected void released(MouseEvent e) { ! if (Math.abs(t) < 0.0000001) { ! removeExtrusion(); ! } else { finishExtrusion(); } --- 441,445 ---- */ protected void released(MouseEvent e) { ! if (mode == DRAG_MODE) { finishExtrusion(); } *************** *** 447,450 **** --- 487,493 ---- number = number.substring(0, length - 1); } + } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + removeExtrusion(); + cleanUp(); } } |