[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool Protractor.java, 1.7, 1.8 ToolFactory
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-11-14 10:34:33
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17018/src/net/sourceforge/bprocessor/gl/tool Modified Files: Protractor.java ToolFactory.java Log Message: Reintroducing the protractor, but not finished Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** ToolFactory.java 12 Nov 2007 07:40:54 -0000 1.89 --- ToolFactory.java 14 Nov 2007 10:34:29 -0000 1.90 *************** *** 92,95 **** --- 92,97 ---- private AbstractPencil tapeMeasure; + private AbstractTool protractor; + /** Constructor tool */ private ConstructorTool constructor; *************** *** 186,189 **** --- 188,192 ---- clipplane = new ClipplaneTool(glv, pencilcursor); tapeMeasure = new TapeMeasure(glv, pencilcursor); + protractor = new Protractor(glv, pencilcursor); relation = new RelationTool(glv, arrowAddCursor); camera = new CameraTool(glv, rotationCursor); *************** *** 219,226 **** registerTool(Tool.MULTI_EXTRUDE_TOOL, multiExtrude, "Biconextrudetool2.gif", "Extend"); ! //this.registerTool(Tool.MOVE_TOOL, alternate, "Biconmovetool.gif", "Move"); ! //registerTool(Tool.CONTROLLED_MOVE_TOOL, controlled, "Biconmovetool.gif", "Controlled Move"); ! //registerTool(Tool.ALT_MOVE_TOOL, altMoveTool, "Biconmovetool.gif", "Alternative Moving"); ! //registerTool(Tool.EDGE_MOVE_TOOL, edgeMoveTool, "Biconmovetool.gif", "Edge moving"); JToggleButton moveBut = registerTool(Tool.FINAL_MOVE_TOOL, finalMoveTool, "Bmovetool.gif", "Final Move"); --- 222,226 ---- registerTool(Tool.MULTI_EXTRUDE_TOOL, multiExtrude, "Biconextrudetool2.gif", "Extend"); ! JToggleButton moveBut = registerTool(Tool.FINAL_MOVE_TOOL, finalMoveTool, "Bmovetool.gif", "Final Move"); *************** *** 228,236 **** JToggleButton rotationBut = this.registerTool(Tool.ROTATION_TOOL, rotation, "Biconrotaxe.gif", "Rotate"); tb.addSeparator(5); ! JToggleButton tmBut = this.registerTool(Tool.TAPE_MEASURE_TOOL, tapeMeasure, ! "Bicontapemes.gif", "Tape Measure"); ! this.registerTool(Tool.CONSTRUCTOR_TOOL, constructor, "Biconconstructor.gif", "Constructor"); ! this.registerTool(Tool.RELATION_TOOL, relation, "chaintool.gif", "Create relation"); tb.addSeparator(5); --- 228,237 ---- JToggleButton rotationBut = this.registerTool(Tool.ROTATION_TOOL, rotation, "Biconrotaxe.gif", "Rotate"); + tb.addSeparator(5); ! registerTool(Tool.TAPE_MEASURE_TOOL, tapeMeasure, "Bicontapemes.gif", "Tape Measure"); ! registerTool(Tool.PROTRACTOR_TOOL, protractor, "Bprotrac.gif", "Protractor"); ! registerTool(Tool.CONSTRUCTOR_TOOL, constructor, "Biconconstructor.gif", "Constructor"); ! registerTool(Tool.RELATION_TOOL, relation, "chaintool.gif", "Create relation"); tb.addSeparator(5); Index: Protractor.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Protractor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Protractor.java 19 Sep 2007 20:57:47 -0000 1.7 --- Protractor.java 14 Nov 2007 10:34:29 -0000 1.8 *************** *** 13,20 **** --- 13,29 ---- import java.util.List; + import javax.media.opengl.GL; + import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.gl.model.GlObject; + import net.sourceforge.bprocessor.gl.view.View; + import net.sourceforge.bprocessor.model.CoordinateSystem; + import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometry; import net.sourceforge.bprocessor.model.Line; + import net.sourceforge.bprocessor.model.Plane; + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; + import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; *************** *** 24,27 **** --- 33,38 ---- public class Protractor extends AbstractPencil { + private Protract protract; + /** * Constructor *************** *** 40,60 **** */ protected Line createConstructor(Vertex start, Vertex end) { ! return new Line(start, end.minus(start), true, true); } /** * Update feedback - * */ protected void updateFeedback() { if (start != null) { List edges = new LinkedList(); ! Line l; ! ! l = createConstructor(start.vertex(), current.vertex()); ! ! edges.add(l); feedback(edges); } else { feedback(new LinkedList()); } makeTarget(current); --- 51,77 ---- */ protected Line createConstructor(Vertex start, Vertex end) { ! Vertex direction = end.minus(start); ! direction.normalize(); ! return new Line(start, direction, true, true); } + /** * Update feedback */ protected void updateFeedback() { + if (protract != null) { + glv.getView().removeGlObjects3D(protract); + protract = null; + } if (start != null) { List edges = new LinkedList(); ! Line line; ! line = createConstructor(start.vertex(), current.vertex()); ! edges.add(line); feedback(edges); } else { feedback(new LinkedList()); + protract = new Protract(current.vertex()); + glv.getView().addGlObjects3D(protract); } makeTarget(current); *************** *** 62,69 **** /** ! * @param e MouseEven */ ! protected void moved(MouseEvent e) { ! current = findIntersection(e); if (current != null) { updateFeedback(); --- 79,86 ---- /** ! * {@inheritDoc} */ ! protected void moved(MouseEvent event) { ! current = findIntersection(event); if (current != null) { updateFeedback(); *************** *** 80,91 **** Geometry.insertConstructor(l); start = null; } /** ! * @param e MouseEven */ ! protected void pressed(MouseEvent e) { if (start == null) { start = current; } else { onVertex(); --- 97,119 ---- Geometry.insertConstructor(l); start = null; + cleanUp(); } /** ! * {@inheritDoc} */ ! protected void pressed(MouseEvent event) { ! current = findIntersection(event); if (start == null) { start = current; + CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); + system = system.copy(start.vertex()); + Plane plane = system.plane(); + Surface surface = View.getLastSurface(); + if (surface != null) { + plane = surface.plane(); + } + lockingPlane = plane; + lock = true; } else { onVertex(); *************** *** 96,108 **** /** ! * @param e MouseEven */ ! protected void dragged(MouseEvent e) { } /** ! * @param e MouseEven */ ! protected void released(MouseEvent e) { } --- 124,136 ---- /** ! * {@inheritDoc} */ ! protected void dragged(MouseEvent event) { } /** ! * {@inheritDoc} */ ! protected void released(MouseEvent event) { } *************** *** 113,115 **** --- 141,197 ---- Selection.primary().clear(); } + + /** + * {@inheritDoc} + */ + public void cleanUp() { + if (protract != null) { + glv.getView().removeGlObjects3D(protract); + protract = null; + } + } + + /** + * Protract + */ + public static class Protract implements GlObject { + private Vertex origin; + + /** + * Constructs a Protract + * @param origin Vertex + */ + public Protract(Vertex origin) { + this.origin = origin; + } + + /** {@inheritDoc} */ + public void draw(GL gl) { + gl.glPushMatrix(); + gl.glTranslated(origin.getX(), origin.getY(), origin.getZ()); + double radius = 1; + double n = 24; + gl.glLineWidth(1.5f); + gl.glColor3fv(View.CONSTRUCTOR_COLOR, 0); + gl.glBegin(GL.GL_LINE_LOOP); + for (int i = 0; i < n; i++) { + double angle = 2 * Math.PI * i / n; + double x = Math.cos(angle) * radius; + double y = Math.sin(angle) * radius; + gl.glVertex3d(x, y, 0); + } + gl.glEnd(); + gl.glPopMatrix(); + } + + /** {@inheritDoc} */ + public Plane getPlane() { + return null; + } + + /** {@inheritDoc} */ + public Vertex intersection(Edge e) { + return null; + } + } } |