[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool FinalMoveTool.java, 1.47, 1.48
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-12-20 09:37:49
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv12790/src/net/sourceforge/bprocessor/gl/tool Modified Files: FinalMoveTool.java Log Message: changeTool on Editor now return the resulting tool from the change... FinalMovetool start a move of a instance by grabbing the handle by which it is moved and make Instance popup choice start moving the created instance. Index: FinalMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/FinalMoveTool.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** FinalMoveTool.java 18 Dec 2007 23:41:36 -0000 1.47 --- FinalMoveTool.java 20 Dec 2007 09:37:44 -0000 1.48 *************** *** 14,17 **** --- 14,18 ---- import java.util.HashSet; import java.util.LinkedList; + import java.util.List; import java.util.Map; import java.util.Set; *************** *** 209,221 **** this.initialCoordinate = instance.getInstanceAnchor().copy(); this.handle = handle.copy(); - Transformation transformation = editor.getView().transformation(); - double x = pressPos[0]; - double y = View.getHeight() - pressPos[1]; - Vertex near = new Vertex(x, y, 0.0); - Vertex far = new Vertex(x, y, 1.0); - Edge ray = new Edge(near, far); - ray = transformation.unProject(ray); CoordinateSystem tmp = this.initialCoordinate.unTranslate(this.handle); ! Vertex center = tmp.plane().intersection(ray); start = new Intersection(center, start.type(), start.object()); --- 210,215 ---- this.initialCoordinate = instance.getInstanceAnchor().copy(); this.handle = handle.copy(); CoordinateSystem tmp = this.initialCoordinate.unTranslate(this.handle); ! Vertex center = tmp.center(); start = new Intersection(center, start.type(), start.object()); *************** *** 495,559 **** @Override protected void pressed(MouseEvent e) { - if (geometrics == null) { ! geometrics = new LinkedList(); if (Selection.primary().isEmpty()) { if (target != null) { ! geometrics.add((Geometric) target); ! } ! } else { ! geometrics.addAll(Selection.primary()); ! } ! ! owner = Project.getInstance().getActiveSpace(); ! for (Geometric current : geometrics) { ! if (current.getOwner() != owner) { ! GUI.getInstance().alert("All objects must belong to active space"); ! cleanUp(); ! return; ! } ! } ! ! if (!geometrics.isEmpty()) { ! copy = e.isAltDown(); ! if (copy) { ! mesh = new Mesh(geometrics); ! mesh = mesh.copyAndAssign(new HashMap()); ! geometrics = mesh.geometrics(); ! Project.getInstance().getActiveSpace().addProtected(geometrics); ! } else { ! mesh = null; ! } ! ! ! vertices = Geometry.collect(geometrics); ! mover = new VectorMove(vertices); ! ! affected = getAffected(geometrics); ! current = findIntersection(e); ! start = current.copy(); ! ! if (geometrics.size() == 1) { ! Geometric work = geometrics.iterator().next(); ! if (work instanceof Instance) { ! Instance space = (Instance)work; ! if (space.isInstance()) { ! CoordinateSystem anchor = null; ! for (CoordinateSystem currentSystem : space.getProto().getCoordinateSystems()) { ! anchor = currentSystem; ! break; ! } ! if (anchor == null) { ! anchor = Project.getInstance().getActiveCoordinateSystem().copy(); ! } ! mover = new InstanceMove(space, anchor); ! } ! } } - updateFeedback(); - setTip(secondClickTip()); } else { ! geometrics = null; } } else { finish(); --- 489,505 ---- @Override protected void pressed(MouseEvent e) { if (geometrics == null) { ! copy = e.isAltDown(); ! Intersection intersection = findIntersection(e); ! ! List<Geometric> actual = new LinkedList(); if (Selection.primary().isEmpty()) { if (target != null) { ! actual.add((Geometric) target); } } else { ! actual.addAll(Selection.primary()); } + activate(actual, intersection); } else { finish(); *************** *** 655,657 **** --- 601,661 ---- " Escape cancels."; } + + /*** + * Activate the tool on this collection of geometric + * @param geoms the list of geometric + * @param intersection The intersection at start + */ + public void activate(Collection<? extends Geometric> geoms, Intersection intersection) { + current = intersection; + start = current; + geometrics = (Collection<Geometric>)geoms; + owner = Project.getInstance().getActiveSpace(); + for (Geometric current : geometrics) { + if (current.getOwner() != owner) { + GUI.getInstance().alert("All objects must belong to active space"); + cleanUp(); + return; + } + } + + if (!geometrics.isEmpty()) { + if (copy) { + mesh = new Mesh(geometrics); + mesh = mesh.copyAndAssign(new HashMap()); + geometrics = mesh.geometrics(); + Project.getInstance().getActiveSpace().addProtected(geometrics); + } else { + mesh = null; + } + + + vertices = Geometry.collect(geometrics); + mover = new VectorMove(vertices); + + affected = getAffected(geometrics); + + if (geometrics.size() == 1) { + Geometric work = geometrics.iterator().next(); + if (work instanceof Instance) { + Instance space = (Instance)work; + if (space.isInstance()) { + CoordinateSystem anchor = null; + for (CoordinateSystem currentSystem : space.getProto().getCoordinateSystems()) { + anchor = currentSystem; + break; + } + if (anchor == null) { + anchor = Project.getInstance().getActiveCoordinateSystem().copy(); + } + mover = new InstanceMove(space, anchor); + } + } + } + updateFeedback(); + setTip(secondClickTip()); + } else { + geometrics = null; + } + } } |