[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.183, 1.184
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-02-14 14:27:32
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17746/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: Refactoring draw code Ð removed usage of gld Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.183 retrieving revision 1.184 diff -C2 -d -r1.183 -r1.184 *** View.java 14 Feb 2007 11:41:57 -0000 1.183 --- View.java 14 Feb 2007 14:27:24 -0000 1.184 *************** *** 357,363 **** private Set tempVertices; - /** Entities that should be drawn on top of everything else*/ - private Set onTopEntities; - /** Maps entities to a color */ private Map colorMap; --- 357,360 ---- *************** *** 382,388 **** private int maxClippingPlanes; - /** */ - private static final boolean DRAW_ALL = true; - static { setTransparency(100); --- 379,382 ---- *************** *** 495,499 **** tempSurfaces = new HashSet(); tempVertices = new HashSet(); - onTopEntities = new HashSet(); colorMap = new HashMap(); glObjects3D = new HashSet(); --- 489,492 ---- *************** *** 531,538 **** */ public void init(GLAutoDrawable gld) { if (log.isDebugEnabled()) { log.debug("[init]"); } ! gl = gld.getGL(); //ENABLE FOR DEBUG gld.setGL(new DebugGL(gld.getGL())); --- 524,532 ---- */ public void init(GLAutoDrawable gld) { + gl = gld.getGL(); if (log.isDebugEnabled()) { log.debug("[init]"); } ! //ENABLE FOR DEBUG gld.setGL(new DebugGL(gld.getGL())); *************** *** 612,623 **** */ public void display(GLAutoDrawable gld) { boolean hitdetection = false; ! gl.glClearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]); - gl = gld.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); ! ! glu = new GLU(); ! //gl.glViewport(0, 0, (int)width, (int)height); if (picking > 0) { selectBuffer = BufferUtil.newIntBuffer(selectionLength); --- 606,617 ---- */ public void display(GLAutoDrawable gld) { + gl = gld.getGL(); + glu = new GLU(); + boolean hitdetection = false; ! gl.glClearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); ! if (picking > 0) { selectBuffer = BufferUtil.newIntBuffer(selectionLength); *************** *** 627,631 **** } ! initCamera(gld); gl.glPushMatrix(); picking = 0; --- 621,625 ---- } ! initCamera(); gl.glPushMatrix(); picking = 0; *************** *** 636,640 **** gl.glLineWidth(1.0f); ! drawAll(gld, hitdetection); gl.glEnable(GL.GL_DEPTH_TEST); --- 630,634 ---- gl.glLineWidth(1.0f); ! drawAll(hitdetection); gl.glEnable(GL.GL_DEPTH_TEST); *************** *** 745,757 **** /** * The camera setup function - * @param gld The GLDrawable object */ ! public void initCamera(GLAutoDrawable gld) { if (log.isDebugEnabled()) { log.debug("[display]"); } - gl = gld.getGL(); - glu = new GLU(); - gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); --- 739,747 ---- /** * The camera setup function */ ! public void initCamera() { if (log.isDebugEnabled()) { log.debug("[display]"); } gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); *************** *** 837,848 **** /** * Draw all the existing elements - * @param gld The GLDrawable * @param hitdetection For hitdetection */ ! protected void drawAll(GLAutoDrawable gld, boolean hitdetection) { ! if (!hitdetection) { ! drawNormalMode(gld); } else { ! drawSelectionMode(gld); } } --- 827,837 ---- /** * Draw all the existing elements * @param hitdetection For hitdetection */ ! protected void drawAll(boolean hitdetection) { ! if (!hitdetection) { ! drawNormalMode(); } else { ! drawSelectionMode(); } } *************** *** 854,921 **** public Collection collectSupportingEdges(Space active) { Collection edges = new HashSet(); ! ! if (DRAW_ALL) { ! if (active != Project.getInstance().world()) { ! Space current = active; ! while (current != null) { ! if (current.isUnion()) { ! Collection<Surface> surfaces = new LinkedList<Surface>(); ! current.collectSurfaces(surfaces); ! edges.addAll(Surface.edges(surfaces)); ! } else { ! edges.addAll(current.getEdges()); ! } ! current = current.getOwner(); ! } ! } ! } else { ! if (active != Project.getInstance().world()) { ! Space empty = active.getOwner().getEmpty(); ! Collection envelope = active.getEnvelope(); ! Set spaces = new HashSet(); ! { ! Iterator iter = envelope.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! Space other; ! if (current.getFrontDomain() == active) { ! other = current.getBackDomain(); ! } else { ! other = current.getFrontDomain(); ! } ! if (other != empty) { ! spaces.add(other); ! } ! } ! } ! Set surfaces = new HashSet(); ! surfaces.addAll(envelope); ! { ! Iterator iter = spaces.iterator(); ! while (iter.hasNext()) { ! Space current = (Space) iter.next(); ! surfaces.addAll(current.getEnvelope()); ! } ! } ! { ! Set holes = new HashSet(); ! Iterator iter = surfaces.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! holes.addAll(current.getHoles()); ! } ! surfaces.addAll(holes); ! } ! edges.addAll(Surface.edges(surfaces)); ! } ! { ! Iterator iter = Selection.primary().iterator(); ! while (iter.hasNext()) { ! Geometric current = (Geometric) iter.next(); ! if (current instanceof Space) { ! Space space = (Space) current; ! edges.addAll(space.getEdges()); ! } } } } --- 843,857 ---- public Collection collectSupportingEdges(Space active) { Collection edges = new HashSet(); ! if (active != Project.getInstance().world()) { ! Space current = active; ! while (current != null) { ! if (current.isUnion()) { ! Collection<Surface> surfaces = new LinkedList<Surface>(); ! current.collectSurfaces(surfaces); ! edges.addAll(Surface.edges(surfaces)); ! } else { ! edges.addAll(current.getEdges()); } + current = current.getOwner(); } } *************** *** 925,931 **** /** * Draw the model normally - * @param gld The GLDrawable */ ! private void drawNormalMode(GLAutoDrawable gld) { Collection selection = Selection.primary(); gl.glEnable(GL.GL_DEPTH_TEST); --- 861,866 ---- /** * Draw the model normally */ ! private void drawNormalMode() { Collection selection = Selection.primary(); gl.glEnable(GL.GL_DEPTH_TEST); *************** *** 968,982 **** } ! if (DRAW_ALL) { ! drawSpace(Project.getInstance().world(), gld, true); ! } else { ! Space active = Project.getInstance().getActiveSpace(); ! drawSpace(active, gld, false); ! Object o; ! } //Draw edges if (doDrawEdges) { ! drawEdges(gld); } --- 903,913 ---- } ! drawSpace(Project.getInstance().world(), true); //Draw edges if (doDrawEdges) { ! disableClipplanes(); ! drawGeneralEdges(tempEdges, false); ! enableClipplanes(); } *************** *** 1025,1041 **** while (it.hasNext()) { GlObject glo = (GlObject) it.next(); ! glo.draw(gld); } } drawConstructorPlanes(); - - gl.glDisable(GL.GL_DEPTH_TEST); - { - Iterator it = onTopEntities.iterator(); - while (it.hasNext()) { - drawGeometric((Geometric) it.next()); - } - } } --- 956,964 ---- while (it.hasNext()) { GlObject glo = (GlObject) it.next(); ! glo.draw(gl); } } drawConstructorPlanes(); } *************** *** 1136,1144 **** /** * Draw space - * @param gld GLDrawable * @param space The Space * @param dodge dodge the colors */ ! private void drawSpace(Space space, GLAutoDrawable gld, boolean dodge) { if (space == Project.getInstance().getActiveSpace()) { dodge = false; --- 1059,1066 ---- /** * Draw space * @param space The Space * @param dodge dodge the colors */ ! private void drawSpace(Space space, boolean dodge) { if (space == Project.getInstance().getActiveSpace()) { dodge = false; *************** *** 1155,1162 **** gl.glCullFace(GL.GL_BACK); ! drawSurfaces(gld, surfaces, FRONT, dodge); gl.glCullFace(GL.GL_FRONT); ! drawSurfaces(gld, surfaces, BACK, dodge); gl.glDisable(GL.GL_CULL_FACE); --- 1077,1084 ---- gl.glCullFace(GL.GL_BACK); ! drawSurfaces(surfaces, FRONT, dodge); gl.glCullFace(GL.GL_FRONT); ! drawSurfaces(surfaces, BACK, dodge); gl.glDisable(GL.GL_CULL_FACE); *************** *** 1173,1177 **** gl.glPolygonOffset(1.0f, 1.0f); gl.glColor3fv(SURFACE_COLOR, 0); ! drawSurfaces(gld, surfaces, BOTH, dodge); gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); break; --- 1095,1099 ---- gl.glPolygonOffset(1.0f, 1.0f); gl.glColor3fv(SURFACE_COLOR, 0); ! drawSurfaces(surfaces, BOTH, dodge); gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); break; *************** *** 1179,1183 **** } if (doDrawEdges) { ! drawGeneralEdges(gld, space.getEdges(), dodge); } Collection elements = space.getElements(); --- 1101,1105 ---- } if (doDrawEdges) { ! drawGeneralEdges(space.getEdges(), dodge); } Collection elements = space.getElements(); *************** *** 1185,1189 **** while (iter.hasNext()) { Space current = (Space) iter.next(); ! drawSpace(current, gld, dodge); } gl.glPopMatrix(); --- 1107,1111 ---- while (iter.hasNext()) { Space current = (Space) iter.next(); ! drawSpace(current, dodge); } gl.glPopMatrix(); *************** *** 1251,1272 **** /** - * Draw all edges - * @param gld The GLDrawable - */ - private void drawEdges(GLAutoDrawable gld) { - disableClipplanes(); - drawGeneralEdges(gld, tempEdges, false); - enableClipplanes(); - - if (!DRAW_ALL) { - Space active = Project.getInstance().getActiveSpace(); - if (active != Project.getInstance().world()) { - Collection edges = collectSupportingEdges(active); - drawConstructionEdges(gld, edges); - } - } - } - - /** * Draw constructor planes. * --- 1173,1176 ---- *************** *** 1588,1596 **** /** * FIXME edge-drawing - * @param gld The GLDrawable * @param edges The edges * @param dodge dodge colors */ ! public void drawGeneralEdges(GLAutoDrawable gld, Collection edges, boolean dodge) { gl.glLineWidth(1.0f); gl.glColor3fv(lineColor, 0); --- 1492,1499 ---- /** * FIXME edge-drawing * @param edges The edges * @param dodge dodge colors */ ! public void drawGeneralEdges(Collection edges, boolean dodge) { gl.glLineWidth(1.0f); gl.glColor3fv(lineColor, 0); *************** *** 1651,1661 **** /** * Draw the surfaces - * @param gld The GLDrawable * @param surfaces The surfaces to draw * @param side The side of the Surface to draw * @param dodge dodge colors */ ! private void drawSurfaces(GLAutoDrawable gld, Collection surfaces, int side, boolean dodge) { ! GL gl = gld.getGL(); Iterator it = surfaces.iterator(); while (it.hasNext()) { --- 1554,1562 ---- /** * Draw the surfaces * @param surfaces The surfaces to draw * @param side The side of the Surface to draw * @param dodge dodge colors */ ! private void drawSurfaces(Collection surfaces, int side, boolean dodge) { Iterator it = surfaces.iterator(); while (it.hasNext()) { *************** *** 2023,2029 **** /** * Draws the objects for selection - * @param gld The GLDrawable */ ! private void drawSelectionMode(GLAutoDrawable gld) { Space space = Project.getInstance().getActiveSpace(); Collection surfaces = new LinkedList(); --- 1924,1929 ---- /** * Draws the objects for selection */ ! private void drawSelectionMode() { Space space = Project.getInstance().getActiveSpace(); Collection surfaces = new LinkedList(); *************** *** 2058,2063 **** selectionMode = OBJECTS; } ! ! gl = gld.getGL(); initNames(gl); --- 1958,1962 ---- selectionMode = OBJECTS; } ! initNames(gl); *************** *** 2141,2145 **** GlObject glo = (GlObject) it.next(); pushName(gl, glo); ! glo.draw(gld); popName(gl); } --- 2040,2044 ---- GlObject glo = (GlObject) it.next(); pushName(gl, glo); ! glo.draw(gl); popName(gl); } *************** *** 3105,3116 **** /** - * Adds a temporary edge to be drawn on top. - * @param e the edge - */ - public void addTempEdgeOnTop(Edge e) { - onTopEntities.add(e); - } - - /** * Removes a temporary edge * @param e the edge to remove --- 3004,3007 ---- *************** *** 3129,3140 **** /** - * Adds a temporary vertex to be drawn on top. - * @param v the vertex - */ - public void addTempVertexOnTop(Vertex v) { - onTopEntities.add(v); - } - - /** * Removes a temporary vertex * @param v the vertex to remove --- 3020,3023 ---- *************** *** 3144,3155 **** } - /** - * Removes a temporary Entity that is on top - * @param e the entity to remove - */ - public void removeEntityOnTop(Entity e) { - onTopEntities.remove(e); - } - /** * Puts a new color in the color map for an entity --- 3027,3030 ---- |