// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets 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.Drawing; using System.Linq; using Core.Components.Chart.Data; using Core.Components.Chart.Styles; using Ringtoets.MacroStabilityInwards.Forms.Properties; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.Forms.Factories { /// /// Factory for creating for data used as input in the macro stability inwards failure mechanism. /// internal static class MacroStabilityInwardsChartDataFactory { /// /// Create with default styling for a . /// /// The created . public static ChartLineData CreateSurfaceLineChartData() { return new ChartLineData(Resources.RingtoetsMacroStabilityInwardsSurfaceLine_DisplayName, new ChartLineStyle { Color = Color.Sienna, Width = 2, DashStyle = ChartLineDashStyle.Solid }); } /// /// Create a for a . /// /// The created . public static ChartDataCollection CreateSoilProfileChartData() { return new ChartDataCollection(Resources.StochasticSoilProfileProperties_DisplayName); } /// /// Create for a based on its color. /// /// The index of the in for which to create . /// The which contains the . /// The created . /// Thrown when is null. /// Thrown when is outside the allowable range of values ([0, number_of_soil_layers>). public static ChartMultipleAreaData CreateSoilLayerChartData(int soilLayerIndex, MacroStabilityInwardsSoilProfile soilProfile) { if (soilProfile == null) { throw new ArgumentNullException(nameof(soilProfile)); } if (soilLayerIndex < 0 || soilLayerIndex >= soilProfile.Layers.Count()) { throw new ArgumentOutOfRangeException(nameof(soilLayerIndex)); } MacroStabilityInwardsSoilLayer soilLayer = soilProfile.Layers.ElementAt(soilLayerIndex); return new ChartMultipleAreaData($"{soilLayerIndex + 1} {soilLayer.MaterialName}", new ChartAreaStyle { FillColor = soilLayer.Color, StrokeColor = Color.Black, StrokeThickness = 1 }); } /// /// Updates the name of based on . /// /// The to update the name for. /// The used for obtaining the name. /// A default name is set (the same as in ) when is null. public static void UpdateSurfaceLineChartDataName(ChartLineData chartData, RingtoetsMacroStabilityInwardsSurfaceLine surfaceLine) { chartData.Name = surfaceLine != null ? surfaceLine.Name : Resources.RingtoetsMacroStabilityInwardsSurfaceLine_DisplayName; } /// /// Updates the name of based on . /// /// The to update the name for. /// The used for obtaining the name. /// A default name is set (the same as in ) when /// is null. public static void UpdateSoilProfileChartDataName(ChartDataCollection chartData, MacroStabilityInwardsSoilProfile soilProfile) { chartData.Name = soilProfile != null ? soilProfile.Name : Resources.StochasticSoilProfileProperties_DisplayName; } } }