public async Task CopyButtonMakesCopyOfPart() { await MatterControlUtilities.RunTest((testRunner) => { testRunner.OpenEmptyPartTab(); testRunner.AddItemToBedplate(); // Get View3DWidget View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out _, 3) as View3DWidget; var scene = view3D.InteractionLayer.Scene; testRunner.WaitForName("Calibration - Box.stl"); Assert.AreEqual(1, scene.Children.Count, "Should have 1 part before copy"); // Select scene object testRunner.Select3DPart("Calibration - Box.stl"); // Click Copy button and count Scene.Children testRunner.ClickByName("Duplicate Button"); testRunner.WaitFor(() => scene.Children.Count == 2); Assert.AreEqual(2, scene.Children.Count, "Should have 2 parts after copy"); // Click Copy button a second time and count Scene.Children testRunner.ClickByName("Duplicate Button"); testRunner.WaitFor(() => scene.Children.Count > 2); Assert.AreEqual(3, scene.Children.Count, "Should have 3 parts after 2nd copy"); return(Task.CompletedTask); }, overrideWidth : 1300, maxTimeToRun : 60); }
public void GroupAndUngroup() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages); { SystemWindow systemWindow; //Navigate to Local Library testRunner.ClickByName("Library Tab"); MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection"); testRunner.Wait(1); testRunner.ClickByName("Row Item Calibration - Box"); testRunner.ClickByName("Row Item Calibration - Box Print Button"); testRunner.Wait(1); //Get View3DWidget and count MeshGroups before Copy button is clicked GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3); View3DWidget view3D = partPreview as View3DWidget; string copyButtonName = "3D View Copy"; //Click Edit button to make edit controls visible testRunner.ClickByName("3D View Edit"); testRunner.Wait(1); int partCountBeforeCopy = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partCountBeforeCopy == 1); for (int i = 0; i <= 4; i++) { testRunner.ClickByName(copyButtonName); testRunner.Wait(1); } //Get MeshGroupCount before Group is clicked System.Threading.Thread.Sleep(2000); int partsOnBedBeforeGroup = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partsOnBedBeforeGroup == 6); //Click Group Button and get MeshGroup count after Group button is clicked testRunner.ClickByName("3D View Group"); System.Threading.Thread.Sleep(2000); int partsOnBedAfterGroup = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partsOnBedAfterGroup == 1); testRunner.ClickByName("3D View Ungroup"); System.Threading.Thread.Sleep(2000); int partsOnBedAfterUngroup = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partsOnBedAfterUngroup == 6); MatterControlUtilities.CloseMatterControl(testRunner); } }; AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 4); // make sure we ran all our tests }
public void SaveAsToQueue() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages); { MatterControlUtilities.PrepForTestRun(testRunner); //Navigate to Local Library testRunner.ClickByName("Library Tab"); MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection"); testRunner.Wait(1); testRunner.ClickByName("Row Item Calibration - Box"); MatterControlUtilities.LibraryEditSelectedItem(testRunner); testRunner.Wait(1); //Click Edit button to make edit controls visible testRunner.ClickByName("3D View Edit"); testRunner.Wait(1); SystemWindow systemWindow; GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3); View3DWidget view3D = partPreview as View3DWidget; for (int i = 0; i <= 2; i++) { testRunner.ClickByName("3D View Copy"); testRunner.Wait(1); } //Click Save As button to save changes to the part testRunner.ClickByName("Save As Menu"); testRunner.Wait(1); testRunner.ClickByName("Save As Menu Item"); testRunner.Wait(1); //Type in name of new part and then save to Print Queue testRunner.Type("Save As Print Queue"); MatterControlUtilities.NavigateToFolder(testRunner, "Print Queue Row Item Collection"); testRunner.Wait(1); testRunner.ClickByName("Save As Save Button"); view3D.CloseOnIdle(); testRunner.Wait(.5); //Make sure there is a new Queue item with a name that matches the new part testRunner.Wait(1); testRunner.ClickByName("Queue Tab"); testRunner.Wait(1); resultsHarness.AddTestResult(testRunner.WaitForName("Queue Item Save As Print Queue", 5)); MatterControlUtilities.CloseMatterControl(testRunner); } }; AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun); Assert.IsTrue(testHarness.AllTestsPassed(1)); }
void GeneratePartViews(object state = null) { double buildHeight = ActiveSliceSettings.Instance.BuildHeight; part3DView = new View3DWidget(PrinterConnectionAndCommunication.Instance.ActivePrintItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, View3DWidget.WindowType.Embeded, View3DWidget.AutoRotate.Enabled); part3DView.Margin = new BorderDouble(bottom: 4); part3DView.AnchorAll(); part3DViewContainer.RemoveAllChildren(); part3DViewContainer.AddChild(part3DView); partGcodeView = new ViewGcodeBasic(PrinterConnectionAndCommunication.Instance.ActivePrintItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, false); partGcodeView.AnchorAll(); partGcodeViewContainer.RemoveAllChildren(); partGcodeViewContainer.AddChild(partGcodeView); }
void LoadColumnTwo(object state = null) { ColumnTwo.CloseAndRemoveAllChildren(); double buildHeight = ActiveSliceSettings.Instance.BuildHeight; #if NEW_TWO_COLUMN_MODE PartPreviewContent partViewContent = new PartPreviewContent(PrinterConnectionAndCommunication.Instance.ActivePrintItem, true, View3DWidget.AutoRotate.Enabled, false); partViewContent.AnchorAll(); ColumnTwo.AddChild(partViewContent); #else part3DView = new View3DWidget(PrinterConnectionAndCommunication.Instance.ActivePrintItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, View3DWidget.WindowType.Embeded, View3DWidget.AutoRotate.Enabled); part3DView.Margin = new BorderDouble(bottom: 4); part3DView.AnchorAll(); partGcodeView = new ViewGcodeBasic(PrinterConnectionAndCommunication.Instance.ActivePrintItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, false); partGcodeView.AnchorAll(); ColumnTwo.AddChild(part3DView); ColumnTwo.AddChild(partGcodeView); #endif ColumnTwo.AnchorAll(); }
public void CopyButtonClickedMakesCopyOfPartOnBed() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages); { MatterControlUtilities.PrepForTestRun(testRunner); SystemWindow systemWindow; //Navigate to Local Library testRunner.ClickByName("Library Tab"); MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection"); testRunner.Wait(1); testRunner.ClickByName("Row Item Calibration - Box"); testRunner.ClickByName("Row Item Calibration - Box View Button"); testRunner.Wait(1); //Get View3DWidget and count MeshGroups before Copy button is clicked GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3); View3DWidget view3D = partPreview as View3DWidget; string copyButtonName = "3D View Copy"; //Click Edit button to make edit controls visible testRunner.ClickByName("3D View Edit"); testRunner.Wait(1); int partCountBeforeCopy = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partCountBeforeCopy == 1); //Click Copy button and count MeshGroups testRunner.ClickByName(copyButtonName); System.Threading.Thread.Sleep(500); int partCountAfterCopy = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partCountAfterCopy == 2); testRunner.Wait(1); //Click Copy button a second time and count MeshGroups again testRunner.ClickByName(copyButtonName); System.Threading.Thread.Sleep(500); int partCountAfterSecondCopy = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partCountAfterSecondCopy == 3); view3D.CloseOnIdle(); testRunner.Wait(.5); MatterControlUtilities.CloseMatterControl(testRunner); } }; AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 3); // make sure we ran all our tests }
private static void Offset3DView(View3DWidget view3D, Vector2 offset, TrackBallTransformType operation) { var center = view3D.TrackballTumbleWidget.LocalBounds.Center; view3D.TrackballTumbleWidget.TrackBallController.OnMouseDown(center, Matrix4X4.Identity, operation); view3D.TrackballTumbleWidget.TrackBallController.OnMouseMove(center + offset); view3D.TrackballTumbleWidget.TrackBallController.OnMouseUp(); view3D.TrackballTumbleWidget.Invalidate(); }
private static void NudgeItem(View3DWidget view3D, IObject3D item, ArrowDirection arrowDirection, KeyEventArgs keyEvent) { var world = view3D.Object3DControlLayer.World; var vector3 = default(Vector3); var moveDistance = Math.Max(.1, view3D.Object3DControlLayer.SnapGridDistance); if (keyEvent.Shift) { moveDistance *= 5; } else if (keyEvent.Control) { moveDistance *= .2; } switch (arrowDirection) { case ArrowDirection.Left: vector3 = new Vector3(-moveDistance, 0, 0); break; case ArrowDirection.Right: vector3 = new Vector3(moveDistance, 0, 0); break; case ArrowDirection.Up: if (keyEvent.Control) { vector3 = new Vector3(0, moveDistance, 0); } else { vector3 = new Vector3(0, moveDistance, 0); } break; case ArrowDirection.Down: if (keyEvent.Control) { vector3 = new Vector3(0, -moveDistance, 0); } else { vector3 = new Vector3(0, -moveDistance, 0); } break; } var matrix = world.GetXYInViewRotation(item.GetCenter()); item.Translate(vector3.Transform(matrix)); }
public void RemoveButtonRemovesParts() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages); { MatterControlUtilities.PrepForTestRun(testRunner); SystemWindow systemWindow; //Navigate to Local Library testRunner.ClickByName("Library Tab"); MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection"); testRunner.Wait(1); testRunner.ClickByName("Row Item Calibration - Box"); MatterControlUtilities.LibraryEditSelectedItem(testRunner); testRunner.Wait(1); //Get View3DWidget and count MeshGroups before Copy button is clicked GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3); View3DWidget view3D = partPreview as View3DWidget; string copyButtonName = "3D View Copy"; //Click Edit button to make edit controls visible testRunner.ClickByName("3D View Edit"); testRunner.Wait(1); int partCountBeforeCopy = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partCountBeforeCopy == 1); for (int i = 0; i <= 4; i++) { testRunner.ClickByName(copyButtonName); testRunner.Wait(1); } //Get MeshGroupCount before Group is clicked System.Threading.Thread.Sleep(2000); int partsOnBedBeforeRemove = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partsOnBedBeforeRemove == 6); //Check that MeshCount decreases by 1 testRunner.ClickByName("3D View Remove"); System.Threading.Thread.Sleep(2000); int meshCountAfterRemove = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(meshCountAfterRemove == 5); MatterControlUtilities.CloseMatterControl(testRunner); } }; AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun); Assert.IsTrue(testHarness.AllTestsPassed(3)); }
public void LibraryQueueViewRefreshesOnAddItem() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages); { MatterControlUtilities.PrepForTestRun(testRunner); testRunner.ClickByName("Library Tab", 5); MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection"); testRunner.Wait(1); testRunner.ClickByName("Row Item Calibration - Box"); testRunner.ClickByName("Row Item Calibration - Box View Button"); testRunner.Wait(1); SystemWindow systemWindow; GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3); View3DWidget view3D = partPreview as View3DWidget; resultsHarness.AddTestResult(testRunner.ClickByName("3D View Edit", 3)); resultsHarness.AddTestResult(testRunner.ClickByName("3D View Copy", 3), "Click Copy"); // wait for the copy to finish testRunner.Wait(.1); resultsHarness.AddTestResult(testRunner.ClickByName("3D View Remove", 3), "Click Delete"); resultsHarness.AddTestResult(testRunner.ClickByName("Save As Menu", 3), "Click Save As Menu"); resultsHarness.AddTestResult(testRunner.ClickByName("Save As Menu Item", 3), "Click Save As"); testRunner.Wait(1); testRunner.Type("0Test Part"); resultsHarness.AddTestResult(MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection")); resultsHarness.AddTestResult(testRunner.ClickByName("Save As Save Button", 1)); view3D.CloseOnIdle(); testRunner.Wait(.5); // ensure that it is now in the library folder (that the folder updated) resultsHarness.AddTestResult(testRunner.WaitForName("Row Item " + "0Test Part", 5), "The part we added should be in the library"); testRunner.Wait(.5); MatterControlUtilities.CloseMatterControl(testRunner); } }; AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 8); // make sure we ran all our tests }
public async Task GroupAndUngroup() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); SystemWindow systemWindow; //Navigate to Local Library testRunner.ClickByName("Library Tab"); testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.Delay(1); testRunner.ClickByName("Row Item Calibration - Box"); MatterControlUtilities.LibraryEditSelectedItem(testRunner); //Get View3DWidget and count MeshGroups before Copy button is clicked GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3); View3DWidget view3D = partPreview as View3DWidget; string copyButtonName = "3D View Copy"; int partCountBeforeCopy = view3D.MeshGroups.Count; Assert.IsTrue(partCountBeforeCopy == 1); for (int i = 0; i <= 4; i++) { testRunner.ClickByName(copyButtonName); testRunner.Delay(1); } //Get MeshGroupCount before Group is clicked System.Threading.Thread.Sleep(2000); int partsOnBedBeforeGroup = view3D.MeshGroups.Count; Assert.IsTrue(partsOnBedBeforeGroup == 6); //Click Group Button and get MeshGroup count after Group button is clicked testRunner.ClickByName("3D View Group"); System.Threading.Thread.Sleep(2000); int partsOnBedAfterGroup = view3D.MeshGroups.Count; Assert.IsTrue(partsOnBedAfterGroup == 1); testRunner.ClickByName("3D View Ungroup"); System.Threading.Thread.Sleep(2000); int partsOnBedAfterUngroup = view3D.MeshGroups.Count; Assert.IsTrue(partsOnBedAfterUngroup == 6); return(Task.FromResult(0)); }; await MatterControlUtilities.RunTest(testToRun, overrideWidth : 600); }
public InspectForm(GuiWidget inspectedSystemWindow, InteractiveScene scene, View3DWidget view3DWidget) : this(inspectedSystemWindow) { this.view3DWidget = view3DWidget; this.scene = scene; if (scene != null) { this.scene.Children.ItemsModified += Scene_ChildrenModified; sceneTreeView.SuspendLayout(); this.AddTree(scene, null); sceneTreeView.ResumeLayout(); } }
public async Task CopyRemoveUndoRedo() { AutomationTest testToRun = (testRunner) => { SystemWindow systemWindow; testRunner.CloseSignInAndPrinterSelect(); // Navigate to Local Library testRunner.ClickByName("Library Tab"); testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.ClickByName("Row Item Calibration - Box", 1); MatterControlUtilities.LibraryEditSelectedItem(testRunner); // Get View3DWidget View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3) as View3DWidget; // Click Edit button to make edit controls visible testRunner.WaitForName("3D View Copy", 3); testRunner.Delay(1); // wait for window to finish opening Assert.AreEqual(1, view3D.MeshGroups.Count, "Should have 1 part before copy"); for (int i = 0; i <= 4; i++) { testRunner.ClickByName("3D View Copy", 1); testRunner.Delay(.2); } Assert.AreEqual(6, view3D.MeshGroups.Count, "Should have 6 parts after batch copy"); testRunner.ClickByName("3D View Remove", 1); testRunner.Delay(() => view3D.MeshGroups.Count == 5, 3); Assert.AreEqual(5, view3D.MeshGroups.Count, "Should have 5 parts after Remove"); testRunner.ClickByName("3D View Undo"); testRunner.Delay(() => view3D.MeshGroups.Count == 6, 3); Assert.AreEqual(6, view3D.MeshGroups.Count, "Should have 6 parts after Undo"); testRunner.ClickByName("3D View Redo"); testRunner.Delay(() => view3D.MeshGroups.Count == 5, 3); Assert.AreEqual(5, view3D.MeshGroups.Count, "Should have 5 parts after Redo"); view3D.CloseOnIdle(); testRunner.Delay(.1); return(Task.FromResult(0)); }; await MatterControlUtilities.RunTest(testToRun, overrideWidth : 800); }
public async Task SaveAsToQueue() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); //Navigate to Local Library testRunner.ClickByName("Library Tab"); testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.Delay(1); testRunner.ClickByName("Row Item Calibration - Box"); MatterControlUtilities.LibraryEditSelectedItem(testRunner); SystemWindow systemWindow; GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3); View3DWidget view3D = partPreview as View3DWidget; for (int i = 0; i <= 2; i++) { testRunner.ClickByName("3D View Copy"); testRunner.Delay(.5); } //Click Save As button to save changes to the part testRunner.ClickByName("Save As Menu"); testRunner.Delay(1); testRunner.ClickByName("Save As Menu Item"); testRunner.Delay(1); //Type in name of new part and then save to Print Queue testRunner.Type("Save As Print Queue"); testRunner.NavigateToFolder("Print Queue Row Item Collection"); testRunner.Delay(1); testRunner.ClickByName("Save As Save Button"); view3D.CloseOnIdle(); testRunner.Delay(.5); //Make sure there is a new Queue item with a name that matches the new part testRunner.Delay(1); testRunner.ClickByName("Queue Tab"); testRunner.Delay(1); Assert.IsTrue(testRunner.WaitForName("Queue Item Save As Print Queue", 5)); return(Task.FromResult(0)); }; await MatterControlUtilities.RunTest(testToRun, overrideWidth : 600); }
public async Task UndoRedoCopy() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); SystemWindow systemWindow; // Navigate to Local Library testRunner.ClickByName("Library Tab"); testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.ClickByName("Row Item Calibration - Box"); MatterControlUtilities.LibraryEditSelectedItem(testRunner); // Get View3DWidget and count MeshGroups before Copy button is clicked View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3) as View3DWidget; for (int i = 0; i <= 4; i++) { testRunner.ClickByName("3D View Copy"); testRunner.Delay(() => view3D.MeshGroups.Count == i + 2, 2); Assert.AreEqual(i + 2, view3D.MeshGroups.Count); } testRunner.Delay(.2); for (int x = 0; x <= 4; x++) { int meshCountBeforeUndo = view3D.MeshGroups.Count; testRunner.ClickByName("3D View Undo"); testRunner.Delay(() => view3D.MeshGroups.Count == meshCountBeforeUndo - 1, 2); Assert.AreEqual(meshCountBeforeUndo - 1, view3D.MeshGroups.Count); } testRunner.Delay(.2); for (int z = 0; z <= 4; z++) { int meshCountBeforeRedo = view3D.MeshGroups.Count; testRunner.ClickByName("3D View Redo"); testRunner.Delay(() => view3D.MeshGroups.Count == meshCountBeforeRedo + 1, 2); Assert.AreEqual(meshCountBeforeRedo + 1, view3D.MeshGroups.Count); } return(Task.FromResult(0)); }; await MatterControlUtilities.RunTest(testToRun, overrideWidth : 640); }
private static void NudgeItem(View3DWidget view3D, IObject3D item, ArrowDirection arrowDirection, KeyEventArgs keyEvent) { var world = view3D.InteractionLayer.World; var vector3 = default(Vector3); // TODO: analyze the view and adjust movements to be relative to the current perspective // // Naive movements in Identity space switch (arrowDirection) { case ArrowDirection.Left: vector3 = new Vector3(-view3D.InteractionLayer.SnapGridDistance, 0, 0); break; case ArrowDirection.Right: vector3 = new Vector3(view3D.InteractionLayer.SnapGridDistance, 0, 0); break; case ArrowDirection.Up: if (keyEvent.Control) { vector3 = new Vector3(0, 0, view3D.InteractionLayer.SnapGridDistance); } else { vector3 = new Vector3(0, view3D.InteractionLayer.SnapGridDistance, 0); } break; case ArrowDirection.Down: if (keyEvent.Control) { vector3 = new Vector3(0, 0, -view3D.InteractionLayer.SnapGridDistance); } else { vector3 = new Vector3(0, -view3D.InteractionLayer.SnapGridDistance, 0); } break; } var matrix = world.GetXYInViewRotation(item.GetCenter()); item.Translate(vector3.Transform(matrix)); }
private static void Offset3DView(View3DWidget view3D, Vector2 offset, TrackBallTransformType operation) { var center = view3D.TrackballTumbleWidget.LocalBounds.Center; var oldState = view3D.TrackballTumbleWidget.TransformState; view3D.TrackballTumbleWidget.TransformState = operation; var mouseEvent = new MouseEventArgs(MouseButtons.Left, 1, center.X, center.Y, 0); view3D.TrackballTumbleWidget.OnMouseDown(mouseEvent); mouseEvent = new MouseEventArgs(mouseEvent, center.X + offset.X, center.Y + offset.Y); view3D.TrackballTumbleWidget.OnMouseMove(mouseEvent); view3D.TrackballTumbleWidget.OnMouseUp(mouseEvent); view3D.TrackballTumbleWidget.TransformState = oldState; view3D.TrackballTumbleWidget.Invalidate(); }
public async Task GroupAndUngroup() { await MatterControlUtilities.RunTest((testRunner) => { testRunner.CloseSignInAndPrinterSelect(); testRunner.OpenEmptyPartTab(); testRunner.AddItemToBedplate(); // Get View3DWidget and count Scene.Children before Copy button is clicked View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out _, 3) as View3DWidget; var scene = view3D.InteractionLayer.Scene; // Assert expected start count Assert.AreEqual(1, scene.Children.Count, "Should have one part before copy"); // Select scene object testRunner.Select3DPart("Calibration - Box.stl"); for (int i = 2; i <= 6; i++) { testRunner.ClickByName("Duplicate Button"); testRunner.WaitFor(() => scene.Children.Count == i); Assert.AreEqual(i, scene.Children.Count, $"Should have {i} parts after copy"); } // Get MeshGroupCount before Group is clicked Assert.AreEqual(6, scene.Children.Count, "Scene should have 6 parts after copy loop"); // Duplicate button moved to new container - move focus back to View3DWidget so CTRL-A below is seen by expected control testRunner.Select3DPart("Calibration - Box.stl"); // select all testRunner.Type("^a"); testRunner.ClickByName("Group Button"); testRunner.WaitFor(() => scene.Children.Count == 1); Assert.AreEqual(1, scene.Children.Count, $"Should have 1 parts after group"); testRunner.ClickByName("Ungroup Button"); testRunner.WaitFor(() => scene.Children.Count == 6); Assert.AreEqual(6, scene.Children.Count, $"Should have 6 parts after ungroup"); return(Task.CompletedTask); }, overrideWidth : 1300); }
public async Task LibraryQueueViewRefreshesOnAddItem() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); testRunner.ClickByName("Library Tab", 5); testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.Delay(1); testRunner.ClickByName("Row Item Calibration - Box"); testRunner.ClickByName("Row Item Calibration - Box View Button"); testRunner.Delay(1); SystemWindow systemWindow; GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3); View3DWidget view3D = partPreview as View3DWidget; testRunner.ClickByName("3D View Edit", 3); testRunner.ClickByName("3D View Copy", 3); // wait for the copy to finish testRunner.Delay(.1); testRunner.ClickByName("3D View Remove", 3); testRunner.ClickByName("Save As Menu", 3); testRunner.ClickByName("Save As Menu Item", 3); testRunner.Delay(1); testRunner.Type("0Test Part"); testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.ClickByName("Save As Save Button", 1); view3D.CloseOnIdle(); testRunner.Delay(.5); // ensure that it is now in the library folder (that the folder updated) Assert.IsTrue(testRunner.WaitForName("Row Item 0Test Part", 5), "The part we added should be in the library"); testRunner.Delay(.5); return(Task.FromResult(0)); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd : QueueTemplate.Three_Queue_Items, overrideWidth : 600); }
public async Task CopyButtonMakesCopyOfPart() { AutomationTest testToRun = (testRunner) => { SystemWindow systemWindow; testRunner.CloseSignInAndPrinterSelect(); // Navigate to Local Library testRunner.ClickByName("Library Tab"); testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.Delay(1); testRunner.ClickByName("Row Item Calibration - Box"); testRunner.ClickByName("Row Item Calibration - Box View Button"); testRunner.Delay(1); // Get View3DWidget View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3) as View3DWidget; // Click Edit button to make edit controls visible testRunner.ClickByName("3D View Edit"); testRunner.WaitForName("3D View Copy", 3); Assert.AreEqual(1, view3D.MeshGroups.Count, "Should have 1 part before copy"); // Click Copy button and count MeshGroups testRunner.ClickByName("3D View Copy"); testRunner.Delay(() => view3D.MeshGroups.Count == 2, 3); Assert.AreEqual(2, view3D.MeshGroups.Count, "Should have 2 parts after copy"); // Click Copy button a second time and count MeshGroups testRunner.ClickByName("3D View Copy"); testRunner.Delay(() => view3D.MeshGroups.Count == 3, 3); Assert.AreEqual(3, view3D.MeshGroups.Count, "Should have 3 parts after 2nd copy"); return(Task.FromResult(0)); }; await MatterControlUtilities.RunTest(testToRun, overrideWidth : 800); }
public async Task ScaleObjectWorksWithAndWithoutSheet() { await MatterControlUtilities.RunTest((testRunner) => { testRunner.OpenEmptyPartTab(); var primitive = "Cube"; var primitiveName = "Row Item " + primitive; testRunner.DoubleClickByName(primitiveName); // Get View3DWidget View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out _, 3) as View3DWidget; var scene = view3D.Object3DControlLayer.Scene; testRunner.WaitForName(primitive); Assert.AreEqual(1, scene.Children.Count, "Should have 1 part"); var cube = testRunner.GetObjectByName(primitive, out _) as CubeObject3D; Assert.AreEqual(20, cube.Width.Value(cube)); // Select scene object and add a scale testRunner.Select3DPart(primitive) .ClickByName("Scale Inner SplitButton") .ClickByName("Width Edit") .Type("25") .Type("{Enter}") .Delay(); var scale = testRunner.GetObjectByName("Scale", out _) as ScaleObject3D_3; var scaleAabb = scale.GetAxisAlignedBoundingBox(Matrix4X4.Identity); Assert.AreEqual(25, scaleAabb.XSize); // add a scale to the object return(Task.CompletedTask); }, overrideWidth : 1300, maxTimeToRun : 60); }
public void UndoRedoCopy() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages); { MatterControlUtilities.PrepForTestRun(testRunner); SystemWindow systemWindow; //Navigate to Local Library testRunner.ClickByName("Library Tab"); MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection"); testRunner.Wait(1); testRunner.ClickByName("Row Item Calibration - Box"); MatterControlUtilities.LibraryEditSelectedItem(testRunner); testRunner.Wait(1); //Get View3DWidget and count MeshGroups before Copy button is clicked GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3); View3DWidget view3D = partPreview as View3DWidget; string copyButtonName = "3D View Copy"; //Click Edit button to make edit controls visible testRunner.ClickByName("3D View Edit"); testRunner.Wait(1); int partCountBeforeCopy = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(partCountBeforeCopy == 1); for (int i = 0; i <= 4; i++) { testRunner.ClickByName(copyButtonName); testRunner.Wait(1); } testRunner.Wait(1); for (int x = 0; x <= 4; x++) { int meshCountBeforeUndo = view3D.MeshGroups.Count(); testRunner.ClickByName("3D View Undo"); System.Threading.Thread.Sleep(2000); int meshCountAfterUndo = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(meshCountAfterUndo == meshCountBeforeUndo - 1); } testRunner.Wait(1); for (int z = 0; z <= 4; z++) { int meshCountBeforeRedo = view3D.MeshGroups.Count(); testRunner.ClickByName("3D View Redo"); System.Threading.Thread.Sleep(2000); int meshCountAfterRedo = view3D.MeshGroups.Count(); resultsHarness.AddTestResult(meshCountAfterRedo == meshCountBeforeRedo + 1); } MatterControlUtilities.CloseMatterControl(testRunner); } }; AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 11); // make sure we ran all our tests }
public async Task DimensionsWorkWhenNoSheet() { await MatterControlUtilities.RunTest((testRunner) => { testRunner.OpenEmptyPartTab(); var primitive = "Cube"; var primitiveName = "Row Item " + primitive; testRunner.DoubleClickByName(primitiveName); // Get View3DWidget View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out _, 3) as View3DWidget; var scene = view3D.Object3DControlLayer.Scene; testRunner.WaitForName(primitive); Assert.AreEqual(1, scene.Children.Count, "Should have 1 part"); var cube = testRunner.GetObjectByName(primitive, out _) as CubeObject3D; Assert.AreEqual(20, cube.Width.Value(cube), .001); // Select scene object testRunner.Select3DPart(primitive); // Scale it wider testRunner.DragDropByName("ScaleWidthRight", "ScaleWidthRight", offsetDrag: new Point2D(0, 0), offsetDrop: new Point2D(0, 10)); Assert.Greater(cube.Width.Value(cube), 20.0); testRunner.ClickByName("3D View Undo"); Assert.AreEqual(20, cube.Width.Value(cube), .0001); // try scaling by text entry testRunner.ClickByName("ScaleWidthLeft") .ClickByName("XValueDisplay") .Type("35") .Type("{Enter}"); Assert.AreEqual(35, cube.Width.Value(cube)); testRunner.ClickByName("3D View Undo"); Assert.AreEqual(20, cube.Width.Value(cube), .0001); // try scaling by text entry of an equation testRunner.ClickByName("Width Field") .Type("=40 + 5") .Type("{Enter}"); Assert.AreEqual(45, cube.Width.Value(cube)); // Select Nothing testRunner.ClickByName("View3DWidget"); testRunner.SelectNone(); Assert.AreEqual(null, scene.SelectedItem); // and re-select the object testRunner.SelectAll(); Assert.AreEqual(1, scene.Children.Count); Assert.AreEqual(cube, scene.SelectedItem); // now that has an equation in the width it should not have an x edge controls Assert.IsFalse(testRunner.NameExists("ScaleWidthRight", .2)); testRunner.ClickByName("3D View Undo"); Assert.AreEqual(20, cube.Width.Value(cube), .0001); return(Task.CompletedTask); }, overrideWidth : 1300, maxTimeToRun : 60); }
// TODO: Figure out how best to collapse the InsertionGroup after the load task completes public InsertionGroupObject3D(IEnumerable <ILibraryItem> items, View3DWidget view3DWidget, InteractiveScene scene, Vector2 newItemOffset, Action <IObject3D, IEnumerable <IObject3D> > layoutParts, bool trackSourceFiles = false) { if (items == null) { return; } this.layoutParts = layoutParts; // Add a temporary placeholder to give us some bounds this.scene = scene; this.view3DWidget = view3DWidget; this.LoadingItemsTask = Task.Run(async() => { var offset = Matrix4X4.Identity; // Add the placeholder 'Loading...' object var placeholderItem = new Object3D() { Mesh = placeHolderMesh, Matrix = Matrix4X4.Identity, Parent = this }; this.Children.Add(placeholderItem); var itemsToLoad = items.Where(item => item.IsContentFileType()).ToList(); // Filter to content file types only foreach (var item in itemsToLoad) { // Acquire var progressControl = new DragDropLoadProgress(view3DWidget, null, ApplicationController.Instance.Theme); // Position at accumulating offset placeholderItem.Matrix *= Matrix4X4.CreateTranslation(newItemOffset.X, (double)newItemOffset.Y, 0); placeholderItem.Visible = true; progressControl.TrackingObject = placeholderItem; var loadedItem = await item.CreateContent(progressControl.ProgressReporter); if (loadedItem != null) { var aabb = loadedItem.GetAxisAlignedBoundingBox(); // lets move the cube to the center of the loaded thing placeholderItem.Matrix *= Matrix4X4.CreateTranslation(-10 + aabb.XSize / 2, 0, 0); placeholderItem.Visible = false; // Copy scale/rotation/translation from the source and Center loadedItem.Matrix = loadedItem.Matrix * Matrix4X4.CreateTranslation((double)-aabb.Center.X, (double)-aabb.Center.Y, (double)-aabb.MinXYZ.Z) * placeholderItem.Matrix; // check if the item has 0 height (it is probably an image) if (loadedItem.ZSize() == 0) { // raise it up a bit so it is not z fighting with the bed loadedItem.Matrix *= Matrix4X4.CreateTranslation(0, 0, .1); } loadedItem.Color = loadedItem.Color; // Set mesh path if tracking requested if (trackSourceFiles && item is FileSystemFileItem fileItem && item.IsMeshFileType()) { loadedItem.MeshPath = fileItem.Path; } this.Children.Add(loadedItem); loadedItem.MakeNameNonColliding(); // Adjust next item position newItemOffset.X = loadedItem.GetAxisAlignedBoundingBox().XSize / 2 + 10; } // the 1.3 is so the progress bar will collapse after going past 1 progressControl.ProgressReporter(1.3, ""); } this.Children.Remove(placeholderItem); this.Collapse(); this.Invalidate(InvalidateType.Children); }); }
// TODO: Figure out how best to collapse the InsertionGroup after the load task completes public InsertionGroupObject3D(IEnumerable <ILibraryItem> items, View3DWidget view3DWidget, InteractiveScene scene, Vector2 bedCenter, Func <bool> dragOperationActive, bool trackSourceFiles = false) { if (items == null) { return; } // Add a temporary placeholder to give us some bounds this.scene = scene; this.view3DWidget = view3DWidget; this.LoadingItemsTask = Task.Run((Func <Task>)(async() => { var newItemOffset = Vector2.Zero; if (dragOperationActive != null && !dragOperationActive()) { newItemOffset = bedCenter; } var offset = Matrix4X4.Identity; // Add the placeholder 'Loading...' object var placeholderItem = new Object3D() { Mesh = placeHolderMesh, Matrix = Matrix4X4.Identity, Parent = this }; this.Children.Add(placeholderItem); // Filter to content file types only foreach (var item in items.Where(item => item.IsContentFileType()).ToList()) { // Acquire var progressControl = new DragDropLoadProgress(view3DWidget, null); // Position at accumulating offset placeholderItem.Matrix *= Matrix4X4.CreateTranslation(newItemOffset.X, (double)newItemOffset.Y, 0); placeholderItem.Visible = true; progressControl.TrackingObject = placeholderItem; var loadedItem = await item.CreateContent(progressControl.ProgressReporter); if (loadedItem != null) { var aabb = loadedItem.GetAxisAlignedBoundingBox(Matrix4X4.Identity); // lets move the cube to the center of the loaded thing placeholderItem.Matrix *= Matrix4X4.CreateTranslation(-10 + aabb.XSize / 2, 0, 0); placeholderItem.Visible = false; // Copy scale/rotation/translation from the source and Center loadedItem.Matrix = loadedItem.Matrix * Matrix4X4.CreateTranslation((double)-aabb.Center.X, (double)-aabb.Center.Y, (double)-aabb.minXYZ.Z) * placeholderItem.Matrix; // check if the item has 0 height (it is probably an image) if (loadedItem.ZSize() == 0) { // raise it up a bit so it is not z fighting with the bed loadedItem.Matrix *= Matrix4X4.CreateTranslation(0, 0, .1); } loadedItem.Color = loadedItem.Color; // Set mesh path if tracking requested if (trackSourceFiles && item is FileSystemFileItem fileItem && item.IsMeshFileType()) { loadedItem.MeshPath = fileItem.Path; } // Notification should force invalidate and redraw //progressReporter?.Invoke(1, ""); this.Children.Add(loadedItem); loadedItem.MakeNameNonColliding(); // Wait for content to load // Adjust next item position // TODO: do something more interesting than increment in x newItemOffset.X = loadedItem.GetAxisAlignedBoundingBox(Matrix4X4.Identity).XSize / 2 + 10; } progressControl.ProgressReporter(1.3, ""); } this.Children.Remove(placeholderItem); this.ContentAcquired = true; ContentLoaded?.Invoke(this, null); if (dragOperationActive != null && !dragOperationActive()) { this.Collapse(); } this.Invalidate(new InvalidateArgs(this, InvalidateType.Content)); })); }