diff --git a/MatterControl.Printing/Settings/PrinterSettings.cs b/MatterControl.Printing/Settings/PrinterSettings.cs index cd994f0f9..3f4fb6f75 100644 --- a/MatterControl.Printing/Settings/PrinterSettings.cs +++ b/MatterControl.Printing/Settings/PrinterSettings.cs @@ -45,40 +45,30 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public enum BedShape { Rectangular, - Circular } + [JsonConverter(typeof(StringEnumConverter))] public enum LevelingSystem { Probe3Points, - Probe7PointRadial, - Probe13PointRadial, - Probe100PointRadial, - Probe3x3Mesh, - Probe5x5Mesh, - Probe10x10Mesh, - ProbeCustom } + public enum NamedSettingsLayers { MHBaseSettings, - OEMSettings, - Quality, - Material, - + Scene, User, - All } @@ -427,6 +417,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration yield return this.UserLayer; } + var sceneLayer = this.GetSceneLayer?.Invoke(); + if (sceneLayer != null) + { + yield return sceneLayer; + } + if (this.MaterialLayer != null) { yield return this.MaterialLayer; @@ -479,7 +475,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public List MaterialLayers { get; set; } = new List(); - public PrinterSettingsLayer OemLayer { get; set; } + public PrinterSettingsLayer OemLayer { get; set; } = new PrinterSettingsLayer(); [JsonIgnore] public bool PrinterSelected => OemLayer?.Keys.Count > 0; @@ -506,6 +502,25 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } + [JsonIgnore] + public IEnumerable SceneLayerCascade + { + get + { + if (this.SceneLayer != null) + { + yield return this.SceneLayer; + } + + if (this.OemLayer != null) + { + yield return this.OemLayer; + } + + yield return this.BaseLayer; + } + } + public List QualityLayers { get; private set; } = new List(); [JsonIgnore] @@ -546,6 +561,20 @@ namespace MatterHackers.MatterControl.SlicerConfiguration /// public PrinterSettingsLayer UserLayer { get; private set; } = new PrinterSettingsLayer(); + public PrinterSettingsLayer SceneLayer + { + get + { + return GetSceneLayer?.Invoke(); + } + } + + /// + /// Scene settings override (this comes from a SliceSettingsObject3D being in the scene + /// + [JsonIgnore] + public Func GetSceneLayer; + public static PrinterSettings LoadFile(string printerProfilePath, bool performMigrations = false) { if (performMigrations) @@ -891,6 +920,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { return layer[sliceSetting]; } + else if (layer == this.SceneLayer + && layer.ContainsKey(sliceSetting)) + { + return layer[sliceSetting]; + } } return null; @@ -1332,7 +1366,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } else if (typeof(T) == typeof(BedShape)) { - switch (GetValue(settingsKey)) + switch (GetValue(settingsKey, layerCascade)) { case "rectangular": return (T)(object)BedShape.Rectangular; @@ -1342,7 +1376,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration default: #if DEBUG - throw new NotImplementedException("{0} is not a known bed_shape.".FormatWith(GetValue(SettingsKey.bed_shape))); + throw new NotImplementedException("{0} is not a known bed_shape.".FormatWith(GetValue(SettingsKey.bed_shape, layerCascade))); #else return (T)(object)BedShape.Rectangular; #endif @@ -1378,6 +1412,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration case NamedSettingsLayers.Material: return MaterialLayer?.ContainsKey(sliceSetting) == true; + case NamedSettingsLayers.Scene: + return SceneLayer?.ContainsKey(sliceSetting) == true; + case NamedSettingsLayers.User: return UserLayer?.ContainsKey(sliceSetting) == true; diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 14f7af2cd..f3effc385 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -553,9 +553,8 @@ namespace MatterHackers.MatterControl // Returns the authentication dialog from the authentication plugin public static Func GetAuthPage; - public SlicePresetsPage EditMaterialPresetsPage { get; set; } + public SlicePresetsPage AcitveSlicePresetsPage { get; set; } - public SlicePresetsPage EditQualityPresetsWindow { get; set; } public MainViewWidget MainView; diff --git a/MatterControlLib/ApplicationView/Config/PrinterConfig.cs b/MatterControlLib/ApplicationView/Config/PrinterConfig.cs index dcbe0af71..e56b9d267 100644 --- a/MatterControlLib/ApplicationView/Config/PrinterConfig.cs +++ b/MatterControlLib/ApplicationView/Config/PrinterConfig.cs @@ -38,6 +38,8 @@ using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.VectorMath; using Newtonsoft.Json; using System.Linq; +using MatterHackers.DataConverters3D; +using MatterHackers.MatterControl.DesignTools.Operations; namespace MatterHackers.MatterControl { @@ -65,10 +67,26 @@ namespace MatterHackers.MatterControl return !printingOrPause && !errors.Any(err => err.ErrorLevel == ValidationErrorLevel.Error); } + private PrinterSettingsLayer GetSceneLayer() + { + var scene = Bed?.Scene; + if (scene != null) + { + if (scene.DescendantsAndSelf().Where(c => c is PartSettingsObject3D).FirstOrDefault() is PartSettingsObject3D partSettingsObject3D) + { + return partSettingsObject3D.Overrides; + } + } + + return null; + } + public PrinterConfig(PrinterSettings settings) { this.Settings = settings; + settings.GetSceneLayer = GetSceneLayer; + this.Bed = new BedConfig(ApplicationController.Instance.Library.PlatingHistory, this); this.ViewState = new PrinterViewState(); diff --git a/MatterControlLib/ApplicationView/SettingsValidation.cs b/MatterControlLib/ApplicationView/SettingsValidation.cs index 6a784d3b5..38dc2f8b0 100644 --- a/MatterControlLib/ApplicationView/SettingsValidation.cs +++ b/MatterControlLib/ApplicationView/SettingsValidation.cs @@ -81,6 +81,7 @@ namespace MatterHackers.MatterControl // Check to see if current OEM layer matches downloaded OEM layer { if (settingsContext.GetValue(SettingsKey.make) != "Other" + && settingsContext.GetValue(SettingsKey.make) != "Undefined" && ProfileManager.GetOemSettingsNeedingUpdate(printer).Any()) { errors.Add(new ValidationError(ValidationErrors.SettingsUpdateAvailable) diff --git a/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs b/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs index 85fdb771b..6ba63cdd5 100644 --- a/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs +++ b/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs @@ -733,6 +733,8 @@ namespace MatterHackers.MatterControl { public Color MaterialPreset { get; set; } = Color.Orange; + public Color ScenePreset { get; set; } = Color.Green; + public Color QualityPreset { get; set; } = Color.Yellow; public Color UserOverride { get; set; } = new Color(68, 95, 220, 150); diff --git a/MatterControlLib/ControlElements/MHDropDownList.cs b/MatterControlLib/ControlElements/MHDropDownList.cs index ece7fb855..9b14a50c1 100644 --- a/MatterControlLib/ControlElements/MHDropDownList.cs +++ b/MatterControlLib/ControlElements/MHDropDownList.cs @@ -100,7 +100,7 @@ namespace MatterHackers.MatterControl { return theme.DropList.Open.BackgroundColor; } - else if (this.mouseInBounds) + else if (this.ContainsFirstUnderMouseRecursive()) { return theme.DropList.Hovered.BackgroundColor; } diff --git a/MatterControlLib/DesignTools/Operations/PartSettingsObject3D.cs b/MatterControlLib/DesignTools/Operations/PartSettingsObject3D.cs new file mode 100644 index 000000000..267c83fab --- /dev/null +++ b/MatterControlLib/DesignTools/Operations/PartSettingsObject3D.cs @@ -0,0 +1,136 @@ +/* +Copyright (c) 2022, Lars Brubaker +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 MatterHackers.Agg.Platform; +using MatterHackers.DataConverters3D; +using MatterHackers.Localizations; +using MatterHackers.MatterControl.SlicerConfiguration; +using MatterHackers.PolygonMesh; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; + +namespace MatterHackers.MatterControl.DesignTools.Operations +{ + [HideChildrenFromTreeView] + [RequiresPermissions] + [HideMeterialAndColor] + public class PartSettingsObject3D : Object3D, IEditorButtonProvider, IStaticThumbnail + { + public PartSettingsObject3D() + { + Name = "Part Settings".Localize(); + } + + public PrinterSettingsLayer Overrides { get; set; } = new PrinterSettingsLayer(); + + public static async Task Create() + { + var item = new PartSettingsObject3D(); + await item.Rebuild(); + return item; + } + + private static object loadLock = new object(); + private static IObject3D sliceSettingsObject; + + public override Mesh Mesh + { + get + { + if (this.Children.Count == 0) + { + lock (loadLock) + { + if (sliceSettingsObject == null) + { + sliceSettingsObject = MeshContentProvider.LoadMCX(StaticData.Instance.OpenStream(Path.Combine("Stls", "part_settings.mcx"))); + } + + this.Children.Modify((list) => + { + list.Clear(); + + list.Add(sliceSettingsObject.Clone()); + }); + } + } + + return null; + } + + set => base.Mesh = value; + } + + public override bool Printable => false; + + public string ThumbnailName => nameof(PartSettingsObject3D); + + public IEnumerable GetEditorButtonsData() + { + if (ApplicationController.Instance.UserHasPermission(this)) + { + yield return new EditorButtonData() + { + Action = () => + { + var settings = new PrinterSettings(); + var printer = new PrinterConfig(settings); + // set this after the PrinterConfig is constructed to change it to overrides + settings.GetSceneLayer = () => Overrides; + + var presetsContext = new PresetsContext(null, printer.Settings.SceneLayer) + { + LayerType = NamedSettingsLayers.Scene, + }; + + var editMaterialPresetsPage = new SlicePresetsPage(printer, presetsContext, false); + editMaterialPresetsPage.Closed += (s, e2) => + { + ApplicationController.Instance.AcitveSlicePresetsPage = null; + var containingPrinter = this.ContainingPrinter(); + if (containingPrinter != null) + { + this.Invalidate(InvalidateType.DisplayValues); + ApplicationController.Instance.ReloadSettings(containingPrinter); + // refresh the properties pannel by unselecting and selecting + containingPrinter.Bed.Scene.SelectedItem = null; + containingPrinter.Bed.Scene.SelectedItem = this; + } + }; + + ApplicationController.Instance.AcitveSlicePresetsPage = editMaterialPresetsPage; + DialogWindow.Show(editMaterialPresetsPage); + }, + Name = "Edit".Localize(), + }; + } + } + } +} \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Operations/SliceSettingsObject3D.cs b/MatterControlLib/DesignTools/Operations/SliceSettingsObject3D.cs deleted file mode 100644 index 1f1c3f556..000000000 --- a/MatterControlLib/DesignTools/Operations/SliceSettingsObject3D.cs +++ /dev/null @@ -1,108 +0,0 @@ -/* -Copyright (c) 2022, Lars Brubaker -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 MatterHackers.DataConverters3D; -using MatterHackers.DataConverters3D.UndoCommands; -using MatterHackers.Localizations; -using MatterHackers.MatterControl.SlicerConfiguration; -using System.Linq; -using static MatterHackers.DataConverters3D.Object3DExtensions; - -namespace MatterHackers.MatterControl.DesignTools.Operations -{ - public class SliceSettingsObject3D : Object3D - { - public SliceSettingsObject3D() - { - Name = "Slice Settings".Localize(); - } - - public PrinterSettingsLayer Overrides { get; set; } - - public void WrapSelectedItemAndSelect(InteractiveScene scene) - { - var items = scene.GetSelectedItems(); - - var parent = items.First().Parent; - RebuildLocks parentLock = (parent == null) ? null : parent.RebuilLockAll(); - - var firstChild = new Object3D(); - this.Children.Add(firstChild); - - // if the items we are replacing are already in a list - if (parent != null) - { - if (scene.UndoBuffer != null) - { - foreach (var item in items) - { - firstChild.Children.Add(item.Clone()); - } - - var replace = new ReplaceCommand(items, new[] { this }); - scene.UndoBuffer.AddAndDo(replace); - } - else - { - parent.Children.Modify(list => - { - foreach (var item in items) - { - list.Remove(item); - firstChild.Children.Add(item); - } - - list.Add(this); - }); - } - } - else // just add them - { - firstChild.Children.Modify(list => - { - list.AddRange(items); - }); - } - - parentLock?.Dispose(); - - // and select this - var rootItem = this.Parents().Where(i => scene.Children.Contains(i)).FirstOrDefault(); - if (rootItem != null) - { - scene.SelectedItem = rootItem; - } - - scene.SelectedItem = this; - - this.CancelAllParentBuilding(); - parent?.Invalidate(new InvalidateArgs(parent, InvalidateType.Children)); - } - } -} \ No newline at end of file diff --git a/MatterControlLib/DesignTools/PublicPropertyEditor.cs b/MatterControlLib/DesignTools/PublicPropertyEditor.cs index 5a0ac7795..6643e156d 100644 --- a/MatterControlLib/DesignTools/PublicPropertyEditor.cs +++ b/MatterControlLib/DesignTools/PublicPropertyEditor.cs @@ -72,7 +72,9 @@ namespace MatterHackers.MatterControl.DesignTools typeof(SelectedChildren), typeof(ImageBuffer), typeof(Histogram), - typeof(List) + typeof(List), + typeof(PrinterSettingsLayer), + }; public const BindingFlags OwnedPropertiesOnly = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; @@ -564,6 +566,93 @@ namespace MatterHackers.MatterControl.DesignTools rowContainer.AddChild(row2); } + else if (propertyValue is PrinterSettingsLayer printerSettingsLayer) + { + var settingsBackground = new GuiWidget() + { + Name = "Background", + HAnchor = HAnchor.Stretch, + VAnchor = VAnchor.Fit, + Margin = 7, + }; + + var settingsHolder = settingsBackground.AddChild(new FlowLayoutWidget(FlowDirection.TopToBottom) + { + Name = "Holder", + HAnchor = HAnchor.Stretch, + }); + + settingsHolder.AddChild(new HorizontalLine(Color.Green) + { + Height = 4 * GuiWidget.DeviceScale + }); + + var settingsCover = settingsBackground.AddChild(new GuiWidget() + { + Name = "Cover", + HAnchor = HAnchor.Stretch, + BackgroundColor = theme.BackgroundColor.WithAlpha(100), + }); + + settingsHolder.SizeChanged += (s5, e5) => + { + settingsCover.Height = settingsHolder.Height; + }; + + rowContainer = settingsBackground; + + var printerProfile = new PrinterSettings(); + printerProfile.OemLayer = new PrinterSettingsLayer(); + // move all the settings to the oem layer + var layout = new List<(int index, string category, string group, string key)>(); + foreach (var kvp in printerSettingsLayer) + { + printerProfile.OemLayer[kvp.Key] = kvp.Value; + layout.Add(SliceSettingsLayouts.GetLayout(kvp.Key)); + } + + var printer = new PrinterConfig(printerProfile); + var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All); + var tabIndex = 0; + var orderedSettings = layout.OrderBy(i => i.index).Select(i => (i.category, i.key)); + + var lastCategory = ""; + + foreach ((string category, string key) setting in orderedSettings) + { + if (setting.category == "") + { + continue; + } + + if (setting.category != lastCategory) + { + lastCategory = setting.category; + // add a new setting header + settingsHolder.AddChild(new TextWidget(setting.category.Localize() + " " + "Settings".Localize() + ":", 0, 0, bold: true) + { + TextColor = theme.TextColor, + Margin = new BorderDouble(0, 5, 0, 7) + }); + } + + var settingsData = PrinterSettings.SettingsData[setting.key]; + var row = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, theme, ref tabIndex); + + if (row is SliceSettingsRow settingsRow) + { + settingsRow.ArrowDirection = ArrowDirection.Left; + settingsRow.Enabled = true; + } + + settingsHolder.AddChild(row); + } + + settingsHolder.AddChild(new HorizontalLine(Color.Green) + { + Height = 4 * GuiWidget.DeviceScale + }); + } else if (propertyValue is SelectedChildren childSelector) { if (property.PropertyInfo.GetCustomAttributes(true).OfType().FirstOrDefault() is ShowAsListAttribute showAsList) @@ -625,7 +714,7 @@ namespace MatterHackers.MatterControl.DesignTools { imageWidget = new ImageWidget(imageBuffer); } - + if (imageDisplayAttribute != null) { imageWidget.MaximumSize = new Vector2(imageDisplayAttribute.MaxXSize * GuiWidget.DeviceScale, int.MaxValue); @@ -643,7 +732,7 @@ namespace MatterHackers.MatterControl.DesignTools { image = imageObject2.Image; } - + // Show image load error if needed if (image == null) { @@ -960,7 +1049,7 @@ namespace MatterHackers.MatterControl.DesignTools { rowContainer = NewImageSearchWidget(theme); } - else if(object3D is AssetObject3D assetObject + else if (object3D is AssetObject3D assetObject && property.PropertyInfo.Name == "AssetPath") { // This is the AssetPath property of an asset object, add a button to set the AssetPath from a file @@ -1095,7 +1184,7 @@ namespace MatterHackers.MatterControl.DesignTools rowContainer = CreateSettingsColumn(property, field, fullWidth: true); } else - { + { // create a string editor var field = new TextField(theme); field.Initialize(0); diff --git a/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs b/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs index b4196e4a5..56f94a184 100644 --- a/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs +++ b/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs @@ -33,26 +33,21 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Text.RegularExpressions; -using System.Threading; using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.MatterControl.DesignTools.Operations; -using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.PolygonMesh; -using MatterHackers.PolygonMesh.Processors; -using MatterHackers.VectorMath; using org.mariuszgromada.math.mxparser; namespace MatterHackers.MatterControl.DesignTools { - [HideChildrenFromTreeView] + [HideChildrenFromTreeView] [HideMeterialAndColor] [WebPageLink("Documentation", "Open", "https://www.matterhackers.com/support/mattercontrol-variable-support")] [MarkDownDescription("[BETA] - Experimental support for variables and equations with a sheets like interface.")] - public class SheetObject3D : Object3D, IObject3DControlsProvider, IStaticThumbnail + public class SheetObject3D : Object3D, IStaticThumbnail { private SheetData _sheetData; public SheetData SheetData @@ -605,9 +600,5 @@ namespace MatterHackers.MatterControl.DesignTools return (T)(object)default(T); } - - public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) - { - } } } \ No newline at end of file diff --git a/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs b/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs index f8aa7d76d..a1431d2c2 100644 --- a/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs +++ b/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs @@ -36,6 +36,7 @@ using MatterHackers.Agg.Platform; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.DesignTools; +using MatterHackers.MatterControl.DesignTools.Operations; namespace MatterHackers.MatterControl.Library { diff --git a/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs b/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs index 9b6d7f5ec..54be7dc5f 100644 --- a/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs +++ b/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs @@ -114,7 +114,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { if (layerType == NamedSettingsLayers.Material) { - if (ApplicationController.Instance.EditMaterialPresetsPage == null) + if (ApplicationController.Instance.AcitveSlicePresetsPage == null) { string presetsID = printer.Settings.ActiveMaterialKey; if (string.IsNullOrEmpty(presetsID)) @@ -145,21 +145,21 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var editMaterialPresetsPage = new SlicePresetsPage(printer, presetsContext, true); editMaterialPresetsPage.Closed += (s, e2) => { - ApplicationController.Instance.EditMaterialPresetsPage = null; + ApplicationController.Instance.AcitveSlicePresetsPage = null; }; - ApplicationController.Instance.EditMaterialPresetsPage = editMaterialPresetsPage; + ApplicationController.Instance.AcitveSlicePresetsPage = editMaterialPresetsPage; DialogWindow.Show(editMaterialPresetsPage); } else { - ApplicationController.Instance.EditMaterialPresetsPage.DialogWindow.BringToFront(); + ApplicationController.Instance.AcitveSlicePresetsPage.DialogWindow.BringToFront(); } } if (layerType == NamedSettingsLayers.Quality) { - if (ApplicationController.Instance.EditQualityPresetsWindow == null) + if (ApplicationController.Instance.AcitveSlicePresetsPage == null) { string presetsID = printer.Settings.ActiveQualityKey; if (string.IsNullOrEmpty(presetsID)) @@ -192,15 +192,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var editQualityPresetsWindow = new SlicePresetsPage(printer, presetsContext, false); editQualityPresetsWindow.Closed += (s, e2) => { - ApplicationController.Instance.EditQualityPresetsWindow = null; + ApplicationController.Instance.AcitveSlicePresetsPage = null; }; - ApplicationController.Instance.EditQualityPresetsWindow = editQualityPresetsWindow; + ApplicationController.Instance.AcitveSlicePresetsPage = editQualityPresetsWindow; DialogWindow.Show(editQualityPresetsWindow); } else { - ApplicationController.Instance.EditQualityPresetsWindow.DialogWindow.BringToFront(); + ApplicationController.Instance.AcitveSlicePresetsPage.DialogWindow.BringToFront(); } } }; diff --git a/MatterControlLib/SlicerConfiguration/SlicePresetsWindow/SlicePresetsPage.cs b/MatterControlLib/SlicerConfiguration/SlicePresetsWindow/SlicePresetsPage.cs index e342c02b1..3ed0ee090 100644 --- a/MatterControlLib/SlicerConfiguration/SlicePresetsWindow/SlicePresetsPage.cs +++ b/MatterControlLib/SlicerConfiguration/SlicePresetsWindow/SlicePresetsPage.cs @@ -65,44 +65,49 @@ namespace MatterHackers.MatterControl.SlicerConfiguration contentRow.BackgroundColor = Color.Transparent; - var inlineNameEdit = new InlineStringEdit(presetsContext.PersistenceLayer.Name, - theme, - presetsContext.LayerType.ToString() + " Name", - boldFont: true, - emptyText: "Setting Name".Localize()); - - inlineNameEdit.ValueChanged += (s, e) => - { - printer.Settings.SetValue(SettingsKey.layer_name, inlineNameEdit.Text, presetsContext.PersistenceLayer); - }; - inlineNameEdit.Closed += (s, e) => - { - printer.Settings.SetValue(SettingsKey.layer_name, inlineNameEdit.Text, presetsContext.PersistenceLayer); - }; - contentRow.AddChild(inlineNameEdit); - var sliceSettingsWidget = CreateSliceSettingsWidget(printer, presetsContext.PersistenceLayer); contentRow.AddChild(sliceSettingsWidget); - var duplicateButton = theme.CreateDialogButton("Duplicate".Localize()); - duplicateButton.Click += (s, e) => + GuiWidget duplicateButton = null; + + if (presetsContext.SetAsActive != null) { - string sanitizedName = numberMatch.Replace(inlineNameEdit.Text, "").Trim(); - string newProfileName = agg_basics.GetNonCollidingName(sanitizedName, new HashSet(presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name)))); + var inlineNameEdit = new InlineStringEdit(presetsContext.PersistenceLayer.Name, + theme, + presetsContext.LayerType.ToString() + " Name", + boldFont: true, + emptyText: "Setting Name".Localize()); - var clonedLayer = presetsContext.PersistenceLayer.Clone(); - clonedLayer.Name = newProfileName; - presetsContext.PresetLayers.Add(clonedLayer); + inlineNameEdit.ValueChanged += (s, e) => + { + printer.Settings.SetValue(SettingsKey.layer_name, inlineNameEdit.Text, presetsContext.PersistenceLayer); + }; + inlineNameEdit.Closed += (s, e) => + { + printer.Settings.SetValue(SettingsKey.layer_name, inlineNameEdit.Text, presetsContext.PersistenceLayer); + }; + contentRow.AddChild(inlineNameEdit); - presetsContext.SetAsActive(clonedLayer.LayerID); - presetsContext.PersistenceLayer = clonedLayer; + duplicateButton = theme.CreateDialogButton("Duplicate".Localize()); + duplicateButton.Click += (s, e) => + { + string sanitizedName = numberMatch.Replace(inlineNameEdit.Text, "").Trim(); + string newProfileName = agg_basics.GetNonCollidingName(sanitizedName, new HashSet(presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name)))); - sliceSettingsWidget.Close(); - sliceSettingsWidget = CreateSliceSettingsWidget(printer, clonedLayer); - contentRow.AddChild(sliceSettingsWidget); + var clonedLayer = presetsContext.PersistenceLayer.Clone(); + clonedLayer.Name = newProfileName; + presetsContext.PresetLayers.Add(clonedLayer); - inlineNameEdit.Text = newProfileName; - }; + presetsContext.SetAsActive(clonedLayer.LayerID); + presetsContext.PersistenceLayer = clonedLayer; + + sliceSettingsWidget.Close(); + sliceSettingsWidget = CreateSliceSettingsWidget(printer, clonedLayer); + contentRow.AddChild(sliceSettingsWidget); + + inlineNameEdit.Text = newProfileName; + }; + } if (showExport) { @@ -143,16 +148,22 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.AddPageAction(exportButton, false); } - var deleteButton = theme.CreateDialogButton("Delete".Localize()); - deleteButton.Click += (s, e) => + if (presetsContext.DeleteLayer != null) { - presetsContext.DeleteLayer(); - this.DialogWindow.Close(); - }; + var deleteButton = theme.CreateDialogButton("Delete".Localize()); + deleteButton.Click += (s, e) => + { + presetsContext.DeleteLayer(); + this.DialogWindow.Close(); + }; - this.AddPageAction(deleteButton, false); + this.AddPageAction(deleteButton, false); + } - this.AddPageAction(duplicateButton, false); + if (duplicateButton != null) + { + this.AddPageAction(duplicateButton, false); + } AcceptButton = CancelButton; } diff --git a/MatterControlLib/SlicerConfiguration/SliceSettingsRow.cs b/MatterControlLib/SlicerConfiguration/SliceSettingsRow.cs index 579b7353a..e1707618a 100644 --- a/MatterControlLib/SlicerConfiguration/SliceSettingsRow.cs +++ b/MatterControlLib/SlicerConfiguration/SliceSettingsRow.cs @@ -540,6 +540,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration highlightColor = theme.PresetColors.QualityPreset; showRestoreButton = true; break; + case NamedSettingsLayers.Scene: + highlightColor = theme.PresetColors.ScenePreset; + showRestoreButton = true; + break; } } else if (settingsContext.IsPrimarySettingsView) @@ -555,6 +559,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { highlightColor = theme.PresetColors.UserOverride; } + else if (settings.SettingExistsInLayer(key, NamedSettingsLayers.Scene)) + { + highlightColor = theme.PresetColors.ScenePreset; + } else if (settings.SettingExistsInLayer(key, NamedSettingsLayers.Material)) { highlightColor = theme.PresetColors.MaterialPreset; diff --git a/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs b/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs index bef07cdf2..b10ba08a9 100644 --- a/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs +++ b/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs @@ -244,7 +244,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration foreach (var category in settingsSection.Categories) { if (category.Name == "Printer" - && (settingsContext.ViewFilter == NamedSettingsLayers.Material || settingsContext.ViewFilter == NamedSettingsLayers.Quality)) + && (settingsContext.ViewFilter == NamedSettingsLayers.Material + || settingsContext.ViewFilter == NamedSettingsLayers.Quality)) { continue; } @@ -391,6 +392,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration case NamedSettingsLayers.Quality: this.FilterToOverrides(printer.Settings.QualityLayerCascade); break; + case NamedSettingsLayers.Scene: + this.FilterToOverrides(printer.Settings.SceneLayerCascade); + break; } }; @@ -473,7 +477,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration bool firstRow = true; GuiWidget settingsRow = null; - var presetsView = settingsContext.ViewFilter == NamedSettingsLayers.Material || settingsContext.ViewFilter == NamedSettingsLayers.Quality; + var presetsView = settingsContext.ViewFilter == NamedSettingsLayers.Material + || settingsContext.ViewFilter == NamedSettingsLayers.Quality + || settingsContext.ViewFilter == NamedSettingsLayers.Scene; var ignoredPresets = new HashSet { SettingsKey.temperature2, SettingsKey.temperature3 }; using (groupPanel.LayoutLock()) @@ -527,7 +533,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration private static bool CheckIfShouldBeShown(SliceSettingData settingData, SettingsContext settingsContext) { bool settingShouldBeShown = settingData.Show?.Invoke(settingsContext.Printer.Settings) != false; - if (settingsContext.ViewFilter == NamedSettingsLayers.Material || settingsContext.ViewFilter == NamedSettingsLayers.Quality) + if (settingsContext.ViewFilter == NamedSettingsLayers.Material || settingsContext.ViewFilter == NamedSettingsLayers.Quality || NamedSettingsLayers.Scene == settingsContext.ViewFilter) { if (!settingData.ShowAsOverride) { @@ -885,7 +891,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration bool settingEnabled = settingData.Show?.Invoke(settingsContext.Printer.Settings) != false; if (settingEnabled || settingsContext.ViewFilter == NamedSettingsLayers.Material - || settingsContext.ViewFilter == NamedSettingsLayers.Quality) + || settingsContext.ViewFilter == NamedSettingsLayers.Quality + || settingsContext.ViewFilter == NamedSettingsLayers.Scene) { if (placeFieldInDedicatedRow) { diff --git a/StaticData/Images/Thumbnails/13713010527636813975-256x256.png b/StaticData/Images/Thumbnails/13713010527636813975-256x256.png new file mode 100644 index 000000000..a5ebb9fe0 Binary files /dev/null and b/StaticData/Images/Thumbnails/13713010527636813975-256x256.png differ diff --git a/StaticData/Images/Thumbnails/3843136786335874911-256x256.png b/StaticData/Images/Thumbnails/3843136786335874911-256x256.png new file mode 100644 index 000000000..a5ebb9fe0 Binary files /dev/null and b/StaticData/Images/Thumbnails/3843136786335874911-256x256.png differ diff --git a/StaticData/Stls/part_settings.mcx b/StaticData/Stls/part_settings.mcx new file mode 100644 index 000000000..e1deb2e95 Binary files /dev/null and b/StaticData/Stls/part_settings.mcx differ diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 978cb2699..51920b676 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -3340,6 +3340,9 @@ Translated:Part Cooling Fan English:Part Cooling Fan {i} Translated:Part Cooling Fan {i} +English:Part Settings +Translated:Part Settings + English:Part(s) to Subtract Translated:Part(s) to Subtract diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 5f8b9d518..7ea2bbbf3 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 5f8b9d518d71c559bca4711611bf92de46a3ffb0 +Subproject commit 7ea2bbbf3634ab37698640cc184ac2d2755cffbe