// 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 Core.Components.Chart.Data;
using Core.Components.Chart.Styles;
using Ringtoets.Common.Data.Helpers;
using Ringtoets.MacroStabilityInwards.Data.SoilProfile;
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 a for waternet zones
/// under extreme circumstances.
///
/// The created .
public static ChartDataCollection CreateWaternetZonesExtremeChartDataCollection()
{
return new ChartDataCollection(Resources.WaternetLinesExtreme_DisplayName);
}
///
/// Create a for waternet zones
/// under daily circumstances.
///
/// The created .
public static ChartDataCollection CreateWaternetZonesDailyChartDataCollection()
{
return new ChartDataCollection(Resources.WaternetLinesDaily_DisplayName);
}
///
/// Create a for a waternet zone.
///
/// The name of the zone.
/// The created .
/// Thrown when
/// is null.
public static ChartMultipleAreaData CreateWaternetZoneChartData(string name)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
return new ChartMultipleAreaData(name, new ChartAreaStyle
{
StrokeThickness = 0,
FillColor = Color.FromArgb(60, Color.DeepSkyBlue),
IsEditable = true
});
}
///
/// Create a for a phreatic line.
///
/// The name of the line.
/// The created .
/// Thrown when
/// is null.
public static ChartLineData CreatePhreaticLineChartData(string name)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
return new ChartLineData(name, new ChartLineStyle
{
Color = Color.Blue,
DashStyle = ChartLineDashStyle.Solid,
Width = 2
});
}
///
/// 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 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));
}
///
/// Creates with default styling for the slip plane.
///
/// The created .
public static ChartLineData CreateSlipPlaneChartData()
{
return new ChartLineData(Resources.SlipPlane_DisplayName,
new ChartLineStyle
{
Color = Color.SaddleBrown,
DashStyle = ChartLineDashStyle.Solid,
Width = 3,
IsEditable = true
});
}
///
/// Creates with default styling for the active circle
/// radius line.
///
/// The created .
public static ChartLineData CreateActiveCircleRadiusChartData()
{
return new ChartLineData(Resources.ActiveCircleRadius_DisplayName,
GetCircleRadiusStyle());
}
///
/// Creates with default styling for the passive circle
/// radius line.
///
/// The created .
public static ChartLineData CreatePassiveCircleRadiusChartData()
{
return new ChartLineData(Resources.PassiveCircleRadius_DisplayName,
GetCircleRadiusStyle());
}
///
/// Create for a .
///
/// The layer to create the for.
/// The created .
/// Thrown when is null.
public static ChartMultipleAreaData CreateSoilLayerChartData(MacroStabilityInwardsSoilLayer2D layer)
{
if (layer == null)
{
throw new ArgumentNullException(nameof(layer));
}
MacroStabilityInwardsSoilLayerData data = layer.Data;
return new ChartMultipleAreaData(SoilLayerDataHelper.GetValidName(data.MaterialName),
new ChartAreaStyle
{
FillColor = SoilLayerDataHelper.GetValidColor(data.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,
IMacroStabilityInwardsSoilProfile soilProfile)
{
chartData.Name = soilProfile != null
? soilProfile.Name
: RingtoetsCommonFormsResources.StochasticSoilProfileProperties_DisplayName;
}
private static ChartLineStyle GetCircleRadiusStyle()
{
return new ChartLineStyle
{
Color = Color.Gray,
DashStyle = ChartLineDashStyle.Dash,
Width = 1,
IsEditable = true
};
}
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
};
}
}
}