Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27028
Modified Files:
TapeMeasureTool.java
Log Message:
typing in a length ends measurement when pressing enter. X, Y and Z axis can be clicked now
Index: TapeMeasureTool.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/TapeMeasureTool.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TapeMeasureTool.java 30 Nov 2005 15:39:59 -0000 1.2
--- TapeMeasureTool.java 5 Dec 2005 17:26:37 -0000 1.3
***************
*** 30,33 ****
--- 30,42 ----
private static Logger log = Logger.getLogger(TapeMeasureTool.class);
+ /** The x axis */
+ private Edge xAxis = new Edge("x", new Vertex("", -50, 0, 0), new Vertex("", 50, 0, 0));
+
+ /** The y axis */
+ private Edge yAxis = new Edge("y", new Vertex("", 0, -50, 0), new Vertex("", 0, 50, 0));
+
+ /**The z axis */
+ private Edge zAxis = new Edge("z", new Vertex("", 0, 0, -50), new Vertex("", 0, 0, 50));
+
/** The current edge */
private Edge currentEdge;
***************
*** 54,57 ****
--- 63,68 ----
private String number;
+ /** Tells if the tool is currently measuring or not */
+ private boolean measuring;
/**
* Constructor
***************
*** 61,64 ****
--- 72,76 ----
public TapeMeasureTool(GLView glv, Cursor cursor) {
super(glv, cursor);
+ measuring = false;
}
***************
*** 70,84 ****
if (currentEdge != null) {
if (movePlane == null) {
! findTarget(e);
! if (target instanceof Surface) {
! Surface targetSurface = (Surface)target;
! if (currentEdge.getSurfaces().contains(targetSurface)) {
! number = "";
! glv.getView().makeTarget(target);
! movePlane = targetSurface.plane();
! Vertex edgeDirection = currentEdge.getTo().minus(currentEdge.getFrom());
! Vertex surfaceNormal = targetSurface.normal();
! edgeNormal = edgeDirection.cross(surfaceNormal);
! move(e);
}
}
--- 82,110 ----
if (currentEdge != null) {
if (movePlane == null) {
! if (currentEdge.equals(xAxis)) {
! movePlane = new Plane(0, 0, 1, 0);
! edgeNormal = new Vertex("", 0, 1, 0);
! move(e);
! } else if (currentEdge.equals(yAxis)) {
! movePlane = new Plane(0, 0, 1, 0);
! edgeNormal = new Vertex("", 1, 0, 0);
! move(e);
! } else if (currentEdge.equals(zAxis)) {
! movePlane = new Plane(0, 1, 0, 0);
! edgeNormal = new Vertex("", 1, 0, 0);
! move(e);
! } else {
! findTarget(e);
! if (target instanceof Surface) {
! Surface targetSurface = (Surface)target;
! if (currentEdge.getSurfaces().contains(targetSurface)) {
! number = "";
! glv.getView().makeTarget(target);
! movePlane = targetSurface.plane();
! Vertex edgeDirection = currentEdge.getTo().minus(currentEdge.getFrom());
! Vertex surfaceNormal = targetSurface.normal();
! edgeNormal = edgeDirection.cross(surfaceNormal);
! move(e);
! }
}
}
***************
*** 127,135 ****
*/
protected void pressed(MouseEvent e) {
findTarget(e);
! if (currentEdge == null) {
if (target instanceof Edge) {
currentEdge = (Edge)target;
!
Vertex minus = currentEdge.getTo().minus(currentEdge.getFrom());
minus.scale(1 / minus.length());
--- 153,165 ----
*/
protected void pressed(MouseEvent e) {
+ View v = glv.getView();
+ v.addTempEdge(xAxis);
+ v.addTempEdge(yAxis);
+ v.addTempEdge(zAxis);
findTarget(e);
! if (!measuring) {
if (target instanceof Edge) {
currentEdge = (Edge)target;
! measuring = true;
Vertex minus = currentEdge.getTo().minus(currentEdge.getFrom());
minus.scale(1 / minus.length());
***************
*** 151,155 ****
double x = e.getX();
double y = AbstractView.getHeight() - e.getY();
- View v = glv.getView();
Transformation transformation = v.transformation();
Vertex near = new Vertex("near", x, y, 0.0);
--- 181,184 ----
***************
*** 167,181 ****
}
} else {
! View v = glv.getView();
! v.removeTempEdge(edgeToConstruction);
! v.removeTempVertex(edgePoint);
! v.removeTempVertex(constructionPoint);
! currentEdge = null;
! currentConstruction = null;
! movePlane = null;
! edgeToConstruction = null;
! removeVertex(edgePoint);
! removeVertex(constructionPoint);
}
}
--- 196,205 ----
}
} else {
! endTapeMeasure();
}
+ v.removeTempEdge(xAxis);
+ v.removeTempEdge(yAxis);
+ v.removeTempEdge(zAxis);
+
}
***************
*** 236,239 ****
--- 260,264 ----
edgeNormal.getY() * delta,
edgeNormal.getZ() * delta);
+ endTapeMeasure();
glv.repaint();
}
***************
*** 257,260 ****
super.keyPressed(e);
}
!
}
--- 282,303 ----
super.keyPressed(e);
}
!
! /**
! * Ends one tape measure
! */
! private void endTapeMeasure() {
! if (measuring) {
! View v = glv.getView();
! v.removeTempEdge(edgeToConstruction);
! v.removeTempVertex(edgePoint);
! v.removeTempVertex(constructionPoint);
! currentEdge = null;
! currentConstruction = null;
! movePlane = null;
! edgeToConstruction = null;
! removeVertex(edgePoint);
! removeVertex(constructionPoint);
! measuring = false;
! }
! }
}
|