[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool DrawTool.java,1.5,1.6
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-08-05 10:58:05
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31537 Modified Files: DrawTool.java Log Message: changed construction of surfaces and edges to fix a bug Index: DrawTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/DrawTool.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DrawTool.java 4 Aug 2005 10:49:57 -0000 1.5 --- DrawTool.java 5 Aug 2005 10:57:47 -0000 1.6 *************** *** 19,22 **** --- 19,23 ---- import java.util.Iterator; import java.util.List; + import java.util.Set; *************** *** 88,92 **** if (e.getClickCount() >= 2) { if (currentButton == MouseEvent.BUTTON1) { ! // double click on Button1 => surface end endSurface(coords); } --- 89,93 ---- if (e.getClickCount() >= 2) { if (currentButton == MouseEvent.BUTTON1) { ! // THE ACTIONS HAVE BEEN pressed->released->pressed at the position endSurface(coords); } *************** *** 113,120 **** protected void endSurface(double[] coord) { Edge activeEdge = glv.getView().getActiveEdge(); ! if (activeEdge != null) { Vertex to = vertexCollide(coord); if (to != null) { // we have to change excisting surface Vertex old = activeEdge.getTo(); --- 114,122 ---- protected void endSurface(double[] coord) { Edge activeEdge = glv.getView().getActiveEdge(); ! if (!edges.isEmpty()) { Vertex to = vertexCollide(coord); if (to != null) { // we have to change excisting surface + edges.add(activeEdge); Vertex old = activeEdge.getTo(); *************** *** 127,137 **** } else { to = activeEdge.getTo(); ! updateVertex(to, coord); } ! Surface s = createSurface(edges); ! glv.getView().setAlignVertex(null); ! glv.getView().setActiveEdge(null); ! edges = new ArrayList(); } } --- 129,142 ---- } else { to = activeEdge.getTo(); ! removeEdge(activeEdge); ! removeVertex(to); } ! } else { ! edges.add(activeEdge); } + Surface s = createSurface(edges); + glv.getView().setAlignVertex(null); + glv.getView().setActiveEdge(null); + edges = new ArrayList(); } *************** *** 141,145 **** */ protected void addEdge(double[] coord) { ! if (edges.isEmpty()) { Vertex from = vertexCollide(coord); if (from == null) { --- 146,150 ---- */ protected void addEdge(double[] coord) { ! if (glv.getView().getActiveEdge() == null) { Vertex from = vertexCollide(coord); if (from == null) { *************** *** 147,153 **** } Vertex to = createVertex(coord); ! Edge activeEdge = createEdge(to, from); glv.getView().setActiveEdge(activeEdge); - edges.add(activeEdge); glv.getView().setAlignVertex(null); } else { --- 152,157 ---- } Vertex to = createVertex(coord); ! Edge activeEdge = createEdge(from, to); glv.getView().setActiveEdge(activeEdge); glv.getView().setAlignVertex(null); } else { *************** *** 155,163 **** // we did not end an edgelist Edge activeEdge = glv.getView().getActiveEdge(); Vertex from = activeEdge.getTo(); Vertex to = createVertex(coord); ! activeEdge = createEdge(to, from); glv.getView().setActiveEdge(activeEdge); - edges.add(activeEdge); glv.getView().setAlignVertex(null); } else { --- 159,167 ---- // we did not end an edgelist Edge activeEdge = glv.getView().getActiveEdge(); + edges.add(activeEdge); Vertex from = activeEdge.getTo(); Vertex to = createVertex(coord); ! activeEdge = createEdge(from, to); glv.getView().setActiveEdge(activeEdge); glv.getView().setAlignVertex(null); } else { *************** *** 174,178 **** protected void changeTo(double[] coord) { Edge activeEdge = glv.getView().getActiveEdge(); ! if (activeEdge != null && !edges.isEmpty()) { Vertex v = activeEdge.getTo(); updateVertex(v, coord); --- 178,182 ---- protected void changeTo(double[] coord) { Edge activeEdge = glv.getView().getActiveEdge(); ! if (activeEdge != null) { Vertex v = activeEdge.getTo(); updateVertex(v, coord); *************** *** 188,199 **** protected Vertex vertexCollide(double[] coord) { Edge e = glv.getView().getActiveEdge(); ! Set vertexes = VertexFacade.getInstance().findAll(); Iterator it = vertexes.iterator(); while (it.hasNext()) { Vertex v = (Vertex)it.next(); ! if (collide(v.getX(), coord[0]) && ! collide(v.getY(), coord[1]) && ! collide(v.getZ(), coord[2]) && ! (e == null || (!v.equals(e.getTo()) && !v.equals(e.getFrom())))) { return v; } --- 192,203 ---- protected Vertex vertexCollide(double[] coord) { Edge e = glv.getView().getActiveEdge(); ! Set vertexes = VertexFacade.getInstance().findByLocation(coord[0], ! coord[1], ! coord[2], ! EPSILON); Iterator it = vertexes.iterator(); while (it.hasNext()) { Vertex v = (Vertex)it.next(); ! if (e == null || (!v.equals(e.getTo()) && !v.equals(e.getFrom()))) { return v; } |