mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-12 19:42:32 +02:00
65ef92d7f0
* **Scripting:** * Add scripting capability, this allow to run external scripts inside the GUI and take advantage of visual layout to display user input fields * Scripts run under the "Roslyn Scripting API" and can make use of the whole C# language, this mean a huge boost compared to PowerShell scripts * Scripts are written in the same way UVtools is, by learning and programing scripts you are learning the UVtools core * For more information see the script sample: https://github.com/sn4k3/UVtools/tree/master/UVtools.ScriptSample * To run scripts go to: Tools - Scripting * **File formats:** * Add a check and warning when opening an file that have a diferent layer and file resolution * **Issues:** * Add "Print height" as new type of issue detection, all layers that goes beyond maximum printer Z height will be flagged as PrintHeight issue * Print height issues will not be automatical fixed, however user can fix it by remove some layers to counter the problem, still is recommended to resize object on slicer * Fix unable to compute issues when only islands or overhangs are selected to be detected alone (#177) * **Settings:** * Add default directory for scripts on "General - File dialogs" * Add checkbox on "Issues - Compute - Print height" to enable or disable this type of detection * Add numerical on "Issues - Print height - Offset" to define a custom offset from Z top * Fix default directories input width to not grow with text, it was overflowing on large strings * **Menu - Help:** * Add web link to "Wiki & tutorials" * Add web link to "Facebook group" * Add web link to "Report a issue" * Add web link to "Ask a question" * Add web link to "Suggest an improvement or new features"
130 lines
3.9 KiB
C#
130 lines
3.9 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using UVtools.Core.FileFormats;
|
|
|
|
namespace UVtools.Core.Operations
|
|
{
|
|
[Serializable]
|
|
public sealed class OperationLayerRemove : Operation
|
|
{
|
|
#region Overrides
|
|
|
|
public override Enumerations.LayerRangeSelection StartLayerRangeSelection => Enumerations.LayerRangeSelection.Current;
|
|
public override bool CanROI => false;
|
|
public override bool PassActualLayerIndex => true;
|
|
|
|
public override string Title => "Remove layers";
|
|
|
|
public override string Description =>
|
|
"Remove Layers in a given range.";
|
|
|
|
public override string ConfirmationText =>
|
|
$"remove layers {LayerIndexStart} through {LayerIndexEnd}?";
|
|
|
|
public override string ProgressTitle =>
|
|
$"Removing layers {LayerIndexStart} through {LayerIndexEnd}";
|
|
|
|
public override string ProgressAction => "Removed layers";
|
|
|
|
public override bool CanCancel => false;
|
|
|
|
public override bool CanHaveProfiles => false;
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public OperationLayerRemove() { }
|
|
|
|
public OperationLayerRemove(FileFormat slicerFile) : base(slicerFile) { }
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
protected override bool ExecuteInternally(OperationProgress progress)
|
|
{
|
|
progress.CanCancel = false;
|
|
var layersRemove = new List<uint>();
|
|
for (uint layerIndex = LayerIndexStart; layerIndex <= LayerIndexEnd; layerIndex++)
|
|
{
|
|
layersRemove.Add(layerIndex);
|
|
}
|
|
|
|
return RemoveLayers(SlicerFile, layersRemove, progress);
|
|
}
|
|
|
|
public static bool RemoveLayers(FileFormat slicerFile, List<uint> layersRemove, OperationProgress progress = null)
|
|
{
|
|
if (layersRemove.Count == 0) return false;
|
|
|
|
progress ??= new OperationProgress(false);
|
|
|
|
progress.Reset("Removed layers", (uint)layersRemove.Count);
|
|
|
|
foreach (var layerIndex in layersRemove)
|
|
{
|
|
slicerFile[layerIndex] = null;
|
|
progress++;
|
|
}
|
|
|
|
slicerFile.LayerManager.RemoveNulls();
|
|
|
|
/*var oldLayers = slicerFile.LayerManager.Layers;
|
|
var layerHeight = slicerFile.LayerHeight;
|
|
|
|
var layers = new Layer[oldLayers.Length - layersRemove.Count];
|
|
|
|
// Re-set
|
|
uint newLayerIndex = 0;
|
|
for (uint layerIndex = 0; layerIndex < oldLayers.Length; layerIndex++)
|
|
{
|
|
if (layersRemove.Contains(layerIndex)) continue;
|
|
layers[newLayerIndex] = oldLayers[layerIndex];
|
|
layers[newLayerIndex].Index = newLayerIndex;
|
|
|
|
// Re-Z
|
|
float posZ = layerHeight;
|
|
if (newLayerIndex > 0)
|
|
{
|
|
if (oldLayers[layerIndex - 1].PositionZ == oldLayers[layerIndex].PositionZ)
|
|
{
|
|
posZ = layers[newLayerIndex - 1].PositionZ;
|
|
}
|
|
else
|
|
{
|
|
posZ = Layer.RoundHeight(layers[newLayerIndex - 1].PositionZ + layerHeight);
|
|
}
|
|
}
|
|
|
|
layers[newLayerIndex].PositionZ = posZ;
|
|
layers[newLayerIndex].IsModified = true;
|
|
|
|
newLayerIndex++;
|
|
progress++;
|
|
}
|
|
|
|
slicerFile.LayerManager.Layers = layers;*/
|
|
|
|
|
|
|
|
return true;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|