[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui PopupMenu.java, 1.69, 1.70
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-11-12 08:05:34
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31982/src/net/sourceforge/bprocessor/gui Modified Files: PopupMenu.java Log Message: coordinate systems Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** PopupMenu.java 9 Nov 2007 13:58:45 -0000 1.69 --- PopupMenu.java 12 Nov 2007 08:05:30 -0000 1.70 *************** *** 124,127 **** --- 124,137 ---- /** + * + * @param systems Collection of coordinate systems + * @return Menu for coordinate systems + */ + public static JPopupMenu getCoordinateSystemMenu(Collection systems) { + JPopupMenu menu = getGeometricMenu(systems); + return menu; + } + + /** * A popup generator for a space * @param space the space *************** *** 359,362 **** --- 369,414 ---- Project.getInstance().getActiveSpace().add(union); Project.getInstance().changed(Project.getInstance()); + Project.getInstance().checkpoint(); + } + }; + menu.add(action); + } + { + AbstractAction action = new GeometricMenuAction(arguments, "Align Axes") { + public void actionPerformed(ActionEvent event) { + if (entities.size() == 1) { + Geometric geometric = entities.iterator().next(); + if (geometric instanceof Vertex) { + Vertex vertex = (Vertex) geometric; + Collection<Edge> edges = vertex.getEdges(); + double x = 0; + double y = 0; + double z = 0; + for (Edge current : edges) { + Vertex other = current.otherVertex(vertex); + Vertex v = other.minus(vertex); + x += v.getX(); + y += v.getY(); + z += v.getZ(); + } + x /= edges.size(); + y /= edges.size(); + z /= edges.size(); + Vertex n = new Vertex(x, y, z); + Edge edge = edges.iterator().next(); + Vertex other = edge.otherVertex(vertex); + + Vertex v = other.minus(vertex); + Vertex i = n.cross(v); + Vertex j = n.cross(i); + + Vertex o = vertex.copy(); + CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); + system.setIJN(i, j, n); + system.setOrigin(o); + Project.getInstance().changed(Project.getInstance()); + Project.getInstance().checkpoint(); + } + } } }; *************** *** 415,432 **** public static JPopupMenu getBackgroundMenu() { JPopupMenu menu = new JPopupMenu(); ! AbstractAction action = new AbstractAction("Cube...") { ! public void actionPerformed(ActionEvent event) { ! Command command = new Command.Cube(); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! action = new AbstractAction("Cylinder...") { ! public void actionPerformed(ActionEvent event) { ! Command command = new Command.Cylinder(); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); return menu; } --- 467,504 ---- public static JPopupMenu getBackgroundMenu() { JPopupMenu menu = new JPopupMenu(); ! { ! AbstractAction action = new AbstractAction("Reset View") { ! public void actionPerformed(ActionEvent event) { ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! Vertex i = new Vertex(1, 0, 0); ! Vertex j = new Vertex(0, 1, 0); ! Vertex n = new Vertex(0, 0, 1); ! Vertex o = new Vertex(0, 0, 0); ! system.setIJN(i, j, n); ! system.setOrigin(o); ! Project.getInstance().changed(Project.getInstance()); ! Project.getInstance().checkpoint(); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new AbstractAction("Cube...") { ! public void actionPerformed(ActionEvent event) { ! Command command = new Command.Cube(); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new AbstractAction("Cylinder...") { ! public void actionPerformed(ActionEvent event) { ! Command command = new Command.Cylinder(); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } return menu; } *************** *** 456,459 **** --- 528,533 ---- } else if (type instanceof Edge) { return getEdgeMenu(new LinkedList<Geometric>(Selection.primary())); + } else if (type instanceof CoordinateSystem) { + return getCoordinateSystemMenu(new LinkedList<Geometric>(Selection.primary())); } else { return PopupMenu.getGeometricMenu(new LinkedList<Geometric>(Selection.primary())); |