public void SelectPointAfterMove() { var ctx = Context.Current; var sketch = TestGeomGenerator.CreateSketch(TestGeomGenerator.SketchType.MultiCircle); var body = TestGeomGenerator.CreateBody(sketch); ctx.ViewportController.ZoomFitAll(); var tool = new SketchEditorTool(sketch); ctx.WorkspaceController.StartTool(tool); // Move point ctx.ClickAt(377, 122); Assert.AreEqual(1, tool.SelectedPoints.Count); ctx.MoveTo(392, 104); ctx.ViewportController.MouseDown(); ctx.MoveTo(387, 141); ctx.ViewportController.MouseUp(false); // Return to idle ctx.ClickAt(1, 1); ctx.ViewportController.MouseDown(); ctx.ViewportController.MouseUp(false); Assert.AreEqual(0, tool.SelectedPoints.Count); // Try to select point ctx.ClickAt(371, 160); Assert.AreEqual(1, tool.SelectedPoints.Count); // Cleanup tool.Stop(); }
public void MovePointSnap() { var ctx = Context.Current; var sketch = TestGeomGenerator.CreateSketch(TestGeomGenerator.SketchType.MultiCircle); var body = TestGeomGenerator.CreateBody(sketch); ctx.ViewportController.ZoomFitAll(); var tool = new SketchEditorTool(sketch); ctx.WorkspaceController.StartTool(tool); ctx.EditorState.SnappingEnabled = true; ctx.EditorState.SnapToGridSelected = true; Assert.Multiple(() => { // Select Point ctx.ClickAt(377, 122); // Move on progress ctx.MoveTo(390, 108); ctx.ViewportController.MouseDown(); ctx.ViewportController.MouseMove(new Point(257, 83)); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePointSnap01")); // Move released ctx.ViewportController.MouseUp(false); ctx.ClickAt(1, 1); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePointSnap02")); // Cleanup tool.Stop(); }); }
public void RubberbandSelection() { var ctx = Context.Current; var sketch = TestGeomGenerator.CreateSketch(TestGeomGenerator.SketchType.MultiCircle); var body = TestGeomGenerator.CreateBody(sketch); ctx.ViewportController.ZoomFitAll(); var tool = new SketchEditorTool(sketch); ctx.WorkspaceController.StartTool(tool); ctx.MoveTo(170, 50); ctx.ViewportController.MouseDown(); ctx.ViewportController.StartRubberbandSelection(ViewportController.RubberbandSelectionMode.Rectangle, false); ctx.MoveTo(450, 300); ctx.ViewportController.MouseUp(false); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "RubberbandSelection01")); Assert.AreEqual(4, tool.SelectedPoints.Count); Assert.AreEqual(1, tool.SelectedSegments.Count); // Cleanup tool.Stop(); }
public void SplitPeriodicSegment() { var ctx = Context.Current; var sketch = TestSketchGenerator.CreateSketch(TestSketchGenerator.SketchType.Circle); var body = TestGeomGenerator.CreateBody(sketch); ctx.ViewportController.ZoomFitAll(); var tool = new SketchEditorTool(sketch); ctx.WorkspaceController.StartTool(tool); Assert.Multiple(() => { // Select Segment ctx.ClickAt(140, 90); // Start split tool var splitTool = new SplitElementSketchTool(); tool.StartTool(splitTool); ctx.MoveTo(184, 103); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "SplitPeriodicSegment01"), 1.0); ctx.ClickAt(184, 103); // Cleanup tool.StopTool(); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "SplitPeriodicSegment02"), 1.0); }); tool.Stop(); }
public void MovePoint() { var ctx = Context.Current; var sketch = TestGeomGenerator.CreateSketch(TestGeomGenerator.SketchType.MultiCircle); var body = TestGeomGenerator.CreateBody(sketch); ctx.ViewportController.ZoomFitAll(); var tool = new SketchEditorTool(sketch); ctx.WorkspaceController.StartTool(tool); Assert.Multiple(() => { // MovePoints Idle AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint01")); // Hilite Point ctx.ViewportController.MouseMove(new Point(377, 122)); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint02")); // Select Point, move gizmo shown ctx.ViewportController.MouseDown(); ctx.ViewportController.MouseUp(false); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint03")); // Hilite Gizmo X-Axis ctx.ViewportController.MouseMove(new Point(459, 122)); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint04")); // Hilite Gizmo Y-Axis ctx.ViewportController.MouseMove(new Point(377, 38)); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint05")); // Hilite Gizmo XY-Plane ctx.ViewportController.MouseMove(new Point(392, 104)); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint06")); // Move on progress ctx.ViewportController.MouseDown(); ctx.ViewportController.MouseMove(new Point(387, 141)); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint07")); // Move released ctx.ViewportController.MouseUp(false); ctx.ViewportController.MouseMove(new Point(1, 1)); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint08")); // Return to idle ctx.ViewportController.MouseDown(); ctx.ViewportController.MouseUp(false); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint09")); // Cleanup tool.Stop(); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "MovePoint10")); }); }
public void SplitSegmentUndo() { var ctx = Context.Current; var sketch = TestSketchGenerator.CreateSketch(TestSketchGenerator.SketchType.Rectangle); var body = TestGeomGenerator.CreateBody(sketch); ctx.ViewportController.ZoomFitAll(); Assert.IsFalse(ctx.UndoHandler.CanUndo); Assert.IsFalse(ctx.UndoHandler.CanRedo); var tool = new SketchEditorTool(sketch); ctx.WorkspaceController.StartTool(tool); Assert.Multiple(() => { // Select Segment ctx.ClickAt(140, 90); // Start split tool var splitTool = new SplitElementSketchTool(); tool.StartTool(splitTool); // Split ctx.ClickAt(150, 88); Assert.AreEqual(5, tool.Sketch.Segments.Count); Assert.IsTrue(ctx.UndoHandler.CanUndo); Assert.IsFalse(ctx.UndoHandler.CanRedo); // Undo ctx.UndoHandler.DoUndo(1); Assert.AreEqual(4, tool.Sketch.Segments.Count); Assert.IsFalse(ctx.UndoHandler.CanUndo); Assert.IsTrue(ctx.UndoHandler.CanRedo); // Redo ctx.UndoHandler.DoRedo(1); Assert.AreEqual(5, tool.Sketch.Segments.Count); Assert.IsTrue(ctx.UndoHandler.CanUndo); Assert.IsFalse(ctx.UndoHandler.CanRedo); // Cleanup tool.StopTool(); }); tool.Stop(); }
public void RestoreWorkingContextWithTopView() { var ctx = Context.Current; var viewportParameterSet = InteractiveContext.Current.Parameters.Get <ViewportParameterSet>(); viewportParameterSet.ShowViewCube = true; // Create sketch ctx.WorkspaceController.StartTool(new CreateSketchTool(CreateSketchTool.CreateMode.WorkplaneXY)); var sketchEditTool = ctx.WorkspaceController.CurrentTool as SketchEditorTool; Assert.That(sketchEditTool, Is.Not.Null); var sketch = sketchEditTool.Sketch; // Fill in anything sketchEditTool.StartSegmentCreation <SketchSegmentCircleCreator>(); ctx.ClickAt(250, 250); // Center point ctx.ClickAt(100, 250); // Rim point // Exit editor sketchEditTool.Stop(); // Select predefined topview ctx.WorkspaceController.ActiveViewControlller.SetPredefinedView(ViewportController.PredefinedViews.Top); Thread.Sleep(500); ctx.WorkspaceController.Invalidate(forceRedraw: true); // AssertHelper.IsSameViewport(Path.Combine(_BasePath, "RestoreWorkingContext22"), 1.0); // Enter editor sketchEditTool = new SketchEditorTool(sketch); ctx.WorkspaceController.StartTool(sketchEditTool); // move the viewport ctx.MoveTo(250, 250); ctx.ViewportController.MouseMove(new Point(150, 250), ViewportController.MouseMoveMode.Panning); // Leave editor sketchEditTool.Stop(); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "RestoreWorkingContext21"), 1.0); }
public void SplitPoint() { var ctx = Context.Current; var sketch = TestGeomGenerator.CreateSketch(TestGeomGenerator.SketchType.Rectangle); var body = TestGeomGenerator.CreateBody(sketch); ctx.ViewportController.ZoomFitAll(); var tool = new SketchEditorTool(sketch); ctx.WorkspaceController.StartTool(tool); Assert.Multiple(() => { // Select Segment ctx.ClickAt(140, 90); // Start split tool var splitTool = new SplitElementSketchTool(); tool.StartTool(splitTool); ctx.MoveTo(88, 88); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "SplitPoint01")); ctx.ClickAt(88, 88); // Cleanup tool.StopTool(); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "SplitPoint02")); // Move ctx.ClickAt(88, 88); ctx.MoveTo(95, 80); ctx.ViewportController.MouseDown(); ctx.MoveTo(150, 40); ctx.ViewportController.MouseUp(false); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "SplitPoint03")); }); tool.Stop(); }
public void EmptySketchMarker() { var ctx = Context.Current; ctx.WorkspaceController.StartTool(new CreateSketchTool(CreateSketchTool.CreateMode.WorkplaneXY)); var sketchEditTool = ctx.WorkspaceController.CurrentTool as SketchEditorTool; Assert.That(sketchEditTool, Is.Not.Null); var sketch = sketchEditTool.Sketch; Assert.Multiple(() => { // In Editor, no marker AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EmptySketchMarker01"), 1.0); sketchEditTool.Stop(); // Out of Editor, marker AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EmptySketchMarker02"), 1.0); // Enter editor, no marker sketchEditTool = new SketchEditorTool(sketch); ctx.WorkspaceController.StartTool(sketchEditTool); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EmptySketchMarker01"), 1.0); // Create Circle, no marker sketchEditTool.StartSegmentCreation <SketchSegmentCircleCreator>(); ctx.ClickAt(200, 200); // Center point ctx.MoveTo(100, 100); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EmptySketchMarker03"), 1.0); ctx.ClickAt(100, 250); // Rim point ctx.MoveTo(50, 50); // Move crsr out of the way AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EmptySketchMarker04"), 1.0); // Leave editor, no marker sketchEditTool.Stop(); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EmptySketchMarker05"), 1.0); }); }