From 2a2a71726561b0921b25a3ac828e3495ed5ba886 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 28 Apr 2022 16:39:03 -0700 Subject: [PATCH] updating ui hints fixing issue with group --- .../ApplicationView/Application.cs | 18 +++++++++ .../ApplicationView/ApplicationController.cs | 7 +++- .../ApplicationView/SceneOperations.cs | 2 + .../CustomWidgets/SceneOperation.cs | 2 + .../DesignTools/Operations/GroupObject3D.cs | 37 +++++++++++++++++-- .../OperationSourceContainerObject3D.cs | 37 +++++++++++-------- .../View3D/Object3DControlsLayer.cs | 2 +- .../View3D/PrinterBar/PrintPopupMenu.cs | 2 + .../PartPreviewWindow/View3D/View3DWidget.cs | 14 +++++-- .../PartPreviewWindow/ViewToolBarControls.cs | 21 +++++++++++ MatterControlLib/SetupWizard/HelpTreePanel.cs | 6 +-- StaticData/Translations/Master.txt | 36 ++++++++++++++++++ Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 14 files changed, 157 insertions(+), 31 deletions(-) diff --git a/MatterControlLib/ApplicationView/Application.cs b/MatterControlLib/ApplicationView/Application.cs index 7f43686ed..0dd637eef 100644 --- a/MatterControlLib/ApplicationView/Application.cs +++ b/MatterControlLib/ApplicationView/Application.cs @@ -271,6 +271,24 @@ namespace MatterHackers.MatterControl break; + case Keys.G: + if (view3D.Printer == null + || (view3D.Printer != null && view3D.Printer.ViewState.ViewMode == PartViewMode.Model)) + { + var scene = view3D.sceneContext.Scene; + if (scene.SelectedItem != null + && scene.SelectedItem is SelectionGroupObject3D + && scene.SelectedItem.Children.Count > 1) + { + var group = new GroupHolesAppliedObject3D(); + group.WrapSelectedItemAndSelect(scene); + } + } + + keyEvent.Handled = true; + keyEvent.SuppressKeyPress = true; + break; + case Keys.Z: if (keyEvent.Control) { diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 62d17bde9..8b3c9f282 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -1518,8 +1518,11 @@ namespace MatterHackers.MatterControl set { - _uiHint = value; - UiHintChanged?.Invoke(this, null); + if (_uiHint != value) + { + _uiHint = value; + UiHintChanged?.Invoke(this, null); + } } } diff --git a/MatterControlLib/ApplicationView/SceneOperations.cs b/MatterControlLib/ApplicationView/SceneOperations.cs index 6f02c4b5e..84ef96751 100644 --- a/MatterControlLib/ApplicationView/SceneOperations.cs +++ b/MatterControlLib/ApplicationView/SceneOperations.cs @@ -1086,6 +1086,7 @@ namespace MatterHackers.MatterControl && scene.SelectedItem is SelectionGroupObject3D && scene.SelectedItem.Children.Count > 1, Icon = (theme) => StaticData.Instance.LoadIcon("group.png", 16, 16).SetPreMultiply(), + UiHint = "G Key".Localize(), }; } @@ -1324,6 +1325,7 @@ namespace MatterHackers.MatterControl IsEnabled = (sceneContext) => IsMeshObject(sceneContext.Scene.SelectedItem), ShowInModifyMenu = (sceneContext) => false, TitleGetter = () => "Remove".Localize(), + UiHint = "Delete Key".Localize(), }; } diff --git a/MatterControlLib/CustomWidgets/SceneOperation.cs b/MatterControlLib/CustomWidgets/SceneOperation.cs index 0183fbcfe..82d3cc22f 100644 --- a/MatterControlLib/CustomWidgets/SceneOperation.cs +++ b/MatterControlLib/CustomWidgets/SceneOperation.cs @@ -59,6 +59,8 @@ namespace MatterHackers.Agg.UI public string HelpText => this.HelpTextGetter?.Invoke(); + public string UiHint { get; set; } + public Func TitleGetter { get; set; } public string Title => this.TitleGetter?.Invoke(); diff --git a/MatterControlLib/DesignTools/Operations/GroupObject3D.cs b/MatterControlLib/DesignTools/Operations/GroupObject3D.cs index 690f014e4..cee1e16b1 100644 --- a/MatterControlLib/DesignTools/Operations/GroupObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/GroupObject3D.cs @@ -27,12 +27,13 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; +using MatterHackers.DataConverters3D.UndoCommands; using MatterHackers.Localizations; using MatterHackers.MatterControl.PartPreviewWindow.View3D; -using System; +using System.Collections.Generic; using System.Linq; -using System.Text.Json.Serialization; namespace MatterHackers.MatterControl.DesignTools.Operations { @@ -54,13 +55,43 @@ namespace MatterHackers.MatterControl.DesignTools.Operations Name = "Group".Localize(); } + public override void Apply(UndoBuffer undoBuffer) + { + using (RebuildLock()) + { + var newChildren = new List(); + // push our matrix into a copy of our children + foreach (var child in this.SourceContainer.Children) + { + var newChild = child.Clone(); + newChildren.Add(newChild); + newChild.Matrix *= this.Matrix; + } + + // and replace us with the children + var replaceCommand = new ReplaceCommand(new[] { this }, newChildren, maintainCenterAndZHeight: false); + + if (undoBuffer != null) + { + undoBuffer.AddAndDo(replaceCommand); + } + else + { + replaceCommand.Do(); + } + } + + Invalidate(InvalidateType.Children); + } + + [HideFromEditor] public override SelectedChildren SelectedChildren { get { var selections = new SelectedChildren(); - foreach(var child in SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf().Children.Where(i => i.WorldOutputType(this) == PrintOutputTypes.Hole)) + foreach(var child in SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf().Children.Where(i => i.WorldOutputType(this) == PrintOutputTypes.Hole && !(i is OperationSourceObject3D) )) { selections.Add(child.ID); } diff --git a/MatterControlLib/DesignTools/Primitives/OperationSourceContainerObject3D.cs b/MatterControlLib/DesignTools/Primitives/OperationSourceContainerObject3D.cs index 13fecc598..a17ac147a 100644 --- a/MatterControlLib/DesignTools/Primitives/OperationSourceContainerObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/OperationSourceContainerObject3D.cs @@ -80,37 +80,42 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } + private object locker = new object(); + [JsonIgnore] public IObject3D SourceContainer { get { - IObject3D sourceContainer = this.Children.FirstOrDefault(c => c is OperationSourceObject3D); - if (sourceContainer == null) + lock (locker) { - using (this.RebuildLock()) + IObject3D sourceContainer = this.Children.FirstOrDefault(c => c is OperationSourceObject3D); + if (sourceContainer == null) { - sourceContainer = new OperationSourceObject3D(); - - // Move all the children to sourceContainer - this.Children.Modify(thisChildren => + using (this.RebuildLock()) { - sourceContainer.Children.Modify(sourceChildren => + sourceContainer = new OperationSourceObject3D(); + + // Move all the children to sourceContainer + this.Children.Modify(thisChildren => { - foreach (var child in thisChildren) + sourceContainer.Children.Modify(sourceChildren => { - sourceChildren.Add(child); - } - }); + foreach (var child in thisChildren) + { + sourceChildren.Add(child); + } + }); // and then add the source container to this thisChildren.Clear(); - thisChildren.Add(sourceContainer); - }); + thisChildren.Add(sourceContainer); + }); + } } - } - return sourceContainer; + return sourceContainer; + } } } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs index 6211acc2a..c51ee6c1c 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs @@ -470,7 +470,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { ApplicationController.Instance.UiHint = "Click to edit values".Localize(); } - else + else if (ApplicationController.Instance.UiHint == "Click to edit values".Localize()) { ApplicationController.Instance.UiHint = ""; } diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs index 440b03cc5..9ef92b840 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs @@ -171,6 +171,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var errors = printer.Validate(); var startPrintButton = CreateStartPrintButton("Start Print".Localize(), printer, menuTheme, out bool printEnabled); + startPrintButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Ctrl + P".Localize(); + startPrintButton.MouseLeaveBounds += (s, e) => ApplicationController.Instance.UiHint = ""; startPrintButton.Click += (s, e) => this.CloseMenu(); var hasErrors = errors.Any(e => e.ErrorLevel == ValidationErrorLevel.Error); diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index bdf58848b..0ab12f566 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -361,7 +361,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ToolTipText = "Select Parts".Localize(), Margin = theme.ButtonSpacing, }; - + + partSelectButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Ctrl + A = Select Alll, 'Space' = Clear Selection, 'ESC' = Cancel Drag".Localize(); + partSelectButton.MouseLeaveBounds += (s, e) => ApplicationController.Instance.UiHint = ""; AddRoundButton(partSelectButton, RotatedMargin(partSelectButton, MathHelper.Tau * .15)); partSelectButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.PartSelect; buttonGroupA.Add(partSelectButton); @@ -372,7 +374,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ToolTipText = "Rotate View".Localize(), Margin = theme.ButtonSpacing }; - rotateButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Rotate: Right Mouse Button | Ctrl + Left Mouse Button".Localize(); + rotateButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Rotate: Right Mouse Button, Ctrl + Left Mouse Button, Arrow Keys".Localize(); rotateButton.MouseLeaveBounds += (s, e) => ApplicationController.Instance.UiHint = ""; AddRoundButton(rotateButton, RotatedMargin(rotateButton, MathHelper.Tau * .05)); rotateButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.Rotate; @@ -384,7 +386,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ToolTipText = "Move View".Localize(), Margin = theme.ButtonSpacing }; - translateButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Move: Middle Mouse Button | Ctrl + Shift + Left Mouse Button".Localize(); + translateButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Move: Middle Mouse Button, Ctrl + Shift + Left Mouse Button, Shift Arrow Keys".Localize(); translateButton.MouseLeaveBounds += (s, e) => ApplicationController.Instance.UiHint = ""; AddRoundButton(translateButton, RotatedMargin(translateButton , - MathHelper.Tau * .05)); translateButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.Translate; @@ -396,7 +398,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ToolTipText = "Zoom View".Localize(), Margin = theme.ButtonSpacing }; - zoomButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Zoom: Mouse Wheel | Ctrl + Alt + Left Mouse Button".Localize(); + zoomButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Zoom: Mouse Wheel, Ctrl + Alt + Left Mouse Button, Ctrl + '+' & Ctrl + '-'".Localize(); zoomButton.MouseLeaveBounds += (s, e) => ApplicationController.Instance.UiHint = ""; AddRoundButton(zoomButton, RotatedMargin(zoomButton, - MathHelper.Tau * .15)); zoomButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.Scale; @@ -468,6 +470,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ToolTipText = "Reset View".Localize(), Margin = theme.ButtonSpacing }; + homeButton.MouseEnterBounds += (s1, e1) => ApplicationController.Instance.UiHint = "W Key"; + homeButton.MouseLeaveBounds += (s1, e1) => ApplicationController.Instance.UiHint = ""; AddRoundButton(homeButton, RotatedMargin(homeButton, MathHelper.Tau * .3)).Click += (s, e) => viewControls3D.NotifyResetView(); var zoomToSelectionButton = new IconButton(StaticData.Instance.LoadIcon("select.png", 16, 16).SetToColor(theme.TextColor), theme) @@ -476,6 +480,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ToolTipText = "Zoom to Selection".Localize(), Margin = theme.ButtonSpacing }; + zoomToSelectionButton.MouseEnterBounds += (s1, e1) => ApplicationController.Instance.UiHint = "Z Key"; + zoomToSelectionButton.MouseLeaveBounds += (s1, e1) => ApplicationController.Instance.UiHint = ""; void SetZoomEnabled(object s, EventArgs e) { zoomToSelectionButton.Enabled = this.Scene.SelectedItem != null diff --git a/MatterControlLib/PartPreviewWindow/ViewToolBarControls.cs b/MatterControlLib/PartPreviewWindow/ViewToolBarControls.cs index bf49ffb20..380752770 100644 --- a/MatterControlLib/PartPreviewWindow/ViewToolBarControls.cs +++ b/MatterControlLib/PartPreviewWindow/ViewToolBarControls.cs @@ -131,6 +131,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Margin = theme.ButtonSpacing, VAnchor = VAnchor.Center }; + undoButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Ctrl + z".Localize(); + undoButton.MouseLeaveBounds += (s, e) => ApplicationController.Instance.UiHint = ""; undoButton.Click += (sender, e) => { sceneContext.Scene.Undo(); @@ -146,6 +148,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Enabled = false, VAnchor = VAnchor.Center }; + redoButton.MouseEnterBounds += (s, e) => ApplicationController.Instance.UiHint = "Ctrl + Y, Ctrl + Shift + Z".Localize(); + redoButton.MouseLeaveBounds += (s, e) => ApplicationController.Instance.UiHint = ""; redoButton.Click += (sender, e) => { sceneContext.Scene.Redo(); @@ -258,6 +262,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow HoverColor = theme.ToolbarButtonHover, MouseDownColor = theme.ToolbarButtonDown, }; + + if (!string.IsNullOrEmpty(namedAction.UiHint)) + { + button.MouseEnterBounds += (s1, e1) => ApplicationController.Instance.UiHint = namedAction.UiHint; + button.MouseLeaveBounds += (s1, e1) => ApplicationController.Instance.UiHint = ""; + } } else { @@ -423,6 +433,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } var operationButton = new OperationIconButton(operation, sceneContext, theme); + if (!string.IsNullOrEmpty(operation.UiHint)) + { + operationButton.MouseEnterBounds += (s1, e1) => ApplicationController.Instance.UiHint = operation.UiHint; + operationButton.MouseLeaveBounds += (s1, e1) => ApplicationController.Instance.UiHint = ""; + } operationButtons.Add(operationButton, operation); buttonGroup.AddChild(operationButton); @@ -484,6 +499,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow iconButton.SetIcon(operation.Icon(theme)); iconButton.ToolTipText = operation.HelpText ?? operation.Title; + if (!string.IsNullOrEmpty(operation.UiHint)) + { + iconButton.MouseEnterBounds += (s1, e1) => ApplicationController.Instance.UiHint = operation.UiHint; + iconButton.MouseLeaveBounds += (s1, e1) => ApplicationController.Instance.UiHint = ""; + } + UserSettings.Instance.set(operationGroup.GroupRecordId, operationGroup.Operations.IndexOf(operation).ToString()); defaultOperation = operation; diff --git a/MatterControlLib/SetupWizard/HelpTreePanel.cs b/MatterControlLib/SetupWizard/HelpTreePanel.cs index fa3c243bf..066750184 100644 --- a/MatterControlLib/SetupWizard/HelpTreePanel.cs +++ b/MatterControlLib/SetupWizard/HelpTreePanel.cs @@ -158,16 +158,16 @@ namespace MatterHackers.MatterControl ("ctrl + -","Zoom out".Localize()), ("← → ↑ ↓","Rotate".Localize()), ("shift + ← → ↑ ↓","Pan".Localize()), - //("f","Zoom to fit".Localize()), ("w","Zoom to window".Localize()), ("z","Zoom to selection".Localize()), + ("ctrl + a","Select all".Localize()), + ("space bar","Clear selection".Localize()), + ("esc","Cancel command".Localize()), ("ctrl + s","Save".Localize()), ("ctrl + z","Undo".Localize()), ("ctrl + y","Redo".Localize()), ("ctrl + p","Print".Localize()), ("delete","Delete selection".Localize()), - ("space bar","Clear selection".Localize()), - ("esc","Cancel command".Localize()), //("enter","Accept command".Localize()) }); diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index ad48a10c9..9e0dc0286 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -1150,6 +1150,18 @@ Translated:Creating Threads English:Creation Data Translated:Creation Data +English:Ctrl + A = Select Alll, 'Space' = Clear Selection, 'ESC' = Cancel Drag +Translated:Ctrl + A = Select Alll, 'Space' = Clear Selection, 'ESC' = Cancel Drag + +English:Ctrl + Y | Ctrl + Shift + Z +Translated:Ctrl + Y | Ctrl + Shift + Z + +English:Ctrl + Y, Ctrl + Shift + Z +Translated:Ctrl + Y, Ctrl + Shift + Z + +English:Ctrl + z +Translated:Ctrl + z + English:Cube Translated:Cube @@ -1204,6 +1216,9 @@ Translated:Define New English:Delete Translated:Delete +English:Delete Key +Translated:Delete Key + English:Delete Printer Translated:Delete Printer @@ -1933,6 +1948,9 @@ Translated:Fuzzy Frequency English:Fuzzy Thickness Translated:Fuzzy Thickness +English:G Key +Translated:G Key + English:g/cm³ Translated:g/cm³ @@ -2968,6 +2986,12 @@ Translated:Move Z positive English:Move: Middle Mouse Button | Ctrl + Shift + Left Mouse Button Translated:Move: Middle Mouse Button | Ctrl + Shift + Left Mouse Button +English:Move: Middle Mouse Button | Ctrl + Shift + Left Mouse Button | Shift Arrow Keys +Translated:Move: Middle Mouse Button | Ctrl + Shift + Left Mouse Button | Shift Arrow Keys + +English:Move: Middle Mouse Button, Ctrl + Shift + Left Mouse Button, Shift Arrow Keys +Translated:Move: Middle Mouse Button, Ctrl + Shift + Left Mouse Button, Shift Arrow Keys + English:Movement Translated:Movement @@ -4153,6 +4177,12 @@ Translated:Rotate View English:Rotate: Right Mouse Button | Ctrl + Left Mouse Button Translated:Rotate: Right Mouse Button | Ctrl + Left Mouse Button +English:Rotate: Right Mouse Button | Ctrl + Left Mouse Button | Arrow Keys +Translated:Rotate: Right Mouse Button | Ctrl + Left Mouse Button | Arrow Keys + +English:Rotate: Right Mouse Button, Ctrl + Left Mouse Button, Arrow Keys +Translated:Rotate: Right Mouse Button, Ctrl + Left Mouse Button, Arrow Keys + English:Rotation Distance Translated:Rotation Distance @@ -6403,3 +6433,9 @@ Translated:Zoom View English:Zoom: Mouse Wheel | Ctrl + Alt + Left Mouse Button Translated:Zoom: Mouse Wheel | Ctrl + Alt + Left Mouse Button +English:Zoom: Mouse Wheel | Ctrl + Alt + Left Mouse Button | Ctrl + '+' & Ctrl + '-' +Translated:Zoom: Mouse Wheel | Ctrl + Alt + Left Mouse Button | Ctrl + '+' & Ctrl + '-' + +English:Zoom: Mouse Wheel, Ctrl + Alt + Left Mouse Button, Ctrl + '+' & Ctrl + '-' +Translated:Zoom: Mouse Wheel, Ctrl + Alt + Left Mouse Button, Ctrl + '+' & Ctrl + '-' + diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index d318d70f3..389d7aa2b 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit d318d70f3f2772d1b987a63291a1860c7dfc04f9 +Subproject commit 389d7aa2b2a790792b847814cf1702d4e562e5e4 diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 9e115e537..e525a40b0 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 9e115e5373d44f9cc7fdcee0e3290b1e88c39970 +Subproject commit e525a40b09db6c88c20742fd51c2215cc5bfc0a5