[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.48,1.49 View.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-10-31 07:52:53
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6571/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java View.java Log Message: PencilTool - Can align the first point to existing geometry - Can use length field when setting first point - Improved display of feedback Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** AbstractView.java 30 Oct 2005 15:55:40 -0000 1.48 --- AbstractView.java 31 Oct 2005 07:52:45 -0000 1.49 *************** *** 82,92 **** /** The Snap vertex */ ! protected static Vertex snapVertex = null; ! ! /** For clever snapping */ ! protected static double[] alignPoint = null; ! /** The alignment vertex */ ! protected static Vertex alignVertex = null; /** The target */ --- 82,89 ---- /** The Snap vertex */ ! protected static Vertex snapVertex = null; ! /** The current vertex */ ! protected static Vertex currentVertex = null; /** The target */ *************** *** 158,164 **** --- 155,165 ---- /** The transparency of surfaces */ protected static byte[] transparency = new byte[128]; + + /** The transparency of highlight */ + protected static byte[] highlight = new byte[128]; static { setTransparency(100); + setHighlight(); }; *************** *** 178,181 **** --- 179,204 ---- } } + + /** + * Set the highlight pattern + */ + public static void setHighlight() { + byte b1 = (byte) 0x88; + byte b2 = (byte) 0x22; + byte b3 = (byte) 0x00; + for (int i = 0; i < highlight.length; i++) { + int d = ((int)(i / 4)) % 4; + + if (d == 0) { + highlight[i] = b1; + } else if (d == 1) { + highlight[i] = b3; + } else if (d == 2) { + highlight[i] = b2; + } else if (d == 3) { + highlight[i] = b3; + } + } + } /** *************** *** 205,208 **** --- 228,232 ---- gl.glClearColor(0.7f, 0.7f, 0.7f, 0.0f); gl.glViewport(0, 0, (int)width, (int)height); + gl.glLineStipple(4, (short)0xAAAA); ball = glu.gluNewQuadric(); *************** *** 250,254 **** // grid and coords are always completely lit gl.glDisable(GL.GL_DEPTH_TEST); - gl.glDisable(GL.GL_LIGHTING); gl.glLineWidth(1.0f); grid(); --- 274,277 ---- *************** *** 258,271 **** coords(); - // set up lighting for the model - if (drawMode == LIGHTING_MODE) { - //gl.glShadeModel(GL.GL_SMOOTH); - gl.glEnable(GL.GL_LIGHTING); - } else { - gl.glDisable(GL.GL_LIGHTING); - } - gl.glColor3fv(STD_LINE_COLOR); ! gl.glLineWidth(3.0f); drawAll(gld); --- 281,286 ---- coords(); gl.glColor3fv(STD_LINE_COLOR); ! gl.glLineWidth(1.0f); drawAll(gld); *************** *** 324,330 **** */ public void reset() { - setAlignVertex(null); setSnapVertex(null); ! setAlignPoint(null); makeTarget(null); } --- 339,344 ---- */ public void reset() { setSnapVertex(null); ! setCurrentVertex(null); makeTarget(null); } *************** *** 545,554 **** if (mode[0] != GL.GL_SELECT) { gl.glEnable(GL.GL_DEPTH_TEST); - - if (drawMode == LIGHTING_MODE) { - gl.glEnable(GL.GL_LIGHTING); - } else { - gl.glDisable(GL.GL_LIGHTING); - } // draw selection gl.glColor3fv(SELECTED_COLOR); --- 559,562 ---- *************** *** 559,619 **** } - // draw target - gl.glColor3fv(TARGET_COLOR); - if (target != null) { - drawObject(target); - } - - gl.glDisable(GL.GL_LIGHTING); - // draw activeEdge different if it is parallel with axis - if (activeEdge != null) { - Vertex to = activeEdge.getTo(); - Vertex from = activeEdge.getFrom(); - if (from.getY() == to.getY() && from.getZ() == to.getZ()) { - gl.glColor3fv(X_AXIS_COLOR); - } else if (from.getX() == to.getX() && from.getZ() == to.getZ()) { - gl.glColor3fv(Y_AXIS_COLOR); - } else if (from.getX() == to.getX() && from.getY() == to.getY()) { - gl.glColor3fv(Z_AXIS_COLOR); - } else { - gl.glColor3fv(STD_LINE_COLOR); - } - gl.glBegin(GL.GL_LINES); - gl.glLineWidth(1.0f); - gl.glVertex3d(from.getX(), from.getY(), from.getZ()); - gl.glVertex3d(to.getX(), to.getY(), to.getZ()); - gl.glEnd(); - } - - // draw alignment line - if (alignPoint != null && alignVertex != null) { - if (alignPoint[1] == alignVertex.getY() && alignPoint[2] == alignVertex.getZ()) { - gl.glColor3fv(X_AXIS_COLOR); - } else if (alignPoint[0] == alignVertex.getX() && alignPoint[2] == alignVertex.getZ()) { - gl.glColor3fv(Y_AXIS_COLOR); - } else if (alignPoint[0] == alignVertex.getX() && alignPoint[1] == alignVertex.getY()) { - gl.glColor3fv(Z_AXIS_COLOR); - } else { - gl.glColor3fv(DRAW_COLOR); - } - gl.glBegin(GL.GL_LINES); - gl.glVertex3d(alignPoint[0], alignPoint[1], alignPoint[2]); - gl.glVertex3d(alignVertex.getX(), alignVertex.getY(), alignVertex.getZ()); - gl.glEnd(); - } - - // draw snap point if any - if (snapVertex != null) { - gl.glColor3d(0.0, 1.0, 0.0); - gl.glPointSize(5.0f); - gl.glBegin(GL.GL_POINTS); - gl.glVertex3d(snapVertex.getX(), snapVertex.getY(), snapVertex.getZ()); - gl.glEnd(); - gl.glPointSize(1.0f); - } - - - if (doDrawEdges) { gl.glLineWidth(1.0f); --- 567,572 ---- } + // Draw edges if (doDrawEdges) { gl.glLineWidth(1.0f); *************** *** 627,630 **** --- 580,601 ---- } + // Draw any Vertex that are not part of an edge + { + gl.glColor3fv(STD_LINE_COLOR); + Iterator it = vertices.iterator(); + while (it.hasNext()) { + Vertex v = (Vertex)it.next(); + if (v.getEdges().isEmpty()) { + gl.glColor3fv(STD_LINE_COLOR); + gl.glPointSize(5.0f); + gl.glBegin(GL.GL_POINTS); + gl.glVertex3d(v.getX(), v.getY(), v.getZ()); + gl.glEnd(); + gl.glPointSize(1.0f); + } + } + } + + // Fill surfaces switch (drawMode) { case LIGHTING_MODE: { *************** *** 660,663 **** --- 631,703 ---- } } + + + + + + // draw target + gl.glColor3fv(TARGET_COLOR); + if (target != null) { + drawObject(target); + } + + gl.glDisable(GL.GL_DEPTH_TEST); + Vertex to = null; + if (activeEdge != null) { + to = activeEdge.getTo(); + Vertex from = activeEdge.getFrom(); + if (from.getY() == to.getY() && from.getZ() == to.getZ()) { + gl.glColor3fv(X_AXIS_COLOR); + } else if (from.getX() == to.getX() && from.getZ() == to.getZ()) { + gl.glColor3fv(Y_AXIS_COLOR); + } else if (from.getX() == to.getX() && from.getY() == to.getY()) { + gl.glColor3fv(Z_AXIS_COLOR); + } else { + gl.glColor3fv(STD_LINE_COLOR); + } + gl.glBegin(GL.GL_LINES); + gl.glLineWidth(1.0f); + gl.glVertex3d(from.getX(), from.getY(), from.getZ()); + gl.glVertex3d(to.getX(), to.getY(), to.getZ()); + gl.glEnd(); + + } + + if (to == null) { + to = currentVertex; + } + if (snapVertex != null && to != null) { + boolean doDraw = true; + if (snapVertex.getY() == to.getY() && snapVertex.getZ() == to.getZ()) { + gl.glColor3fv(X_AXIS_COLOR); + } else if (snapVertex.getX() == to.getX() && snapVertex.getZ() == to.getZ()) { + gl.glColor3fv(Y_AXIS_COLOR); + } else if (snapVertex.getX() == to.getX() && snapVertex.getY() == to.getY()) { + gl.glColor3fv(Z_AXIS_COLOR); + } else { + doDraw = false; + } + if (doDraw) { + gl.glEnable(GL.GL_LINE_STIPPLE); + gl.glBegin(GL.GL_LINES); + gl.glLineWidth(1.0f); + gl.glVertex3d(snapVertex.getX(), snapVertex.getY(), snapVertex.getZ()); + gl.glVertex3d(to.getX(), to.getY(), to.getZ()); + gl.glEnd(); + gl.glDisable(GL.GL_LINE_STIPPLE); + } + } + + + // draw snap point if any + if (snapVertex != null) { + gl.glDisable(GL.GL_DEPTH_TEST); + gl.glColor3fv(TARGET_COLOR); + gl.glPointSize(5.0f); + gl.glBegin(GL.GL_POINTS); + gl.glVertex3d(snapVertex.getX(), snapVertex.getY(), snapVertex.getZ()); + gl.glEnd(); + gl.glPointSize(1.0f); + } } else { *************** *** 702,711 **** private void drawObject(Object o) { if (o instanceof Vertex) { Vertex v = (Vertex) o; ! gl.glPointSize(7.0f); gl.glBegin(GL.GL_POINTS); gl.glVertex3d(v.getX(), v.getY(), v.getZ()); gl.glEnd(); ! gl.glPointSize(1.0f); } else if (o instanceof Edge) { Edge e = (Edge) o; --- 742,753 ---- private void drawObject(Object o) { if (o instanceof Vertex) { + gl.glDisable(GL.GL_DEPTH_TEST); Vertex v = (Vertex) o; ! gl.glPointSize(9.0f); gl.glBegin(GL.GL_POINTS); gl.glVertex3d(v.getX(), v.getY(), v.getZ()); gl.glEnd(); ! gl.glPointSize(1.0f); ! gl.glEnable(GL.GL_DEPTH_TEST); } else if (o instanceof Edge) { Edge e = (Edge) o; *************** *** 718,722 **** } else if (o instanceof Surface) { gl.glEnable(GL.GL_POLYGON_STIPPLE); ! gl.glPolygonStipple(transparency); Surface s = (Surface) o; drawSurface(s); --- 760,764 ---- } else if (o instanceof Surface) { gl.glEnable(GL.GL_POLYGON_STIPPLE); ! gl.glPolygonStipple(highlight); Surface s = (Surface) o; drawSurface(s); *************** *** 958,993 **** /** ! * Getter for alignVertex ! * @return alignVertex ! */ ! public Vertex getAlignVertex() { ! return alignVertex; ! } ! ! /** ! * Setter for alignVertex ! * @param v The new alignVertex */ ! public void setAlignVertex(Vertex v) { ! alignVertex = v; } /** ! * Setter for alignPoint ! * @param coord The new alignPoint */ ! public void setAlignPoint(double[] coord) { ! alignPoint = coord; } /** - * Getter for alignPoint - * @return alignPoint - */ - public double[] getAlignPoint() { - return alignPoint; - } - - /** * Setter for target * @param o The object to be target --- 1000,1019 ---- /** ! * Getter for currentVertex ! * @return currentVertex */ ! public Vertex getCurrentVertex() { ! return currentVertex; } /** ! * Setter for currentVertex ! * @param v The new currentVertex */ ! public void setCurrentVertex(Vertex v) { ! currentVertex = v; } /** * Setter for target * @param o The object to be target Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** View.java 30 Oct 2005 15:55:40 -0000 1.15 --- View.java 31 Oct 2005 07:52:45 -0000 1.16 *************** *** 31,41 **** /** the color of the x axis */ ! public static final float[] X_AXIS_COLOR = new float[] {0.0f, 1.0f, 0.0f}; /** the color of the y axis */ ! public static final float[] Y_AXIS_COLOR = new float[] {1.0f, 0.0f, 0.0f}; /** the color of the z axis */ ! public static final float[] Z_AXIS_COLOR = new float[] {0.0f, 0.0f, 1.0f}; /** the std line color*/ --- 31,41 ---- /** the color of the x axis */ ! public static final float[] X_AXIS_COLOR = new float[] {0.1f, 0.8f, 0.1f}; /** the color of the y axis */ ! public static final float[] Y_AXIS_COLOR = new float[] {0.8f, 0.1f, 0.1f}; /** the color of the z axis */ ! public static final float[] Z_AXIS_COLOR = new float[] {0.1f, 0.1f, 0.8f}; /** the std line color*/ *************** *** 61,65 **** /** Used for target objects */ ! public static final float[] TARGET_COLOR = new float[] {0.1f, 0.8f, 0.1f}; /** Can be used for setting wireframe mode */ --- 61,65 ---- /** Used for target objects */ ! public static final float[] TARGET_COLOR = new float[] {0.8f, 0.8f, 0.1f}; /** Can be used for setting wireframe mode */ *************** *** 148,161 **** /** ! * Setter for alignVertex ! * @param v The new alignVertex */ ! public void setAlignVertex(Vertex v); /** ! * Getter for alignVertex ! * @return alignVertex */ ! public Vertex getAlignVertex(); /** --- 148,162 ---- /** ! * Setter for currentVertex ! * @param v The new currentVertex */ ! public void setCurrentVertex(Vertex v); /** ! * Getter for currentVertex ! * @return currentVertex */ ! public Vertex getCurrentVertex(); ! /** *************** *** 166,181 **** /** - * Setter for alignPoint - * @param coord The new alignPoint - */ - public void setAlignPoint(double[] coord); - - /** - * Getter for alignPoint - * @return alignPoint - */ - public double[] getAlignPoint(); - - /** * Get transformation for model to screen coordinates * @return The transformation --- 167,170 ---- |