Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18862/src/net/sourceforge/bprocessor/gl/tool
Modified Files:
Tool.java ToolFactory.java
Added Files:
FocusTool.java
Log Message:
Added a focus on tool that works as a tool
--- NEW FILE: FocusTool.java ---
//---------------------------------------------------------------------------------
// $Id: FocusTool.java,v 1.1 2007/02/22 12:36:57 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 net.sourceforge.bprocessor.gl.GLView;
import net.sourceforge.bprocessor.model.Camera;
import net.sourceforge.bprocessor.model.ClippingPlane;
import net.sourceforge.bprocessor.model.Geometric;
import net.sourceforge.bprocessor.model.Project;
import net.sourceforge.bprocessor.model.Selection;
import net.sourceforge.bprocessor.model.Surface;
/**
* @author Rimestad
*
*/
public class FocusTool extends AbstractTool {
/**
* @param glv
* @param cursor
*/
public FocusTool(GLView glv, Cursor cursor) {
super(glv, cursor);
}
/**
* {@inheritDoc}
*/
protected void moved(MouseEvent e) {
findTarget(e);
if (target instanceof Surface || target instanceof ClippingPlane) {
glv.getView().makeTarget(target);
} else {
target = null;
}
}
/**
* {@inheritDoc}
*/
protected void pressed(MouseEvent e) {
// do nothing
}
/**
* {@inheritDoc}
*/
protected void dragged(MouseEvent e) {
// do nothing
}
/**
* {@inheritDoc}
*/
protected void released(MouseEvent e) {
if (target != null) {
if (target instanceof Surface) {
Camera.focusOn(Project.getInstance().getCurrentCamera(), (Surface)target);
} else {
Camera.focusOn(Project.getInstance().getCurrentCamera(), (ClippingPlane)target);
}
this.glv.repaint();
}
}
}
Index: ToolFactory.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** ToolFactory.java 8 Feb 2007 12:23:13 -0000 1.75
--- ToolFactory.java 22 Feb 2007 12:36:57 -0000 1.76
***************
*** 156,159 ****
--- 156,162 ----
private RelationTool relation;
+ /** The tool for focusing on objects */
+ private FocusTool focusTool;
+
/**
* Constructor
***************
*** 207,210 ****
--- 210,214 ----
offset = new OffsetTool(glv, pencilcursor);
altRect = new RectTool(glv, pencilcursor);
+ focusTool = new FocusTool(glv, null);
Toolbar tb = Toolbar.getInstance();
***************
*** 256,271 ****
Toolbar.getInstance().registerPushButtonAction(zoomAction, "Zoom All");
! Action focusAction = new ToolAction(glv, 0, "Biconzomeselect.gif") {
! public void actionPerformed(ActionEvent agr0) {
! if (Selection.primary().size() == 1) {
! Object o = Selection.primary().iterator().next();
! if (o instanceof Surface) {
! Camera.focusOn(Project.getInstance().getCurrentCamera(), (Surface)o);
! this.glv.repaint();
! }
! }
! }
! };
! Toolbar.getInstance().registerPushButtonAction(focusAction, "Focus on surface");
tb.addSeparator(10);
--- 260,264 ----
Toolbar.getInstance().registerPushButtonAction(zoomAction, "Zoom All");
! this.registerTool(Tool.FOCUS_TOOL, focusTool, "Biconzomeselect.gif", "Focus on surface");
tb.addSeparator(10);
Index: Tool.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Tool.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** Tool.java 6 Feb 2007 17:30:17 -0000 1.28
--- Tool.java 22 Feb 2007 12:36:57 -0000 1.29
***************
*** 62,65 ****
--- 62,67 ----
/** the tool for creating relation between elements */
public static final int RELATION_TOOL = 20;
+ /** the tool for focusing on objects */
+ public static final int FOCUS_TOOL = 21;
/**
|