Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.45,1.46
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2005-10-27 15:05:25
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16295 Modified Files: AbstractView.java Log Message: Changed way of displaying the space labels Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** AbstractView.java 26 Oct 2005 10:15:05 -0000 1.45 --- AbstractView.java 27 Oct 2005 15:05:10 -0000 1.46 *************** *** 122,126 **** /** The ball is used for hit-detecting vertices */ - protected GLUquadric ball; --- 122,125 ---- *************** *** 269,277 **** drawAll(gld); - - if (glv.getTool() instanceof SelectTool) { - decorateSelection(); - } - gl.glGetIntegerv(GL.GL_RENDER_MODE, mode); --- 268,271 ---- *************** *** 371,376 **** CoordinateSystem system = surface.coordinateSystem(); Vertex n = system.getN(); ! ! Edge edge = new Edge("", from.minus(n), from.add(n)); gl.glColor3d(0.0, 0.0, 1.0); drawEdge(edge); --- 365,370 ---- CoordinateSystem system = surface.coordinateSystem(); Vertex n = system.getN(); ! ! Edge edge = new Edge("", from, from.add(n)); gl.glColor3d(0.0, 0.0, 1.0); drawEdge(edge); *************** *** 404,408 **** Vertex n = surface.normal(); n.scale(1 / n.length()); - Vertex spot = from.add(n); Transformation transformation = transformation(); Domain frontDomain = surface.getFrontDomain(); --- 398,401 ---- *************** *** 426,523 **** int backWidth = glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_18, backName); ! Vertex front = transformation.project(from.add(n)); ! Vertex back = transformation.project(from.minus(n)); ! Vertex frontAnchor; ! Vertex backAnchor; Vertex frontTextAnchor; Vertex backTextAnchor; - int backSign; - int frontSign; - if (front.getX() > back.getX()) { - frontAnchor = new Vertex("", front.getX() + 40, front.getY() + 10, front.getZ()); - frontTextAnchor = frontAnchor; - backAnchor = new Vertex("", back.getX() - 40, back.getY() + 10, back.getZ()); - backTextAnchor = new Vertex("", backAnchor.getX() - backWidth, - backAnchor.getY(), backAnchor.getZ()); - frontSign = 1; - backSign = -1; - } else { - frontAnchor = new Vertex("", front.getX() - 40, front.getY() + 10, front.getZ()); - frontTextAnchor = new Vertex("", frontAnchor.getX() - frontWidth, - frontAnchor.getY(), frontAnchor.getZ()); - backAnchor = new Vertex("", back.getX() + 40, back.getY() + 10, back.getZ()); - backTextAnchor = backAnchor; - frontSign = -1; - backSign = 1; - } - ! gl.glLineWidth(1.0f); ! gl.glColor3d(0.4, 0.4, 0.4); ! gl.glBegin(GL.GL_LINES); ! gl.glVertex3d(front.getX(), front.getY(), front.getZ()); ! gl.glVertex3d(frontAnchor.getX(), frontAnchor.getY(), frontAnchor.getZ()); ! gl.glEnd(); ! if (frontDomain instanceof FunctionalSpace) { ! gl.glColor3d(0.2, 0.2, 0.5); ! } else if (frontDomain instanceof ConstructionSpace) { ! gl.glColor3d(0.8, 0.2, 0.4); } else { ! gl.glColor3d(0.2, 0.2, 0.2); } if (clickable) { ! pushName(gl, "front"); ! gl.glBegin(GL.GL_POLYGON); ! gl.glVertex3d(frontAnchor.getX(), frontAnchor.getY(), frontAnchor.getZ()); ! gl.glVertex3d(frontAnchor.getX() + (frontSign * frontWidth), ! frontAnchor.getY(), ! frontAnchor.getZ()); ! gl.glVertex3d(frontAnchor.getX() + (frontSign * frontWidth), ! frontAnchor.getY() + 18, ! frontAnchor.getZ()); ! gl.glVertex3d(frontAnchor.getX(), ! frontAnchor.getY() + 18, ! frontAnchor.getZ()); ! gl.glEnd(); popName(gl); } else { drawString(frontTextAnchor.getX(), frontTextAnchor.getY(), frontName); } ! gl.glColor3d(0.4, 0.4, 0.4); gl.glBegin(GL.GL_LINES); ! gl.glVertex3d(back.getX(), back.getY(), back.getZ()); ! gl.glVertex3d(backAnchor.getX(), backAnchor.getY(), backAnchor.getZ()); gl.glEnd(); - if (backDomain instanceof FunctionalSpace) { - gl.glColor3d(0.2, 0.2, 0.5); - } else if (backDomain instanceof ConstructionSpace) { - gl.glColor3d(0.8, 0.2, 0.4); - } else { - gl.glColor3d(0.2, 0.2, 0.2); - } - if (clickable) { - pushName(gl, "back"); - gl.glBegin(GL.GL_POLYGON); - gl.glVertex3d(backAnchor.getX(), - backAnchor.getY(), - backAnchor.getZ()); - gl.glVertex3d(backAnchor.getX() + (backSign * backWidth), - backAnchor.getY(), - backAnchor.getZ()); - gl.glVertex3d(backAnchor.getX() + (backSign * backWidth), - backAnchor.getY() + 18, - backAnchor.getZ()); - gl.glVertex3d(backAnchor.getX(), - backAnchor.getY(), - backAnchor.getZ()); - gl.glEnd(); - popName(gl); - } else { - drawString(backTextAnchor.getX(), backTextAnchor.getY(), backName); - } } /** * Put labels on the selection * @param clickable if true clicking the labels brings up dialog. --- 419,518 ---- int backWidth = glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_18, backName); ! Vertex front = transformation.project(from); Vertex frontTextAnchor; Vertex backTextAnchor; ! Vertex near = new Vertex("", front.getX(), front.getY(), 0.0); ! Vertex far = new Vertex("", front.getX(), front.getY(), 1.0); ! Edge ray = new Edge("", near, far); ! ray = transformation.unProject(ray); ! Vertex rayDir = ray.getTo().minus(ray.getFrom()); ! if (rayDir.dot(n) > 0) { ! frontTextAnchor = new Vertex("", front.getX() - (frontWidth / 2), ! front.getY() - 17, front.getZ()); ! backTextAnchor = new Vertex("", front.getX() - (backWidth / 2), ! front.getY() + 7, front.getZ()); } else { ! frontTextAnchor = new Vertex("", front.getX() - (frontWidth / 2), ! front.getY() + 7, front.getZ()); ! backTextAnchor = new Vertex("", front.getX() - (backWidth / 2), ! front.getY() - 17, front.getZ()); } + if (clickable) { ! //Name must be "front" ! drawClickBox(frontTextAnchor.getX(), frontTextAnchor.getY(), ! frontTextAnchor.getZ(), frontWidth, 10, ! "front"); ! //Name must be "back" ! drawClickBox(backTextAnchor.getX(), backTextAnchor.getY(), ! backTextAnchor.getZ(), backWidth, 10, ! "back"); ! //Name must be "bar" ! pushName(gl, "bar"); ! drawSeperator(front, Math.max(frontWidth, backWidth)); popName(gl); } else { + //draw the front domain name + if (frontDomain instanceof FunctionalSpace) { + gl.glColor3d(0.2, 0.2, 0.5); + } else if (frontDomain instanceof ConstructionSpace) { + gl.glColor3d(0.8, 0.2, 0.4); + } else { + gl.glColor3d(0.2, 0.2, 0.2); + } drawString(frontTextAnchor.getX(), frontTextAnchor.getY(), frontName); + + //draw the back domain name + if (backDomain instanceof FunctionalSpace) { + gl.glColor3d(0.2, 0.2, 0.5); + } else if (backDomain instanceof ConstructionSpace) { + gl.glColor3d(0.8, 0.2, 0.4); + } else { + gl.glColor3d(0.2, 0.2, 0.2); + } + drawString(backTextAnchor.getX(), backTextAnchor.getY(), backName); + + drawSeperator(front, Math.max(frontWidth, backWidth)); } ! } ! /** ! * Draws the seperator between spacenames ! * @param center the center of the seperating bar ! * @param width the width of the bar ! */ ! private void drawSeperator(Vertex center, int width) { ! gl.glLineWidth(3.0f); ! gl.glColor3d(0.0, 0.0, 0.0); gl.glBegin(GL.GL_LINES); ! gl.glVertex3d(center.getX() + (width / 2), center.getY(), center.getZ()); ! gl.glVertex3d(center.getX() - (width / 2), center.getY(), center.getZ()); gl.glEnd(); } /** + * Draws a box from the coordinates that gets a given name in selection + * @param x x-coordinate of lower left corner + * @param y y-coordinate of lower left corner + * @param z z-coordinate of lower left corner + * @param width box width + * @param height box height + * @param name the name for the box + */ + private void drawClickBox(double x, double y, double z, + int width, int height, String name) { + pushName(gl, name); + gl.glBegin(GL.GL_POLYGON); + gl.glVertex3d(x, y, z); + gl.glVertex3d(x * width, y, z); + gl.glVertex3d(x + width, y + height, z); + gl.glVertex3d(x, y + height, z); + gl.glEnd(); + popName(gl); + } + + + /** * Put labels on the selection * @param clickable if true clicking the labels brings up dialog. |