[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java,1.68,1.69
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-03-06 06:51:56
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17327/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: getObjectAtPoint can now find edge-intersections and also checks to see if the intersections is close to the mouse Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** View.java 3 Mar 2006 12:13:34 -0000 1.68 --- View.java 6 Mar 2006 06:51:52 -0000 1.69 *************** *** 451,456 **** glu = gld.getGLU(); gl.glViewport(0, 0, (int)width, (int)height); - View.height = height; - View.width = width; if (picking > 0) { selectBuffer = BufferUtils.newIntBuffer(selectionLength); --- 451,454 ---- *************** *** 1743,1749 **** * Process Selection * @param unWantedEntities Entities to be ignored * @return Selection */ ! private List processSelect(Collection unWantedEntities) { int bufferOffset = 0; int names = 0; --- 1741,1748 ---- * Process Selection * @param unWantedEntities Entities to be ignored + * @param intersections Are intersections wanted * @return Selection */ ! private List processSelect(Collection unWantedEntities, boolean intersections) { int bufferOffset = 0; int names = 0; *************** *** 1861,1867 **** } else { if (edge != null) { ! result.add(edge); ! edges.remove(edge); ! result.addAll(edges); } else { if (surface != null) { --- 1860,1903 ---- } else { if (edge != null) { ! if (intersections) { ! Vertex intersection = null; ! Transformation transformation = this.transformation(); ! ! Edge e1 = edge; ! Vertex v1 = e1.getTo().minus(e1.getFrom()); ! edges.remove(edge); ! Iterator iter = edges.iterator(); ! ! while (iter.hasNext()) { ! Edge e2 = (Edge) iter.next(); ! Vertex v2 = e2.getTo().minus(e2.getFrom()); ! Vertex cross = v1.cross(v2); ! if (!cross.isZero()) { ! Edge intersect = e1.intersection(e2); ! if (intersect != null) { ! if (intersect.getLength() < 0.0000001) { ! intersection = intersect.getFrom(); ! } ! } ! } ! } ! if (intersection != null) { ! Vertex projected = transformation.project(intersection); ! double dx = x - projected.getX(); ! double dy = (height - y) - projected.getY(); ! double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 6) { ! result.add(intersection); ! } else { ! result.add(edge); ! } ! } else { ! result.add(edge); ! } ! } else { ! result.add(edge); ! edges.remove(edge); ! result.addAll(edges); ! } } else { if (surface != null) { *************** *** 1883,1889 **** * @param y y-coordinate of the point * @param unWantedEntities the collection of unwanted entities * @return entity under the point. */ ! public List getObjectAtPoint(double x, double y, Collection unWantedEntities) { this.x = x; this.y = y; --- 1919,1927 ---- * @param y y-coordinate of the point * @param unWantedEntities the collection of unwanted entities + * @param intersections Are intersections wanted * @return entity under the point. */ ! public List getObjectAtPoint(double x, double y, ! Collection unWantedEntities, boolean intersections) { this.x = x; this.y = y; *************** *** 1893,1897 **** glv.repaint(true); ! List selection = processSelect(unWantedEntities); clearNames(); return selection; --- 1931,1935 ---- glv.repaint(true); ! List selection = processSelect(unWantedEntities, intersections); clearNames(); return selection; *************** *** 1905,1909 **** */ public List getObjectAtPoint(double x, double y) { ! return getObjectAtPoint(x, y, new HashSet()); } --- 1943,1947 ---- */ public List getObjectAtPoint(double x, double y) { ! return getObjectAtPoint(x, y, new HashSet(), false); } *************** *** 1976,1980 **** glv.repaint(true); ! List selection = processSelect(new HashSet()); clearNames(); return selection; --- 2014,2018 ---- glv.repaint(true); ! List selection = processSelect(new HashSet(), false); clearNames(); return selection; *************** *** 1995,1999 **** glv.repaint(true); ! List selection = processSelect(new HashSet()); clearNames(); return selection; --- 2033,2037 ---- glv.repaint(true); ! List selection = processSelect(new HashSet(), false); clearNames(); return selection; |