Add series to graph
This commit is contained in:
@@ -86,7 +86,6 @@
|
|||||||
<Folder Include="Infrastructure\UI\DataContexts\Logics\" />
|
<Folder Include="Infrastructure\UI\DataContexts\Logics\" />
|
||||||
<Folder Include="Resources\" />
|
<Folder Include="Resources\" />
|
||||||
<Folder Include="Windows\UserControls\MultiplyTuples\" />
|
<Folder Include="Windows\UserControls\MultiplyTuples\" />
|
||||||
<Folder Include="Windows\ViewModels\Graphs\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -73,7 +73,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
|||||||
{
|
{
|
||||||
SafetyProcessor.RunSafeProcess(() =>
|
SafetyProcessor.RunSafeProcess(() =>
|
||||||
{
|
{
|
||||||
var wnd = new GraphView(arrayParameter);
|
var series = new Series(arrayParameter) { Name = "Forces and curvatures" };
|
||||||
|
var vm = new GraphViewModel(new List<Series>() { series });
|
||||||
|
var wnd = new GraphView(vm);
|
||||||
wnd.ShowDialog();
|
wnd.ShowDialog();
|
||||||
},
|
},
|
||||||
"Errors appeared during showing a graph, see detailed information");
|
"Errors appeared during showing a graph, see detailed information");
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using StructureHelperCommon.Models.Parameters;
|
|||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||||
using StructureHelperLogics.Services.NdmPrimitives;
|
using StructureHelperLogics.Services.NdmPrimitives;
|
||||||
using System;
|
using System;
|
||||||
@@ -17,6 +18,9 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
|
//All rights reserved.
|
||||||
|
|
||||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
|
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
|
||||||
{
|
{
|
||||||
internal class InteractionDiagramLogic : ILongProcessLogic
|
internal class InteractionDiagramLogic : ILongProcessLogic
|
||||||
@@ -24,46 +28,36 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
const string ForceUnitString = "kN";
|
const string ForceUnitString = "kN";
|
||||||
const string MomentUnitString = "kNm";
|
const string MomentUnitString = "kNm";
|
||||||
|
|
||||||
private ArrayParameter<double> arrayParameter;
|
//private List<ArrayParameter<double>> arrayParameters;
|
||||||
private IResult result;
|
private IResult result;
|
||||||
private IUnit unitForce = CommonOperation.GetUnit(UnitTypes.Force, ForceUnitString);
|
private IUnit unitForce = CommonOperation.GetUnit(UnitTypes.Force, ForceUnitString);
|
||||||
private IUnit unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, MomentUnitString);
|
private IUnit unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, MomentUnitString);
|
||||||
|
private int stepCount;
|
||||||
|
|
||||||
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
|
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
|
||||||
|
public LimitCurveInputData InputData { get; set; }
|
||||||
public int StepCount => SurroundData.PointCount;
|
public int StepCount { get => stepCount; set => stepCount = value; }
|
||||||
|
|
||||||
public Action<int> SetProgress { get; set; }
|
public Action<int> SetProgress { get; set; }
|
||||||
public bool Result { get; set; }
|
public bool Result { get; set; }
|
||||||
public IEnumerable<INdmPrimitive> NdmPrimitives { get; set; }
|
|
||||||
public LimitStates LimitState { get; set; }
|
|
||||||
public CalcTerms CalcTerm { get; set; }
|
|
||||||
//public ForceTuple ForceTuple { get; set; }
|
|
||||||
|
|
||||||
|
public InteractionDiagramLogic(LimitCurveInputData inputData)
|
||||||
public SurroundData SurroundData { get; set; }
|
|
||||||
|
|
||||||
public InteractionDiagramLogic(SurroundData surroundData)
|
|
||||||
{
|
{
|
||||||
SurroundData = surroundData;
|
InputData = inputData;
|
||||||
|
stepCount = InputData.PointCount;
|
||||||
|
stepCount *= InputData.LimitStates.Count();
|
||||||
|
stepCount *= InputData.CalcTerms.Count();
|
||||||
|
stepCount *= InputData.PredicateEntries.Count();
|
||||||
|
//arrayParameters = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoCalculations()
|
private void DoCalculations()
|
||||||
{
|
{
|
||||||
var ndmCollection = NdmPrimitivesService.GetNdms(NdmPrimitives, LimitState, CalcTerm);
|
var convertLogic = InputData.SurroundData.ConvertLogicEntity;
|
||||||
var convertLogic = SurroundData.ConvertLogicEntity;
|
var calculator = new LimitCurvesCalculator()
|
||||||
convertLogic.ConstDirectionValue = SurroundData.ConstZ;
|
|
||||||
var predicateFactory = new PredicateFactory()
|
|
||||||
{
|
{
|
||||||
Ndms = ndmCollection,
|
InputData = InputData
|
||||||
ConvertLogic = convertLogic.ConvertLogic,
|
|
||||||
};
|
};
|
||||||
Predicate<IPoint2D> predicate = predicateFactory.IsSectionFailure;
|
|
||||||
//Predicate<IPoint2D> predicate = predicateFactory.IsSectionCracked;
|
|
||||||
//var logic = new StabLimitCurveLogic();
|
|
||||||
var logic = new LimitCurveLogic(predicate);
|
|
||||||
var calculator = new LimitCurveCalculator(logic);
|
|
||||||
calculator.SurroundData = SurroundData;
|
|
||||||
calculator.ActionToOutputResults = SetProgressByResult;
|
calculator.ActionToOutputResults = SetProgressByResult;
|
||||||
SafetyProcessor.RunSafeProcess(() =>
|
SafetyProcessor.RunSafeProcess(() =>
|
||||||
{
|
{
|
||||||
@@ -71,15 +65,34 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
}, "Errors appeared during showing a graph, see detailed information");
|
}, "Errors appeared during showing a graph, see detailed information");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CalcResult(LimitCurveCalculator calculator)
|
private void CalcResult(LimitCurvesCalculator calculator)
|
||||||
{
|
{
|
||||||
calculator.Run();
|
calculator.Run();
|
||||||
result = calculator.Result;
|
var curvesResult = calculator.Result as LimitCurvesResult;
|
||||||
if (result.IsValid == false) { return; }
|
if (curvesResult.IsValid == false) { return; }
|
||||||
var interactionResult = result as LimitCurveResult;
|
result = curvesResult;
|
||||||
|
foreach (var curveResult in curvesResult.LimitCurveResults)
|
||||||
|
{
|
||||||
|
ProcessCurveResult(curveResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessCurveResult(LimitCurveResult curveResult)
|
||||||
|
{
|
||||||
|
if (curveResult.IsValid == false)
|
||||||
|
{
|
||||||
|
SafetyProcessor.ShowMessage("Calculation error", curveResult.Description);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//var arrayParameter = GetParametersByCurveResult(curveResult);
|
||||||
|
//arrayParameters.Add(arrayParameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayParameter<double> GetParametersByCurveResult(LimitCurveResult curveResult)
|
||||||
|
{
|
||||||
string[] labels = GetLabels();
|
string[] labels = GetLabels();
|
||||||
var items = interactionResult.Points;
|
var items = curveResult.Points;
|
||||||
arrayParameter = new ArrayParameter<double>(items.Count(), labels.Count(), labels);
|
var arrayParameter = new ArrayParameter<double>(items.Count(), labels.Count(), labels);
|
||||||
var data = arrayParameter.Data;
|
var data = arrayParameter.Data;
|
||||||
for (int i = 0; i < items.Count(); i++)
|
for (int i = 0; i < items.Count(); i++)
|
||||||
{
|
{
|
||||||
@@ -94,23 +107,25 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
data[i, j] = valueList[j];
|
data[i, j] = valueList[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return arrayParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetProgressByResult(IResult calcResult)
|
private void SetProgressByResult(IResult calcResult)
|
||||||
{
|
{
|
||||||
if (calcResult is not LimitCurveResult)
|
if (calcResult is not LimitCurvesResult)
|
||||||
{
|
{
|
||||||
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(LimitCurveResult), calcResult));
|
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(LimitCurvesResult), calcResult));
|
||||||
}
|
}
|
||||||
var parameterResult = calcResult as LimitCurveResult;
|
var parameterResult = calcResult as LimitCurvesResult;
|
||||||
|
StepCount = stepCount;// parameterResult.MaxIterationCount;
|
||||||
SetProgress?.Invoke(parameterResult.IterationNumber);
|
SetProgress?.Invoke(parameterResult.IterationNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string[] GetLabels()
|
private string[] GetLabels()
|
||||||
{
|
{
|
||||||
string[] strings = new string[2];
|
string[] strings = new string[2];
|
||||||
strings[0] = GetLabel(SurroundData.ConvertLogicEntity.XForceType);
|
strings[0] = GetLabel(InputData.SurroundData.ConvertLogicEntity.XForceType);
|
||||||
strings[1] = GetLabel(SurroundData.ConvertLogicEntity.YForceType);
|
strings[1] = GetLabel(InputData.SurroundData.ConvertLogicEntity.YForceType);
|
||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +156,15 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
{
|
{
|
||||||
if (result.IsValid == true)
|
if (result.IsValid == true)
|
||||||
{
|
{
|
||||||
var wnd = new GraphView(arrayParameter);
|
var curveResult = result as LimitCurvesResult;
|
||||||
|
var seriesList = new List<Series>();
|
||||||
|
foreach (var item in curveResult.LimitCurveResults)
|
||||||
|
{
|
||||||
|
var series = new Series(GetParametersByCurveResult(item)) { Name = item.Name };
|
||||||
|
seriesList.Add(series);
|
||||||
|
}
|
||||||
|
var vm = new GraphViewModel(seriesList);
|
||||||
|
var wnd = new GraphView(vm);
|
||||||
wnd.ShowDialog();
|
wnd.ShowDialog();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -13,9 +13,23 @@
|
|||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="35"/>
|
<RowDefinition Height="35"/>
|
||||||
|
<RowDefinition Height="35"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<fc:SurroundDataControl x:Name="SurData" SurroundData="{Binding SurroundData}"/>
|
<fc:SurroundDataControl x:Name="SurData" SurroundData="{Binding SurroundData}"/>
|
||||||
|
<Grid Grid.Row="1">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="150"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition Width="120"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Point count"/>
|
||||||
|
<TextBox Grid.Column="1" Text="{Binding PointCount, ValidatesOnDataErrors=True}"/>
|
||||||
|
<uc:MultiplyDouble Margin="2" Grid.Column="3" ValueChanged="PointCountChanged"/>
|
||||||
|
</Grid>
|
||||||
<!--<ContentControl ContentTemplate="{StaticResource SurroundData}" Content="{Binding SurroundDataViewModel}"/>-->
|
<!--<ContentControl ContentTemplate="{StaticResource SurroundData}" Content="{Binding SurroundDataViewModel}"/>-->
|
||||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
<ContentControl Grid.Row="2" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -31,5 +31,16 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SurData.SurroundData = vm.SurroundData;
|
SurData.SurroundData = vm.SurroundData;
|
||||||
}
|
}
|
||||||
|
private void PointCountChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
viewModel.PointCount = Convert.ToInt32(viewModel.PointCount * ChangeValue(sender));
|
||||||
|
}
|
||||||
|
|
||||||
|
private double ChangeValue(object sender)
|
||||||
|
{
|
||||||
|
var obj = (MultiplyDouble)sender;
|
||||||
|
var factor = obj.DoubleFactor;
|
||||||
|
return factor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using StructureHelperCommon.Models.Shapes;
|
|||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||||
|
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -17,16 +18,75 @@ using System.Windows.Data;
|
|||||||
|
|
||||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
|
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
|
||||||
{
|
{
|
||||||
public class LimitCurveDataViewModel : OkCancelViewModelBase
|
public class LimitCurveDataViewModel : OkCancelViewModelBase, IDataErrorInfo
|
||||||
{
|
{
|
||||||
|
private int pointCount;
|
||||||
|
|
||||||
//public SurroundDataViewModel SurroundDataViewModel { get; private set; }
|
//public SurroundDataViewModel SurroundDataViewModel { get; private set; }
|
||||||
public SurroundData SurroundData { get; set; }
|
public SurroundData SurroundData { get; set; }
|
||||||
|
public List<INdmPrimitive> Primitives { get; set; }
|
||||||
|
public int PointCount
|
||||||
|
{
|
||||||
|
get => pointCount; set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pointCount = value;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
pointCount = 40;
|
||||||
|
}
|
||||||
|
OnPropertyChanged(nameof(PointCount));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public LimitCurveDataViewModel(SurroundData surroundData)
|
public LimitCurveDataViewModel(SurroundData surroundData)
|
||||||
{
|
{
|
||||||
//SurroundDataViewModel = new(surroundData);
|
//SurroundDataViewModel = new(surroundData);
|
||||||
SurroundData = surroundData;
|
SurroundData = surroundData;
|
||||||
|
pointCount = 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LimitCurveDataViewModel() : this (new SurroundData())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public LimitCurveInputData GetLimitCurveInputData()
|
||||||
|
{
|
||||||
|
LimitCurveInputData inputData = new()
|
||||||
|
{
|
||||||
|
SurroundData = SurroundData,
|
||||||
|
PointCount = pointCount
|
||||||
|
};
|
||||||
|
inputData.LimitStates.Add(LimitStates.ULS);
|
||||||
|
inputData.LimitStates.Add(LimitStates.SLS);
|
||||||
|
inputData.CalcTerms.Add(CalcTerms.ShortTerm);
|
||||||
|
inputData.CalcTerms.Add(CalcTerms.LongTerm);
|
||||||
|
inputData.PredicateEntries.Add(new PredicateEntry() { Name = "Strength", PredicateType = PredicateTypes.Strength });
|
||||||
|
inputData.PredicateEntries.Add(new PredicateEntry() { Name = "Cracking", PredicateType = PredicateTypes.Cracking });
|
||||||
|
inputData.Primitives = Primitives;
|
||||||
|
return inputData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Error => throw new NotImplementedException();
|
||||||
|
|
||||||
|
public string this[string columnName]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string error = String.Empty;
|
||||||
|
switch (columnName)
|
||||||
|
{
|
||||||
|
case nameof(PointCount):
|
||||||
|
if (PointCount < 24)
|
||||||
|
{
|
||||||
|
error = "Point count must be greater than 24";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
{
|
{
|
||||||
SafetyProcessor.RunSafeProcess(() =>
|
SafetyProcessor.RunSafeProcess(() =>
|
||||||
{
|
{
|
||||||
var wnd = new GraphView(arrayParameter);
|
var series = new Series(arrayParameter) { Name = "Forces and curvatures" };
|
||||||
|
var vm = new GraphViewModel(new List<Series>() { series});
|
||||||
|
var wnd = new GraphView(vm);
|
||||||
wnd.ShowDialog();
|
wnd.ShowDialog();
|
||||||
},
|
},
|
||||||
"Errors appeared during showing a graph, see detailed information");
|
"Errors appeared during showing a graph, see detailed information");
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
|
|
||||||
public void ShowProgressResult(int progressValue)
|
public void ShowProgressResult(int progressValue)
|
||||||
{
|
{
|
||||||
|
progressViewModel.MaxValue = processLogic.StepCount;
|
||||||
progressViewModel.ProgressValue = progressValue;
|
progressViewModel.ProgressValue = progressValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using StructureHelperCommon.Models.Shapes;
|
|||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Services.Forces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
|
using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||||
@@ -74,26 +75,21 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
return showInteractionDiagramCommand ??
|
return showInteractionDiagramCommand ??
|
||||||
(showInteractionDiagramCommand = new RelayCommand(o =>
|
(showInteractionDiagramCommand = new RelayCommand(o =>
|
||||||
{
|
{
|
||||||
var tuple = SelectedResult.DesignForceTuple.ForceTuple.Clone() as ForceTuple;
|
var surroundDdata = new SurroundData();
|
||||||
var data = new SurroundData();
|
var vm = new LimitCurveDataViewModel(surroundDdata);
|
||||||
//data.ConstZ = tuple.My;
|
vm.Primitives = ndmPrimitives.ToList();
|
||||||
var wnd = new LimitCurveDataView(data);
|
var wnd = new LimitCurveDataView(vm);
|
||||||
wnd.ShowDialog();
|
wnd.ShowDialog();
|
||||||
if (wnd.DialogResult != true) return;
|
if (wnd.DialogResult != true) return;
|
||||||
interactionDiagramLogic = new(data)
|
var inputData = vm.GetLimitCurveInputData();
|
||||||
{
|
interactionDiagramLogic = new(inputData);
|
||||||
//ForceTuple = tuple,
|
|
||||||
LimitState = SelectedResult.DesignForceTuple.LimitState,
|
|
||||||
CalcTerm = SelectedResult.DesignForceTuple.CalcTerm,
|
|
||||||
NdmPrimitives = ndmPrimitives
|
|
||||||
};
|
|
||||||
showProgressLogic = new(interactionDiagramLogic)
|
showProgressLogic = new(interactionDiagramLogic)
|
||||||
{
|
{
|
||||||
WindowTitle = "Diagram creating...",
|
WindowTitle = "Diagram creating...",
|
||||||
ShowResult = interactionDiagramLogic.ShowWindow
|
ShowResult = interactionDiagramLogic.ShowWindow
|
||||||
};
|
};
|
||||||
showProgressLogic.Show();
|
showProgressLogic.Show();
|
||||||
}, o => SelectedResult != null && SelectedResult.IsValid));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ICommand ShowIsoFieldCommand
|
public ICommand ShowIsoFieldCommand
|
||||||
@@ -160,7 +156,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
};
|
};
|
||||||
showProgressLogic.Show();
|
showProgressLogic.Show();
|
||||||
}
|
}
|
||||||
}
|
}, o => SelectedResult != null && SelectedResult.IsValid
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public ICommand ShowCrackGraphsCommand
|
public ICommand ShowCrackGraphsCommand
|
||||||
@@ -191,7 +187,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
};
|
};
|
||||||
showProgressLogic.Show();
|
showProgressLogic.Show();
|
||||||
}
|
}
|
||||||
}
|
}, o => SelectedResult != null && SelectedResult.IsValid
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public ICommand ShowCrackResultCommand
|
public ICommand ShowCrackResultCommand
|
||||||
|
|||||||
@@ -87,17 +87,6 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<Grid Margin="35,0,0,0">
|
<Grid Margin="35,0,0,0">
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="25"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="150"/>
|
|
||||||
<ColumnDefinition/>
|
|
||||||
<ColumnDefinition Width="120"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<TextBlock Text="Point count"/>
|
|
||||||
<TextBox Grid.Column="1" Text="{Binding PointCount, ValidatesOnDataErrors=True}"/>
|
|
||||||
<uc:MultiplyDouble Margin="2" Grid.Column="3" ValueChanged="PointCountChanged"/>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
{
|
{
|
||||||
if (SurroundData is null)
|
if (SurroundData is null)
|
||||||
{
|
{
|
||||||
ViewModel = new SurroundDataViewModel(new() { PointCount = 40 });
|
ViewModel = new SurroundDataViewModel(new());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -90,10 +90,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
{
|
{
|
||||||
ViewModel.ConstZ *= ChangeValue(sender);
|
ViewModel.ConstZ *= ChangeValue(sender);
|
||||||
}
|
}
|
||||||
private void PointCountChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ViewModel.PointCount = Convert.ToInt32(ViewModel.PointCount * ChangeValue(sender));
|
|
||||||
}
|
|
||||||
|
|
||||||
private double ChangeValue(object sender)
|
private double ChangeValue(object sender)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
OnPropertyChanged(nameof(YMax));
|
OnPropertyChanged(nameof(YMax));
|
||||||
OnPropertyChanged(nameof(YMin));
|
OnPropertyChanged(nameof(YMin));
|
||||||
OnPropertyChanged(nameof(ConstZ));
|
OnPropertyChanged(nameof(ConstZ));
|
||||||
OnPropertyChanged(nameof(PointCount));
|
|
||||||
OnPropertyChanged(nameof(XLabel));
|
OnPropertyChanged(nameof(XLabel));
|
||||||
OnPropertyChanged(nameof(YLabel));
|
OnPropertyChanged(nameof(YLabel));
|
||||||
OnPropertyChanged(nameof(ZLabel));
|
OnPropertyChanged(nameof(ZLabel));
|
||||||
@@ -162,22 +161,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int PointCount
|
|
||||||
{
|
|
||||||
get => SurroundData.PointCount; set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SurroundData.PointCount = value;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
SurroundData.PointCount = 40;
|
|
||||||
}
|
|
||||||
OnPropertyChanged(nameof(PointCount));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Error => throw new NotImplementedException();
|
public string Error => throw new NotImplementedException();
|
||||||
|
|
||||||
public string this[string columnName]
|
public string this[string columnName]
|
||||||
@@ -187,12 +170,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
string error = String.Empty;
|
string error = String.Empty;
|
||||||
switch (columnName)
|
switch (columnName)
|
||||||
{
|
{
|
||||||
case nameof(PointCount):
|
//case nameof(PointCount):
|
||||||
if (PointCount < 24)
|
// if (PointCount < 24)
|
||||||
{
|
// {
|
||||||
error = "Point count must be greater than 24";
|
// error = "Point count must be greater than 24";
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
{
|
{
|
||||||
lineSeries.Stroke = new SolidColorBrush(color);
|
lineSeries.Stroke = new SolidColorBrush(color);
|
||||||
lineSeries.Fill = new SolidColorBrush(color) { Opacity = visualProps.Opacity };
|
lineSeries.Fill = new SolidColorBrush(color) { Opacity = visualProps.Opacity };
|
||||||
|
SetVisualProps(lineSeries, visualProps);
|
||||||
|
}
|
||||||
|
public static void SetVisualProps(LineSeries lineSeries, GraphVisualProps visualProps)
|
||||||
|
{
|
||||||
lineSeries.LineSmoothness = visualProps.LineSmoothness;
|
lineSeries.LineSmoothness = visualProps.LineSmoothness;
|
||||||
lineSeries.PointGeometry = DefaultGeometries.Circle;
|
lineSeries.PointGeometry = DefaultGeometries.Circle;
|
||||||
lineSeries.PointGeometrySize = visualProps.StrokeSize;
|
lineSeries.PointGeometrySize = visualProps.StrokeSize;
|
||||||
|
|||||||
@@ -24,51 +24,60 @@
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="170"/>
|
||||||
<RowDefinition Height="40"/>
|
<RowDefinition Height="40"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid>
|
<ListBox ItemsSource="{Binding Series}">
|
||||||
<Grid.RowDefinitions>
|
<ListBox.ItemTemplate>
|
||||||
<RowDefinition Height="70"/>
|
<DataTemplate>
|
||||||
<RowDefinition/>
|
<Expander Header="{Binding Name}" IsExpanded="True" Background="{Binding Color}">
|
||||||
<RowDefinition Height="170"/>
|
<Grid >
|
||||||
</Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<GroupBox Grid.Row="0" Header="X-axis values">
|
<RowDefinition Height="70"/>
|
||||||
<StackPanel>
|
<RowDefinition/>
|
||||||
<ComboBox ItemsSource="{Binding XItems.Collection}" SelectedItem="{Binding XItems.SelectedItem}">
|
</Grid.RowDefinitions>
|
||||||
<ComboBox.ItemTemplate>
|
<GroupBox Grid.Row="0" Margin="10,0,10,0" Header="X-axis values">
|
||||||
<DataTemplate>
|
<StackPanel>
|
||||||
<Grid>
|
<ComboBox ItemsSource="{Binding XItems.Collection}" SelectedItem="{Binding XItems.SelectedItem}">
|
||||||
<Grid.ColumnDefinitions>
|
<ComboBox.ItemTemplate>
|
||||||
<ColumnDefinition Width="20"/>
|
<DataTemplate>
|
||||||
<ColumnDefinition/>
|
<Grid>
|
||||||
</Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<Rectangle Grid.Column="0" Margin="3">
|
<ColumnDefinition Width="20"/>
|
||||||
<Rectangle.Fill>
|
<ColumnDefinition/>
|
||||||
<SolidColorBrush Color="{Binding Color}"/>
|
</Grid.ColumnDefinitions>
|
||||||
</Rectangle.Fill>
|
<Rectangle Grid.Column="0" Margin="3">
|
||||||
</Rectangle>
|
<Rectangle.Fill>
|
||||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
<SolidColorBrush Color="{Binding Color}"/>
|
||||||
</Grid>
|
</Rectangle.Fill>
|
||||||
</DataTemplate>
|
</Rectangle>
|
||||||
</ComboBox.ItemTemplate>
|
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||||
</ComboBox>
|
</Grid>
|
||||||
<CheckBox Margin="5" Content="Invert Values" IsChecked="{Binding InvertXValues}"/>
|
</DataTemplate>
|
||||||
</StackPanel>
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
<CheckBox Margin="5" Content="Invert Values" IsChecked="{Binding InvertXValues}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<GroupBox Grid.Row="1" Header="Y-axis values">
|
<GroupBox Grid.Row="1" Margin="10,0,10,0" Header="Y-axis values">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
<RowDefinition Height="30"/>
|
<RowDefinition Height="30"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>
|
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>
|
||||||
<CheckBox Grid.Row="1" Margin="5" Content="Invert Values" IsChecked="{Binding InvertYValues}"/>
|
<CheckBox Grid.Row="1" Margin="5" Content="Invert Values" IsChecked="{Binding InvertYValues}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<ContentControl Grid.Row="2" ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}" Content="{Binding VisualProps}"/>
|
</Grid>
|
||||||
</Grid>
|
</Expander>
|
||||||
<StackPanel Grid.Row="1">
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}" Content="{Binding VisualProps}"/>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="2">
|
||||||
<Button Margin="3" Content="Draw Lines" ToolTip="Draw Lines" Command="{Binding RedrawLinesCommand}"/>
|
<Button Margin="3" Content="Draw Lines" ToolTip="Draw Lines" Command="{Binding RedrawLinesCommand}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -35,5 +35,8 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
public GraphView(ArrayParameter<double> arrayParameter) : this(new GraphViewModel(arrayParameter))
|
public GraphView(ArrayParameter<double> arrayParameter) : this(new GraphViewModel(arrayParameter))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
public GraphView(IEnumerable<ArrayParameter<double>> arrayParameters) : this(new GraphViewModel(arrayParameters))
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
|
//All rights reserved.
|
||||||
|
|
||||||
namespace StructureHelper.Windows.Graphs
|
namespace StructureHelper.Windows.Graphs
|
||||||
{
|
{
|
||||||
public class GraphViewModel : ViewModelBase
|
public class GraphViewModel : ViewModelBase
|
||||||
@@ -28,9 +31,8 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IArrayParameter<double> arrayParameter;
|
List<IArrayParameter<double>> arrayParameters;
|
||||||
List<IValueParameter<double>> valueParameters;
|
|
||||||
Dictionary<IValueParameter<double>, double[]> valueList;
|
|
||||||
private RelayCommand redrawLinesCommand;
|
private RelayCommand redrawLinesCommand;
|
||||||
private bool invertXValues;
|
private bool invertXValues;
|
||||||
private bool invertYValues;
|
private bool invertYValues;
|
||||||
@@ -39,6 +41,7 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
public SelectedItemViewModel<IValueParameter<double>> XItems { get; private set; }
|
public SelectedItemViewModel<IValueParameter<double>> XItems { get; private set; }
|
||||||
public SelectItemsViewModel<IValueParameter<double>> YItems { get; set; }
|
public SelectItemsViewModel<IValueParameter<double>> YItems { get; set; }
|
||||||
public ObservableCollection<ColumnInfo> Columns { get; } = new ObservableCollection<ColumnInfo>();
|
public ObservableCollection<ColumnInfo> Columns { get; } = new ObservableCollection<ColumnInfo>();
|
||||||
|
public ObservableCollection<Series> Series { get;}
|
||||||
|
|
||||||
|
|
||||||
public bool InvertXValues
|
public bool InvertXValues
|
||||||
@@ -68,7 +71,7 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
|
|
||||||
public ICommand RedrawLinesCommand
|
public ICommand RedrawLinesCommand
|
||||||
{
|
{
|
||||||
get => redrawLinesCommand ??= new RelayCommand(o => DrawLines());
|
get => redrawLinesCommand ??= new RelayCommand(o => DrawSeries());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand SaveAsImage
|
public ICommand SaveAsImage
|
||||||
@@ -102,47 +105,36 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
Clipboard.SetImage(bitmapImage);
|
Clipboard.SetImage(bitmapImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphViewModel(IArrayParameter<double> arrayParameter)
|
public GraphViewModel(IArrayParameter<double> arrayParameter) : this (new List<IArrayParameter<double>>() { arrayParameter})
|
||||||
{
|
{
|
||||||
this.arrayParameter = arrayParameter;
|
|
||||||
valueParameters = GetParameters();
|
|
||||||
XItems = new SelectedItemViewModel<IValueParameter<double>>(valueParameters);
|
|
||||||
YItems = new SelectItemsViewModel<IValueParameter<double>>(valueParameters);
|
|
||||||
YItems.ShowButtons = true;
|
|
||||||
XItems.SelectedItem = XItems.Collection[0];
|
|
||||||
YItems.UnSelectAllCommand.Execute(null);
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public GraphViewModel(IEnumerable<IArrayParameter<double>> arrayParameters)
|
||||||
|
{
|
||||||
|
this.arrayParameters = arrayParameters.ToList();
|
||||||
|
Series = new();
|
||||||
|
foreach (var item in this.arrayParameters)
|
||||||
|
{
|
||||||
|
Series.Add(new Series(item));
|
||||||
|
}
|
||||||
VisualProps = new();
|
VisualProps = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IValueParameter<double>> GetParameters()
|
public GraphViewModel(IEnumerable<Series> series)
|
||||||
{
|
{
|
||||||
valueList = new Dictionary<IValueParameter<double>, double[]>();
|
Series = new();
|
||||||
var items = new List<IValueParameter<double>>();
|
foreach (var item in series)
|
||||||
var data = arrayParameter.Data;
|
|
||||||
int columnCount = data.GetLength(1);
|
|
||||||
for (int i = 0; i < columnCount; i++)
|
|
||||||
{
|
{
|
||||||
var item = new ValueParameter<double>()
|
Series.Add(item);
|
||||||
{
|
|
||||||
Name = arrayParameter.ColumnLabels[i],
|
|
||||||
Color = ColorProcessor.GetRandomColor(),
|
|
||||||
};
|
|
||||||
items.Add(item);
|
|
||||||
int rowCount = data.GetLength(0);
|
|
||||||
var values = new double[rowCount];
|
|
||||||
for (int j = 0; j < rowCount; j++)
|
|
||||||
{
|
|
||||||
values[j] = data[j, i];
|
|
||||||
}
|
|
||||||
valueList.Add(item, values);
|
|
||||||
}
|
}
|
||||||
return items;
|
VisualProps = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawLines()
|
|
||||||
|
|
||||||
|
private void DrawSeries()
|
||||||
{
|
{
|
||||||
if (XItems.SelectedItem is null || YItems.SelectedCount == 0) return;
|
|
||||||
SetLines();
|
SetLines();
|
||||||
OnPropertyChanged(nameof(SeriesCollection));
|
OnPropertyChanged(nameof(SeriesCollection));
|
||||||
OnPropertyChanged(nameof(Labels));
|
OnPropertyChanged(nameof(Labels));
|
||||||
@@ -150,47 +142,15 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
|
|
||||||
private void SetLines()
|
private void SetLines()
|
||||||
{
|
{
|
||||||
var xParameter = XItems.SelectedItem;
|
|
||||||
var yParameters = YItems.SelectedItems;
|
|
||||||
var xFactor = invertXValues ? -1d : 1d;
|
|
||||||
var yFactor = invertYValues ? -1d : 1d;
|
|
||||||
var labels = new List<double>();
|
|
||||||
SeriesCollection = new SeriesCollection();
|
SeriesCollection = new SeriesCollection();
|
||||||
foreach (var yParameter in yParameters)
|
Labels = new();
|
||||||
|
foreach (var series in Series)
|
||||||
{
|
{
|
||||||
var localLabels = new List<double>();
|
series.VisualProps = VisualProps;
|
||||||
var lineSeries = new LineSeries()
|
series.RefreshSeries();
|
||||||
{
|
SeriesCollection.AddRange(series.SeriesCollection);
|
||||||
Configuration = new CartesianMapper<IPoint2D>()
|
Labels.AddRange(series.Labels);
|
||||||
.X(point => point.X)
|
|
||||||
.Y(point => point.Y),
|
|
||||||
Title = yParameter.Name,
|
|
||||||
};
|
|
||||||
GraphService.SetVisualProps(lineSeries, VisualProps, yParameter.Color);
|
|
||||||
_ = valueList.TryGetValue(xParameter, out double[] xValues);
|
|
||||||
_ = valueList.TryGetValue(yParameter, out double[] yValues);
|
|
||||||
var chartValues = new ChartValues<Point2D>();
|
|
||||||
for (int i = 0; i < yValues.Count(); i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
double diagramValue = yValues[i] * yFactor;
|
|
||||||
var x = xValues[i] * xFactor;
|
|
||||||
var y = yValues[i] * yFactor;
|
|
||||||
var point = new Point2D() { X = x, Y = y };
|
|
||||||
chartValues.Add(point);
|
|
||||||
labels.Add(x);
|
|
||||||
localLabels.Add(x);
|
|
||||||
|
|
||||||
}
|
|
||||||
lineSeries.Values = chartValues;
|
|
||||||
//lineSeries.LabelPoint = point => localLabels[(int)point.X].ToString();
|
|
||||||
SeriesCollection.Add(lineSeries);
|
|
||||||
}
|
}
|
||||||
Labels = labels
|
|
||||||
.OrderBy(x => x)
|
|
||||||
.Distinct()
|
|
||||||
.Select(x => x.ToString())
|
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GraphService.SetVisualProps(lineSeries, VisualProps, ColorProcessor.GetRandomColor());
|
GraphService.SetVisualProps(lineSeries, VisualProps);
|
||||||
}
|
}
|
||||||
var chartValues = new ChartValues<double>();
|
var chartValues = new ChartValues<double>();
|
||||||
for (double s = minValue; s < maxValue; s += step)
|
for (double s = minValue; s < maxValue; s += step)
|
||||||
|
|||||||
148
StructureHelper/Windows/Graphs/Series.cs
Normal file
148
StructureHelper/Windows/Graphs/Series.cs
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
using LiveCharts;
|
||||||
|
using LiveCharts.Configurations;
|
||||||
|
using LiveCharts.Wpf;
|
||||||
|
using StructureHelper.Infrastructure;
|
||||||
|
using StructureHelper.Windows.ViewModels;
|
||||||
|
using StructureHelperCommon.Models.Parameters;
|
||||||
|
using StructureHelperCommon.Models.Shapes;
|
||||||
|
using StructureHelperCommon.Services.ColorServices;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
|
//All rights reserved.
|
||||||
|
|
||||||
|
namespace StructureHelper.Windows.Graphs
|
||||||
|
{
|
||||||
|
public class Series : ViewModelBase
|
||||||
|
{
|
||||||
|
private IArrayParameter<double> arrayParameter;
|
||||||
|
private List<IValueParameter<double>> valueParameters;
|
||||||
|
private Dictionary<IValueParameter<double>, double[]> valueList;
|
||||||
|
private bool invertXValues;
|
||||||
|
private bool invertYValues;
|
||||||
|
|
||||||
|
public SelectedItemViewModel<IValueParameter<double>> XItems { get; }
|
||||||
|
public SelectItemsViewModel<IValueParameter<double>> YItems { get; }
|
||||||
|
public bool InvertXValues
|
||||||
|
{
|
||||||
|
get { return invertXValues; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
invertXValues = value;
|
||||||
|
OnPropertyChanged(nameof(InvertXValues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool InvertYValues
|
||||||
|
{
|
||||||
|
get { return invertYValues; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
invertYValues = value;
|
||||||
|
OnPropertyChanged(nameof(InvertYValues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GraphVisualProps VisualProps { get; set; }
|
||||||
|
public SeriesCollection SeriesCollection { get; private set; }
|
||||||
|
public List<string> Labels { get; private set; }
|
||||||
|
public Color Color { get; private set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
public IArrayParameter<double> ArrayParameter { get; set; }
|
||||||
|
public Series(IArrayParameter<double> arrayParameter)
|
||||||
|
{
|
||||||
|
this.arrayParameter = arrayParameter;
|
||||||
|
valueParameters = GetParameters();
|
||||||
|
XItems = new SelectedItemViewModel<IValueParameter<double>>(valueParameters);
|
||||||
|
YItems = new SelectItemsViewModel<IValueParameter<double>>(valueParameters);
|
||||||
|
YItems.ShowButtons = true;
|
||||||
|
XItems.SelectedItem = XItems.Collection[0];
|
||||||
|
YItems.UnSelectAllCommand.Execute(null);
|
||||||
|
VisualProps = new();
|
||||||
|
Color = ColorProcessor.GetRandomColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<IValueParameter<double>> GetParameters()
|
||||||
|
{
|
||||||
|
valueList = new Dictionary<IValueParameter<double>, double[]>();
|
||||||
|
var items = new List<IValueParameter<double>>();
|
||||||
|
var data = arrayParameter.Data;
|
||||||
|
int columnCount = data.GetLength(1);
|
||||||
|
for (int i = 0; i < columnCount; i++)
|
||||||
|
{
|
||||||
|
var item = new ValueParameter<double>()
|
||||||
|
{
|
||||||
|
Name = arrayParameter.ColumnLabels[i],
|
||||||
|
Color = ColorProcessor.GetRandomColor(),
|
||||||
|
};
|
||||||
|
items.Add(item);
|
||||||
|
int rowCount = data.GetLength(0);
|
||||||
|
var values = new double[rowCount];
|
||||||
|
for (int j = 0; j < rowCount; j++)
|
||||||
|
{
|
||||||
|
values[j] = data[j, i];
|
||||||
|
}
|
||||||
|
valueList.Add(item, values);
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawLines()
|
||||||
|
{
|
||||||
|
if (XItems.SelectedItem is null || YItems.SelectedCount == 0) return;
|
||||||
|
RefreshSeries();
|
||||||
|
OnPropertyChanged(nameof(SeriesCollection));
|
||||||
|
OnPropertyChanged(nameof(Labels));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshSeries()
|
||||||
|
{
|
||||||
|
var xParameter = XItems.SelectedItem;
|
||||||
|
var yParameters = YItems.SelectedItems;
|
||||||
|
var xFactor = invertXValues ? -1d : 1d;
|
||||||
|
var yFactor = invertYValues ? -1d : 1d;
|
||||||
|
var labels = new List<double>();
|
||||||
|
SeriesCollection = new SeriesCollection();
|
||||||
|
foreach (var yParameter in yParameters)
|
||||||
|
{
|
||||||
|
var localLabels = new List<double>();
|
||||||
|
var lineSeries = new LineSeries()
|
||||||
|
{
|
||||||
|
Configuration = new CartesianMapper<IPoint2D>()
|
||||||
|
.X(point => point.X)
|
||||||
|
.Y(point => point.Y),
|
||||||
|
Title = yParameter.Name,
|
||||||
|
};
|
||||||
|
GraphService.SetVisualProps(lineSeries, VisualProps, yParameter.Color);
|
||||||
|
_ = valueList.TryGetValue(xParameter, out double[] xValues);
|
||||||
|
_ = valueList.TryGetValue(yParameter, out double[] yValues);
|
||||||
|
var chartValues = new ChartValues<Point2D>();
|
||||||
|
for (int i = 0; i < yValues.Count(); i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
double diagramValue = yValues[i] * yFactor;
|
||||||
|
var x = xValues[i] * xFactor;
|
||||||
|
var y = yValues[i] * yFactor;
|
||||||
|
var point = new Point2D() { X = x, Y = y };
|
||||||
|
chartValues.Add(point);
|
||||||
|
labels.Add(x);
|
||||||
|
localLabels.Add(x);
|
||||||
|
|
||||||
|
}
|
||||||
|
lineSeries.Values = chartValues;
|
||||||
|
//lineSeries.LabelPoint = point => localLabels[(int)point.X].ToString();
|
||||||
|
SeriesCollection.Add(lineSeries);
|
||||||
|
}
|
||||||
|
Labels = labels
|
||||||
|
.OrderBy(x => x)
|
||||||
|
.Distinct()
|
||||||
|
.Select(x => x.ToString())
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,5 +26,14 @@ namespace StructureHelper.Windows.ViewModels.Errors
|
|||||||
new ErrorMessage(vm).ShowDialog();
|
new ErrorMessage(vm).ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void ShowMessage(string shortText, string detailText)
|
||||||
|
{
|
||||||
|
var vm = new ErrorProcessor()
|
||||||
|
{
|
||||||
|
ShortText = shortText,
|
||||||
|
DetailText = detailText
|
||||||
|
};
|
||||||
|
new ErrorMessage(vm).ShowDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
{
|
{
|
||||||
if (predicate(end) == false)
|
if (predicate(end) == false)
|
||||||
{
|
{
|
||||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": pridicate for end value must be true");
|
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": predicate for end value must be true");
|
||||||
|
|
||||||
}
|
}
|
||||||
double precision = Accuracy.IterationAccuracy;
|
double precision = Accuracy.IterationAccuracy;
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
public double Parameter { get; set; }
|
public double Parameter { get; set; }
|
||||||
public int IterationNumber { get; set; }
|
public int IterationNumber { get; set; }
|
||||||
public double CurrentAccuracy { get; set; }
|
public double CurrentAccuracy { get; set; }
|
||||||
|
public int MaxIterationCount { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
StructureHelperCommon/Models/Calculators/IInputData.cs
Normal file
15
StructureHelperCommon/Models/Calculators/IInputData.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
|
//All rights reserved.
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Calculators
|
||||||
|
{
|
||||||
|
public interface IInputData
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
{
|
{
|
||||||
public interface IiterationResult
|
public interface IiterationResult
|
||||||
{
|
{
|
||||||
|
int MaxIterationCount { get; set; }
|
||||||
int IterationNumber { get; set; }
|
int IterationNumber { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,8 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Infrastructures\Predicates\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
|
//All rights reserved.
|
||||||
|
|
||||||
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
|
{
|
||||||
|
public class PredicateEntry
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public PredicateTypes PredicateType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,21 @@
|
|||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
using System.Linq;
|
//All rights reserved.
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
|
public enum PredicateTypes
|
||||||
|
{
|
||||||
|
Strength,
|
||||||
|
Cracking
|
||||||
|
}
|
||||||
public class PredicateFactory
|
public class PredicateFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
private ForceTupleCalculator calculator;
|
private ForceTupleCalculator calculator;
|
||||||
private ForceTuple tuple;
|
private ForceTuple tuple;
|
||||||
private ForceTupleInputData inputData;
|
private ForceTupleInputData inputData;
|
||||||
@@ -24,7 +26,23 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
inputData = new();
|
inputData = new();
|
||||||
calculator = new() { InputData = inputData };
|
calculator = new() { InputData = inputData };
|
||||||
}
|
}
|
||||||
public bool IsSectionFailure(IPoint2D point2D)
|
public Predicate<IPoint2D> GetPredicate(PredicateTypes predicateType)
|
||||||
|
{
|
||||||
|
if (predicateType == PredicateTypes.Strength)
|
||||||
|
{
|
||||||
|
return point2D => IsSectionFailure(point2D);
|
||||||
|
}
|
||||||
|
else if (predicateType == PredicateTypes.Cracking)
|
||||||
|
{
|
||||||
|
return point2D => IsSectionCracked(point2D);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(predicateType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsSectionFailure(IPoint2D point2D)
|
||||||
{
|
{
|
||||||
var point3D = ConvertLogic.GetPoint3D(point2D);
|
var point3D = ConvertLogic.GetPoint3D(point2D);
|
||||||
tuple = new()
|
tuple = new()
|
||||||
@@ -40,7 +58,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
return !result.IsValid;
|
return !result.IsValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSectionCracked(IPoint2D point2D)
|
private bool IsSectionCracked(IPoint2D point2D)
|
||||||
{
|
{
|
||||||
var logic = new HoleSectionCrackedLogic();
|
var logic = new HoleSectionCrackedLogic();
|
||||||
var point3D = ConvertLogic.GetPoint3D(point2D);
|
var point3D = ConvertLogic.GetPoint3D(point2D);
|
||||||
@@ -48,7 +66,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
{
|
{
|
||||||
Nz = point3D.Z,
|
Nz = point3D.Z,
|
||||||
Mx = point3D.X,
|
Mx = point3D.X,
|
||||||
My = point2D.Y
|
My = point3D.Y
|
||||||
};
|
};
|
||||||
logic.Tuple = tuple;
|
logic.Tuple = tuple;
|
||||||
logic.NdmCollection = Ndms;
|
logic.NdmCollection = Ndms;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
|
||||||
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
|
{
|
||||||
|
public interface ILimitCurveCalculator : ICalculator, IHasActionByResult
|
||||||
|
{
|
||||||
|
Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
SurroundData SurroundData { get; set; }
|
||||||
|
int PointCount { get; set; }
|
||||||
|
ISurroundProc SurroundProcLogic { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
public interface ISurroundProc
|
public interface ISurroundProc
|
||||||
{
|
{
|
||||||
SurroundData SurroundData { get; set; }
|
SurroundData SurroundData { get; set; }
|
||||||
|
int PointCount { get; set; }
|
||||||
List<IPoint2D> GetPoints();
|
List<IPoint2D> GetPoints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
public class LimitCurveCalculator : ICalculator, IHasActionByResult
|
public class LimitCurveCalculator : ILimitCurveCalculator
|
||||||
{
|
{
|
||||||
private LimitCurveResult result;
|
private LimitCurveResult result;
|
||||||
private List<IPoint2D> surroundList;
|
private List<IPoint2D> surroundList;
|
||||||
@@ -19,6 +19,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public SurroundData SurroundData { get; set; }
|
public SurroundData SurroundData { get; set; }
|
||||||
|
public int PointCount { get; set; }
|
||||||
public ISurroundProc SurroundProcLogic { get; set; }
|
public ISurroundProc SurroundProcLogic { get; set; }
|
||||||
|
|
||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
@@ -46,7 +47,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
{
|
{
|
||||||
result = new LimitCurveResult();
|
result = new LimitCurveResult();
|
||||||
result.IsValid = true;
|
result.IsValid = true;
|
||||||
|
result.Name = Name;
|
||||||
SurroundProcLogic.SurroundData = SurroundData;
|
SurroundProcLogic.SurroundData = SurroundData;
|
||||||
|
SurroundProcLogic.PointCount = PointCount;
|
||||||
surroundList = SurroundProcLogic.GetPoints();
|
surroundList = SurroundProcLogic.GetPoints();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Models.Shapes;
|
||||||
|
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
|
//All rights reserved.
|
||||||
|
|
||||||
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
|
||||||
|
{
|
||||||
|
public class LimitCurveInputData : IInputData
|
||||||
|
{
|
||||||
|
public List<LimitStates> LimitStates { get; }
|
||||||
|
public List<CalcTerms> CalcTerms { get; }
|
||||||
|
public List<INdmPrimitive> Primitives { get; set; }
|
||||||
|
public List<PredicateEntry> PredicateEntries { get; }
|
||||||
|
public SurroundData SurroundData { get; set; }
|
||||||
|
public int PointCount { get; set; }
|
||||||
|
public LimitCurveInputData()
|
||||||
|
{
|
||||||
|
LimitStates = new();
|
||||||
|
CalcTerms = new();
|
||||||
|
Primitives = new();
|
||||||
|
PredicateEntries = new();
|
||||||
|
SurroundData = new();
|
||||||
|
PointCount = 80;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,16 +33,49 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
var range = points.Select(point => new Point2D { X = point.X * 0d, Y = point.Y * 0d }).ToList();
|
var range = points.Select(point => new Point2D { X = point.X * 0d, Y = point.Y * 0d }).ToList();
|
||||||
resultList.AddRange(range);
|
resultList.AddRange(range);
|
||||||
return resultList;
|
return resultList;
|
||||||
//throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": predicate for zero value is not valid");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//MultyProcessPoints(points);
|
||||||
|
MonoProcessPoints(points);
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MultyProcessPoints(IEnumerable<IPoint2D> points)
|
||||||
|
{
|
||||||
|
Task<IPoint2D>[] tasks = new Task<IPoint2D>[points.Count()];
|
||||||
|
for (int i = 0; i < points.Count(); i++)
|
||||||
|
{
|
||||||
|
var point = points.ToList()[i];
|
||||||
|
tasks[i] = new Task<IPoint2D>(() => FindResultPoint(point));
|
||||||
|
tasks[i].Start();
|
||||||
|
}
|
||||||
|
Task.WaitAll(tasks);
|
||||||
|
for (int j = 0; j < points.Count(); j++)
|
||||||
|
{
|
||||||
|
var taskResult = tasks[j].Result;
|
||||||
|
resultList.Add(taskResult);
|
||||||
|
result.IterationNumber = resultList.Count;
|
||||||
|
ActionToOutputResults?.Invoke(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MonoProcessPoints(IEnumerable<IPoint2D> points)
|
||||||
|
{
|
||||||
foreach (var point in points)
|
foreach (var point in points)
|
||||||
{
|
{
|
||||||
FindParameter(point);
|
FindParameter(point);
|
||||||
}
|
}
|
||||||
return resultList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FindParameter(IPoint2D point)
|
private void FindParameter(IPoint2D point)
|
||||||
|
{
|
||||||
|
IPoint2D resultPoint = FindResultPoint(point);
|
||||||
|
resultList.Add(resultPoint);
|
||||||
|
result.IterationNumber = resultList.Count;
|
||||||
|
ActionToOutputResults?.Invoke(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D FindResultPoint(IPoint2D point)
|
||||||
{
|
{
|
||||||
double parameter;
|
double parameter;
|
||||||
currentPoint = point.Clone() as IPoint2D;
|
currentPoint = point.Clone() as IPoint2D;
|
||||||
@@ -53,16 +86,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parameter = parameterLogic.GetParameter();
|
parameter = parameterLogic.GetParameter();
|
||||||
}
|
}
|
||||||
var resultPoint = new Point2D()
|
var resultPoint = new Point2D()
|
||||||
{
|
{
|
||||||
X = currentPoint.X * parameter,
|
X = currentPoint.X * parameter,
|
||||||
Y = currentPoint.Y * parameter
|
Y = currentPoint.Y * parameter
|
||||||
};
|
};
|
||||||
resultList.Add(resultPoint);
|
return resultPoint;
|
||||||
result.IterationNumber = resultList.Count;
|
|
||||||
ActionToOutputResults?.Invoke(result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,19 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
|
//All rights reserved.
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
public class LimitCurveResult : IResult, IiterationResult
|
public class LimitCurveResult : IResult, IiterationResult
|
||||||
{
|
{
|
||||||
public bool IsValid { get; set; }
|
public bool IsValid { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public List<IPoint2D> Points { get; set; }
|
public List<IPoint2D> Points { get; set; }
|
||||||
public int IterationNumber { get; set; }
|
public int IterationNumber { get; set; }
|
||||||
|
public int MaxIterationCount { get; set; }
|
||||||
|
|
||||||
public LimitCurveResult()
|
public LimitCurveResult()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
using LoaderCalculator.Data.Ndms;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Shapes;
|
||||||
|
using StructureHelperLogics.Models.Calculations.CalculationsResults;
|
||||||
|
using StructureHelperLogics.Services.NdmPrimitives;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
|
//All rights reserved.
|
||||||
|
|
||||||
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
|
||||||
|
{
|
||||||
|
public class LimitCurvesCalculator : ISaveable, ICalculator, IHasActionByResult
|
||||||
|
{
|
||||||
|
private LimitCurvesResult result;
|
||||||
|
private int curvesIterationCount;
|
||||||
|
|
||||||
|
public Guid Id { get; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public LimitCurveInputData InputData { get; set; }
|
||||||
|
public IResult Result => result;
|
||||||
|
|
||||||
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
|
||||||
|
public void Run()
|
||||||
|
{
|
||||||
|
GetNewResult();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var calculators = GetCalulators();
|
||||||
|
curvesIterationCount = 0;
|
||||||
|
foreach (var item in calculators)
|
||||||
|
{
|
||||||
|
item.Run();
|
||||||
|
var locResult = item.Result as LimitCurveResult;
|
||||||
|
result.LimitCurveResults.Add(locResult);
|
||||||
|
if (locResult.IsValid == false) { result.Description += locResult.Description; }
|
||||||
|
result.IterationNumber = curvesIterationCount * InputData.PointCount + locResult.IterationNumber;
|
||||||
|
ActionToOutputResults?.Invoke(result);
|
||||||
|
curvesIterationCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.IsValid = false;
|
||||||
|
result.Description += ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetNewResult()
|
||||||
|
{
|
||||||
|
result = new()
|
||||||
|
{
|
||||||
|
IsValid = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ILimitCurveCalculator> GetCalulators()
|
||||||
|
{
|
||||||
|
List<ILimitCurveCalculator> calculators = new();
|
||||||
|
foreach (var limitState in InputData.LimitStates)
|
||||||
|
{
|
||||||
|
foreach (var calcTerm in InputData.CalcTerms)
|
||||||
|
{
|
||||||
|
var ndms = NdmPrimitivesService.GetNdms(InputData.Primitives, limitState, calcTerm);
|
||||||
|
foreach (var predicateEntry in InputData.PredicateEntries)
|
||||||
|
{
|
||||||
|
string calcName = $"{predicateEntry.Name}_{limitState}_{calcTerm}";
|
||||||
|
LimitCurveCalculator calculator = GetCalculator(ndms, predicateEntry, calcName);
|
||||||
|
calculators.Add(calculator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return calculators;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LimitCurveCalculator GetCalculator(List<INdm> ndms, PredicateEntry predicateEntry, string calcName)
|
||||||
|
{
|
||||||
|
var factory = new PredicateFactory()
|
||||||
|
{
|
||||||
|
Ndms = ndms,
|
||||||
|
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic
|
||||||
|
};
|
||||||
|
var predicateType = predicateEntry.PredicateType;
|
||||||
|
var predicate = factory.GetPredicate(predicateType);
|
||||||
|
//Predicate<IPoint2D> predicate = factory.IsSectionCracked;
|
||||||
|
var logic = new LimitCurveLogic(predicate);
|
||||||
|
//var logic = new StabLimitCurveLogic();
|
||||||
|
var calculator = new LimitCurveCalculator(logic)
|
||||||
|
{
|
||||||
|
Name = calcName,
|
||||||
|
SurroundData = InputData.SurroundData,
|
||||||
|
PointCount = InputData.PointCount,
|
||||||
|
ActionToOutputResults = SetCurveCount
|
||||||
|
};
|
||||||
|
return calculator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetCurveCount(IResult locResult)
|
||||||
|
{
|
||||||
|
var curveResult = locResult as IiterationResult;;
|
||||||
|
result.IterationNumber = curvesIterationCount * InputData.PointCount + curveResult.IterationNumber;
|
||||||
|
ActionToOutputResults?.Invoke(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
|
||||||
|
{
|
||||||
|
public class LimitCurvesResult : IResult, IiterationResult
|
||||||
|
{
|
||||||
|
public bool IsValid { get; set; }
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public List<LimitCurveResult> LimitCurveResults {get;set;}
|
||||||
|
public int MaxIterationCount { get; set; }
|
||||||
|
public int IterationNumber { get; set; }
|
||||||
|
|
||||||
|
public LimitCurvesResult()
|
||||||
|
{
|
||||||
|
LimitCurveResults = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -12,13 +13,20 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
private List<IPoint2D> surroundList;
|
private List<IPoint2D> surroundList;
|
||||||
|
|
||||||
public SurroundData SurroundData { get; set; }
|
public SurroundData SurroundData { get; set; }
|
||||||
|
public int PointCount { get; set; }
|
||||||
|
|
||||||
|
public RectSurroundProc()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public List<IPoint2D> GetPoints()
|
public List<IPoint2D> GetPoints()
|
||||||
{
|
{
|
||||||
|
CheckParameters();
|
||||||
var xRadius = (SurroundData.XMax - SurroundData.XMin) / 2;
|
var xRadius = (SurroundData.XMax - SurroundData.XMin) / 2;
|
||||||
var yRadius = (SurroundData.YMax - SurroundData.YMin) / 2;
|
var yRadius = (SurroundData.YMax - SurroundData.YMin) / 2;
|
||||||
surroundList = new();
|
surroundList = new();
|
||||||
var pointCount = Convert.ToInt32(Math.Ceiling(SurroundData.PointCount / 8d));
|
var pointCount = Convert.ToInt32(Math.Ceiling(PointCount / 8d));
|
||||||
double xStep = xRadius / pointCount;
|
double xStep = xRadius / pointCount;
|
||||||
double yStep = yRadius / pointCount;
|
double yStep = yRadius / pointCount;
|
||||||
double x, y;
|
double x, y;
|
||||||
@@ -49,5 +57,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
surroundList.Add(surroundList[0].Clone() as IPoint2D);
|
surroundList.Add(surroundList[0].Clone() as IPoint2D);
|
||||||
return surroundList;
|
return surroundList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckParameters()
|
||||||
|
{
|
||||||
|
//if (surroundList is null || surroundList.Count == 0)
|
||||||
|
//{
|
||||||
|
// throw new StructureHelperException(ErrorStrings.ParameterIsNull);
|
||||||
|
//}
|
||||||
|
if (PointCount < 12)
|
||||||
|
{
|
||||||
|
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Point count must be grater than 12, but was {PointCount}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
private List<IPoint2D> surroundList;
|
private List<IPoint2D> surroundList;
|
||||||
|
|
||||||
public SurroundData SurroundData { get; set; }
|
public SurroundData SurroundData { get; set; }
|
||||||
|
public int PointCount { get; set; }
|
||||||
|
|
||||||
public RoundSurroundProc()
|
public RoundSurroundProc()
|
||||||
{
|
{
|
||||||
SurroundData = new();
|
SurroundData = new();
|
||||||
@@ -23,7 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
var xCenter = (SurroundData.XMax + SurroundData.XMin) / 2;
|
var xCenter = (SurroundData.XMax + SurroundData.XMin) / 2;
|
||||||
var yCenter = (SurroundData.YMax + SurroundData.YMin) / 2;
|
var yCenter = (SurroundData.YMax + SurroundData.YMin) / 2;
|
||||||
surroundList = new();
|
surroundList = new();
|
||||||
var pointCount = Convert.ToInt32(Math.Ceiling(SurroundData.PointCount / 4d) * 4d);
|
var pointCount = Convert.ToInt32(Math.Ceiling(PointCount / 4d) * 4d);
|
||||||
double angleStep = 2d * Math.PI / pointCount;
|
double angleStep = 2d * Math.PI / pointCount;
|
||||||
double angle;
|
double angle;
|
||||||
for (int i = 0; i < pointCount; i++)
|
for (int i = 0; i < pointCount; i++)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
foreach (var item in points)
|
foreach (var item in points)
|
||||||
{
|
{
|
||||||
result.Add(new Point2D() { X = item.X * 0.5d, Y = item.Y * 0.5d });
|
result.Add(new Point2D() { X = item.X * 0.5d, Y = item.Y * 0.5d });
|
||||||
|
Thread.Sleep(10);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,24 +6,37 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
|
//All rights reserved.
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Limits of coordinates for workplane
|
||||||
|
/// </summary>
|
||||||
public class SurroundData
|
public class SurroundData
|
||||||
{
|
{
|
||||||
public double XMax { get; set; }
|
public double XMax { get; set; }
|
||||||
public double XMin { get; set; }
|
public double XMin { get; set; }
|
||||||
public double YMax { get; set; }
|
public double YMax { get; set; }
|
||||||
public double YMin { get; set; }
|
public double YMin { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Constant value of coordinate in direction, which is normal to specific workplane
|
||||||
|
/// </summary>
|
||||||
public double ConstZ { get; set; }
|
public double ConstZ { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Logic for transformation of 2D worplane to 3D space
|
||||||
|
/// </summary>
|
||||||
public ConstOneDirectionConverter ConvertLogicEntity { get; set; }
|
public ConstOneDirectionConverter ConvertLogicEntity { get; set; }
|
||||||
public int PointCount { get; set; }
|
/// <summary>
|
||||||
|
/// Returns new instance of class
|
||||||
|
/// </summary>
|
||||||
public SurroundData()
|
public SurroundData()
|
||||||
{
|
{
|
||||||
XMax = 1e7d;
|
XMax = 1e7d;
|
||||||
XMin = -1e7d;
|
XMin = -1e7d;
|
||||||
YMax = 1e7d;
|
YMax = 1e7d;
|
||||||
YMin = -1e7d;
|
YMin = -1e7d;
|
||||||
PointCount = 80;
|
|
||||||
ConvertLogicEntity = ConvertLogics.ConverterLogics[0];
|
ConvertLogicEntity = ConvertLogics.ConverterLogics[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user