From cb8a942e0850ff01b9c24b7fb91fc1f6042d7ece Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 22 Mar 2022 17:26:21 -0700 Subject: [PATCH] Made ImageConverter test pass --- MatterControl.Winforms/InspectForm.cs | 64 +++++++--- .../PartPreviewWindow/SectionWidget.cs | 2 +- Submodules/agg-sharp | 2 +- .../ReSliceTests.cs | 109 ++++++++---------- .../MatterControl/MatterControlUtilities.cs | 2 +- 5 files changed, 97 insertions(+), 82 deletions(-) diff --git a/MatterControl.Winforms/InspectForm.cs b/MatterControl.Winforms/InspectForm.cs index 219dbcb2a..31748f05a 100644 --- a/MatterControl.Winforms/InspectForm.cs +++ b/MatterControl.Winforms/InspectForm.cs @@ -1,28 +1,54 @@ -using System; +/* +Copyright (c) 2022, Lars Brubaker, John Lewin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. +*/ + +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; -using System.Text; using System.Windows.Forms; using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.MatterControl.PartPreviewWindow; -using MatterHackers.MatterControl.PrinterCommunication.Io; -using MatterHackers.MeshVisualizer; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl { public partial class InspectForm : WinformsSystemWindow.FormInspector { - private System.Windows.Forms.TreeNode activeTreeNode; + private TreeNode activeTreeNode; private GuiWidget inspectedSystemWindow; private Vector2 mousePosition; - private Dictionary aggTreeNodes = new Dictionary(); - private Dictionary sceneTreeNodes = new Dictionary(); + private Dictionary aggTreeNodes = new Dictionary(); + private Dictionary sceneTreeNodes = new Dictionary(); private InteractiveScene scene; private View3DWidget view3DWidget; @@ -119,7 +145,7 @@ namespace MatterHackers.MatterControl activeTreeNode.Checked = false; } - if (aggTreeNodes.TryGetValue(_inspectedWidget, out System.Windows.Forms.TreeNode treeNode)) + if (aggTreeNodes.TryGetValue(_inspectedWidget, out TreeNode treeNode)) { aggTreeView.SelectedNode = treeNode; @@ -156,14 +182,14 @@ namespace MatterHackers.MatterControl } } - private void AddItemEnsureAncestors(GuiWidget widget, string text = null, System.Windows.Forms.TreeNode childNode = null, bool showAllParents = true) + private void AddItemEnsureAncestors(GuiWidget widget, string text = null, TreeNode childNode = null, bool showAllParents = true) { if (text == null) { text = BuildDefaultName(widget); } - if (aggTreeNodes.TryGetValue(widget, out System.Windows.Forms.TreeNode existingNode)) + if (aggTreeNodes.TryGetValue(widget, out TreeNode existingNode)) { if (childNode != null) { @@ -173,7 +199,7 @@ namespace MatterHackers.MatterControl } else { - var node = new System.Windows.Forms.TreeNode(text) + var node = new TreeNode(text) { Tag = widget }; @@ -204,9 +230,9 @@ namespace MatterHackers.MatterControl } } - private TreeNode AddItem(GuiWidget widget, System.Windows.Forms.TreeNode parentNode) + private TreeNode AddItem(GuiWidget widget, TreeNode parentNode) { - var node = new System.Windows.Forms.TreeNode(BuildDefaultName(widget)) + var node = new TreeNode(BuildDefaultName(widget)) { Tag = widget }; @@ -226,9 +252,9 @@ namespace MatterHackers.MatterControl return node; } - private TreeNode AddItem(IObject3D item, System.Windows.Forms.TreeNode parentNode) + private TreeNode AddItem(IObject3D item, TreeNode parentNode) { - var node = new System.Windows.Forms.TreeNode(BuildDefaultName(item)) + var node = new TreeNode(BuildDefaultName(item)) { Tag = item }; @@ -249,7 +275,7 @@ namespace MatterHackers.MatterControl return node; } - private void AddTree(GuiWidget widget, System.Windows.Forms.TreeNode parent) + private void AddTree(GuiWidget widget, TreeNode parent) { var node = AddItem(widget, parent); @@ -259,7 +285,7 @@ namespace MatterHackers.MatterControl } } - private void AddTree(IObject3D item, System.Windows.Forms.TreeNode parent) + private void AddTree(IObject3D item, TreeNode parent) { var node = AddItem(item, parent); @@ -322,7 +348,7 @@ namespace MatterHackers.MatterControl public void MoveUpTree() { - if (activeTreeNode?.Parent is System.Windows.Forms.TreeNode parent) + if (activeTreeNode?.Parent is TreeNode parent) { this.InspectedWidget = parent.Tag as GuiWidget; } @@ -330,7 +356,7 @@ namespace MatterHackers.MatterControl public void MoveDownTree() { - if (activeTreeNode?.Nodes.Cast().FirstOrDefault() is System.Windows.Forms.TreeNode firstChild) + if (activeTreeNode?.Nodes.Cast().FirstOrDefault() is TreeNode firstChild) { this.InspectedWidget = firstChild.Tag as GuiWidget; } diff --git a/MatterControlLib/PartPreviewWindow/SectionWidget.cs b/MatterControlLib/PartPreviewWindow/SectionWidget.cs index ab021865b..859c72cd5 100644 --- a/MatterControlLib/PartPreviewWindow/SectionWidget.cs +++ b/MatterControlLib/PartPreviewWindow/SectionWidget.cs @@ -79,7 +79,7 @@ namespace MatterHackers.MatterControl.CustomWidgets checkbox.CheckedStateChanged += (s, e) => { - var scrollable = this.Parents().First(); + var scrollable = this.Parents().FirstOrDefault(); var topPosition = Vector2.Zero; if (scrollable != null) { diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 068334475..e6ab6cc55 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 0683344758e8784f1ce10fb51b34dcf0a1c3c158 +Subproject commit e6ab6cc55ca02e6527da36e9a188bad9aa23b318 diff --git a/Tests/MatterControl.AutomationTests/ReSliceTests.cs b/Tests/MatterControl.AutomationTests/ReSliceTests.cs index 4d462854d..8e25765f2 100644 --- a/Tests/MatterControl.AutomationTests/ReSliceTests.cs +++ b/Tests/MatterControl.AutomationTests/ReSliceTests.cs @@ -86,73 +86,62 @@ namespace MatterHackers.MatterControl.Tests.Automation }; // Add a cube to the bed - testRunner.NavigateToFolder("Queue Row Item Collection"); - testRunner.ClickByName("Row Item cube_20x20x20.stl"); - testRunner.ClickByName("Print Library Overflow Menu"); - testRunner.ClickByName("Add to Bed Menu Item"); - testRunner.ClickByName("Print Library Overflow Menu"); - testRunner.ClickByName("Add to Bed Menu Item"); - - // start the print - testRunner.StartPrint(printer, pauseAtLayers: "50;60"); - - // Wait for pause - testRunner.WaitForName("No Button", 80); // the yes button is 'Resume' - testRunner.ClickByName("No Button"); - - // Delete the cube - testRunner.ClickByName("Bed Options Menu"); - testRunner.ClickByName("Clear Bed Menu Item"); - - testRunner.Delay(); - - // ensure there is nothing on the bed + testRunner.NavigateToFolder("Queue Row Item Collection") + .ClickByName("Row Item cube_20x20x20.stl") + .ClickByName("Print Library Overflow Menu") + .ClickByName("Add to Bed Menu Item") + .Delay() + .ClickByName("Print Library Overflow Menu") + .Delay() + .ClickByName("Add to Bed Menu Item") + .Delay() + // start the print + .StartPrint(printer, pauseAtLayers: "50;60") + // Wait for pause + // the yes button is 'Resume' + .ClickByName("No Button", secondsToWait: 80) + // Delete the cube + .ClickByName("Bed Options Menu") + .ClickByName("Clear Bed Menu Item") + .Delay(); + // ensure there is nothing on the bed Assert.AreEqual(0, scene.Children.Count); // Add a cylinder - testRunner.NavigateToFolder("Queue Row Item Collection"); - testRunner.ClickByName("Row Item cylinder_5x20.stl"); - testRunner.ClickByName("Print Library Overflow Menu"); - testRunner.ClickByName("Add to Bed Menu Item"); - testRunner.ClickByName("Add Content Menu"); - - // re-slice the part - testRunner.ClickByName("Re-Slice Button"); - testRunner.WaitForName("Switch Button", 10); // The change to new g-code - testRunner.ClickByName("Switch Button"); - - // and resume the print - testRunner.ClickByName("Resume Task Button"); - - // Wait for next pause - testRunner.WaitForName("No Button", 80); // the yes button is 'Resume' - testRunner.ClickByName("No Button"); - - // Switch back to the cube - // Delete the cylinder - testRunner.ClickByName("Bed Options Menu"); - testRunner.ClickByName("Clear Bed Menu Item"); - + testRunner.NavigateToFolder("Queue Row Item Collection") + .ClickByName("Row Item cylinder_5x20.stl") + .ClickByName("Print Library Overflow Menu") + .ClickByName("Add to Bed Menu Item") + .ClickByName("Add Content Menu") + // re-slice the part + .ClickByName("Re-Slice Button") + // The change to new g-code + .ClickByName("Switch Button", secondsToWait: 10) + // and resume the print + .ClickByName("Resume Task Button") + // Wait for next pause + .ClickByName("No Button", secondsToWait: 80) + // Switch back to the cube + // Delete the cylinder + .ClickByName("Bed Options Menu") + .ClickByName("Clear Bed Menu Item"); + // ensure there is nothing on the bed Assert.AreEqual(0, scene.Children.Count); // add the cube - testRunner.NavigateToFolder("Queue Row Item Collection"); - testRunner.ClickByName("Row Item cube_20x20x20.stl"); - testRunner.ClickByName("Print Library Overflow Menu"); - testRunner.ClickByName("Add to Bed Menu Item"); - testRunner.ClickByName("Add Content Menu"); - - // re-slice the part - testRunner.ClickByName("Re-Slice Button"); - testRunner.WaitForName("Switch Button", 10); // The change to new g-code - testRunner.ClickByName("Switch Button"); - - // and resume the print - testRunner.ClickByName("Resume Task Button"); - - // Wait for done - testRunner.WaitForPrintFinished(printer); + testRunner.NavigateToFolder("Queue Row Item Collection") + .ClickByName("Row Item cube_20x20x20.stl") + .ClickByName("Print Library Overflow Menu") + .ClickByName("Add to Bed Menu Item") + .ClickByName("Add Content Menu") + // re-slice the part + .ClickByName("Re-Slice Button") + .ClickByName("Switch Button", secondsToWait: 10) + // and resume the print + .ClickByName("Resume Task Button") + // Wait for done + .WaitForPrintFinished(printer); // this will make sure we turned off line splitting and had good data about the extruder position Assert.AreEqual(-7, largestRetraction, "Airwolf HD has a retraction of 7mm, make sure we had one"); diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index d7b1bc64a..080e3b553 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -829,7 +829,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder(containerName); } - var partWidget = testRunner.GetWidgetByName(partName, out _) as ListViewItemBase; + var partWidget = testRunner.GetWidgetByName(partName, out _, onlyVisible: false) as ListViewItemBase; if (!partWidget.IsSelected) { testRunner.ScrollIntoView(partName);