[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/actions FileImportActionListener.java, 1
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-10-29 18:16:18
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25598/src/net/sourceforge/bprocessor/gui/actions Modified Files: FileImportActionListener.java ImportFileReader.java Log Message: added a calc normals checkbox to obj import window that make importer call calcSmoothNormals on all surfaces, if none is present in the file. Index: FileImportActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileImportActionListener.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FileImportActionListener.java 29 Oct 2007 09:05:18 -0000 1.10 --- FileImportActionListener.java 29 Oct 2007 18:16:21 -0000 1.11 *************** *** 17,20 **** --- 17,21 ---- import javax.swing.BoxLayout; + import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFileChooser; *************** *** 110,114 **** into.add(s); ImportFileReader.importObjFile(lfile, s, info.objPanel.getScale(), ! info.objPanel.getDirection()); Project.getInstance().changed(s); Project.getInstance().checkpoint(); --- 111,115 ---- into.add(s); ImportFileReader.importObjFile(lfile, s, info.objPanel.getScale(), ! info.objPanel.getDirection(), info.objPanel.getCalcNormals()); Project.getInstance().changed(s); Project.getInstance().checkpoint(); *************** *** 125,128 **** --- 126,130 ---- private JComboBox basis; private JTextField scale; + private JCheckBox generateNomals; public OBJJPanel() { *************** *** 136,139 **** --- 138,144 ---- scale.addActionListener(this); this.add(scale); + generateNomals = new JCheckBox("Calc normals"); + generateNomals.setSelected(false); + this.add(generateNomals); } *************** *** 158,161 **** --- 163,174 ---- /** + * Tell if normals should be calculated + * @return a boolean value + */ + public boolean getCalcNormals() { + return generateNomals.isSelected(); + } + + /** * Return a int beeing one of the static finals XY, ZX, YZ which * is the coords that should be treated as XY plane when importing *************** *** 263,267 **** */ private CVSinfo(JFileChooser fc) { ! setPreferredSize(new Dimension(100, 50)); csvPanel = new CSVJPanel(); objPanel = new OBJJPanel(); --- 276,280 ---- */ private CVSinfo(JFileChooser fc) { ! setPreferredSize(new Dimension(150, 50)); csvPanel = new CSVJPanel(); objPanel = new OBJJPanel(); Index: ImportFileReader.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/ImportFileReader.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ImportFileReader.java 29 Oct 2007 09:05:18 -0000 1.9 --- ImportFileReader.java 29 Oct 2007 18:16:21 -0000 1.10 *************** *** 67,74 **** * @param scale The scale to import in * @param basisPlane the plane to use as xy plane. Use one of the static final ints in * net.sourceforge.bprocessor.gui.actions.FileImportActionListener * @throws IOException a possible file read error */ ! public static void importObjFile(File f, Space into, double scale, int basisPlane) throws IOException { if (f.exists()) { --- 67,76 ---- * @param scale The scale to import in * @param basisPlane the plane to use as xy plane. Use one of the static final ints in + * @param calcNormals Should the import calc smooth normals if there aint any * net.sourceforge.bprocessor.gui.actions.FileImportActionListener * @throws IOException a possible file read error */ ! public static void importObjFile(File f, Space into, double scale, ! int basisPlane, boolean calcNormals) throws IOException { if (f.exists()) { *************** *** 86,89 **** --- 88,92 ---- Space currentGroup = into.createConstructionSpace("Object"); Material currentMaterial = null; + boolean missNormals = false; groups.add(currentGroup); int lineNum = 0; *************** *** 165,168 **** --- 168,173 ---- if (!normals.isEmpty()) { s.setNormals(normals); + } else { + missNormals = true; } surfaces.add(s); *************** *** 192,198 **** } for (Space s : groups) { ! if (!s.getVertices().isEmpty()) { into.add(s); } } for (Material m : materialMap.values()) { --- 197,204 ---- } for (Space s : groups) { ! if (!s.getEnvelope().isEmpty()) { into.add(s); } + s.setLocked(true); } for (Material m : materialMap.values()) { *************** *** 206,211 **** --- 212,222 ---- } for (Surface s : surfaces) { + if (calcNormals && missNormals) { + s.calcNormals(); + } into.addProtected(s); } + into.setLocked(true); + into.add(new CoordinateSystem(new Vertex(0, 0, 0))); into.changed(); stream.close(); |