Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Project.java, 1.166, 1.167 Container
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-05-12 11:51:31
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10030/src/net/sourceforge/bprocessor/model Modified Files: Project.java Container.java Log Message: export obj Index: Container.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Container.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Container.java 4 May 2009 09:43:24 -0000 1.21 --- Container.java 12 May 2009 11:51:19 -0000 1.22 *************** *** 1597,1602 **** interior.orient(interior.getEnvelope().iterator().next()); interior.export(out); ! getOwner().add(holder); ! Project.getInstance().changed(Project.getInstance()); } --- 1597,1602 ---- interior.orient(interior.getEnvelope().iterator().next()); interior.export(out); ! //getOwner().add(holder); ! //Project.getInstance().changed(Project.getInstance()); } Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.166 retrieving revision 1.167 diff -C2 -d -r1.166 -r1.167 *** Project.java 12 May 2009 11:02:03 -0000 1.166 --- Project.java 12 May 2009 11:51:19 -0000 1.167 *************** *** 11,14 **** --- 11,16 ---- import java.io.ByteArrayOutputStream; import java.io.File; + import java.io.FileNotFoundException; + import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; *************** *** 33,36 **** --- 35,40 ---- import java.util.StringTokenizer; + import javax.swing.SwingUtilities; + import net.sourceforge.bprocessor.model.bridge.Connection; import net.sourceforge.bprocessor.model.bridge.DataItem; *************** *** 99,102 **** --- 103,107 ---- private static boolean doDisplayGeometry; private static boolean doDebugGeometry; + private static boolean doExport; /** The cameras */ *************** *** 118,121 **** --- 123,128 ---- private boolean dirty; + private boolean isExporting; + /** The path to the current project */ private String savePath; *************** *** 147,150 **** --- 154,159 ---- /** The script of the Project */ private Description script; + + private String exportPath; /** The copy buffer */ *************** *** 317,320 **** --- 326,330 ---- super(); setName("new project"); + setExportPath("b-processor-export.obj"); script = new Description(""); undoStack = new Stack(); *************** *** 747,750 **** --- 757,772 ---- public void makeDirty() { dirty = true; + if (doExport) { + if (!isExporting) { + isExporting = true; + SwingUtilities.invokeLater( + new Runnable() { + public void run() { + export(); + } + } + ); + } + } } *************** *** 1011,1015 **** } else if (a.getName().equals("Debug Geometry")) { doDebugGeometry = ((Boolean) a.getValue()).booleanValue(); ! } } changed(this); --- 1033,1041 ---- } else if (a.getName().equals("Debug Geometry")) { doDebugGeometry = ((Boolean) a.getValue()).booleanValue(); ! } else if (a.getName().equals("Export")) { ! doExport = ((Boolean) a.getValue()).booleanValue(); ! } else if (a.getName().equals("Export Path")) { ! setExportPath((String)a.getValue()); ! } } changed(this); *************** *** 1026,1029 **** --- 1052,1057 ---- res.add(new Attribute("Display Geometry", Boolean.valueOf(doDisplayGeometry))); res.add(new Attribute("Debug Geometry", Boolean.valueOf(doDebugGeometry))); + res.add(new Attribute("Export", Boolean.valueOf(doExport))); + res.add(new Attribute("Export Path", getExportPath())); res.add(new Attribute("Script", script)); return res; *************** *** 1053,1056 **** --- 1081,1101 ---- } + + /** + * + * @return Export Path + */ + public String getExportPath() { + return exportPath; + } + + /** + * Set export path + * @param value new export path + */ + public void setExportPath(String value) { + exportPath = value; + } + /** * String representation of the object *************** *** 1615,1620 **** /** * */ ! public void exportOBJ() { List<Container> constructs = new LinkedList(); for (Space current : world.getElements()) { --- 1660,1667 ---- /** * + * @param out OutputStream */ ! public void exportOBJ(OutputStream out) { ! PrintStream printer = new PrintStream(out); List<Container> constructs = new LinkedList(); for (Space current : world.getElements()) { *************** *** 1628,1633 **** for (Container current : constructs) { System.out.println("-- " + current.getName() + " --"); ! current.exportTesselated(System.out); } } --- 1675,1699 ---- for (Container current : constructs) { System.out.println("-- " + current.getName() + " --"); ! current.exportTesselated(printer); ! } ! } ! ! /** ! * ! */ ! public void export() { ! System.out.println("export to " + getExportPath()); ! try { ! OutputStream out = new FileOutputStream(new File(getExportPath())); ! exportOBJ(out); ! out.close(); ! } catch (FileNotFoundException e) { ! // TODO Auto-generated catch block ! System.out.println("cannot export to " + getExportPath()); ! } catch (IOException e) { ! // TODO Auto-generated catch block ! System.out.println("cannot export to " + getExportPath()); } + isExporting = false; } |