// 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.Drawing.Drawing2D;
using System.Linq;
using Core.Components.Charting.Data;
using Core.Components.Charting.Styles;
using Ringtoets.MacroStabilityInwards.Forms.Properties;
using Ringtoets.MacroStabilityInwards.Primitives;
using MacroStabilityInwardsDataResources = Ringtoets.MacroStabilityInwards.Data.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 .
///
/// The created .
public static ChartLineData CreateSurfaceLineChartData()
{
return new ChartLineData(Resources.RingtoetsPipingSurfaceLine_DisplayName)
{
Style = new ChartLineStyle(Color.Sienna, 2, DashStyle.Solid)
};
}
///
/// Create with default styling for an entry point.
///
/// The created .
public static ChartPointData CreateEntryPointChartData()
{
return new ChartPointData(Resources.PipingInput_EntryPointL_DisplayName)
{
Style = GetGeneralPointStyle(Color.Gold)
};
}
///
/// Create with default styling for an exit point.
///
/// The created .
public static ChartPointData CreateExitPointChartData()
{
return new ChartPointData(Resources.PipingInput_ExitPointL_DisplayName)
{
Style = GetGeneralPointStyle(Color.Tomato)
};
}
///
/// Create with default styling for a characteristic point of type ditch polder side.
///
/// The created .
public static ChartPointData CreateDitchPolderSideChartData()
{
return new ChartPointData(MacroStabilityInwardsDataResources.CharacteristicPoint_DitchPolderSide)
{
Style = GetCharacteristicPointStyle(Color.IndianRed)
};
}
///
/// Create with default styling for a characteristic point of type bottom ditch polder side.
///
/// The created .
public static ChartPointData CreateBottomDitchPolderSideChartData()
{
return new ChartPointData(MacroStabilityInwardsDataResources.CharacteristicPoint_BottomDitchPolderSide)
{
Style = GetCharacteristicPointStyle(Color.Teal)
};
}
///
/// Create with default styling for a characteristic point of type bottom ditch dike side.
///
/// The created .
public static ChartPointData CreateBottomDitchDikeSideChartData()
{
return new ChartPointData(MacroStabilityInwardsDataResources.CharacteristicPoint_BottomDitchDikeSide)
{
Style = GetCharacteristicPointStyle(Color.DarkSeaGreen)
};
}
///
/// Create with default styling for a characteristic point of type ditch dike side.
///
/// The created .
public static ChartPointData CreateDitchDikeSideChartData()
{
return new ChartPointData(MacroStabilityInwardsDataResources.CharacteristicPoint_DitchDikeSide)
{
Style = GetCharacteristicPointStyle(Color.MediumPurple)
};
}
///
/// Create with default styling for a characteristic point of type dike toe at river.
///
/// The created .
public static ChartPointData CreateDikeToeAtRiverChartData()
{
return new ChartPointData(MacroStabilityInwardsDataResources.CharacteristicPoint_DikeToeAtRiver)
{
Style = GetCharacteristicPointStyle(Color.DarkBlue)
};
}
///
/// Create with default styling for a characteristic point of type dike toe at polder.
///
/// The created .
public static ChartPointData CreateDikeToeAtPolderChartData()
{
return new ChartPointData(MacroStabilityInwardsDataResources.CharacteristicPoint_DikeToeAtPolder)
{
Style = GetCharacteristicPointStyle(Color.SlateGray)
};
}
///
/// 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(string.Format("{0} {1}", soilLayerIndex + 1, soilLayer.MaterialName))
{
Style = new ChartAreaStyle(soilLayer.Color, Color.Black, 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.RingtoetsPipingSurfaceLine_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;
}
private static ChartPointStyle GetGeneralPointStyle(Color color)
{
return new ChartPointStyle(color, 8, Color.Transparent, 0, ChartPointSymbol.Triangle);
}
private static ChartPointStyle GetCharacteristicPointStyle(Color indianRed)
{
return new ChartPointStyle(indianRed, 8, Color.Transparent, 0, ChartPointSymbol.Circle);
}
}
}