bprocessor-commit Mailing List for B-processor (Page 49)
Status: Pre-Alpha
Brought to you by:
henryml
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(12) |
Jul
(117) |
Aug
(151) |
Sep
(157) |
Oct
(81) |
Nov
(117) |
Dec
(119) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(183) |
Feb
(130) |
Mar
(117) |
Apr
(61) |
May
(82) |
Jun
(45) |
Jul
(149) |
Aug
(173) |
Sep
(199) |
Oct
(165) |
Nov
(107) |
Dec
(137) |
2007 |
Jan
(124) |
Feb
(58) |
Mar
(123) |
Apr
(80) |
May
(130) |
Jun
(64) |
Jul
(31) |
Aug
(42) |
Sep
(114) |
Oct
(167) |
Nov
(239) |
Dec
(200) |
2008 |
Jan
(43) |
Feb
(43) |
Mar
(4) |
Apr
(9) |
May
(5) |
Jun
(1) |
Jul
(3) |
Aug
(3) |
Sep
(13) |
Oct
(9) |
Nov
(12) |
Dec
|
2009 |
Jan
|
Feb
(20) |
Mar
(7) |
Apr
(12) |
May
(34) |
Jun
(72) |
Jul
|
Aug
(3) |
Sep
(31) |
Oct
(2) |
Nov
(8) |
Dec
(4) |
2010 |
Jan
(5) |
Feb
(32) |
Mar
(8) |
Apr
(7) |
May
(36) |
Jun
|
Jul
(11) |
Aug
(15) |
Sep
(7) |
Oct
(2) |
Nov
(13) |
Dec
(80) |
2011 |
Jan
|
Feb
|
Mar
(8) |
Apr
(12) |
May
(32) |
Jun
(9) |
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(8) |
2012 |
Jan
|
Feb
|
Mar
(3) |
Apr
(5) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(22) |
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael L. <he...@us...> - 2007-10-16 11:03:09
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7773/src/net/sourceforge/bprocessor/gl/tool Modified Files: FinalMoveTool.java Log Message: Fixed bug in Space.simplify() Index: FinalMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/FinalMoveTool.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** FinalMoveTool.java 17 Sep 2007 13:58:40 -0000 1.25 --- FinalMoveTool.java 16 Oct 2007 11:02:57 -0000 1.26 *************** *** 455,460 **** moved(e); } - - System.out.println("geometrics = " + geometrics); } --- 455,458 ---- |
From: Michael L. <he...@us...> - 2007-10-15 14:08:51
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18256/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: Removed large amount of code Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.251 retrieving revision 1.252 diff -C2 -d -r1.251 -r1.252 *** View.java 15 Oct 2007 11:45:45 -0000 1.251 --- View.java 15 Oct 2007 14:08:53 -0000 1.252 *************** *** 20,33 **** import net.sourceforge.bprocessor.model.Constructor; import net.sourceforge.bprocessor.model.CoordinateSystem; - import net.sourceforge.bprocessor.model.Defaults; import net.sourceforge.bprocessor.model.AxisRotate; import net.sourceforge.bprocessor.model.Geometric; - import net.sourceforge.bprocessor.model.Geometry; - import net.sourceforge.bprocessor.model.Line; - import net.sourceforge.bprocessor.model.Net; import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Camera; [...1610 lines suppressed...] - } - - /** - * The vertex callback. - * @param vertex an object representing the vertex. - */ - public void vertex(Object vertex) { - if (vertex instanceof TesselatorPoint) { - TesselatorPoint p = (TesselatorPoint)vertex; - gl.glVertex3d(p.x, p.y, p.z); - } else { - log.error("A none-point object was passed to the tessellator"); - } - } - } - - /** * Return the near plane * @return The near plane --- 1685,1688 ---- |
From: rimestad <rim...@us...> - 2007-10-15 12:44:06
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16540/src/net/sourceforge/bprocessor/gui Modified Files: PopupMenu.java Log Message: When makepopupfromselection is called the list is packed into a new collection structure to be able to empty the selction and then alter the objects Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** PopupMenu.java 12 Oct 2007 10:19:15 -0000 1.43 --- PopupMenu.java 15 Oct 2007 12:43:56 -0000 1.44 *************** *** 399,403 **** Selection.primary().clear(); for (Entity current : entities) { ! ((Geometric) current).erase(); Project.getInstance().changed(current); } --- 399,407 ---- Selection.primary().clear(); for (Entity current : entities) { ! if (current instanceof Geometric) { ! ((Geometric)current).erase(); ! } else { ! current.delete(); ! } Project.getInstance().changed(current); } *************** *** 570,582 **** type = next; } else if (!next.getClass().isInstance(type)) { ! return PopupMenu.getEntiesMenu(new LinkedList(Selection.primary())); } } if (type instanceof Space) { ! return PopupMenu.getSpaceMenu(Selection.primary()); } else if (type instanceof Surface) { ! return PopupMenu.getSurfaceMenu(Selection.primary()); } else { ! return PopupMenu.getEntiesMenu(new LinkedList(Selection.primary())); } } --- 574,586 ---- type = next; } else if (!next.getClass().isInstance(type)) { ! return PopupMenu.getEntiesMenu(new LinkedList<Geometric>(Selection.primary())); } } if (type instanceof Space) { ! return PopupMenu.getSpaceMenu(new LinkedList<Geometric>(Selection.primary())); } else if (type instanceof Surface) { ! return PopupMenu.getSurfaceMenu(new LinkedList<Geometric>(Selection.primary())); } else { ! return PopupMenu.getEntiesMenu(new LinkedList<Geometric>(Selection.primary())); } } |
From: rimestad <rim...@us...> - 2007-10-15 12:43:20
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16138/src/net/sourceforge/bprocessor/gui/actions Modified Files: ImportFileReader.java Log Message: Made obj import use the move specific material class Index: ImportFileReader.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/ImportFileReader.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ImportFileReader.java 12 Oct 2007 10:20:35 -0000 1.2 --- ImportFileReader.java 15 Oct 2007 12:42:51 -0000 1.3 *************** *** 27,30 **** --- 27,32 ---- import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.Material; + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; *************** *** 36,39 **** --- 38,42 ---- public class ImportFileReader { private static Logger log = Logger.getLogger(ImportFileReader.class); + /** * Importer for the obj format that is as follows *************** *** 73,81 **** Set<Surface> surfaces = new HashSet<Surface>(); Map<Vertex, Set<Edge>> v2es = new HashMap<Vertex, Set<Edge>>(); int lineNum = 0; while (br.ready()) { ! String line = br.readLine(); lineNum++; ! String[] lineContent = line.split(" "); if (lineContent[0].equals("v")) { Vertex v = new Vertex(Double.parseDouble(lineContent[1]), --- 76,90 ---- Set<Surface> surfaces = new HashSet<Surface>(); Map<Vertex, Set<Edge>> v2es = new HashMap<Vertex, Set<Edge>>(); + List<Space> groups = new LinkedList<Space>(); + Map<String, Material> materialMap = new HashMap<String, Material>(); + Space currentGroup = into.createConstructionSpace("Object"); + Material currentMaterial = new Material("Object", new float[]{0f, 0.9f, 0f}); + materialMap.put("default", currentMaterial); + groups.add(currentGroup); int lineNum = 0; while (br.ready()) { ! String line = br.readLine().trim(); lineNum++; ! String[] lineContent = line.split("\\s"); if (lineContent[0].equals("v")) { Vertex v = new Vertex(Double.parseDouble(lineContent[1]), *************** *** 96,103 **** } edge.add(findEdge(prev, first, v2es)); ! surfaces.add(new Surface(edge)); edges.addAll(edge); } } for (Vertex v : verts) { into.add(v); --- 105,135 ---- } edge.add(findEdge(prev, first, v2es)); ! Surface s = new Surface(edge); ! surfaces.add(s); ! s.setBackDomain(currentGroup); ! s.setFrontMaterial(currentMaterial); edges.addAll(edge); + } else if (lineContent[0].equals("g")) { + currentGroup = into.createConstructionSpace(lineContent[1]); + groups.add(currentGroup); + } else if (lineContent[0].equals("usemtl")) { + Material m = materialMap.get(lineContent[1]); + if (m != null) { + currentMaterial = m; + } + } else if (lineContent[0].equals("mtllib")) { + String name = lineContent[1]; + for (int i = 2; i < lineContent.length; i++) { + name += " " + lineContent[i]; + } + loadMaterials(new File(f.getParent() + "\\" + name), materialMap); } } + for (Space s : groups) { + into.add(s); + } + for (Material m : materialMap.values()) { + Project.getInstance().add(m); + } for (Vertex v : verts) { into.add(v); *************** *** 113,116 **** --- 145,237 ---- } + /** + * Read a obj material file as + * Comments begin with a '#' character in column 1. Blank lines may be inserted for clarity. + * Otherwise, the file consists of a sequence of newmtl statements, followed by a definition + * of various properties for that material. + * The quantities that may be defined for a material include: + * Ka r g b + * defines the ambient color of the material to be (r,g,b). The default is (0.2,0.2,0.2); + * Kd r g b + * defines the diffuse color of the material to be (r,g,b). The default is (0.8,0.8,0.8); + * Ks r g b + * defines the specular color of the material to be (r,g,b). This color shows up in + * highlights. The default is (1.0,1.0,1.0); + * d alpha + * defines the transparency of the material to be alpha. + * The default is 1.0 (not transparent at all) Some formats use Tr instead of d; + * Tr alpha + * defines the transparency of the material to be alpha. + * The default is 1.0 (not transparent at all). Some formats use d instead of Tr; + * Ns s + * defines the shininess of the material to be s. The default is 0.0; + * illum n + * denotes the illumination model used by the material. + * illum = 1 indicates a flat material with no specular highlights, so the value of Ks + * is not used. illum = 2 denotes the presence of specular highlights, and so a specification + * for Ks is required. + * map_Ka filename + * names a file containing a texture map, which should just be an ASCII dump of RGB values; + * @param file the material file + * @param materialMap A map from name to material + * @throws FileNotFoundException If file is not located + * @throws IOException If the file is unreadable + */ + private static void loadMaterials(File file, Map<String, Material> materialMap) + throws FileNotFoundException, IOException { + if (file.exists() && file.canRead()) { + FileInputStream stream = new FileInputStream(file); + InputStreamReader reader = new InputStreamReader(stream); + BufferedReader br = new BufferedReader(reader); + Material currentMaterial = null; + while (br.ready()) { + String line = br.readLine().trim(); + String[] content = line.split("\\s"); + if (content[0].equals("newmtl")) { + currentMaterial = new Material(); + currentMaterial.setName(content[1]); + materialMap.put(currentMaterial.getName(), currentMaterial); + } else { + if (currentMaterial != null) { + if (content[0].equals("Ka")) { + if (content.length >= 4) { + currentMaterial.setAmbientColor( + new float[]{Float.parseFloat(content[1]), + Float.parseFloat(content[2]), + Float.parseFloat(content[3])}); + } + } else if (content[0].equals("Kd")) { + if (content.length >= 4) { + currentMaterial.setDiffuseColor( + new float[]{Float.parseFloat(content[1]), + Float.parseFloat(content[2]), + Float.parseFloat(content[3])}); + } + } else if (content[0].equals("Ks")) { + if (content.length >= 4) { + currentMaterial.setSpecularColor( + new float[]{Float.parseFloat(content[1]), + Float.parseFloat(content[2]), + Float.parseFloat(content[3])}); + } + } else if (content[0].equals("d") || content[0].equals("Tr")) { + if (content.length >= 2) { + currentMaterial.setAlpha(Float.parseFloat(content[1])); + } + } else if (content[0].equals("Ns")) { + if (content.length >= 2) { + currentMaterial.setShininess(Float.parseFloat(content[1])); + } + } else if (content[0].equals("illum")) { + if (content.length >= 2) { + currentMaterial.setIllumination(Float.parseFloat(content[1])); + } + } + } + } + } + } + } + private static Edge findEdge(Vertex prev, Vertex cur, Map<Vertex, Set<Edge>> v2es) { Edge e = null; |
From: rimestad <rim...@us...> - 2007-10-15 12:41:47
|
Update of /cvsroot/bprocessor/model/src/etc In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15661/src/etc Modified Files: bprocessor.xsd Log Message: Changed material to be placed in the project not in the space, later on there should be a material attached to a space though to make things easier. Made the change to the persistence and all using classes as well Index: bprocessor.xsd =================================================================== RCS file: /cvsroot/bprocessor/model/src/etc/bprocessor.xsd,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** bprocessor.xsd 11 Oct 2007 10:21:46 -0000 1.32 --- bprocessor.xsd 15 Oct 2007 12:41:24 -0000 1.33 *************** *** 156,163 **** <xsd:complexContent> <xsd:extension base="EntityType"> <xsd:attribute name="name" type="xsd:string" use="required"/> ! <xsd:attribute name="R" type="xsd:float" use="required"/> ! <xsd:attribute name="G" type="xsd:float" use="required"/> ! <xsd:attribute name="B" type="xsd:float" use="required"/> </xsd:extension> </xsd:complexContent> --- 156,171 ---- <xsd:complexContent> <xsd:extension base="EntityType"> + <xsd:sequence> + <xsd:element name="ambientColor" type="TripletType" maxOccurs="1" minOccurs="0"/> + <xsd:element name="specularColor" type="TripletType" maxOccurs="1" minOccurs="0"/> + <xsd:element name="diffuseColor" type="TripletType" maxOccurs="1" minOccurs="0"/> + </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required"/> ! <xsd:attribute name="R" type="xsd:float" use="optional"/> ! <xsd:attribute name="G" type="xsd:float" use="optional"/> ! <xsd:attribute name="B" type="xsd:float" use="optional"/> ! <xsd:attribute name="alpha" type="xsd:double" use="optional"/> ! <xsd:attribute name="shininess" type="xsd:double" use="optional"/> ! <xsd:attribute name="illumination" type="xsd:double" use="optional"/> </xsd:extension> </xsd:complexContent> *************** *** 374,378 **** <xsd:element ref="material" maxOccurs="unbounded" minOccurs="0"/> <xsd:element name="camera" type="CameraType" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element name="global" type="MapElementType" maxOccurs="unbounded" minOccurs="0"/> </xsd:sequence> </xsd:complexType> --- 382,386 ---- <xsd:element ref="material" maxOccurs="unbounded" minOccurs="0"/> <xsd:element name="camera" type="CameraType" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element name="global" type="MapElementType" maxOccurs="unbounded" minOccurs="0"/> </xsd:sequence> </xsd:complexType> |
From: rimestad <rim...@us...> - 2007-10-15 12:41:37
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15661/src/net/sourceforge/bprocessor/model/modellor Modified Files: TileModellor.java Log Message: Changed material to be placed in the project not in the space, later on there should be a material attached to a space though to make things easier. Made the change to the persistence and all using classes as well Index: TileModellor.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/modellor/TileModellor.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** TileModellor.java 31 Aug 2007 09:09:08 -0000 1.18 --- TileModellor.java 15 Oct 2007 12:41:24 -0000 1.19 *************** *** 92,96 **** } space.getOwner().add(startPoint); ! space.add(tileColor); updateOutline(); updateNet(startPoint); --- 92,96 ---- } space.getOwner().add(startPoint); ! Project.getInstance().add(tileColor); updateOutline(); updateNet(startPoint); *************** *** 445,451 **** a = attributes.get("Material"); if (a != null) { ! space.remove(tileColor); tileColor = (Material)a.getValue(); ! space.add(tileColor); } a = attributes.get("Surface"); --- 445,452 ---- a = attributes.get("Material"); if (a != null) { ! Project p = Project.getInstance(); ! p.remove(tileColor); tileColor = (Material)a.getValue(); ! p.add(tileColor); } a = attributes.get("Surface"); |
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15661/src/net/sourceforge/bprocessor/model Modified Files: Space.java Persistence.java Surface.java Material.java Defaults.java Project.java Log Message: Changed material to be placed in the project not in the space, later on there should be a material attached to a space though to make things easier. Made the change to the persistence and all using classes as well Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.192 retrieving revision 1.193 diff -C2 -d -r1.192 -r1.193 *** Surface.java 9 Oct 2007 14:02:16 -0000 1.192 --- Surface.java 15 Oct 2007 12:41:24 -0000 1.193 *************** *** 1334,1338 **** */ public Material getFrontMaterial() { - return frontMaterial; } --- 1334,1337 ---- *************** *** 1852,1858 **** } } else if (a.getName().equals("Front Material")) { ! setFrontMaterial((Material) a.getValue()); } else if (a.getName().equals("Back Material")) { ! setBackMaterial((Material) a.getValue()); } else if (a.getName().equals("Holes")) { continue; --- 1851,1871 ---- } } else if (a.getName().equals("Front Material")) { ! if (a.getValue() instanceof String) { ! String s = (String)a.getValue(); ! for (Material m : Project.getInstance().getMaterials()) { ! if (s.equalsIgnoreCase(m.getName())) { ! setFrontMaterial(m); ! } ! } ! } } else if (a.getName().equals("Back Material")) { ! if (a.getValue() instanceof String) { ! String s = (String)a.getValue(); ! for (Material m : Project.getInstance().getMaterials()) { ! if (s.equalsIgnoreCase(m.getName())) { ! setBackMaterial(m); ! } ! } ! } } else if (a.getName().equals("Holes")) { continue; *************** *** 1885,1893 **** } else { if (getFrontDomain().isConstructionSpace()) { ! res.add(new Attribute("Front Material", new Material("", Defaults.getFrontColor()))); } else if (getFrontDomain().isFunctionalSpace()) { ! res.add(new Attribute("Front Material", new Material("", Defaults.getBackColor()))); } else { ! res.add(new Attribute("Front Material", new Material("", Defaults.getNoneColor()))); } } --- 1898,1906 ---- } else { if (getFrontDomain().isConstructionSpace()) { ! res.add(new Attribute("Front Material", Defaults.getFrontMaterial())); } else if (getFrontDomain().isFunctionalSpace()) { ! res.add(new Attribute("Front Material", Defaults.getBackMaterial())); } else { ! res.add(new Attribute("Front Material", Defaults.getNoneMaterial())); } } *************** *** 1903,1911 **** } else { if (getBackDomain().isConstructionSpace()) { ! res.add(new Attribute("Back Material", new Material("", Defaults.getFrontColor()))); } else if (getBackDomain().isFunctionalSpace()) { ! res.add(new Attribute("Back Material", new Material("", Defaults.getBackColor()))); } else { ! res.add(new Attribute("Back Material", new Material("", Defaults.getNoneColor()))); } } --- 1916,1924 ---- } else { if (getBackDomain().isConstructionSpace()) { ! res.add(new Attribute("Back Material", Defaults.getFrontMaterial())); } else if (getBackDomain().isFunctionalSpace()) { ! res.add(new Attribute("Back Material", Defaults.getBackMaterial())); } else { ! res.add(new Attribute("Back Material", Defaults.getNoneMaterial())); } } Index: Material.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Material.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Material.java 16 Apr 2007 15:55:22 -0000 1.9 --- Material.java 15 Oct 2007 12:41:24 -0000 1.10 *************** *** 7,11 **** --- 7,15 ---- package net.sourceforge.bprocessor.model; + import java.awt.Color; + import java.awt.color.ColorSpace; import java.io.Serializable; + import java.util.LinkedList; + import java.util.List; /** *************** *** 17,30 **** * usage="read-write" */ ! public class Material implements Serializable { /** The name of the material */ private String name; - /** The color of the material */ - private float[] color; - /** The id */ private Long id; /** --- 21,43 ---- * usage="read-write" */ ! public class Material extends Entity implements Parametric, Serializable { /** The name of the material */ private String name; /** The id */ private Long id; + + private float[] ambientColor; + + private float[] diffuseColor; + + private float[] specularColor; + + private double alpha; + + private double shininess; + + private double illumination; /** *************** *** 33,38 **** --- 46,58 ---- public Material() { setColor(0, 0, 0); + setAmbientColor(new float[]{0.2f, 0.2f, 0.2f}); + setDiffuseColor(new float[]{0.8f, 0.8f, 0.8f}); + setSpecularColor(new float[]{1.0f, 1.0f, 1.0f}); + setAlpha(1.0); + setShininess(0.0); + setIllumination(0.0); } + /** * Constructor for Material *************** *** 41,53 **** */ public Material(String name, float[] color3fv) { ! setName(name); if (color3fv != null) { ! setColor(color3fv); ! } else { ! setColor(0, 0, 0); } } /** * Get the id * @return The id --- 61,120 ---- */ public Material(String name, float[] color3fv) { ! this(); ! this.setName(name); if (color3fv != null) { ! this.setColor(color3fv); } } /** + * Set the degree of illumination + * @param d the illumination degree + */ + public void setIllumination(double d) { + this.illumination = d; + } + + /** + * Set the ambient color of the material + * @param fs The Color + */ + public void setAmbientColor(float[] fs) { + ambientColor = fs; + } + + /** + * Set the diffuse color of the material + * @param fs The Color + */ + public void setDiffuseColor(float[] fs) { + diffuseColor = fs; + } + + /** + * Set the specular color of the material + * @param fs The Color + */ + public void setSpecularColor(float[] fs) { + specularColor = fs; + } + + /** + * Set the alpha of the material + * @param alpha The Color + */ + public void setAlpha(double alpha) { + this.alpha = alpha; + } + + /** + * Set the shininess of the material + * @param value The degree of shininess + */ + public void setShininess(double value) { + this.shininess = value; + } + + /** * Get the id * @return The id *************** *** 91,97 **** */ public void setColor(float[] color3fv) { ! if (color3fv.length >= 3) { ! setColor(color3fv[0], color3fv[1], color3fv[2]); ! } } --- 158,162 ---- */ public void setColor(float[] color3fv) { ! setDiffuseColor(color3fv); } *************** *** 103,112 **** */ public void setColor(float r, float g, float b) { ! if (this.color == null) { ! this.color = new float[3]; } ! this.color[0] = r; ! this.color[1] = g; ! this.color[2] = b; } --- 168,177 ---- */ public void setColor(float r, float g, float b) { ! if (this.diffuseColor == null) { ! this.diffuseColor = new float[3]; } ! this.diffuseColor[0] = r; ! this.diffuseColor[1] = g; ! this.diffuseColor[2] = b; } *************** *** 117,121 **** */ public float[] getColor() { ! return (float[]) color.clone(); } } --- 182,289 ---- */ public float[] getColor() { ! return (float[]) diffuseColor.clone(); ! } ! ! /** ! * @return the alpha ! */ ! public double getAlpha() { ! return alpha; ! } ! ! /** ! * @return the ambientColor ! */ ! public float[] getAmbientColor() { ! return ambientColor; ! } ! ! /** ! * @return the diffuseColor ! */ ! public float[] getDiffuseColor() { ! return diffuseColor; ! } ! ! /** ! * @return the illumination ! */ ! public double getIllumination() { ! return illumination; ! } ! ! /** ! * @return the shininess ! */ ! public double getShininess() { ! return shininess; ! } ! ! /** ! * @return the specularColor ! */ ! public float[] getSpecularColor() { ! return specularColor; ! } ! ! /** ! * {@inheritDoc} ! */ ! @Override ! public void delete() { ! this.setId(null); ! Project.getInstance().remove(this); ! } ! ! /** ! * {@inheritDoc} ! */ ! public List<Attribute> getAttributes() { ! LinkedList<Attribute> res = new LinkedList<Attribute>(); ! res.add(new Attribute("Name", getName(), true)); ! res.add(new Attribute("Id", getId().toString(), false)); ! res.add(new Attribute("diffuseColor", ! new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), getDiffuseColor(), 1.0f))); ! res.add(new Attribute("ambientColor", ! new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), getAmbientColor(), 1.0f))); ! res.add(new Attribute("specularColor", ! new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), getSpecularColor(), 1.0f))); ! res.add(new Attribute("Aplha", alpha)); ! res.add(new Attribute("Shininess", shininess)); ! res.add(new Attribute("Illumination", illumination)); ! return res; ! } ! ! /** ! * {@inheritDoc} ! */ ! public String getGeneralName() { ! return "Material"; ! } ! ! /** ! * {@inheritDoc} ! */ ! public void setAttributes(List<Attribute> attributes) { ! for (Attribute a : attributes) { ! if (a.getName().equalsIgnoreCase("name")) { ! setName((String)a.getValue()); ! } else if (a.getName().equalsIgnoreCase("diffusecolor")) { ! Color c = (Color)a.getValue(); ! setDiffuseColor(c.getColorComponents(null)); ! } else if (a.getName().equalsIgnoreCase("ambientcolor")) { ! Color c = (Color)a.getValue(); ! setAmbientColor(c.getColorComponents(null)); ! } else if (a.getName().equalsIgnoreCase("specularcolor")) { ! Color c = (Color)a.getValue(); ! setSpecularColor(c.getColorComponents(null)); ! } else if (a.getName().equalsIgnoreCase("alpha")) { ! setAlpha((Double)a.getValue()); ! } else if (a.getName().equalsIgnoreCase("illumination")) { ! setIllumination((Double)a.getValue()); ! } else if (a.getName().equalsIgnoreCase("shininess")) { ! setShininess((Double)a.getValue()); ! } ! } } } Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.134 retrieving revision 1.135 diff -C2 -d -r1.134 -r1.135 *** Project.java 14 Sep 2007 10:11:32 -0000 1.134 --- Project.java 15 Oct 2007 12:41:24 -0000 1.135 *************** *** 16,19 **** --- 16,20 ---- import java.util.LinkedList; import java.util.List; + import java.util.Map; import java.util.Stack; import java.util.StringTokenizer; *************** *** 113,116 **** --- 114,121 ---- /** Flag set when updating */ private boolean updating = false; + + private Map<Long, Material> materials; + + private long nextMaterialId; /** *************** *** 153,156 **** --- 158,166 ---- world = new Space("World", Space.FUNCTIONAL, Space.PROJECT_LEVEL, true); world.setId(new Long(0)); + materials = new HashMap<Long, Material>(); + nextMaterialId = 0; + add(Defaults.getBackMaterial()); + add(Defaults.getFrontMaterial()); + add(Defaults.getNoneMaterial()); activeCoordinateSystem = new CoordinateSystem(new Vertex(1, 0, 0), new Vertex(0, 1, 0), new Vertex(0, 0, 1), new Vertex(0, 0, 0)); *************** *** 452,456 **** */ public void add(Material material) { ! world.add(material); } --- 462,470 ---- */ public void add(Material material) { ! if (material.getId() == null) { ! material.setId(new Long(nextMaterialId)); ! nextMaterialId++; ! } ! materials.put(material.getId(), material); } *************** *** 459,464 **** * @param material The material */ ! private void remove(Material material) { ! world.remove(material); } --- 473,478 ---- * @param material The material */ ! public void remove(Material material) { ! materials.remove(material.getId()); } *************** *** 475,480 **** * @return The Material */ ! public Collection getMaterials() { ! return world.getMaterials(); } --- 489,494 ---- * @return The Material */ ! public Collection<Material> getMaterials() { ! return materials.values(); } *************** *** 485,489 **** */ public Material findMaterialById(long id) { ! return (Material)world.getMaterial(id); } --- 499,503 ---- */ public Material findMaterialById(long id) { ! return materials.get(id); } Index: Defaults.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Defaults.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Defaults.java 10 Apr 2006 11:53:51 -0000 1.1 --- Defaults.java 15 Oct 2007 12:41:24 -0000 1.2 *************** *** 14,25 **** /** Front color for surfaces */ ! private static float[] frontColor = new float[] {0.90f, 0.90f, 0.90f}; ! /** NONE color for surfaces */ ! private static float[] noneColor = new float[] {0.40f, 0.58f, 0.93f}; ! /** Back color for surfaces */ ! private static float[] backColor = new float[] {0.96f, 0.87f, 0.70f}; ! /** * Return front color --- 14,23 ---- /** Front color for surfaces */ ! private static Material frontMaterial = new Material("Front", new float[] {0.90f, 0.90f, 0.90f}); /** NONE color for surfaces */ ! private static Material noneMaterial = new Material("None", new float[] {0.40f, 0.58f, 0.93f}); /** Back color for surfaces */ ! private static Material backMaterial = new Material("Back", new float[] {0.96f, 0.87f, 0.70f}); ! /** * Return front color *************** *** 27,33 **** */ public static float[] getFrontColor() { ! return frontColor; } /** * Return back color --- 25,56 ---- */ public static float[] getFrontColor() { ! return frontMaterial.getColor(); } + + /** + * @return the backMaterial + */ + public static Material getBackMaterial() { + return backMaterial; + } + + + /** + * @return the frontMaterial + */ + public static Material getFrontMaterial() { + return frontMaterial; + } + + + /** + * @return the noneMaterial + */ + public static Material getNoneMaterial() { + return noneMaterial; + } + + /** * Return back color *************** *** 35,39 **** */ public static float[] getBackColor() { ! return backColor; } --- 58,62 ---- */ public static float[] getBackColor() { ! return backMaterial.getColor(); } *************** *** 43,47 **** */ public static float[] getNoneColor() { ! return noneColor; } --- 66,70 ---- */ public static float[] getNoneColor() { ! return backMaterial.getColor(); } Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.182 retrieving revision 1.183 diff -C2 -d -r1.182 -r1.183 *** Space.java 12 Oct 2007 11:06:58 -0000 1.182 --- Space.java 15 Oct 2007 12:41:24 -0000 1.183 *************** *** 122,130 **** private long nextConstructorId; - /** The materials */ - private HashMap<Long, Material> materials; - /** The next surface id */ - private long nextMaterialId; - /** The transformation */ private TransformStack transform; --- 122,125 ---- *************** *** 195,200 **** elements = new HashMap<Long, Space>(); nextElementId = 1; - materials = new HashMap<Long, Material>(); - nextMaterialId = 1; constructors = new HashMap<Long, Constructor>(); nextConstructorId = 1; --- 190,193 ---- *************** *** 926,974 **** return (Surface) surfaces.get(new Long(id)); } - - /** - * Add a material - * @param material The material - */ - public void add(Material material) { - if (container) { - Long id = new Long(nextMaterialId++); - material.setId(id); - materials.put(id, material); - } else { - throw new Error("adding material to non-container " + this); - } - } - - /** - * Remove a material - * @param material The material - */ - public void remove(Material material) { - edges.remove(material.getId()); - material.setId(null); - } - - /** - * Return the materials - * @return The materials - */ - public Collection getMaterials() { - if (container) { - return materials.values(); - } else { - return Collections.EMPTY_LIST; - } - } - - /** - * Return the material - * @param id The id - * @return The material - */ - public Material getMaterial(long id) { - return (Material) materials.get(new Long(id)); - } - /** --- 919,922 ---- Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** Persistence.java 12 Oct 2007 08:10:57 -0000 1.48 --- Persistence.java 15 Oct 2007 12:41:24 -0000 1.49 *************** *** 126,138 **** (SpaceType) document.getSpace().iterator().next(), mapper, xmls); - { - Iterator iter = xmls.iterator(); - while (iter.hasNext()) { - EntityType external = (EntityType) iter.next(); - Object object = mapper.get(new Long(external.getId())); - internalizeReferences(object, external, mapper); - } - } Project p = Project.getInstance(); p.setWorld(world); p.setActiveCoordinateSystem( --- 126,132 ---- (SpaceType) document.getSpace().iterator().next(), mapper, xmls); Project p = Project.getInstance(); + p.getMaterials().clear(); + p.getConstructors().clear(); p.setWorld(world); p.setActiveCoordinateSystem( *************** *** 152,156 **** Project.getInstance().getGlobals().setAttributes(attributes); } ! { Iterator iter = document.getCamera().iterator(); --- 146,156 ---- Project.getInstance().getGlobals().setAttributes(attributes); } ! { ! Iterator iter = document.getMaterial().iterator(); ! while (iter.hasNext()) { ! MaterialType current = (MaterialType) iter.next(); ! p.add(internalizeMaterial(current, mapper, xmls)); ! } ! } { Iterator iter = document.getCamera().iterator(); *************** *** 185,188 **** --- 185,196 ---- } } + { + Iterator iter = xmls.iterator(); + while (iter.hasNext()) { + EntityType external = (EntityType) iter.next(); + Object object = mapper.get(new Long(external.getId())); + internalizeReferences(object, external, mapper); + } + } } *************** *** 336,340 **** space.setVertices(vertices); } ! { Iterator iter = xml.getMaterial().iterator(); while (iter.hasNext()) { --- 344,348 ---- space.setVertices(vertices); } ! /*{ Iterator iter = xml.getMaterial().iterator(); while (iter.hasNext()) { *************** *** 342,346 **** space.add(internalizeMaterial(current, mapper, xmls)); } ! } { Iterator iter = xml.getTransforms().iterator(); --- 350,354 ---- space.add(internalizeMaterial(current, mapper, xmls)); } ! }*/ { Iterator iter = xml.getTransforms().iterator(); *************** *** 784,802 **** HashMap mapper = new HashMap(); document.getSpace().add(externalizeSpace(Project.getInstance().world(), mapper)); - { ! Set entries = mapper.entrySet(); ! Iterator iter = entries.iterator(); ! while (iter.hasNext()) { ! Entry current = (Entry) iter.next(); ! Object object = current.getKey(); ! EntityType external = (EntityType) current.getValue(); ! externalizeReferences(object, external, mapper); } } - document.setCs(id(mapper, Project.getInstance().getActiveCoordinateSystem())); - document.setActive(id(mapper, Project.getInstance().getActiveSpace())); - document.setName(Project.getInstance().getName()); - { Collection globals = document.getGlobal(); --- 792,801 ---- HashMap mapper = new HashMap(); document.getSpace().add(externalizeSpace(Project.getInstance().world(), mapper)); { ! Collection materials = document.getMaterial(); ! for (Material m : Project.getInstance().getMaterials()) { ! materials.add(externalizeMaterial(m, mapper)); } } { Collection globals = document.getGlobal(); *************** *** 805,808 **** --- 804,810 ---- } } + document.setCs(id(mapper, Project.getInstance().getActiveCoordinateSystem())); + document.setActive(id(mapper, Project.getInstance().getActiveSpace())); + document.setName(Project.getInstance().getName()); { Collection cams = document.getCamera(); *************** *** 854,857 **** --- 856,869 ---- } } + { + Set entries = mapper.entrySet(); + Iterator iter = entries.iterator(); + while (iter.hasNext()) { + Entry current = (Entry) iter.next(); + Object object = current.getKey(); + EntityType external = (EntityType) current.getValue(); + externalizeReferences(object, external, mapper); + } + } return document; } *************** *** 995,999 **** } } ! { Iterator iter = space.getMaterials().iterator(); while (iter.hasNext()) { --- 1007,1011 ---- } } ! /*{ Iterator iter = space.getMaterials().iterator(); while (iter.hasNext()) { *************** *** 1001,1005 **** xml.getMaterial().add(externalizeMaterial(current, map)); } ! } { Iterator iter = space.getConstructors().iterator(); --- 1013,1017 ---- xml.getMaterial().add(externalizeMaterial(current, map)); } ! }*/ { Iterator iter = space.getConstructors().iterator(); *************** *** 1293,1297 **** externalizeReferences((Vertex) object, (VertexType) xml, map); } else if (object instanceof Material) { ! externalizeMaterial((Material) object, (MaterialType) xml, map); } else if (object instanceof Constructor) { externalizeReferences((Constructor) object, (ConstructorType) xml, map); --- 1305,1309 ---- externalizeReferences((Vertex) object, (VertexType) xml, map); } else if (object instanceof Material) { ! externalizeReference((Material) object, (MaterialType) xml, map); } else if (object instanceof Constructor) { externalizeReferences((Constructor) object, (ConstructorType) xml, map); *************** *** 1457,1461 **** * @param map The map */ ! private static void externalizeMaterial(Material object, MaterialType xml, Map map) { } --- 1469,1473 ---- * @param map The map */ ! private static void externalizeReference(Material object, MaterialType xml, Map map) { } |
From: Michael L. <he...@us...> - 2007-10-15 11:45:46
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25955/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Display.java Log Message: Not display net not active Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Display.java 15 Oct 2007 10:29:27 -0000 1.35 --- Display.java 15 Oct 2007 11:45:45 -0000 1.36 *************** *** 745,749 **** } } else { ! interior = true; } --- 745,757 ---- } } else { ! if (space instanceof Net) { ! if (space == active) { ! interior = true; ! } else { ! interior = false; ! } ! } else { ! interior = true; ! } } Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.250 retrieving revision 1.251 diff -C2 -d -r1.250 -r1.251 *** View.java 15 Oct 2007 10:29:27 -0000 1.250 --- View.java 15 Oct 2007 11:45:45 -0000 1.251 *************** *** 1617,1621 **** Vertex direction = to.minus(from); double dist = direction.length() * 16; - System.out.println("dist " + dist); gl.glEnable(GL.GL_LIGHTING); GLUquadric quad = glu.gluNewQuadric(); --- 1617,1620 ---- |
From: rimestad <rim...@us...> - 2007-10-15 11:36:11
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22422/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java Log Message: Made inner class private and change use of syso to log Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.132 retrieving revision 1.133 diff -C2 -d -r1.132 -r1.133 *** AbstractTool.java 27 Sep 2007 10:48:53 -0000 1.132 --- AbstractTool.java 15 Oct 2007 11:36:07 -0000 1.133 *************** *** 684,688 **** * Builtin function */ ! public abstract class Builtin implements Invokable { } --- 684,688 ---- * Builtin function */ ! private abstract class Builtin implements Invokable { } *************** *** 900,908 **** return stack; } catch (Exception error) { ! System.out.println(error); error.printStackTrace(); } } catch (Exception error) { ! System.out.println(error); } --- 900,908 ---- return stack; } catch (Exception error) { ! log.error(error); error.printStackTrace(); } } catch (Exception error) { ! log.error(error); } |
From: Michael L. <he...@us...> - 2007-10-15 10:29:32
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28075/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Display.java Log Message: fixed bug in hit-detection Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Display.java 15 Oct 2007 08:18:26 -0000 1.34 --- Display.java 15 Oct 2007 10:29:27 -0000 1.35 *************** *** 65,68 **** --- 65,69 ---- private static int mode; private static boolean transparency; + private static Collection<Geometric> excluded; private static Project project; *************** *** 213,216 **** --- 214,225 ---- /** + * + * @param value collection of excluded geometry + */ + public static void excluded(Collection<Geometric> value) { + excluded = value; + } + + /** * Returns the value of intersecting * @return intersecting *************** *** 651,656 **** if (intersecting) { for (Constructor current : constructors) { ! Collection<Edge> guides = current.guides(grid.size()); ! selectEdges(guides); } } else { --- 660,667 ---- if (intersecting) { for (Constructor current : constructors) { ! if (!excluded.contains(current)) { ! Collection<Edge> guides = current.guides(grid.size()); ! selectEdges(guides); ! } } } else { Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.249 retrieving revision 1.250 diff -C2 -d -r1.249 -r1.250 *** View.java 12 Oct 2007 14:34:34 -0000 1.249 --- View.java 15 Oct 2007 10:29:27 -0000 1.250 *************** *** 720,723 **** --- 720,724 ---- Display.colors(colorMap); Display.targetColor(targetColor); + Display.excluded(excluded); if (target instanceof Geometric) { Display.target((Geometric) target); |
From: Michael L. <he...@us...> - 2007-10-15 08:18:32
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8725/src/net/sourceforge/bprocessor/gl/view Modified Files: Display.java Log Message: Improved hit-detection Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Display.java 12 Oct 2007 14:34:34 -0000 1.33 --- Display.java 15 Oct 2007 08:18:26 -0000 1.34 *************** *** 485,489 **** drawContour(surface, reverse); for (Surface current : surface.getHoles()) { ! drawContour(current, false); } glu.gluTessEndPolygon(tesselator); --- 485,491 ---- drawContour(surface, reverse); for (Surface current : surface.getHoles()) { ! if (surface.getOwner() == current.getOwner()) { ! drawContour(current, false); ! } } glu.gluTessEndPolygon(tesselator); *************** *** 719,871 **** Collection<Constructor> constructors = new LinkedList(); ! for (Space current : space.getElements()) { ! if (!hidden.contains(current)) { ! elements.add(current); } } { ! Set<Surface> visible = new HashSet(); ! for (Space current : elements) { ! visible.addAll(current.getEnvelope()); ! } ! for (Surface current : visible) { if (!hidden.contains(current)) { ! surfaces.add(current); } } ! } ! { ! Set<Edge> visible = new HashSet(); ! for (Surface current : surfaces) { ! visible.addAll(current.getEdges()); ! for (Surface hole : current.getHoles()) { ! visible.addAll(hole.getEdges()); } ! } ! for (Edge current : visible) { ! if (!hidden.contains(current)) { ! edges.add(current); } } ! ! // FIXME the set of edges not connected ! // to a surface should be cashed. ! Set<Edge> mark = new HashSet(); ! for (Surface current : space.getSurfaces()) { ! mark.addAll(current.getEdges()); ! } ! for (Edge current : space.getEdges()) { ! if (!mark.contains(current)) { if (!hidden.contains(current)) { edges.add(current); } } ! } ! } ! ! { ! if (selecting() || (space instanceof Net && space == active)) { ! Set<Vertex> visible = new HashSet(); ! for (Edge current : edges) { ! visible.add(current.getFrom()); ! visible.add(current.getTo()); } ! for (Vertex current : visible) { ! if (!hidden.contains(current)) { ! vertices.add(current); } } } ! ! //FIXME: The set of lonely vertices should be cached. ! Set<Vertex> mark = new HashSet(); ! for (Edge current : space.getEdges()) { ! mark.add(current.getFrom()); ! mark.add(current.getTo()); ! } ! for (Vertex current : space.getVertices()) { ! if (!mark.contains(current)) { ! if (!hidden.contains(current)) { ! vertices.add(current); } } } ! } ! ! for (Constructor current : space.getConstructors()) { ! if (!hidden.contains(current)) { ! constructors.add(current); } } - - gl.glEnable(GL.GL_DEPTH_TEST); ! if (selecting()) { ! if (inside) { ! if (mode != View.WIREFRAME_MODE) { ! selectSurfaces(surfaces, transparency); } ! } ! if (inside || (intersecting() && !(active instanceof Net))) { ! selectEdges(edges); ! } ! if (construction()) { ! selectConstructors(constructors); ! } ! } else { ! if (inside) { ! if (mode == View.SOLID_MODE) { ! paintSurfaces(surfaces, alice); ! } else if (mode == View.LIGHTING_MODE) { ! paintSurfaces(surfaces, transparency); ! } else if (mode == View.WIREFRAME_MODE) { ! // do not paint surfaces } - } - if (active == space) { if (construction()) { ! gl.glDepthMask(false); ! draw(grid); ! paintConstructors(constructors); ! gl.glDepthMask(true); } - } - Collection<Edge> stippled = new LinkedList(); - Collection<Edge> normal = new LinkedList(); - split(edges, normal, stippled); - - float size; - float[] color; - - if (space instanceof Net) { - size = 2.0f; - } else { - size = 1.0f; - } - if (inside) { - color = black; } else { ! color = grey; ! } ! paintEdges(normal, color, size); ! paintStippled(stippled, middleblue, size); ! } ! ! gl.glDisable(GL.GL_DEPTH_TEST); ! ! if (selecting()) { ! if (inside || intersecting()) { ! selectVertices(vertices); } ! } else { ! float[] color; ! if (space instanceof Net) { ! color = middleblue; } else { ! color = black; } - paintVertices(vertices, color, 9.0f); } ! for (Space current : elements) { draw(current, inside || (current == active)); --- 721,905 ---- Collection<Constructor> constructors = new LinkedList(); ! boolean interior; ! ! if (selecting) { ! if (!intersecting && transparency) { ! if (space == active) { ! interior = true; ! } else { ! interior = false; ! } ! } else { ! interior = true; } + } else { + interior = true; } + { ! // Geometry collection ! ! for (Space current : space.getElements()) { if (!hidden.contains(current)) { ! elements.add(current); } } ! { ! Set<Surface> visible = new HashSet(); ! for (Space current : elements) { ! visible.addAll(current.getEnvelope()); } ! for (Surface current : visible) { ! if (transparency) { ! if (!hidden.contains(current)) { ! surfaces.add(current); ! } ! } else { ! if (!transparent(current)) { ! surfaces.add(current); ! } ! } } } ! { ! Set<Edge> visible = new HashSet(); ! for (Surface current : surfaces) { ! visible.addAll(current.getEdges()); ! for (Surface hole : current.getHoles()) { ! if (current.getOwner() == hole.getOwner()) { ! visible.addAll(hole.getEdges()); ! } ! } ! } ! for (Edge current : visible) { if (!hidden.contains(current)) { edges.add(current); } } ! ! // FIXME the set of edges not connected ! // to a surface should be cashed. ! Set<Edge> mark = new HashSet(); ! for (Surface current : space.getSurfaces()) { ! mark.addAll(current.getEdges()); } ! for (Edge current : space.getEdges()) { ! if (!mark.contains(current)) { ! if (!hidden.contains(current)) { ! edges.add(current); ! } } } } ! ! { ! if (selecting() || (space instanceof Net && space == active)) { ! Set<Vertex> visible = new HashSet(); ! for (Edge current : edges) { ! visible.add(current.getFrom()); ! visible.add(current.getTo()); ! } ! for (Vertex current : visible) { ! if (!hidden.contains(current)) { ! vertices.add(current); ! } ! } ! } ! ! //FIXME: The set of lonely vertices should be cached. ! Set<Vertex> mark = new HashSet(); ! for (Edge current : space.getEdges()) { ! mark.add(current.getFrom()); ! mark.add(current.getTo()); ! } ! for (Vertex current : space.getVertices()) { ! if (!mark.contains(current)) { ! if (!hidden.contains(current)) { ! vertices.add(current); ! } } } } ! ! for (Constructor current : space.getConstructors()) { ! if (!hidden.contains(current)) { ! constructors.add(current); ! } } } ! if (interior) { ! // Geometry rendering ! ! gl.glEnable(GL.GL_DEPTH_TEST); ! ! if (selecting()) { ! if (inside) { ! if (mode != View.WIREFRAME_MODE) { ! selectSurfaces(surfaces, transparency); ! } } ! if (inside || (intersecting() && !(active instanceof Net))) { ! selectEdges(edges); } if (construction()) { ! selectConstructors(constructors); } } else { ! if (inside) { ! if (mode == View.SOLID_MODE) { ! paintSurfaces(surfaces, alice); ! } else if (mode == View.LIGHTING_MODE) { ! paintSurfaces(surfaces, transparency); ! } else if (mode == View.WIREFRAME_MODE) { ! // do not paint surfaces ! } ! } ! if (active == space) { ! if (construction()) { ! gl.glDepthMask(false); ! draw(grid); ! paintConstructors(constructors); ! gl.glDepthMask(true); ! } ! } ! Collection<Edge> stippled = new LinkedList(); ! Collection<Edge> normal = new LinkedList(); ! split(edges, normal, stippled); ! ! float size; ! float[] color; ! ! if (space instanceof Net) { ! size = 2.0f; ! } else { ! size = 1.0f; ! } ! if (inside) { ! color = black; ! } else { ! color = grey; ! } ! paintEdges(normal, color, size); ! paintStippled(stippled, middleblue, size); } ! ! gl.glDisable(GL.GL_DEPTH_TEST); ! ! if (selecting()) { ! if (inside || intersecting()) { ! selectVertices(vertices); ! } } else { ! float[] color; ! if (space instanceof Net) { ! color = middleblue; ! } else { ! color = black; ! } ! paintVertices(vertices, color, 9.0f); } } ! for (Space current : elements) { draw(current, inside || (current == active)); |
From: Michael L. <he...@us...> - 2007-10-12 14:34:35
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31428/src/net/sourceforge/bprocessor/model Modified Files: Camera.java Log Message: new display system in effect Index: Camera.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Camera.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** Camera.java 5 Sep 2007 11:18:46 -0000 1.45 --- Camera.java 12 Oct 2007 14:34:37 -0000 1.46 *************** *** 371,375 **** public double distance(Vertex vertex) { Vertex eye = new Vertex(getCamera()); ! double scale = (getFocalwidth() / 65); double dist = 0.0; if (getType() == Camera.PERSPECTIVE) { --- 371,375 ---- public double distance(Vertex vertex) { Vertex eye = new Vertex(getCamera()); ! double scale = (getFocalwidth() / 85); double dist = 0.0; if (getType() == Camera.PERSPECTIVE) { |
From: Michael L. <he...@us...> - 2007-10-12 14:34:31
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31414/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Display.java Log Message: new display system in effect Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Display.java 12 Oct 2007 13:14:42 -0000 1.32 --- Display.java 12 Oct 2007 14:34:34 -0000 1.33 *************** *** 20,23 **** --- 20,24 ---- import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.glu.GLU; + import javax.media.opengl.glu.GLUquadric; import javax.media.opengl.glu.GLUtessellator; import javax.media.opengl.glu.GLUtessellatorCallback; *************** *** 32,35 **** --- 33,37 ---- import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometric; + import net.sourceforge.bprocessor.model.Geometry; import net.sourceforge.bprocessor.model.Line; import net.sourceforge.bprocessor.model.Net; *************** *** 98,102 **** public static void initialize() { if (!initialized) { - glu = new GLU(); tesselator = glu.gluNewTess(); GLUtessellatorCallback callback = new TesselatorCallback(); --- 100,103 ---- *************** *** 515,526 **** paint((CoordinateSystem) constructor); } else if (constructor instanceof Line) { ! paint((Line) constructor); } } ! private static void paint(Line line) { gl.glLineWidth(1.0f); gl.glEnable(GL.GL_LINE_STIPPLE); ! gl.glColor3fv(middleblue, 0); draw(line); gl.glDisable(GL.GL_LINE_STIPPLE); --- 516,527 ---- paint((CoordinateSystem) constructor); } else if (constructor instanceof Line) { ! paint((Line) constructor, middleblue); } } ! private static void paint(Line line, float[] color) { gl.glLineWidth(1.0f); gl.glEnable(GL.GL_LINE_STIPPLE); ! gl.glColor3fv(color, 0); draw(line); gl.glDisable(GL.GL_LINE_STIPPLE); *************** *** 533,547 **** Vertex n = system.getN(); Line xaxis = new Line(origin, i); Line yaxis = new Line(origin, j); Line zaxis = new Line(origin, n); ! gl.glLineWidth(1.0f); ! gl.glEnable(GL.GL_LINE_STIPPLE); ! gl.glColor3fv(red, 0); ! draw(xaxis); ! gl.glColor3fv(green, 0); ! draw(yaxis); ! gl.glColor3fv(blue, 0); ! draw(zaxis); ! gl.glDisable(GL.GL_LINE_STIPPLE); } --- 534,545 ---- Vertex n = system.getN(); Line xaxis = new Line(origin, i); + xaxis.setEditable(system.isEditable()); Line yaxis = new Line(origin, j); + yaxis.setEditable(system.isEditable()); Line zaxis = new Line(origin, n); ! zaxis.setEditable(system.isEditable()); ! paint(xaxis, red); ! paint(yaxis, green); ! paint(zaxis, blue); } *************** *** 552,557 **** --- 550,559 ---- Vertex n = system.getN(); Line xaxis = new Line(origin, i); + xaxis.setEditable(system.isEditable()); Line yaxis = new Line(origin, j); + yaxis.setEditable(system.isEditable()); Line zaxis = new Line(origin, n); + zaxis.setEditable(system.isEditable()); + draw(xaxis); draw(yaxis); *************** *** 571,574 **** --- 573,606 ---- Edge edge = line.edge(grid.size()); draw(edge); + if (line.isEditable()) { + Vertex from = line.getOrigin(); + double dist = camera.distance(from); + Vertex to = line.tip(dist); + drawVectorBase(from, to); + drawVectorTip(from, to); + } + } + + private static void drawVectorBase(Vertex from, Vertex to) { + gl.glLineWidth(2); + gl.glBegin(GL.GL_LINES); + gl.glVertex3d(from.getX(), from.getY(), from.getZ()); + gl.glVertex3d(to.getX(), to.getY(), to.getZ()); + gl.glEnd(); + } + private static void drawVectorTip(Vertex from, Vertex to) { + Vertex direction = to.minus(from); + double dist = direction.length() * 16; + gl.glEnable(GL.GL_LIGHTING); + GLUquadric quad = glu.gluNewQuadric(); + glu.gluQuadricNormals(quad, GLU.GLU_SMOOTH); + gl.glPushMatrix(); + gl.glTranslated(to.getX(), to.getY(), to.getZ()); + gl.glRotated(Math.toDegrees(Geometry.degreesAboutZ(direction)), 0, 0, 1); + gl.glRotated(-Math.toDegrees(Geometry.degreesAboutY(direction)), 0, 1, 0); + gl.glRotated(90, 0, 1, 0); + glu.gluCylinder(quad, (dist / 90), 0, (dist / 20), 10, 10); + gl.glPopMatrix(); + gl.glDisable(GL.GL_LIGHTING); } *************** *** 963,970 **** /** * ! * @param gld GLAutoDrawable */ ! public static void draw(GLAutoDrawable gld) { ! gl = gld.getGL(); initialize(); project = Project.getInstance(); --- 995,1005 ---- /** * ! * @param gld gld ! * @param gl gl ! * @param glu glu */ ! public static void draw(GLAutoDrawable gld, GL gl, GLU glu) { ! Display.gl = gl; ! Display.glu = glu; initialize(); project = Project.getInstance(); Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.248 retrieving revision 1.249 diff -C2 -d -r1.248 -r1.249 *** View.java 12 Oct 2007 13:14:42 -0000 1.248 --- View.java 12 Oct 2007 14:34:34 -0000 1.249 *************** *** 82,86 **** private static final boolean DISP = false; ! private static final boolean UNIFIED_DISPLAY = false; /** OBJECTS flag */ --- 82,86 ---- private static final boolean DISP = false; ! private static final boolean UNIFIED_DISPLAY = true; /** OBJECTS flag */ *************** *** 736,740 **** Display.extras(extras); Display.glos(glObjects3D); ! Display.draw(gld); Display.selecting(false); Display.intersecting(false); --- 736,740 ---- Display.extras(extras); Display.glos(glObjects3D); ! Display.draw(gld, gl, glu); Display.selecting(false); Display.intersecting(false); *************** *** 1616,1619 **** --- 1616,1620 ---- Vertex direction = to.minus(from); double dist = direction.length() * 16; + System.out.println("dist " + dist); gl.glEnable(GL.GL_LIGHTING); GLUquadric quad = glu.gluNewQuadric(); |
From: Michael L. <he...@us...> - 2007-10-12 13:14:52
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30659/src/net/sourceforge/bprocessor/model Modified Files: CoordinateSystem.java Log Message: Changes to the displayed attributes of CoordinateSystem Ð editable displayed, normal displayed even when only plane Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** CoordinateSystem.java 5 Oct 2007 13:30:49 -0000 1.58 --- CoordinateSystem.java 12 Oct 2007 13:14:46 -0000 1.59 *************** *** 571,588 **** this.j = j; } ! if (onlyPlane) { ! setActive(((Boolean)(((Attribute)attributes.get(12)).getValue())).booleanValue()); ! onlyPlane(((Boolean)(((Attribute)attributes.get(13)).getValue())).booleanValue()); ! } else { ! Vertex n = new Vertex(0, 0, 0); ! n.setX(((Double)(((Attribute)attributes.get(13)).getValue())).doubleValue()); ! n.setY(((Double)(((Attribute)attributes.get(14)).getValue())).doubleValue()); ! n.setZ(((Double)(((Attribute)attributes.get(15)).getValue())).doubleValue()); ! if (n.length() > 0) { ! this.n = n; ! } ! setActive(((Boolean)(((Attribute)attributes.get(16)).getValue())).booleanValue()); ! onlyPlane(((Boolean)(((Attribute)attributes.get(17)).getValue())).booleanValue()); } update(); } --- 571,584 ---- this.j = j; } ! Vertex n = new Vertex(0, 0, 0); ! n.setX(((Double)(((Attribute)attributes.get(13)).getValue())).doubleValue()); ! n.setY(((Double)(((Attribute)attributes.get(14)).getValue())).doubleValue()); ! n.setZ(((Double)(((Attribute)attributes.get(15)).getValue())).doubleValue()); ! if (n.length() > 0) { ! this.n = n; } + setActive(((Boolean)(((Attribute)attributes.get(16)).getValue())).booleanValue()); + onlyPlane(((Boolean)(((Attribute)attributes.get(17)).getValue())).booleanValue()); + setEditable(((Boolean)(((Attribute)attributes.get(18)).getValue())).booleanValue()); update(); } *************** *** 603,612 **** res.add(new Attribute("y", new Double(getJ().getY()))); res.add(new Attribute("z", new Double(getJ().getZ()))); ! if (!onlyPlane()) { ! res.add(new Attribute("K (Normal)", "", false)); ! res.add(new Attribute("x", new Double(getN().getX()))); ! res.add(new Attribute("y", new Double(getN().getY()))); ! res.add(new Attribute("z", new Double(getN().getZ()))); ! } if (isActive()) { res.add(new Attribute("Active", Boolean.TRUE)); --- 599,607 ---- res.add(new Attribute("y", new Double(getJ().getY()))); res.add(new Attribute("z", new Double(getJ().getZ()))); ! res.add(new Attribute("K (Normal)", "", false)); ! res.add(new Attribute("x", new Double(getN().getX()))); ! res.add(new Attribute("y", new Double(getN().getY()))); ! res.add(new Attribute("z", new Double(getN().getZ()))); ! if (isActive()) { res.add(new Attribute("Active", Boolean.TRUE)); *************** *** 619,622 **** --- 614,618 ---- res.add(new Attribute("Only plane", Boolean.FALSE)); } + res.add(new Attribute("Editable", Boolean.valueOf(isEditable()))); return res; } *************** *** 624,632 **** /** {@inheritDoc} */ public String getGeneralName() { ! if (onlyPlane()) { ! return "B-Plane"; ! } else { ! return "B-System"; ! } } --- 620,624 ---- /** {@inheritDoc} */ public String getGeneralName() { ! return "B-System"; } |
From: Michael L. <he...@us...> - 2007-10-12 13:14:40
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30650/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Display.java Log Message: Changes to the displayed attributes of CoordinateSystem Ð editable displayed, normal displayed even when only plane Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Display.java 12 Oct 2007 11:06:53 -0000 1.31 --- Display.java 12 Oct 2007 13:14:42 -0000 1.32 *************** *** 14,17 **** --- 14,18 ---- import java.util.LinkedList; import java.util.List; + import java.util.Map; import java.util.Set; *************** *** 55,58 **** --- 56,61 ---- private static Collection<? extends Geometric> extras; private static Collection<GlObject> glos; + private static Map<Geometric, float[]> colors; + private static float[] targetColor; private static Grid grid; private static boolean intersecting; *************** *** 193,196 **** --- 196,215 ---- /** + * + * @param value colors + */ + public static void colors(Map<Geometric, float[]> value) { + colors = value; + } + + /** + * + * @param value target color + */ + public static void targetColor(float[] value) { + targetColor = value; + } + + /** * Returns the value of intersecting * @return intersecting *************** *** 867,871 **** paint((Vertex) current, redish, 9.0f); } else { ! paint((Vertex) current, blueish, 6.0f); } } --- 886,894 ---- paint((Vertex) current, redish, 9.0f); } else { ! if (targetColor != null) { ! paint((Vertex) current, targetColor, 6.0f); ! } else { ! paint((Vertex) current, blueish, 6.0f); ! } } } *************** *** 983,987 **** selectVertices(vertices); } else { ! paintVertices(vertices, black, 9.0f); } --- 1006,1016 ---- selectVertices(vertices); } else { ! for (Vertex current : vertices) { ! float[] color = colors.get(current); ! if (color == null) { ! color = middleblue; ! } ! paint(current, color, 9.0f); ! } } Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.247 retrieving revision 1.248 diff -C2 -d -r1.247 -r1.248 *** View.java 12 Oct 2007 11:06:52 -0000 1.247 --- View.java 12 Oct 2007 13:14:42 -0000 1.248 *************** *** 39,43 **** import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.Surface; - import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Transform; --- 39,42 ---- *************** *** 134,138 **** /** Used for target objects */ ! public static final float[] TARGET_COLOR = new float[] {0.8f, 0.8f, 0.1f}; /** Used for vertices on edges */ --- 133,137 ---- /** Used for target objects */ ! public static final float[] TARGET_COLOR = new float[] {0.5f, 0.2f, 0.1f}; /** Used for vertices on edges */ *************** *** 143,147 **** /** Used for vertices on surface */ ! public static final float[] SURFACE_ON_COLOR = new float[] {0.6f, 0.2f, 0.1f}; /** Used for vertices on edges */ --- 142,146 ---- /** Used for vertices on surface */ ! public static final float[] SURFACE_ON_COLOR = new float[] {0.6f, 0.6f, 0.1f}; /** Used for vertices on edges */ *************** *** 371,375 **** /** Maps entities to a color */ ! private Map colorMap; /** Maps edges to a set of attributes */ --- 370,374 ---- /** Maps entities to a color */ ! private Map<Geometric, float[]> colorMap; /** Maps edges to a set of attributes */ *************** *** 719,722 **** --- 718,723 ---- initNames(gl); Display.objects(objectTable); + Display.colors(colorMap); + Display.targetColor(targetColor); if (target instanceof Geometric) { Display.target((Geometric) target); *************** *** 3200,3204 **** * @param color the color */ ! public void changeColor(Entity e, float[] color) { colorMap.put(e, color); } --- 3201,3205 ---- * @param color the color */ ! public void changeColor(Geometric e, float[] color) { colorMap.put(e, color); } *************** *** 3208,3212 **** * @param e the entity */ ! public void clearColor(Entity e) { colorMap.remove(e); } --- 3209,3213 ---- * @param e the entity */ ! public void clearColor(Geometric e) { colorMap.remove(e); } |
From: Michael L. <he...@us...> - 2007-10-12 11:07:03
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13742/src/net/sourceforge/bprocessor/model Modified Files: Space.java Log Message: Toolbar reorganized Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.181 retrieving revision 1.182 diff -C2 -d -r1.181 -r1.182 *** Space.java 12 Oct 2007 10:19:09 -0000 1.181 --- Space.java 12 Oct 2007 11:06:58 -0000 1.182 *************** *** 213,217 **** setType(type); this.level = level; ! setTransparent(false); this.container = container; description = new Description(""); --- 213,221 ---- setType(type); this.level = level; ! if (type == FUNCTIONAL) { ! setTransparent(true); ! } else { ! setTransparent(false); ! } this.container = container; description = new Description(""); |
From: Michael L. <he...@us...> - 2007-10-12 11:06:54
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13721/src/net/sourceforge/bprocessor/gl/tool Modified Files: ToolFactory.java Log Message: Toolbar reorganized Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** ToolFactory.java 27 Sep 2007 10:48:53 -0000 1.86 --- ToolFactory.java 12 Oct 2007 11:06:53 -0000 1.87 *************** *** 222,226 **** this.registerTool(Tool.ERASER_TOOL, eraser, "Biconeraser.gif", "Eraser"); eraserBut.setMnemonic(KeyEvent.VK_A); ! tb.addSeparator(3); JToggleButton offBut = this.registerTool(Tool.OFFSET_TOOL, offset, "Biconoffset.gif", "Offset"); --- 222,226 ---- this.registerTool(Tool.ERASER_TOOL, eraser, "Biconeraser.gif", "Eraser"); eraserBut.setMnemonic(KeyEvent.VK_A); ! tb.addSeparator(5); JToggleButton offBut = this.registerTool(Tool.OFFSET_TOOL, offset, "Biconoffset.gif", "Offset"); *************** *** 239,248 **** JToggleButton rotationBut = this.registerTool(Tool.ROTATION_TOOL, rotation, "Biconrotaxe.gif", "Rotate"); ! tb.addSeparator(3); JToggleButton tmBut = this.registerTool(Tool.TAPE_MEASURE_TOOL, tapeMeasure, "Bicontapemes.gif", "Tape Measure"); this.registerTool(Tool.CONSTRUCTOR_TOOL, constructor, "Biconconstructor.gif", "Constructor"); this.registerTool(Tool.RELATION_TOOL, relation, "chaintool.gif", "Create relation"); ! tb.addSeparator(3); JToggleButton cRotBut = --- 239,248 ---- JToggleButton rotationBut = this.registerTool(Tool.ROTATION_TOOL, rotation, "Biconrotaxe.gif", "Rotate"); ! tb.addSeparator(5); JToggleButton tmBut = this.registerTool(Tool.TAPE_MEASURE_TOOL, tapeMeasure, "Bicontapemes.gif", "Tape Measure"); this.registerTool(Tool.CONSTRUCTOR_TOOL, constructor, "Biconconstructor.gif", "Constructor"); this.registerTool(Tool.RELATION_TOOL, relation, "chaintool.gif", "Create relation"); ! tb.addSeparator(5); JToggleButton cRotBut = *************** *** 253,276 **** //walkBut = this.registerTool(Tool.WALK_TOOL, walk, "Biconwalk.gif", "Walk"); ! Action zoomAction = new ToolAction(glv, 0, "Biconzomeall.gif") { ! public void actionPerformed(ActionEvent agr0) { ! double aspect = glv.getView().getAspect(); ! if (Selection.primary().isEmpty()) { ! List list = new LinkedList(); ! list.add(Project.getInstance().getActiveSpace()); ! Project.getInstance().getCurrentCamera().zoomOn(list, aspect); ! } else { ! Project.getInstance().getCurrentCamera().zoomOn(Selection.primary(), aspect); ! } ! this.glv.repaint(); ! } ! }; ! Toolbar.getInstance().registerPushButtonAction(zoomAction, "Zoom All"); ! this.registerTool(Tool.FOCUS_TOOL, focusTool, "Biconzomeselect.gif", "Focus on surface"); ! tb.addSeparator(10); JToggleButton clipBut = this.registerTool(Tool.CLIP_TOOL, clipplane, "Bclip.gif", "Clipping"); Action orthoAction = new ToolAction(glv, 0, "Borto.gif") { public void actionPerformed(ActionEvent agr0) { --- 253,264 ---- //walkBut = this.registerTool(Tool.WALK_TOOL, walk, "Biconwalk.gif", "Walk"); ! this.registerTool(Tool.FOCUS_TOOL, focusTool, "Biconzomeselect.gif", "Focus on surface"); ! JToggleButton clipBut = this.registerTool(Tool.CLIP_TOOL, clipplane, "Bclip.gif", "Clipping"); + tb.addSeparator(10); + Action orthoAction = new ToolAction(glv, 0, "Borto.gif") { public void actionPerformed(ActionEvent agr0) { *************** *** 306,310 **** --- 294,314 ---- }; Toolbar.getInstance().registerPushButtonAction(topAction, "See from above"); + Action zoomAction = new ToolAction(glv, 0, "Biconzomeall.gif") { + public void actionPerformed(ActionEvent agr0) { + double aspect = glv.getView().getAspect(); + if (Selection.primary().isEmpty()) { + List list = new LinkedList(); + list.add(Project.getInstance().getActiveSpace()); + Project.getInstance().getCurrentCamera().zoomOn(list, aspect); + } else { + Project.getInstance().getCurrentCamera().zoomOn(Selection.primary(), aspect); + } + this.glv.repaint(); + } + }; + Toolbar.getInstance().registerPushButtonAction(zoomAction, "Zoom All"); + + tb.addSeparator(5); ButtonGroup viewGroup = new ButtonGroup(); JToggleButton perspBut = Toolbar.getInstance().registerAction(perspAction); |
From: Michael L. <he...@us...> - 2007-10-12 11:06:54
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13721/src/net/sourceforge/bprocessor/gl/view Modified Files: ViewToolbarFactory.java View.java Display.java Log Message: Toolbar reorganized Index: ViewToolbarFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewToolbarFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ViewToolbarFactory.java 3 Sep 2007 11:22:32 -0000 1.3 --- ViewToolbarFactory.java 12 Oct 2007 11:06:52 -0000 1.4 *************** *** 35,39 **** public void registerToolbar(GLView glv) { Toolbar tb = Toolbar.getInstance(); ! tb.addSeparator(3); ButtonGroup bg = new ButtonGroup(); --- 35,39 ---- public void registerToolbar(GLView glv) { Toolbar tb = Toolbar.getInstance(); ! tb.addSeparator(5); ButtonGroup bg = new ButtonGroup(); *************** *** 44,52 **** but.setSelected(true); - but = tb.registerAction(new ViewNoRaster(glv)); - bg.add(but); - but.setToolTipText("Shading no raster"); - but.setMnemonic(KeyEvent.VK_F6); - but = tb.registerAction(new ViewSolid(glv)); bg.add(but); --- 44,47 ---- *************** *** 59,62 **** --- 54,64 ---- but.setMnemonic(KeyEvent.VK_F8); + tb.addSeparator(5); + + but = tb.registerAction(new ViewNoRaster(glv)); + but.setSelected(true); + but.setToolTipText("Shading no raster"); + but.setMnemonic(KeyEvent.VK_F6); + but = tb.registerAction(new ViewGrid(glv)); but.setToolTipText("Grid"); *************** *** 79,83 **** public void actionPerformed(ActionEvent event) { JToggleButton button = (JToggleButton) event.getSource(); - glv.getView(); if (button.isSelected()) { glv.getView().enableGrid(); --- 81,84 ---- *************** *** 145,152 **** /** * Called when the button is pressed ! * @param e The ActionEvent */ ! public void actionPerformed(ActionEvent e) { ! glv.getView().changeDrawMode(View.SPACE_ASSGN_MODE); glv.repaint(true); } --- 146,159 ---- /** * Called when the button is pressed ! * @param event The ActionEvent */ ! public void actionPerformed(ActionEvent event) { ! //glv.getView().changeDrawMode(View.SPACE_ASSGN_MODE); ! JToggleButton button = (JToggleButton) event.getSource(); ! if (button.isSelected()) { ! glv.getView().showTransparent(); ! } else { ! glv.getView().hideTransparent(); ! } glv.repaint(true); } Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Display.java 12 Oct 2007 07:57:53 -0000 1.30 --- Display.java 12 Oct 2007 11:06:53 -0000 1.31 *************** *** 59,62 **** --- 59,63 ---- private static boolean construction; private static int mode; + private static boolean transparency; private static Project project; *************** *** 241,244 **** --- 242,261 ---- /** + * + * @return show transparent surfaces + */ + public static boolean transparency() { + return transparency; + } + + /** + * + * @param value show transparent surfaces + */ + public static void transparency(boolean value) { + transparency = value; + } + + /** * Sets the objects table * @param value ArrayList *************** *** 736,744 **** if (inside) { if (mode != View.WIREFRAME_MODE) { ! if (mode == View.LIGHTING_MODE) { ! selectSurfaces(surfaces, true); ! } else { ! selectSurfaces(surfaces, false); ! } } } --- 753,757 ---- if (inside) { if (mode != View.WIREFRAME_MODE) { ! selectSurfaces(surfaces, transparency); } } *************** *** 754,760 **** paintSurfaces(surfaces, alice); } else if (mode == View.LIGHTING_MODE) { ! paintSurfaces(surfaces, true); ! } else if (mode == View.SPACE_ASSGN_MODE) { ! paintSurfaces(surfaces, false); } else if (mode == View.WIREFRAME_MODE) { // do not paint surfaces --- 767,771 ---- paintSurfaces(surfaces, alice); } else if (mode == View.LIGHTING_MODE) { ! paintSurfaces(surfaces, transparency); } else if (mode == View.WIREFRAME_MODE) { // do not paint surfaces Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.246 retrieving revision 1.247 diff -C2 -d -r1.246 -r1.247 *** View.java 11 Oct 2007 13:12:12 -0000 1.246 --- View.java 12 Oct 2007 11:06:52 -0000 1.247 *************** *** 325,328 **** --- 325,330 ---- /** grid enabled */ private boolean gridEnabled; + + private boolean showTransparent = true; /** The mode of selecting. Either edges or surfaces */ *************** *** 628,631 **** --- 630,649 ---- /** + * + * + */ + public void showTransparent() { + showTransparent = true; + } + + /** + * + * + */ + public void hideTransparent() { + showTransparent = false; + } + + /** * Apply edge attributes * @param attributes the new attributes *************** *** 698,701 **** --- 716,720 ---- Display.construction(gridEnabled); Display.mode(drawMode); + Display.transparency(showTransparent); initNames(gl); Display.objects(objectTable); *************** *** 1192,1205 **** Collection<Surface> surfaces = space.getSurfaces(); switch (drawMode) { ! case SPACE_ASSGN_MODE: { ! Collection<Surface> temp = new HashSet<Surface>(); ! for (Surface s : surfaces) { ! if (isVisible(s)) { ! temp.add(s); } } - surfaces = temp; - } - case LIGHTING_MODE: { gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); --- 1211,1224 ---- Collection<Surface> surfaces = space.getSurfaces(); switch (drawMode) { ! case LIGHTING_MODE: { ! if (!showTransparent) { ! Collection<Surface> temp = new HashSet<Surface>(); ! for (Surface s : surfaces) { ! if (isVisible(s)) { ! temp.add(s); ! } } + surfaces = temp; } gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); *************** *** 2152,2156 **** if (drawMode == WIREFRAME_MODE) { surfaces = new HashSet<Surface>(); ! } else if (drawMode == SPACE_ASSGN_MODE) { Collection<Surface> temp = new LinkedList<Surface>(); for (Surface s : surfaces) { --- 2171,2175 ---- if (drawMode == WIREFRAME_MODE) { surfaces = new HashSet<Surface>(); ! } else if (drawMode == LIGHTING_MODE && !showTransparent) { Collection<Surface> temp = new LinkedList<Surface>(); for (Surface s : surfaces) { *************** *** 2935,2939 **** if (mode <= 3 && mode >= 0) { drawMode = mode; - log.info("drawmode:" + mode); } } --- 2954,2957 ---- |
From: rimestad <rim...@us...> - 2007-10-12 10:20:35
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27796/src/net/sourceforge/bprocessor/gui/actions Modified Files: FileImportActionListener.java ImportFileReader.java Log Message: Improved on obj readin Index: FileImportActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileImportActionListener.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FileImportActionListener.java 12 Oct 2007 08:00:13 -0000 1.7 --- FileImportActionListener.java 12 Oct 2007 10:20:35 -0000 1.8 *************** *** 23,26 **** --- 23,27 ---- import net.sourceforge.bprocessor.model.Project; + import net.sourceforge.bprocessor.model.Space; import org.apache.log4j.Logger; *************** *** 80,84 **** } else if (lfile.getName().endsWith(".obj")) { try { ! ImportFileReader.importObjFile(lfile, Project.getInstance().world()); } catch (Exception ex) { log.error("Could not open file: " + lfile, ex); --- 81,87 ---- } else if (lfile.getName().endsWith(".obj")) { try { ! Space s = Project.getInstance().world().createUnion(lfile.getName()); ! ImportFileReader.importObjFile(lfile, s); ! Project.getInstance().world().add(s); } catch (Exception ex) { log.error("Could not open file: " + lfile, ex); Index: ImportFileReader.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/ImportFileReader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImportFileReader.java 12 Oct 2007 08:00:14 -0000 1.1 --- ImportFileReader.java 12 Oct 2007 10:20:35 -0000 1.2 *************** *** 14,19 **** --- 14,23 ---- import java.io.InputStreamReader; import java.util.ArrayList; + import java.util.HashMap; + import java.util.HashSet; import java.util.LinkedList; import java.util.List; + import java.util.Map; + import java.util.Set; import java.util.StringTokenizer; *************** *** 33,37 **** private static Logger log = Logger.getLogger(ImportFileReader.class); /** ! * Importer for the obj format * @param f The file to load * @param into the space to paste it into --- 37,63 ---- private static Logger log = Logger.getLogger(ImportFileReader.class); /** ! * Importer for the obj format that is as follows ! * # some text ! * Line is a comment until the end of the line ! * v float float float ! * A single vertex's geometric position in space. The first vertex listed in ! * the file has index 1, and subsequent vertices are numbered sequentially. ! * vn float float float ! * A normal. The first normal in the file is index 1, and subsequent normals ! * are numbered sequentially. ! * vt float float ! * A texture coordinate. The first texture coordinate in the file is index 1, ! * and subsequent textures are numbered sequentially. ! * f int int int ... ! * or ! * f int/int int/int int/int . . . ! * or ! * f int/int/int int/int/int int/int/int ... ! * A polygonal face. The numbers are indexes into the arrays of vertex positions, ! * texture coordinates, and normals respectively. A number may be omitted if, for ! * example, texture coordinates are not being defined in the model. ! * There is no maximum number of vertices that a single polygon may contain. ! * The .obj file specification says that each face must be flat and convex. ! * In JavaView polygonal face may be triangulated. * @param f The file to load * @param into the space to paste it into *************** *** 44,48 **** BufferedReader br = new BufferedReader(reader); LinkedList<Vertex> verts = new LinkedList<Vertex>(); ! LinkedList<Surface> surfaces = new LinkedList<Surface>(); int lineNum = 0; while (br.ready()) { --- 70,76 ---- BufferedReader br = new BufferedReader(reader); LinkedList<Vertex> verts = new LinkedList<Vertex>(); ! Set<Edge> edges = new HashSet<Edge>(); ! Set<Surface> surfaces = new HashSet<Surface>(); ! Map<Vertex, Set<Edge>> v2es = new HashMap<Vertex, Set<Edge>>(); int lineNum = 0; while (br.ready()) { *************** *** 51,78 **** String[] lineContent = line.split(" "); if (lineContent[0].equals("v")) { ! verts.add(new Vertex(Double.parseDouble(lineContent[1]), Double.parseDouble(lineContent[2]), ! Double.parseDouble(lineContent[3]))); } else if (lineContent[0].equals("f")) { ! LinkedList<Edge> edges = new LinkedList<Edge>(); Vertex cur = null; ! Vertex first = verts.get(Integer.parseInt(lineContent[1].split("/")[0])); Vertex prev = first; for (int i = 2; i < lineContent.length; i++) { ! cur = verts.get(Integer.parseInt(lineContent[i].split("/")[0])); ! edges.add(new Edge(prev, cur)); prev = cur; } ! edges.add(new Edge(prev, first)); ! surfaces.add(new Surface(edges)); ! } else if (lineContent[0].equals("#")) { ! continue; ! } else { ! log.error("Did not understand content on line " + lineNum + " containing " + line); } } } } /** * Importer for the csv file format --- 79,136 ---- String[] lineContent = line.split(" "); if (lineContent[0].equals("v")) { ! Vertex v = new Vertex(Double.parseDouble(lineContent[1]), Double.parseDouble(lineContent[2]), ! Double.parseDouble(lineContent[3])); ! verts.add(v); ! v2es.put(v, new HashSet<Edge>()); } else if (lineContent[0].equals("f")) { ! LinkedList<Edge> edge = new LinkedList<Edge>(); Vertex cur = null; ! Vertex first = verts.get(Integer.parseInt(lineContent[1].split("/")[0]) - 1); Vertex prev = first; for (int i = 2; i < lineContent.length; i++) { ! cur = verts.get(Integer.parseInt(lineContent[i].split("/")[0]) - 1); ! Edge e = findEdge(prev, cur, v2es); ! edge.add(e); prev = cur; } ! edge.add(findEdge(prev, first, v2es)); ! surfaces.add(new Surface(edge)); ! edges.addAll(edge); } } + for (Vertex v : verts) { + into.add(v); + } + for (Edge e : edges) { + into.add(e); + } + for (Surface s : surfaces) { + into.add(s); + } + into.changed(); } } + private static Edge findEdge(Vertex prev, Vertex cur, Map<Vertex, Set<Edge>> v2es) { + Edge e = null; + Set<Edge> prevEdges = v2es.get(prev); + Set<Edge> curEdges = v2es.get(cur); + for (Edge edge : prevEdges) { + if (curEdges.contains(edge)) { + if (e != null) { + log.error("Allready found one common " + e + " and now " + edge); + } + e = edge; + } + } + if (e == null) { + e = new Edge(prev, cur); + v2es.get(prev).add(e); + v2es.get(cur).add(e); + } + return e; + } + /** * Importer for the csv file format |
From: rimestad <rim...@us...> - 2007-10-12 10:19:13
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27344/src/net/sourceforge/bprocessor/gui Modified Files: PopupMenu.java Log Message: Added a createUnion method on a space to create a union in the space called upon Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** PopupMenu.java 3 Sep 2007 11:50:58 -0000 1.42 --- PopupMenu.java 12 Oct 2007 10:19:15 -0000 1.43 *************** *** 466,471 **** } } ! Space union = owner.createConstructionSpace("Union"); ! union.setUnion(true); Map<Geometric, Geometric> map = new HashMap<Geometric, Geometric>(); --- 466,470 ---- } } ! Space union = owner.createUnion("Union"); Map<Geometric, Geometric> map = new HashMap<Geometric, Geometric>(); |
From: rimestad <rim...@us...> - 2007-10-12 10:19:12
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27325/src/net/sourceforge/bprocessor/model Modified Files: Space.java Log Message: Added a createUnion method on a space to create a union in the space called upon Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.180 retrieving revision 1.181 diff -C2 -d -r1.180 -r1.181 *** Space.java 10 Oct 2007 08:32:00 -0000 1.180 --- Space.java 12 Oct 2007 10:19:09 -0000 1.181 *************** *** 249,252 **** --- 249,262 ---- } + /** + * Create a Union Space + * @param name The name + * @return The space + */ + public Space createUnion(String name) { + Space s = createConstructionSpace(name); + s.setUnion(true); + return s; + } /** |
From: rimestad <rim...@us...> - 2007-10-12 08:10:56
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8261/src/net/sourceforge/bprocessor/model Modified Files: Persistence.java Log Message: Does compile a compile of the build.xml is just necessary to get the global list added to the bmodel xml object Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** Persistence.java 11 Oct 2007 13:11:45 -0000 1.47 --- Persistence.java 12 Oct 2007 08:10:57 -0000 1.48 *************** *** 143,152 **** { List<Attribute> attributes = new LinkedList<Attribute>(); ! // for (Object o : document.getGlobal()) { ! // if (o instanceof MapElementType) { ! // MapElementType elem = (MapElementType)o; ! // attributes.add(internalizeKeyValue(elem, mapper)); ! // } ! // } Collections.sort(attributes, new Attribute.AttributeComparator()); Project.getInstance().getGlobals().setAttributes(attributes); --- 143,152 ---- { List<Attribute> attributes = new LinkedList<Attribute>(); ! for (Object o : document.getGlobal()) { ! if (o instanceof MapElementType) { ! MapElementType elem = (MapElementType)o; ! attributes.add(internalizeKeyValue(elem, mapper)); ! } ! } Collections.sort(attributes, new Attribute.AttributeComparator()); Project.getInstance().getGlobals().setAttributes(attributes); *************** *** 799,808 **** document.setName(Project.getInstance().getName()); ! // { ! // Collection globals = document.getGlobal(); ! // for (Attribute a : Project.getInstance().getGlobals().getAttributes()) { ! // globals.add(externalizeKeyValue(a.getName(), a.getValue(), mapper)); ! // } ! // } { Collection cams = document.getCamera(); --- 799,808 ---- document.setName(Project.getInstance().getName()); ! { ! Collection globals = document.getGlobal(); ! for (Attribute a : Project.getInstance().getGlobals().getAttributes()) { ! globals.add(externalizeKeyValue(a.getName(), a.getValue(), mapper)); ! } ! } { Collection cams = document.getCamera(); |
From: rimestad <rim...@us...> - 2007-10-12 08:05:04
|
Update of /cvsroot/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6000 Modified Files: .classpath build.xml Log Message: Made double labels use scripts, they are always evaluated and only used if the result is a double Index: .classpath =================================================================== RCS file: /cvsroot/bprocessor/gui/.classpath,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** .classpath 10 Aug 2006 15:37:31 -0000 1.5 --- .classpath 12 Oct 2007 08:05:05 -0000 1.6 *************** *** 4,7 **** --- 4,8 ---- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="src" path="/model"/> + <classpathentry kind="src" path="/bscript"/> <classpathentry kind="output" path="build"/> </classpath> Index: build.xml =================================================================== RCS file: /cvsroot/bprocessor/gui/build.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** build.xml 2 Jan 2007 17:27:13 -0000 1.4 --- build.xml 12 Oct 2007 08:05:05 -0000 1.5 *************** *** 8,11 **** --- 8,12 ---- <property name="model.dir" value="${basedir}/../model"/> <property name="tools.dir" value="${basedir}/../tools"/> + <property name="bscript.dir" value="${basedir}/../bscript"/> <property name="build.dir" value="${basedir}/build"/> *************** *** 71,74 **** --- 72,80 ---- </fileset> </copy> + <copy todir="${lib.dir}"> + <fileset dir="${bscript.dir}/dist"> + <include name="**/bscript*"/> + </fileset> + </copy> </target> |
From: rimestad <rim...@us...> - 2007-10-12 08:05:04
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6000/src/net/sourceforge/bprocessor/gui/attrview Modified Files: StringAttribute.java Log Message: Made double labels use scripts, they are always evaluated and only used if the result is a double Index: StringAttribute.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/StringAttribute.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** StringAttribute.java 22 Sep 2007 13:54:26 -0000 1.16 --- StringAttribute.java 12 Oct 2007 08:05:06 -0000 1.17 *************** *** 13,19 **** --- 13,23 ---- import java.awt.event.MouseEvent; import java.awt.event.MouseListener; + import java.io.Reader; + import java.io.StringReader; + import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; + import java.util.Stack; import javax.swing.Box; *************** *** 25,28 **** --- 29,38 ---- import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.model.Attribute; + import net.sourceforge.bprocessor.model.Project; + import net.sourceforge.bprocessor.model.evaluator.Environment; + import net.sourceforge.bprocessor.model.evaluator.Function; + import net.sourceforge.bprocessor.model.evaluator.Invokable; + import net.sourceforge.bprocessor.parser.ScriptLexer; + import net.sourceforge.bprocessor.parser.ScriptParser; import org.apache.log4j.Logger; *************** *** 227,231 **** } } ! /** * Stop editing the value by replacing the editor with an label, --- 237,248 ---- } } ! ! /** ! * Builtin function ! */ ! private abstract class Builtin implements Invokable { ! ! } ! /** * Stop editing the value by replacing the editor with an label, *************** *** 239,243 **** attribute.setValue(editor.getText()); } else if (val instanceof Double) { ! attribute.setValue(Double.valueOf(editor.getText()) / 1000); } component.remove(editor); --- 256,295 ---- attribute.setValue(editor.getText()); } else if (val instanceof Double) { ! HashMap<String, Object> globals = Project.getInstance().getGlobals().environment(); ! globals.put("echo", new Builtin() { ! public void evaluate(Environment env, Stack<Object> stack) { ! stack.push(env.get(0)); ! } ! }); ! String script = Project.getInstance().getScript(); ! try { ! Reader input = new StringReader(script); ! ScriptLexer lexer = new ScriptLexer(input); ! ScriptParser parser = new ScriptParser(lexer); ! parser.script(globals); ! try { ! Environment global = new Environment(globals, null); ! Environment env = new Environment(global, new HashMap(), new LinkedList()); ! input = new StringReader("echo (" + editor.getText() + ")"); ! lexer = new ScriptLexer(input); ! parser = new ScriptParser(lexer); ! Function function = new Function(); ! parser.statement(function); ! Stack stack = new Stack(); ! function.evaluate(env, stack); ! Object o = stack.pop(); ! if (o instanceof Double) { ! attribute.setValue((Double)o / 1000); ! } else { ! attribute.setValue(0); ! } ! } catch (Exception error) { ! log.error(error); ! error.printStackTrace(); ! } ! } catch (Exception error) { ! log.error(error); ! } ! //attribute.setValue(Double.valueOf(editor.getText()) / 1000); } component.remove(editor); |
From: rimestad <rim...@us...> - 2007-10-12 08:00:16
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4080/src/net/sourceforge/bprocessor/gui/actions Modified Files: FileImportActionListener.java Added Files: ImportFileReader.java Removed Files: CsvReader.java Log Message: Refactored all readmechanisms to ImportFileReader and started on implementing obj reader --- CsvReader.java DELETED --- Index: FileImportActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileImportActionListener.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FileImportActionListener.java 31 Jan 2007 20:45:54 -0000 1.6 --- FileImportActionListener.java 12 Oct 2007 08:00:13 -0000 1.7 *************** *** 20,23 **** --- 20,24 ---- import javax.swing.JLabel; import javax.swing.JPanel; + import javax.swing.filechooser.FileFilter; import net.sourceforge.bprocessor.model.Project; *************** *** 32,39 **** --- 33,62 ---- private static Logger log = Logger.getLogger(FileImportActionListener.class); + private JFileChooser loadChooser = null; + + private CVSinfo info = null; + /** * FileImportActionListener */ public FileImportActionListener() { + loadChooser = new JFileChooser(Project.getInstance().getDefaultPath()); + info = new CVSinfo(loadChooser); + loadChooser.setAccessory(info); + loadChooser.setFileFilter(new FileFilter() { + @Override + public boolean accept(File f) { + String name = f.getName(); + if (f.isDirectory() || name.endsWith(".csv") || name.endsWith(".obj")) { + return true; + } + return false; + } + + @Override + public String getDescription() { + return "Legal import formats"; + } + }); } *************** *** 43,59 **** */ public void actionPerformed(ActionEvent e) { - JFileChooser loadChooser = new JFileChooser(Project.getInstance().getDefaultPath()); - CVSinfo info = new CVSinfo(loadChooser); - loadChooser.setAccessory(info); int lstate = loadChooser.showOpenDialog(null); File lfile = loadChooser.getSelectedFile(); if (lfile != null && lstate == JFileChooser.APPROVE_OPTION) { ! try { ! CsvReader read = new CsvReader(lfile, Project.getInstance().world()); ! read.importFloor(info.getSelectedFloor()); ! Project.getInstance().changed(Project.getInstance()); ! } catch (Exception ex) { ! log.error("Could not open file: " + lfile, ex); } } --- 66,87 ---- */ public void actionPerformed(ActionEvent e) { int lstate = loadChooser.showOpenDialog(null); File lfile = loadChooser.getSelectedFile(); if (lfile != null && lstate == JFileChooser.APPROVE_OPTION) { ! if (lfile.getName().endsWith(".csv")) { ! try { ! ImportFileReader.importCsvFile(lfile, Project.getInstance().world(), ! info.getSelectedFloor()); ! Project.getInstance().changed(Project.getInstance()); ! } catch (Exception ex) { ! log.error("Could not open file: " + lfile, ex); ! } ! } else if (lfile.getName().endsWith(".obj")) { ! try { ! ImportFileReader.importObjFile(lfile, Project.getInstance().world()); ! } catch (Exception ex) { ! log.error("Could not open file: " + lfile, ex); ! } } } *************** *** 64,68 **** * for the users pleasure */ ! public class CVSinfo extends JPanel implements PropertyChangeListener, ActionListener { private File file = null; --- 92,96 ---- * for the users pleasure */ ! private class CVSinfo extends JPanel implements PropertyChangeListener, ActionListener { private File file = null; *************** *** 78,82 **** * @param fc the filechooser to add the additional view to */ ! public CVSinfo(JFileChooser fc) { setPreferredSize(new Dimension(100, 50)); floor = new JComboBox(); --- 106,110 ---- * @param fc the filechooser to add the additional view to */ ! private CVSinfo(JFileChooser fc) { setPreferredSize(new Dimension(100, 50)); floor = new JComboBox(); *************** *** 93,97 **** * @return The chosen floor -1 if all are selected */ ! public int getSelectedFloor() { return selectedFloor; } --- 121,125 ---- * @return The chosen floor -1 if all are selected */ ! private int getSelectedFloor() { return selectedFloor; } *************** *** 114,158 **** update = true; } ! ! if (update && file != null && file.exists() && file.canRead()) { ! try { ! BufferedReader bf; ! FileInputStream fis = new FileInputStream(file); ! InputStreamReader isr = new InputStreamReader(fis); ! bf = new BufferedReader(isr); ! int lines = 0; ! long floors = 0; ! while (bf.ready()) { ! String line = bf.readLine(); ! if (line.charAt(0) == '#') { ! //skip comments ! continue; ! } else { ! lines++; ! //read info from file ! String[] tokens = line.split(";"); ! if (tokens.length < 15) { ! throw new Exception("Wrong file format"); } ! long f = Long.parseLong(tokens[2]); //read out the floor ! floors = floors | (long)Math.pow(2, f); ! } ! } ! ! resetView(); ! ! for (int i = 0; i < 64; i++) { ! long val = (floors >> i) & 1; ! if (val == 1) { ! floor.addItem("" + i); } } ! linesLabel.setText("Lines: " + lines); ! } catch (Exception exc) { ! log.error(exc); ! } ! if (isShowing()) { ! repaint(); } } else { resetView(); --- 142,192 ---- update = true; } ! if (update && file != null) { ! if (file.getName().endsWith(".csv")) { ! linesLabel.setEnabled(true); ! if (file.canRead()) { ! try { ! BufferedReader bf; ! FileInputStream fis = new FileInputStream(file); ! InputStreamReader isr = new InputStreamReader(fis); ! bf = new BufferedReader(isr); ! int lines = 0; ! long floors = 0; ! while (bf.ready()) { ! String line = bf.readLine(); ! if (line.charAt(0) == '#') { ! //skip comments ! continue; ! } else { ! lines++; ! //read info from file ! String[] tokens = line.split(";"); ! if (tokens.length < 15) { ! throw new Exception("Wrong file format"); ! } ! long f = Long.parseLong(tokens[2]); //read out the floor ! floors = floors | (long)Math.pow(2, f); ! } } ! ! resetView(); ! ! for (int i = 0; i < 64; i++) { ! long val = (floors >> i) & 1; ! if (val == 1) { ! floor.addItem("" + i); ! } ! } ! linesLabel.setText("Lines: " + lines); ! } catch (Exception exc) { ! log.error(exc); } } ! } else { ! linesLabel.setEnabled(false); } + } + if (isShowing()) { + repaint(); } else { resetView(); --- NEW FILE: ImportFileReader.java --- //--------------------------------------------------------------------------------- // $Id: ImportFileReader.java,v 1.1 2007/10/12 08:00:14 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.actions; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.StringTokenizer; import org.apache.log4j.Logger; import net.sourceforge.bprocessor.model.Classification; import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; /** * A singleton class with stitic methods for loading different file formats into the model */ public class ImportFileReader { private static Logger log = Logger.getLogger(ImportFileReader.class); /** * Importer for the obj format * @param f The file to load * @param into the space to paste it into * @throws IOException a possible file read error */ public static void importObjFile(File f, Space into) throws IOException { if (f.exists()) { FileInputStream stream = new FileInputStream(f); InputStreamReader reader = new InputStreamReader(stream); BufferedReader br = new BufferedReader(reader); LinkedList<Vertex> verts = new LinkedList<Vertex>(); LinkedList<Surface> surfaces = new LinkedList<Surface>(); int lineNum = 0; while (br.ready()) { String line = br.readLine(); lineNum++; String[] lineContent = line.split(" "); if (lineContent[0].equals("v")) { verts.add(new Vertex(Double.parseDouble(lineContent[1]), Double.parseDouble(lineContent[2]), Double.parseDouble(lineContent[3]))); } else if (lineContent[0].equals("f")) { LinkedList<Edge> edges = new LinkedList<Edge>(); Vertex cur = null; Vertex first = verts.get(Integer.parseInt(lineContent[1].split("/")[0])); Vertex prev = first; for (int i = 2; i < lineContent.length; i++) { cur = verts.get(Integer.parseInt(lineContent[i].split("/")[0])); edges.add(new Edge(prev, cur)); prev = cur; } edges.add(new Edge(prev, first)); surfaces.add(new Surface(edges)); } else if (lineContent[0].equals("#")) { continue; } else { log.error("Did not understand content on line " + lineNum + " containing " + line); } } } } /** * Importer for the csv file format * @param file The file to load * @param where The space to paste into * @param chosenFloor The level in the file to load * @throws IOException A possible file read exception */ public static void importCsvFile(File file, Space where, int chosenFloor) throws IOException { if (file.exists()) { BufferedReader bf; FileInputStream fis = new FileInputStream(file); InputStreamReader isr = new InputStreamReader(fis); bf = new BufferedReader(isr); String current = ""; double x = 0; double y = 0; double z = 0; int curId = 0; int prevId = 0; int spaceid = 0; int surfaceId = -1; int floor = -1; int previousSpaceId = spaceid; int classification = 0; Space currentSpace = null; Surface outerSurface = null; List<Vertex> verts = new ArrayList<Vertex>(); int line = 0; while (bf.ready()) { current = bf.readLine(); line++; StringTokenizer st = new StringTokenizer(current, ";"); if (st.countTokens() == 16) { int curSurfaceId = Integer.parseInt(st.nextToken()); // surface(with holes)id if (surfaceId == -1) { surfaceId = curSurfaceId; } st.nextToken(); // hus floor = Integer.parseInt(st.nextToken()); // etage st.nextToken(); // lejl st.nextToken(); // rum st.nextToken(); // kode y = Double.parseDouble(st.nextToken()); // y x = Double.parseDouble(st.nextToken()); // x z = Double.parseDouble(st.nextToken()); // z st.nextToken(); // tal curId = Integer.parseInt(st.nextToken()); // utal st.nextToken(); // type st.nextToken(); // material st.nextToken(); // billed spaceid = Integer.parseInt(st.nextToken()); // Object_id classification = Integer.parseInt(st.nextToken()); // Object_kode if (floor == chosenFloor || chosenFloor == -1) { if (curId < prevId && !verts.isEmpty()) { // Started on new surface Surface s = addToRead(verts, currentSpace, where, outerSurface); if (outerSurface == null) { // this is the first surface in a face outerSurface = s; } if (surfaceId != curSurfaceId) { // this were the last surface in a face outerSurface = null; surfaceId = curSurfaceId; } } if (spaceid != previousSpaceId) { currentSpace = new Space("Space with id " + spaceid, Space.CONSTRUCTION, Space.SPACE_LEVEL, true); where.add(currentSpace); currentSpace.setClassification(new Classification("Type " + classification, -1)); previousSpaceId = spaceid; } // add the just read vertex to the list of verts for the next surface verts.add(new Vertex(x, y, z)); } else if (!verts.isEmpty()) { // The previous vertex were from a wanted floor Surface s = addToRead(verts, currentSpace, where, outerSurface); if (outerSurface == null) { // this is the first surface in a face outerSurface = s; } if (surfaceId != curSurfaceId) { // this were the last surface in a face outerSurface = null; surfaceId = curSurfaceId; } } // last part of while loop prevId = curId; } else { throw new IOException("Problems in format at line " + line); } } //check if there is something left to read if (!verts.isEmpty()) { addToRead(verts, currentSpace, where, outerSurface); } } else { throw new FileNotFoundException(); } } /** * Make a list of edges out of a list of vertexes * @param verts the vertex list (have to be greater than 2) * @return The list of edges */ private static List<Edge> makeEdgesFromVertexes(List<Vertex> verts) { if (verts.size() > 2) { List<Edge> res = new ArrayList<Edge>(verts.size() + 1); Vertex first = null; Vertex previous = null; Vertex last = null; for (Vertex v : verts) { if (first == null) { first = v; previous = first; } else { res.add(new Edge(previous, v)); previous = v; } last = previous; } res.add(new Edge(last, first)); return res; } else { return null; } } /** * @param verts the vertex list * @param currentSpace the added space * @param where The space to insert into * @param outer If the given vertex list is inside a * surface pass it here otherwise pass null * @return the generated surface */ private static Surface addToRead(List<Vertex> verts, Space currentSpace, Space where, Surface outer) { List<Edge> es = makeEdgesFromVertexes(verts); Surface s = null; if (es != null) { es = where.insert(es); if (es.size() > 2) { s = new Surface(es); if (outer != null) { outer.addHole(s); } CoordinateSystem cs = new CoordinateSystem(new Vertex(1, 0, 0), new Vertex(0, 1, 0), new Vertex(0, 0, 1), new Vertex(0, 0, 0)); int dir = s.direction(cs); if (dir == Surface.LEFT) { s.setBackDomain(currentSpace); } else if (dir == Surface.RIGHT) { s.setFrontDomain(currentSpace); } else { cs = new CoordinateSystem(new Vertex(0, 0, 1), new Vertex(0, 1, 0), new Vertex(1, 0, 0), new Vertex(0, 0, 0)); dir = s.direction(cs); if (dir == Surface.LEFT) { s.setBackDomain(currentSpace); } else if (dir == Surface.RIGHT) { s.setFrontDomain(currentSpace); } else { cs = new CoordinateSystem(new Vertex(1, 0, 0), new Vertex(0, 0, 1), new Vertex(0, 1, 0), new Vertex(0, 0, 0)); dir = s.direction(cs); if (dir == Surface.LEFT) { s.setBackDomain(currentSpace); } else if (dir == Surface.RIGHT) { s.setFrontDomain(currentSpace); } else { log.info("Had to give up assigning"); } } } where.add(s); log.debug("Surface " + s + " had a direction of " + dir); } else { log.warn("There were a edge list with fewer than 3 edges"); } verts.clear(); return s; } else { log.warn("There were " + verts.size() + " vertexes which resulted in a empty edge list"); return s; } } } |