Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Grid.java, 1.7, 1.8 Camera.java, 1.5
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-09-09 10:31:13
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11521/src/net/sourceforge/bprocessor/model Modified Files: Grid.java Camera.java Space.java Persistence.java Log Message: Grid drawing changed Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** Persistence.java 28 Aug 2009 12:58:46 -0000 1.82 --- Persistence.java 9 Sep 2009 10:31:00 -0000 1.83 *************** *** 577,581 **** res.setActive(xml.isActive()); res.setDistance(xml.getDistance()); ! res.setSize(xml.getSize()); res.setId(xml.getProgid()); mapper.put(xml.getId(), res); --- 577,581 ---- res.setActive(xml.isActive()); res.setDistance(xml.getDistance()); ! res.setWidth(xml.getSize()); res.setId(xml.getProgid()); mapper.put(xml.getId(), res); *************** *** 856,859 **** --- 856,860 ---- public static Bmodel externalize() { Bmodel document = new BmodelImpl(); + document.setUnits("meter"); counter = 1; HashMap mapper = new HashMap(); *************** *** 1268,1272 **** xml.setActive(grid.isActive()); xml.setDistance((float) grid.getDistance()); ! xml.setSize((float) grid.getSize()); xml.setVertex(externalizeVertex(grid.getOrigin(), new HashMap())); --- 1269,1273 ---- xml.setActive(grid.isActive()); xml.setDistance((float) grid.getDistance()); ! xml.setSize((float) grid.getWidth()); xml.setVertex(externalizeVertex(grid.getOrigin(), new HashMap())); Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.243 retrieving revision 1.244 diff -C2 -d -r1.243 -r1.244 *** Space.java 30 Jun 2009 11:34:45 -0000 1.243 --- Space.java 9 Sep 2009 10:31:00 -0000 1.244 *************** *** 1738,1740 **** --- 1738,1761 ---- } } + + private boolean verify(double value) { + double result = Math.round(value); + return value == result; + } + + private boolean verify(Vertex v) { + return verify(v.x) && verify(v.y) && verify(v.z); + } + + /** + * + */ + public void verify() { + Collection<Vertex> vertices = collect(); + for (Vertex current : vertices) { + if (!verify(current)) { + System.out.println(current + " imprecise"); + } + } + } } Index: Grid.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Grid.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Grid.java 26 May 2009 10:33:50 -0000 1.7 --- Grid.java 9 Sep 2009 10:31:00 -0000 1.8 *************** *** 15,19 **** */ public class Grid extends Constructor { ! private double size; private double distance; --- 15,20 ---- */ public class Grid extends Constructor { ! private double width; ! private double height; private double distance; *************** *** 24,29 **** public Grid() { super(new Vertex(0, 0, 0)); ! size = 40.0; ! distance = 1.0; } --- 25,31 ---- public Grid() { super(new Vertex(0, 0, 0)); ! distance = 2.4; ! width = 12 * distance; ! height = 8 * distance; } *************** *** 32,37 **** * @return size */ ! public double getSize() { ! return size; } --- 34,39 ---- * @return size */ ! public double getWidth() { ! return width; } *************** *** 40,47 **** * @param value new size */ ! public void setSize(double value) { ! size = value; } /** * --- 42,66 ---- * @param value new size */ ! public void setWidth(double value) { ! width = value; } + + /** + * Sets the height. + * @param value new value of height. + */ + public void setHeight(double value) { + height = value; + } + + /** + * Returns the height. + * @return the height. + */ + public double getHeight() { + return height; + } + /** * *************** *** 68,72 **** public List<Attribute> getAttributes() { LinkedList<Attribute> attributes = new LinkedList(); ! attributes.add(new Attribute("Size", new Double(size))); attributes.add(new Attribute("Distance", new Double(distance))); return attributes; --- 87,92 ---- public List<Attribute> getAttributes() { LinkedList<Attribute> attributes = new LinkedList(); ! attributes.add(new Attribute("Width", new Double(width))); ! attributes.add(new Attribute("Height", new Double(height))); attributes.add(new Attribute("Distance", new Double(distance))); return attributes; *************** *** 76,81 **** public void setAttributes(List<Attribute> attributes) { for (Attribute current : attributes) { ! if (current.getName().equals("Size")) { ! size = (Double)(current.getValue()); } else if (current.getName().equals("Distance")) { distance = (Double)(current.getValue()); --- 96,103 ---- public void setAttributes(List<Attribute> attributes) { for (Attribute current : attributes) { ! if (current.getName().equals("Width")) { ! width = (Double)(current.getValue()); ! } else if (current.getName().equals("Height")) { ! height = (Double)(current.getValue()); } else if (current.getName().equals("Distance")) { distance = (Double)(current.getValue()); *************** *** 91,95 **** public Collection<Line> lines() { ! double size = getSize(); double delta = getDistance(); CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); --- 113,117 ---- public Collection<Line> lines() { ! double size = getWidth(); double delta = getDistance(); CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); *************** *** 137,140 **** --- 159,197 ---- } + /** + * + * @param system CoordinateSystem + * @return grid lines + */ + public Collection<Edge> guides(CoordinateSystem system) { + Collection<Edge> guides = new LinkedList(); + Vertex origin = system.getOrigin(); + Vertex i = system.getI(); + Vertex j = system.getJ(); + { + double w = getWidth(); + double h = getHeight(); + double d = getDistance(); + int n = (int) Math.floor((w + d) / d); + int m = (int) Math.floor((h + d) / d); + Vertex from = origin.copy(); + for (int k = 0; k < n; k++) { + Vertex to = from.add(j.scale(h)); + Edge edge = new Edge(from, to); + guides.add(edge); + from = from.add(i.scale(d)); + } + from = origin.copy(); + for (int k = 0; k < m; k++) { + Vertex to = from.add(i.scale(w)); + Edge edge = new Edge(from, to); + guides.add(edge); + from = from.add(j.scale(d)); + } + } + return guides; + } + + /** {@inheritDoc} */ public String title() { Index: Camera.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Camera.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** Camera.java 25 Jun 2009 20:29:33 -0000 1.59 --- Camera.java 9 Sep 2009 10:31:00 -0000 1.60 *************** *** 142,173 **** this.setHiddenGeometrics(new HashSet(other.getHiddenGeometrics())); } - - /** - /** - * Create a default camera of your choice - * @param type the camera type - * @return a new camera - */ - public static Camera create(int type) { - Camera res = null; - if (type == VIEW_3D) { - res = new Camera("3D", new double[]{6, 3, 2}, - new double[]{7, -12, 16}, - new double[] {0, 0, 1}, PERSPECTIVE); - } else if (type == VIEW_XZ) { - res = new Camera("xz (ortho)", new double[]{0, 0, 0}, - new double[]{0, -20, 0}, - new double[] {0, 0, 1}, ORTHOGRAPHIC); - } else if (type == VIEW_XY) { - res = new Camera("xy (ortho)", new double[]{0, 0, 0}, - new double[]{0, 0, 20}, - new double[] {0, 1, 0}, ORTHOGRAPHIC); - } else if (type == VIEW_YZ) { - res = new Camera("yz (ortho)", new double[]{0, 0, 0}, - new double[]{20, 0, 0}, - new double[] {0, 0, 1}, ORTHOGRAPHIC); - } - return res; - } /** --- 142,145 ---- |