diff --git a/Plugins/ImageProcessing/Controllers/ObjectDetectionManagerController.cs b/Plugins/ImageProcessing/Controllers/ObjectDetectionManagerController.cs index 455a7f2..6b1604e 100644 --- a/Plugins/ImageProcessing/Controllers/ObjectDetectionManagerController.cs +++ b/Plugins/ImageProcessing/Controllers/ObjectDetectionManagerController.cs @@ -55,7 +55,7 @@ public void Initialize() // Must initialize the object detection controller first so that all points // loaded by the tagger are sent to the object detection controller - this.taggerController.Initialize(); + ////this.taggerController.Initialize(); } public void Close() diff --git a/Plugins/ImageProcessing/Controllers/TaggerController.cs b/Plugins/ImageProcessing/Controllers/TaggerController.cs index 61a2e19..b46d42e 100644 --- a/Plugins/ImageProcessing/Controllers/TaggerController.cs +++ b/Plugins/ImageProcessing/Controllers/TaggerController.cs @@ -17,7 +17,6 @@ namespace ImageProcessing.Controllers public class TaggerController { private TaggerService taggerService; - private string selectedLabel; public TaggerController(TaggerService taggerService) { @@ -34,6 +33,12 @@ public IEnumerable Labels } } + public string SelectedLabel + { + get; + private set; + } + public string DisplayName { get @@ -42,17 +47,6 @@ public string DisplayName } } - public void Initialize() - { - ////this.taggerView.SetTaggerModel(this.taggerModel); - - ////this.taggerView.LabelAdded += this.TaggerView_LabelAdded; - - ////this.imageManagerController.ActiveImageChanged += this.ImageManagerController_ActiveImageChanged; - - this.RegisterActiveImage(); - } - public void Close() { } @@ -79,14 +73,14 @@ public void SelectLabel(string label) this.taggerService.Labels.ShouldContain(label); } - this.selectedLabel = label; + this.SelectedLabel = label; } public void SelectPixel(IImageSource imageSource, Point pixelPosition) { - if (this.selectedLabel != null) + if (this.SelectedLabel != null) { - this.taggerService.SelectPixel(imageSource, this.selectedLabel, pixelPosition); + this.taggerService.SelectPixel(imageSource, this.SelectedLabel, pixelPosition); } } diff --git a/Plugins/ImageProcessing/Tests/ImageProcessing.Controllers.Tests/TaggerControllerTest.cs b/Plugins/ImageProcessing/Tests/ImageProcessing.Controllers.Tests/TaggerControllerTest.cs index 9aae5f6..b47c424 100644 --- a/Plugins/ImageProcessing/Tests/ImageProcessing.Controllers.Tests/TaggerControllerTest.cs +++ b/Plugins/ImageProcessing/Tests/ImageProcessing.Controllers.Tests/TaggerControllerTest.cs @@ -114,5 +114,61 @@ public void RemovePoint() taggerController.GetPoints(LabelName).Count.ShouldBe(0); } + + [Fact] + public void Close() + { + TaggerController taggerController = this.Container.GetInstance(); + + taggerController.Close(); + } + + [Fact] + public void SelectLabel() + { + TaggerController taggerController = this.Container.GetInstance(); + + taggerController.SelectedLabel.ShouldBeNull(); + + // Cannot select label which has not been added yet + Assert.Throws(() => { taggerController.SelectLabel(LabelName); }); + + taggerController.AddLabel(LabelName); + + taggerController.SelectLabel(LabelName); + + taggerController.SelectedLabel.ShouldBe(LabelName); + + taggerController.SelectLabel(null); + + taggerController.SelectedLabel.ShouldBeNull(); + } + + [Fact] + public void SelectPixel() + { + TaggerController taggerController = this.Container.GetInstance(); + + taggerController.GetPoints(LabelName).Count().ShouldBe(0); + + taggerController.SelectPixel(null, Point.Empty); + + taggerController.GetPoints(LabelName).Count().ShouldBe(0); + + taggerController.AddLabel(LabelName); + + taggerController.SelectPixel(null, Point.Empty); + + taggerController.GetPoints(LabelName).Count().ShouldBe(0); + + taggerController.SelectLabel(LabelName); + + taggerController.SelectPixel(null, new Point(42, 54)); + + taggerController.GetPoints(LabelName).Count().ShouldBe(1); + + taggerController.GetPoints(LabelName)[0].X.ShouldBe(42); + taggerController.GetPoints(LabelName)[0].Y.ShouldBe(54); + } } }