diff --git a/StructureHelper/StructureHelper.csproj b/StructureHelper/StructureHelper.csproj index ee00776..a5adeb8 100644 --- a/StructureHelper/StructureHelper.csproj +++ b/StructureHelper/StructureHelper.csproj @@ -86,7 +86,6 @@ - diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs index d5fdd90..2520d47 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs @@ -73,7 +73,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews { SafetyProcessor.RunSafeProcess(() => { - var wnd = new GraphView(arrayParameter); + var series = new Series(arrayParameter) { Name = "Forces and curvatures" }; + var vm = new GraphViewModel(new List() { series }); + var wnd = new GraphView(vm); wnd.ShowDialog(); }, "Errors appeared during showing a graph, see detailed information"); diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs index 1f8e896..348636d 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs @@ -9,6 +9,7 @@ using StructureHelperCommon.Models.Parameters; using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Units; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve; using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.Services.NdmPrimitives; using System; @@ -17,6 +18,9 @@ using System.ComponentModel; using System.Linq; using System.Windows; +//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia +//All rights reserved. + namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews { internal class InteractionDiagramLogic : ILongProcessLogic @@ -24,46 +28,36 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu const string ForceUnitString = "kN"; const string MomentUnitString = "kNm"; - private ArrayParameter arrayParameter; + //private List> arrayParameters; private IResult result; private IUnit unitForce = CommonOperation.GetUnit(UnitTypes.Force, ForceUnitString); private IUnit unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, MomentUnitString); + private int stepCount; private static GeometryNames GeometryNames => ProgramSetting.GeometryNames; - - public int StepCount => SurroundData.PointCount; + public LimitCurveInputData InputData { get; set; } + public int StepCount { get => stepCount; set => stepCount = value; } public Action SetProgress { get; set; } public bool Result { get; set; } - public IEnumerable NdmPrimitives { get; set; } - public LimitStates LimitState { get; set; } - public CalcTerms CalcTerm { get; set; } - //public ForceTuple ForceTuple { get; set; } - - public SurroundData SurroundData { get; set; } - - public InteractionDiagramLogic(SurroundData surroundData) + public InteractionDiagramLogic(LimitCurveInputData inputData) { - SurroundData = surroundData; + InputData = inputData; + stepCount = InputData.PointCount; + stepCount *= InputData.LimitStates.Count(); + stepCount *= InputData.CalcTerms.Count(); + stepCount *= InputData.PredicateEntries.Count(); + //arrayParameters = new(); } private void DoCalculations() { - var ndmCollection = NdmPrimitivesService.GetNdms(NdmPrimitives, LimitState, CalcTerm); - var convertLogic = SurroundData.ConvertLogicEntity; - convertLogic.ConstDirectionValue = SurroundData.ConstZ; - var predicateFactory = new PredicateFactory() + var convertLogic = InputData.SurroundData.ConvertLogicEntity; + var calculator = new LimitCurvesCalculator() { - Ndms = ndmCollection, - ConvertLogic = convertLogic.ConvertLogic, + InputData = InputData }; - Predicate predicate = predicateFactory.IsSectionFailure; - //Predicate predicate = predicateFactory.IsSectionCracked; - //var logic = new StabLimitCurveLogic(); - var logic = new LimitCurveLogic(predicate); - var calculator = new LimitCurveCalculator(logic); - calculator.SurroundData = SurroundData; calculator.ActionToOutputResults = SetProgressByResult; SafetyProcessor.RunSafeProcess(() => { @@ -71,15 +65,34 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu }, "Errors appeared during showing a graph, see detailed information"); } - private void CalcResult(LimitCurveCalculator calculator) + private void CalcResult(LimitCurvesCalculator calculator) { calculator.Run(); - result = calculator.Result; - if (result.IsValid == false) { return; } - var interactionResult = result as LimitCurveResult; + var curvesResult = calculator.Result as LimitCurvesResult; + if (curvesResult.IsValid == false) { return; } + 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 GetParametersByCurveResult(LimitCurveResult curveResult) + { string[] labels = GetLabels(); - var items = interactionResult.Points; - arrayParameter = new ArrayParameter(items.Count(), labels.Count(), labels); + var items = curveResult.Points; + var arrayParameter = new ArrayParameter(items.Count(), labels.Count(), labels); var data = arrayParameter.Data; for (int i = 0; i < items.Count(); i++) { @@ -94,23 +107,25 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu data[i, j] = valueList[j]; } } + return arrayParameter; } 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); } private string[] GetLabels() { string[] strings = new string[2]; - strings[0] = GetLabel(SurroundData.ConvertLogicEntity.XForceType); - strings[1] = GetLabel(SurroundData.ConvertLogicEntity.YForceType); + strings[0] = GetLabel(InputData.SurroundData.ConvertLogicEntity.XForceType); + strings[1] = GetLabel(InputData.SurroundData.ConvertLogicEntity.YForceType); return strings; } @@ -141,7 +156,15 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu { if (result.IsValid == true) { - var wnd = new GraphView(arrayParameter); + var curveResult = result as LimitCurvesResult; + var seriesList = new List(); + 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(); } else diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml index 86fc3aa..fe8e4dd 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml @@ -13,9 +13,23 @@ + + + + + + + + + + + + + + - + diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml.cs index d14f3b0..5aed1a6 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml.cs @@ -31,5 +31,16 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu InitializeComponent(); 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; + } } } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataViewModel.cs index 8605a33..e8d2f6a 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataViewModel.cs @@ -6,6 +6,7 @@ using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Units; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve; +using StructureHelperLogics.NdmCalculations.Primitives; using System; using System.Collections.Generic; using System.ComponentModel; @@ -17,16 +18,75 @@ using System.Windows.Data; 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 SurroundData SurroundData { get; set; } + public List Primitives { get; set; } + public int PointCount + { + get => pointCount; set + { + try + { + pointCount = value; + } + catch (Exception) + { + pointCount = 40; + } + OnPropertyChanged(nameof(PointCount)); + } + } public LimitCurveDataViewModel(SurroundData surroundData) { //SurroundDataViewModel = new(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; + } + } } } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs index 2bd33b3..3d146d9 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs @@ -47,7 +47,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu { SafetyProcessor.RunSafeProcess(() => { - var wnd = new GraphView(arrayParameter); + var series = new Series(arrayParameter) { Name = "Forces and curvatures" }; + var vm = new GraphViewModel(new List() { series}); + var wnd = new GraphView(vm); wnd.ShowDialog(); }, "Errors appeared during showing a graph, see detailed information"); diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowProgressLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowProgressLogic.cs index 1d73543..ecf5414 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowProgressLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowProgressLogic.cs @@ -46,6 +46,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu public void ShowProgressResult(int progressValue) { + progressViewModel.MaxValue = processLogic.StepCount; progressViewModel.ProgressValue = progressValue; } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs index cc873a7..0cbac0d 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs @@ -21,6 +21,7 @@ using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Forces; using StructureHelperLogics.NdmCalculations.Analyses; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics; using StructureHelperLogics.NdmCalculations.Analyses.Geometry; using StructureHelperLogics.NdmCalculations.Primitives; @@ -74,26 +75,21 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu return showInteractionDiagramCommand ?? (showInteractionDiagramCommand = new RelayCommand(o => { - var tuple = SelectedResult.DesignForceTuple.ForceTuple.Clone() as ForceTuple; - var data = new SurroundData(); - //data.ConstZ = tuple.My; - var wnd = new LimitCurveDataView(data); + var surroundDdata = new SurroundData(); + var vm = new LimitCurveDataViewModel(surroundDdata); + vm.Primitives = ndmPrimitives.ToList(); + var wnd = new LimitCurveDataView(vm); wnd.ShowDialog(); if (wnd.DialogResult != true) return; - interactionDiagramLogic = new(data) - { - //ForceTuple = tuple, - LimitState = SelectedResult.DesignForceTuple.LimitState, - CalcTerm = SelectedResult.DesignForceTuple.CalcTerm, - NdmPrimitives = ndmPrimitives - }; + var inputData = vm.GetLimitCurveInputData(); + interactionDiagramLogic = new(inputData); showProgressLogic = new(interactionDiagramLogic) { WindowTitle = "Diagram creating...", ShowResult = interactionDiagramLogic.ShowWindow }; showProgressLogic.Show(); - }, o => SelectedResult != null && SelectedResult.IsValid)); + })); } } public ICommand ShowIsoFieldCommand @@ -160,7 +156,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu }; showProgressLogic.Show(); } - } + }, o => SelectedResult != null && SelectedResult.IsValid ); } public ICommand ShowCrackGraphsCommand @@ -191,7 +187,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu }; showProgressLogic.Show(); } - } + }, o => SelectedResult != null && SelectedResult.IsValid ); } public ICommand ShowCrackResultCommand diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataControl.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataControl.xaml index 99606ea..8be3f3f 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataControl.xaml +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataControl.xaml @@ -87,17 +87,6 @@ - - - - - - - - - - - diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataControl.xaml.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataControl.xaml.cs index 2f53e31..af71278 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataControl.xaml.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataControl.xaml.cs @@ -59,7 +59,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu { if (SurroundData is null) { - ViewModel = new SurroundDataViewModel(new() { PointCount = 40 }); + ViewModel = new SurroundDataViewModel(new()); } else { @@ -90,10 +90,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu { ViewModel.ConstZ *= ChangeValue(sender); } - private void PointCountChanged(object sender, EventArgs e) - { - ViewModel.PointCount = Convert.ToInt32(ViewModel.PointCount * ChangeValue(sender)); - } + private double ChangeValue(object sender) { diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs index 9f5209f..79ab546 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs @@ -39,7 +39,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu OnPropertyChanged(nameof(YMax)); OnPropertyChanged(nameof(YMin)); OnPropertyChanged(nameof(ConstZ)); - OnPropertyChanged(nameof(PointCount)); OnPropertyChanged(nameof(XLabel)); OnPropertyChanged(nameof(YLabel)); 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 this[string columnName] @@ -187,12 +170,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu string error = String.Empty; switch (columnName) { - case nameof(PointCount): - if (PointCount < 24) - { - error = "Point count must be greater than 24"; - } - break; + //case nameof(PointCount): + // if (PointCount < 24) + // { + // error = "Point count must be greater than 24"; + // } + // break; } return error; } diff --git a/StructureHelper/Windows/Graphs/GraphService.cs b/StructureHelper/Windows/Graphs/GraphService.cs index e22cff4..fbc3dad 100644 --- a/StructureHelper/Windows/Graphs/GraphService.cs +++ b/StructureHelper/Windows/Graphs/GraphService.cs @@ -15,6 +15,10 @@ namespace StructureHelper.Windows.Graphs { lineSeries.Stroke = new SolidColorBrush(color); lineSeries.Fill = new SolidColorBrush(color) { Opacity = visualProps.Opacity }; + SetVisualProps(lineSeries, visualProps); + } + public static void SetVisualProps(LineSeries lineSeries, GraphVisualProps visualProps) + { lineSeries.LineSmoothness = visualProps.LineSmoothness; lineSeries.PointGeometry = DefaultGeometries.Circle; lineSeries.PointGeometrySize = visualProps.StrokeSize; diff --git a/StructureHelper/Windows/Graphs/GraphView.xaml b/StructureHelper/Windows/Graphs/GraphView.xaml index 5e7d75a..e1e49bd 100644 --- a/StructureHelper/Windows/Graphs/GraphView.xaml +++ b/StructureHelper/Windows/Graphs/GraphView.xaml @@ -24,51 +24,60 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + +