Index: Riskeer/Common/src/Riskeer.Common.Data/Structures/StructuresCalculationScenario.cs =================================================================== diff -u -r96ccefa48aa5c97c949f7a7858fcb4d3dc727a3a -rd83c0765fdc3f03caa9e6e92e4a4e9db9f5d992f --- Riskeer/Common/src/Riskeer.Common.Data/Structures/StructuresCalculationScenario.cs (.../StructuresCalculationScenario.cs) (revision 96ccefa48aa5c97c949f7a7858fcb4d3dc727a3a) +++ Riskeer/Common/src/Riskeer.Common.Data/Structures/StructuresCalculationScenario.cs (.../StructuresCalculationScenario.cs) (revision d83c0765fdc3f03caa9e6e92e4a4e9db9f5d992f) @@ -28,6 +28,7 @@ /// /// This class holds the information for a structures calculation scenario. /// + /// The type of input contained by the calculation scenario. public class StructuresCalculationScenario : StructuresCalculation, ICalculationScenario where T : IStructuresCalculationInput, new() { Index: Riskeer/Common/src/Riskeer.Common.Forms/Views/StructuresFailureMechanismResultView.cs =================================================================== diff -u --- Riskeer/Common/src/Riskeer.Common.Forms/Views/StructuresFailureMechanismResultView.cs (revision 0) +++ Riskeer/Common/src/Riskeer.Common.Forms/Views/StructuresFailureMechanismResultView.cs (revision d83c0765fdc3f03caa9e6e92e4a4e9db9f5d992f) @@ -0,0 +1,142 @@ +// 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 System.Linq; +using Core.Common.Base; +using Riskeer.Common.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.FailureMechanism; +using Riskeer.Common.Data.Structures; +using Riskeer.Common.Forms.Builders; + +namespace Riskeer.Common.Forms.Views +{ + /// + /// The view for the in structures. + /// + /// The type of failure mechanism. + /// The type of input. + public class StructuresFailureMechanismResultView : FailureMechanismResultView + where TFailureMechanism : IHasSectionResults + where TStructuresInput : IStructuresCalculationInput, new() + { + private const int initialFailureMechanismResultIndex = 2; + private const int initialFailureMechanismResultSectionProbabilityIndex = 3; + private const int furtherAnalysisNeededIndex = 4; + private const int refinedSectionProbabilityIndex = 5; + private const int sectionProbabilityIndex = 6; + private const int assemblyGroupIndex = 7; + + private readonly IAssessmentSection assessmentSection; + private readonly Func getNFunc; + + /// + /// Creates a new instance of . + /// + /// The collection of to + /// show in the view. + /// The failure mechanism the results belong to. + /// The assessment section the failure mechanism results belong to. + /// The to get the N. + /// Thrown when any parameter is null. + public StructuresFailureMechanismResultView(IObservableEnumerable failureMechanismSectionResults, + TFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + Func getNFunc) + : base(failureMechanismSectionResults, failureMechanism) + { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + if (getNFunc == null) + { + throw new ArgumentNullException(nameof(getNFunc)); + } + + this.assessmentSection = assessmentSection; + this.getNFunc = getNFunc; + } + protected override AdoptableFailureMechanismSectionResultRow CreateFailureMechanismSectionResultRow(AdoptableFailureMechanismSectionResult sectionResult) + { + StructuresCalculationScenario[] calculationScenarios = FailureMechanism.Calculations + .OfType>() + .ToArray(); + + return new AdoptableFailureMechanismSectionResultRow( + sectionResult, + () => sectionResult.GetInitialFailureMechanismResultProbability(calculationScenarios), + new InitialFailureMechanismResultErrorProvider>( + sectionResult, calculationScenarios, (scenario, lineSegments) => scenario.IsStructureIntersectionWithReferenceLineInSection(lineSegments)), + assessmentSection, new AdoptableFailureMechanismSectionResultRow.ConstructionProperties + { + InitialFailureMechanismResultIndex = initialFailureMechanismResultIndex, + InitialFailureMechanismResultSectionProbabilityIndex = initialFailureMechanismResultSectionProbabilityIndex, + FurtherAnalysisNeededIndex = furtherAnalysisNeededIndex, + RefinedSectionProbabilityIndex = refinedSectionProbabilityIndex, + SectionProbabilityIndex = sectionProbabilityIndex, + AssemblyGroupIndex = assemblyGroupIndex + }); + } + + protected override double GetN() + { + return getNFunc(FailureMechanism); + } + + protected override void AddDataGridColumns() + { + FailureMechanismSectionResultViewColumnBuilder.AddSectionNameColumn( + DataGridViewControl, + nameof(AdoptableFailureMechanismSectionResultRow.Name)); + + FailureMechanismSectionResultViewColumnBuilder.AddIsRelevantColumn( + DataGridViewControl, + nameof(AdoptableFailureMechanismSectionResultRow.IsRelevant)); + + FailureMechanismSectionResultViewColumnBuilder.AddInitialFailureMechanismResultColumn( + DataGridViewControl, + nameof(AdoptableFailureMechanismSectionResultRow.InitialFailureMechanismResult)); + + FailureMechanismSectionResultViewColumnBuilder.AddInitialFailureMechanismResultSectionProbabilityColumn( + DataGridViewControl, + nameof(AdoptableFailureMechanismSectionResultRow.InitialFailureMechanismResultSectionProbability)); + + FailureMechanismSectionResultViewColumnBuilder.AddFurtherAnalysisNeededColumn( + DataGridViewControl, + nameof(AdoptableFailureMechanismSectionResultRow.FurtherAnalysisNeeded)); + + FailureMechanismSectionResultViewColumnBuilder.AddRefinedSectionProbabilityColumn( + DataGridViewControl, + nameof(AdoptableFailureMechanismSectionResultRow.RefinedSectionProbability)); + + FailureMechanismSectionResultViewColumnBuilder.AddAssemblySectionProbabilityColumn( + DataGridViewControl, + nameof(AdoptableFailureMechanismSectionResultRow.SectionProbability)); + + FailureMechanismSectionResultViewColumnBuilder.AddAssemblyGroupColumn( + DataGridViewControl, + nameof(AdoptableFailureMechanismSectionResultRow.AssemblyGroup)); + } + } +} \ No newline at end of file