[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool MoveTool.java,1.12,1.13
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-09-20 17:25:36
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9655 Modified Files: MoveTool.java Log Message: added cancel on ESC and corrected calculation of a ray Index: MoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** MoveTool.java 20 Sep 2005 12:43:33 -0000 1.12 --- MoveTool.java 20 Sep 2005 17:25:26 -0000 1.13 *************** *** 8,12 **** import net.sourceforge.bprocessor.gl.GLView; ! import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.gl.view.Transformation; --- 8,12 ---- import net.sourceforge.bprocessor.gl.GLView; ! import net.sourceforge.bprocessor.gl.view.AbstractView; import net.sourceforge.bprocessor.gl.view.Transformation; *************** *** 43,51 **** private Vertex initial; /** The previous X coordinate */ ! private int previousX = 0; /** The previous Y cordinate */ ! private int previousY = 0; /** The plane to drag according to */ --- 43,57 ---- private Vertex initial; + /** The parent location (total drag) */ + private Vertex parentPos; + + /** The location to move from */ + private Vertex from; + /** The previous X coordinate */ ! private double previousX = 0; /** The previous Y cordinate */ ! private double previousY = 0; /** The plane to drag according to */ *************** *** 70,93 **** if (target != null) { ! dragPlane = findMovePlane(); initial = glv.getView().toPlaneCoords(new double[] {previousX, previousY}, dragPlane); } - log.info("plane: " + dragPlane); } /** * Finds the plan to move the element on * @return The movement plane */ ! protected Plane findMovePlane() { Plane temp = null; //indicating wherther or not we are moving an inner surface boolean inner = false; ! if (target instanceof Vertex) { ! temp = new Plane(0, 0, 1, 0); ! } else if (target instanceof Edge) { ! temp = new Plane(0, 0, 1, 0); ! } else if (target instanceof Surface) { ! Surface sel = (Surface)target; inner = sel.getIsInner(); temp = sel.plane(); --- 76,101 ---- if (target != null) { ! dragPlane = findMovePlane(target); initial = glv.getView().toPlaneCoords(new double[] {previousX, previousY}, dragPlane); + parentPos = new Vertex("parent", initial.getX(), initial.getY(), initial.getZ()); + from = new Vertex("from", initial.getX(), initial.getY(), initial.getZ()); } } /** * Finds the plan to move the element on + * @param o The object to find a plane for * @return The movement plane */ ! protected Plane findMovePlane(Object o) { Plane temp = null; //indicating wherther or not we are moving an inner surface boolean inner = false; ! if (o instanceof Vertex) { ! temp = new Plane(0, 0, 1, -((Vertex)o).getZ()); ! } else if (o instanceof Edge) { ! temp = new Plane(0, 0, 1, -((Edge)o).getTo().getZ()); ! } else if (o instanceof Surface) { ! Surface sel = (Surface)o; inner = sel.getIsInner(); temp = sel.plane(); *************** *** 96,101 **** if (moveMode == XZ && !inner) { Transformation trans = glv.getView().transformation(); ! int x = previousX; ! int y = previousY; Vertex near = new Vertex("near", x, y, 0.0); Vertex far = new Vertex("far", x, y, 1.0); --- 104,109 ---- if (moveMode == XZ && !inner) { Transformation trans = glv.getView().transformation(); ! double x = previousX; ! double y = AbstractView.getHeight() - previousY; Vertex near = new Vertex("near", x, y, 0.0); Vertex far = new Vertex("far", x, y, 1.0); *************** *** 114,119 **** --- 122,129 ---- super.released(e); + from = null; initial = null; dragPlane = null; + parentPos = null; } *************** *** 126,141 **** int x = e.getX(); int y = e.getY(); ! ! View view = glv.getView(); ! Vertex from = view.toPlaneCoords(new double[] {previousX, previousY}, dragPlane); ! Vertex to = view.toPlaneCoords(new double[] {x, y}, dragPlane); ! Vertex delta = to.minus(from); if (log.isDebugEnabled()) { log.debug("from " + from.getX() + ", " + from.getY() + ", " + from.getZ()); - log.debug("to " + to.getX() + ", " + to.getY() + ", " + to.getZ()); log.debug("delta " + delta.getX() + ", " + delta.getY() + ", " + delta.getZ()); } move(selection, delta); ! glv.setLength(to.minus(initial).length()); } --- 136,162 ---- int x = e.getX(); int y = e.getY(); ! ! parentPos = glv.getView().toPlaneCoords(new double[] {x, y}, dragPlane); ! Vertex delta = parentPos.minus(from); if (log.isDebugEnabled()) { log.debug("from " + from.getX() + ", " + from.getY() + ", " + from.getZ()); log.debug("delta " + delta.getX() + ", " + delta.getY() + ", " + delta.getZ()); } + + Vertex v = initial.minus(parentPos); + Vertex appr = initial.minus(from); + if (Math.abs(v.getX()) < .25) { + delta.setX(appr.getX()); + } + if (Math.abs(v.getY()) < .25) { + delta.setY(appr.getY()); + } + if (Math.abs(v.getZ()) < .25) { + delta.setZ(appr.getZ()); + } + move(selection, delta); ! from.move(delta.getX(), delta.getY(), delta.getZ()); ! glv.setLength(from.minus(initial).length()); } *************** *** 172,181 **** moveMode = XY; if (target != null) { ! dragPlane = findMovePlane(); } } else if (e.getKeyCode() == KeyEvent.VK_S) { moveMode = XZ; if (target != null) { ! dragPlane = findMovePlane(); } } else { --- 193,207 ---- moveMode = XY; if (target != null) { ! dragPlane = findMovePlane(target); } } else if (e.getKeyCode() == KeyEvent.VK_S) { moveMode = XZ; if (target != null) { ! dragPlane = findMovePlane(target); ! } ! } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { ! if (dragPlane != null) { ! dragPlane = null; ! move(selection, initial.minus(parentPos)); } } else { |