Skip to content

Commit

Permalink
v2.14.2
Browse files Browse the repository at this point in the history
- **Exposure time finder:**
   - (Add) [ME] Option: 'Use different settings for layers with same Z positioning'
   - (Add) [ME] Option: 'Lift height' for same Z positioned layers
   - (Add) [ME] Option: 'Light-off delay' for same Z positioned layers
   - (Improvement) Auto-detect and optimize the 'multiple exposures' test to decrease the print time, by set a minimal lift to almost none
   - (Improvement) Better information on the thumbnail
   - (Fix) Importing a profile would crash the application
   - (Fix) Error with 'Pattern loaded model' fails when generating more models than build plate can afford (#239)
- **GCode:**
   - (Fix) When the last layer have no lifts and a move to top command is set on end, that value were being set incorrectly as last layer position
   - (Fix) Layer parsing from mm/s to mm/m bad convertion
- (Add) File formats: Setter `SuppressRebuildGCode` to disable or enable the gcode auto rebuild when needed, set this to false to manually write your own gcode
- (Fix) ZCode: Some test files come with layer height of 0mm on a property, in that case lookup layer height on the second property as fallback
  • Loading branch information
sn4k3 committed Jul 11, 2021
1 parent 29c4854 commit 683a6f4
Show file tree
Hide file tree
Showing 23 changed files with 512 additions and 177 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 11/06/2021 - v2.14.2

- **Exposure time finder:**
- (Add) [ME] Option: 'Use different settings for layers with same Z positioning'
- (Add) [ME] Option: 'Lift height' for same Z positioned layers
- (Add) [ME] Option: 'Light-off delay' for same Z positioned layers
- (Improvement) Auto-detect and optimize the 'multiple exposures' test to decrease the print time, by set a minimal lift to almost none
- (Improvement) Better information on the thumbnail
- (Fix) Importing a profile would crash the application
- (Fix) Error with 'Pattern loaded model' fails when generating more models than build plate can afford (#239)
- **GCode:**
- (Fix) When the last layer have no lifts and a move to top command is set on end, that value were being set incorrectly as last layer position
- (Fix) Layer parsing from mm/s to mm/m bad convertion
- (Add) File formats: Setter `SuppressRebuildGCode` to disable or enable the gcode auto rebuild when needed, set this to false to manually write your own gcode
- (Add) UVtools version to error logs
- (Fix) ZCode: Some test files come with layer height of 0mm on a property, in that case lookup layer height on the second property as fallback

## 07/06/2021 - v2.14.1

- (Upgrade) EmguCV from 4.5.1 to 4.5.2
Expand All @@ -11,7 +28,7 @@
- (Fix) Division by 0 when start layer is equal to end layer
- (Fix) Calculations when using the option "Increase or decrease towards 100%"
- (Add) About window: OpenCV build number and a button to copy build information to clipboard
- (Improvement) Exposure exposure finder: Improve the **Multiple brightness** section to auto fill with correct values for file formats that use time fractions to emulate AntiAliasing, this can be used to replace the **Multiple exposures** section
- (Improvement) Exposure time finder: Improve the **Multiple brightness** section to auto fill with correct values for file formats that use time fractions to emulate AntiAliasing, this can be used to replace the **Multiple exposures** section
- (Fix) UVJ: Error when using a null or empty layer array on manifest `config.json` file (#232)
- (Fix) GCode parser: When only a G4/wait command is present on a layer it was setting the global exposure time and discard the this value per layer

Expand Down
3 changes: 2 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@
- James Kao
- Finn Newick
- Thomas Wilbert
- Gary Kyle
- Gary Kyle
- Peter Csaki
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 27 additions & 10 deletions UVtools.Core/Extensions/EmguExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,16 @@ public static string PutTextLineAlignmentTrim(string line, PutTextLineAlignment
}

public static Size GetTextSizeExtended(string text, FontFace fontFace, double fontScale, int thickness, ref int baseLine, PutTextLineAlignment lineAlignment = default)
=> GetTextSizeExtended(text, fontFace, fontScale, thickness, 0, ref baseLine, lineAlignment);
public static Size GetTextSizeExtended(string text, FontFace fontFace, double fontScale, int thickness, int lineGapOffset, ref int baseLine, PutTextLineAlignment lineAlignment = default)
{
text = text.TrimEnd('\n', '\r', ' ');
var lines = text.Split(StaticObjects.LineBreakCharacters, StringSplitOptions.None);
var textSize = CvInvoke.GetTextSize(text, fontFace, fontScale, thickness, ref baseLine);

if (lines.Length is 0 or 1) return textSize;

var lineGap = textSize.Height / 3;
var lineGap = textSize.Height / 3 + lineGapOffset;
var width = 0;
var height = lines.Length * (lineGap + textSize.Height) - lineGap;

Expand All @@ -706,11 +708,16 @@ public static Size GetTextSizeExtended(string text, FontFace fontFace, double fo
return new(width, height);
}

/// <summary>
/// Extended OpenCV PutText to accepting line breaks and line alignment
/// </summary>
public static void PutTextExtended(this Mat src, string text, Point org, FontFace fontFace, double fontScale,
MCvScalar color, int thickness = 1, LineType lineType = LineType.EightConnected, bool bottomLeftOrigin = false, PutTextLineAlignment lineAlignment = default)
MCvScalar color, int thickness = 1, LineType lineType = LineType.EightConnected,
bool bottomLeftOrigin = false, PutTextLineAlignment lineAlignment = default)
=> src.PutTextExtended(text, org, fontFace, fontScale, color, thickness, 0, lineType, bottomLeftOrigin, lineAlignment);

/// <summary>
/// Extended OpenCV PutText to accepting line breaks and line alignment
/// </summary>
public static void PutTextExtended(this Mat src, string text, Point org, FontFace fontFace, double fontScale,
MCvScalar color, int thickness = 1, int lineGapOffset = 0, LineType lineType = LineType.EightConnected, bool bottomLeftOrigin = false, PutTextLineAlignment lineAlignment = default)
{
text = text.TrimEnd('\n', '\r', ' ');
var lines = text.Split(StaticObjects.LineBreakCharacters, StringSplitOptions.None);
Expand All @@ -727,7 +734,7 @@ public static Size GetTextSizeExtended(string text, FontFace fontFace, double fo
// Get height of text lines in pixels (height of all lines is the same)
int baseLine = 0;
var textSize = CvInvoke.GetTextSize(text, fontFace, fontScale, thickness, ref baseLine);
var lineGap = textSize.Height / 3;
var lineGap = textSize.Height / 3 + lineGapOffset;
var linesSize = new Size[lines.Length];
int width = 0;

Expand Down Expand Up @@ -769,15 +776,25 @@ public static Size GetTextSizeExtended(string text, FontFace fontFace, double fo
}
}

/// <summary>
/// Extended OpenCV PutText to accepting line breaks, line alignment and rotation
/// </summary>
public static void PutTextRotated(this Mat src, string text, Point org, FontFace fontFace, double fontScale,
MCvScalar color,
int thickness = 1, LineType lineType = LineType.EightConnected, bool bottomLeftOrigin = false,
PutTextLineAlignment lineAlignment = default, double angle = 0)
=> src.PutTextRotated(text, org, fontFace, fontScale, color, thickness, 0, lineType, bottomLeftOrigin,
lineAlignment, angle);

/// <summary>
/// Extended OpenCV PutText to accepting line breaks, line alignment and rotation
/// </summary>
public static void PutTextRotated(this Mat src, string text, Point org, FontFace fontFace, double fontScale, MCvScalar color,
int thickness = 1, LineType lineType = LineType.EightConnected, bool bottomLeftOrigin = false, PutTextLineAlignment lineAlignment = default, double angle = 0)
int thickness = 1, int lineGapOffset = 0, LineType lineType = LineType.EightConnected, bool bottomLeftOrigin = false, PutTextLineAlignment lineAlignment = default, double angle = 0)
{
if (angle % 360 == 0) // No rotation needed, cheaper cycle
{
src.PutTextExtended(text, org, fontFace, fontScale, color, thickness, lineType, bottomLeftOrigin, lineAlignment);
src.PutTextExtended(text, org, fontFace, fontScale, color, thickness, lineGapOffset, lineType, bottomLeftOrigin, lineAlignment);
return;
}

Expand All @@ -786,10 +803,10 @@ public static Size GetTextSizeExtended(string text, FontFace fontFace, double fo
var sizeDifference = (rotatedSrc.Size - src.Size).Half();
org.Offset(sizeDifference.ToPoint());
org = org.Rotate(-angle, new Point(rotatedSrc.Size.Width / 2, rotatedSrc.Size.Height / 2));
rotatedSrc.PutTextExtended(text, org, fontFace, fontScale, color, thickness, lineType, bottomLeftOrigin, lineAlignment);
rotatedSrc.PutTextExtended(text, org, fontFace, fontScale, color, thickness, lineGapOffset, lineType, bottomLeftOrigin, lineAlignment);

using var mask = rotatedSrc.NewBlank();
mask.PutTextExtended(text, org, fontFace, fontScale, WhiteColor, thickness, lineType, bottomLeftOrigin, lineAlignment);
mask.PutTextExtended(text, org, fontFace, fontScale, WhiteColor, thickness, lineGapOffset, lineType, bottomLeftOrigin, lineAlignment);

rotatedSrc.Rotate(angle, src.Size);
mask.Rotate(angle, src.Size);
Expand Down
4 changes: 2 additions & 2 deletions UVtools.Core/FileFormats/ChituboxZipFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected override void EncodeInternally(string fileFullPath, OperationProgress
{
using (ZipArchive outputFile = ZipFile.Open(fileFullPath, ZipArchiveMode.Create))
{
if (Thumbnails.Length > 0 && !ReferenceEquals(Thumbnails[0], null))
if (Thumbnails.Length > 0 && Thumbnails[0] is not null)
{
using (Stream stream = outputFile.CreateEntry("preview.png").Open())
{
Expand All @@ -358,7 +358,7 @@ protected override void EncodeInternally(string fileFullPath, OperationProgress
}
}

if (Thumbnails.Length > 1 && !ReferenceEquals(Thumbnails[1], null))
if (Thumbnails.Length > 1 && Thumbnails[1] is not null)
{
using (Stream stream = outputFile.CreateEntry("preview_cropping.png").Open())
{
Expand Down
9 changes: 7 additions & 2 deletions UVtools.Core/FileFormats/FileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class FileFormat : BindableBase, IDisposable, IEquatable<FileFor
private const string ExtractConfigFileExtension = "ini";


public const float DefaultLayerHeight = 0.5f;
public const float DefaultLayerHeight = 0.05f;
public const ushort DefaultBottomLayerCount = 4;

public const float DefaultBottomExposureTime = 30;
Expand Down Expand Up @@ -1216,6 +1216,11 @@ public virtual string MachineName
/// </summary>
public bool HaveGCode => SupportsGCode && !GCode.IsEmpty;

/// <summary>
/// Disable or enable the gcode auto rebuild when needed, set this to false to manually write your own gcode
/// </summary>
public bool SuppressRebuildGCode { get; set; }

/// <summary>
/// Get all configuration objects with properties and values
/// </summary>
Expand Down Expand Up @@ -2024,7 +2029,7 @@ public bool SetLightOffDelay(bool isBottomLayer, float extraTime = 0)
/// </summary>
public virtual void RebuildGCode()
{
if (!SupportsGCode) return;
if (!SupportsGCode || SuppressRebuildGCode) return;
GCode.RebuildGCode(this);
}

Expand Down
4 changes: 2 additions & 2 deletions UVtools.Core/FileFormats/ZCodeFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public class ZcodePrintJob
public float VolumeMl { get; set; }

[XmlElement("thickness")]
public float LayerHeight { get; set; }
public float LayerHeight { get; set; } = FileFormat.DefaultLayerHeight;

[XmlElement("price")]
public float Price { get; set; }
Expand Down Expand Up @@ -276,7 +276,7 @@ public override byte AntiAliasing

public override float LayerHeight
{
get => ManifestFile.Job.LayerHeight;
get => ManifestFile.Job.LayerHeight > 0 ? ManifestFile.Job.LayerHeight : ManifestFile.Profile.Slice.LayerHeight;
set
{
ManifestFile.Job.LayerHeight = ManifestFile.Profile.Slice.LayerHeight = Layer.RoundHeight(value);
Expand Down

0 comments on commit 683a6f4

Please sign in to comment.