[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.21,1.22
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-09-06 13:51:29
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25935/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java Log Message: Changed selection to not allow clicking through surfaces Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** AbstractView.java 6 Sep 2005 12:00:09 -0000 1.21 --- AbstractView.java 6 Sep 2005 13:51:21 -0000 1.22 *************** *** 19,22 **** --- 19,23 ---- import net.sourceforge.bprocessor.model.SurfaceFacade; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; *************** *** 56,59 **** --- 57,64 ---- private static final int VERTICES = 2; + /** Select mode for selecting ALL **/ + + private static final int ALL = 3; + /** The width of the window */ protected static double width; *************** *** 110,113 **** --- 115,121 ---- protected IntBuffer selectBuffer; + /** The objectTable used for assigning unique ID's during selection */ + protected ArrayList objectTable; + /** The last used near value */ protected double near; *************** *** 313,317 **** glu = gld.getGLU(); ! gl.glInitNames(); if (mode[0] != GL.GL_SELECT) { gl.glEnable(GL.GL_DEPTH_TEST); --- 321,325 ---- glu = gld.getGLU(); ! initNames(gl); if (mode[0] != GL.GL_SELECT) { gl.glEnable(GL.GL_DEPTH_TEST); *************** *** 421,457 **** } else { // HERE STARTS SELECTION MODE DRAWING ! if (selectMode == SURFACES) { ! Iterator it = surfaces.iterator(); ! gl.glColor3fv(SURFACE_COLOR); while (it.hasNext()) { ! Surface s = (Surface)it.next(); ! int name = s.getId().intValue(); ! gl.glPushName(name); ! drawSurface(s); ! gl.glPopName(); } } ! ! if (selectMode == EDGES) { Iterator it = edges.iterator(); gl.glColor3fv(STD_LINE_COLOR); while (it.hasNext()) { Edge e = (Edge)it.next(); ! int name = e.getId().intValue(); ! gl.glPushName(name); drawEdge(e); ! gl.glPopName(); } } ! ! if (selectMode == VERTICES) { ! Iterator it = vertices.iterator(); ! gl.glColor3fv(STD_LINE_COLOR); while (it.hasNext()) { ! Vertex v = (Vertex)it.next(); ! int name = v.getId().intValue(); ! gl.glPushName(name); ! drawVertex(v); ! gl.glPopName(); } } --- 429,460 ---- } else { // HERE STARTS SELECTION MODE DRAWING ! if (selectMode == VERTICES || selectMode == ALL) { ! Iterator it = vertices.iterator(); ! gl.glColor3fv(STD_LINE_COLOR); while (it.hasNext()) { ! Vertex v = (Vertex)it.next(); ! pushName(gl, v); ! drawVertex(v); ! popName(gl); } } ! if (selectMode == EDGES || selectMode == ALL) { Iterator it = edges.iterator(); gl.glColor3fv(STD_LINE_COLOR); while (it.hasNext()) { Edge e = (Edge)it.next(); ! pushName(gl, e); drawEdge(e); ! popName(gl); } } ! if (selectMode == SURFACES || selectMode == ALL) { ! Iterator it = surfaces.iterator(); ! gl.glColor3fv(SURFACE_COLOR); while (it.hasNext()) { ! Surface s = (Surface)it.next(); ! pushName(gl, s); ! drawSurface(s); ! popName(gl); } } *************** *** 781,784 **** --- 784,826 ---- /** + * Initialize the objectTable and the name-stack + * @param gl The GL + */ + private void initNames(GL gl) { + objectTable = new ArrayList(); + gl.glInitNames(); + } + /** + * Insert object into objectTable and push its index on the name-stack + * @param gl The GL + * @param object The object to insert + */ + private void pushName(GL gl, Object object) { + objectTable.add(object); + gl.glPushName(objectTable.size()); + } + /** + * Pop a name from the name-stack + * @param gl The GL + */ + private void popName(GL gl) { + gl.glPopName(); + } + /** + * Return the object with the specifed index in objectTable + * @param index The index of the object + * @return The object + */ + private Object getName(int index) { + return objectTable.get(index - 1); + } + /** + * Remove the objectTable + * + */ + private void clearNames() { + objectTable = null; + } + /** * Processes the select buffer * @return the ID of the closest hit *************** *** 833,865 **** // indicating that I am trying to pick(used in camera) picking = 10; ! selectMode = VERTICES; ! //repainting to get selection buffer ! glv.repaint(true); ! id = processSelect(); ! if (id != null) { ! Vertex v = VertexFacade.getInstance().findById(id); ! return v; ! } ! //indicating that I am trying to pick(used in camera) ! picking = 10; ! selectMode = EDGES; ! //repainting to get selection buffer ! glv.repaint(true); ! id = processSelect(); ! if (id != null) { ! Edge e = EdgeFacade.getInstance().findById(id); ! return e; ! } ! //indicating that I am trying to pick(used in camera) ! picking = 10; ! selectMode = SURFACES; //repainting to get selection buffer glv.repaint(true); id = processSelect(); if (id != null) { ! Surface s = SurfaceFacade.getInstance().findById(id); ! return s; ! } ! return null; } --- 875,892 ---- // indicating that I am trying to pick(used in camera) picking = 10; ! selectMode = ALL; //repainting to get selection buffer glv.repaint(true); id = processSelect(); if (id != null) { ! Object o = getName(id.intValue()); ! clearNames(); ! return o; ! } else { ! clearNames(); ! return null; ! } ! ! } |