diff options
Diffstat (limited to 'UVtools.Core/Operations/OperationEditParameters.cs')
-rw-r--r-- | UVtools.Core/Operations/OperationEditParameters.cs | 67 |
1 files changed, 60 insertions, 7 deletions
diff --git a/UVtools.Core/Operations/OperationEditParameters.cs b/UVtools.Core/Operations/OperationEditParameters.cs index b31e017..b59de70 100644 --- a/UVtools.Core/Operations/OperationEditParameters.cs +++ b/UVtools.Core/Operations/OperationEditParameters.cs @@ -19,6 +19,9 @@ namespace UVtools.Core.Operations { #region Members private bool _perLayerOverride; + private uint _setNumberOfLayer = 1; + private uint _skipNumberOfLayer = 0; + #endregion #region Overrides @@ -92,23 +95,73 @@ namespace UVtools.Core.Operations get => _perLayerOverride; set => RaiseAndSetIfChanged(ref _perLayerOverride, value); } - #endregion - public OperationEditParameters() + /// <summary> + /// Gets or sets the number of sequential layers to set the parameters + /// </summary> + public uint SetNumberOfLayer { + get => _setNumberOfLayer; + set => RaiseAndSetIfChanged(ref _setNumberOfLayer, value); } - public OperationEditParameters(FileFormat.PrintParameterModifier[] modifiers) + /// <summary> + /// Gets or sets the number of sequential layers to skip after set a layer + /// </summary> + public uint SkipNumberOfLayer { - Modifiers = modifiers; + get => _skipNumberOfLayer; + set => RaiseAndSetIfChanged(ref _skipNumberOfLayer, value); } + #endregion + + #region Constructor + + public OperationEditParameters() { } + + public OperationEditParameters(FileFormat slicerFile) : base(slicerFile) { } + + public override void InitWithSlicerFile() + { + base.InitWithSlicerFile(); + SlicerFile.RefreshPrintParametersModifiersValues(); + Modifiers = SlicerFile.PrintParameterModifiers; + } + + #endregion + #region Methods - public override bool Execute(FileFormat slicerFile, OperationProgress progress = null) + protected override bool ExecuteInternally(OperationProgress progress) { - slicerFile.EditPrintParameters(this); - return true; + if (PerLayerOverride) + { + uint setLayers = 0; + for (uint layerIndex = LayerIndexStart; layerIndex <= LayerIndexEnd; layerIndex++) + { + SlicerFile[layerIndex].SetValuesFromPrintParametersModifiers(Modifiers); + if (SkipNumberOfLayer <= 0) continue; + setLayers++; + if (setLayers >= SetNumberOfLayer) + { + setLayers = 0; + layerIndex += SkipNumberOfLayer; + } + } + + foreach (var modifier in Modifiers) + { + modifier.OldValue = modifier.NewValue; + } + SlicerFile.RebuildGCode(); + } + else + { + SlicerFile.SetValuesFromPrintParametersModifiers(); + } + + return !progress.Token.IsCancellationRequested; } #endregion |