[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool RotationToolB.java, 1.1, 1.2 Extrusio
Status: Pre-Alpha
Brought to you by:
henryml
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv4483/src/net/sourceforge/bprocessor/gl/tool Modified Files: RotationToolB.java ExtrusionTool.java RotationTool.java FinalMoveTool.java AbstractPencil.java Protract.java Log Message: Index: ExtrusionTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrusionTool.java,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** ExtrusionTool.java 22 Dec 2009 13:51:51 -0000 1.77 --- ExtrusionTool.java 5 Feb 2010 13:32:59 -0000 1.78 *************** *** 25,29 **** import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometric; - import net.sourceforge.bprocessor.model.Geometry; import net.sourceforge.bprocessor.model.Line; import net.sourceforge.bprocessor.model.Mesh; --- 25,28 ---- *************** *** 254,258 **** ignore.addAll(extrusion); ignore.addAll(Surface.edges(extrusion)); ! ignore.addAll(Geometry.collect(extrusion)); } excluded(ignore); --- 253,257 ---- ignore.addAll(extrusion); ignore.addAll(Surface.edges(extrusion)); ! ignore.addAll(Geometric.collect(extrusion)); } excluded(ignore); Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** AbstractPencil.java 13 Jan 2010 10:58:30 -0000 1.112 --- AbstractPencil.java 5 Feb 2010 13:32:59 -0000 1.113 *************** *** 861,865 **** HashSet affected = new HashSet(); ! Set vertices = Geometry.collect(moveElements); Set edges = Vertex.edges(vertices); Set surfaces = Edge.surfaces(edges); --- 861,865 ---- HashSet affected = new HashSet(); ! Set vertices = Geometric.collect(moveElements); Set edges = Vertex.edges(vertices); Set surfaces = Edge.surfaces(edges); Index: Protract.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Protract.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Protract.java 22 Dec 2009 14:54:34 -0000 1.1 --- Protract.java 5 Feb 2010 13:32:59 -0000 1.2 *************** *** 63,71 **** drawNormal(gl); } /** {@inheritDoc} */ public Intersection intersection(Edge e) { ! Vertex n = u.cross(v); ! Plane plane = new Plane(n, origin); Vertex vertex = plane.intersection(e); return new Intersection(vertex, Intersection.PLANE_INTERSECTION, plane); --- 63,76 ---- drawNormal(gl); } + + private Plane plane() { + Vertex n = u.cross(v); + Plane plane = new Plane(n, origin); + return plane; + } /** {@inheritDoc} */ public Intersection intersection(Edge e) { ! Plane plane = plane(); Vertex vertex = plane.intersection(e); return new Intersection(vertex, Intersection.PLANE_INTERSECTION, plane); *************** *** 152,154 **** --- 157,165 ---- return handles; } + + /** {@inheritDoc} */ + public boolean contains(Vertex v) { + Plane plane = plane(); + return plane.contains(v); + } } Index: FinalMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/FinalMoveTool.java,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** FinalMoveTool.java 13 Jan 2010 10:58:30 -0000 1.56 --- FinalMoveTool.java 5 Feb 2010 13:32:59 -0000 1.57 *************** *** 29,33 **** import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometric; - import net.sourceforge.bprocessor.model.Geometry; import net.sourceforge.bprocessor.model.Instance; import net.sourceforge.bprocessor.model.Mesh; --- 29,32 ---- *************** *** 464,468 **** v.scaleIt(i); Mesh copy = mesh.copy(new HashMap()); ! for (Vertex current : Geometry.collect(copy.geometrics())) { current.setX(current.getX() + v.getX()); current.setY(current.getY() + v.getY()); --- 463,467 ---- v.scaleIt(i); Mesh copy = mesh.copy(new HashMap()); ! for (Vertex current : Geometric.collect(copy.geometrics())) { current.setX(current.getX() + v.getX()); current.setY(current.getY() + v.getY()); *************** *** 479,483 **** v.scaleIt(d / v.length()); Mesh copy = mesh.copy(new HashMap()); ! for (Vertex current : Geometry.collect(copy.geometrics())) { current.setX(current.getX() + v.getX()); current.setY(current.getY() + v.getY()); --- 478,482 ---- v.scaleIt(d / v.length()); Mesh copy = mesh.copy(new HashMap()); ! for (Vertex current : Geometric.collect(copy.geometrics())) { current.setX(current.getX() + v.getX()); current.setY(current.getY() + v.getY()); *************** *** 661,665 **** } ! vertices = Geometry.collect(geometrics); mover = new VectorMove(vertices); --- 660,664 ---- } ! vertices = Geometric.collect(geometrics); mover = new VectorMove(vertices); Index: RotationToolB.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/RotationToolB.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RotationToolB.java 13 Jan 2010 10:58:30 -0000 1.1 --- RotationToolB.java 5 Feb 2010 13:32:59 -0000 1.2 *************** *** 10,13 **** --- 10,15 ---- import java.awt.Cursor; import java.awt.event.MouseEvent; + import java.util.Collection; + import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; *************** *** 19,23 **** import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Geometry; - import net.sourceforge.bprocessor.model.Instance; import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; --- 21,24 ---- *************** *** 29,37 **** */ public class RotationToolB extends AbstractPencil { private CoordinateSystem system; private Protract protract; private Vertex base; ! private List<Vertex> vertices; ! private List<Vertex> originals; /** --- 30,44 ---- */ public class RotationToolB extends AbstractPencil { + private List<Vertex> vertices; + private List<Vertex> originals; + + private Collection<Geometric> affected; + private CoordinateSystem system; private Protract protract; private Vertex base; ! ! ! /** *************** *** 89,92 **** --- 96,100 ---- Project.getInstance().changed(vertices); cache(); + excluded(Collections.EMPTY_LIST); } *************** *** 95,110 **** */ protected void moved(MouseEvent e) { ! current = findIntersection(e); ! if (current != null) { ! if (system != null) { ! if (base != null) { ! double angle = angle(); ! if (!Double.isNaN(angle)) { ! rotate(angle); } } } - updateFeedback(); } } /** --- 103,125 ---- */ protected void moved(MouseEvent e) { ! if (vertices == null) { ! findTarget(e); ! } else { ! if (affected != null && base != null) { ! excluded(affected); ! } ! current = findIntersection(e); ! if (current != null) { ! if (system != null) { ! if (base != null) { ! double angle = angle(); ! if (!Double.isNaN(angle)) { ! rotate(angle); ! } } } } } + updateFeedback(); } /** *************** *** 112,140 **** */ protected void pressed(MouseEvent e) { ! current = findIntersection(e); ! if (current != null) { ! if (system != null) { ! if (base == null) { ! base = direction(); ! } else { ! double angle = angle(); ! rotate(angle); ! finish(); ! } ! } else { ! if (start == null) { ! start = current; } else { ! Vertex origin = start.vertex(); ! Vertex to = current.vertex(); ! Vertex n = to.minus(origin); ! if (!n.isZero()) { ! n.normalize(); ! system = CoordinateSystem.systemFor(origin, n); ! start = null; } } } - updateFeedback(); } } --- 127,164 ---- */ protected void pressed(MouseEvent e) { ! if (vertices == null) { ! if (target != null) { ! activate((Geometric) target); ! } ! } else { ! if (affected != null && base != null) { ! excluded(affected); ! } ! current = findIntersection(e); ! if (current != null) { ! if (system != null) { ! if (base == null) { ! base = direction(); ! } else { ! double angle = angle(); ! rotate(angle); ! finish(); ! } } else { ! if (start == null) { ! start = current; ! } else { ! Vertex origin = start.vertex(); ! Vertex to = current.vertex(); ! Vertex n = to.minus(origin); ! if (!n.isZero()) { ! n.normalize(); ! system = CoordinateSystem.systemFor(origin, n); ! start = null; ! } } } + updateFeedback(); } } } *************** *** 207,229 **** List<Edge> edges = new LinkedList(); ! if (current != null) { ! if (system != null) { ! showConstructors = false; ! Vertex center = system.getOrigin(); ! Vertex i = base(); ! Vertex j = normal().cross(i); ! protract = new Protract(center, i, j, true); ! editor.getView().addGlObjects3D(protract); ! } else { ! showConstructors = true; ! if (start != null) { ! Vertex origin = start.vertex(); ! Vertex to = current.vertex(); ! Edge axis = new Edge(origin, to); ! axis.setStrippled(true); ! edges.add(axis); } } } feedback(edges); makeTarget(current); --- 231,259 ---- List<Edge> edges = new LinkedList(); ! ! if (vertices != null) { ! if (current != null) { ! if (system != null) { ! showConstructors = false; ! Vertex center = system.getOrigin(); ! Vertex i = base(); ! Vertex j = normal().cross(i); ! protract = new Protract(center, i, j, true); ! editor.getView().addGlObjects3D(protract); ! } else { ! showConstructors = true; ! if (start != null) { ! Vertex origin = start.vertex(); ! Vertex to = current.vertex(); ! Edge axis = new Edge(origin, to); ! axis.setStrippled(true); ! edges.add(axis); ! } } } + } else { + editor.getView().makeTarget(target); } + feedback(edges); makeTarget(current); *************** *** 247,270 **** public void prepare() { setLabel("Angle:"); ! if (Selection.primary().size() == 1) { ! Geometric geometric = Selection.primary().iterator().next(); ! system = systemFor(geometric); ! if (system != null) { ! system = system.copy(); ! } } - vertices = new LinkedList(Selection.primary().collect()); - cache(); } ! private CoordinateSystem systemFor(Geometric geometric) { ! if (geometric instanceof Instance) { ! return systemFor((Instance) geometric); } - return null; } ! private CoordinateSystem systemFor(Instance instance) { ! return instance.getAnchor(); } --- 277,308 ---- public void prepare() { setLabel("Angle:"); ! System.out.println("rotation-prepare " + System.currentTimeMillis()); ! if (!Selection.primary().isEmpty()) { ! activate(Selection.primary()); } } ! ! /** ! * ! * @param geometric Geometric ! */ ! public void activate(Geometric geometric) { ! Collection<Geometric> geometrics = new LinkedList(); ! activate(geometrics); ! system = CoordinateSystem.systemFor(geometric); ! if (system != null) { ! system = system.copy(); } } ! /** ! * ! * @param geometrics Geometrics ! */ ! public void activate(Collection<Geometric> geometrics) { ! vertices = new LinkedList(Geometric.collect(geometrics)); ! cache(); ! affected = getAffected(geometrics); } *************** *** 287,290 **** --- 325,330 ---- base = null; system = null; + vertices = null; + affected = null; } } Index: RotationTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/RotationTool.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** RotationTool.java 13 Jan 2010 10:58:30 -0000 1.36 --- RotationTool.java 5 Feb 2010 13:32:59 -0000 1.37 *************** *** 432,435 **** --- 432,442 ---- return plane; } + + /** + * @inheritDoc + */ + public boolean contains(Vertex v) { + return getPlane().contains(v); + } } |