Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool PencilTool.java,1.44,1.45
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Nordholt <nor...@us...> - 2005-12-06 16:51:36
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4690 Modified Files: PencilTool.java Log Message: Added construction lines on the snapvertex, construction lines on alignvertex are now aligned to last edge, changed how to make constructor lines and implemented clean up method to clean up any temporary constructor lines Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** PencilTool.java 5 Dec 2005 19:25:38 -0000 1.44 --- PencilTool.java 6 Dec 2005 16:51:25 -0000 1.45 *************** *** 13,16 **** --- 13,17 ---- import java.util.List; import java.util.Set; + import java.util.HashSet; import net.sourceforge.bprocessor.gl.GLView; *************** *** 46,57 **** private Edge zAxis = new Edge("z", new Vertex("", 0, 0, -50), new Vertex("", 0, 0, 50)); ! /**The x axis constructor*/ ! private Edge xConstructor; ! ! /**The y axis constructor*/ ! private Edge yConstructor; ! /**The z axis constructor*/ ! private Edge zConstructor; /** The active */ --- 47,55 ---- private Edge zAxis = new Edge("z", new Vertex("", 0, 0, -50), new Vertex("", 0, 0, 50)); ! /** The constructors from the current vertex */ ! private Set currentConstructors; ! /** The constructors from the snap vertex */ ! private Set snapConstructors; /** The active */ *************** *** 70,73 **** --- 68,74 ---- protected Vertex alignVertex = null; + /** The last align */ + protected Vertex lastAlignVertex = null; + /** The snap vertex */ protected Vertex snapVertex = null; *************** *** 76,80 **** protected Surface exterior = null; - /** The candidates are the Set of surfaces that could be the exterior * for a hole being defined. --- 77,80 ---- *************** *** 166,173 **** */ protected void setAlignVertex(Vertex vertex) { alignVertex = vertex; ! clearXYZConstructors(); if (vertex != null) { ! makeXYZConstructors(vertex); } } --- 166,175 ---- */ protected void setAlignVertex(Vertex vertex) { + lastAlignVertex = alignVertex; alignVertex = vertex; ! clearConstructors(currentConstructors); ! currentConstructors = null; if (vertex != null) { ! currentConstructors = makeXYZConstructors(vertex); } } *************** *** 179,187 **** protected void setSnapVertex(Vertex vertex) { if (vertex != alignVertex) { ! snapVertex = vertex; ! glv.getView().setSnapVertex(vertex); } } /** --- 181,198 ---- protected void setSnapVertex(Vertex vertex) { if (vertex != alignVertex) { ! if (vertex == null || alignVertex == null || ! !(Math.abs(vertex.getX() - alignVertex.getX()) < 0.00001 && ! Math.abs(vertex.getY() - alignVertex.getY()) < 0.00001 && ! Math.abs(vertex.getZ() - alignVertex.getZ()) < 0.00001)) { ! snapVertex = vertex; ! glv.getView().setSnapVertex(vertex); ! clearConstructors(snapConstructors); ! snapConstructors = makeXYZConstructors(vertex); ! } } } + + /** *************** *** 199,236 **** * from a vertex. * @param v the vertex */ ! private void makeXYZConstructors(Vertex v) { ! xConstructor = new Edge("xconst", ! xAxis.getFrom().add(v), ! xAxis.getTo().add(v)); ! xConstructor.setConstructor(true); ! yConstructor = new Edge("yconst", ! yAxis.getFrom().add(v), ! yAxis.getTo().add(v)); ! yConstructor.setConstructor(true); ! zConstructor = new Edge("zconst", ! zAxis.getFrom().add(v), ! zAxis.getTo().add(v)); ! zConstructor.setConstructor(true); ! glv.getView().addTempEdge(xConstructor); ! glv.getView().addTempEdge(yConstructor); ! glv.getView().addTempEdge(zConstructor); } ! /** ! * Removes constructors parralel to the x y and z-axis. */ ! private void clearXYZConstructors() { ! if (xConstructor != null) { ! glv.getView().removeTempEdge(xConstructor); ! xConstructor = null; ! } ! if (yConstructor != null) { ! glv.getView().removeTempEdge(yConstructor); ! yConstructor = null; } ! if (zConstructor != null) { ! glv.getView().removeTempEdge(zConstructor); ! zConstructor = null; } } --- 210,323 ---- * from a vertex. * @param v the vertex + * @return a set of XYZ constructors. */ ! private Set makeXYZConstructors(Vertex v) { ! if (v != null) { ! Edge x = new Edge("xconst", ! xAxis.getFrom().add(v), ! xAxis.getTo().add(v)); ! x.setConstructor(true); ! Edge y = new Edge("yconst", ! yAxis.getFrom().add(v), ! yAxis.getTo().add(v)); ! y.setConstructor(true); ! Edge z = new Edge("zconst", ! zAxis.getFrom().add(v), ! zAxis.getTo().add(v)); ! z.setConstructor(true); ! Set constructors = new HashSet(); ! constructors.add(x); ! constructors.add(y); ! constructors.add(z); ! glv.getView().addTempEdge(x); ! glv.getView().addTempEdge(y); ! glv.getView().addTempEdge(z); ! return constructors; ! } ! return null; } ! /** ! * Makes a set of three constructors where one is aligned with the given edge ! * and all constructors are orthogonal. ! * @param v the vertex ! * @param e the edge ! * @return a set of constructors */ ! private Set makeAlignedConstructors(Vertex v, Edge e) { ! if (v != null && e != null) { ! Vertex minus = e.getTo().minus(e.getFrom()); ! minus.scale(1 / minus.length()); ! minus.scale(50); ! Vertex firstFrom = minus.copy(); ! minus.scale(-1); ! Vertex firstTo = minus.copy(); ! Edge first = new Edge("first", firstFrom, firstTo); ! minus.scale(1 / minus.length()); ! Vertex ortho = new Vertex("ortho", 0, 0, 0); ! if (minus.getX() != 0) { ! if (minus.getY() != 0) { ! if (minus.getX() != 0) { ! ortho.setX(1); ! ortho.setY(-minus.getX() / minus.getY()); ! ortho.setZ(0); ! } else { ! ortho.setZ(1); ! } ! } else { ! ortho.setY(1); ! } ! } else { ! ortho.setX(1); ! } ! ! ortho.scale(1 / ortho.length()); ! ortho.scale(50); ! Vertex secondFrom = ortho.copy(); ! ortho.scale(-1); ! Vertex secondTo = ortho.copy(); ! Edge second = new Edge("second", secondFrom, secondTo); ! ortho.scale(1 / ortho.length()); ! ! Vertex cross = ortho.cross(minus); ! cross.scale(1 / cross.length()); ! cross.scale(50); ! Vertex thirdFrom = cross.copy(); ! cross.scale(-1); ! Vertex thirdTo = cross.copy(); ! Edge third = new Edge("third", thirdFrom, thirdTo); ! ! first.setTo(first.getTo().add(v)); ! first.setFrom(first.getFrom().add(v)); ! second.setTo(second.getTo().add(v)); ! second.setFrom(second.getFrom().add(v)); ! third.setTo(third.getTo().add(v)); ! third.setFrom(third.getFrom().add(v)); ! first.setConstructor(true); ! second.setConstructor(true); ! third.setConstructor(true); ! Set constructors = new HashSet(); ! constructors.add(first); ! constructors.add(second); ! constructors.add(third); ! glv.getView().addTempEdge(first); ! glv.getView().addTempEdge(second); ! glv.getView().addTempEdge(third); ! return constructors; } ! return null; ! } ! ! /** ! * Removes a set of constructors. ! * @param constructors a set of constructors. ! */ ! private void clearConstructors(Set constructors) { ! if (constructors != null) { ! Iterator it = constructors.iterator(); ! while (it.hasNext()) { ! Edge constructor = (Edge)it.next(); ! glv.getView().removeTempEdge(constructor); ! } } } *************** *** 293,296 **** --- 380,386 ---- active.setTo(vertex); intern(active); + + clearConstructors(currentConstructors); + currentConstructors = makeAlignedConstructors(vertex, active); from = vertex; *************** *** 566,570 **** if (target != null) { if (target instanceof Vertex) { ! setSnapVertex((Vertex) target); } } --- 656,661 ---- if (target != null) { if (target instanceof Vertex) { ! Vertex vertex = (Vertex) target; ! setSnapVertex(vertex); } } *************** *** 749,751 **** --- 840,850 ---- return null; } + + /** + * Cleans up any temporary construction lines. + */ + public void cleanUp() { + clearConstructors(currentConstructors); + clearConstructors(snapConstructors); + } } |