Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.119, 1.120
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-07-21 19:23:36
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30545/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: Made constructors hit-detectable with the select-tool Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** View.java 21 Jul 2006 14:57:26 -0000 1.119 --- View.java 21 Jul 2006 19:23:33 -0000 1.120 *************** *** 260,263 **** --- 260,266 ---- private int selectMode; + /** Are intersections wanted in hit-detection? */ + private boolean selectIntersections; + /** The drawing mode. Either wireframe, solid og lighting */ protected int drawMode = View.LIGHTING_MODE; *************** *** 531,535 **** Camera camera = Project.getInstance().getCurrentCamera(); double scale = (camera.getFocalwidth() / 65) * (500 / height); ! drawCoordinateSystem(Project.getInstance().getActiveCoordinateSystem(), camera.dist() * scale); Iterator clipit = Project.getInstance().getCurrentCamera().getClipplanes().iterator(); --- 534,539 ---- Camera camera = Project.getInstance().getCurrentCamera(); double scale = (camera.getFocalwidth() / 65) * (500 / height); ! drawCoordinateSystem(Project.getInstance().getActiveCoordinateSystem(), ! camera.dist() * scale, true); Iterator clipit = Project.getInstance().getCurrentCamera().getClipplanes().iterator(); *************** *** 913,916 **** --- 917,930 ---- drawClipplane(cp); gl.glEnable(GL.GL_DEPTH_TEST); + } else if (o instanceof Constructor) { + Constructor c = (Constructor) o; + Camera camera = Project.getInstance().getCurrentCamera(); + Vertex v = new Vertex(camera.getCamera()); + double scale = (camera.getFocalwidth() / 65) * (500 / height); + double dist = v.minus(new Vertex(camera.getCenter())).length() * scale; + if (camera.getType() == Camera.PERSPECTIVE) { + dist = (c.getOrigin().minus(v)).length() * scale; + } + drawGeneralConstructor(c, dist, false); } } *************** *** 970,991 **** dist = (c.getOrigin().minus(v)).length() * scale; } ! ! if (o instanceof Point) { ! gl.glColor3fv(CONSTRUCTOR_COLOR); ! drawConstructorPoint(((Point)o).getOrigin(), dist); ! } else if (o instanceof Line) { ! gl.glColor3fv(CONSTRUCTOR_COLOR); ! Line l = (Line)o; ! //drawConstructorPoint(l.getOrigin(), dist); ! drawConstructorVector(l.getOrigin(), l.getDirection(), dist); ! if (l.isActive()) { ! drawConstructorLine(l.getOrigin(), l.getDirection(), dist); ! } ! } else if (o instanceof CoordinateSystem) { ! CoordinateSystem coo = (CoordinateSystem)o; ! if (cs != coo) { ! drawCoordinateSystem(coo, dist); ! } ! } } } else { --- 984,988 ---- dist = (c.getOrigin().minus(v)).length() * scale; } ! drawGeneralConstructor(c, dist, true); } } else { *************** *** 997,1013 **** /** * draw the coordinatesystem * @param cs The coordinatesystem * @param dist The distance to the center of the system */ ! private void drawCoordinateSystem(CoordinateSystem cs, double dist) { Vertex i = cs.getI(); Vertex j = cs.getJ(); ! gl.glColor3fv(X_AXIS_COLOR); drawConstructorVector(cs.getOrigin(), i, dist); if (cs.isActive()) { drawConstructorLine(cs.getOrigin(), i, dist); } ! gl.glColor3fv(Y_AXIS_COLOR); drawConstructorVector(cs.getOrigin(), j, dist); if (cs.isActive()) { --- 994,1045 ---- /** + * Draw a constructor + * @param constructor The constructor + * @param dist The dist parameter + * @param colorize Apply color + */ + private void drawGeneralConstructor(Constructor constructor, double dist, boolean colorize) { + if (constructor instanceof Point) { + if (colorize) { + gl.glColor3fv(CONSTRUCTOR_COLOR); + } + drawConstructorPoint(((Point)constructor).getOrigin(), dist); + } else if (constructor instanceof Line) { + if (colorize) { + gl.glColor3fv(CONSTRUCTOR_COLOR); + } + Line l = (Line)constructor; + drawConstructorVector(l.getOrigin(), l.getDirection(), dist); + if (l.isActive()) { + drawConstructorLine(l.getOrigin(), l.getDirection(), dist); + } + } else if (constructor instanceof CoordinateSystem) { + CoordinateSystem system = (CoordinateSystem)constructor; + CoordinateSystem cs = Project.getInstance().getActiveCoordinateSystem(); + if (cs != system) { + drawCoordinateSystem(system, dist, colorize); + } + } + } + + /** * draw the coordinatesystem * @param cs The coordinatesystem * @param dist The distance to the center of the system + * @param colorize Apply color */ ! private void drawCoordinateSystem(CoordinateSystem cs, double dist, boolean colorize) { Vertex i = cs.getI(); Vertex j = cs.getJ(); ! if (colorize) { ! gl.glColor3fv(X_AXIS_COLOR); ! } drawConstructorVector(cs.getOrigin(), i, dist); if (cs.isActive()) { drawConstructorLine(cs.getOrigin(), i, dist); } ! if (colorize) { ! gl.glColor3fv(Y_AXIS_COLOR); ! } drawConstructorVector(cs.getOrigin(), j, dist); if (cs.isActive()) { *************** *** 1016,1020 **** if (!cs.onlyPlane()) { Vertex n = cs.getN(); ! gl.glColor3fv(Z_AXIS_COLOR); drawConstructorVector(cs.getOrigin(), n, dist); if (cs.isActive()) { --- 1048,1054 ---- if (!cs.onlyPlane()) { Vertex n = cs.getN(); ! if (colorize) { ! gl.glColor3fv(Z_AXIS_COLOR); ! } drawConstructorVector(cs.getOrigin(), n, dist); if (cs.isActive()) { *************** *** 1653,1686 **** double dist = v.minus(new Vertex(camera.getCenter())).length() * scale; ! Iterator iter = space.getConstructors().iterator(); while (iter.hasNext()) { Constructor current = (Constructor) iter.next(); ! pushName(gl, current.getOrigin()); ! drawVertexHit(current.getOrigin()); ! popName(gl); ! if (current instanceof Line) { ! Line line = (Line) current; ! ! Vertex origin = line.getOrigin(); ! Vertex direction = line.getDirection().copy(); ! direction.scale(View.gridSize() * 2); ! Vertex from = origin.minus(direction); ! Vertex to = origin.add(direction); ! Edge constructor = new Edge(from, to); ! constructor.setConstructor(true); ! ! if (camera.getType() == Camera.PERSPECTIVE) { ! dist = (origin.minus(v)).length() * scale; ! } ! Vertex tip = line.tip(dist / 16 + dist / 20); ! pushName(gl, tip); ! drawVertexHit(tip); popName(gl); ! if (current.isActive()) { ! pushName(gl, constructor); ! drawEdge(constructor); popName(gl); } } } --- 1687,1726 ---- double dist = v.minus(new Vertex(camera.getCenter())).length() * scale; ! Iterator iter = space.getConstructors().iterator(); while (iter.hasNext()) { Constructor current = (Constructor) iter.next(); ! if (camera.getType() == Camera.PERSPECTIVE) { ! dist = (current.getOrigin().minus(v)).length() * scale; ! } ! if (selectIntersections) { ! pushName(gl, current.getOrigin()); ! drawVertexHit(current.getOrigin()); popName(gl); ! if (current instanceof Line) { ! Line line = (Line) current; ! ! Vertex origin = line.getOrigin(); ! Vertex direction = line.getDirection().copy(); ! direction.scale(View.gridSize() * 2); ! Vertex from = origin.minus(direction); ! Vertex to = origin.add(direction); ! Edge constructor = new Edge(from, to); ! constructor.setConstructor(true); ! ! Vertex tip = line.tip(dist / 16 + dist / 20); ! pushName(gl, tip); ! drawVertexHit(tip); popName(gl); + if (current.isActive()) { + pushName(gl, constructor); + drawEdge(constructor); + popName(gl); + } } + } else { + pushName(gl, current); + drawGeneralConstructor(current, dist, false); + popName(gl); } } *************** *** 2196,2199 **** --- 2236,2240 ---- picking = 10; selectMode = ALL; + selectIntersections = intersections; glv.repaint(true); |