Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool OffsetTool.java, 1.6, 1.7 ExtrudeTool
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-09-18 14:10:17
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17851/src/net/sourceforge/bprocessor/gl/tool Modified Files: OffsetTool.java ExtrudeTool.java AbstractPencil.java Log Message: Made changes to extrude tool to use extend abstractpencil and therfore making escape work and modified offset to use Edge.offset and thereby giving way for offset of only a subset of edges... There are still some bugs to be fixed Index: ExtrudeTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrudeTool.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ExtrudeTool.java 11 Sep 2006 12:47:32 -0000 1.22 --- ExtrudeTool.java 18 Sep 2006 14:09:58 -0000 1.23 *************** *** 28,32 **** * The ExtrudeTool */ ! public class ExtrudeTool extends AbstractTool { /** Limit offset */ --- 28,32 ---- * The ExtrudeTool */ ! public class ExtrudeTool extends AbstractPencil { /** Limit offset */ *************** *** 59,65 **** private Plane dragplane; - /** The length typed in for length of the extrusion*/ - private String number; - /** The previous x-coordinate */ private double prevX; --- 59,62 ---- *************** *** 95,99 **** public ExtrudeTool(GLView glv, Cursor cursor) { super(glv, cursor); - number = new String(); } --- 92,95 ---- *************** *** 109,114 **** findTarget(e); if (target instanceof Surface) { - sides = new HashSet(); extrudeSurface = (Surface) target; View view = glv.getView(); Transformation trans = view.transformation(); --- 105,113 ---- findTarget(e); if (target instanceof Surface) { extrudeSurface = (Surface) target; + start = findIntersection(e); + lock = true; + lockingEdge = new Edge(start.vertex(), start.vertex().add(extrudeSurface.normal())); + sides = new HashSet(); View view = glv.getView(); Transformation trans = view.transformation(); *************** *** 119,123 **** Edge ray = new Edge(near, far); ray = trans.unProject(ray); ! dragplane = extrudeSurface.plane().orthogonalPlane(ray); mode = MOVE_MODE; } --- 118,123 ---- Edge ray = new Edge(near, far); ray = trans.unProject(ray); ! plane = extrudeSurface.plane(); ! dragplane = plane.orthogonalPlane(ray); mode = MOVE_MODE; } *************** *** 194,202 **** /** * Apply extrusion - * @param length The length */ ! private void apply(double length) { ! removeExtrusion(); if (extrudeSurface != null && length > 0) { sides = new HashSet(); holeSides = null; --- 194,202 ---- /** * Apply extrusion */ ! public void onVertex() { ! double length = start.vertex().minus(current.vertex()).length(); if (extrudeSurface != null && length > 0) { + removeExtrusion(); sides = new HashSet(); holeSides = null; *************** *** 244,247 **** --- 244,255 ---- mode = UNDICIDED; } + + /** + * escape + */ + public void escape() { + removeExtrusion(); + super.escape(); + } /** Do tool cleanup */ *************** *** 254,258 **** sides = null; holeSides = null; ! number = new String(); } --- 262,267 ---- sides = null; holeSides = null; ! mode = UNDICIDED; ! super.cleanUp(); } *************** *** 340,343 **** --- 349,353 ---- } } else if (mode == MOVE_MODE) { + current = findIntersection(e); doThing(e); } *************** *** 383,387 **** elements.addAll(sides); elements.add(top); ! if (extrudeAll) { elements.addAll(holeSides); } --- 393,397 ---- elements.addAll(sides); elements.add(top); ! if (holeSides != null) { elements.addAll(holeSides); } *************** *** 459,532 **** for extrusion, and if the "number"-variable has been initialised */ ! if (extrudeSurface != null && number != null) { ! if (e.getKeyCode() == KeyEvent.VK_1) { ! number += "1"; ! } else if (e.getKeyCode() == KeyEvent.VK_2) { ! number += "2"; ! } else if (e.getKeyCode() == KeyEvent.VK_3) { ! number += "3"; ! } else if (e.getKeyCode() == KeyEvent.VK_4) { ! number += "4"; ! } else if (e.getKeyCode() == KeyEvent.VK_5) { ! number += "5"; ! } else if (e.getKeyCode() == KeyEvent.VK_6) { ! number += "6"; ! } else if (e.getKeyCode() == KeyEvent.VK_7) { ! number += "7"; ! } else if (e.getKeyCode() == KeyEvent.VK_8) { ! number += "8"; ! } else if (e.getKeyCode() == KeyEvent.VK_9) { ! number += "9"; ! } else if (e.getKeyCode() == KeyEvent.VK_0) { ! number += "0"; ! } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { ! if (!number.equals("")) { ! double length = glv.getLength(); ! apply(length); ! glv.repaint(); ! } ! } else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { ! int length = number.length(); ! if (length > 0) { ! number = number.substring(0, length - 1); ! } ! } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { ! removeExtrusion(); ! cleanUp(); ! } ! } if ((e.getModifiersEx() & KeyEvent.ALT_DOWN_MASK) == KeyEvent.ALT_DOWN_MASK) { // Alt were pressed so holes are not supposed to be extruded extrudeAll = false; } - - if (number.equals("") || number.equals("-")) { - glv.setLength(0); - } else { - try { - double d = Double.parseDouble(number); - glv.setLength(d / 1000); - } catch (NumberFormatException exp) { - System.out.println(exp); - } - } - } - - /** - * Delete - */ - public void delete() { - int length = number.length(); - if (length > 1) { - number = number.substring(0, length - 1); - } else { - number = String.valueOf(0); - } - try { - double d = Double.parseDouble(number); - glv.setLength(d / 1000); - } catch (NumberFormatException exp) { - Project.info(exp); - } } --- 469,477 ---- for extrusion, and if the "number"-variable has been initialised */ ! super.key(e); if ((e.getModifiersEx() & KeyEvent.ALT_DOWN_MASK) == KeyEvent.ALT_DOWN_MASK) { // Alt were pressed so holes are not supposed to be extruded extrudeAll = false; } } Index: OffsetTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/OffsetTool.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OffsetTool.java 11 Sep 2006 12:47:32 -0000 1.6 --- OffsetTool.java 18 Sep 2006 14:09:58 -0000 1.7 *************** *** 12,15 **** --- 12,16 ---- import java.awt.event.MouseEvent; + import java.util.Collection; import java.util.Iterator; import java.util.List; *************** *** 19,24 **** --- 20,29 ---- import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.gl.model.Intersection; + import net.sourceforge.bprocessor.model.Direction; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometry; + import net.sourceforge.bprocessor.model.Point; + import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; *************** *** 49,52 **** --- 54,65 ---- private boolean dragging; + /** The point the offset are started from */ + private Vertex edgePoint; + + /** the intersection edge */ + private Edge edge; + + private LinkedList edges; + /** * Constructor fo OffsetTool *************** *** 61,64 **** --- 74,79 ---- dragging = false; outNormal = null; + edgePoint = null; + edge = null; } *************** *** 76,81 **** surfaceFound = true; Surface surface = (Surface)current.object(); ! contour = copyContour(surface); ! directionMap = findDirections(contour, surface.normal()); feedback(contour); outNormal = startEdge.getDirection().cross(surface.normal()); --- 91,106 ---- surfaceFound = true; Surface surface = (Surface)current.object(); ! edges = new LinkedList(); ! edges.addAll(surface.getEdges()); ! Collection selection = Selection.primary(); ! if (selection.size() > 0 && edges.containsAll(selection)) { ! System.out.println("Did contain all"); ! edges.clear(); ! edges.addAll(selection); ! } ! directionMap = new HashMap(); ! contour.addAll(Edge.offset(edges, surface, ! -(current.vertex().minus(start.vertex()).length()), directionMap)); ! //directionMap = findDirections(contour, surface.normal()); feedback(contour); outNormal = startEdge.getDirection().cross(surface.normal()); *************** *** 93,97 **** length = projection.length(); } else { ! length = (-1 * projection.length()); } moveContour(length); --- 118,122 ---- length = projection.length(); } else { ! length = -projection.length(); } moveContour(length); *************** *** 99,103 **** --- 124,137 ---- } } + if (start == null && current.object() instanceof Surface) { + Surface s = (Surface)current.object(); + edge = s.findClosestEdge(current.vertex()); + edgePoint = edge.intersection(current.vertex()); + LinkedList feedback = new LinkedList(); + feedback.add(new Point(edgePoint)); + feedback(feedback); + } makeTarget(current); + timer.stop(); } *************** *** 107,116 **** */ private void moveContour(double length) { ! Iterator it = Geometry.collect(contour).iterator(); while (it.hasNext()) { ! Vertex v = (Vertex)it.next(); ! Vertex dir = ((Vertex)directionMap.get(v)).copy(); dir.scale(length); ! v.move(dir.getX(), dir.getY(), dir.getZ()); } } --- 141,150 ---- */ private void moveContour(double length) { ! Iterator it = directionMap.values().iterator(); while (it.hasNext()) { ! Direction d = (Direction)it.next(); ! Vertex dir = d.getDirection().copy(); dir.scale(length); ! d.getVertex().move(dir.getX(), dir.getY(), dir.getZ()); } } *************** *** 133,140 **** protected void pressed(MouseEvent e) { if (start == null) { ! if (current != null && current.object() instanceof Edge) { ! start = current; ! lastOffsetPoint = start.vertex().copy(); ! } } else { endOffset(); --- 167,179 ---- protected void pressed(MouseEvent e) { if (start == null) { ! if (current != null) { ! if (current.object() instanceof Edge) { ! start = current; ! lastOffsetPoint = start.vertex().copy(); ! } else if (current.object() instanceof Surface) { ! start = new Intersection(edgePoint, Intersection.EDGE, edge); ! lastOffsetPoint = current.vertex().copy(); ! } ! } } else { endOffset(); *************** *** 172,175 **** --- 211,216 ---- surfaceFound = false; outNormal = null; + edgePoint = null; + edge = null; feedback(contour); } Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** AbstractPencil.java 11 Sep 2006 13:25:05 -0000 1.66 --- AbstractPencil.java 18 Sep 2006 14:09:58 -0000 1.67 *************** *** 621,625 **** */ public void onVertex() { ! } --- 621,625 ---- */ public void onVertex() { ! log.info("onVertex"); } |