Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool VectorMoveStrategy.java, 1.3, 1.4 Tap
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-06-14 14:37:04
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26728/src/net/sourceforge/bprocessor/gl/tool Modified Files: VectorMoveStrategy.java TapeMeasureTool.java ControlledMoveStrategy.java AbstractPencil.java Log Message: Fixed bug in tape-measure handling of length-field. Steps towards general handling of length-field Index: TapeMeasureTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/TapeMeasureTool.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** TapeMeasureTool.java 15 May 2006 08:37:44 -0000 1.15 --- TapeMeasureTool.java 14 Jun 2006 14:36:56 -0000 1.16 *************** *** 12,16 **** import java.awt.Cursor; import java.awt.event.MouseEvent; - import java.awt.event.KeyEvent; import net.sourceforge.bprocessor.model.Edge; --- 12,15 ---- *************** *** 135,138 **** --- 134,138 ---- constructors(consts); excluded(consts); + glv.repaint(); } else { super.updateConstructors(); *************** *** 148,160 **** /** - * Invoked when a key has been pressed. - * @param e The KeyEvent - */ - public void keyPressed(KeyEvent e) { - super.keyPressed(e); - //move(); - } - - /** * Ends one tape measure */ --- 148,151 ---- *************** *** 162,172 **** if (currentConstruction != null) { insertEdge(currentConstruction, false); - createEdge(currentConstruction.getFrom(), currentConstruction.getFrom()); currentEdge = null; constructors(new LinkedList()); excluded(new LinkedList()); Project.getInstance().checkpoint(); } } /** * Finish tape measure --- 153,200 ---- if (currentConstruction != null) { insertEdge(currentConstruction, false); currentEdge = null; constructors(new LinkedList()); excluded(new LinkedList()); Project.getInstance().checkpoint(); + start = null; + glv.repaint(); } } + + /** + * @param length The length from the length-field + */ + public void apply(double length) { + log.info("tape-measeure-apply(" + length + ")"); + number = ""; + + if (constructionPoint != null) { + if (start != null) { + Vertex direction = constructionPoint.minus(start.vertex()); + direction.scale(length / direction.length()); + constructionPoint = start.vertex().add(direction); + Vertex minus = currentEdge.getDirection(); + minus.scale(1 / minus.length()); + Vertex constructionFrom = new Vertex ((currentEdge.getFrom().getX() + + minus.getX() * -50), + (currentEdge.getFrom().getY() + + minus.getY() * -50), + (currentEdge.getFrom().getZ() + + minus.getZ() * -50)); + Vertex constructionTo = new Vertex((currentEdge.getTo().getX() + + minus.getX() * 50), + (currentEdge.getTo().getY() + + minus.getY() * 50), + (currentEdge.getTo().getZ() + + minus.getZ() * 50)); + currentConstruction = new Edge(constructionFrom, constructionTo); + currentConstruction.setConstructor(true); + currentConstruction.move(direction.getX(), direction.getY(), direction.getZ()); + endTapeMeasure(); + } + } + + } + /** * Finish tape measure *************** *** 174,179 **** public void onVertex() { move(); ! endTapeMeasure(); ! start = null; } } --- 202,208 ---- public void onVertex() { move(); ! updateConstructors(); ! //endTapeMeasure(); ! //start = null; } } Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** AbstractPencil.java 15 May 2006 14:55:41 -0000 1.31 --- AbstractPencil.java 14 Jun 2006 14:36:56 -0000 1.32 *************** *** 631,634 **** --- 631,660 ---- } + + /** + * Apply current tool with specified length value + * @param length The lengthfield value + */ + public void apply(double length) { + log.info("general-apply(" + length + ")"); + if (current != null) { + Vertex before = null; + if (start != null) { + before = start.vertex(); + } else if (incident != null) { + before = incident.vertex(); + } + if (before != null) { + Vertex v = current.vertex().minus(before); + if (v.length() > 0.000000001) { + v.scale(length / v.length()); + Vertex to = before.add(v); + current = new Intersection(to, Intersection.VERTEX, to); + onVertex(); + number = ""; + } + } + } + } /** *************** *** 744,765 **** try { double d = Double.parseDouble(number); ! if (current != null) { ! Vertex before = null; ! if (start != null) { ! before = start.vertex(); ! } else if (incident != null) { ! before = incident.vertex(); ! } ! if (before != null) { ! Vertex v = current.vertex().minus(before); ! if (v.length() > 0.000000001) { ! v.scale((d / 1000) / v.length()); ! Vertex to = before.add(v); ! current = new Intersection(to, Intersection.VERTEX, to); ! onVertex(); ! number = ""; ! } ! } ! } } catch (NumberFormatException exp) { Project.info(exp); --- 770,774 ---- try { double d = Double.parseDouble(number); ! apply(d / 1000); } catch (NumberFormatException exp) { Project.info(exp); Index: VectorMoveStrategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/VectorMoveStrategy.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** VectorMoveStrategy.java 5 Apr 2006 10:24:56 -0000 1.3 --- VectorMoveStrategy.java 14 Jun 2006 14:36:56 -0000 1.4 *************** *** 15,19 **** import java.awt.event.MouseEvent; import java.awt.Cursor; - import java.awt.event.KeyEvent; --- 15,18 ---- *************** *** 52,67 **** super.moved(e); } - - /** - * Invoked when a key has been pressed. Lets user control the mode of movement. - * After movement in one direction a length can be typed in to adjust the movement - * to a specific length. - * ESCAPE - cancel movement. - * 0-9 - type length in length field. - * ENTER - perform move of the specified length. - * @param e The KeyEvent - */ - public void keyPressed(KeyEvent e) { - super.keyPressed(e); - } } --- 51,53 ---- Index: ControlledMoveStrategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ControlledMoveStrategy.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ControlledMoveStrategy.java 13 Apr 2006 13:36:10 -0000 1.4 --- ControlledMoveStrategy.java 14 Jun 2006 14:36:56 -0000 1.5 *************** *** 25,29 **** import java.awt.event.MouseEvent; import java.awt.Cursor; - import java.awt.event.KeyEvent; import org.apache.log4j.Logger; --- 25,28 ---- *************** *** 323,338 **** } } - - /** - * Invoked when a key has been pressed. Lets user control the mode of movement. - * After movement in one direction a length can be typed in to adjust the movement - * to a specific length. - * ESCAPE - cancel movement. - * 0-9 - type length in length field. - * ENTER - perform move of the specified length. - * @param e The KeyEvent - */ - public void keyPressed(KeyEvent e) { - super.keyPressed(e); - } } --- 322,324 ---- |