mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:46:30 +00:00
fix switcher between modes in DatasetExplorer.xaml
This commit is contained in:
@@ -57,7 +57,7 @@
|
||||
<RowDefinition Height="32"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="250" />
|
||||
<ColumnDefinition Width="4"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
@@ -22,7 +22,7 @@ public partial class DatasetExplorer
|
||||
private readonly AnnotationConfig _annotationConfig;
|
||||
private readonly DirectoriesConfig _directoriesConfig;
|
||||
|
||||
private readonly Dictionary<int, List<Annotation>> _annotationsDict;
|
||||
private readonly Dictionary<int, Dictionary<string, Annotation>> _annotationsDict;
|
||||
private readonly CancellationTokenSource _cts = new();
|
||||
|
||||
public List<DetectionClass> AllDetectionClasses { get; set; }
|
||||
@@ -61,7 +61,7 @@ public partial class DatasetExplorer
|
||||
|
||||
var photoModes = Enum.GetValues(typeof(PhotoMode)).Cast<PhotoMode>().ToList();
|
||||
_annotationsDict = _annotationConfig.DetectionClasses.SelectMany(cls => photoModes.Select(mode => (int)mode + cls.Id))
|
||||
.ToDictionary(x => x, _ => new List<Annotation>());
|
||||
.ToDictionary(x => x, _ => new Dictionary<string, Annotation>());
|
||||
_annotationsDict.Add(-1, []);
|
||||
|
||||
AnnotationsClasses = annotationConfig.Value.DetectionClasses;
|
||||
@@ -141,8 +141,8 @@ public partial class DatasetExplorer
|
||||
public void AddAnnotationToDict(Annotation annotation)
|
||||
{
|
||||
foreach (var c in annotation.Classes)
|
||||
_annotationsDict[c].Add(annotation);
|
||||
_annotationsDict[-1].Add(annotation);
|
||||
_annotationsDict[c][annotation.Name] = annotation;
|
||||
_annotationsDict[-1][annotation.Name] = annotation;
|
||||
}
|
||||
|
||||
private async Task LoadClassDistribution()
|
||||
@@ -277,9 +277,11 @@ public partial class DatasetExplorer
|
||||
private async Task ReloadThumbnails()
|
||||
{
|
||||
SelectedAnnotations.Clear();
|
||||
foreach (var ann in _annotationsDict[ExplorerEditor.CurrentAnnClass.Id])
|
||||
SelectedAnnotationDict.Clear();
|
||||
var annotations = _annotationsDict[ExplorerEditor.CurrentAnnClass.YoloId];
|
||||
foreach (var ann in annotations.OrderByDescending(x => x.Value.CreatedDate))
|
||||
{
|
||||
var annThumb = new AnnotationThumbnail(ann);
|
||||
var annThumb = new AnnotationThumbnail(ann.Value);
|
||||
SelectedAnnotations.Add(annThumb);
|
||||
SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
|
||||
}
|
||||
|
||||
@@ -92,11 +92,14 @@ public class DatasetExplorerEventHandler(
|
||||
|
||||
//TODO: For editing existing need to handle updates
|
||||
datasetExplorer.AddAnnotationToDict(annotation);
|
||||
if (annotation.Classes.Contains(selectedClass))
|
||||
if (annotation.Classes.Contains(selectedClass) || selectedClass == -1)
|
||||
{
|
||||
var annThumb = new AnnotationThumbnail(annotation);
|
||||
datasetExplorer.SelectedAnnotations.Add(annThumb);
|
||||
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
|
||||
if (!datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
|
||||
{
|
||||
datasetExplorer.SelectedAnnotations.Insert(0, annThumb);
|
||||
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
|
||||
}
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user