Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool Protractor.java, 1.3, 1.4 TapeMeasure
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-08-03 15:41:23
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10934/src/net/sourceforge/bprocessor/gl/tool Modified Files: Protractor.java TapeMeasureTool.java Log Message: changed the tools to create constructors instead of edges Index: TapeMeasureTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/TapeMeasureTool.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** TapeMeasureTool.java 14 Jun 2006 14:36:56 -0000 1.16 --- TapeMeasureTool.java 3 Aug 2006 14:27:52 -0000 1.17 *************** *** 14,20 **** import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Vertex; - import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.gl.GLView; --- 14,21 ---- import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.Line; import net.sourceforge.bprocessor.model.Project; + import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.gl.GLView; *************** *** 33,40 **** /** The current construction edge */ ! private Edge currentConstruction; /** The construction edge point */ private Vertex constructionPoint; /** --- 34,44 ---- /** The current construction edge */ ! private Line currentConstruction; /** The construction edge point */ private Vertex constructionPoint; + + /** The chosen movement direction of the construction line */ + private Vertex lockDirection; /** *************** *** 65,81 **** private void move() { if (start != null) { ! Vertex direction = currentEdge.getDirection(); ! Vertex origin = start.vertex(); ! Plane plane = new Plane (direction.getX(), direction.getY(), direction.getZ(), ! -(direction.getX() * origin.getX() + ! direction.getY() * origin.getY() + ! direction.getZ() * origin.getZ())); ! Vertex currentPos = plane.project(current.vertex()); ! direction.scale(origin.dot(direction) / (direction.length() * direction.length())); ! currentPos = currentPos.add(direction); ! Vertex move = currentPos.minus(constructionPoint); ! ! currentConstruction.move(move.getX(), move.getY(), move.getZ()); ! constructionPoint.move(move.getX(), move.getY(), move.getZ()); } } --- 69,87 ---- private void move() { if (start != null) { ! if (lockDirection != null) { ! Vertex tmp = current.vertex().minus(start.vertex()); ! Vertex move = tmp.projectOnto(lockDirection); ! Vertex where = start.vertex().add(move); ! move = where.minus(constructionPoint); ! constructionPoint.move(move.getX(), move.getY(), move.getZ()); ! } else { ! if (current.object() instanceof Surface && ! currentEdge.getSurfaces().contains(current.object())) { ! Surface surface = (Surface)current.object(); ! plane = surface.plane(); ! lockDirection = surface.normal().cross(currentEdge.getDirection()); ! lockDirection.normalize(); ! } ! } } } *************** *** 96,117 **** if (current != null && current.object() instanceof Edge) { start = current; ! currentEdge = (Edge)current.object(); ! 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); constructionPoint = start.vertex().copy(); } } else { --- 102,110 ---- if (current != null && current.object() instanceof Edge) { start = current; ! currentEdge = (Edge)current.object(); constructionPoint = start.vertex().copy(); + currentConstruction = + new Line(constructionPoint, currentEdge.getDirection(), true, false); + } } else { *************** *** 129,134 **** consts.add(currentConstruction); Edge edge = new Edge(start.vertex(), constructionPoint); ! edge.setConstructor(true); ! glv.setLength(edge.getFrom().minus(edge.getTo()).length()); consts.add(edge); constructors(consts); --- 122,127 ---- consts.add(currentConstruction); Edge edge = new Edge(start.vertex(), constructionPoint); ! edge.setStrippled(true); ! glv.setLength(edge.getLength()); consts.add(edge); constructors(consts); *************** *** 152,161 **** private void endTapeMeasure() { if (currentConstruction != null) { ! insertEdge(currentConstruction, false); ! currentEdge = null; constructors(new LinkedList()); excluded(new LinkedList()); Project.getInstance().checkpoint(); start = null; glv.repaint(); } --- 145,155 ---- private void endTapeMeasure() { if (currentConstruction != null) { ! currentConstruction.setEditable(true); ! insertConstructor(currentConstruction); constructors(new LinkedList()); excluded(new LinkedList()); Project.getInstance().checkpoint(); start = null; + lockDirection = null; glv.repaint(); } *************** *** 169,194 **** 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(); } --- 163,170 ---- number = ""; ! if (currentConstruction != null) { if (start != null) { ! Edge e = new Edge(start.vertex(), constructionPoint); ! e.setLength(length); endTapeMeasure(); } Index: Protractor.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Protractor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Protractor.java 29 Mar 2006 13:18:29 -0000 1.3 --- Protractor.java 3 Aug 2006 14:27:52 -0000 1.4 *************** *** 14,19 **** import net.sourceforge.bprocessor.gl.GLView; ! import net.sourceforge.bprocessor.model.Edge; ! import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Vertex; --- 14,18 ---- import net.sourceforge.bprocessor.gl.GLView; ! import net.sourceforge.bprocessor.model.Line; import net.sourceforge.bprocessor.model.Vertex; *************** *** 22,27 **** */ public class Protractor extends AbstractPencil { - /** angling */ - private boolean angling; /** --- 21,24 ---- *************** *** 38,51 **** * @param start From * @param end To ! * @return Edge */ ! protected Edge createConstructor(Vertex start, Vertex end) { ! Vertex vector = current.vertex().minus(start); ! vector.scale(50 / vector.length()); ! Vertex from = start.minus(vector); ! Vertex to = start.add(vector); ! Edge edge = new Edge(from, to); ! edge.setConstructor(true); ! return edge; } /** --- 35,42 ---- * @param start From * @param end To ! * @return Line */ ! protected Line createConstructor(Vertex start, Vertex end) { ! return new Line(start, end.minus(start), true, true); } /** *************** *** 56,69 **** if (start != null) { List edges = new LinkedList(); ! Edge edge; ! if (angling) { ! edge = createConstructor(start.vertex(), current.vertex()); ! } else { ! edge = new Edge(start.vertex(), current.vertex()); ! edge.setConstructor(true); ! } ! edges.add(edge); feedback(edges); } else { --- 47,55 ---- if (start != null) { List edges = new LinkedList(); ! Line l; ! l = createConstructor(start.vertex(), current.vertex()); ! edges.add(l); feedback(edges); } else { *************** *** 91,105 **** start = current; } else { ! if (angling) { ! Edge edge = createConstructor(start.vertex(), current.vertex()); ! Project.getInstance().add(edge.getFrom()); ! Project.getInstance().add(edge.getTo()); ! Project.getInstance().add(edge); ! Project.getInstance().checkpoint(); ! start = null; ! angling = false; ! } else { ! angling = true; ! } } updateFeedback(); --- 77,83 ---- start = current; } else { ! Line l = createConstructor(start.vertex(), current.vertex()); ! insertConstructor(l); ! start = null; } updateFeedback(); *************** *** 118,121 **** protected void released(MouseEvent e) { } - } --- 96,98 ---- |