[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool SpaceSelectTool.java, NONE, 1.1 Tool.
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-06-19 14:53:36
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4407/src/net/sourceforge/bprocessor/gl/tool Modified Files: Tool.java ToolFactory.java Added Files: SpaceSelectTool.java Log Message: new space-select tool Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** ToolFactory.java 5 Feb 2008 13:34:32 -0000 1.104 --- ToolFactory.java 19 Jun 2009 13:32:29 -0000 1.105 *************** *** 65,68 **** --- 65,69 ---- private AbstractTool select; private AbstractTool assign; + private AbstractTool spaceselect; private Pencil pencil; *************** *** 132,135 **** --- 133,137 ---- select = new SelectTool(editor, null); assign = new SpaceTool(editor, null); + spaceselect = new SpaceSelectTool(editor, null); pencil = new Pencil(editor, pencilcursor); eraser = new EraserTool(editor, pencilcursor); *************** *** 152,155 **** --- 154,158 ---- Toolbar tb = Toolbar.getInstance(); + registerTool(Tool.SPACE_SELECT, spaceselect, "Biconselecttool2.gif", "Sensor Select"); registerTool(Tool.SELECT_TOOL, select, "Biconselecttool.gif", "Select"); registerTool(Tool.ASSIGN_TOOL, assign, "assign-icon-3.png", "Assign"); Index: Tool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Tool.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Tool.java 3 Dec 2007 17:29:48 -0000 1.41 --- Tool.java 19 Jun 2009 13:32:29 -0000 1.42 *************** *** 80,83 **** --- 80,86 ---- public static final int ASSIGN_TOOL = 27; + /** the zoom tool */ + public static final int SPACE_SELECT = 28; + /** * Return the current selection --- NEW FILE: SpaceSelectTool.java --- //--------------------------------------------------------------------------------- // $Id: SpaceSelectTool.java,v 1.1 2009/06/19 13:32:29 henryml 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 net.sourceforge.bprocessor.gl.Editor; import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; import java.awt.Cursor; import java.awt.event.MouseEvent; import java.util.LinkedList; import javax.swing.JPopupMenu; /** * The Space Select Tool */ public class SpaceSelectTool extends AbstractTool { /** * The constructor * @param editor The 3D canvas * @param cursor The cursor */ public SpaceSelectTool(Editor editor, Cursor cursor) { super(editor, cursor); } /** * Invoked when the mouse cursor has been moved * @param e The MouseEvent object */ protected void moved(MouseEvent e) { } /** * Invoked when a mouse button has been pressed on a component. * @param e The MouseEvent object */ protected void pressed(MouseEvent e) { boolean done = false; if (e.getButton() == MouseEvent.BUTTON1) { findTarget(e); if (target instanceof Surface) { Surface surface = (Surface) target; Space front = surface.getFrontDomain(); Space back = surface.getBackDomain(); if (front.isConstructionSpace()) { Selection.primary().set(front); } else if (back.isConstructionSpace()) { Selection.primary().set(back); } } } } /** * Invoked when the mouse is held pressed and moved * @param e The MouseEvent object */ protected void dragged(MouseEvent e) { if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK) { // Empty if block } } /** * Invoked when a mouse button has been released on a component. * @param e The MouseEvent */ protected void released(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { // Empty if block } } /** * {@inheritDoc} */ public String initialTip() { return "Click objects to select." + " Hold shift to add to selection." + " Drag to multi-select."; } /** * {@inheritDoc} */ public void handleMenu(MouseEvent event) { Selection selection = Selection.primary(); JPopupMenu menu = null; if (target == null) { selection.clear(); menu = GUI.getInstance().menuFactory().menuFor(new LinkedList<Geometric>()); } else { if (target instanceof Geometric) { if (!selection.contains(target)) { selection.set((Geometric) target); } menu = GUI.getInstance().menuFactory().menuFor(selection); } } if (menu != null && menu.getComponentCount() > 0) { editor.popup(menu, event.getX(), event.getY()); } } } |