[Bprocessor-commit] /gl/src/net/sourceforge/bprocessor/gl/tool RotationTool.java, 1.23, 1.24
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-01-02 17:45:45
|
Update of /cvsroot/bprocessor//gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19138/src/net/sourceforge/bprocessor/gl/tool Modified Files: RotationTool.java Log Message: made changes to the way GLObjects are selected in View and made som minor changes to the tool and added the requirement of a getPlane function that returns a plane GlObject interface, maybe a special INTERSECTION type is need later Index: RotationTool.java =================================================================== RCS file: /cvsroot/bprocessor//gl/src/net/sourceforge/bprocessor/gl/tool/RotationTool.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** RotationTool.java 18 Dec 2006 14:48:04 -0000 1.23 --- RotationTool.java 2 Jan 2007 17:45:40 -0000 1.24 *************** *** 44,48 **** /** The logger */ private static Logger log = Logger.getLogger(RotationTool.class); ! /** The vertexes to rotate */ private Set vertices = new HashSet(); --- 44,48 ---- /** The logger */ private static Logger log = Logger.getLogger(RotationTool.class); ! /** The vertexes to rotate */ private Set vertices = new HashSet(); *************** *** 63,67 **** /** The set of object not to hit */ private Set nothits = new HashSet(); ! /** * The Constructor --- 63,67 ---- /** The set of object not to hit */ private Set nothits = new HashSet(); ! /** * The Constructor *************** *** 72,76 **** super(glv, cursor); } ! /** * Invoked when a mouse button has been pressed on a component. --- 72,76 ---- super(glv, cursor); } ! /** * Invoked when a mouse button has been pressed on a component. *************** *** 87,91 **** current = findIntersection(e); if (current != null) { - updateFeedback(); if (previous != null) { //find the angle to rotate --- 87,90 ---- *************** *** 99,105 **** rotate(angle); } ! previous = onto.projection(current.vertex()); } } } --- 98,105 ---- rotate(angle); } ! previous = to; } } + updateFeedback(); } *************** *** 109,115 **** */ protected void released(MouseEvent e) { ! } ! /** * Update the length field --- 109,115 ---- */ protected void released(MouseEvent e) { ! } ! /** * Update the length field *************** *** 123,127 **** } } ! /** * On Vertex --- 123,127 ---- } } ! /** * On Vertex *************** *** 130,134 **** process(null); } ! /** * Process click --- 130,134 ---- process(null); } ! /** * Process click *************** *** 145,157 **** p2 = p1.add(((Edge)current.object()).getDirection()); initDisk(); } else if (current.type() == Intersection.SURFACE) { p1 = current.vertex(); p2 = p1.add(((Surface)(current.object())).normal()); initDisk(); } else { p1 = current.vertex(); start = current; - active = true; totalAngle = 0; } } else if (p2 == null) { --- 145,159 ---- p2 = p1.add(((Edge)current.object()).getDirection()); initDisk(); + active = false; } else if (current.type() == Intersection.SURFACE) { p1 = current.vertex(); p2 = p1.add(((Surface)(current.object())).normal()); initDisk(); + active = false; } else { p1 = current.vertex(); start = current; totalAngle = 0; + active = true; } } else if (p2 == null) { *************** *** 159,163 **** start = null; initDisk(); ! active = true; } else if (from == null) { current = findIntersection(e); --- 161,165 ---- start = null; initDisk(); ! active = false; } else if (from == null) { current = findIntersection(e); *************** *** 165,178 **** previous = from; pro.setStart(from); - active = false; nothits = getAffected(vertices); } else { finish(); - active = false; } updateFeedback(); } } ! /** * Initialize the gldisk --- 167,178 ---- previous = from; pro.setStart(from); nothits = getAffected(vertices); } else { finish(); } updateFeedback(); } } ! /** * Initialize the gldisk *************** *** 182,185 **** --- 182,186 ---- v.normalize(); onto = new Plane(v.getX(), v.getY(), v.getZ(), p1); + log.info("Disk were: " + onto); pro = new GlProtractor(onto, p1); glv.getView().addGlObjects3D(pro); *************** *** 195,199 **** clear(); } ! /** * Escape --- 196,200 ---- clear(); } ! /** * Escape *************** *** 205,209 **** cleanUp(); } ! /** * Apply current tool with specified length value --- 206,210 ---- cleanUp(); } ! /** * Apply current tool with specified length value *************** *** 218,222 **** finish(); } ! /** * Update the feedback --- 219,223 ---- finish(); } ! /** * Update the feedback *************** *** 247,251 **** updateConstructors(); } ! /** * Remove tool specific things at tool change --- 248,252 ---- updateConstructors(); } ! /** * Remove tool specific things at tool change *************** *** 256,260 **** updateFeedback(); } ! /** * Remove all internal stuff --- 257,261 ---- updateFeedback(); } ! /** * Remove all internal stuff *************** *** 275,279 **** nothits.clear(); } ! /** * Do the rotation of the vertices --- 276,280 ---- nothits.clear(); } ! /** * Do the rotation of the vertices *************** *** 288,292 **** } } ! /** * A GlObject that draw a protactor on the gl --- 289,293 ---- } } ! /** * A GlObject that draw a protactor on the gl *************** *** 300,307 **** private Vertex start; /** The preset angles to intersect with */ ! private LinkedList edges; /** The magnification factor */ private double factor; ! /** * The construtor for the protractor --- 301,308 ---- private Vertex start; /** The preset angles to intersect with */ ! private LinkedList < Line > edges; /** The magnification factor */ private double factor; ! /** * The construtor for the protractor *************** *** 312,318 **** plane = p; this.origin = origin; ! edges = new LinkedList(); } ! /** * Setter for the start vertex --- 313,319 ---- plane = p; this.origin = origin; ! edges = new LinkedList < Line > (); } ! /** * Setter for the start vertex *************** *** 332,336 **** } } ! /** * @inheritDoc --- 333,337 ---- } } ! /** * @inheritDoc *************** *** 346,355 **** // translate Vertex z = plane.normal(); - z.normalize(); Vertex y = new Vertex(0, 1, 0); ! if (y.minus(z).length() < 0.00000001) { y = new Vertex(1, 0, 0); } ! // place the axis right if (start != null) { --- 347,355 ---- // translate Vertex z = plane.normal(); Vertex y = new Vertex(0, 1, 0); ! if (y.cross(z).length() < 0.00001) { y = new Vertex(1, 0, 0); } ! // place the axis right if (start != null) { *************** *** 358,370 **** } Vertex x = y.cross(z); y = z.cross(x); double[] m = new double[]{x.getX(), x.getY(), x.getZ(), 0, ! y.getX(), y.getY(), y.getZ(), 0, ! z.getX(), z.getY(), z.getZ(), 0, ! origin.getX(), origin.getY(), origin.getZ(), 1}; gl.glPushMatrix(); gl.glMultMatrixd(m, 0); //draw ! gl.glColor4fv(new float[] {0.5f, 0.5f, 0.5f, 0.6f}, 0); int sign = 1; --- 358,371 ---- } Vertex x = y.cross(z); + x.normalize(); y = z.cross(x); double[] m = new double[]{x.getX(), x.getY(), x.getZ(), 0, ! y.getX(), y.getY(), y.getZ(), 0, ! z.getX(), z.getY(), z.getZ(), 0, ! origin.getX(), origin.getY(), origin.getZ(), 1}; gl.glPushMatrix(); gl.glMultMatrixd(m, 0); //draw ! gl.glColor4fv(new float[] {0.5f, 0.5f, 0.5f, 0.6f}, 0); int sign = 1; *************** *** 378,388 **** //restore matrix gl.glPopMatrix(); ! //draw lines ! /*gl.glColor3d(0.2, 0.2, 0.2); ! gl.glLineWidth(0.1f); ! Iterator iter = edges.iterator(); while (iter.hasNext()) { ! Line l = (Line) iter.next(); Vertex from = l.getPointAt(-1.8 * factor); Vertex to = l.getPointAt(1.8 * factor); --- 379,389 ---- //restore matrix gl.glPopMatrix(); ! //draw lines ! gl.glColor3d(0.2, 0.2, 0.2); ! gl.glLineWidth(1.0f); ! Iterator < Line > iter = edges.iterator(); while (iter.hasNext()) { ! Line l = iter.next(); Vertex from = l.getPointAt(-1.8 * factor); Vertex to = l.getPointAt(1.8 * factor); *************** *** 391,395 **** gl.glVertex3d(to.getX(), to.getY(), to.getZ()); gl.glEnd(); ! }*/ } --- 392,396 ---- gl.glVertex3d(to.getX(), to.getY(), to.getZ()); gl.glEnd(); ! } } *************** *** 399,407 **** public Vertex intersection(Edge e) { Vertex i = plane.intersection(e); ! Iterator iter = edges.iterator(); double p1 = -2.5 * factor; double p2 = 2.5 * factor; while (iter.hasNext()) { ! Line l = (Line) iter.next(); Edge tmp = new Edge(l.getPointAt(p1), l.getPointAt(p2)); Edge con = e.intersection(tmp); --- 400,408 ---- public Vertex intersection(Edge e) { Vertex i = plane.intersection(e); ! Iterator<Line> iter = edges.iterator(); double p1 = -2.5 * factor; double p2 = 2.5 * factor; while (iter.hasNext()) { ! Line l = iter.next(); Edge tmp = new Edge(l.getPointAt(p1), l.getPointAt(p2)); Edge con = e.intersection(tmp); *************** *** 416,419 **** --- 417,427 ---- return i; } + + /** + * @inheritDoc + */ + public Plane getPlane() { + return plane; + } } } |