[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.38,1.39
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2005-10-02 20:39:23
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21409 Modified Files: AbstractView.java Log Message: added support for clicking the domain labels and did some clean up Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** AbstractView.java 29 Sep 2005 15:05:02 -0000 1.38 --- AbstractView.java 30 Sep 2005 17:56:16 -0000 1.39 *************** *** 14,22 **** import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.EdgeFacade; ! import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.VertexFacade; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.SurfaceFacade; import java.util.ArrayList; --- 14,23 ---- import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.EdgeFacade; ! import net.sourceforge.bprocessor.model.Domain; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.VertexFacade; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.SurfaceFacade; + import net.sourceforge.bprocessor.model.FunctionalSpace; import java.util.ArrayList; *************** *** 262,283 **** if (glv.getTool() instanceof SelectTool) { - //gl.glDisable(GL.GL_DEPTH_TEST); - //gl.glDisable(GL.GL_LIGHTING); decorateSelection(); } if (glv.getTool() instanceof SelectTool) { gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); glu.gluOrtho2D(0, width, 0, height); gl.glMatrixMode(GL.GL_MODELVIEW); ! gl.glLoadIdentity(); ! labelSelection(); } ! //drawTextBox(200, 200, "Space 1"); ! ! ! gl.glGetIntegerv(GL.GL_RENDER_MODE, mode); ! if (mode[0] == GL.GL_SELECT) { gl.glFlush(); --- 263,284 ---- if (glv.getTool() instanceof SelectTool) { decorateSelection(); } + gl.glGetIntegerv(GL.GL_RENDER_MODE, mode); + if (glv.getTool() instanceof SelectTool) { gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); + if (mode[0] == GL.GL_SELECT) { + int[] viewport = new int[] {0, 0, (int)width, (int)height}; + glu.gluPickMatrix(x, viewport[3] - y, 5, 5, viewport); + } glu.gluOrtho2D(0, width, 0, height); gl.glMatrixMode(GL.GL_MODELVIEW); ! gl.glLoadIdentity(); ! labelSelection(mode[0] == GL.GL_SELECT); } ! if (mode[0] == GL.GL_SELECT) { gl.glFlush(); *************** *** 388,413 **** * Put labels on a Surface * @param surface The Surface */ ! void labelSurface(Surface surface) { Vertex from = surface.center(); - // CoordinateSystem system = surface.coordinateSystem(); - // Vertex n = system.getN(); Vertex n = surface.normal(); n.scale(1 / n.length()); Vertex spot = from.add(n); Transformation transformation = transformation(); ! Space frontSpace = (Space) surface.getFrontDomain(); ! Space backSpace = (Space) surface.getBackDomain(); String frontName; String backName; ! if (frontSpace != null) { ! frontName = frontSpace.getName(); } else { frontName = "None"; } ! if (backSpace != null) { ! backName = backSpace.getName(); } else { backName = "None"; --- 389,413 ---- * Put labels on a Surface * @param surface The Surface + * @param clickable if true clicking the labels brings up dialog. */ ! void labelSurface(Surface surface, boolean clickable) { Vertex from = surface.center(); Vertex n = surface.normal(); n.scale(1 / n.length()); Vertex spot = from.add(n); Transformation transformation = transformation(); ! Domain frontDomain = surface.getFrontDomain(); ! Domain backDomain = surface.getBackDomain(); String frontName; String backName; ! if (frontDomain != null) { ! frontName = frontDomain.getName(); } else { frontName = "None"; } ! if (backDomain != null) { ! backName = backDomain.getName(); } else { backName = "None"; *************** *** 424,428 **** Vertex backTextAnchor; ! if (front.getX() > back.getX()) { frontAnchor = new Vertex("", front.getX() + 40, front.getY() + 10, front.getZ()); --- 424,429 ---- Vertex backTextAnchor; ! int backSign; ! int frontSign; if (front.getX() > back.getX()) { frontAnchor = new Vertex("", front.getX() + 40, front.getY() + 10, front.getZ()); *************** *** 430,441 **** backAnchor = new Vertex("", back.getX() - 40, back.getY() + 10, back.getZ()); backTextAnchor = new Vertex("", backAnchor.getX() - backWidth, ! backAnchor.getY(), backAnchor.getZ()); } 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; } gl.glLineWidth(1.0f); --- 431,447 ---- 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); *************** *** 446,450 **** gl.glEnd(); gl.glColor3d(0.2, 0.2, 0.2); ! drawString(frontTextAnchor.getX(), frontTextAnchor.getY(), frontName); gl.glColor3d(0.4, 0.4, 0.4); gl.glBegin(GL.GL_LINES); --- 452,473 ---- gl.glEnd(); 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); *************** *** 453,463 **** gl.glEnd(); gl.glColor3d(0.2, 0.2, 0.2); ! drawString(backTextAnchor.getX(), backTextAnchor.getY(), backName); } /** * Put labels on the selection */ ! void labelSelection() { Collection selection = glv.getTool().getSelection(); if (selection.size() == 1) { --- 476,506 ---- gl.glEnd(); 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. */ ! void labelSelection(boolean clickable) { Collection selection = glv.getTool().getSelection(); if (selection.size() == 1) { *************** *** 466,470 **** Object current = iter.next(); if (current instanceof Surface) { ! labelSurface((Surface) current); } } --- 509,513 ---- Object current = iter.next(); if (current instanceof Surface) { ! labelSurface((Surface) current, clickable); } } *************** *** 639,642 **** --- 682,691 ---- */ private void drawSurface(Surface s) { + if (s.getIsInner() && + s.getBackDomain() instanceof FunctionalSpace && + s.getFrontDomain() instanceof FunctionalSpace) { + gl.glEnable(GL.GL_POLYGON_STIPPLE); + gl.glPolygonStipple(transparency); + } GLUtesselator tess = glu.gluNewTess(); GLUtesselatorCallback cb = new Callback(); *************** *** 646,650 **** glu.gluTessCallback(tess, GLU.GLU_TESS_END, cb); glu.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, cb); ! //Contours contained in an even number of contours are filled glu.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD); --- 695,699 ---- glu.gluTessCallback(tess, GLU.GLU_TESS_END, cb); glu.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, cb); ! //Contours contained in an even number of contours are filled glu.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD); *************** *** 675,678 **** --- 724,728 ---- glu.gluTessEndPolygon(tess); glu.gluDeleteTess(tess); + gl.glDisable(GL.GL_POLYGON_STIPPLE); } *************** *** 926,932 **** /** * Processes the select buffer ! * @return the ID of the closest hit */ ! private Long processSelect() { //Processing hits int bufferOffset = 0; --- 976,982 ---- /** * Processes the select buffer ! * @return the ID of the closest hit and -1 of no hit. */ ! private int processSelect() { //Processing hits int bufferOffset = 0; *************** *** 934,939 **** long zMax = 0xFFFFFFFFL; double nearest = 1.0; ! Long id = null; ! Integer intId; for (int i = 0; i < hits; i++) { names = selectBuffer.get(bufferOffset); --- 984,988 ---- long zMax = 0xFFFFFFFFL; double nearest = 1.0; ! int id = -1; for (int i = 0; i < hits; i++) { names = selectBuffer.get(bufferOffset); *************** *** 948,953 **** if (near < nearest) { nearest = near; ! id = new Long((new Integer(selectBuffer.get(bufferOffset))).longValue()); ! } bufferOffset += names; --- 997,1001 ---- if (near < nearest) { nearest = near; ! id = selectBuffer.get(bufferOffset); } bufferOffset += names; *************** *** 957,965 **** } ! if (id != null) { ! return id; ! } else { ! return null; ! } } --- 1005,1009 ---- } ! return id; } *************** *** 968,979 **** * @param x the x coordinate of the point in mouse coordinates * @param y the y coordinate of the point in mouse coordinates ! * @return a Long id of the object under the point, null if no object is there */ public Object getObjectAtPoint(double x, double y) { ! Long id = null; this.x = x; this.y = y; ! // indicating that I am trying to pick(used in camera) picking = 10; selectMode = ALL; --- 1012,1023 ---- * @param x the x coordinate of the point in mouse coordinates * @param y the y coordinate of the point in mouse coordinates ! * @return The object under the point, null if no object is there */ public Object getObjectAtPoint(double x, double y) { ! int id; this.x = x; this.y = y; ! // indicating that I am trying to pick picking = 10; selectMode = ALL; *************** *** 981,986 **** glv.repaint(true); id = processSelect(); ! if (id != null) { ! Object o = getName(id.intValue()); clearNames(); return o; --- 1025,1030 ---- glv.repaint(true); id = processSelect(); ! if (id != -1) { ! Object o = getName(id); clearNames(); return o; *************** *** 988,994 **** clearNames(); return null; ! } ! ! } --- 1032,1036 ---- clearNames(); return null; ! } } |