Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionExtendedView.Designer.cs =================================================================== diff -u --- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionExtendedView.Designer.cs (revision 0) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionExtendedView.Designer.cs (revision 860456f6b63623abee26e389444876d936864351) @@ -0,0 +1,64 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Riskeer.Integration.Forms.Views +{ + partial class AssessmentSectionExtendedView + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.riskeerMapControl = new Riskeer.Common.Forms.Views.RiskeerMapControl(); + this.SuspendLayout(); + // + // riskeerMapControl + // + this.riskeerMapControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.riskeerMapControl.Location = new System.Drawing.Point(0, 0); + this.riskeerMapControl.Name = "riskeerMapControl"; + this.riskeerMapControl.Size = new System.Drawing.Size(150, 150); + this.riskeerMapControl.TabIndex = 0; + // + // AssessmentSectionView + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.riskeerMapControl); + this.Name = "AssessmentSectionExtendedView"; + this.ResumeLayout(false); + + } + + #endregion + + private Riskeer.Common.Forms.Views.RiskeerMapControl riskeerMapControl; + } +} Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionExtendedView.cs =================================================================== diff -u --- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionExtendedView.cs (revision 0) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionExtendedView.cs (revision 860456f6b63623abee26e389444876d936864351) @@ -0,0 +1,137 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base; +using Core.Components.Gis.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Forms.Factories; +using Riskeer.Common.Forms.Helpers; + +namespace Riskeer.Integration.Forms.Views +{ + /// + /// This class is an extended view showing map data for an assessment section. + /// + public partial class AssessmentSectionExtendedView : AssessmentSectionReferenceLineView + { + private readonly IAssessmentSection assessmentSection; + + private readonly MapPointData hydraulicBoundaryLocationsMapData; + + private Observer hydraulicBoundaryLocationsObserver; + private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForFactorizedSignalingNormObserver; + private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForSignalingNormObserver; + private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForLowerLimitNormObserver; + private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForFactorizedLowerLimitNormObserver; + private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForFactorizedSignalingNormObserver; + private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForSignalingNormObserver; + private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForLowerLimitNormObserver; + private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForFactorizedLowerLimitNormObserver; + + /// + /// Creates a new instance of . + /// + /// The assessment section to show the data for. + /// Thrown when + /// is null. + public AssessmentSectionExtendedView(IAssessmentSection assessmentSection) : base(assessmentSection) + { + InitializeComponent(); + + this.assessmentSection = assessmentSection; + + CreateObservers(); + + hydraulicBoundaryLocationsMapData = RiskeerMapDataFactory.CreateHydraulicBoundaryLocationsMapData(); + + MapDataCollection.Add(hydraulicBoundaryLocationsMapData); + + SetAllMapDataFeatures(); + } + + protected override void Dispose(bool disposing) + { + waterLevelCalculationsForFactorizedSignalingNormObserver.Dispose(); + waterLevelCalculationsForSignalingNormObserver.Dispose(); + waterLevelCalculationsForLowerLimitNormObserver.Dispose(); + waterLevelCalculationsForFactorizedLowerLimitNormObserver.Dispose(); + waveHeightCalculationsForFactorizedSignalingNormObserver.Dispose(); + waveHeightCalculationsForSignalingNormObserver.Dispose(); + waveHeightCalculationsForLowerLimitNormObserver.Dispose(); + waveHeightCalculationsForFactorizedLowerLimitNormObserver.Dispose(); + hydraulicBoundaryLocationsObserver.Dispose(); + + if (disposing) + { + components?.Dispose(); + } + + base.Dispose(disposing); + } + + private void CreateObservers() + { + waterLevelCalculationsForFactorizedSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( + assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm, UpdateHydraulicBoundaryLocationsMapData); + waterLevelCalculationsForSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( + assessmentSection.WaterLevelCalculationsForSignalingNorm, UpdateHydraulicBoundaryLocationsMapData); + waterLevelCalculationsForLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( + assessmentSection.WaterLevelCalculationsForLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData); + waterLevelCalculationsForFactorizedLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( + assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData); + waveHeightCalculationsForFactorizedSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( + assessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm, UpdateHydraulicBoundaryLocationsMapData); + waveHeightCalculationsForSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( + assessmentSection.WaveHeightCalculationsForSignalingNorm, UpdateHydraulicBoundaryLocationsMapData); + waveHeightCalculationsForLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( + assessmentSection.WaveHeightCalculationsForLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData); + waveHeightCalculationsForFactorizedLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( + assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData); + + hydraulicBoundaryLocationsObserver = new Observer(UpdateHydraulicBoundaryLocationsMapData) + { + Observable = assessmentSection.HydraulicBoundaryDatabase.Locations + }; + } + + private void SetAllMapDataFeatures() + { + SetHydraulicBoundaryLocationsMapData(); + } + + #region HydraulicBoundaryLocations MapData + + private void UpdateHydraulicBoundaryLocationsMapData() + { + SetHydraulicBoundaryLocationsMapData(); + hydraulicBoundaryLocationsMapData.NotifyObservers(); + } + + private void SetHydraulicBoundaryLocationsMapData() + { + hydraulicBoundaryLocationsMapData.Features = RiskeerMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(assessmentSection); + } + + #endregion + } +} \ No newline at end of file Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionExtendedView.resx =================================================================== diff -u --- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionExtendedView.resx (revision 0) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionExtendedView.resx (revision 860456f6b63623abee26e389444876d936864351) @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionReferenceLineView.Designer.cs =================================================================== diff -u -rd04957276dbeb07bf0ab6189ad7d77385b8f20ca -r860456f6b63623abee26e389444876d936864351 --- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionReferenceLineView.Designer.cs (.../AssessmentSectionReferenceLineView.Designer.cs) (revision d04957276dbeb07bf0ab6189ad7d77385b8f20ca) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionReferenceLineView.Designer.cs (.../AssessmentSectionReferenceLineView.Designer.cs) (revision 860456f6b63623abee26e389444876d936864351) @@ -47,7 +47,7 @@ this.riskeerMapControl.Size = new System.Drawing.Size(150, 150); this.riskeerMapControl.TabIndex = 0; // - // AssessmentSectionView + // AssessmentSectionReferenceLineView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; Fisheye: Tag 860456f6b63623abee26e389444876d936864351 refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionView.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 860456f6b63623abee26e389444876d936864351 refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionView.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 860456f6b63623abee26e389444876d936864351 refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionView.resx'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssessmentSectionExtendedViewTest.cs =================================================================== diff -u -r24dadd7f736e8b0c9cd420a1def367e5c51e4ad2 -r860456f6b63623abee26e389444876d936864351 --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssessmentSectionExtendedViewTest.cs (.../AssessmentSectionExtendedViewTest.cs) (revision 24dadd7f736e8b0c9cd420a1def367e5c51e4ad2) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssessmentSectionExtendedViewTest.cs (.../AssessmentSectionExtendedViewTest.cs) (revision 860456f6b63623abee26e389444876d936864351) @@ -59,42 +59,10 @@ AssessmentSectionExtendedView extendedView = ShowCalculationsView(assessmentSection); // Assert - Assert.IsInstanceOf(extendedView); - Assert.IsInstanceOf(extendedView); - Assert.IsNull(extendedView.Data); - - Assert.AreEqual(2, extendedView.Controls.Count); - Assert.IsInstanceOf(extendedView.Controls[0]); - Assert.AreSame(extendedView.Map, ((RiskeerMapControl) extendedView.Controls[0]).MapControl); - Assert.AreEqual(DockStyle.Fill, ((Control) extendedView.Map).Dock); - AssertEmptyMapData(extendedView.Map.Data); + Assert.IsInstanceOf(extendedView); } [Test] - public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() - { - // Call - void Call() => new AssessmentSectionExtendedView(null); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("assessmentSection", exception.ParamName); - } - - [Test] - public void Constructor_AssessmentSectionWithBackgroundData_BackgroundDataSet() - { - // Setup - var assessmentSection = new AssessmentSectionStub(); - - // Call - AssessmentSectionExtendedView extendedView = ShowCalculationsView(assessmentSection); - - // Assert - MapDataTestHelper.AssertImageBasedMapData(assessmentSection.BackgroundData, extendedView.Map.BackgroundMapData); - } - - [Test] public void Constructor_WithReferenceLineAndHydraulicBoundaryDatabase_DataUpdatedToCollectionOfFilledMapData() { // Setup @@ -126,7 +94,8 @@ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, hydraulicBoundaryLocationsMapData); MapData referenceLineMapData = mapData.Collection.ElementAt(referenceLineIndex); - AssertReferenceLineMapData(referenceLine, referenceLineMapData); + MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); + Assert.IsTrue(referenceLineMapData.IsVisible); } [Test] @@ -202,87 +171,6 @@ } [Test] - public void UpdateObserver_AssessmentSectionUpdated_MapDataUpdated() - { - // Setup - var referenceLine = new ReferenceLine(); - referenceLine.SetGeometry(new List - { - new Point2D(1.0, 2.0), - new Point2D(2.0, 1.0) - }); - - var assessmentSection = new AssessmentSectionStub - { - ReferenceLine = referenceLine - }; - - AssessmentSectionExtendedView extendedView = ShowCalculationsView(assessmentSection); - IMapControl map = ((RiskeerMapControl) extendedView.Controls[0]).MapControl; - - var mocks = new MockRepository(); - IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[referenceLineIndex].Expect(obs => obs.UpdateObserver()); - mocks.ReplayAll(); - - var referenceLineMapData = (MapLineData) map.Data.Collection.ElementAt(referenceLineIndex); - - // Precondition - MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features); - AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); - - // Call - assessmentSection.Name = "New name"; - assessmentSection.NotifyObservers(); - - // Assert - MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features); - mocks.VerifyAll(); - } - - [Test] - public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated() - { - // Setup - var referenceLine = new ReferenceLine(); - referenceLine.SetGeometry(new List - { - new Point2D(1.0, 2.0), - new Point2D(2.0, 1.0) - }); - - var assessmentSection = new AssessmentSectionStub - { - ReferenceLine = referenceLine - }; - - AssessmentSectionExtendedView extendedView = ShowCalculationsView(assessmentSection); - IMapControl map = ((RiskeerMapControl) extendedView.Controls[0]).MapControl; - - var mocks = new MockRepository(); - IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[referenceLineIndex].Expect(obs => obs.UpdateObserver()); - mocks.ReplayAll(); - - MapData referenceLineMapData = map.Data.Collection.ElementAt(referenceLineIndex); - - // Precondition - AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); - - // Call - referenceLine.SetGeometry(new List - { - new Point2D(2.0, 5.0), - new Point2D(4.0, 3.0) - }); - referenceLine.NotifyObservers(); - - // Assert - AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); - mocks.VerifyAll(); - } - - [Test] public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup @@ -345,12 +233,6 @@ testForm.Dispose(); } - private static void AssertReferenceLineMapData(ReferenceLine referenceLine, MapData referenceLineMapData) - { - MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); - Assert.IsTrue(referenceLineMapData.IsVisible); - } - private static void AssertEmptyMapData(MapDataCollection mapDataCollection) { Assert.AreEqual("Trajectkaart", mapDataCollection.Name); Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssessmentSectionReferenceLineViewTest.cs =================================================================== diff -u -r60b0b93589099f5f331ebf12aa2d5e646d325963 -r860456f6b63623abee26e389444876d936864351 --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssessmentSectionReferenceLineViewTest.cs (.../AssessmentSectionReferenceLineViewTest.cs) (revision 60b0b93589099f5f331ebf12aa2d5e646d325963) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssessmentSectionReferenceLineViewTest.cs (.../AssessmentSectionReferenceLineViewTest.cs) (revision 860456f6b63623abee26e389444876d936864351) @@ -117,7 +117,8 @@ Assert.IsNotNull(mapData); MapData referenceLineMapData = mapData.Collection.ElementAt(referenceLineIndex); - AssertReferenceLineMapData(referenceLine, referenceLineMapData); + MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); + Assert.IsTrue(referenceLineMapData.IsVisible); } [Test] @@ -149,7 +150,8 @@ // Precondition MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features); - AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); + MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); + Assert.IsTrue(referenceLineMapData.IsVisible); // Call assessmentSection.Name = "New name"; @@ -188,7 +190,8 @@ MapData referenceLineMapData = map.Data.Collection.ElementAt(referenceLineIndex); // Precondition - AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); + MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); + Assert.IsTrue(referenceLineMapData.IsVisible); // Call referenceLine.SetGeometry(new List @@ -199,14 +202,9 @@ referenceLine.NotifyObservers(); // Assert - AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); - mocks.VerifyAll(); - } - - private static void AssertReferenceLineMapData(ReferenceLine referenceLine, MapData referenceLineMapData) - { MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); Assert.IsTrue(referenceLineMapData.IsVisible); + mocks.VerifyAll(); } private static void AssertEmptyMapData(MapDataCollection mapDataCollection) Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/AssessmentSectionExtendedViewInfoTest.cs =================================================================== diff -u -r24dadd7f736e8b0c9cd420a1def367e5c51e4ad2 -r860456f6b63623abee26e389444876d936864351 --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/AssessmentSectionExtendedViewInfoTest.cs (.../AssessmentSectionExtendedViewInfoTest.cs) (revision 24dadd7f736e8b0c9cd420a1def367e5c51e4ad2) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/AssessmentSectionExtendedViewInfoTest.cs (.../AssessmentSectionExtendedViewInfoTest.cs) (revision 860456f6b63623abee26e389444876d936864351) @@ -69,7 +69,7 @@ } [Test] - public void Image_Always_ReturnsGenericInputOutputIcon() + public void Image_Always_ReturnsExpectedIcon() { // Call Image image = info.Image; @@ -79,7 +79,7 @@ } [Test] - public void CreateInstance_WithAssessmentSection_ReturnsAssessmentSectionView() + public void CreateInstance_WithAssessmentSection_ReturnsAssessmentSectionExtendedView() { // Setup var assessmentSection = new AssessmentSectionStub(); Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/AssessmentSectionStateRootContextViewInfoTest.cs =================================================================== diff -u -r1c5bb8a344ba13e3d1a952b26ac771e46f937754 -r860456f6b63623abee26e389444876d936864351 --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/AssessmentSectionStateRootContextViewInfoTest.cs (.../AssessmentSectionStateRootContextViewInfoTest.cs) (revision 1c5bb8a344ba13e3d1a952b26ac771e46f937754) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/AssessmentSectionStateRootContextViewInfoTest.cs (.../AssessmentSectionStateRootContextViewInfoTest.cs) (revision 860456f6b63623abee26e389444876d936864351) @@ -71,7 +71,7 @@ } [Test] - public void Image_Always_ReturnsGenericInputOutputIcon() + public void Image_Always_ReturnsExpectedIcon() { // Call Image image = info.Image; @@ -81,7 +81,7 @@ } [Test] - public void CreateInstance_WithAssessmentSection_ReturnsAssessmentSectionView() + public void CreateInstance_WithContext_ReturnsAssessmentSectionReferenceLineView() { // Setup var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(new AssessmentSection(AssessmentSectionComposition.Dike));