[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractTool.java,1.66,1.67 PencilTool
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-04-05 09:36:35
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8430/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java PencilTool.java ExtrudeTool.java ToolFactory.java SpaceTool.java MultiExtrudeTool.java DomainPopupListener.java AbstractPencil.java CreateSpaceActionListener.java Log Message: A large amount of changes because of the CVS outage at sourceforge. Element-modelling now completet Index: CreateSpaceActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/CreateSpaceActionListener.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CreateSpaceActionListener.java 24 Jan 2006 14:10:32 -0000 1.6 --- CreateSpaceActionListener.java 5 Apr 2006 09:36:16 -0000 1.7 *************** *** 14,17 **** --- 14,18 ---- import java.awt.event.ActionListener; + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Surface; *************** *** 55,67 **** public void actionPerformed(ActionEvent e) { String result; if (functional) { result = JOptionPane.showInputDialog(GUI.getInstance(), "Name", ! "Create Functional Space", JOptionPane.QUESTION_MESSAGE); } else { result = JOptionPane.showInputDialog(GUI.getInstance(), "Name", ! "Create Construction Space", JOptionPane.QUESTION_MESSAGE); } --- 56,75 ---- public void actionPerformed(ActionEvent e) { String result; + String category = null; + if (surface.getOwner() == Project.getInstance().world()) { + category = "Space"; + } else { + category = "Element"; + } + if (functional) { result = JOptionPane.showInputDialog(GUI.getInstance(), "Name", ! "Create Functional " + category, JOptionPane.QUESTION_MESSAGE); } else { result = JOptionPane.showInputDialog(GUI.getInstance(), "Name", ! "Create Construction " + category, JOptionPane.QUESTION_MESSAGE); } *************** *** 70,96 **** } if (result != null && !result.trim().equals("")) { Space space; if (functional) { space = Space.createFunctionalSpace(result.trim()); - Project.getInstance().add(space); } else { space = Space.createConstructionSpace(result.trim()); ! Project.getInstance().add(space); ! } - Space old; if (front) { - old = surface.getFrontDomain(); surface.setFrontDomain(space); } else { - old = surface.getBackDomain(); surface.setBackDomain(space); } ! space.addSurface(surface); ! space.changed(); ! if (old != null) { ! old.changed(); ! } } } --- 78,99 ---- } + Space owner = surface.getOwner(); + if (result != null && !result.trim().equals("")) { Space space; if (functional) { space = Space.createFunctionalSpace(result.trim()); } else { space = Space.createConstructionSpace(result.trim()); ! } ! ! owner.add(space); if (front) { surface.setFrontDomain(space); } else { surface.setBackDomain(space); } ! Project.getInstance().checkpoint(); } } Index: ExtrudeTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrudeTool.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ExtrudeTool.java 12 Mar 2006 12:33:01 -0000 1.14 --- ExtrudeTool.java 5 Apr 2006 09:36:16 -0000 1.15 *************** *** 22,26 **** import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; --- 22,25 ---- *************** *** 31,34 **** --- 30,36 ---- public class ExtrudeTool extends AbstractTool { + /** Limit offset */ + static final boolean LIMIT = false; + /** The dragSurface */ private Surface top; *************** *** 92,110 **** prevY = e.getY(); number = new String(); ! if (!selection.isEmpty()) { ! Object object = selection.iterator().next(); ! if (object instanceof Surface) { ! sides = new HashSet(); ! extrudeSurface = (Surface) object; ! View view = glv.getView(); ! Transformation trans = view.transformation(); ! double x = prevX; ! double y = View.getHeight() - prevY; ! Vertex near = new Vertex(x, y, 0.0); ! Vertex far = new Vertex(x, y, 1.0); ! Edge ray = new Edge(near, far); ! ray = trans.unProject(ray); ! dragplane = extrudeSurface.plane().orthogonalPlane(ray); ! } } } --- 94,111 ---- prevY = e.getY(); number = new String(); ! findTarget(e); ! ! if (target instanceof Surface) { ! sides = new HashSet(); ! extrudeSurface = (Surface) target; ! View view = glv.getView(); ! Transformation trans = view.transformation(); ! double x = prevX; ! double y = View.getHeight() - prevY; ! Vertex near = new Vertex(x, y, 0.0); ! Vertex far = new Vertex(x, y, 1.0); ! Edge ray = new Edge(near, far); ! ray = trans.unProject(ray); ! dragplane = extrudeSurface.plane().orthogonalPlane(ray); } } *************** *** 140,156 **** /** ! * Apply extrusion ! * @param length The length */ ! private void apply(double length) { if (top != null) { ! Project.getInstance().delete(top); Iterator iter = sides.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); ! Project.getInstance().delete(current); } sides = null; } if (extrudeSurface != null) { sides = new HashSet(); --- 141,165 ---- /** ! * */ ! private void removeExtrusion() { if (top != null) { ! top.delete(); ! top = null; Iterator iter = sides.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); ! current.delete(); } sides = null; } + } + + /** + * Apply extrusion + * @param length The length + */ + private void apply(double length) { + removeExtrusion(); if (extrudeSurface != null) { sides = new HashSet(); *************** *** 160,164 **** top = extrudeSurface.extrude(length, sides); holeAnalysis(top); ! Selection.primary().set(top); } } --- 169,173 ---- top = extrudeSurface.extrude(length, sides); holeAnalysis(top); ! Project.getInstance().checkpoint(); } } *************** *** 178,206 **** lowerLimit = Double.NEGATIVE_INFINITY; } ! ! Collection surfaces = Project.getInstance().getSurfaces(); ! Iterator iter = surfaces.iterator(); ! Vertex normal = top.normal(); ! Vertex origin = extrudeSurface.getFirstVertex(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! if (current != extrudeSurface && current != top) { ! Vertex n = current.normal(); ! Vertex cross = normal.cross(n); ! if (cross.isZero()) { ! Vertex o = current.getFirstVertex(); ! Vertex vector = o.minus(origin); ! double d = vector.dot(normal); ! if (direction > 0) { ! if (d > 0.0000001) { ! if (d < upperLimit) { ! upperLimit = d; } } ! } ! if (direction < 0) { ! if (d < -0.0000001) { ! if (d > lowerLimit) { ! lowerLimit = d; } } --- 187,216 ---- lowerLimit = Double.NEGATIVE_INFINITY; } ! if (LIMIT) { ! Collection surfaces = Project.getInstance().getSurfaces(); ! Iterator iter = surfaces.iterator(); ! Vertex normal = top.normal(); ! Vertex origin = extrudeSurface.getFirstVertex(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! if (current != extrudeSurface && current != top) { ! Vertex n = current.normal(); ! Vertex cross = normal.cross(n); ! if (cross.isZero()) { ! Vertex o = current.getFirstVertex(); ! Vertex vector = o.minus(origin); ! double d = vector.dot(normal); ! if (direction > 0) { ! if (d > 0.0000001) { ! if (d < upperLimit) { ! upperLimit = d; ! } } } ! if (direction < 0) { ! if (d < -0.0000001) { ! if (d > lowerLimit) { ! lowerLimit = d; ! } } } *************** *** 216,219 **** --- 226,233 ---- */ protected void moved(MouseEvent e) { + findTarget(e); + if (target instanceof Surface) { + glv.getView().makeTarget(target); + } } *************** *** 235,241 **** Vertex delta = to.minus(from); double normDotDelta = normal.dot(delta); ! double x = e.getX(); ! double y = e.getY(); if (top == null) { if (x * x + y * y > 16) { top = extrudeSurface.extrude(normDotDelta, sides); --- 249,256 ---- Vertex delta = to.minus(from); double normDotDelta = normal.dot(delta); ! if (top == null) { + double x = e.getX() - prevX; + double y = e.getY() - prevY; if (x * x + y * y > 16) { top = extrudeSurface.extrude(normDotDelta, sides); *************** *** 249,252 **** --- 264,311 ---- } } else { + if (!LIMIT) { + Set elements = new HashSet(); + { + Set edges = new HashSet(); + elements.add(extrudeSurface); + elements.addAll(sides); + elements.add(top); + Iterator iter = elements.iterator(); + while (iter.hasNext()) { + Surface current = (Surface) iter.next(); + edges.addAll(current.getEdges()); + } + elements.addAll(edges); + } + findTarget(e, elements); + if (target instanceof Surface) { + Vertex origin = extrudeSurface.getFirstVertex(); + Surface surface = (Surface) target; + if (surface != extrudeSurface && surface != top && !elements.contains(surface)) { + Vertex n = surface.normal(); + Vertex cross = normal.cross(n); + if (cross.isZero()) { + Vertex o = surface.getFirstVertex(); + Vertex vector = o.minus(origin); + double d = vector.dot(normal); + if (Math.abs(d) > 0.0000001) { + moveTo(d); + return; + } + } + } + } + if (target instanceof Edge) { + Vertex origin = extrudeSurface.getFirstVertex(); + Edge edge = (Edge) target; + Vertex o = edge.center(); + Vertex vector = o.minus(origin); + double d = vector.dot(normal); + if (Math.abs(d) > 0.0000001) { + moveTo(d); + return; + } + } + } moveTo(normDotDelta); } *************** *** 260,273 **** protected void released(MouseEvent e) { if (Math.abs(t) < 0.0000001) { ! if (top != null) { ! Project.getInstance().delete(top); ! top = null; ! Iterator iter = sides.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! Project.getInstance().delete(current); ! } ! sides = null; ! } } else { holeAnalysis(top); --- 319,323 ---- protected void released(MouseEvent e) { if (Math.abs(t) < 0.0000001) { ! removeExtrusion(); } else { holeAnalysis(top); *************** *** 277,281 **** holeAnalysis(current); } ! Selection.primary().set(top); } } --- 327,331 ---- holeAnalysis(current); } ! Project.getInstance().checkpoint(); } } Index: DomainPopupListener.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/DomainPopupListener.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DomainPopupListener.java 4 Jan 2006 14:29:50 -0000 1.4 --- DomainPopupListener.java 5 Apr 2006 09:36:16 -0000 1.5 *************** *** 9,12 **** --- 9,14 ---- import java.awt.event.ActionEvent; import java.awt.event.ActionListener; + + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; *************** *** 71,74 **** --- 73,77 ---- } surface.changed(); + Project.getInstance().checkpoint(); } } Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** ToolFactory.java 27 Mar 2006 14:41:03 -0000 1.40 --- ToolFactory.java 5 Apr 2006 09:36:16 -0000 1.41 *************** *** 181,185 **** move.setStrategy(vectorStrategy); rotation = new RotationTool(glv, pencilcursor); ! extrusion = new MultiExtrudeTool(glv, pencilcursor); clipplane = new ClipplaneTool(glv, pencilcursor); tapeMeasure = new TapeMeasureTool(glv, pencilcursor); --- 181,185 ---- move.setStrategy(vectorStrategy); rotation = new RotationTool(glv, pencilcursor); ! extrusion = new ExtrudeTool(glv, pencilcursor); clipplane = new ClipplaneTool(glv, pencilcursor); tapeMeasure = new TapeMeasureTool(glv, pencilcursor); Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** PencilTool.java 10 Mar 2006 16:41:25 -0000 1.63 --- PencilTool.java 5 Apr 2006 09:36:16 -0000 1.64 *************** *** 195,199 **** protected void intern(Surface surface) { if (surface.getId() == null) { ! Project.getInstance().add(surface); } } --- 195,199 ---- protected void intern(Surface surface) { if (surface.getId() == null) { ! Project.getInstance().world().insert(surface); } } Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** AbstractTool.java 29 Mar 2006 08:11:58 -0000 1.66 --- AbstractTool.java 5 Apr 2006 09:36:16 -0000 1.67 *************** *** 29,33 **** import java.net.URL; - import java.util.List; import java.util.Iterator; import java.util.Set; --- 29,32 ---- *************** *** 402,416 **** return edge; } - - /** - * Make and register a new Surface - * @param edges The list of edges in the surface - * @return The new Surface - */ - protected Surface createSurface(List edges) { - Surface surface = new Surface(edges); - Project.getInstance().add(surface); - return surface; - } /** --- 401,404 ---- Index: SpaceTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SpaceTool.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SpaceTool.java 26 Feb 2006 10:52:26 -0000 1.15 --- SpaceTool.java 5 Apr 2006 09:36:16 -0000 1.16 *************** *** 11,14 **** --- 11,15 ---- import java.awt.event.ActionEvent; import java.awt.event.ActionListener; + import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.Arrays; *************** *** 83,86 **** --- 84,103 ---- } + /** + * SpaceAction for making actions on spaces + */ + protected abstract class SpaceAction extends MenuAction { + /** The space to operate on */ + protected Space space; + + /** + * Constructor + * @param space The space to operate on + */ + public SpaceAction(Space space) { + this.space = space; + } + + } /** *************** *** 206,209 **** --- 223,229 ---- public class Cylinder extends Modellor { + /** Default */ + private static final long serialVersionUID = 1L; + /** radius */ private double radius = 1.0; *************** *** 215,224 **** private int axisDivisions = 12; - /** height divisions */ - private int heightDivisions = 1; - - /** cap divisions */ - private int capDivisions = 1; - /*** * Generate a Cylinder --- 235,238 ---- *************** *** 277,291 **** edges.add(se[i]); sf[i] = new Surface(edges); ! Project.getInstance().add(sf[i]); } { List edges = new LinkedList(Arrays.asList(be)); bottom = new Surface(edges); ! Project.getInstance().add(bottom); } { List edges = new LinkedList(Arrays.asList(te)); top = new Surface(edges); ! Project.getInstance().add(top); } } --- 291,305 ---- edges.add(se[i]); sf[i] = new Surface(edges); ! Project.getInstance().world().insert(sf[i]); } { List edges = new LinkedList(Arrays.asList(be)); bottom = new Surface(edges); ! Project.getInstance().world().insert(bottom); } { List edges = new LinkedList(Arrays.asList(te)); top = new Surface(edges); ! Project.getInstance().world().insert(top); } } *************** *** 363,372 **** */ private JPopupMenu spacePopup(String side) { ! JPopupMenu pp = new JPopupMenu(side); SpacePopupListener spl = new SpacePopupListener(side.equals("front"), glv.getView()); ! Collection domains = Project.getInstance().getSpaces(); ! Iterator domIt = domains.iterator(); Iterator selIt = new HashSet(selection).iterator(); Surface surface = null; if (selIt.hasNext()) { Object o = selIt.next(); --- 377,388 ---- */ private JPopupMenu spacePopup(String side) { ! JPopupMenu menu = new JPopupMenu(side); SpacePopupListener spl = new SpacePopupListener(side.equals("front"), glv.getView()); ! ! Iterator selIt = new HashSet(selection).iterator(); Surface surface = null; + Space space = null; + if (selIt.hasNext()) { Object o = selIt.next(); *************** *** 374,377 **** --- 390,403 ---- surface = (Surface)o; } + + if (surface != null) { + if (side.equals("front")) { + space = surface.getFrontDomain(); + } + if (side.equals("back")) { + space = surface.getBackDomain(); + } + } + JMenuItem noneItem = new JMenuItem("NONE"); ActionListener noneListener = new DomainPopupListener(null, *************** *** 380,384 **** noneItem.addActionListener(noneListener); ! JMenuItem createFuncItem = new JMenuItem("New Functional Space"); ActionListener funcListener = new CreateSpaceActionListener(surface, side.equals("front"), --- 406,421 ---- noneItem.addActionListener(noneListener); ! Collection domains = null; ! String category = null; ! if (surface.getOwner() == Project.getInstance().world()) { ! domains = Project.getInstance().getSpaces(); ! category = "Space"; ! } else { ! domains = surface.getOwner().getElements(); ! category = "Element"; ! } ! ! ! JMenuItem createFuncItem = new JMenuItem("New Functional " + category); ActionListener funcListener = new CreateSpaceActionListener(surface, side.equals("front"), *************** *** 386,390 **** createFuncItem.addActionListener(funcListener); ! JMenuItem createConstItem = new JMenuItem("New Construction Space"); ActionListener constListener = new CreateSpaceActionListener(surface, side.equals("front"), --- 423,427 ---- createFuncItem.addActionListener(funcListener); ! JMenuItem createConstItem = new JMenuItem("New Construction" + category); ActionListener constListener = new CreateSpaceActionListener(surface, side.equals("front"), *************** *** 392,399 **** createConstItem.addActionListener(constListener); ! JMenu funcMenu = new JMenu("Functional Spaces"); ! JMenu constMenu = new JMenu("Construction Spaces"); ! boolean funcEnabled = false; ! boolean constEnabled = false; while (domIt.hasNext()) { Space domain = (Space)domIt.next(); --- 429,451 ---- createConstItem.addActionListener(constListener); ! JMenuItem editSpaceItem = new JMenuItem("Edit Space"); ! editSpaceItem.addActionListener(new SpaceAction(space) { ! public void actionPerformed(ActionEvent arg0) { ! if (space != null) { ! selection.clear(); ! glv.getView().makeTarget(null); ! Project.getInstance().setActiveSpace(space); ! } ! } ! }); ! ! ! ! ! ! JMenu funcMenu = new JMenu("Functional " + category + "s"); ! JMenu constMenu = new JMenu("Construction " + category + "s"); ! ! Iterator domIt = domains.iterator(); while (domIt.hasNext()) { Space domain = (Space)domIt.next(); *************** *** 416,432 **** constMenu.addSeparator(); constMenu.add(createConstItem); ! pp.add(funcMenu); ! pp.add(constMenu); ! pp.addSeparator(); ! pp.add(noneItem); ! pp.addPopupMenuListener(spl); ! pp.pack(); ! return pp; } else { log.warn("Space popup menu has no surface"); return null; ! } } ! } --- 468,497 ---- constMenu.addSeparator(); constMenu.add(createConstItem); ! menu.add(funcMenu); ! menu.add(constMenu); ! menu.addSeparator(); ! menu.add(noneItem); ! menu.add(editSpaceItem); ! menu.addPopupMenuListener(spl); ! menu.pack(); ! return menu; } else { log.warn("Space popup menu has no surface"); return null; ! } } ! /** ! * Invoked when a key has been pressed. Lets user delete what is selected. ! * @param e The KeyEvent ! */ ! public void keyPressed(KeyEvent e) { ! if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { ! selection.clear(); ! glv.getView().makeTarget(null); ! Project.getInstance().setActiveSpace(null); ! } else { ! super.keyPressed(e); ! } ! } } Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** AbstractPencil.java 30 Mar 2006 07:41:27 -0000 1.20 --- AbstractPencil.java 5 Apr 2006 09:36:16 -0000 1.21 *************** *** 111,114 **** --- 111,121 ---- */ public Vertex insertVertex(Vertex vertex) { + + Space space = mesh(); + + if (vertex.getOwner() != space) { + vertex = vertex.copy(); + } + Vertex actual = null; { *************** *** 186,190 **** if (from == to) { Surface surface = new Surface(actual); ! mesh().add(surface); holeAnalysis(surface); } else { --- 193,197 ---- if (from == to) { Surface surface = new Surface(actual); ! mesh().insert(surface); holeAnalysis(surface); } else { *************** *** 316,319 **** --- 323,330 ---- constructors.add(parrallel); } + if (plane != null) { + info(plane); + info("origin = " + plane.origin()); + } } } *************** *** 425,428 **** --- 436,440 ---- case Intersection.SURFACE: target = intersection.object(); + plane = ((Surface) target).plane(); break; case Intersection.EDGE_MIDPOINT: *************** *** 437,440 **** --- 449,453 ---- case Intersection.PLANE_INTERSECTION: target = null; + plane = (Plane) intersection.object(); break; } *************** *** 596,598 **** --- 609,619 ---- timer.stop(); } + + /** + * info + * @param info Info + */ + public static void info(Object info) { + log.info(info); + } } Index: MultiExtrudeTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MultiExtrudeTool.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** MultiExtrudeTool.java 29 Mar 2006 08:14:28 -0000 1.12 --- MultiExtrudeTool.java 5 Apr 2006 09:36:16 -0000 1.13 *************** *** 146,157 **** } ! if (direction == 0) { //we have never set the direction; ! direction = normDotDelta; ! } if (top == null) { // there are no extrusion make one if we move the mouse if ((e.getX() - pressX) * (e.getX() - pressX) + ! (e.getY() - pressY) * (e.getY() - pressY) > 16) { elements = makeExtrusion(surfaces); } --- 146,158 ---- } ! //if (direction == 0) { //we have never set the direction; ! //direction = normDotDelta; ! //} if (top == null) { // there are no extrusion make one if we move the mouse if ((e.getX() - pressX) * (e.getX() - pressX) + ! (e.getY() - pressY) * (e.getY() - pressY) > 32) { ! direction = normDotDelta; elements = makeExtrusion(surfaces); } *************** *** 219,222 **** --- 220,224 ---- */ private void moveTo(Collection which, double to) { + Project.info("move-to " + to); double delta = t - to; Iterator iter = which.iterator(); *************** *** 275,278 **** --- 277,281 ---- while (iter.hasNext()) { Surface cur = (Surface)iter.next(); + Project.info("extruding in " + direction); Surface s = cur.extrude(direction, elements, e2e, v2e, e2s, v2dir); if (cur == extrudeSurface) { |