[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ToolFactory.java,1.26,1.27 RotationToo
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-01-30 14:12:13
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10697/src/net/sourceforge/bprocessor/gl/tool Modified Files: ToolFactory.java RotationTool.java Log Message: Now the rotation tool does work but still in a simple matter and with no snap or info of angle rotated. Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ToolFactory.java 30 Jan 2006 11:34:10 -0000 1.26 --- ToolFactory.java 30 Jan 2006 14:11:55 -0000 1.27 *************** *** 107,110 **** --- 107,111 ---- but.setToolTipText("Move"); but = tb.registerAction(new RotationAction(glv)); + bg.add(but); but.setToolTipText("Rotate"); but = tb.registerAction(new ExtrudeAction(glv)); *************** *** 118,124 **** but.setToolTipText("Tape Measure"); tb.addSeparator(); - but = tb.registerAction(new RotationAction(glv)); - bg.add(but); - but.setToolTipText("Rotation"); but = tb.registerAction(new CameraAction(glv)); bg.add(but); --- 119,122 ---- Index: RotationTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/RotationTool.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RotationTool.java 27 Jan 2006 12:22:45 -0000 1.5 --- RotationTool.java 30 Jan 2006 14:11:55 -0000 1.6 *************** *** 13,18 **** import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Plane; - import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.Surface; --- 13,18 ---- import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Entity; + import net.sourceforge.bprocessor.model.Geometry; import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.Surface; *************** *** 29,32 **** --- 29,33 ---- import org.apache.log4j.Logger; + /** * The rotation tool *************** *** 67,70 **** --- 68,73 ---- /** The set containing the guide line */ private HashSet guide = new HashSet(); + /** The vertexes to rotate */ + private HashSet vertices = new HashSet(); /** *************** *** 101,115 **** if (xCircle.contains(target)) { axis = X_AXIS; - Selection.primary().addAll(xCircle); clearConstructors(zCircle); clearConstructors(yCircle); } else if (yCircle.contains(target)) { axis = Y_AXIS; - Selection.primary().addAll(yCircle); clearConstructors(xCircle); clearConstructors(zCircle); } else if (zCircle.contains(target)) { axis = Z_AXIS; - Selection.primary().addAll(zCircle); clearConstructors(xCircle); clearConstructors(yCircle); --- 104,115 ---- *************** *** 132,141 **** } } else { ! clearConstructors(xCircle); ! xCircle.clear(); ! clearConstructors(yCircle); ! yCircle.clear(); ! clearConstructors(zCircle); ! zCircle.clear(); } } --- 132,136 ---- } } else { ! cleanUp(); } } *************** *** 148,156 **** super.released(e); if (axis != 0) { ! // We were rotation so show all constructor line again displayConstructors(xCircle); displayConstructors(yCircle); displayConstructors(zCircle); - Selection.primary().clear(); // remove guideline clearConstructors(guide); --- 143,152 ---- super.released(e); if (axis != 0) { ! rotate(from, initial, this.center); ! ! // We were rotating so show all constructor line again displayConstructors(xCircle); displayConstructors(yCircle); displayConstructors(zCircle); // remove guideline clearConstructors(guide); *************** *** 160,173 **** if (target != null && target instanceof Entity) { if (target instanceof Edge && ((Edge)target).getConstructor()) { ! // If it is a constructor it should not be rotatable return; } ! clearConstructors(xCircle); ! clearConstructors(yCircle); ! clearConstructors(zCircle); ! xCircle.clear(); ! yCircle.clear(); ! zCircle.clear(); ! HashSet vertices = new HashSet(); collect(selection, vertices); --- 156,163 ---- if (target != null && target instanceof Entity) { if (target instanceof Edge && ((Edge)target).getConstructor()) { ! // If it is a constructor it should not be rotateable return; } ! cleanUp(); collect(selection, vertices); *************** *** 179,182 **** --- 169,173 ---- drawCircles(((Entity)target).center(), dist); } else { + // There were nothing selected if (axis == 0) { dist = 0; *************** *** 199,203 **** initial.setY(ny.getY()); initial.setZ(ny.getZ()); - // TODO rotate the object from prev to initial prev = initial; --- 190,193 ---- *************** *** 216,220 **** public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { ! //TODO rotate object from initial back to from } } --- 206,239 ---- public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { ! rotate(initial, from, this.center); ! } ! } ! ! /** ! * Rotate the selected vertexes the angle from v1 to v2 ! * @param v1 The from vertex ! * @param v2 The to vertex ! * @param center the vertex to rotate about ! */ ! private void rotate(Vertex v1, Vertex v2, Vertex center) { ! Vertex first = from.minus(center); ! Vertex second = initial.minus(center); ! double direction = first.cross(second).getX() + ! first.cross(second).getY() + ! first.cross(second).getZ(); ! double angle = Math.acos(first.dot(second) / (first.length() * second.length()));; ! int x = axis == X_AXIS ? 1 : 0; ! int y = axis == Y_AXIS ? 1 : 0; ! int z = axis == Z_AXIS ? 1 : 0; ! if (!new Double(angle).isNaN()) { ! Iterator iter = vertices.iterator(); ! while (iter.hasNext()) { ! Vertex v = (Vertex)iter.next(); ! if (direction > 0) { ! Geometry.rotate(angle, x, y, z, v, center); ! } else { ! Geometry.rotate(-angle, x, y, z, v, center); ! } ! } } } *************** *** 222,226 **** /** * Remove tool specific things at tool change - * */ public void cleanUp() { --- 241,244 ---- *************** *** 231,234 **** --- 249,253 ---- yCircle.clear(); zCircle.clear(); + vertices.clear(); } |