Files
UVtools/UVtools.Core/Operations/OperationFlip.cs
T
Tiago Conceição a4bdf8f9f3 v1.3.2
* (Add) Tools: Warn where layer preview is critical for use the tool, must disable layer rotation first (#100)
* (Add) CWS: Bottom lift speed property
* (Add) CWS: Support Wanhao Workshop CWX and Wanhao Creation Workshop file types (#98)
* (Add) CWS: Split format into virtual extensions (.cws, .rgb.cws, .xml.cws) to support diferent file formats and diferent printers under same main .cws extensions. That will affect file converts only to let UVtools know what type of encoding to use. Load and save a xxx.cws file will always auto decode/encode the file for the correct target format no matter the extension.
* (Improvement) CWS: It no longer search for a specific filename in the zip file, instead it look for extension to get the files to ensure it always found them no matter the file name system
* (Fix) CWS: When "Save as" the file were generating sub files with .cws extension, eg: filename0001.cws.png
* (Change) Allow read empty layers without error from Anycubic files (PWS, PW0, PWxx) due a bug on slicer software under macOS
2020-11-19 04:23:37 +00:00

106 lines
3.7 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 Emgu.CV.CvEnum;
namespace UVtools.Core.Operations
{
[Serializable]
public class OperationFlip : Operation
{
private bool _makeCopy;
private Enumerations.FlipDirection _flipDirection = Enumerations.FlipDirection.Horizontally;
public override string Title => "Flip";
public override string Description =>
"Flip the layers of the model vertically and/or horizontally.\n" +
"Note: Before perform this operation, un-rotate the layer preview to see the real orientation.";
public override string ConfirmationText =>
FlipDirection == Enumerations.FlipDirection.Both
? $"flip {(MakeCopy == true? "and blend ":"")}layers {LayerIndexStart} through {LayerIndexEnd} Horizontally and Vertically?"
: $"flip {(MakeCopy == true ? "and blend " : "")}layers {LayerIndexStart} through {LayerIndexEnd} {FlipDirection}?";
public override string ProgressTitle =>
FlipDirection == Enumerations.FlipDirection.Both
? $"Flipping {(MakeCopy == true ? "and blending " : "")}layers {LayerIndexStart} through {LayerIndexEnd} Horizontally and Vertically"
: $"Flipping {(MakeCopy == true ? "and blending " : "")}layers {LayerIndexStart} through {LayerIndexEnd} {FlipDirection}";
public override string ProgressAction => "Flipped layers";
public Enumerations.FlipDirection FlipDirection
{
get => _flipDirection;
set => RaiseAndSetIfChanged(ref _flipDirection, value);
}
public bool MakeCopy
{
get => _makeCopy;
set => RaiseAndSetIfChanged(ref _makeCopy, value);
}
public static Array FlipDirections => Enum.GetValues(typeof(Enumerations.FlipDirection));
public FlipType FlipTypeOpenCV
{
get
{
var flipType = FlipType.Horizontal;
switch (FlipDirection)
{
case Enumerations.FlipDirection.Horizontally:
flipType = FlipType.Horizontal;
break;
case Enumerations.FlipDirection.Vertically:
flipType = FlipType.Vertical;
break;
case Enumerations.FlipDirection.Both:
flipType = FlipType.Horizontal | FlipType.Vertical;
break;
}
return flipType;
}
}
public override string ToString()
{
var result = $"[{_flipDirection}] [Blend: {_makeCopy}]" + LayerRangeString;
if (!string.IsNullOrEmpty(ProfileName)) result = $"{ProfileName}: {result}";
return result;
}
#region Equality
protected bool Equals(OperationFlip other)
{
return _makeCopy == other._makeCopy && _flipDirection == other._flipDirection;
}
public override bool Equals(object obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((OperationFlip) obj);
}
public override int GetHashCode()
{
unchecked
{
return (_makeCopy.GetHashCode() * 397) ^ (int) _flipDirection;
}
}
#endregion
}
}