From 7f9ca45fc92bcbe6de63491b6d68544c3e49d029 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 12 Jan 2018 09:40:52 -0800 Subject: [PATCH] Made update button work better on subtract --- ApplicationView/ApplicationController.cs | 2 +- .../View3D/Actions/SubtractAndReplace.cs | 19 ++++++++++++++----- .../View3D/Actions/SubtractEditor.cs | 17 ++++++++++++++--- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 34ce646ab..0c43e7769 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -358,7 +358,6 @@ namespace MatterHackers.MatterControl Icon = AggContext.StaticData.LoadIcon("intersect.png"), IsEnabled = (scene) => scene.SelectedItem is SelectionGroup, }, -#if DEBUG // keep this work in progress to the editor for now new SceneSelectionOperation() { TitleResolver = () => "Subtract & Replace".Localize(), @@ -366,6 +365,7 @@ namespace MatterHackers.MatterControl Icon = AggContext.StaticData.LoadIcon("paint.png").SetPreMultiply(), IsEnabled = (scene) => scene.SelectedItem is SelectionGroup, }, +#if DEBUG // keep this work in progress to the editor for now new SceneSelectionOperation() { TitleResolver = () => "Make Support".Localize(), diff --git a/PartPreviewWindow/View3D/Actions/SubtractAndReplace.cs b/PartPreviewWindow/View3D/Actions/SubtractAndReplace.cs index f710753f4..59402e81d 100644 --- a/PartPreviewWindow/View3D/Actions/SubtractAndReplace.cs +++ b/PartPreviewWindow/View3D/Actions/SubtractAndReplace.cs @@ -40,7 +40,6 @@ using MatterHackers.PolygonMesh; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { -#if DEBUG // keep this work in progress to the editor for now public class SubtractAndReplace : IObject3DEditor { private MeshWrapperOperation group; @@ -108,10 +107,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { // make sure the mesh on the group is not visible group.ResetMeshWrappers(); + updateButton.Enabled = false; ProcessBooleans(group); }; - int checkedCount = 0; List radioSiblings = new List(); for (int i = 0; i < children.Count; i++) { @@ -161,10 +160,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D }; tabContainer.AddChild(rowContainer); - checkedCount += checkBox.Checked ? 1 : 0; } - if(checkedCount == 0) // no items selected + bool opperationApplied = group.Descendants() + .Where((obj) => obj.OwnerID == group.ID) + .Where((objId) => objId.Mesh != objId.Children.First().Mesh).Count() > 0; + + bool selectionHasBeenMade = group.Descendants() + .Where((obj) => obj.OwnerID == group.ID) + .Where((objId) => objId.OutputType == PrintOutputTypes.Hole).Count() > 0; + + if (!opperationApplied && !selectionHasBeenMade) { // select the last item if (tabContainer.Decendants().Where((d) => d is ICheckbox).Last() is ICheckbox firstCheckBox) @@ -172,6 +178,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D firstCheckBox.Checked = true; } } + else + { + updateButton.Enabled = opperationApplied; + } // add this last so it is at the bottom tabContainer.AddChild(updateButton); @@ -248,5 +258,4 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D }); } } -#endif } \ No newline at end of file diff --git a/PartPreviewWindow/View3D/Actions/SubtractEditor.cs b/PartPreviewWindow/View3D/Actions/SubtractEditor.cs index 24a068d4f..c4d382920 100644 --- a/PartPreviewWindow/View3D/Actions/SubtractEditor.cs +++ b/PartPreviewWindow/View3D/Actions/SubtractEditor.cs @@ -88,10 +88,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { // make sure the mesh on the group is not visible group.ResetMeshWrappers(); + updateButton.Enabled = false; ProcessBooleans(group); }; - int checkedCount = 0; List radioSiblings = new List(); for (int i = 0; i < children.Count; i++) { @@ -141,10 +141,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D }; tabContainer.AddChild(rowContainer); - checkedCount += checkBox.Checked ? 1 : 0; } - if (checkedCount == 0) // no items selected + bool opperationApplied = group.Descendants() + .Where((obj) => obj.OwnerID == group.ID) + .Where((objId) => objId.Mesh != objId.Children.First().Mesh).Count() > 0; + + bool selectionHasBeenMade = group.Descendants() + .Where((obj) => obj.OwnerID == group.ID) + .Where((objId) => objId.OutputType == PrintOutputTypes.Hole).Count() > 0; + + if (!opperationApplied && !selectionHasBeenMade) { // select the last item if (tabContainer.Decendants().Where((d) => d is ICheckbox).Last() is ICheckbox firstCheckBox) @@ -152,6 +159,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D firstCheckBox.Checked = true; } } + else + { + updateButton.Enabled = !opperationApplied; + } // add this last so it is at the bottom tabContainer.AddChild(updateButton);