Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractTool.java,1.47,1.48 PencilTool
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-01-10 14:02:04
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17461 Modified Files: AbstractTool.java PencilTool.java Log Message: refactored the way temporary constructors work to make them work in movetool as well Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** PencilTool.java 29 Dec 2005 14:20:41 -0000 1.54 --- PencilTool.java 10 Jan 2006 14:01:48 -0000 1.55 *************** *** 36,48 **** /** The logger */ private static Logger log = Logger.getLogger(PencilTool.class); - - /** The x axis */ - private Edge xAxis = new Edge(new Vertex(-50, 0, 0), new Vertex(50, 0, 0)); - - /** The y axis */ - private Edge yAxis = new Edge(new Vertex(0, -50, 0), new Vertex(0, 50, 0)); - - /**The z axis */ - private Edge zAxis = new Edge(new Vertex(0, 0, -50), new Vertex(0, 0, 50)); /** The constructors from the current vertex */ --- 36,39 ---- *************** *** 50,57 **** /** The constructors from the snap vertex */ ! private Set snapConstructors; ! ! /** Whether to show the constructors */ ! private boolean showConstructors; /** The plane currently drawn in */ --- 41,45 ---- /** The constructors from the snap vertex */ ! private Set snapConstructors; /** The plane currently drawn in */ *************** *** 226,258 **** } - /** - * Makes constructors parralel to the x y and z-axis, originating - * 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(xAxis.getFrom().add(v), - xAxis.getTo().add(v)); - x.setConstructor(true); - Edge y = new Edge(yAxis.getFrom().add(v), - yAxis.getTo().add(v)); - y.setConstructor(true); - Edge z = new Edge(zAxis.getFrom().add(v), - zAxis.getTo().add(v)); - z.setConstructor(true); - Set constructors = new HashSet(); - constructors.add(x); - constructors.add(y); - constructors.add(z); - if (showConstructors) { - displayConstructors(constructors); - } - return constructors; - } - return null; - } - /** * Makes a set of three constructors where one is aligned with the given edge --- 214,217 ---- *************** *** 377,408 **** /** - * 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); - } - } - } - - /** - * Makes a set of constructors be displayed. - * @param constructors a set of constructors. - */ - private void displayConstructors(Set constructors) { - if (constructors != null) { - Iterator it = constructors.iterator(); - while (it.hasNext()) { - Edge constructor = (Edge)it.next(); - glv.getView().addTempEdge(constructor); - } - } - } - - /** * Called with the vertex that are clicked on - either: * - A vertex on the xy-plane --- 336,339 ---- Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** AbstractTool.java 6 Jan 2006 15:36:14 -0000 1.47 --- AbstractTool.java 10 Jan 2006 14:01:48 -0000 1.48 *************** *** 29,32 **** --- 29,33 ---- import java.util.Iterator; import java.util.Set; + import java.util.HashSet; import java.util.Collection; *************** *** 38,41 **** --- 39,51 ---- /** The logger */ private static Logger log = Logger.getLogger(AbstractTool.class); + + /** The x axis */ + protected Edge xAxis = new Edge(new Vertex(-50, 0, 0), new Vertex(50, 0, 0)); + + /** The y axis */ + protected Edge yAxis = new Edge(new Vertex(0, -50, 0), new Vertex(0, 50, 0)); + + /**The z axis */ + protected Edge zAxis = new Edge(new Vertex(0, 0, -50), new Vertex(0, 0, 50)); /** The mouse position last time the mouse was pressed initializes to (0,0) */ *************** *** 75,80 **** protected Cursor cursor; /** The cursor for drag */ ! private Cursor dragCursor; static { --- 85,94 ---- protected Cursor cursor; + /** Whether to show the temporary constructors */ + protected boolean showConstructors; + /** The cursor for drag */ ! private Cursor dragCursor; ! static { *************** *** 556,560 **** } } ! } /** --- 570,660 ---- } } ! } ! ! /** ! * Makes constructors parralel to the x y and z-axis, originating ! * from a vertex. ! * @param v the vertex ! * @return a set of XYZ constructors. ! */ ! protected Set makeXYZConstructors(Vertex v) { ! if (v != null) { ! Edge x = new Edge(xAxis.getFrom().add(v), ! xAxis.getTo().add(v)); ! x.setConstructor(true); ! Edge y = new Edge(yAxis.getFrom().add(v), ! yAxis.getTo().add(v)); ! y.setConstructor(true); ! Edge z = new Edge(zAxis.getFrom().add(v), ! zAxis.getTo().add(v)); ! z.setConstructor(true); ! Set constructors = new HashSet(); ! constructors.add(x); ! constructors.add(y); ! constructors.add(z); ! if (showConstructors) { ! displayConstructors(constructors); ! } ! return constructors; ! } ! return null; ! } ! ! /** ! * Makes constructors parrallel to the edges connected to a vertex. ! * @param v the vertex ! * @return a set of constructors. ! */ ! protected Set makeEdgeConstructors(Vertex v) { ! Set constructors = new HashSet(); ! Set edges = v.getEdges(); ! Iterator it = edges.iterator(); ! while (it.hasNext()) { ! Edge e = (Edge)it.next(); ! Vertex direction = e.getFrom().minus(e.getTo()); ! direction.scale(50 / direction.length()); ! Vertex to = direction.copy(); ! direction.scale(-1); ! Vertex from = direction.copy(); ! to = to.add(v); ! from = from.add(v); ! Edge constructor = new Edge(from, to); ! ! constructor.setConstructor(true); ! constructors.add(constructor); ! } ! if (showConstructors) { ! displayConstructors(constructors); ! } ! return constructors; ! } ! ! /** ! * Makes a set of constructors be displayed. ! * @param constructors a set of constructors. ! */ ! protected void displayConstructors(Set constructors) { ! if (constructors != null) { ! Iterator it = constructors.iterator(); ! while (it.hasNext()) { ! Edge constructor = (Edge)it.next(); ! glv.getView().addTempEdge(constructor); ! } ! } ! } ! ! /** ! * Removes a set of constructors. ! * @param constructors a set of constructors. ! */ ! protected void clearConstructors(Set constructors) { ! if (constructors != null) { ! Iterator it = constructors.iterator(); ! while (it.hasNext()) { ! Edge constructor = (Edge)it.next(); ! glv.getView().removeTempEdge(constructor); ! } ! } ! } /** |