From aeef26db01536e7d9992cc203ca2d9fa8c79730a Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 19 Apr 2022 18:10:09 -0700 Subject: [PATCH 1/2] Starting the work of creating 'holes' --- .../Operations/Object3DExtensions.cs | 2 +- .../PartPreviewWindow/SelectedObjectPanel.cs | 29 +++++-- .../View3D/Object3DControlsLayer.cs | 56 +++++++------ .../View3D/UndoCommands/ChangeColor.cs | 2 +- .../View3D/UndoCommands/MakeHole.cs | 79 +++++++++++++++++++ StaticData/Translations/Master.txt | 3 + Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 8 files changed, 138 insertions(+), 37 deletions(-) create mode 100644 MatterControlLib/PartPreviewWindow/View3D/UndoCommands/MakeHole.cs diff --git a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs index af339cf20..d80c8d2c4 100644 --- a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs +++ b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs @@ -380,7 +380,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations /// /// Union a and b together. This can either return a single item with a mesh on it - /// or a group item that has the a and be items as children + /// or a group item that has the a and b items as children /// /// /// diff --git a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs index 6b9d8206d..04ebea4ef 100644 --- a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs +++ b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs @@ -310,13 +310,29 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } }; - // color row - var row = new SettingsRow("Color".Localize(), null, colorField.Content, theme); + editorPanel.AddChild(new SettingsRow("Color".Localize(), null, colorField.Content, theme) + { + // Special top border style for first item in editor + Border = new BorderDouble(0, 1) + }); - // Special top border style for first item in editor - row.Border = new BorderDouble(0, 1); + // put in a hole edit field + var holeField = new ToggleboxField(theme); + holeField.Initialize(0); + holeField.Checked = selectedItem.WorldOutputType() == PrintOutputTypes.Hole; + holeField.ValueChanged += (s, e) => + { + if (selectedItem.OutputType == PrintOutputTypes.Hole) + { + undoBuffer.AddAndDo(new ChangeColor(selectedItem, colorField.Color)); + } + else + { + undoBuffer.AddAndDo(new MakeHole(selectedItem)); + } + }; - editorPanel.AddChild(row); + editorPanel.AddChild(new SettingsRow("Hole".Localize(), null, holeField.Content, theme)); // put in a material edit field var materialField = new MaterialIndexField(sceneContext.Printer, theme, selectedItem.MaterialIndex); @@ -339,8 +355,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; // material row - editorPanel.AddChild( - new SettingsRow("Material".Localize(), null, materialField.Content, theme)); + editorPanel.AddChild(new SettingsRow("Material".Localize(), null, materialField.Content, theme)); } var rows = new SafeList(); diff --git a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs index 836833144..6211acc2a 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs @@ -92,17 +92,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow floorDrawable = new FloorDrawable(editorType, sceneContext, this.BuildVolumeColor, theme); - if (viewOnlyTexture == null) + if (stripeTexture == null) { - // TODO: What is the ViewOnlyTexture??? + // open gl can only be run on the ui thread so make sure it is on it by using RunOnIdle UiThread.RunOnIdle(() => { - viewOnlyTexture = new ImageBuffer(32, 32, 32); - var graphics2D = viewOnlyTexture.NewGraphics2D(); + stripeTexture = new ImageBuffer(32, 32, 32); + var graphics2D = stripeTexture.NewGraphics2D(); graphics2D.Clear(Color.White); - graphics2D.FillRectangle(0, 0, viewOnlyTexture.Width / 2, viewOnlyTexture.Height, Color.LightGray); + graphics2D.FillRectangle(0, 0, stripeTexture.Width / 2, stripeTexture.Height, Color.LightGray); // request the texture so we can set it to repeat - ImageGlPlugin.GetImageGlPlugin(viewOnlyTexture, true, true, false); + ImageGlPlugin.GetImageGlPlugin(stripeTexture, true, true, false); }); } @@ -329,7 +329,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { foreach (var bvhIterator in allResults) { - Object3DControlsLayer.RenderBounds(e, world, bvhIterator.TransformToWorld, bvhIterator.Bvh, bvhIterator.Depth); + RenderBounds(e, world, bvhIterator.TransformToWorld, bvhIterator.Bvh, bvhIterator.Depth); } } @@ -635,7 +635,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public GuiWidget GuiSurface => this; - private static ImageBuffer viewOnlyTexture; + private static ImageBuffer stripeTexture; private Color lightWireframe = new Color("#aaa4"); private Color darkWireframe = new Color("#3334"); @@ -807,8 +807,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow foreach (var item in object3D.VisibleMeshes()) { - // check for correct protection rendering - ValidateViewOnlyTexturing(item); + // check if the object should have a stripe texture + ValidateStripeTexturing(item); Color drawColor = this.GetItemColor(item, selectedItem); @@ -849,12 +849,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - private static void ValidateViewOnlyTexturing(IObject3D item) + private static void ValidateStripeTexturing(IObject3D item) { - // if there is no view only texture or the item is locked - if (Object3DControlsLayer.viewOnlyTexture == null + // if there is no stripe texture built or the item is locked + if (stripeTexture == null || item.Mesh.Faces.Count == 0) { + // exit and wait for a later time return; } @@ -864,33 +865,35 @@ namespace MatterHackers.MatterControl.PartPreviewWindow item.Mesh.FaceTextures.TryGetValue(0, out FaceTextureData faceTexture); bool faceIsTextured = faceTexture?.image != null; - // if not persistable and has view only texture, remove the view only texture if it has it - if (item.WorldPersistable() - && faceIsTextured) + // if persistable and has a stripe texture, remove the stripe texture + if (faceIsTextured + && item.WorldPersistable() + && item.WorldOutputType() != PrintOutputTypes.Hole) { - // make sure it does not have the view only texture + // make sure it does not have a stripe texture using (item.RebuildLock()) { - item.Mesh.RemoveTexture(Object3DControlsLayer.viewOnlyTexture, 0); + item.Mesh.RemoveTexture(stripeTexture, 0); } } - else if (!item.WorldPersistable() - && !faceIsTextured - && !item.RebuildLocked) + else if (!faceIsTextured + && !item.RebuildLocked + // and it is protected or a hole + && (!item.WorldPersistable() || item.WorldOutputType() == PrintOutputTypes.Hole)) { - // add a view only texture if it does not have one - // make a copy of the mesh and texture it + // add a stripe texture if it does not have one Task.Run(() => { - // make sure it does have the view only texture + // put on the stripe texture var aabb = item.Mesh.GetAxisAlignedBoundingBox(); var matrix = Matrix4X4.CreateScale(.5, .5, 1); matrix *= Matrix4X4.CreateRotationZ(MathHelper.Tau / 8); // make sure it has it's own copy of the mesh using (item.RebuildLock()) { + // we make a copy so that we don't modify the global instance of a mesh item.Mesh = item.Mesh.Copy(CancellationToken.None); - item.Mesh.PlaceTexture(Object3DControlsLayer.viewOnlyTexture, matrix); + item.Mesh.PlaceTexture(stripeTexture, matrix); } }); } @@ -1167,7 +1170,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow RenderTypes.Outlines, object3D.WorldMatrix() * World.ModelviewMatrix, wireColor, - allowBspRendering: transparentMeshes.Count < 1000); + allowBspRendering: transparentMeshes.Count < 1000, + forceCullBackFaces: false); } if (!lookingDownOnBed) diff --git a/MatterControlLib/PartPreviewWindow/View3D/UndoCommands/ChangeColor.cs b/MatterControlLib/PartPreviewWindow/View3D/UndoCommands/ChangeColor.cs index b9344e575..09547b1f2 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/UndoCommands/ChangeColor.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/UndoCommands/ChangeColor.cs @@ -35,7 +35,7 @@ using MatterHackers.DataConverters3D; namespace MatterHackers.MatterControl.PartPreviewWindow { - public class ChangeColor : IUndoRedoCommand + public class ChangeColor : IUndoRedoCommand { private List itemsPrintOutputType = new List(); private List itemsColor = new List(); diff --git a/MatterControlLib/PartPreviewWindow/View3D/UndoCommands/MakeHole.cs b/MatterControlLib/PartPreviewWindow/View3D/UndoCommands/MakeHole.cs new file mode 100644 index 000000000..a2937f75c --- /dev/null +++ b/MatterControlLib/PartPreviewWindow/View3D/UndoCommands/MakeHole.cs @@ -0,0 +1,79 @@ +/* +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 System.Collections.Generic; +using System.Linq; +using MatterHackers.Agg.UI; +using MatterHackers.DataConverters3D; + +namespace MatterHackers.MatterControl.PartPreviewWindow +{ + public class MakeHole : IUndoRedoCommand + { + private List itemsPrintOutputType = new List(); + private List itemsToChange = new List(); + + public MakeHole(IObject3D selectedItem) + { + if (selectedItem is SelectionGroupObject3D) + { + SetData(selectedItem.Children.ToList()); + } + else + { + SetData(new List { selectedItem }); + } + } + + void SetData(List itemsToChange) + { + foreach (var item in itemsToChange) + { + this.itemsToChange.Add(item); + this.itemsPrintOutputType.Add(item.OutputType); + } + } + + void IUndoRedoCommand.Do() + { + foreach (var item in this.itemsToChange) + { + item.OutputType = PrintOutputTypes.Hole; + } + } + + void IUndoRedoCommand.Undo() + { + for (int i = 0; i < this.itemsToChange.Count; i++) + { + itemsToChange[i].OutputType = itemsPrintOutputType[i]; + } + } + } +} diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index ee244daed..11b153341 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -2155,6 +2155,9 @@ Translated:Hold 'Shift' to scale proportionally, Type 'Esc' to cancel English:Holding Temperature Translated:Holding Temperature +English:Hole +Translated:Hole + English:Hollow Translated:Hollow diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index e754c8142..bc96dac61 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit e754c81428db89bb94fadac23f026de7579bff8f +Subproject commit bc96dac612a6cb3bff321b96657d5cdaef5b28d6 diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 303fb1cf3..a1708b040 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 303fb1cf3baada642aaa46eb4d2e9fd546045bf7 +Subproject commit a1708b04012fe859f1e42cabd8a23234f7912ef7 From cb86a9973bb1a56097297f8bc3a48ec99029190e Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 20 Apr 2022 14:28:34 -0700 Subject: [PATCH 2/2] Improving updating of part settings override We now can combine multiple part settings --- .../Settings/SliceSettingsLayouts.cs | 337 ++++++++++-------- .../ApplicationView/Config/PrinterConfig.cs | 26 +- .../Operations/PartSettingsObject3D.cs | 25 +- .../Operations/PlaneCutObject3D.cs | 16 +- .../SlicerConfiguration/SliceSettingsRow.cs | 2 +- Submodules/MatterSlice | 2 +- 6 files changed, 235 insertions(+), 173 deletions(-) diff --git a/MatterControl.Printing/Settings/SliceSettingsLayouts.cs b/MatterControl.Printing/Settings/SliceSettingsLayouts.cs index 30a8aa00c..8a62611db 100644 --- a/MatterControl.Printing/Settings/SliceSettingsLayouts.cs +++ b/MatterControl.Printing/Settings/SliceSettingsLayouts.cs @@ -27,14 +27,13 @@ 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; - namespace MatterHackers.MatterControl.SlicerConfiguration { public static class SliceSettingsLayouts { private static (string categoryName, (string groupName, string[] settings)[] groups)[] sliceSettings; + + private static (string categoryName, (string groupName, string[] settings)[] groups)[] printerSettings; public static (string categoryName, (string groupName, string[] settings)[] groups)[] SliceSettings() { if (sliceSettings == null) @@ -136,7 +135,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration SettingsKey.t1_extrusion_move_speed_multiplier, }), ("Speed Overrides", new [] - { + { SettingsKey.max_print_speed, }), ("Cooling", new[] @@ -269,181 +268,203 @@ namespace MatterHackers.MatterControl.SlicerConfiguration }), }), }; - } + } return sliceSettings; } public static (string categoryName, (string groupName, string[] settings)[] groups)[] PrinterSettings() { - var printerSettings = new (string categoryName, (string groupName, string[] settings)[] groups)[] + if (printerSettings == null) { - ("General", new[] + printerSettings = new (string categoryName, (string groupName, string[] settings)[] groups)[] { ("General", new[] { - SettingsKey.make, - SettingsKey.model, - SettingsKey.auto_connect, - SettingsKey.baud_rate, - SettingsKey.com_port, - SettingsKey.selector_ip_address, - SettingsKey.ip_address, - SettingsKey.ip_port, + ("General", new[] + { + SettingsKey.make, + SettingsKey.model, + SettingsKey.auto_connect, + SettingsKey.baud_rate, + SettingsKey.com_port, + SettingsKey.selector_ip_address, + SettingsKey.ip_address, + SettingsKey.ip_port, + }), + ("Bed", new[] + { + SettingsKey.bed_size, + SettingsKey.print_center, + SettingsKey.build_height, + SettingsKey.bed_shape, + // add settings specific to SLA + SettingsKey.sla_resolution, + SettingsKey.sla_printable_area_inset, + SettingsKey.sla_mirror_mode, + }), + ("Extruders", new[] + { + SettingsKey.extruder_count, + SettingsKey.nozzle_diameter, + SettingsKey.t0_inset, + SettingsKey.t1_inset, + SettingsKey.extruders_share_temperature, + SettingsKey.extruder_offset, + }), }), - ("Bed", new[] + ("Features", new (string groupName, string[] settings)[] { - SettingsKey.bed_size, - SettingsKey.print_center, - SettingsKey.build_height, - SettingsKey.bed_shape, - // add settings specific to SLA - SettingsKey.sla_resolution, - SettingsKey.sla_printable_area_inset, - SettingsKey.sla_mirror_mode, + ("Leveling", new[] + { + SettingsKey.print_leveling_solution, + SettingsKey.print_leveling_insets, + SettingsKey.leveling_sample_points, + SettingsKey.print_leveling_required_to_print, + }), + ("Print Recovery", new[] + { + SettingsKey.recover_is_enabled, + SettingsKey.recover_first_layer_speed, + SettingsKey.recover_position_before_z_home, + }), + ("Probe", new[] + { + SettingsKey.print_leveling_probe_start, + SettingsKey.use_z_probe, + SettingsKey.validate_leveling, + SettingsKey.validation_threshold, + SettingsKey.z_probe_samples, + SettingsKey.probe_offset, + SettingsKey.z_servo_depolyed_angle, + SettingsKey.z_servo_retracted_angle, + SettingsKey.measure_probe_offset_conductively, + SettingsKey.conductive_pad_center, + SettingsKey.conductive_probe_min_z, + }), + ("Behavior", new[] + { + SettingsKey.slice_engine, + SettingsKey.heat_extruder_before_homing, + SettingsKey.auto_release_motors, + SettingsKey.validate_layer_height, + SettingsKey.emulate_endstops, + SettingsKey.send_with_checksum, + SettingsKey.additional_printing_errors, + SettingsKey.reset_long_extrusion, + SettingsKey.output_only_first_layer, + SettingsKey.g0, + SettingsKey.progress_reporting, + SettingsKey.include_firmware_updater, + SettingsKey.backup_firmware_before_update, + SettingsKey.enable_firmware_sounds, + }), + ("Diagnostics", new[] + { + SettingsKey.report_runout_sensor_data, + }), + ("Printer Help", new[] + { + SettingsKey.trim_filament_markdown, + SettingsKey.insert_filament_markdown2, + SettingsKey.running_clean_markdown2, + SettingsKey.insert_filament_1_markdown, + SettingsKey.running_clean_1_markdown, + SettingsKey.printer_sku, + SettingsKey.created_date, + }), }), - ("Extruders", new[] + ("Hardware", new (string groupName, string[] settings)[] { - SettingsKey.extruder_count, - SettingsKey.nozzle_diameter, - SettingsKey.t0_inset, - SettingsKey.t1_inset, - SettingsKey.extruders_share_temperature, - SettingsKey.extruder_offset, + ("Hardware", new[] + { + SettingsKey.firmware_type, + SettingsKey.show_reset_connection, + SettingsKey.z_homes_to_max, + SettingsKey.has_fan, + SettingsKey.has_fan_per_extruder, + SettingsKey.has_hardware_leveling, + SettingsKey.has_independent_z_motors, + SettingsKey.has_heated_bed, + SettingsKey.has_swappable_bed, + SettingsKey.has_sd_card_reader, + SettingsKey.has_power_control, + SettingsKey.filament_runout_sensor, + SettingsKey.runout_sensor_check_distance, + SettingsKey.runout_sensor_trigger_ratio, + SettingsKey.has_z_probe, + SettingsKey.has_z_servo, + SettingsKey.has_conductive_nozzle, + SettingsKey.has_c_axis, + SettingsKey.enable_network_printing, + SettingsKey.enable_sailfish_communication, + SettingsKey.max_acceleration, + SettingsKey.max_velocity, + SettingsKey.jerk_velocity, + SettingsKey.print_time_estimate_multiplier, + SettingsKey.load_filament_length, + SettingsKey.unload_filament_length, + SettingsKey.load_filament_speed, + }), }), - }), - ("Features", new (string groupName, string[] settings)[] - { - ("Leveling", new[] + ("G-Code", new[] { - SettingsKey.print_leveling_solution, - SettingsKey.print_leveling_insets, - SettingsKey.leveling_sample_points, - SettingsKey.print_leveling_required_to_print, + ("Printer Control", new[] + { + SettingsKey.start_gcode, + SettingsKey.end_gcode, + SettingsKey.layer_gcode, + SettingsKey.connect_gcode, + SettingsKey.clear_bed_gcode, + }), + ("User Control", new[] + { + SettingsKey.cancel_gcode, + SettingsKey.pause_gcode, + SettingsKey.resume_gcode, + }), + ("Multi-Extruder", new[] + { + SettingsKey.before_toolchange_gcode, + SettingsKey.toolchange_gcode, + SettingsKey.before_toolchange_gcode_1, + SettingsKey.toolchange_gcode_1, + SettingsKey.before_toolchange_gcode_2, + SettingsKey.toolchange_gcode_2, + SettingsKey.before_toolchange_gcode_3, + SettingsKey.toolchange_gcode_3, + }), + ("Filters", new[] + { + SettingsKey.write_regex, + SettingsKey.read_regex, + }), }), - ("Print Recovery", new[] - { - SettingsKey.recover_is_enabled, - SettingsKey.recover_first_layer_speed, - SettingsKey.recover_position_before_z_home, - }), - ("Probe", new[] - { - SettingsKey.print_leveling_probe_start, - SettingsKey.use_z_probe, - SettingsKey.validate_leveling, - SettingsKey.validation_threshold, - SettingsKey.z_probe_samples, - SettingsKey.probe_offset, - SettingsKey.z_servo_depolyed_angle, - SettingsKey.z_servo_retracted_angle, - SettingsKey.measure_probe_offset_conductively, - SettingsKey.conductive_pad_center, - SettingsKey.conductive_probe_min_z, - }), - ("Behavior", new[] - { - SettingsKey.slice_engine, - SettingsKey.heat_extruder_before_homing, - SettingsKey.auto_release_motors, - SettingsKey.validate_layer_height, - SettingsKey.emulate_endstops, - SettingsKey.send_with_checksum, - SettingsKey.additional_printing_errors, - SettingsKey.reset_long_extrusion, - SettingsKey.output_only_first_layer, - SettingsKey.g0, - SettingsKey.progress_reporting, - SettingsKey.include_firmware_updater, - SettingsKey.backup_firmware_before_update, - SettingsKey.enable_firmware_sounds, - }), - ("Diagnostics", new[] - { - SettingsKey.report_runout_sensor_data, - }), - ("Printer Help", new[] - { - SettingsKey.trim_filament_markdown, - SettingsKey.insert_filament_markdown2, - SettingsKey.running_clean_markdown2, - SettingsKey.insert_filament_1_markdown, - SettingsKey.running_clean_1_markdown, - SettingsKey.printer_sku, - SettingsKey.created_date, - }), - }), - ("Hardware", new (string groupName, string[] settings)[] - { - ("Hardware", new[] - { - SettingsKey.firmware_type, - SettingsKey.show_reset_connection, - SettingsKey.z_homes_to_max, - SettingsKey.has_fan, - SettingsKey.has_fan_per_extruder, - SettingsKey.has_hardware_leveling, - SettingsKey.has_independent_z_motors, - SettingsKey.has_heated_bed, - SettingsKey.has_swappable_bed, - SettingsKey.has_sd_card_reader, - SettingsKey.has_power_control, - SettingsKey.filament_runout_sensor, - SettingsKey.runout_sensor_check_distance, - SettingsKey.runout_sensor_trigger_ratio, - SettingsKey.has_z_probe, - SettingsKey.has_z_servo, - SettingsKey.has_conductive_nozzle, - SettingsKey.has_c_axis, - SettingsKey.enable_network_printing, - SettingsKey.enable_sailfish_communication, - SettingsKey.max_acceleration, - SettingsKey.max_velocity, - SettingsKey.jerk_velocity, - SettingsKey.print_time_estimate_multiplier, - SettingsKey.load_filament_length, - SettingsKey.unload_filament_length, - SettingsKey.load_filament_speed, - }), - }), - ("G-Code", new[] - { - ("Printer Control", new[] - { - SettingsKey.start_gcode, - SettingsKey.end_gcode, - SettingsKey.layer_gcode, - SettingsKey.connect_gcode, - SettingsKey.clear_bed_gcode, - }), - ("User Control", new[] - { - SettingsKey.cancel_gcode, - SettingsKey.pause_gcode, - SettingsKey.resume_gcode, - }), - ("Multi-Extruder", new[] - { - SettingsKey.before_toolchange_gcode, - SettingsKey.toolchange_gcode, - SettingsKey.before_toolchange_gcode_1, - SettingsKey.toolchange_gcode_1, - SettingsKey.before_toolchange_gcode_2, - SettingsKey.toolchange_gcode_2, - SettingsKey.before_toolchange_gcode_3, - SettingsKey.toolchange_gcode_3, - }), - ("Filters", new[] - { - SettingsKey.write_regex, - SettingsKey.read_regex, - }), - }), - }; + }; + } return printerSettings; } + public static bool ContainesKey((string categoryName, (string groupName, string[] settings)[] groups)[] settingsGrouping, string key) + { + foreach (var category in settingsGrouping) + { + foreach (var group in category.groups) + { + foreach (var setting in group.settings) + { + if (setting == key) + { + return true; + } + } + } + } + + return false; + } + public static (int index, string category, string group, string key) GetLayout(string key) { // find the setting in SliceSettings() diff --git a/MatterControlLib/ApplicationView/Config/PrinterConfig.cs b/MatterControlLib/ApplicationView/Config/PrinterConfig.cs index e56b9d267..b0ca21fac 100644 --- a/MatterControlLib/ApplicationView/Config/PrinterConfig.cs +++ b/MatterControlLib/ApplicationView/Config/PrinterConfig.cs @@ -67,15 +67,37 @@ namespace MatterHackers.MatterControl return !printingOrPause && !errors.Any(err => err.ErrorLevel == ValidationErrorLevel.Error); } + private PrinterSettingsLayer sceneOverrides = new PrinterSettingsLayer(); + private PrinterSettingsLayer GetSceneLayer() { var scene = Bed?.Scene; if (scene != null) { - if (scene.DescendantsAndSelf().Where(c => c is PartSettingsObject3D).FirstOrDefault() is PartSettingsObject3D partSettingsObject3D) + var currentSceneOverrides = new PrinterSettingsLayer(); + // accumulate all the scene overrides ordered by their names, which is the order they will be in the design tree + foreach (var partSettingsObject in scene.DescendantsAndSelf().Where(c => c is PartSettingsObject3D).OrderBy(i => i.Name)) { - return partSettingsObject3D.Overrides; + var settings = ((PartSettingsObject3D)partSettingsObject).Overrides; + foreach (var setting in settings) + { + currentSceneOverrides[setting.Key] = setting.Value; + } } + + var same = currentSceneOverrides.Count == sceneOverrides.Count && !currentSceneOverrides.Except(sceneOverrides).Any(); + + // if they are different + if (!same) + { + // store that current set + sceneOverrides = currentSceneOverrides; + // stash user overrides for all the values that are set + Settings.DeactivateConflictingUserOverrides(sceneOverrides); + } + + // return the current set + return sceneOverrides; } return null; diff --git a/MatterControlLib/DesignTools/Operations/PartSettingsObject3D.cs b/MatterControlLib/DesignTools/Operations/PartSettingsObject3D.cs index e0a14c4bb..a4b73e3d9 100644 --- a/MatterControlLib/DesignTools/Operations/PartSettingsObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/PartSettingsObject3D.cs @@ -34,6 +34,7 @@ using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.PolygonMesh; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; namespace MatterHackers.MatterControl.DesignTools.Operations @@ -152,11 +153,23 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { var data = SliceSettingsRow.GetStyleData(containingPrinter, ApplicationController.Instance.Theme, settingsContext, setting.Key, true); - if (!settingsToIgnore.Contains(setting.Key) && data.showRestoreButton) + if (!settingsToIgnore.Contains(setting.Key) + && data.showRestoreButton + && SliceSettingsLayouts.ContainesKey(SliceSettingsLayouts.SliceSettings(), setting.Key)) { Overrides[setting.Key] = setting.Value; } } + + foreach (var setting in Overrides.ToList()) + { + if (!SliceSettingsLayouts.ContainesKey(SliceSettingsLayouts.SliceSettings(), setting.Key)) + { + Overrides.Remove(setting.Key); + } + } + + UpdateSettingsDisplay(containingPrinter); }, Name = "Add User Overrides".Localize(), @@ -183,20 +196,20 @@ namespace MatterHackers.MatterControl.DesignTools.Operations // set this after the PrinterConfig is constructed to change it to overrides settings.GetSceneLayer = () => Overrides; - var presetsContext = new PresetsContext(null, printer.Settings.SceneLayer) + var presetsContext = new PresetsContext(null, Overrides) { LayerType = NamedSettingsLayers.Scene, }; - var editMaterialPresetsPage = new SlicePresetsPage(printer, presetsContext, false); - editMaterialPresetsPage.Closed += (s, e2) => + var editPartSettingsPresetsPage = new SlicePresetsPage(printer, presetsContext, false); + editPartSettingsPresetsPage.Closed += (s, e2) => { ApplicationController.Instance.AcitveSlicePresetsPage = null; UpdateSettingsDisplay(containingPrinter); }; - ApplicationController.Instance.AcitveSlicePresetsPage = editMaterialPresetsPage; - DialogWindow.Show(editMaterialPresetsPage); + ApplicationController.Instance.AcitveSlicePresetsPage = editPartSettingsPresetsPage; + DialogWindow.Show(editPartSettingsPresetsPage); }, Name = "Edit".Localize(), }; diff --git a/MatterControlLib/DesignTools/Operations/PlaneCutObject3D.cs b/MatterControlLib/DesignTools/Operations/PlaneCutObject3D.cs index 00d150e9a..91e756c03 100644 --- a/MatterControlLib/DesignTools/Operations/PlaneCutObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/PlaneCutObject3D.cs @@ -129,16 +129,22 @@ namespace MatterHackers.MatterControl.DesignTools } mesh.Faces = new FaceList(keptFaces); + + mesh.CleanAndMerge(); } - public override Task Rebuild() + public override AxisAlignedBoundingBox GetAxisAlignedBoundingBox(Matrix4X4 matrix) + { + var aabb = base.GetAxisAlignedBoundingBox(matrix); + return aabb; + } + + public override Task Rebuild() { this.DebugDepth("Rebuild"); var rebuildLocks = this.RebuilLockAll(); - var valuesChanged = false; - return TaskBuilder( "Plane Cut".Localize(), (reporter, cancellationToken) => @@ -148,11 +154,11 @@ namespace MatterHackers.MatterControl.DesignTools root = root == null ? SourceContainer : root; foreach (var sourceItem in SourceContainer.VisibleMeshes()) { - var reducedMesh = Cut(sourceItem); + var cutMesh = Cut(sourceItem); var newMesh = new Object3D() { - Mesh = reducedMesh, + Mesh = cutMesh, OwnerID = sourceItem.ID }; newMesh.CopyWorldProperties(sourceItem, root, Object3DPropertyFlags.All); diff --git a/MatterControlLib/SlicerConfiguration/SliceSettingsRow.cs b/MatterControlLib/SlicerConfiguration/SliceSettingsRow.cs index 9f1d91028..03b778118 100644 --- a/MatterControlLib/SlicerConfiguration/SliceSettingsRow.cs +++ b/MatterControlLib/SlicerConfiguration/SliceSettingsRow.cs @@ -546,7 +546,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration break; case NamedSettingsLayers.Scene: highlightColor = theme.PresetColors.ScenePreset; - showRestoreButton = false; + showRestoreButton = true; break; } } diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index bc96dac61..e754c8142 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit bc96dac612a6cb3bff321b96657d5cdaef5b28d6 +Subproject commit e754c81428db89bb94fadac23f026de7579bff8f