[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool MoveTool.java,1.46,1.47
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-03-20 23:18:14
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23119 Modified Files: MoveTool.java Log Message: hoover aligning in vector movement mode Index: MoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** MoveTool.java 12 Mar 2006 21:10:29 -0000 1.46 --- MoveTool.java 20 Mar 2006 23:18:09 -0000 1.47 *************** *** 32,35 **** --- 32,37 ---- import java.util.List; import java.util.LinkedList; + import java.util.Timer; + import java.util.TimerTask; import org.apache.log4j.Logger; *************** *** 54,57 **** --- 56,62 ---- public static final int CONTROLLED = 3; + /** The goemetry based movement mode */ + public static final int GEOMETRY = 4; + /** The initial movepoint */ private Vertex initial; *************** *** 90,102 **** private Entity snapEntity; ! /** The Collection of entities being moved */ private Collection moveEntities; - /** Sliding edge of the to point */ - private Edge toSlideEdge; - - /** Sliding edge of the from point */ - private Edge fromSlideEdge; - /** * Mapping from each vertex being moved, --- 95,101 ---- private Entity snapEntity; ! /** The Collection of entities being moved*/ private Collection moveEntities; /** * Mapping from each vertex being moved, *************** *** 108,111 **** --- 107,113 ---- /** The entity being moved in a controlled way */ private Entity controlled; + + /** The aligning edge */ + private Edge alignEdge; /** *************** *** 119,125 **** restrictionVector = null; snapEntity = null; ! toSlideEdge = null; ! fromSlideEdge = null; ! slideMap = null; numberOfClicks = 1; moveMode = AXIS_RESTRICTED; --- 121,126 ---- restrictionVector = null; snapEntity = null; ! alignEdge = null; ! slideMap = new HashMap(); numberOfClicks = 1; moveMode = AXIS_RESTRICTED; *************** *** 188,192 **** } ! /** Talking care of the three-click mode * @param e the MouseEvent object */ --- 189,193 ---- } ! /** Taking care of the three-click mode * @param e the MouseEvent object */ *************** *** 206,209 **** --- 207,214 ---- glv.getView().removeTempEdge(threeClickConst); threeClickConst = null; + if (alignEdge != null) { + glv.getView().removeTempEdge(alignEdge); + alignEdge = null; + } update(); numberOfClicks = 1; *************** *** 226,233 **** /** ! * Finds the initial point clicked for movement. ! * @param entity the entity initialy clicked * @param e the mouse event associated with the click. ! * @return the initial point of movement. */ protected Vertex findInitial(Object entity, MouseEvent e) { --- 231,238 ---- /** ! * Finds the point clicked. ! * @param entity the entity clicked * @param e the mouse event associated with the click. ! * @return the point. */ protected Vertex findInitial(Object entity, MouseEvent e) { *************** *** 271,276 **** restrictionVector = null; dragPlane = null; - toSlideEdge = null; - fromSlideEdge = null; number = ""; } --- 276,279 ---- *************** *** 281,293 **** */ protected void moved(MouseEvent e) { ! findTarget(e); ! glv.getView().makeTarget(target); ! if (moveMode == THREE_CLICK && threeClickConst != null) { if (target != null) { Vertex to = findInitial(target, e); if (to != null) { threeClickConst.setTo(to); } } } } --- 284,332 ---- */ protected void moved(MouseEvent e) { ! boolean showAlign = false; ! if (moveMode == THREE_CLICK && threeClickConst != null) { ! moveConstructors = makeXYZConerConstructors(new Vertex(0, 0, 0)); ! displayConstructors(moveConstructors); ! glv.getView().removeTempEdge(threeClickConst); ! if (alignEdge != null) { ! glv.getView().addTempEdge(alignEdge); ! } ! ! findTarget(e); ! glv.getView().makeTarget(target); if (target != null) { Vertex to = findInitial(target, e); + if (target instanceof Edge) { + Edge targetEdge = (Edge)target; + if (!targetEdge.equals(alignEdge)) { + Timer alignTimer = new Timer(); + TimerTask alignTask = new AlignTask(targetEdge); + alignTimer.schedule(alignTask, 300); + } + if (alignEdge != null) { + Vertex alignDir = alignEdge.getDirection(); + Vertex targetDir = targetEdge.getDirection(); + Vertex dirCross = alignDir.cross(targetDir); + showAlign = dirCross.length() < 0.000001; + } + } + if (to != null) { threeClickConst.setTo(to); } + } else { + threeClickConst.setTo(from); + } + + if (threeClickConst != null) { + glv.getView().addTempEdge(threeClickConst); } + if (!showAlign) { + glv.getView().removeTempEdge(alignEdge); + } + clearConstructors(moveConstructors); + } else { + findTarget(e); + glv.getView().makeTarget(target); } } *************** *** 426,430 **** } } else if (moveMode == CONTROLLED && controlled != null) { ! if (toSlideEdge == null && fromSlideEdge == null) { findTarget(e); if (controlled instanceof Edge) { --- 465,469 ---- } } else if (moveMode == CONTROLLED && controlled != null) { ! if (slideMap.isEmpty()) { findTarget(e); if (controlled instanceof Edge) { *************** *** 454,457 **** --- 493,498 ---- rightEdge = (Edge)edges.get(index + 1); } + Edge toSlideEdge = null; + Edge fromSlideEdge = null; if (controlledDir.cross(leftEdge.getDirection()).length() > 0.00001 && controlledDir.cross(rightEdge.getDirection()).length() > 0.00001) { *************** *** 462,469 **** toSlideEdge = leftEdge; fromSlideEdge = rightEdge; ! } else if (from.getEdges().contains(leftEdge) && to.getEdges().contains(rightEdge)) { fromSlideEdge = leftEdge; ! toSlideEdge = rightEdge; } slideMap = new HashMap(); --- 503,510 ---- toSlideEdge = leftEdge; fromSlideEdge = rightEdge; ! } else if (from.getEdges().contains(leftEdge) && to.getEdges().contains(rightEdge)) { fromSlideEdge = leftEdge; ! toSlideEdge = rightEdge; } slideMap = new HashMap(); *************** *** 486,491 **** restrictionVector = targetEdge.getDirection(); findRestrictionPlane(); - fromSlideEdge = targetEdge; - toSlideEdge = targetEdge; } } else if (controlled instanceof Surface) { --- 527,530 ---- *************** *** 702,710 **** move(vertices, initial.minus(from)); } - } else if (e.getKeyCode() == KeyEvent.VK_M) { - if (dragPlane == null) { - moveMode = (moveMode + 1) % 3; - } - numberOfClicks = 1; } else if (lastRestriction != null && initial != null && --- 741,744 ---- *************** *** 775,777 **** --- 809,849 ---- moveMode = mode; } + + /** + * Class for handeling the task of assigning an alignedge. + */ + private class AlignTask extends TimerTask { + /** The edge candidate to become the alignedge */ + private Edge candidateEdge; + + /** + * Constructor + * @param candidate the candidate to become alignedge + */ + public AlignTask(Edge candidate) { + super(); + candidateEdge = candidate; + } + + /** + * checks if the target is still the same edge, + * thus making it the alignedge + */ + public void run() { + if (target instanceof Edge) { + candidateEdge.equals((Edge)target); + + Vertex direction = candidateEdge.getDirection(); + Vertex alignTo = direction.copy(); + Vertex alignFrom = direction.copy(); + alignFrom.scale(-1000); + alignTo.scale(1000); + glv.getView().removeTempEdge(alignEdge); + alignEdge = new Edge(alignFrom.add(from), alignTo.add(from)); + alignEdge.setConstructor(true); + glv.getView().addTempEdge(alignEdge); + glv.repaint(true); + } + } + } } |