[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.287, 1.288
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-05-25 12:00:48
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24047/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.287 retrieving revision 1.288 diff -C2 -d -r1.287 -r1.288 *** View.java 21 Apr 2009 10:21:18 -0000 1.287 --- View.java 25 May 2009 12:00:40 -0000 1.288 *************** *** 62,70 **** /** The logger */ private static Logger log = Logger.getLogger(View.class); ! private static final boolean DISP = false; ! private boolean enabled; ! private GLTesselator tesselator; --- 62,70 ---- /** The logger */ private static Logger log = Logger.getLogger(View.class); ! private static final boolean DISP = false; ! private boolean enabled; ! private GLTesselator tesselator; *************** *** 110,114 **** /** Used for selected objects */ public static final float[] SELECTED_COLOR = new float[] {0.7f, 0.3f, 0.1f}; ! /** Used for clipping planes */ --- 110,114 ---- /** Used for selected objects */ public static final float[] SELECTED_COLOR = new float[] {0.7f, 0.3f, 0.1f}; ! /** Used for clipping planes */ *************** *** 132,136 **** /** Used for vertices on edges */ public static final float[] EDGE_ON_COLOR = new float[] {0.2f, 0.3f, 0.6f}; ! /** Used for testing */ public static final float[] UGLY_COLOR = new float[] {0.0f, 1.0f, 1.0f}; --- 132,136 ---- /** Used for vertices on edges */ public static final float[] EDGE_ON_COLOR = new float[] {0.2f, 0.3f, 0.6f}; ! /** Used for testing */ public static final float[] UGLY_COLOR = new float[] {0.0f, 1.0f, 1.0f}; *************** *** 170,175 **** /** The last touched surface */ protected static Surface lastSurface; ! ! /** Flag for the lighted style of view (this is the default) */ --- 170,175 ---- /** The last touched surface */ protected static Surface lastSurface; ! ! /** Flag for the lighted style of view (this is the default) */ *************** *** 265,287 **** /** The y-coordinate of last selection */ protected double y; ! /** * Keeps track of the current EdgeAttributes. */ private EdgeAttributes currentEdgeAttributes; ! /** * Keeps track of the current stippling */ private boolean stipple; ! /** grid enabled */ private boolean gridEnabled; ! private boolean edgesEnabled; ! private boolean showTransparent = true; ! /** What type of entities should be selected */ private int selectionMode; --- 265,287 ---- /** The y-coordinate of last selection */ protected double y; ! /** * Keeps track of the current EdgeAttributes. */ private EdgeAttributes currentEdgeAttributes; ! /** * Keeps track of the current stippling */ private boolean stipple; ! /** grid enabled */ private boolean gridEnabled; ! private boolean edgesEnabled; ! private boolean showTransparent = true; ! /** What type of entities should be selected */ private int selectionMode; *************** *** 325,329 **** /** Maps entities to a color */ private Map<Geometric, float[]> colorMap; ! /** Maps edges to a set of attributes */ private Map<Edge, EdgeAttributes> edgeStyleMap; --- 325,329 ---- /** Maps entities to a color */ private Map<Geometric, float[]> colorMap; ! /** Maps edges to a set of attributes */ private Map<Edge, EdgeAttributes> edgeStyleMap; *************** *** 334,338 **** */ private Set<GlObject> glObjects3D; ! /** * A list of Widget objects displayed on top of the 3d model. --- 334,338 ---- */ private Set<GlObject> glObjects3D; ! /** * A list of Widget objects displayed on top of the 3d model. *************** *** 342,346 **** /** Max number of clipplanes */ private int maxClippingPlanes; ! private HashMap<Surface, Integer> displayLists = new HashMap<Surface, Integer>(); --- 342,346 ---- /** Max number of clipplanes */ private int maxClippingPlanes; ! private HashMap<Surface, Integer> displayLists = new HashMap<Surface, Integer>(); *************** *** 422,426 **** } } ! /** * The constructor --- 422,426 ---- } } ! /** * The constructor *************** *** 428,431 **** --- 428,432 ---- */ public View(Editor editor) { + this.editor = editor; bgColor = BACKGROUND_COLOR; *************** *** 454,458 **** return lastSurface; } ! /** * --- 455,459 ---- return lastSurface; } ! /** * *************** *** 472,484 **** log.debug("[init]"); } ! //ENABLE FOR DEBUG gld.setGL(new DebugGL(gld.getGL())); glu = new GLU(); ! tesselator = new GLTesselator(glu); Project.getInstance().setTesselator(tesselator); ! ! int[] maxplanes = new int[1]; gl.glGetIntegerv(GL.GL_MAX_CLIP_PLANES, maxplanes, 0); --- 473,485 ---- log.debug("[init]"); } ! //ENABLE FOR DEBUG gld.setGL(new DebugGL(gld.getGL())); glu = new GLU(); ! tesselator = new GLTesselator(glu); Project.getInstance().setTesselator(tesselator); ! ! int[] maxplanes = new int[1]; gl.glGetIntegerv(GL.GL_MAX_CLIP_PLANES, maxplanes, 0); *************** *** 520,524 **** gridEnabled = true; } ! /** * Disable grid --- 521,525 ---- gridEnabled = true; } ! /** * Disable grid *************** *** 527,531 **** gridEnabled = false; } ! /** * Enable edges --- 528,532 ---- gridEnabled = false; } ! /** * Enable edges *************** *** 534,538 **** edgesEnabled = true; } ! /** * Disable edges --- 535,539 ---- edgesEnabled = true; } ! /** * Disable edges *************** *** 541,545 **** edgesEnabled = false; } ! /** * --- 542,546 ---- edgesEnabled = false; } ! /** * *************** *** 549,553 **** showTransparent = true; } ! /** * --- 550,554 ---- showTransparent = true; } ! /** * *************** *** 557,561 **** showTransparent = false; } ! /** * --- 558,562 ---- showTransparent = false; } ! /** * *************** *** 567,571 **** Container front = surface.getFrontDomain(); Container back = surface.getBackDomain(); ! Container owner = surface.getOwner(); Collection<Surface> holes = new LinkedList(surface.getHoles()); --- 568,572 ---- Container front = surface.getFrontDomain(); Container back = surface.getBackDomain(); ! Container owner = surface.getOwner(); Collection<Surface> holes = new LinkedList(surface.getHoles()); *************** *** 574,578 **** } surface.erase(); ! for (Surface current : surfaces) { Surface inserted = owner.insert(current); --- 575,579 ---- } surface.erase(); ! for (Surface current : surfaces) { Surface inserted = owner.insert(current); *************** *** 589,593 **** Project.getInstance().changed(Project.getInstance()); } ! /** * Apply edge attributes --- 590,594 ---- Project.getInstance().changed(Project.getInstance()); } ! /** * Apply edge attributes *************** *** 614,623 **** } } ! private void draw(GLAutoDrawable gld) { gl = gld.getGL(); glu = new GLU(); ! // remove old displayLists for (Integer i : deletedLists) { --- 615,624 ---- } } ! private void draw(GLAutoDrawable gld) { gl = gld.getGL(); glu = new GLU(); ! // remove old displayLists for (Integer i : deletedLists) { *************** *** 625,634 **** } deletedLists.clear(); ! 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) { try { --- 626,635 ---- } deletedLists.clear(); ! 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) { try { *************** *** 643,656 **** } } ! initCamera(); gl.glPushMatrix(); picking = 0; ! enableClipplanes(); ! gl.glColor3fv(lineColor, 0); gl.glLineWidth(1.0f); ! Display.selecting(hitdetection); Display.construction(gridEnabled); --- 644,657 ---- } } ! initCamera(); gl.glPushMatrix(); picking = 0; ! enableClipplanes(); ! gl.glColor3fv(lineColor, 0); gl.glLineWidth(1.0f); ! Display.selecting(hitdetection); Display.construction(gridEnabled); *************** *** 678,687 **** extras.addAll(tempVertices); Display.extras(extras); ! Collection<ClippingPlane> clips = Project.getInstance().getCurrentCamera().getClipplanes(); ! Display.clips(clips); ! Display.glos(glObjects3D); try { --- 679,688 ---- extras.addAll(tempVertices); Display.extras(extras); ! Collection<ClippingPlane> clips = Project.getInstance().getCurrentCamera().getClipplanes(); ! Display.clips(clips); ! Display.glos(glObjects3D); try { *************** *** 693,704 **** Display.intersecting(false); ! gl.glEnable(GL.GL_DEPTH_TEST); ! disableClipplanes(); ! //draw the clipping planes ! ! for (ClippingPlane current : clips) { Collection selection = Selection.primary(); --- 694,705 ---- Display.intersecting(false); ! gl.glEnable(GL.GL_DEPTH_TEST); ! disableClipplanes(); ! //draw the clipping planes ! ! for (ClippingPlane current : clips) { Collection selection = Selection.primary(); *************** *** 721,726 **** } } ! ! gl.glMatrixMode(GL.GL_PROJECTION); gl.glDisable(GL.GL_DEPTH_TEST); --- 722,727 ---- } } ! ! gl.glMatrixMode(GL.GL_PROJECTION); gl.glDisable(GL.GL_DEPTH_TEST); *************** *** 735,743 **** gl.glPushMatrix(); gl.glLoadIdentity(); ! ! ! Geometric candidate = null; ! Collection<Geometric> selection = Selection.primary(); if (!selection.isEmpty()) { --- 736,744 ---- gl.glPushMatrix(); gl.glLoadIdentity(); ! ! ! Geometric candidate = null; ! Collection<Geometric> selection = Selection.primary(); if (!selection.isEmpty()) { *************** *** 751,769 **** } } ! //drawObscureBox(); ! drawSpacePath(hitdetection); ! for (Widget widget : widgets) { widget.display(gl, glu, hitdetection); } ! gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPopMatrix(); ! ! gl.glPopMatrix(); if (hitdetection) { --- 752,770 ---- } } ! //drawObscureBox(); ! drawSpacePath(hitdetection); ! for (Widget widget : widgets) { widget.display(gl, glu, hitdetection); } ! gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPopMatrix(); ! ! gl.glPopMatrix(); if (hitdetection) { *************** *** 778,782 **** } } ! /** * The function responsible for drawing at each update --- 779,783 ---- } } ! /** * The function responsible for drawing at each update *************** *** 794,798 **** } } ! /** * disable all clipping planes --- 795,799 ---- } } ! /** * disable all clipping planes *************** *** 885,892 **** } } ! private void drawObscureBox(double x, double y, double w, double h, float l, float alpha) { ! gl.glColor4f(l, l, l, alpha); gl.glPushMatrix(); --- 886,893 ---- } } ! private void drawObscureBox(double x, double y, double w, double h, float l, float alpha) { ! gl.glColor4f(l, l, l, alpha); gl.glPushMatrix(); *************** *** 905,909 **** gl.glPopMatrix(); } ! private void drawBox(double x, double y, double w, double h) { --- 906,910 ---- gl.glPopMatrix(); } ! private void drawBox(double x, double y, double w, double h) { *************** *** 915,920 **** gl.glEnd(); } ! ! private void drawObscureBox() { double w = width / 10; --- 916,921 ---- gl.glEnd(); } ! ! private void drawObscureBox() { double w = width / 10; *************** *** 930,934 **** } } ! private void drawPath(LinkedList<Container> path, boolean selecting) { LinkedList<Label> labels = new LinkedList<Label>(); --- 931,935 ---- } } ! private void drawPath(LinkedList<Container> path, boolean selecting) { LinkedList<Label> labels = new LinkedList<Label>(); *************** *** 938,944 **** labels.add(new Label("/")); } ! Selection selection = Selection.primary(); ! if (selection.size() == 1) { Geometric geometric = selection.iterator().next(); --- 939,945 ---- labels.add(new Label("/")); } ! Selection selection = Selection.primary(); ! if (selection.size() == 1) { Geometric geometric = selection.iterator().next(); *************** *** 949,953 **** } } ! { double w = 0; --- 950,954 ---- } } ! { double w = 0; *************** *** 961,965 **** drawBox(x, y, w, h); } ! int x = 5; int y = (int) height - 15; --- 962,966 ---- drawBox(x, y, w, h); } ! int x = 5; int y = (int) height - 15; *************** *** 969,973 **** x += label.width() + 6; } ! gl.glColor3f(1, 1, 1); gl.glPushMatrix(); --- 970,974 ---- x += label.width() + 6; } ! gl.glColor3f(1, 1, 1); gl.glPushMatrix(); *************** *** 984,988 **** gl.glPopMatrix(); } ! /** * Draw the space path --- 985,989 ---- gl.glPopMatrix(); } ! /** * Draw the space path *************** *** 1070,1074 **** frontLabelSelect = false; } ! /** * Put labels on a Surface --- 1071,1075 ---- frontLabelSelect = false; } ! /** * Put labels on a Surface *************** *** 1104,1108 **** Vertex backTextAnchor; Vertex mid; ! if (!facingFront(surface)) { frontTextAnchor = new Vertex(front.getX(), --- 1105,1109 ---- Vertex backTextAnchor; Vertex mid; ! if (!facingFront(surface)) { frontTextAnchor = new Vertex(front.getX(), *************** *** 1120,1141 **** front.getY() + 4, front.getZ()); } ! double distance = mid.getX() - front.getX(); ! mid.setX(mid.getX() - distance); frontTextAnchor.setX(frontTextAnchor.getX() - distance); backTextAnchor.setX(backTextAnchor.getX() - distance); ! Display.paint(mid, new float[]{0, 0, 0}, 5); 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"); } else { double fcb = 0; --- 1121,1143 ---- front.getY() + 4, front.getZ()); } ! double distance = mid.getX() - front.getX(); ! mid.setX(mid.getX() - distance); frontTextAnchor.setX(frontTextAnchor.getX() - distance); backTextAnchor.setX(backTextAnchor.getX() - distance); ! Display.paint(mid, new float[]{0, 0, 0}, 5); + 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"); } else { double fcb = 0; *************** *** 1152,1156 **** } drawString(frontTextAnchor.getX(), frontTextAnchor.getY(), ! frontTextAnchor.getZ(), frontName); double bcb = 0; if (backLabelSelect) { --- 1154,1158 ---- } drawString(frontTextAnchor.getX(), frontTextAnchor.getY(), ! frontTextAnchor.getZ(), frontName); double bcb = 0; if (backLabelSelect) { *************** *** 1168,1175 **** drawString(backTextAnchor.getX(), backTextAnchor.getY(), ! backTextAnchor.getZ(), backName); } } ! /** * Put labels on a Surface --- 1170,1177 ---- drawString(backTextAnchor.getX(), backTextAnchor.getY(), ! backTextAnchor.getZ(), backName); } } ! /** * Put labels on a Surface *************** *** 1206,1218 **** if (!facingFront(surface)) { ! 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()); } --- 1208,1220 ---- if (!facingFront(surface)) { ! 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()); } *************** *** 1220,1229 **** //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"); --- 1222,1229 ---- //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"); *************** *** 1373,1377 **** objectTable = null; } ! /** * Process Selection --- 1373,1377 ---- objectTable = null; } ! /** * Process Selection *************** *** 1412,1416 **** Object object = null; Collection<Edge> edges = new HashSet<Edge>(); ! for (int i = 0; i < hits; i++) { names = selectBuffer.get(bufferOffset); --- 1412,1416 ---- Object object = null; Collection<Edge> edges = new HashSet<Edge>(); ! for (int i = 0; i < hits; i++) { names = selectBuffer.get(bufferOffset); *************** *** 1726,1734 **** public Object getObjectAtPoint(double x, double y, Collection unWantedEntities, int mode, Plane xy) { ! if (!enabled) { return null; } ! this.x = x; this.y = y; --- 1726,1734 ---- public Object getObjectAtPoint(double x, double y, Collection unWantedEntities, int mode, Plane xy) { ! if (!enabled) { return null; } ! this.x = x; this.y = y; *************** *** 1743,1747 **** Object object = processSelect(unWantedEntities, mode == INTERSECTIONS, xy); clearNames(); ! if (mode == View.OBJECTS) { if (object instanceof Geometric) { --- 1743,1747 ---- Object object = processSelect(unWantedEntities, mode == INTERSECTIONS, xy); clearNames(); ! if (mode == View.OBJECTS) { if (object instanceof Geometric) { *************** *** 1993,1997 **** colorMap.remove(e); } ! /** * Sets a new style for a given edge --- 1993,1997 ---- colorMap.remove(e); } ! /** * Sets a new style for a given edge *************** *** 2109,2113 **** return glObjects3D.remove(glo); } ! /** * remove a whole set of GLObject --- 2109,2113 ---- return glObjects3D.remove(glo); } ! /** * remove a whole set of GLObject *************** *** 2133,2137 **** this.glObjects3D.add(glo); } ! /** * --- 2133,2137 ---- this.glObjects3D.add(glo); } ! /** * *************** *** 2141,2145 **** widgets.add(widget); } ! /** * --- 2141,2145 ---- widgets.add(widget); } ! /** * |