Make Part Setting have undo support
Make checking for scene overrides check if the scene has changed first faster MeshAllowedBounds calculation
This commit is contained in:
parent
7154180e50
commit
e218b6b961
5 changed files with 103 additions and 39 deletions
|
|
@ -367,6 +367,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
private RectangleDouble _meshAllowedBounds;
|
||||
|
||||
/// <summary>
|
||||
/// The bounds that a mesh can be placed at and the gcode it creates will be within the bed
|
||||
/// </summary>
|
||||
|
|
@ -375,38 +379,48 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
get
|
||||
{
|
||||
var firstLayerExtrusionWidth = GetDouble(SettingsKey.first_layer_extrusion_width);
|
||||
var bedBounds = BedBounds;
|
||||
var totalOffset = 0.0;
|
||||
|
||||
if (GetBool(SettingsKey.create_raft))
|
||||
{
|
||||
// The slicing engine creates a raft 3x the extrusion width
|
||||
firstLayerExtrusionWidth *= 3;
|
||||
totalOffset += firstLayerExtrusionWidth;
|
||||
totalOffset += GetDouble(SettingsKey.raft_extra_distance_around_part);
|
||||
}
|
||||
|
||||
if (GetBool(SettingsKey.create_skirt))
|
||||
if (_meshAllowedBounds.Width == 0)
|
||||
{
|
||||
totalOffset += GetValue<double>(SettingsKey.skirt_distance);
|
||||
totalOffset += (GetDouble(SettingsKey.skirts) + .5) * firstLayerExtrusionWidth;
|
||||
// for every 400mm of min skirt length add another skirt loops
|
||||
totalOffset += GetDouble(SettingsKey.min_skirt_length) / (20 * 20);
|
||||
CacluateMeshAllowedBounds();
|
||||
}
|
||||
|
||||
if (GetBool(SettingsKey.create_brim)
|
||||
&& !GetBool(SettingsKey.create_raft))
|
||||
{
|
||||
totalOffset += GetValue<double>(SettingsKey.brims) * GetDouble(SettingsKey.first_layer_extrusion_width);
|
||||
}
|
||||
|
||||
bedBounds.Inflate(-totalOffset);
|
||||
|
||||
return bedBounds;
|
||||
return _meshAllowedBounds;
|
||||
}
|
||||
}
|
||||
|
||||
private void CacluateMeshAllowedBounds()
|
||||
{
|
||||
var firstLayerExtrusionWidth = GetDouble(SettingsKey.first_layer_extrusion_width);
|
||||
var bedBounds = BedBounds;
|
||||
var totalOffset = 0.0;
|
||||
|
||||
if (GetBool(SettingsKey.create_raft))
|
||||
{
|
||||
// The slicing engine creates a raft 3x the extrusion width
|
||||
firstLayerExtrusionWidth *= 3;
|
||||
totalOffset += firstLayerExtrusionWidth;
|
||||
totalOffset += GetDouble(SettingsKey.raft_extra_distance_around_part);
|
||||
}
|
||||
|
||||
if (GetBool(SettingsKey.create_skirt))
|
||||
{
|
||||
totalOffset += GetValue<double>(SettingsKey.skirt_distance);
|
||||
totalOffset += (GetDouble(SettingsKey.skirts) + .5) * firstLayerExtrusionWidth;
|
||||
// for every 400mm of min skirt length add another skirt loops
|
||||
totalOffset += GetDouble(SettingsKey.min_skirt_length) / (20 * 20);
|
||||
}
|
||||
|
||||
if (GetBool(SettingsKey.create_brim)
|
||||
&& !GetBool(SettingsKey.create_raft))
|
||||
{
|
||||
totalOffset += GetValue<double>(SettingsKey.brims) * GetDouble(SettingsKey.first_layer_extrusion_width);
|
||||
}
|
||||
|
||||
bedBounds.Inflate(-totalOffset);
|
||||
|
||||
_meshAllowedBounds = bedBounds;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public IEnumerable<PrinterSettingsLayer> DefaultLayerCascade
|
||||
{
|
||||
|
|
@ -1028,6 +1042,22 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
this.ResetHotendBounds();
|
||||
}
|
||||
|
||||
if (slicerConfigName == SettingsKey.first_layer_extrusion_width
|
||||
|| slicerConfigName == SettingsKey.create_raft
|
||||
|| slicerConfigName == SettingsKey.raft_extra_distance_around_part
|
||||
|| slicerConfigName == SettingsKey.create_skirt
|
||||
|| slicerConfigName == SettingsKey.skirt_distance
|
||||
|| slicerConfigName == SettingsKey.skirts
|
||||
|| slicerConfigName == SettingsKey.min_skirt_length
|
||||
|| slicerConfigName == SettingsKey.create_brim
|
||||
|| slicerConfigName == SettingsKey.print_center
|
||||
|| slicerConfigName == SettingsKey.bed_size
|
||||
|| slicerConfigName == SettingsKey.bed_shape)
|
||||
{
|
||||
// cleare this so it will be recaculated
|
||||
_meshAllowedBounds = new RectangleDouble();
|
||||
}
|
||||
|
||||
SettingChanged?.Invoke(this, new StringEventArgs(slicerConfigName));
|
||||
AnyPrinterSettingChanged?.Invoke(this, new StringEventArgs(slicerConfigName));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,13 +72,20 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private RunningInterval checkForSceneLayer;
|
||||
private object locker = new object();
|
||||
private ulong undoBufferHashCode = 0;
|
||||
|
||||
private PrinterSettingsLayer GetSceneLayer()
|
||||
{
|
||||
var scene = Bed?.Scene;
|
||||
if (scene != null)
|
||||
{
|
||||
var foundPartSettings = false;
|
||||
if (sceneOverrides != null
|
||||
&& undoBufferHashCode == scene.UndoBuffer.GetLongHashCode())
|
||||
{
|
||||
return sceneOverrides;
|
||||
}
|
||||
|
||||
var foundPartSettings = false;
|
||||
var newSceneOverrides = 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 && c.Parent?.WorldPrintable() == true).OrderBy(i => i.Name))
|
||||
|
|
@ -155,6 +162,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
// return the current set
|
||||
undoBufferHashCode = scene.UndoBuffer.GetLongHashCode();
|
||||
return sceneOverrides;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
var worldMatrix = item.WorldMatrix();
|
||||
// probably need , true (require precision)
|
||||
// probably need, true (require precision)
|
||||
var aabb = item.Mesh.GetAxisAlignedBoundingBox(worldMatrix);
|
||||
|
||||
var bed = printerConfig.Bed;
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
{
|
||||
Action = () =>
|
||||
{
|
||||
var startingOverrides = new PrinterSettingsLayer(Overrides);
|
||||
var editOverrides = new PrinterSettingsLayer(Overrides);
|
||||
|
||||
var settingsContext = new SettingsContext(containingPrinter, null, NamedSettingsLayers.All);
|
||||
foreach (var setting in containingPrinter.Settings.UserLayer.ToList())
|
||||
{
|
||||
|
|
@ -180,21 +183,30 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
&& SliceSettingsLayouts.ContainesKey(SliceSettingsLayouts.SliceSettings(), setting.Key)
|
||||
&& SliceSettingsTabView.CheckIfShouldBeShown(PrinterSettings.SettingsData[setting.Key], settingsContext))
|
||||
{
|
||||
Overrides[setting.Key] = setting.Value;
|
||||
editOverrides[setting.Key] = setting.Value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var setting in Overrides.ToList())
|
||||
foreach (var setting in editOverrides.ToList())
|
||||
{
|
||||
if (!SliceSettingsLayouts.ContainesKey(SliceSettingsLayouts.SliceSettings(), setting.Key)
|
||||
|| !SliceSettingsTabView.CheckIfShouldBeShown(PrinterSettings.SettingsData[setting.Key], settingsContext))
|
||||
{
|
||||
Overrides.Remove(setting.Key);
|
||||
editOverrides.Remove(setting.Key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UpdateSettingsDisplay();
|
||||
var scene = this.ContainingScene();
|
||||
scene.UndoBuffer.AddAndDo(new UndoRedoActions(() =>
|
||||
{
|
||||
Overrides = new PrinterSettingsLayer(startingOverrides);
|
||||
UpdateSettingsDisplay();
|
||||
},
|
||||
() =>
|
||||
{
|
||||
Overrides = new PrinterSettingsLayer(editOverrides);
|
||||
UpdateSettingsDisplay();
|
||||
}));
|
||||
},
|
||||
Name = "Add User Overrides".Localize(),
|
||||
HelpText = "Copy in all current user overides".Localize()
|
||||
|
|
@ -207,7 +219,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
Action = () =>
|
||||
{
|
||||
var settings = new PrinterSettings();
|
||||
settings.GetSceneLayer = () => Overrides;
|
||||
var startingOverrides = new PrinterSettingsLayer(Overrides);
|
||||
var editOverrides = new PrinterSettingsLayer(Overrides);
|
||||
settings.GetSceneLayer = () => editOverrides;
|
||||
var printer = new PrinterConfig(settings);
|
||||
if (containingPrinter != null)
|
||||
{
|
||||
|
|
@ -216,9 +230,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
|
||||
// set this after the PrinterConfig is constructed to change it to overrides
|
||||
// set this after the PrinterConfig is constructed to change it to overrides
|
||||
settings.GetSceneLayer = () => Overrides;
|
||||
settings.GetSceneLayer = () => editOverrides;
|
||||
|
||||
var presetsContext = new PresetsContext(null, Overrides)
|
||||
var presetsContext = new PresetsContext(null, editOverrides)
|
||||
{
|
||||
LayerType = NamedSettingsLayers.Scene,
|
||||
};
|
||||
|
|
@ -227,9 +241,21 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
editPartSettingsPresetsPage.Closed += (s, e2) =>
|
||||
{
|
||||
ApplicationController.Instance.AcitveSlicePresetsPage = null;
|
||||
UpdateSettingsDisplay();
|
||||
};
|
||||
|
||||
// push the new settings into this object
|
||||
var scene = this.ContainingScene();
|
||||
scene.UndoBuffer.AddAndDo(new UndoRedoActions(() =>
|
||||
{
|
||||
Overrides = new PrinterSettingsLayer(startingOverrides);
|
||||
UpdateSettingsDisplay();
|
||||
},
|
||||
() =>
|
||||
{
|
||||
Overrides = new PrinterSettingsLayer(editOverrides);
|
||||
UpdateSettingsDisplay();
|
||||
}));
|
||||
};
|
||||
|
||||
ApplicationController.Instance.AcitveSlicePresetsPage = editPartSettingsPresetsPage;
|
||||
DialogWindow.Show(editPartSettingsPresetsPage);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 3ed0d3e0d5fe7368273223553b87e86895efe281
|
||||
Subproject commit 09c9c93a84e57821ec65c17114acb629ac5320af
|
||||
Loading…
Add table
Add a link
Reference in a new issue