mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-19 06:56:27 +02:00
Fix issue selection
This commit is contained in:
@@ -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.22.1</Version>
|
||||
<Version>2.23.0</Version>
|
||||
<Copyright>Copyright © 2020 PTRTECH</Copyright>
|
||||
<PackageIcon>UVtools.png</PackageIcon>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* of this license document, but changing it is not allowed.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Collections;
|
||||
@@ -38,6 +38,24 @@ namespace UVtools.WPF
|
||||
public DataGrid IssuesGrid;
|
||||
|
||||
private int _issueSelectedIndex = -1;
|
||||
|
||||
public IEnumerable IssuesGridItems
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsFileLoaded || DataContext is null) return null;
|
||||
if (Settings.Issues.DataGridGroupByType || Settings.Issues.DataGridGroupByLayerIndex)
|
||||
{
|
||||
var groupView = new DataGridCollectionView(SlicerFile.IssueManager);
|
||||
if (Settings.Issues.DataGridGroupByType) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("Type"));
|
||||
if (Settings.Issues.DataGridGroupByLayerIndex) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("StartLayerIndex"));
|
||||
|
||||
return groupView;
|
||||
}
|
||||
|
||||
return SlicerFile.IssueManager;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
@@ -53,6 +71,8 @@ namespace UVtools.WPF
|
||||
set => RaiseAndSetIfChanged(ref _resinTrapDetectionStartLayer, value);
|
||||
}
|
||||
|
||||
public bool SuppressIssueGridSelectionEvent { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
@@ -381,7 +401,7 @@ namespace UVtools.WPF
|
||||
|
||||
private void IssuesGridOnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (DataContext is null) return;
|
||||
if (DataContext is null || SuppressIssueGridSelectionEvent) return;
|
||||
|
||||
if (IssuesGrid.SelectedItem is not MainIssue mainIssue)
|
||||
{
|
||||
@@ -390,34 +410,7 @@ namespace UVtools.WPF
|
||||
}
|
||||
|
||||
var issue = mainIssue.FirstOrDefault();
|
||||
|
||||
|
||||
if (mainIssue.Type is MainIssue.IssueType.TouchingBound or MainIssue.IssueType.EmptyLayer || mainIssue.BoundingRectangle.IsEmpty)
|
||||
{
|
||||
ZoomToFit();
|
||||
}
|
||||
else if (!mainIssue.BoundingRectangle.IsEmpty && issue is not null)
|
||||
{
|
||||
|
||||
if (Settings.LayerPreview.ZoomIssues ^ (_globalModifiers & KeyModifiers.Alt) != 0)
|
||||
{
|
||||
ZoomToIssue(issue);
|
||||
}
|
||||
else
|
||||
{
|
||||
//CenterLayerAt(GetTransposedIssueBounds(issue));
|
||||
// If issue is not already visible, center on it and bring it into view.
|
||||
// Issues already in view will not be centered, though their color may
|
||||
// change and the crosshair may move to reflect active selections.
|
||||
|
||||
if (!LayerImageBox.GetSourceImageRegion().Contains(GetTransposedIssueBounds(issue).ToAvalonia()))
|
||||
{
|
||||
CenterAtIssue(issue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ForceUpdateActualLayer(mainIssue.StartLayerIndex);
|
||||
ZoomToIssue(issue, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -960,27 +960,27 @@ namespace UVtools.WPF
|
||||
switch (issue.Parent.Type)
|
||||
{
|
||||
case MainIssue.IssueType.Island:
|
||||
color = selectedIssues.Count > 0 && selectedIssues.Contains(issue)
|
||||
color = selectedIssues.Count > 0 && selectedIssues.Contains(issue.Parent)
|
||||
? Settings.LayerPreview.IslandHighlightColor
|
||||
: Settings.LayerPreview.IslandColor;
|
||||
drawCrosshair = true;
|
||||
|
||||
break;
|
||||
case MainIssue.IssueType.Overhang:
|
||||
color = selectedIssues.Count > 0 && selectedIssues.Contains(issue)
|
||||
color = selectedIssues.Count > 0 && selectedIssues.Contains(issue.Parent)
|
||||
? Settings.LayerPreview.OverhangHighlightColor
|
||||
: Settings.LayerPreview.OverhangColor;
|
||||
drawCrosshair = true;
|
||||
|
||||
break;
|
||||
case MainIssue.IssueType.ResinTrap:
|
||||
color = selectedIssues.Count > 0 && selectedIssues.Contains(issue)
|
||||
color = selectedIssues.Count > 0 && selectedIssues.Contains(issue.Parent)
|
||||
? Settings.LayerPreview.ResinTrapHighlightColor
|
||||
: Settings.LayerPreview.ResinTrapColor;
|
||||
drawCrosshair = true;
|
||||
break;
|
||||
case MainIssue.IssueType.SuctionCup:
|
||||
color = selectedIssues.Count > 0 && selectedIssues.Contains(issue)
|
||||
color = selectedIssues.Count > 0 && selectedIssues.Contains(issue.Parent)
|
||||
? Settings.LayerPreview.SuctionCupHighlightColor
|
||||
: Settings.LayerPreview.SuctionCupColor;
|
||||
drawCrosshair = true;
|
||||
@@ -1583,32 +1583,35 @@ namespace UVtools.WPF
|
||||
/// Zoom the layer preview to the passed issue, or if appropriate for issue type,
|
||||
/// Zoom to fit the plate or print bounds.
|
||||
/// </summary>
|
||||
private void ZoomToIssue(Issue issue)
|
||||
private void ZoomToIssue(Issue issue, bool forceRefreshLayer = false)
|
||||
{
|
||||
if (issue.Parent.Type is MainIssue.IssueType.TouchingBound or MainIssue.IssueType.EmptyLayer || issue.BoundingRectangle.IsEmpty)
|
||||
if (issue.Type is MainIssue.IssueType.TouchingBound or MainIssue.IssueType.EmptyLayer || issue.BoundingRectangle.IsEmpty)
|
||||
{
|
||||
ZoomToFit();
|
||||
if (forceRefreshLayer) ForceUpdateActualLayer(issue.LayerIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!issue.BoundingRectangle.IsEmpty)
|
||||
if (issue.BoundingRectangle.IsEmpty) return;
|
||||
|
||||
if (Settings.LayerPreview.ZoomIssues ^ (_globalModifiers & KeyModifiers.Alt) != 0)
|
||||
{
|
||||
// Check to see if this zoom action will cross the crosshair fade threshold
|
||||
/*if (tsLayerImageShowCrosshairs.Checked && !ReferenceEquals(Issues, null) && flvIssues.SelectedIndices.Count > 0
|
||||
&& pbLayer.Zoom <= CrosshairFadeLevel && LockedZoomLevel > CrosshairFadeLevel)
|
||||
{
|
||||
// Refresh the preview without the crosshairs before zooming-in.
|
||||
// Prevents zoomed-in crosshairs from breifly being displayed before
|
||||
// the Layer Preview is refreshed post-zoom.
|
||||
tsLayerImageShowCrosshairs.Checked = false;
|
||||
ShowLayer();
|
||||
tsLayerImageShowCrosshairs.Checked = true;
|
||||
}*/
|
||||
|
||||
|
||||
CenterLayerAt(GetTransposedIssueBounds(issue), AppSettings.LockedZoomLevel);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//CenterLayerAt(GetTransposedIssueBounds(issue));
|
||||
// If issue is not already visible, center on it and bring it into view.
|
||||
// Issues already in view will not be centered, though their color may
|
||||
// change and the crosshair may move to reflect active selections.
|
||||
|
||||
if (!LayerImageBox.GetSourceImageRegion().Contains(GetTransposedIssueBounds(issue).ToAvalonia()))
|
||||
{
|
||||
CenterAtIssue(issue);
|
||||
}
|
||||
}
|
||||
|
||||
if(forceRefreshLayer) ForceUpdateActualLayer(issue.LayerIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1699,11 +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))
|
||||
foreach (var issue in SlicerFile.IssueManager.GetIssuesBy(_actualLayer).Reverse())
|
||||
{
|
||||
if (!GetTransposedIssueBounds(issue).Contains(location)) continue;
|
||||
|
||||
SuppressIssueGridSelectionEvent = true;
|
||||
IssuesGrid.SelectedItem = issue.Parent;
|
||||
SuppressIssueGridSelectionEvent = false;
|
||||
|
||||
ZoomToIssue(issue, true);
|
||||
|
||||
SelectedTabItem = TabIssues;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -857,7 +857,7 @@
|
||||
SelectedIndex="{Binding IssueSelectedIndex, Mode=TwoWay}"
|
||||
IsReadOnly="True"
|
||||
ClipboardCopyMode="IncludeHeader"
|
||||
Items="{Binding SlicerFile.IssueManager}">
|
||||
Items="{Binding IssuesGridItems}">
|
||||
<DataGrid.Columns>
|
||||
|
||||
<DataGridTextColumn Header="Type"
|
||||
|
||||
@@ -19,7 +19,6 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
@@ -1174,18 +1173,7 @@ namespace UVtools.WPF
|
||||
await settingsWindow.ShowDialog(this);
|
||||
if (settingsWindow.DialogResult == DialogResults.OK)
|
||||
{
|
||||
if (Settings.Issues.DataGridGroupByType || Settings.Issues.DataGridGroupByLayerIndex)
|
||||
{
|
||||
var groupView = new DataGridCollectionView(SlicerFile.IssueManager);
|
||||
if (Settings.Issues.DataGridGroupByType) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("Type"));
|
||||
if (Settings.Issues.DataGridGroupByLayerIndex) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("StartLayerIndex"));
|
||||
|
||||
IssuesGrid.Items = groupView;
|
||||
}
|
||||
else
|
||||
{
|
||||
IssuesGrid.Items = SlicerFile.IssueManager;
|
||||
}
|
||||
RaisePropertyChanged(nameof(IssuesGridItems));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1624,15 +1612,6 @@ namespace UVtools.WPF
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.Issues.DataGridGroupByType || Settings.Issues.DataGridGroupByLayerIndex)
|
||||
{
|
||||
var groupView = new DataGridCollectionView(SlicerFile.IssueManager);
|
||||
if(Settings.Issues.DataGridGroupByType) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("Type"));
|
||||
if (Settings.Issues.DataGridGroupByLayerIndex) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("StartLayerIndex"));
|
||||
|
||||
IssuesGrid.Items = groupView;
|
||||
}
|
||||
|
||||
SlicerFile.IssueManager.CollectionChanged += (sender, e) =>
|
||||
{
|
||||
UpdateLayerTrackerHighlightIssues();
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
<Version>2.22.1</Version>
|
||||
<Version>2.23.0</Version>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user