From 7743a34a8740d4548e078abdf1c012bbf6737e88 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 17 Dec 2018 16:12:11 -0800 Subject: [PATCH 1/4] Don't call ExandedChianged twice in TreeView Let MeshWrapper call GetAxisAl/ignedBoundingBox from base --- .../CustomWidgets/TreeView/TreeNode.cs | 1 - .../View3D/Actions/MeshWrapperObject3D.cs | 28 ------------------- Submodules/agg-sharp | 2 +- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/MatterControlLib/CustomWidgets/TreeView/TreeNode.cs b/MatterControlLib/CustomWidgets/TreeView/TreeNode.cs index 94df4e4f4..9c08c7313 100644 --- a/MatterControlLib/CustomWidgets/TreeView/TreeNode.cs +++ b/MatterControlLib/CustomWidgets/TreeView/TreeNode.cs @@ -91,7 +91,6 @@ namespace MatterHackers.MatterControl.CustomWidgets expandWidget.Click += (s, e) => { this.Expanded = !this.Expanded; - this.ExpandedChanged?.Invoke(this, null); expandWidget.Expanded = this.Expanded; }; diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs index 8aa45211b..609764a5a 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs @@ -73,34 +73,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D base.Flatten(undoBuffer); } - /// - /// MeshWrapperObject3D overrides GetAabb so that it can only check the geometry that it has created - /// - /// - /// - public override AxisAlignedBoundingBox GetAxisAlignedBoundingBox(Matrix4X4 matrix) - { - AxisAlignedBoundingBox totalBounds = AxisAlignedBoundingBox.Empty(); - - // This needs to be Descendants because we need to move past the first visible mesh to our owned objects - foreach (var child in this.Descendants().Where(i => i.OwnerID == this.ID && i.Visible)) - { - var childMesh = child.Mesh; - if (childMesh != null) - { - // Add the bounds of each child object - var childBounds = childMesh.GetAxisAlignedBoundingBox(child.WorldMatrix(this) * matrix); - // Check if the child actually has any bounds - if (childBounds.XSize > 0) - { - totalBounds += childBounds; - } - } - } - - return totalBounds; - } - public IEnumerable<(IObject3D original, IObject3D meshCopy)> WrappedObjects() { return this.Descendants() diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index c0dd75b18..7025350cc 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit c0dd75b189ef909264a736e7d9db9eca67a0c333 +Subproject commit 7025350cc177646c67ec926ee0ca7a7f914d63be From f0fc1234e7513a9cbf08ea4c76dc0116cdc4e34c Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 17 Dec 2018 18:53:52 -0800 Subject: [PATCH 2/4] making more macro replaces work issue: MatterHackers/MCCentral#4720 [temperature1] not working correctly --- MatterControlLib/ApplicationView/PrinterConfig.cs | 3 +++ StaticData/SliceSettings/Properties.json | 9 --------- Submodules/agg-sharp | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/MatterControlLib/ApplicationView/PrinterConfig.cs b/MatterControlLib/ApplicationView/PrinterConfig.cs index 4796c4ed3..feaca771b 100644 --- a/MatterControlLib/ApplicationView/PrinterConfig.cs +++ b/MatterControlLib/ApplicationView/PrinterConfig.cs @@ -85,6 +85,9 @@ namespace MatterHackers.MatterControl new MappedSetting(this, SettingsKey.temperature,SettingsKey.temperature), new MappedSetting(this, "z_offset","z_offset"), new MappedSetting(this, SettingsKey.bed_temperature,SettingsKey.bed_temperature), + new MappedSetting(this, SettingsKey.temperature1, SettingsKey.temperature1), + new MappedSetting(this, SettingsKey.temperature2, SettingsKey.temperature2), + new MappedSetting(this, SettingsKey.temperature3, SettingsKey.temperature3), new ScaledSingleNumber(this, "infill_speed", "infill_speed", 60), new ScaledSingleNumber(this, "min_print_speed", "min_print_speed", 60), new ScaledSingleNumber(this, "perimeter_speed","perimeter_speed", 60), diff --git a/StaticData/SliceSettings/Properties.json b/StaticData/SliceSettings/Properties.json index e35115dc0..c7b18e1cb 100644 --- a/StaticData/SliceSettings/Properties.json +++ b/StaticData/SliceSettings/Properties.json @@ -404,15 +404,6 @@ "ShowIfSet": "!sla_printer", "DefaultValue": "1" }, - { - "SlicerConfigName": "first_layer_bed_temperature", - "PresentationName": "Bed First Layer", - "HelpText": "The temperature to set the bed to before printing the first layer. The printer will wait until this temperature has been reached before printing. Set to 0 to eliminate bed temperature commands.", - "DataEditType": "DOUBLE", - "Units": "°C", - "ShowIfSet": "has_heated_bed", - "DefaultValue": "75" - }, { "SlicerConfigName": "first_layer_extrusion_width", "PresentationName": "First Layer", diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 7025350cc..f5b0a3891 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 7025350cc177646c67ec926ee0ca7a7f914d63be +Subproject commit f5b0a3891ca2fe22a914f9e89d39f2f0f722e2ec From 5910236d5f18697df712fb5c2787a2e51852441a Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 18 Dec 2018 10:05:05 -0800 Subject: [PATCH 3/4] Fixed Flatten in mesh wrapper Reverted GetAxisAlignedBoundingBox in mesh wrapper Have less initialization in FitToBounds --- .../Operations/FitToBoundsObject3D_2.cs | 7 ++- .../DesignTools/Operations/PinchObject3D.cs | 8 +++ .../View3D/Actions/MeshWrapperObject3D.cs | 61 ++++++++++++++++--- Submodules/agg-sharp | 2 +- .../MatterControl/InteractiveSceneTests.cs | 1 - 5 files changed, 66 insertions(+), 13 deletions(-) diff --git a/MatterControlLib/DesignTools/Operations/FitToBoundsObject3D_2.cs b/MatterControlLib/DesignTools/Operations/FitToBoundsObject3D_2.cs index 7d64da3d2..d6828bc4a 100644 --- a/MatterControlLib/DesignTools/Operations/FitToBoundsObject3D_2.cs +++ b/MatterControlLib/DesignTools/Operations/FitToBoundsObject3D_2.cs @@ -78,9 +78,10 @@ namespace MatterHackers.MatterControl.DesignTools.Operations scaleItem.Children.Add(itemToFit); fitToBounds.Children.Add(bounds); - fitToBounds.SizeX = aabb.XSize; - fitToBounds.SizeY = aabb.YSize; - fitToBounds.SizeZ = aabb.ZSize; + fitToBounds.boundsSize.X = aabb.XSize; + fitToBounds.boundsSize.Y = aabb.YSize; + fitToBounds.boundsSize.Z = aabb.ZSize; + fitToBounds.Rebuild(null); return fitToBounds; } diff --git a/MatterControlLib/DesignTools/Operations/PinchObject3D.cs b/MatterControlLib/DesignTools/Operations/PinchObject3D.cs index a81664503..923e68751 100644 --- a/MatterControlLib/DesignTools/Operations/PinchObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/PinchObject3D.cs @@ -42,6 +42,14 @@ namespace MatterHackers.MatterControl.DesignTools public PinchObject3D() { Name = "Pinch".Localize(); + // TODO: This feels like the wronge approach. I think changing the safe list should always + // call into invalidate for every Object3D (this will cause a lot of classes to need to be fixed). + Children.ItemsModified += Children_ItemsModified; + } + + private void Children_ItemsModified(object sender, System.EventArgs e) + { + OnInvalidate(new InvalidateArgs(null, InvalidateType.Content)); } [DisplayName("Back Ratio")] diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs index 609764a5a..2ba118dfe 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs @@ -49,30 +49,75 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D public override void Flatten(UndoBuffer undoBuffer) { - var meshWrappers = this.Descendants().Where(o => o.OwnerID == this.ID).ToList(); + var ownedMeshWrappers = this.Descendants().Where(o => o.OwnerID == this.ID).ToList(); + + var newMeshObjects = new List(); // remove all the meshWrappers (collapse the children) - foreach (var meshWrapper in meshWrappers) + foreach (var ownedMeshWrapper in ownedMeshWrappers) { - var parent = meshWrapper.Parent; - if (meshWrapper.Visible) + var wrapperParent = ownedMeshWrapper.Parent; + if (ownedMeshWrapper.Visible) { var newMesh = new Object3D() { - Mesh = meshWrapper.Mesh + Mesh = ownedMeshWrapper.Mesh.Copy(CancellationToken.None) }; - newMesh.CopyProperties(meshWrapper, Object3DPropertyFlags.All); + newMesh.CopyProperties(ownedMeshWrapper, Object3DPropertyFlags.All); + var matrix = ownedMeshWrapper.WorldMatrix(this); + newMesh.Mesh.Transform(matrix); + newMesh.Matrix = Matrix4X4.Identity; newMesh.Name = this.Name; - parent.Children.Add(newMesh); + newMeshObjects.Add(newMesh); } // remove it - parent.Children.Remove(meshWrapper); + wrapperParent.Children.Remove(ownedMeshWrapper); } + this.Matrix = Matrix4X4.Identity; + + this.Children.Modify(children => + { + children.Clear(); + children.AddRange(newMeshObjects); + foreach(var child in children) + { + child.MakeNameNonColliding(); + } + }); + base.Flatten(undoBuffer); } + /// + /// MeshWrapperObject3D overrides GetAabb so that it can only check the geometry that it has created + /// + /// + /// + public override AxisAlignedBoundingBox GetAxisAlignedBoundingBox(Matrix4X4 matrix) + { + AxisAlignedBoundingBox totalBounds = AxisAlignedBoundingBox.Empty(); + + // This needs to be Descendants because we need to move past the first visible mesh to our owned objects + foreach (var child in this.Descendants().Where(i => i.OwnerID == this.ID && i.Visible)) + { + var childMesh = child.Mesh; + if (childMesh != null) + { + // Add the bounds of each child object + var childBounds = childMesh.GetAxisAlignedBoundingBox(child.WorldMatrix(this) * matrix); + // Check if the child actually has any bounds + if (childBounds.XSize > 0) + { + totalBounds += childBounds; + } + } + } + + return totalBounds; + } + public IEnumerable<(IObject3D original, IObject3D meshCopy)> WrappedObjects() { return this.Descendants() diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index f5b0a3891..c583dd6d0 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit f5b0a3891ca2fe22a914f9e89d39f2f0f722e2ec +Subproject commit c583dd6d0a62f478e456a25552935370446ab099 diff --git a/Tests/MatterControl.Tests/MatterControl/InteractiveSceneTests.cs b/Tests/MatterControl.Tests/MatterControl/InteractiveSceneTests.cs index 362a85937..1cbcf61a3 100644 --- a/Tests/MatterControl.Tests/MatterControl/InteractiveSceneTests.cs +++ b/Tests/MatterControl.Tests/MatterControl/InteractiveSceneTests.cs @@ -62,7 +62,6 @@ namespace MatterControl.Tests.MatterControl { var root = new Object3D(); var cube = new CubeObject3D(20, 20, 20); - root.Children.Add(cube); var fit = FitToBoundsObject3D_2.Create(cube); fit.SizeX = 50; From 147cf829c421893512885797c271e5c7daf5026c Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 18 Dec 2018 11:29:44 -0800 Subject: [PATCH 4/4] Fixing first layer temp test --- .../ApplicationView/PrinterConfig.cs | 2 +- .../EngineMappingMatterSlice.cs | 1 + .../MappingClasses/ReplaceWithSetting.cs | 44 +++++++++++++++++++ .../MatterControl/GCodeProcessingTests.cs | 2 +- 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 MatterControlLib/SlicerConfiguration/MappingClasses/ReplaceWithSetting.cs diff --git a/MatterControlLib/ApplicationView/PrinterConfig.cs b/MatterControlLib/ApplicationView/PrinterConfig.cs index feaca771b..227477f27 100644 --- a/MatterControlLib/ApplicationView/PrinterConfig.cs +++ b/MatterControlLib/ApplicationView/PrinterConfig.cs @@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl new MappedSetting(this, "air_gap_speed", "air_gap_speed"), new MappedSetting(this, "extruder_wipe_temperature","extruder_wipe_temperature"), new MappedSetting(this, SettingsKey.filament_diameter,SettingsKey.filament_diameter), - new MappedSetting(this, "first_layer_bed_temperature", SettingsKey.bed_temperature), + new ReplaceWithSetting(this, "first_layer_bed_temperature", SettingsKey.bed_temperature, SettingsKey.bed_temperature), new MappedSetting(this, "first_layer_temperature", SettingsKey.temperature), new MappedSetting(this, SettingsKey.max_fan_speed,"max_fan_speed"), new MappedSetting(this, SettingsKey.min_fan_speed,"min_fan_speed"), diff --git a/MatterControlLib/SlicerConfiguration/EngineMappingMatterSlice.cs b/MatterControlLib/SlicerConfiguration/EngineMappingMatterSlice.cs index 4068908ba..eb5f5ef7d 100644 --- a/MatterControlLib/SlicerConfiguration/EngineMappingMatterSlice.cs +++ b/MatterControlLib/SlicerConfiguration/EngineMappingMatterSlice.cs @@ -49,6 +49,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration "enable_fan", "extruder_wipe_temperature", "extruders_share_temperature", + "first_layer_bed_temperature", "g0", "layer_to_pause", "selector_ip_address", diff --git a/MatterControlLib/SlicerConfiguration/MappingClasses/ReplaceWithSetting.cs b/MatterControlLib/SlicerConfiguration/MappingClasses/ReplaceWithSetting.cs new file mode 100644 index 000000000..1fbda0f5e --- /dev/null +++ b/MatterControlLib/SlicerConfiguration/MappingClasses/ReplaceWithSetting.cs @@ -0,0 +1,44 @@ +/* +Copyright (c) 2016, 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. +*/ + +namespace MatterHackers.MatterControl.SlicerConfiguration.MappingClasses +{ + public class ReplaceWithSetting : MappedSetting + { + string replaceSettingsName; + + public ReplaceWithSetting(PrinterConfig printer, string canonicalSettingsName, string replaceSettingsName, string exportedName) + : base(printer, canonicalSettingsName, exportedName) + { + this.replaceSettingsName = replaceSettingsName; + } + + public override string Value => printer.Settings.GetValue(replaceSettingsName); + } +} \ No newline at end of file diff --git a/Tests/MatterControl.Tests/MatterControl/GCodeProcessingTests.cs b/Tests/MatterControl.Tests/MatterControl/GCodeProcessingTests.cs index b7aeacca3..f9e8e2e93 100644 --- a/Tests/MatterControl.Tests/MatterControl/GCodeProcessingTests.cs +++ b/Tests/MatterControl.Tests/MatterControl/GCodeProcessingTests.cs @@ -89,7 +89,7 @@ namespace MatterControl.Tests.MatterControl TestMacroReplacement("[external_perimeter_speed]", "1260"); TestMacroReplacement("[extruder_wipe_temperature]", "0"); TestMacroReplacement("[filament_diameter]", "3"); - TestMacroReplacement("[first_layer_bed_temperature]", "75"); + TestMacroReplacement("[first_layer_bed_temperature]", "70"); TestMacroReplacement("[first_layer_temperature]", "205"); TestMacroReplacement("{max_fan_speed}", "100"); TestMacroReplacement("{min_fan_speed}", "35");