From 8cac6069b465c7bed0476aa1c3a67d43865154ce Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 28 Oct 2022 18:00:19 -0700 Subject: [PATCH 1/2] Better name validation --- .../View3D/Actions/SheetEditor.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SheetEditor.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SheetEditor.cs index d01b45db5..ce1dd1a46 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SheetEditor.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SheetEditor.cs @@ -164,14 +164,22 @@ namespace MatterHackers.MatterControl.DesignTools var currentName = SheetData[x, y].Name; if (!string.IsNullOrEmpty(currentName)) { - existingNames.Add(currentName); + existingNames.Add(currentName.ToLower()); } } } } - // first replace spaces with '_' - var name = editSelectedName.Text.Replace(' ', '_'); + var reservedWords = new string[] { "pi", "e", "true", "false", "round" }; + + // add all the reserved words to the existing names + foreach (var reservedWord in reservedWords) + { + existingNames.Add(reservedWord); + } + + // first replace spaces with '_' + var name = editSelectedName.Text.Replace(' ', '_'); // next make sure we don't have the exact name already name = agg_basics.GetNonCollidingName(name, existingNames, false); editSelectedName.Text = name; From 3a5cf179fd95700c972eeceedf58649b8ca997f3 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 4 Nov 2022 11:38:09 -0700 Subject: [PATCH 2/2] Fixing bad intersection tests on close geometry --- MatterControlLib/PartPreviewWindow/Tabs.cs | 9 +++++---- .../PartPreviewWindow/View3D/View3DWidget.cs | 12 +++++++++--- Submodules/agg-sharp | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/MatterControlLib/PartPreviewWindow/Tabs.cs b/MatterControlLib/PartPreviewWindow/Tabs.cs index c6f445e39..9aca0eafe 100644 --- a/MatterControlLib/PartPreviewWindow/Tabs.cs +++ b/MatterControlLib/PartPreviewWindow/Tabs.cs @@ -504,9 +504,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow "Cancel Print".Localize(), "Continue Printing".Localize()); } - else if (this.TabContent is DesignTabPage partTab - && partTab?.Workspace?.SceneContext?.Scene is InteractiveScene scene - && scene.HasUnsavedChanges) + else if (this.TabContent is DesignTabPage partTab // we are a part tap + && partTab?.Workspace?.SceneContext is ISceneContext sceneContext // we have a context + && sceneContext.Scene is InteractiveScene scene // we have a scene + && scene.HasUnsavedChanges // we have unsaved changes + && (sceneContext.EditContext.ContentStore != null || scene.Descendants().Count() > 0)) // we are not an unsaved empty tab (new with only deleting phil) { StyledMessageBox.ShowYNCMessageBox( (response) => @@ -516,7 +518,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow case StyledMessageBox.ResponseType.YES: UiThread.RunOnIdle(async () => { - var sceneContext = partTab.Workspace.SceneContext; if (sceneContext.EditContext.ContentStore == null) { // If we are about to close a tab that has never been saved it will need a name before it can actually save diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index 0670d84ca..63257f71b 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -2225,9 +2225,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if (object3D.GetBVHData().Contains(intersectionInfo.HitPosition)) { - CurrentSelectInfo.PlaneDownHitPos = intersectionInfo.HitPosition; - CurrentSelectInfo.LastMoveDelta = default(Vector3); - return object3D; + // run the same hit on this object only and see if is still the same position + var singleObjectIntersection = object3D.GetBVHData().GetClosestIntersection(ray); + if (singleObjectIntersection != null + && singleObjectIntersection.HitPosition == intersectionInfo.HitPosition) + { + CurrentSelectInfo.PlaneDownHitPos = intersectionInfo.HitPosition; + CurrentSelectInfo.LastMoveDelta = default(Vector3); + return object3D; + } } } } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 03768ac14..4008f642a 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 03768ac1437d052a39a0945204e80625ad1cad80 +Subproject commit 4008f642a465afdc229322751629391b8a729507