Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10370/src/net/sourceforge/bprocessor/gl/tool
Modified Files:
ClipplaneTool.java
Log Message:
made it possible to drag the clipplane to a "better" place when placing
Index: ClipplaneTool.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ClipplaneTool.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** ClipplaneTool.java 7 Nov 2006 10:51:19 -0000 1.10
--- ClipplaneTool.java 7 May 2007 13:30:20 -0000 1.11
***************
*** 8,13 ****
--- 8,17 ----
import net.sourceforge.bprocessor.gl.GLView;
+ import net.sourceforge.bprocessor.gl.view.Transformation;
+ import net.sourceforge.bprocessor.gl.view.View;
import net.sourceforge.bprocessor.model.ClippingPlane;
import net.sourceforge.bprocessor.model.CoordinateSystem;
+ import net.sourceforge.bprocessor.model.Edge;
+ import net.sourceforge.bprocessor.model.Plane;
import net.sourceforge.bprocessor.model.Project;
import net.sourceforge.bprocessor.model.Surface;
***************
*** 26,29 ****
--- 30,36 ----
/** The logger */
private static Logger log = Logger.getLogger(ClipplaneTool.class);
+ private ClippingPlane cp;
+ private Vertex previous;
+ private Plane dragplane;
/**
***************
*** 56,60 ****
system = new CoordinateSystem(i, j, n, o);
! ClippingPlane cp = new ClippingPlane(system);
if (Project.getInstance().getCurrentCamera().getClipplanes().size() <
glv.getView().getMaxClipPlanes()) {
--- 63,67 ----
system = new CoordinateSystem(i, j, n, o);
! cp = new ClippingPlane(system);
if (Project.getInstance().getCurrentCamera().getClipplanes().size() <
glv.getView().getMaxClipPlanes()) {
***************
*** 62,65 ****
--- 69,83 ----
Project.getInstance().changed(Project.getInstance().getCurrentCamera());
}
+
+ View view = glv.getView();
+ previous = view.toPlaneCoords(e.getX(), e.getY(), cp.getPlane());
+ Transformation trans = view.transformation();
+ double x = e.getX();
+ double y = View.getHeight() - e.getY();
+ Vertex near = new Vertex(x, y, 0.0);
+ Vertex far = new Vertex(x, y, 1.0);
+ Edge ray = new Edge(near, far);
+ ray = trans.unProject(ray);
+ dragplane = surface.plane().orthogonalPlane(ray);
}
}
***************
*** 82,86 ****
*/
protected void dragged(MouseEvent e) {
!
}
--- 100,109 ----
*/
protected void dragged(MouseEvent e) {
! if (cp != null) {
! Vertex to = glv.getView().toPlaneCoords(e.getX(), e.getY(), dragplane);
! Vertex delta = to.minus(previous);
! cp.move(delta.getX(), delta.getY(), delta.getZ());
! previous = to;
! }
}
***************
*** 89,93 ****
*/
protected void released(MouseEvent e) {
!
}
}
--- 112,116 ----
*/
protected void released(MouseEvent e) {
! cp = null;
}
}
|