Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ControlledExtrudeTool.java, NONE, 1.1
Status: Pre-Alpha
Brought to you by:
henryml
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14216/src/net/sourceforge/bprocessor/gl/tool Modified Files: ToolFactory.java ExtrusionTool.java AbstractTool.java Tool.java RectTool.java Added Files: ControlledExtrudeTool.java Log Message: Added a controlledExtrudeTool and made som refactoring on the way through the code. Index: Tool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Tool.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Tool.java 3 Sep 2007 13:36:52 -0000 1.36 --- Tool.java 7 Sep 2007 13:21:10 -0000 1.37 *************** *** 71,75 **** public static final int FINAL_MOVE_TOOL = 24; /** the drag tool */ ! public static final int DRAG_TOOL = 25; /** the zoom tool */ public static final int ZOOM_TOOL = 26; --- 71,75 ---- public static final int FINAL_MOVE_TOOL = 24; /** the drag tool */ ! public static final int PAN_TOOL = 25; /** the zoom tool */ public static final int ZOOM_TOOL = 26; Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** ToolFactory.java 3 Sep 2007 16:00:13 -0000 1.83 --- ToolFactory.java 7 Sep 2007 13:21:10 -0000 1.84 *************** *** 130,172 **** private ZoomTool zoomTool; - - /** The selection button */ - private JToggleButton selBut; - - /** The pencil button */ - private JToggleButton pencilBut; - - /** The eraser button */ - private JToggleButton eraserBut; - - /** The move button */ - private JToggleButton moveBut; - - /** The move button */ - private JToggleButton rotationBut; - - /** The extrude button */ - private JToggleButton extrudeBut; - - /** The clipplane button */ - private JToggleButton clipBut; - - /** The tapemeasure button */ - private JToggleButton tmBut; ! /** The camera rotation button */ ! private JToggleButton cRotBut; ! ! /** The camera flymode button */ ! private JToggleButton flyBut; ! ! /** The camera walkmode button */ ! private JToggleButton walkBut; ! ! /** The offset tool button */ ! private JToggleButton offBut; ! ! /** The alternative rect tool button */ ! private JToggleButton altRectBut; protected static Cursor errorCursor; --- 130,135 ---- private ZoomTool zoomTool; ! private ControlledExtrudeTool multiExtrude; protected static Cursor errorCursor; *************** *** 197,201 **** Cursor rotationCursor = Toolkit.getDefaultToolkit().createCustomCursor(rotationImage, new Point(7, 8), "Rotation"); ! url = cl.getResource("Biconfly.gif"); Image flyImage = Toolkit.getDefaultToolkit().getImage(url); Cursor flyCursor = --- 160,164 ---- Cursor rotationCursor = Toolkit.getDefaultToolkit().createCustomCursor(rotationImage, new Point(7, 8), "Rotation"); ! /*url = cl.getResource("Biconfly.gif"); Image flyImage = Toolkit.getDefaultToolkit().getImage(url); Cursor flyCursor = *************** *** 205,209 **** Cursor walkCursor = Toolkit.getDefaultToolkit().createCustomCursor(walkImage, new Point(7, 8), "Walk"); ! url = cl.getResource("Bcursoradd.gif"); Image arrowAddImage = Toolkit.getDefaultToolkit().getImage(url); Cursor arrowAddCursor = --- 168,172 ---- Cursor walkCursor = Toolkit.getDefaultToolkit().createCustomCursor(walkImage, new Point(7, 8), "Walk"); ! url = cl.getResource("Bcursoradd.gif");*/ Image arrowAddImage = Toolkit.getDefaultToolkit().getImage(url); Cursor arrowAddCursor = *************** *** 222,249 **** eraser = new EraserTool(glv, pencilcursor); arc = new ArcTool(glv, pencilcursor); ! alternate = new VectorMoveTool(glv, pencilcursor); ! controlled = new ControlledMoveTool(glv, pencilcursor); rotation = new RotationTool(glv, null); extrude = new ExtrusionTool(glv, pencilcursor); clipplane = new ClipplaneTool(glv, pencilcursor); tapeMeasure = new TapeMeasure(glv, pencilcursor); relation = new RelationTool(glv, arrowAddCursor); camera = new CameraTool(glv, rotationCursor); ! fly = new CameraFlyTool(glv, flyCursor); ! walk = new CameraWalkTool(glv, walkCursor); constructor = new ConstructorTool(glv, pencilcursor); offset = new OffsetTool(glv, pencilcursor); altRect = new RectTool(glv, pencilcursor); focusTool = new FocusTool(glv, null); ! altMoveTool = new AltMoveTool(glv, pencilcursor); finalMoveTool = new FinalMoveTool(glv, pencilcursor); ! edgeMoveTool = new EdgeMoveTool(glv, pencilcursor); panTool = new PanTool(glv, panCursor); zoomTool = new ZoomTool(glv, zoomCursor); Toolbar tb = Toolbar.getInstance(); ! selBut = this.registerTool(Tool.SELECT_TOOL, select, "Biconselecttool.gif", "Select"); selBut.setMnemonic(KeyEvent.VK_Q); ! pencilBut = this.registerTool(Tool.PENCIL_TOOL, pencil, "Biconpentool.gif", "Pencil"); pencilBut.setMnemonic(KeyEvent.VK_W); this.registerTool(Tool.ALT_PENCIL_TOOL, penciltool, "Biconpentool2.gif", "Pencil"); --- 185,215 ---- eraser = new EraserTool(glv, pencilcursor); arc = new ArcTool(glv, pencilcursor); ! // alternate = new VectorMoveTool(glv, pencilcursor); ! // controlled = new ControlledMoveTool(glv, pencilcursor); rotation = new RotationTool(glv, null); extrude = new ExtrusionTool(glv, pencilcursor); + multiExtrude = new ControlledExtrudeTool(glv, pencilcursor); clipplane = new ClipplaneTool(glv, pencilcursor); tapeMeasure = new TapeMeasure(glv, pencilcursor); relation = new RelationTool(glv, arrowAddCursor); camera = new CameraTool(glv, rotationCursor); ! /*fly = new CameraFlyTool(glv, flyCursor); ! walk = new CameraWalkTool(glv, walkCursor);*/ constructor = new ConstructorTool(glv, pencilcursor); offset = new OffsetTool(glv, pencilcursor); altRect = new RectTool(glv, pencilcursor); focusTool = new FocusTool(glv, null); ! // altMoveTool = new AltMoveTool(glv, pencilcursor); finalMoveTool = new FinalMoveTool(glv, pencilcursor); ! // edgeMoveTool = new EdgeMoveTool(glv, pencilcursor); panTool = new PanTool(glv, panCursor); zoomTool = new ZoomTool(glv, zoomCursor); Toolbar tb = Toolbar.getInstance(); ! JToggleButton selBut = ! this.registerTool(Tool.SELECT_TOOL, select, "Biconselecttool.gif", "Select"); selBut.setMnemonic(KeyEvent.VK_Q); ! JToggleButton pencilBut = ! this.registerTool(Tool.PENCIL_TOOL, pencil, "Biconpentool.gif", "Pencil"); pencilBut.setMnemonic(KeyEvent.VK_W); this.registerTool(Tool.ALT_PENCIL_TOOL, penciltool, "Biconpentool2.gif", "Pencil"); *************** *** 253,271 **** JToggleButton arcb = this.registerTool(Tool.ARC_TOOL, arc, "Barc.gif", "Arc"); arcb.setMnemonic(KeyEvent.VK_Z); ! offBut = this.registerTool(Tool.OFFSET_TOOL, offset, "Biconoffset.gif", "Offset"); ! eraserBut = this.registerTool(Tool.ERASER_TOOL, eraser, "Biconeraser.gif", "Eraser"); eraserBut.setMnemonic(KeyEvent.VK_A); tb.addSeparator(3); ! extrudeBut = registerTool(Tool.EXTRUSION_TOOL, extrude, "Biconextrudetool.gif", "Extrude"); extrudeBut.setMnemonic(KeyEvent.VK_V); ! moveBut = this.registerTool(Tool.MOVE_TOOL, alternate, "Biconmovetool.gif", "Move"); moveBut.setMnemonic(KeyEvent.VK_M); ! registerTool(Tool.CONTROLLED_MOVE_TOOL, controlled, "Biconmovetool.gif", "Controlled Move"); ! registerTool(Tool.ALT_MOVE_TOOL, altMoveTool, "Biconmovetool.gif", "Alternative Moving"); ! registerTool(Tool.EDGE_MOVE_TOOL, edgeMoveTool, "Biconmovetool.gif", "Edge moving"); ! registerTool(Tool.FINAL_MOVE_TOOL, finalMoveTool, "Bmovetool.gif", "Final Move"); ! rotationBut = this.registerTool(Tool.ROTATION_TOOL, rotation, "Biconrotaxe.gif", "Rotate"); tb.addSeparator(3); ! tmBut = this.registerTool(Tool.TAPE_MEASURE_TOOL, tapeMeasure, "Bicontapemes.gif", "Tape Measure"); this.registerTool(Tool.CONSTRUCTOR_TOOL, constructor, "Biconconstructor.gif", "Constructor"); --- 219,244 ---- JToggleButton arcb = this.registerTool(Tool.ARC_TOOL, arc, "Barc.gif", "Arc"); arcb.setMnemonic(KeyEvent.VK_Z); ! JToggleButton offBut = ! this.registerTool(Tool.OFFSET_TOOL, offset, "Biconoffset.gif", "Offset"); ! JToggleButton eraserBut = ! this.registerTool(Tool.ERASER_TOOL, eraser, "Biconeraser.gif", "Eraser"); eraserBut.setMnemonic(KeyEvent.VK_A); tb.addSeparator(3); ! JToggleButton extrudeBut = ! registerTool(Tool.EXTRUSION_TOOL, extrude, "Biconextrudetool.gif", "Extrude"); extrudeBut.setMnemonic(KeyEvent.VK_V); ! registerTool(Tool.MULTI_EXTRUDE_TOOL, multiExtrude, ! "Biconextrudetool2.gif", "Controlled extrude"); ! //this.registerTool(Tool.MOVE_TOOL, alternate, "Biconmovetool.gif", "Move"); ! //registerTool(Tool.CONTROLLED_MOVE_TOOL, controlled, "Biconmovetool.gif", "Controlled Move"); ! //registerTool(Tool.ALT_MOVE_TOOL, altMoveTool, "Biconmovetool.gif", "Alternative Moving"); ! //registerTool(Tool.EDGE_MOVE_TOOL, edgeMoveTool, "Biconmovetool.gif", "Edge moving"); ! JToggleButton moveBut = ! registerTool(Tool.FINAL_MOVE_TOOL, finalMoveTool, "Bmovetool.gif", "Final Move"); moveBut.setMnemonic(KeyEvent.VK_M); ! JToggleButton rotationBut = ! this.registerTool(Tool.ROTATION_TOOL, rotation, "Biconrotaxe.gif", "Rotate"); tb.addSeparator(3); ! JToggleButton tmBut = this.registerTool(Tool.TAPE_MEASURE_TOOL, tapeMeasure, "Bicontapemes.gif", "Tape Measure"); this.registerTool(Tool.CONSTRUCTOR_TOOL, constructor, "Biconconstructor.gif", "Constructor"); *************** *** 273,278 **** tb.addSeparator(3); ! cRotBut = this.registerTool(Tool.CAMERA_TOOL, camera, "Biconrotcam.gif", "Orbit (Space)"); ! this.registerTool(Tool.DRAG_TOOL, panTool, "Bicondrag.gif", "Drag (Space)"); this.registerTool(Tool.ZOOM_TOOL, zoomTool, "Biconzomeinout.gif", "Zoom in/out"); //flyBut = this.registerTool(Tool.FLY_TOOL, fly, "Biconfly.gif", "Fly"); --- 246,252 ---- tb.addSeparator(3); ! JToggleButton cRotBut = ! this.registerTool(Tool.CAMERA_TOOL, camera, "Biconrotcam.gif", "Orbit (Space)"); ! this.registerTool(Tool.PAN_TOOL, panTool, "Bicondrag.gif", "Pan"); this.registerTool(Tool.ZOOM_TOOL, zoomTool, "Biconzomeinout.gif", "Zoom in/out"); //flyBut = this.registerTool(Tool.FLY_TOOL, fly, "Biconfly.gif", "Fly"); *************** *** 297,301 **** tb.addSeparator(10); ! clipBut = this.registerTool(Tool.CLIP_TOOL, clipplane, "Bclip.gif", "Clipping"); Action orthoAction = new ToolAction(glv, 0, "Borto.gif") { --- 271,275 ---- tb.addSeparator(10); ! JToggleButton clipBut = this.registerTool(Tool.CLIP_TOOL, clipplane, "Bclip.gif", "Clipping"); Action orthoAction = new ToolAction(glv, 0, "Borto.gif") { --- NEW FILE: ControlledExtrudeTool.java --- //--------------------------------------------------------------------------------- // $Id: ControlledExtrudeTool.java,v 1.1 2007/09/07 13:21:10 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gl.tool; import java.awt.Cursor; import java.awt.event.MouseEvent; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import org.apache.log4j.Logger; import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.model.Direction; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; /** * A tool for push/pulling geometry * Should work as follows: * When a surface is pressed all its bound and unbound vertexes are found. * A bound vertex have edges that is not in the plane of the surface * A unbound is the opposite * All unbound vertexes are copied and connected to the copy by a edge, the * bound are moved in the direction of the edge that bounds it, * which should give a push/pull effect */ public class ControlledExtrudeTool extends AbstractPencil { private static Logger log = Logger.getLogger(ControlledExtrudeTool.class); private HashSet<Surface> extrusion; private Map<Vertex, Direction> v2dir; /** * Tool constructor * @param glv The view to work in * @param cursor The cursor to use */ public ControlledExtrudeTool(GLView glv, Cursor cursor) { super(glv, cursor); extrusion = new HashSet<Surface>(); v2dir = new HashMap<Vertex, Direction>(); } /** {@inheritDoc} */ @Override public void onVertex() { //TODO finish the extrusion } /** {@inheritDoc} */ @Override protected void moved(MouseEvent e) { if (extrusion.isEmpty()) { findTarget(e, View.HANDLES); glv.getView().makeTarget(target); } else { current = findIntersection(e); makeTarget(current); } } /** {@inheritDoc} */ @Override protected void pressed(MouseEvent e) { if (target != null && target instanceof Surface) { Surface workingSurface = (Surface)target; Surface top = workingSurface.extrusionControlled(1, extrusion, v2dir); if (top != null) { extrusion.add(top); } log.debug(extrusion.size()); ExtrusionTool.insert(Project.getInstance().getActiveSpace(), extrusion); } } /** {@inheritDoc} */ @Override public void prepare() { super.prepare(); Selection.primary().clear(); } /** {@inheritDoc} */ @Override public void cleanUp() { super.cleanUp(); extrusion.clear(); v2dir.clear(); } /** {@inheritDoc} */ @Override public String initialTip() { return "Press a surface and drag it to push/pull it"; } } Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.129 retrieving revision 1.130 diff -C2 -d -r1.129 -r1.130 *** AbstractTool.java 3 Sep 2007 11:31:34 -0000 1.129 --- AbstractTool.java 7 Sep 2007 13:21:10 -0000 1.130 *************** *** 185,189 **** ToolFactory factory = ToolFactory.getFactory(glv); if (which == AbstractTool.pan) { ! tool = factory.get(Tool.DRAG_TOOL); } else if (which == AbstractTool.orbit) { tool = factory.get(Tool.CAMERA_TOOL); --- 185,189 ---- ToolFactory factory = ToolFactory.getFactory(glv); if (which == AbstractTool.pan) { ! tool = factory.get(Tool.PAN_TOOL); } else if (which == AbstractTool.orbit) { tool = factory.get(Tool.CAMERA_TOOL); Index: ExtrusionTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrusionTool.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** ExtrusionTool.java 5 Sep 2007 08:56:51 -0000 1.66 --- ExtrusionTool.java 7 Sep 2007 13:21:10 -0000 1.67 *************** *** 88,92 **** * @param extrusion Collection of surfaces */ ! private void insert(Space space, Collection<Surface> extrusion) { Collection<Edge> edges = Surface.edges(extrusion); Collection<Vertex> vertices = Edge.vertices(edges); --- 88,92 ---- * @param extrusion Collection of surfaces */ ! protected static void insert(Space space, Collection<Surface> extrusion) { Collection<Edge> edges = Surface.edges(extrusion); Collection<Vertex> vertices = Edge.vertices(edges); Index: RectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/RectTool.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** RectTool.java 19 Jun 2007 16:11:06 -0000 1.19 --- RectTool.java 7 Sep 2007 13:21:10 -0000 1.20 *************** *** 153,156 **** --- 153,159 ---- protected void pressed(MouseEvent e) { if (start == null) { + if (current == null) { + current = findIntersection(e); + } start = current; lastCurrent = start.vertex(); |