[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.267, 1.268 Display.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-12-07 14:38:50
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4879/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Display.java Log Message: changed instance displaying and selection Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** Display.java 7 Dec 2007 11:00:15 -0000 1.63 --- Display.java 7 Dec 2007 14:38:53 -0000 1.64 *************** *** 849,852 **** --- 849,855 ---- private static void drawInstance(Space space, boolean inside) { gl.glPushMatrix(); + if (space == active) { + paint(space.getInstanceAnchor()); + } translateToCoordinatesystem(space); if (USEDL && inside) { *************** *** 863,884 **** } } ! boolean selActivated = false; ! Space oldActive = active; if (selecting()) { ! push(space); ! selActivated = true; ! if (space == active) { ! selecting = true; ! active = space.getProto(); } } - if (space == active) { - paint(space.getInstanceAnchor()); - } drawSpace(space.getProto(), inside || space == active); ! if (selActivated) { ! selecting = true; ! active = oldActive; ! pop(); } --- 866,893 ---- } } ! boolean activeSet = false; if (selecting()) { ! if (intersecting) { ! push(space); ! } else { ! if (space == active) { ! activeSet = true; ! active = space.getProto(); ! } else { ! push(space); ! } } } drawSpace(space.getProto(), inside || space == active); ! if (selecting()) { ! if (intersecting) { ! pop(); ! } else { ! if (activeSet) { ! active = space; ! } else { ! pop(); ! } ! } } Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.267 retrieving revision 1.268 diff -C2 -d -r1.267 -r1.268 *** View.java 3 Dec 2007 17:52:55 -0000 1.267 --- View.java 7 Dec 2007 14:38:53 -0000 1.268 *************** *** 14,17 **** --- 14,18 ---- import net.sourceforge.bprocessor.gl.model.Intersection; import net.sourceforge.bprocessor.gl.model.Label; + import net.sourceforge.bprocessor.gl.model.SelectionPath; import net.sourceforge.bprocessor.gl.model.SpaceBox; import net.sourceforge.bprocessor.gl.model.Widget; *************** *** 1238,1242 **** objectTable = null; } ! /** * Process Selection --- 1239,1243 ---- objectTable = null; } ! /** * Process Selection *************** *** 1262,1289 **** * @return Selection */ ! private Object processSelect(Collection unWantedEntities, ! boolean intersections, Plane xy) { int bufferOffset = 0; int names = 0; long zMax = 0xFFFFFFFFL; double nearestSurface = 1.0; ! Surface surface = null; ! double nearestVertex = 1.0; ! Vertex vertex = null; ! double nearestEdge = 1.0; ! Edge edge = null; ! double nearestGLO = 1.0; GlObject glo = null; - double nearest = 1.0; Object object = null; - Collection<Edge> edges = new HashSet<Edge>(); - Space instance = null; - for (int i = 0; i < hits; i++) { names = selectBuffer.get(bufferOffset); --- 1263,1282 ---- * @return Selection */ ! private Object processSelect(Collection unWantedEntities, boolean intersections, Plane xy) { int bufferOffset = 0; int names = 0; long zMax = 0xFFFFFFFFL; double nearestSurface = 1.0; ! SelectionPath surface = null; double nearestVertex = 1.0; ! SelectionPath vertex = null; double nearestEdge = 1.0; ! SelectionPath edge = null; double nearestGLO = 1.0; GlObject glo = null; double nearest = 1.0; Object object = null; Collection<Edge> edges = new HashSet<Edge>(); for (int i = 0; i < hits; i++) { names = selectBuffer.get(bufferOffset); *************** *** 1293,1314 **** double near = (double) z1 / (double) zMax; double far = (double) z2 / (double) zMax; - near = (near + far) / 2; - bufferOffset += 2; ! if (names > 1) { ! instance = (Space)getObject(selectBuffer.get(bufferOffset + names - 1)); } int id = selectBuffer.get(bufferOffset + names); - bufferOffset += names + 1; Object current = getObject(id); - if (!unWantedEntities.contains(current)) { if (current instanceof Surface) { if (near < nearestSurface) { nearestSurface = near; ! surface = (Surface) current; if (near < nearest) { object = null; --- 1286,1308 ---- double near = (double) z1 / (double) zMax; double far = (double) z2 / (double) zMax; near = (near + far) / 2; bufferOffset += 2; ! SelectionPath currentPath = new SelectionPath(); if (names > 1) { ! Space instance = (Space)getObject(selectBuffer.get(bufferOffset + names - 1)); ! if (unWantedEntities.contains(instance)) { ! continue; ! } ! currentPath.addGeometricToPath(instance); } int id = selectBuffer.get(bufferOffset + names); bufferOffset += names + 1; Object current = getObject(id); if (!unWantedEntities.contains(current)) { if (current instanceof Surface) { if (near < nearestSurface) { nearestSurface = near; ! currentPath.addGeometricToPath((Surface) current); ! surface = currentPath; if (near < nearest) { object = null; *************** *** 1318,1322 **** if (near < nearestVertex) { nearestVertex = near; ! vertex = (Vertex) current; if (near < nearest) { object = null; --- 1312,1317 ---- if (near < nearestVertex) { nearestVertex = near; ! currentPath.addGeometricToPath((Vertex) current); ! vertex = currentPath; if (near < nearest) { object = null; *************** *** 1327,1331 **** if (near < nearestEdge) { nearestEdge = near; ! edge = (Edge) current; if (near < nearest) { object = null; --- 1322,1327 ---- if (near < nearestEdge) { nearestEdge = near; ! currentPath.addGeometricToPath((Edge)current); ! edge = currentPath; if (near < nearest) { object = null; *************** *** 1354,1358 **** } if (surface != null) { ! if (unWantedEntities.contains(surface)) { surface = null; } --- 1350,1354 ---- } if (surface != null) { ! if (unWantedEntities.contains(surface.getLastInPath())) { surface = null; } *************** *** 1360,1367 **** if (surface != null) { // Test vertex and edge against surface ! Plane plane = surface.plane(); if (vertex != null) { if (nearestSurface < nearestVertex) { ! if (plane != null && !plane.contains(vertex)) { vertex = null; } --- 1356,1363 ---- if (surface != null) { // Test vertex and edge against surface ! Plane plane = ((Surface)surface.getLastInPath()).plane(); if (vertex != null) { if (nearestSurface < nearestVertex) { ! if (plane != null && !plane.contains((Vertex)vertex.getLastInPath())) { vertex = null; } *************** *** 1370,1374 **** if (edge != null) { if (nearestSurface < nearestEdge) { ! if (plane != null && !plane.contains(edge)) { edge = null; } --- 1366,1370 ---- if (edge != null) { if (nearestSurface < nearestEdge) { ! if (plane != null && !plane.contains((Edge)edge.getLastInPath())) { edge = null; } *************** *** 1376,1384 **** } } - if (edge != null && vertex != null) { // Test edge and vertex against each other if (nearestEdge < nearestVertex) { ! if (!edge.intersects(vertex)) { vertex = null; } else { --- 1372,1379 ---- } } if (edge != null && vertex != null) { // Test edge and vertex against each other if (nearestEdge < nearestVertex) { ! if (!((Edge)edge.getLastInPath()).intersects((Vertex)vertex.getLastInPath())) { vertex = null; } else { *************** *** 1387,1409 **** } } - if (object == null && vertex == null && edge == null) { ! setLastSurface(surface); } ! ! if (lastSurface == null) { ! setLastSurface(surface); } - if (edge != null) { edges.remove(edge); ! if (edge.getStrippled()) { Iterator iter = edges.iterator(); - while (iter.hasNext()) { Edge current = (Edge) iter.next(); if (!current.getStrippled()) { ! if (edge.intersects(current.getFrom()) && edge.intersects(current.getTo())) { ! edge = current; break; } --- 1382,1419 ---- } } if (object == null && vertex == null && edge == null) { ! if (surface == null) { ! setLastSurface(null); ! } else { ! if (surface.getPathLength() > 1) { ! Space space = (Space)surface.getFirstInPath(); ! Surface theSurface = ! space.getInstanceAnchor().unTranslate((Surface)surface.getLastInPath()); ! setLastSurface(theSurface); ! } else { ! setLastSurface((Surface)surface.getLastInPath()); ! } ! } } ! if (lastSurface == null && surface != null) { ! if (surface.getPathLength() > 1) { ! Space space = (Space)surface.getFirstInPath(); ! Surface theSurface = ! space.getInstanceAnchor().unTranslate((Surface)surface.getLastInPath()); ! setLastSurface(theSurface); ! } else { ! setLastSurface((Surface)surface.getLastInPath()); ! } } if (edge != null) { edges.remove(edge); ! if (((Edge)edge.getLastInPath()).getStrippled()) { Iterator iter = edges.iterator(); while (iter.hasNext()) { Edge current = (Edge) iter.next(); if (!current.getStrippled()) { ! if (((Edge)edge.getLastInPath()).intersects(current.getFrom()) && ! ((Edge)edge.getLastInPath()).intersects(current.getTo())) { ! edge = new SelectionPath(current); break; } *************** *** 1412,1420 **** } } ! ! if (glo != null && object == null && ! nearestGLO < nearestVertex && ! nearestGLO < nearestEdge && ! nearestGLO < nearestSurface) { surface = null; edge = null; --- 1422,1427 ---- } } ! if (glo != null && object == null && nearestGLO < nearestVertex && ! nearestGLO < nearestEdge && nearestGLO < nearestSurface) { surface = null; edge = null; *************** *** 1428,1444 **** ray = transformation.unProject(ray); if (vertex != null) { ! if (instance != null) { ! vertex = instance.getInstanceAnchor().unTranslate(vertex); } ! return new Intersection(vertex, Intersection.VERTEX, vertex); } else { if (glo != null) { return glo.intersection(ray); } else if (edge != null) { ! if (instance != null) { ! edge = instance.getInstanceAnchor().unTranslate(edge); } ! if (!edge.getStrippled()) { ! Vertex m = edge.getFrom().add(edge.getTo()); m.scaleInPlace(0.5); Vertex projected = transformation.project(m); --- 1435,1455 ---- ray = transformation.unProject(ray); if (vertex != null) { ! Vertex intersection = (Vertex)vertex.getLastInPath(); ! if (vertex.getPathLength() > 1) { ! Space instance = (Space)vertex.getFirstInPath(); ! Vertex cur = (Vertex)vertex.getLastInPath(); ! intersection = instance.getInstanceAnchor().unTranslate(cur); } ! return new Intersection(intersection, Intersection.VERTEX, intersection); } else { if (glo != null) { return glo.intersection(ray); } else if (edge != null) { ! Edge current = (Edge)edge.getLastInPath(); ! if (edge.getPathLength() > 1) { ! current = ((Space)edge.getFirstInPath()).getInstanceAnchor().unTranslate(current); } ! if (!current.getStrippled()) { ! Vertex m = current.getFrom().add(current.getTo()); m.scaleInPlace(0.5); Vertex projected = transformation.project(m); *************** *** 1447,1459 **** double distance = Math.sqrt(dx * dx + dy * dy); if (distance < 5) { ! return new Intersection(m, Intersection.EDGE_MIDPOINT, edge); } } ! ! Edge e1 = edge; Vertex v1 = e1.getTo().minus(e1.getFrom()); - Iterator iter = edges.iterator(); - while (iter.hasNext()) { Edge e2 = (Edge) iter.next(); --- 1458,1467 ---- double distance = Math.sqrt(dx * dx + dy * dy); if (distance < 5) { ! return new Intersection(m, Intersection.EDGE_MIDPOINT, current); } } ! Edge e1 = current; Vertex v1 = e1.getTo().minus(e1.getFrom()); Iterator iter = edges.iterator(); while (iter.hasNext()) { Edge e2 = (Edge) iter.next(); *************** *** 1470,1474 **** double distance = Math.sqrt(dx * dx + dy * dy); if (distance < 5) { ! return new Intersection(i, Intersection.EDGE_INTERSECTION, edge); } } --- 1478,1482 ---- double distance = Math.sqrt(dx * dx + dy * dy); if (distance < 5) { ! return new Intersection(i, Intersection.EDGE_INTERSECTION, current); } } *************** *** 1476,1490 **** } } - - - { if (lastSurface != null) { - if (instance != null) { - lastSurface = instance.getInstanceAnchor().unTranslate(lastSurface); - } if (!unWantedEntities.contains(lastSurface)) { Plane plane = lastSurface.plane(); ! Vertex intersection = plane.intersection(edge); if (intersection != null) { Vertex projected = transformation.project(intersection); --- 1484,1492 ---- } } { if (lastSurface != null) { if (!unWantedEntities.contains(lastSurface)) { Plane plane = lastSurface.plane(); ! Vertex intersection = plane.intersection(current); if (intersection != null) { Vertex projected = transformation.project(intersection); *************** *** 1500,1515 **** } } - { ! Edge intersect = edge.intersection(ray); Vertex intersection = intersect.getFrom(); ! return new Intersection(intersection, Intersection.EDGE, edge); } } else { if (surface != null) { ! if (instance != null) { ! surface = instance.getInstanceAnchor().unTranslate(surface); } ! Plane plane = surface.plane(); for (Edge current : (Collection<Edge>) edges) { Vertex intersection = plane.intersection(current); --- 1502,1518 ---- } } { ! Edge intersect = current.intersection(ray); Vertex intersection = intersect.getFrom(); ! return new Intersection(intersection, Intersection.EDGE, current); } } else { if (surface != null) { ! Surface theSurface = (Surface)surface.getLastInPath(); ! if (surface.getPathLength() > 1) { ! Space instance = (Space)surface.getFirstInPath(); ! theSurface = instance.getInstanceAnchor().unTranslate(theSurface); } ! Plane plane = theSurface.plane(); for (Edge current : (Collection<Edge>) edges) { Vertex intersection = plane.intersection(current); *************** *** 1521,1530 **** if (distance < 5) { return new Intersection(intersection, ! Intersection.SURFACE_INTERSECTION, surface); } } } Vertex intersection = plane.intersection(ray); ! return new Intersection(intersection, Intersection.SURFACE, surface); } else if (object instanceof ClippingPlane) { // find out what is intersected --- 1524,1533 ---- if (distance < 5) { return new Intersection(intersection, ! Intersection.SURFACE_INTERSECTION, theSurface); } } } Vertex intersection = plane.intersection(ray); ! return new Intersection(intersection, Intersection.SURFACE, theSurface); } else if (object instanceof ClippingPlane) { // find out what is intersected *************** *** 1543,1556 **** } } else { ! if (instance != null && instance != Project.getInstance().getActiveSpace()) { ! return instance; ! } else if (object != null) { return object; } else if (vertex != null) { ! return vertex; } else if (edge != null) { ! return edge; } else if (surface != null) { ! return surface; } else if (glo != null) { return glo; --- 1546,1557 ---- } } else { ! if (object != null) { return object; } else if (vertex != null) { ! return vertex.getFirstInPath(); } else if (edge != null) { ! return edge.getFirstInPath(); } else if (surface != null) { ! return surface.getFirstInPath(); } else if (glo != null) { return glo; *************** *** 1560,1565 **** } - - /** * Gets Entity under a point. For use in selection. --- 1561,1564 ---- *************** *** 1623,1628 **** * @return All geometry in the selection */ ! private List getAllGeometryInSelection() { ! List selection = new ArrayList(); int bufferOffset = 0; int names = 0; --- 1622,1627 ---- * @return All geometry in the selection */ ! private Set getAllGeometryInSelection() { ! Set selection = new HashSet(); int bufferOffset = 0; int names = 0; *************** *** 1649,1653 **** * @return The objects in the area */ ! public List getObjectInArea(double x1, double y1, double x2, double y2) { double x = (x1 - x2); double y = (y1 - y2); --- 1648,1652 ---- * @return The objects in the area */ ! public Set getObjectInArea(double x1, double y1, double x2, double y2) { double x = (x1 - x2); double y = (y1 - y2); *************** *** 1665,1669 **** selectionLength = 2056; editor.repaint(true); ! List selection = getAllGeometryInSelection(); selectionLength = lengthTemp; //restore default selection box --- 1664,1668 ---- selectionLength = 2056; editor.repaint(true); ! Set selection = getAllGeometryInSelection(); selectionLength = lengthTemp; //restore default selection box |