// 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.Collections.Generic;
using System.Drawing;
using System.Linq;
using Core.Common.Controls.DataGrid;
using Ringtoets.Common.Data.Probabilistics;
using Ringtoets.MacroStabilityInwards.Data.SoilProfile;
using Ringtoets.MacroStabilityInwards.Forms.Properties;
using Ringtoets.MacroStabilityInwards.Primitives;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
namespace Ringtoets.MacroStabilityInwards.Forms.Views
{
///
/// This class defines a table in which properties of instances
/// are shown as rows.
///
public class MacroStabilityInwardsSoilLayerDataTable : DataGridViewControl
{
///
/// Creates a new instance of .
///
public MacroStabilityInwardsSoilLayerDataTable()
{
AddColumns();
}
///
/// Sets the given for which the properties
/// are shown in the table.
///
/// The collection of layers to show.
public void SetData(IEnumerable layers)
{
SetDataSource(layers?.Select(l => new FormattedMacroStabilityInwardsSoilLayerDataRow(l)).ToArray());
}
private void AddColumns()
{
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.MaterialName),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_MaterialName,
true);
AddColorColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.Color),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_Color);
AddCheckBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.IsAquifer),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_IsAquifer,
true);
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.AbovePhreaticLevel),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_AbovePhreaticLevel,
true);
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.BelowPhreaticLevel),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_BelowPhreaticLevel,
true);
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.ShearStrengthModel),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_ShearStrengthModel,
true);
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.Cohesion),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_Cohesion,
true);
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.FrictionAngle),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_FrictionAngle,
true);
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.ShearStrengthRatio),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_ShearStrengthRatio,
true);
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.StrengthIncreaseExponent),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_StrengthIncreaseExponent,
true);
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.UsePop),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_UsePop,
true);
AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.Pop),
Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_Pop,
true);
}
private static string FormatDesignVariable(VariationCoefficientDesignVariable distribution)
{
return $"{distribution.GetDesignValue()} ({RingtoetsCommonFormsResources.NormalDistribution_Mean_DisplayName} = {distribution.Distribution.Mean}, " +
$"{RingtoetsCommonFormsResources.NormalDistribution_StandardDeviation_DisplayName} = {distribution.Distribution.CoefficientOfVariation})";
}
private class FormattedMacroStabilityInwardsSoilLayerDataRow
{
public FormattedMacroStabilityInwardsSoilLayerDataRow(IMacroStabilityInwardsSoilLayerData layerData)
{
MaterialName = layerData.MaterialName;
Color = layerData.Color;
IsAquifer = layerData.IsAquifer;
AbovePhreaticLevel = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(layerData));
BelowPhreaticLevel = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(layerData));
ShearStrengthModel = layerData.ShearStrengthModel;
Cohesion = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(layerData));
FrictionAngle = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(layerData));
ShearStrengthRatio = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(layerData));
StrengthIncreaseExponent = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(layerData));
UsePop = layerData.UsePop;
Pop = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(layerData));
}
///
/// Gets a value indicating whether or not the is an aquifer.
///
public bool IsAquifer { get; }
///
/// Gets the name of the material that was assigned to the .
///
public string MaterialName { get; }
///
/// Gets the that was used to represent the .
///
public Color Color { get; }
///
/// Gets the formatted design variable for .
///
public string AbovePhreaticLevel { get; }
///
/// Gets the formatted design variable for .
///
public string BelowPhreaticLevel { get; }
///
/// Gets the type.
///
public MacroStabilityInwardsShearStrengthModel ShearStrengthModel { get; }
///
/// Gets the formatted design variable for .
///
public string Cohesion { get; }
///
/// Gets the formatted design variable for .
///
public string FrictionAngle { get; }
///
/// Gets the formatted design variable for .
///
public string ShearStrengthRatio { get; }
///
/// Gets the formatted design variable for .
///
public string StrengthIncreaseExponent { get; }
///
/// Gets a value indicating whether or not the is using POP.
///
public bool UsePop { get; }
///
/// Gets the formatted design variable for .
///
public string Pop { get; }
}
}
}