[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractTool.java, 1.151, 1.152 Selec
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-11-17 13:44:13
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14966/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java SelectStrategy.java Strategy.java OrbitStrategy.java PanStrategy.java Log Message: Index: SelectStrategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectStrategy.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** SelectStrategy.java 25 Jun 2009 23:28:49 -0000 1.34 --- SelectStrategy.java 17 Nov 2009 13:44:00 -0000 1.35 *************** *** 12,19 **** import java.util.List; import java.util.Set; - - - import org.apache.log4j.Logger; - import net.sourceforge.bprocessor.gl.Editor; import net.sourceforge.bprocessor.gl.model.GlCamera; --- 12,15 ---- *************** *** 33,38 **** */ public class SelectStrategy implements Strategy { - /** The logger */ - private static Logger log = Logger.getLogger(SelectStrategy.class); --- 29,32 ---- *************** *** 42,55 **** private Editor editor; ! /** Tempoary edges for multiple selection */ protected Edge e1; ! ! /** Tempoary edges for multiple selection */ protected Edge e2; ! ! /** Tempoary edges for multiple selection */ protected Edge e3; ! ! /** Tempoary edges for multiple selection */ protected Edge e4; --- 36,46 ---- private Editor editor; ! /** Temporary edges for multiple selection */ protected Edge e1; ! /** Temporary edges for multiple selection */ protected Edge e2; ! /** Temporary edges for multiple selection */ protected Edge e3; ! /** Temporary edges for multiple selection */ protected Edge e4; *************** *** 106,110 **** */ public void pressed(MouseEvent e) { - log.debug("pressed"); Transformation t = editor.getView().transformation(); Vertex first = t.unProject(new Vertex(e.getX(), View.getHeight() - e.getY(), 0.001)); --- 97,100 ---- *************** *** 197,201 **** */ public void dragged(MouseEvent e) { - log.debug("dragged"); if (activated) { multipleSelection = true; --- 187,190 ---- *************** *** 274,278 **** */ public void released(MouseEvent e) { - log.debug("released with event:" + e.toString()); if (activated) { if (multipleSelection) { --- 263,266 ---- *************** *** 321,326 **** selection.remove(g); } - } else { - log.error("Tried to insert something different from Geometric in selection"); } } else if (target instanceof GlCamera) { --- 309,312 ---- *************** *** 332,337 **** selection.set((Geometric)target); } - } else { - log.warn("Target weren't a Geometric"); } } --- 318,321 ---- *************** *** 342,344 **** --- 326,336 ---- activated = false; } + + /** + * {@inheritDoc} + */ + public void prepare() { + // TODO Auto-generated method stub + + } } Index: OrbitStrategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/OrbitStrategy.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OrbitStrategy.java 12 Dec 2007 15:07:01 -0000 1.6 --- OrbitStrategy.java 17 Nov 2009 13:44:00 -0000 1.7 *************** *** 17,21 **** /** ! * The rotationtool */ public class OrbitStrategy implements Strategy { --- 17,21 ---- /** ! * The orbit tool */ public class OrbitStrategy implements Strategy { *************** *** 38,41 **** --- 38,44 ---- private int y; + + private boolean initial; + /** * KeyListener for the GL Canvas *************** *** 63,87 **** */ public void dragged(MouseEvent e) { ! Camera c = Project.getInstance().getCurrentCamera(); ! if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == ! MouseEvent.BUTTON1_DOWN_MASK || e.getButton() == MouseEvent.BUTTON1) { ! double angleX = ((double)(e.getX() - x) / 360) * Math.PI; ! double angleY = ((double)(e.getY() - y) / 360) * Math.PI; ! ! if (e.isShiftDown()) { ! // roll camera ! Camera.rollCamera(c, (angleY + angleX) / 2); ! } else if (e.isAltDown()) { ! // rotate camera about itself ! Camera.rotateHorizontallyEye(c, -angleX); ! Camera.rotateVerticallyEye(c, angleY); ! } else { ! // rotate camera about point of view ! double[] pivot = c.getCenter(); ! Camera.rotateHorizontally(c, -angleX, pivot); ! Camera.rotateVertically(c, angleY, pivot); ! } x = e.getX(); y = e.getY(); } } --- 66,96 ---- */ public void dragged(MouseEvent e) { ! if (initial) { x = e.getX(); y = e.getY(); + initial = false; + } else { + Camera c = Project.getInstance().getCurrentCamera(); + if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == + MouseEvent.BUTTON1_DOWN_MASK || e.getButton() == MouseEvent.BUTTON1) { + double angleX = ((double)(e.getX() - x) / 360) * Math.PI; + double angleY = ((double)(e.getY() - y) / 360) * Math.PI; + + if (e.isShiftDown()) { + // roll camera + Camera.rollCamera(c, (angleY + angleX) / 2); + } else if (e.isAltDown()) { + // rotate camera about itself + Camera.rotateHorizontallyEye(c, -angleX); + Camera.rotateVerticallyEye(c, angleY); + } else { + // rotate camera about point of view + double[] pivot = c.getCenter(); + Camera.rotateHorizontally(c, -angleX, pivot); + Camera.rotateVertically(c, angleY, pivot); + } + x = e.getX(); + y = e.getY(); + } } } *************** *** 101,104 **** --- 110,114 ---- x = e.getX(); y = e.getY(); + initial = false; } /** *************** *** 108,110 **** --- 118,127 ---- public void released(MouseEvent e) { } + + /** + * {@inheritDoc} + */ + public void prepare() { + initial = true; + } } Index: PanStrategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PanStrategy.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PanStrategy.java 18 Nov 2007 21:30:17 -0000 1.5 --- PanStrategy.java 17 Nov 2009 13:44:00 -0000 1.6 *************** *** 93,96 **** --- 93,104 ---- public void released(MouseEvent e) { } + + /** + * {@inheritDoc} + */ + public void prepare() { + // TODO Auto-generated method stub + + } } Index: Strategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Strategy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Strategy.java 21 Jun 2006 10:26:33 -0000 1.1 --- Strategy.java 17 Nov 2009 13:44:00 -0000 1.2 *************** *** 15,18 **** --- 15,24 ---- public interface Strategy { + /** + * Invoked when this Strategy is activated. + */ + abstract void prepare(); + + /** * Invoked when the mouse cursor has been moved Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -d -r1.151 -r1.152 *** AbstractTool.java 22 Sep 2009 11:16:57 -0000 1.151 --- AbstractTool.java 17 Nov 2009 13:43:59 -0000 1.152 *************** *** 187,196 **** Tool tool = null; ToolFactory factory = ToolFactory.getFactory(editor); ! if (which == AbstractTool.pan) { ! tool = factory.get(Tool.PAN_TOOL); ! } else if (which == AbstractTool.orbit) { ! tool = factory.get(Tool.CAMERA_TOOL); ! } else if (which == AbstractTool.select) { ! tool = factory.get(Tool.SELECT_TOOL); } else { if (activeStrategy == AbstractTool.select) { --- 187,200 ---- Tool tool = null; ToolFactory factory = ToolFactory.getFactory(editor); ! ! if (which != null) { ! which.prepare(); ! if (which == AbstractTool.pan) { ! tool = factory.get(Tool.PAN_TOOL); ! } else if (which == AbstractTool.orbit) { ! tool = factory.get(Tool.CAMERA_TOOL); ! } else if (which == AbstractTool.select) { ! tool = factory.get(Tool.SELECT_TOOL); ! } } else { if (activeStrategy == AbstractTool.select) { |