Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3842/src/net/sourceforge/bprocessor/gl/tool
Modified Files:
FinalMoveTool.java
Log Message:
Started on instanceMover
Index: FinalMoveTool.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/FinalMoveTool.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** FinalMoveTool.java 18 Nov 2007 21:30:17 -0000 1.34
--- FinalMoveTool.java 23 Nov 2007 10:27:56 -0000 1.35
***************
*** 26,29 ****
--- 26,30 ----
import net.sourceforge.bprocessor.model.Geometric;
import net.sourceforge.bprocessor.model.Geometry;
+ import net.sourceforge.bprocessor.model.Matrix;
import net.sourceforge.bprocessor.model.Mesh;
import net.sourceforge.bprocessor.model.Project;
***************
*** 188,191 ****
--- 189,241 ----
/**
+ * A moover for Instances
+ */
+ public class InstanceMove implements Mover {
+ private Space instance;
+ private CoordinateSystem handle;
+ private CoordinateSystem initialCoordinate;
+ private Matrix translation;
+
+ /**
+ * Costructor
+ * @param instance the instance to move
+ * @param handle the handle to moove acording to
+ */
+ public InstanceMove(Space instance, CoordinateSystem handle) {
+ this.instance = instance;
+ this.handle = handle;
+ this.initialCoordinate = instance.getInstanceAnchor().copy();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void move(Vertex delta) {
+ revert();
+ if (current.object() instanceof Surface) {
+ // convert the handle into the coordinatesystems of the surface and translate
+ //the instance anchor according to that
+ Surface onto = (Surface)current.object();
+ CoordinateSystem cs = onto.coordinateSystem().plane().coordinateSystem();
+ CoordinateSystem anchor = instance.getInstanceAnchor();
+ anchor.setAttributes(cs.getAttributes());
+ anchor.setOrigin(current.vertex());
+ } else {
+ // change i, j, n of the anchor back to its originals and then just move the delta
+ instance.getInstanceAnchor().setIJN(initialCoordinate.getI(),
+ initialCoordinate.getJ(), initialCoordinate.getN());
+ instance.getInstanceAnchor().move(delta.getX(), delta.getY(), delta.getZ());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void revert() {
+ instance.getInstanceAnchor().setAttributes(initialCoordinate.getAttributes());
+ }
+ }
+
+ /**
* Move Handle
*
***************
*** 435,441 ****
}
vertices = Geometry.collect(geometrics);
mover = new VectorMove(vertices);
!
affected = getAffected(geometrics);
current = findIntersection(e);
--- 485,501 ----
}
+
vertices = Geometry.collect(geometrics);
mover = new VectorMove(vertices);
!
! if (geometrics.size() == 1) {
! Geometric work = geometrics.iterator().next();
! if (work instanceof Space) {
! Space space = (Space)work;
! if (space.isInstance()) {
! mover = new InstanceMove(space, space.getInstanceAnchor());
! }
! }
! }
affected = getAffected(geometrics);
current = findIntersection(e);
|