Fixes and improvements

- (Change) Allow touching bounds to have a bounding rectangle and zoom into the issue
- (Fix) Touching bounds are reporting areas of 0
- (Fix) Draw crosshair for issues are called multiple times
- (Fix) Issue:Equals
This commit is contained in:
Tiago Conceição
2021-09-22 17:05:12 +01:00
parent 6d6de93d71
commit 193748dcf7
6 changed files with 54 additions and 31 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ namespace UVtools.Core.Layers
/// </summary>
public MainIssue Parent { get; internal set; }
public MainIssue.IssueType Type => Parent.Type;
public MainIssue.IssueType? Type => Parent?.Type;
/// <summary>
/// Gets the layer where this issue is present
-1
View File
@@ -17,7 +17,6 @@ using System.Threading.Tasks;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using MoreLinq.Extensions;
using UVtools.Core.EmguCV;
using UVtools.Core.Extensions;
+25 -2
View File
@@ -219,7 +219,7 @@ namespace UVtools.Core.Managers
using (var image = layer.LayerMat)
{
int step = image.Step;
var span = image.GetDataSpan<byte>();
var span = image.GetDataByteSpan();
if (touchBoundConfig.Enabled)
{
@@ -230,6 +230,12 @@ namespace UVtools.Core.Managers
bool touchLeft = layer.BoundingRectangle.Left <= touchBoundConfig.MarginLeft;
bool touchRight = layer.BoundingRectangle.Right >=
image.Width - touchBoundConfig.MarginRight;
int minx = int.MaxValue;
int miny = int.MaxValue;
int maxx = 0;
int maxy = 0;
if (touchTop || touchBottom)
{
for (int x = 0; x < image.Width; x++) // Check Top and Bottom bounds
@@ -242,6 +248,10 @@ namespace UVtools.Core.Managers
touchBoundConfig.MinimumPixelBrightness)
{
pixels.Add(new Point(x, y));
minx = Math.Min(minx, x);
miny = Math.Min(miny, y);
maxx = Math.Max(maxx, x);
maxy = Math.Max(maxy, y);
}
}
}
@@ -256,6 +266,10 @@ namespace UVtools.Core.Managers
touchBoundConfig.MinimumPixelBrightness)
{
pixels.Add(new Point(x, y));
minx = Math.Min(minx, x);
miny = Math.Min(miny, y);
maxx = Math.Max(maxx, x);
maxy = Math.Max(maxy, y);
}
}
}
@@ -277,6 +291,10 @@ namespace UVtools.Core.Managers
touchBoundConfig.MinimumPixelBrightness)
{
pixels.Add(new Point(x, y));
minx = Math.Min(minx, x);
miny = Math.Min(miny, y);
maxx = Math.Max(maxx, x);
maxy = Math.Max(maxy, y);
}
}
}
@@ -291,6 +309,10 @@ namespace UVtools.Core.Managers
touchBoundConfig.MinimumPixelBrightness)
{
pixels.Add(new Point(x, y));
minx = Math.Min(minx, x);
miny = Math.Min(miny, y);
maxx = Math.Max(maxx, x);
maxy = Math.Max(maxy, y);
}
}
}
@@ -299,7 +321,8 @@ namespace UVtools.Core.Managers
if (pixels.Count > 0)
{
AddIssue(new MainIssue(MainIssue.IssueType.TouchingBound, new IssueOfPoints(layer, pixels)));
AddIssue(new MainIssue(MainIssue.IssueType.TouchingBound, new IssueOfPoints(layer, pixels,
new Rectangle(minx, miny, maxx-minx+1, maxy-miny+1))));
}
}
+1 -1
View File
@@ -10,7 +10,7 @@
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
<PackageProjectUrl>https://github.com/sn4k3/UVtools</PackageProjectUrl>
<Description>MSLA/DLP, file analysis, calibration, repair, conversion and manipulation</Description>
<Version>2.23.0</Version>
<Version>2.23.1</Version>
<Copyright>Copyright © 2020 PTRTECH</Copyright>
<PackageIcon>UVtools.png</PackageIcon>
<Platforms>AnyCPU;x64</Platforms>
+26 -25
View File
@@ -141,13 +141,14 @@ namespace UVtools.WPF
if (IssuesGrid.SelectedItems.Count == 0 || !IssuesGrid.SelectedItems.Cast<MainIssue>().Any(
mainIssue => // Find a valid candidate to update layer preview, otherwise quit
mainIssue.IsIssueInBetween(_actualLayer)
&& mainIssue.Type is not MainIssue.IssueType.EmptyLayer and not MainIssue.IssueType.TouchingBound)) return;
&& mainIssue.Type is not MainIssue.IssueType.TouchingBound and not MainIssue.IssueType.EmptyLayer)) return;
}
else
{
if (!SlicerFile.IssueManager.Any(
mainIssue => // Find a valid candidate to update layer preview, otherwise quit
mainIssue.IsIssueInBetween(_actualLayer) && mainIssue.Type is not MainIssue.IssueType.EmptyLayer and not MainIssue.IssueType.TouchingBound)) return;
mainIssue.IsIssueInBetween(_actualLayer)
&& mainIssue.Type is not MainIssue.IssueType.TouchingBound and not MainIssue.IssueType.EmptyLayer)) return;
}
// A timer is used here rather than invoking ShowLayer directly to eliminate sublte visual flashing
@@ -951,7 +952,10 @@ namespace UVtools.WPF
if (_showLayerImageIssues && SlicerFile.IssueManager.Count > 0)
{
//var count = 0;
foreach (var issue in SlicerFile.IssueManager.GetIssuesBy(_actualLayer).Where(issue => issue.Parent.Type is not MainIssue.IssueType.PrintHeight and not MainIssue.IssueType.EmptyLayer))
foreach (var issue in SlicerFile.IssueManager.GetIssuesBy(_actualLayer)
.Where(issue => issue.Parent.Type
is not MainIssue.IssueType.PrintHeight
and not MainIssue.IssueType.EmptyLayer))
{
//count++;
var color = Color.Empty;
@@ -1269,17 +1273,15 @@ namespace UVtools.WPF
{
foreach (MainIssue mainIssue in selectedIssues)
// Don't render crosshairs for selected issue that are not on the current layer, or for
// issue types that don't have a specific location or bounds.
foreach (var issue in SlicerFile.IssueManager.GetIssuesBy(_actualLayer)
.Where(issue => issue.Parent.Type
is not MainIssue.IssueType.TouchingBound
and not MainIssue.IssueType.PrintHeight
and not MainIssue.IssueType.EmptyLayer))
{
// Don't render crosshairs for selected issue that are not on the current layer, or for
// issue types that don't have a specific location or bounds.
foreach (var issue in SlicerFile.IssueManager.GetIssuesBy(_actualLayer)
.Where(issue => issue.Parent.Type is not MainIssue.IssueType.PrintHeight and not MainIssue.IssueType.EmptyLayer))
{
DrawCrosshair(issue.BoundingRectangle);
}
DrawCrosshair(issue.BoundingRectangle);
}
}
@@ -1334,10 +1336,10 @@ namespace UVtools.WPF
// LEFT
var startPoint = new System.Drawing.Point(Math.Max(0, rect.X - Settings.LayerPreview.CrosshairMargin - 1),
var startPoint = new Point(Math.Max(0, rect.X - Settings.LayerPreview.CrosshairMargin - 1),
rect.Y + rect.Height / 2);
var endPoint =
new System.Drawing.Point(
new Point(
Settings.LayerPreview.CrosshairLength == 0
? 0
: (int)Math.Max(0, startPoint.X - Settings.LayerPreview.CrosshairLength + 1),
@@ -1364,9 +1366,9 @@ namespace UVtools.WPF
lineThickness);
// TOP
startPoint = new System.Drawing.Point(rect.X + rect.Width / 2,
startPoint = new Point(rect.X + rect.Width / 2,
Math.Max(0, rect.Y - Settings.LayerPreview.CrosshairMargin - 1));
endPoint = new System.Drawing.Point(startPoint.X,
endPoint = new Point(startPoint.X,
(int)(Settings.LayerPreview.CrosshairLength == 0
? 0
: Math.Max(0, startPoint.Y - Settings.LayerPreview.CrosshairLength + 1)));
@@ -1585,15 +1587,13 @@ namespace UVtools.WPF
/// </summary>
private void ZoomToIssue(Issue issue, bool forceRefreshLayer = false)
{
if (issue.Type is MainIssue.IssueType.TouchingBound or MainIssue.IssueType.EmptyLayer || issue.BoundingRectangle.IsEmpty)
if (issue.Type is MainIssue.IssueType.EmptyLayer || issue.BoundingRectangle.IsEmpty)
{
ZoomToFit();
if (forceRefreshLayer) ForceUpdateActualLayer(issue.LayerIndex);
return;
}
if (issue.BoundingRectangle.IsEmpty) return;
if (Settings.LayerPreview.ZoomIssues ^ (_globalModifiers & KeyModifiers.Alt) != 0)
{
CenterLayerAt(GetTransposedIssueBounds(issue), AppSettings.LockedZoomLevel);
@@ -1620,7 +1620,7 @@ namespace UVtools.WPF
/// </summary>
private void CenterAtIssue(Issue issue)
{
if (issue.Parent.Type is MainIssue.IssueType.TouchingBound or MainIssue.IssueType.EmptyLayer || issue.BoundingRectangle.IsEmpty)
if (issue.Parent.Type is MainIssue.IssueType.EmptyLayer || issue.BoundingRectangle.IsEmpty)
{
ZoomToFit();
}
@@ -1702,15 +1702,16 @@ namespace UVtools.WPF
{
//location = GetTransposedPoint(location);
// If location clicked is within an issue, activate it.
foreach (var issue in SlicerFile.IssueManager.GetIssuesBy(_actualLayer).Reverse())
var issues = SlicerFile.IssueManager.GetIssuesBy(_actualLayer);
for (var i = issues.Length-1; i >= 0; i--)
{
if (!GetTransposedIssueBounds(issue).Contains(location)) continue;
if (!GetTransposedIssueBounds(issues[i]).Contains(location)) continue;
SuppressIssueGridSelectionEvent = true;
IssuesGrid.SelectedItem = issue.Parent;
IssuesGrid.SelectedItem = issues[i].Parent;
SuppressIssueGridSelectionEvent = false;
ZoomToIssue(issue, true);
ZoomToIssue(issues[i], true);
SelectedTabItem = TabIssues;
break;
+1 -1
View File
@@ -12,7 +12,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<Version>2.23.0</Version>
<Version>2.23.1</Version>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>