// 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;
using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
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 characteristic point
/// of type shoulder base inside.
///
/// The created .
public static ChartPointData CreateShoulderBaseInsideChartData()
{
return new ChartPointData(RingtoetsCommonDataResources.CharacteristicPoint_ShoulderBaseInside,
GetCharacteristicPointStyle(Color.BlueViolet,
Color.SeaGreen,
ChartPointSymbol.Triangle));
}
///
/// Create with default styling for a characteristic point
/// of type dike top at polder.
///
/// The created .
public static ChartPointData CreateDikeTopAtPolderChartData()
{
return new ChartPointData(RingtoetsCommonDataResources.CharacteristicPoint_DikeTopAtPolder,
GetCharacteristicPointStyle(Color.LightSkyBlue,
Color.SeaGreen,
ChartPointSymbol.Triangle));
}
///
/// Create with default styling for a characteristic point
/// of type shoulder top inside.
///
/// The created .
public static ChartPointData CreateShoulderTopInsideChartData()
{
return new ChartPointData(RingtoetsCommonDataResources.CharacteristicPoint_ShoulderTopInside,
GetCharacteristicPointStyle(Color.DeepSkyBlue,
Color.SeaGreen,
ChartPointSymbol.Triangle));
}
///
/// Create with default styling for a characteristic point
/// of type surface level inside.
///
/// The created .
public static ChartPointData CreateSurfaceLevelInsideChartData()
{
return new ChartPointData(RingtoetsCommonDataResources.CharacteristicPoint_SurfaceLevelInside,
GetCharacteristicPointStyle(Color.ForestGreen,
Color.Black,
ChartPointSymbol.Square));
}
///
/// Create with default styling for a characteristic point
/// of type surface level outside.
///
/// The created .
public static ChartPointData CreateSurfaceLevelOutsideChartData()
{
return new ChartPointData(RingtoetsCommonDataResources.CharacteristicPoint_SurfaceLevelOutside,
GetCharacteristicPointStyle(Color.LightSeaGreen,
Color.Black,
ChartPointSymbol.Square));
}
///
/// Create with default styling for a characteristic point
/// of type traffic load inside.
///
/// The created .
public static ChartPointData CreateTrafficLoadInsideChartData()
{
return new ChartPointData(RingtoetsCommonDataResources.CharacteristicPoint_TrafficLoadInside,
GetCharacteristicPointStyle(Color.LightSlateGray,
Color.White,
ChartPointSymbol.Circle));
}
///
/// Create with default styling for a characteristic point
/// of type traffic load outside.
///
/// The created .
public static ChartPointData CreateTrafficLoadOutsideChartData()
{
return new ChartPointData(RingtoetsCommonDataResources.CharacteristicPoint_TrafficLoadOutside,
GetCharacteristicPointStyle(Color.DarkSlateGray,
Color.White,
ChartPointSymbol.Circle));
}
///
/// Create with default styling for a characteristic point
/// of type dike top at river.
///
/// The created .
public static ChartPointData CreateDikeTopAtRiverChartData()
{
return new ChartPointData(RingtoetsCommonDataResources.CharacteristicPoint_DikeTopAtRiver,
GetCharacteristicPointStyle(Color.LightSteelBlue,
Color.SeaGreen,
ChartPointSymbol.Triangle));
}
///
/// Creates with default styling for grids for the right grid.
///
/// The created .
public static ChartPointData CreateRightGridChartData()
{
return new ChartPointData(Resources.RightGrid_DisplayName,
GetGridStyle(Color.Black, ChartPointSymbol.Plus));
}
///
/// Creates with default styling for grids for the left grid.
///
/// The created .
public static ChartPointData CreateLeftGridChartData()
{
return new ChartPointData(Resources.LeftGrid_DisplayName,
GetGridStyle(Color.Black, ChartPointSymbol.Plus));
}
///
/// 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, MacroStabilityInwardsSoilProfile1D soilProfile)
{
if (soilProfile == null)
{
throw new ArgumentNullException(nameof(soilProfile));
}
if (soilLayerIndex < 0 || soilLayerIndex >= soilProfile.Layers.Count())
{
throw new ArgumentOutOfRangeException(nameof(soilLayerIndex));
}
MacroStabilityInwardsSoilLayer1D soilLayer = soilProfile.Layers.ElementAt(soilLayerIndex);
return new ChartMultipleAreaData($"{soilLayerIndex + 1} {soilLayer.Properties.MaterialName}",
new ChartAreaStyle
{
FillColor = soilLayer.Properties.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 when is null.
public static void UpdateSurfaceLineChartDataName(ChartLineData chartData, MacroStabilityInwardsSurfaceLine surfaceLine)
{
chartData.Name = surfaceLine != null
? surfaceLine.Name
: RingtoetsCommonFormsResources.SurfaceLine_DisplayName;
}
///
/// Updates the name of based on .
///
/// The to update the name for.
/// The used for obtaining the name.
/// A default name is set when is null.
public static void UpdateSoilProfileChartDataName(ChartDataCollection chartData, MacroStabilityInwardsSoilProfile1D soilProfile)
{
chartData.Name = soilProfile != null
? soilProfile.Name
: RingtoetsCommonFormsResources.StochasticSoilProfileProperties_DisplayName;
}
private static ChartPointStyle GetCharacteristicPointStyle(Color fillColor, Color strokeColor, ChartPointSymbol symbol)
{
return new ChartPointStyle
{
Color = fillColor,
StrokeColor = strokeColor,
Size = 8,
StrokeThickness = strokeColor == Color.Transparent
? 0
: 1,
Symbol = symbol,
IsEditable = true
};
}
private static ChartPointStyle GetGridStyle(Color color, ChartPointSymbol symbol)
{
return new ChartPointStyle
{
Color = color,
StrokeColor = color,
Size = 6,
StrokeThickness = color == Color.Transparent
? 0
: 2,
Symbol = symbol,
IsEditable = true
};
}
}
}