[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool SpaceTool.java, 1.40, 1.41 AbstractPe
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-09-26 09:52:32
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19110/src/net/sourceforge/bprocessor/gl/tool Modified Files: SpaceTool.java AbstractPencil.java ControlledMoveTool.java CreateSpaceActionListener.java Log Message: added levels to space and added union as a boolean, now the entire program uses that change Index: SpaceTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SpaceTool.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** SpaceTool.java 19 Sep 2006 19:22:34 -0000 1.40 --- SpaceTool.java 26 Sep 2006 09:52:29 -0000 1.41 *************** *** 32,38 **** --- 32,40 ---- import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.gui.PopupMenu; import net.sourceforge.bprocessor.model.ClippingPlane; import net.sourceforge.bprocessor.model.Constructor; import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; *************** *** 156,197 **** */ protected JPopupMenu makeSelectionMenu() { ! if (target instanceof String) { ! String type = (String) target; ! JPopupMenu menu = new JPopupMenu(); ! JMenuItem layerItem = new JMenuItem("Layer"); ! System.out.println(target); ! Surface surface = null; ! Space space = null; ! ! Iterator iter = Selection.primary().iterator(); ! while (iter.hasNext()) { ! Object current = iter.next(); ! if (current instanceof Surface) { ! surface = (Surface) current; ! } ! } ! if (surface != null) { ! if (type.equals("front")) { ! space = surface.getFrontDomain(); } ! if (type.equals("back")) { ! space = surface.getBackDomain(); } } - layerItem.addActionListener(new LayerAction(space, surface)); - menu.add(layerItem); - return menu; } else { ! ! JPopupMenu menu = new JPopupMenu(); ! JMenuItem offsetItem = new JMenuItem("Offset Constraint"); ! offsetItem.addActionListener(new MenuAction() { ! public void actionPerformed(ActionEvent event) { ! addOffsetConstraint(Selection.primary()); } ! } ! ); ! menu.add(offsetItem); ! return menu; } } --- 158,220 ---- */ protected JPopupMenu makeSelectionMenu() { ! if (Selection.primary().isEmpty()) { ! if (target instanceof String) { ! String type = (String) target; ! JPopupMenu menu = new JPopupMenu(); ! JMenuItem layerItem = new JMenuItem("Layer"); ! Surface surface = null; ! Space space = null; ! ! Iterator iter = Selection.primary().iterator(); ! while (iter.hasNext()) { ! Object current = iter.next(); ! if (current instanceof Surface) { ! surface = (Surface) current; ! } } ! if (surface != null) { ! if (type.equals("front")) { ! space = surface.getFrontDomain(); ! } ! if (type.equals("back")) { ! space = surface.getBackDomain(); ! } } + layerItem.addActionListener(new LayerAction(space, surface)); + menu.add(layerItem); + return menu; + } else if (target instanceof Space) { + return PopupMenu.getSpaceMenu((Space)target); + } else if (target instanceof Entity) { + JPopupMenu menu = PopupMenu.getEntityMenu((Entity) target); + + JMenuItem offsetItem = new JMenuItem("Offset Constraint"); + offsetItem.addActionListener(new MenuAction() { + public void actionPerformed(ActionEvent event) { + addOffsetConstraint(Selection.primary()); + } + } + ); + menu.add(offsetItem); + return menu; + } else { + return null; } } else { ! Iterator sel = Selection.primary().iterator(); ! Collection entities = new LinkedList(); ! while (sel.hasNext()) { ! Object next = sel.next(); ! if (Selection.primary().size() == 1) { ! if (next instanceof Space) { ! return PopupMenu.getSpaceMenu((Space)next); ! } else { ! return PopupMenu.getEntityMenu((Entity)next); ! } ! } else { ! entities.add(next); } ! } ! return PopupMenu.getEntiesMenu(entities); } } *************** *** 438,451 **** Collection domains = null; String category = null; ! Space owner = surface.getOwner(); ! Space world = Project.getInstance().world(); ! if (owner == world) { domains = Project.getInstance().getSpaces(); category = "Space"; ! } else if (owner.getOwner() == world) { domains = owner.getElements(); category = "Element"; ! } else { domains = owner.getElements(); category = "Part"; --- 461,476 ---- Collection domains = null; String category = null; ! Space owner = space.getOwner(); ! if (space.getLevel() == Space.PROJECT_LEVEL) { domains = Project.getInstance().getSpaces(); + category = "Project"; + } else if (space.getLevel() == Space.SPACE_LEVEL) { + domains = owner.getElements(); category = "Space"; ! } else if (space.getLevel() == Space.ELEMENT_LEVEL) { domains = owner.getElements(); category = "Element"; ! } else if (space.getLevel() == Space.PART_LEVEL) { domains = owner.getElements(); category = "Part"; *************** *** 465,479 **** createConstItem.addActionListener(constListener); ! JMenuItem editSpaceItem = new JMenuItem("Edit Space"); ! editSpaceItem.addActionListener(new SpaceAction(space) { ! public void actionPerformed(ActionEvent arg0) { ! if (space != null) { ! Selection.primary().clear(); ! glv.getView().makeTarget(null); ! Project.getInstance().setActiveSpace(space); } ! } ! }); ! JMenuItem copySpaceItem = new JMenuItem("Duplicate Space"); copySpaceItem.addActionListener(new SpaceAction(space) { public void actionPerformed(ActionEvent arg0) { --- 490,507 ---- createConstItem.addActionListener(constListener); ! JMenuItem editSpaceItem = null; ! if (space.isContainer()) { ! editSpaceItem = new JMenuItem("Edit " + category); ! editSpaceItem.addActionListener(new SpaceAction(space) { ! public void actionPerformed(ActionEvent arg0) { ! if (space != null) { ! Selection.primary().clear(); ! glv.getView().makeTarget(null); ! Project.getInstance().setActiveSpace(space); ! } } ! }); ! } ! JMenuItem copySpaceItem = new JMenuItem("Duplicate " + category); copySpaceItem.addActionListener(new SpaceAction(space) { public void actionPerformed(ActionEvent arg0) { *************** *** 487,491 **** }); ! JMenuItem flipSpaceItem = new JMenuItem("Rotate Space 90 degrees CCW"); flipSpaceItem.addActionListener(new SpaceAction(space) { public void actionPerformed(ActionEvent arg0) { --- 515,519 ---- }); ! JMenuItem flipSpaceItem = new JMenuItem("Rotate " + category + " 90 degrees CCW"); flipSpaceItem.addActionListener(new SpaceAction(space) { public void actionPerformed(ActionEvent arg0) { *************** *** 507,527 **** JMenu constMenu = new JMenu("Construction " + category + "s"); ! Iterator domIt = domains.iterator(); ! while (domIt.hasNext()) { ! Space domain = (Space)domIt.next(); ! if (domain instanceof Space) { ! JMenuItem domainItem = new JMenuItem(domain.getName()); ! ActionListener ml = new DomainPopupListener(domain, ! surface, ! side.equals("front")); ! domainItem.addActionListener(ml); ! if (domain.isFunctionalSpace()) { ! funcMenu.add(domainItem); ! } else { ! constMenu.add(domainItem); } } } - funcMenu.addSeparator(); funcMenu.add(createFuncItem); --- 535,556 ---- JMenu constMenu = new JMenu("Construction " + category + "s"); ! if (domains != null) { ! Iterator domIt = domains.iterator(); ! while (domIt.hasNext()) { ! Space domain = (Space)domIt.next(); ! if (domain instanceof Space) { ! JMenuItem domainItem = new JMenuItem(domain.getName()); ! ActionListener ml = new DomainPopupListener(domain, ! surface, ! side.equals("front")); ! domainItem.addActionListener(ml); ! if (domain.isFunctionalSpace()) { ! funcMenu.add(domainItem); ! } else { ! constMenu.add(domainItem); ! } } } } funcMenu.addSeparator(); funcMenu.add(createFuncItem); *************** *** 533,537 **** //menu.add(voidItem); menu.add(copySpaceItem); ! menu.add(editSpaceItem); menu.add(flipSpaceItem); menu.addPopupMenuListener(spl); --- 562,568 ---- //menu.add(voidItem); menu.add(copySpaceItem); ! if (editSpaceItem != null) { ! menu.add(editSpaceItem); ! } menu.add(flipSpaceItem); menu.addPopupMenuListener(spl); *************** *** 618,625 **** parser.script(globals); } catch (Exception error) { ! Project.info(error); } try { ! Project.info("evaluate '" + value + "'"); Environment global = new Environment(globals, null); Environment env = new Environment(global, new HashMap(), new LinkedList()); --- 649,656 ---- parser.script(globals); } catch (Exception error) { ! log.info(error); } try { ! log.info("evaluate '" + value + "'"); Environment global = new Environment(globals, null); Environment env = new Environment(global, new HashMap(), new LinkedList()); *************** *** 651,655 **** } catch (Exception error) { ! Project.info(error); } return null; --- 682,686 ---- } catch (Exception error) { ! log.info(error); } return null; *************** *** 660,664 **** */ public void key(KeyEvent event) { ! { String value; if (typing) { --- 691,695 ---- */ public void key(KeyEvent event) { ! if (!event.isAltDown() && !event.isControlDown()) { String value; if (typing) { *************** *** 673,677 **** typing = true; } else { ! Project.info(new Character(ch)); if (event.getKeyCode() == KeyEvent.VK_ENTER) { evaluate(value); --- 704,708 ---- typing = true; } else { ! log.info(new Character(ch)); if (event.getKeyCode() == KeyEvent.VK_ENTER) { evaluate(value); Index: CreateSpaceActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/CreateSpaceActionListener.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CreateSpaceActionListener.java 15 May 2006 09:17:55 -0000 1.9 --- CreateSpaceActionListener.java 26 Sep 2006 09:52:30 -0000 1.10 *************** *** 61,69 **** String result; category = null; ! if (surface.getOwner() == Project.getInstance().world()) { category = "Space"; ! } else { category = "Element"; } if (functional) { --- 61,73 ---- String result; category = null; ! if (Project.getInstance().getActiveSpace().getLevel() == Space.SPACE_LEVEL) { category = "Space"; ! } ! if (Project.getInstance().getActiveSpace().getLevel() == Space.ELEMENT_LEVEL) { category = "Element"; } + if (Project.getInstance().getActiveSpace().getLevel() == Space.PART_LEVEL) { + category = "Part"; + } if (functional) { *************** *** 86,104 **** 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(); } } --- 90,110 ---- if (result != null && !result.trim().equals("")) { ! try { ! Space space; ! if (functional) { ! space = owner.createFunctionalSpace(result.trim()); ! } else { ! space = owner.createConstructionSpace(result.trim()); ! } ! owner.add(space); ! if (front) { ! surface.setFrontDomain(space); ! } else { ! surface.setBackDomain(space); ! } ! Project.getInstance().checkpoint(); ! } catch (Exception ex) { ! ex.printStackTrace(); } } } Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** AbstractPencil.java 18 Sep 2006 14:09:58 -0000 1.67 --- AbstractPencil.java 26 Sep 2006 09:52:29 -0000 1.68 *************** *** 671,675 **** glv.setLength(d / 1000); } catch (NumberFormatException exp) { ! Project.info(exp); } } --- 671,675 ---- glv.setLength(d / 1000); } catch (NumberFormatException exp) { ! log.warn(exp); } } *************** *** 731,735 **** apply(d / 1000); } catch (NumberFormatException exp) { ! Project.info(exp); } } --- 731,735 ---- apply(d / 1000); } catch (NumberFormatException exp) { ! log.warn(exp); } } *************** *** 739,743 **** glv.setLength(d / 1000); } catch (NumberFormatException exp) { ! Project.info(exp); } } --- 739,743 ---- glv.setLength(d / 1000); } catch (NumberFormatException exp) { ! log.warn(exp); } } *************** *** 806,816 **** return affected; } - - /** - * info - * @param info Info - */ - public static void info(Object info) { - log.info(info); - } } --- 806,808 ---- Index: ControlledMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ControlledMoveTool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ControlledMoveTool.java 5 Sep 2006 11:01:43 -0000 1.4 --- ControlledMoveTool.java 26 Sep 2006 09:52:30 -0000 1.5 *************** *** 16,19 **** --- 16,21 ---- import java.util.Map; + import org.apache.log4j.Logger; + import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.model.Edge; *************** *** 32,35 **** --- 34,39 ---- /** Direction */ private Vertex direction; + /** the logger */ + private static Logger log = Logger.getLogger(ControlledMoveTool.class); /** *************** *** 243,253 **** double slideScale; if (delta == null) { ! Project.info("delta null"); } if (slideDir == null) { ! Project.info("slideDir null"); } if (deltaUnit == null) { ! Project.info("deltaUnit null"); } if (delta.getX() != 0) { --- 247,257 ---- double slideScale; if (delta == null) { ! log.info("delta null"); } if (slideDir == null) { ! log.info("slideDir null"); } if (deltaUnit == null) { ! log.info("deltaUnit null"); } if (delta.getX() != 0) { |