[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.278, 1.279 Display.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2008-07-22 13:19:49
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10339/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Display.java Log Message: Select labels Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** Display.java 13 Feb 2008 08:43:07 -0000 1.80 --- Display.java 22 Jul 2008 13:19:52 -0000 1.81 *************** *** 430,434 **** gl.glEnd(); } ! private static void paint(Vertex vertex, float[] color, float size) { gl.glColor3fv(color, 0); gl.glPointSize(size); --- 430,440 ---- gl.glEnd(); } ! /** ! * ! * @param vertex Vertex ! * @param color Color ! * @param size Size ! */ ! public static void paint(Vertex vertex, float[] color, float size) { gl.glColor3fv(color, 0); gl.glPointSize(size); Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.278 retrieving revision 1.279 diff -C2 -d -r1.278 -r1.279 *** View.java 21 Jul 2008 15:54:45 -0000 1.278 --- View.java 22 Jul 2008 13:19:52 -0000 1.279 *************** *** 8,11 **** --- 8,12 ---- import net.sourceforge.bprocessor.gl.Editor; + import net.sourceforge.bprocessor.gl.tool.SelectTool; import net.sourceforge.bprocessor.gl.tool.SpaceTool; import net.sourceforge.bprocessor.gl.model.EdgeAttributes; *************** *** 692,700 **** gl.glLoadIdentity(); ! if (editor.getTool() instanceof SpaceTool) { ! drawAssignmentWidget(hitdetection); } drawSpacePath(hitdetection); --- 693,714 ---- gl.glLoadIdentity(); ! ! ! Geometric candidate = null; ! ! Collection<Geometric> selection = Selection.primary(); ! if (!selection.isEmpty()) { ! candidate = selection.iterator().next(); ! if (candidate instanceof Surface) { ! if (editor.getTool() instanceof SpaceTool) { ! drawAssignmentWidget((Surface) candidate, hitdetection); ! } else if (editor.getTool() instanceof SelectTool) { ! drawSelectionWidget((Surface) candidate, hitdetection); ! } ! } } + drawSpacePath(hitdetection); *************** *** 949,952 **** --- 963,1068 ---- frontLabelSelect = false; } + + /** + * Put labels on a Surface + * @param surface The Surface + * @param clickable if true clicking the labels brings up dialog. + */ + private void drawSelectionWidget(Surface surface, boolean clickable) { + Transformation transformation = transformation(); + Vertex from = surface.center(); + Vertex front = transformation.project(from); + front.setZ(1); + Container frontDomain = surface.getFrontDomain(); + Container backDomain = surface.getBackDomain(); + String frontName; + String backName; + + if (frontDomain != null) { + frontName = frontDomain.getDisplayName(); + } else { + frontName = "None"; + } + + if (backDomain != null) { + backName = backDomain.getDisplayName(); + } else { + backName = "None"; + } + + int frontWidth = glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, frontName); + int backWidth = glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, backName); + + Vertex frontTextAnchor; + Vertex backTextAnchor; + Vertex mid; + + if (!facingFront(surface)) { + frontTextAnchor = new Vertex(front.getX(), + front.getY(), front.getZ()); + backTextAnchor = new Vertex(front.getX() + frontWidth + 9, + front.getY(), front.getZ()); + mid = new Vertex(front.getX() + frontWidth + 4.5, + front.getY() + 4, front.getZ()); + } else { + frontTextAnchor = new Vertex(front.getX() + backWidth + 9, + front.getY(), front.getZ()); + backTextAnchor = new Vertex(front.getX(), + front.getY(), front.getZ()); + mid = new Vertex(front.getX() + backWidth + 4.5, + 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; + if (frontLabelSelect) { + fcb = 0.3; + } + //draw the front domain name + if (frontDomain == null) { + gl.glColor3d(0.2 + fcb, 0.2 + fcb, 0.2 + fcb); + } else if (frontDomain.isFunctionalSpace()) { + gl.glColor3d(0.2 + fcb, 0.2 + fcb, 0.5 + fcb); + } else if (frontDomain.isConstructionSpace()) { + gl.glColor3d(0.8 + fcb, 0.2 + fcb, 0.4 + fcb); + } + drawString(frontTextAnchor.getX(), frontTextAnchor.getY(), + frontTextAnchor.getZ(), frontName); + double bcb = 0; + if (backLabelSelect) { + bcb = 0.3; + } + //draw the back domain name + + if (backDomain == null) { + gl.glColor3d(0.2 + bcb, 0.2 + bcb, 0.2 + bcb); + } else if (backDomain.isFunctionalSpace()) { + gl.glColor3d(0.2 + bcb, 0.2 + bcb, 0.5 + bcb); + } else if (backDomain.isConstructionSpace()) { + gl.glColor3d(0.8 + bcb, 0.2 + bcb, 0.4 + bcb); + } + + drawString(backTextAnchor.getX(), backTextAnchor.getY(), + backTextAnchor.getZ(), backName); + } + } + /** * Put labels on a Surface *************** *** 958,962 **** Vertex from = surface.center(); Vertex front = transformation.project(from); - //fix for making label selection work in ortho mode front.setZ(1); Container frontDomain = surface.getFrontDomain(); --- 1074,1077 ---- *************** *** 1078,1098 **** } - - /** - * Put labels on the selection - * @param clickable if true clicking the labels brings up dialog. - */ - private void drawAssignmentWidget(boolean clickable) { - Geometric candidate = null; - - Collection<Geometric> selection = Selection.primary(); - if (!selection.isEmpty()) { - candidate = selection.iterator().next(); - if (candidate instanceof Surface) { - drawAssignmentWidget((Surface) candidate, clickable); - } - } - } - /** * Draw a clippingPlane --- 1193,1196 ---- |