From d0f3ead51fbdfadcf92b704cd3e31d58fad82bd3 Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Sun, 24 Dec 2023 20:43:45 +0500 Subject: [PATCH] Limit curve vindow was changed --- .../UI/Resources/GraphsTemplates.xaml | 2 +- StructureHelper/StructureHelper.csproj.user | 6 ++ .../ForceResultLogic/LimitCurveDataView.xaml | 53 ++++++++++----- .../LimitCurveDataViewModel.cs | 55 ++++++++++++++-- .../ForcesResultsViewModel.cs | 41 ++++++++---- .../Windows/Graphs/GraphService.cs | 10 ++- .../Windows/Services/CopyByParameterView.xaml | 62 ++++++++++++++++++ .../Services/CopyByParameterView.xaml.cs | 27 ++++++++ .../Services/CopyByParameterViewModel.cs | 13 ++++ .../ViewModels/SelectItemsViewModel.cs | 22 +++++-- .../LimitCurve/Factories/GetPredicateLogic.cs | 30 +++++++++ .../Factories/IGetPredicateLogic.cs | 9 +++ .../LimitCurve/ILimitCurveParameterLogic.cs | 3 +- .../LimitCurve/LimitCurveCalculator.cs | 4 +- .../ByForces/LimitCurve/LimitCurveLogic.cs | 64 +++++++++++++------ .../LimitCurve/LimitCurveParameterLogic.cs | 17 +++-- .../LimitCurve/LimitCurvesCalculator.cs | 16 +++-- .../Calcuators/LimitCurveLogicTest.cs | 18 ++++-- .../ViewModelTests/GraphViewModelTest.cs | 4 +- 19 files changed, 370 insertions(+), 86 deletions(-) create mode 100644 StructureHelper/Windows/Services/CopyByParameterView.xaml create mode 100644 StructureHelper/Windows/Services/CopyByParameterView.xaml.cs create mode 100644 StructureHelper/Windows/Services/CopyByParameterViewModel.cs create mode 100644 StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/GetPredicateLogic.cs create mode 100644 StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/IGetPredicateLogic.cs diff --git a/StructureHelper/Infrastructure/UI/Resources/GraphsTemplates.xaml b/StructureHelper/Infrastructure/UI/Resources/GraphsTemplates.xaml index de9dadd..af84c25 100644 --- a/StructureHelper/Infrastructure/UI/Resources/GraphsTemplates.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/GraphsTemplates.xaml @@ -15,7 +15,7 @@ - + diff --git a/StructureHelper/StructureHelper.csproj.user b/StructureHelper/StructureHelper.csproj.user index e662ca4..45632a9 100644 --- a/StructureHelper/StructureHelper.csproj.user +++ b/StructureHelper/StructureHelper.csproj.user @@ -45,6 +45,9 @@ Code + + Code + Code @@ -101,6 +104,9 @@ Designer + + Designer + Designer diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml index fe8e4dd..f909c40 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataView.xaml @@ -8,28 +8,47 @@ xmlns:fc="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews" d:DataContext ="{d:DesignInstance local:LimitCurveDataViewModel}" mc:Ignorable="d" - Title="Diagram properties" Height="320" Width="400" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> + Title="Diagram properties" Height="360" Width="400" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataViewModel.cs index e8d2f6a..8a00902 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LimitCurveDataViewModel.cs @@ -2,6 +2,9 @@ using StructureHelper.Windows.ViewModels; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Settings; +using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Parameters; using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Units; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; @@ -25,6 +28,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu //public SurroundDataViewModel SurroundDataViewModel { get; private set; } public SurroundData SurroundData { get; set; } public List Primitives { get; set; } + public SelectItemsViewModel PredicateItems { get; private set; } + public SelectItemsViewModel LimitStateItems { get; private set; } + public SelectItemsViewModel CalcTermITems { get; private set; } public int PointCount { get => pointCount; set @@ -45,9 +51,38 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu { //SurroundDataViewModel = new(surroundData); SurroundData = surroundData; + GetPredicates(); + GetLimitStates(); + GetCalcTerms(); pointCount = 80; } + private void GetCalcTerms() + { + CalcTermITems = new SelectItemsViewModel(ProgramSetting.CalcTermList.CalcTerms); + CalcTermITems.ShowButtons = true; + } + + private void GetLimitStates() + { + LimitStateItems = new SelectItemsViewModel(ProgramSetting.LimitStatesList.LimitStates); + LimitStateItems.ShowButtons = true; + } + + private void GetPredicates() + { + PredicateItems = new SelectItemsViewModel( + new List() + { + new PredicateEntry() + { Name = "Strength", PredicateType = PredicateTypes.Strength }, + new PredicateEntry() + { Name = "Cracking", PredicateType = PredicateTypes.Cracking }, + } + ); + PredicateItems.ShowButtons = true; + } + public LimitCurveDataViewModel() : this (new SurroundData()) { } @@ -59,16 +94,24 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu 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.LimitStates.AddRange(LimitStateItems.SelectedItems.Select(x => x.LimitState)); + inputData.CalcTerms.AddRange(CalcTermITems.SelectedItems.Select(x => x.CalcTerm)); + inputData.PredicateEntries.AddRange(PredicateItems.SelectedItems); inputData.Primitives = Primitives; return inputData; } + public bool Check() + { + if (PredicateItems.SelectedCount == 0 || + LimitStateItems.SelectedCount == 0 || + CalcTermITems.SelectedCount == 0) + { + return false; + } + return true; + } + public string Error => throw new NotImplementedException(); public string this[string columnName] diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs index 0cbac0d..7e220e4 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs @@ -14,6 +14,7 @@ using StructureHelper.Windows.ViewModels.Calculations.Calculators; using StructureHelper.Windows.ViewModels.Errors; using StructureHelper.Windows.ViewModels.PrimitiveProperties; using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Models.Forces; @@ -30,6 +31,7 @@ using StructureHelperLogics.Services.NdmPrimitives; using System; using System.Collections.Generic; using System.Linq; +using System.Windows; using System.Windows.Input; namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews @@ -75,23 +77,34 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu return showInteractionDiagramCommand ?? (showInteractionDiagramCommand = new RelayCommand(o => { - 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; - var inputData = vm.GetLimitCurveInputData(); - interactionDiagramLogic = new(inputData); - showProgressLogic = new(interactionDiagramLogic) - { - WindowTitle = "Diagram creating...", - ShowResult = interactionDiagramLogic.ShowWindow - }; - showProgressLogic.Show(); + ShowInteractionDiagram(); })); } } + + private void ShowInteractionDiagram() + { + var surroundDdata = new SurroundData(); + var vm = new LimitCurveDataViewModel(surroundDdata); + if (vm.Check() == false) + { + MessageBox.Show(ErrorStrings.DataIsInCorrect + ": nothing selected"); ; + return; + } + vm.Primitives = ndmPrimitives.ToList(); + var wnd = new LimitCurveDataView(vm); + wnd.ShowDialog(); + if (wnd.DialogResult != true) return; + var inputData = vm.GetLimitCurveInputData(); + interactionDiagramLogic = new(inputData); + showProgressLogic = new(interactionDiagramLogic) + { + WindowTitle = "Diagram creating...", + ShowResult = interactionDiagramLogic.ShowWindow + }; + showProgressLogic.Show(); + } + public ICommand ShowIsoFieldCommand { get diff --git a/StructureHelper/Windows/Graphs/GraphService.cs b/StructureHelper/Windows/Graphs/GraphService.cs index fbc3dad..4fcd557 100644 --- a/StructureHelper/Windows/Graphs/GraphService.cs +++ b/StructureHelper/Windows/Graphs/GraphService.cs @@ -11,17 +11,21 @@ namespace StructureHelper.Windows.Graphs { internal static class GraphService { - public static void SetVisualProps(LineSeries lineSeries, GraphVisualProps visualProps, Color color) + public static void SetVisualProps(LineSeries lineSeries, GraphVisualProps visualProps, Color lineColor) { - lineSeries.Stroke = new SolidColorBrush(color); - lineSeries.Fill = new SolidColorBrush(color) { Opacity = visualProps.Opacity }; + lineSeries.Stroke = new SolidColorBrush(lineColor); SetVisualProps(lineSeries, visualProps); + lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity }; } public static void SetVisualProps(LineSeries lineSeries, GraphVisualProps visualProps) { lineSeries.LineSmoothness = visualProps.LineSmoothness; lineSeries.PointGeometry = DefaultGeometries.Circle; lineSeries.PointGeometrySize = visualProps.StrokeSize; + Color lineColor = (lineSeries.Stroke as SolidColorBrush)?.Color ?? Colors.Black; + //lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity }; + lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity }; + } } } diff --git a/StructureHelper/Windows/Services/CopyByParameterView.xaml b/StructureHelper/Windows/Services/CopyByParameterView.xaml new file mode 100644 index 0000000..8b3b642 --- /dev/null +++ b/StructureHelper/Windows/Services/CopyByParameterView.xaml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/Services/CopyByParameterView.xaml.cs b/StructureHelper/Windows/Services/CopyByParameterView.xaml.cs new file mode 100644 index 0000000..dddb3e1 --- /dev/null +++ b/StructureHelper/Windows/Services/CopyByParameterView.xaml.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace StructureHelper.Windows.Services +{ + /// + /// Логика взаимодействия для CopyByParameterView.xaml + /// + public partial class CopyByParameterView : Window + { + public CopyByParameterView() + { + InitializeComponent(); + } + } +} diff --git a/StructureHelper/Windows/Services/CopyByParameterViewModel.cs b/StructureHelper/Windows/Services/CopyByParameterViewModel.cs new file mode 100644 index 0000000..a3a27da --- /dev/null +++ b/StructureHelper/Windows/Services/CopyByParameterViewModel.cs @@ -0,0 +1,13 @@ +using StructureHelper.Windows.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Windows.Services +{ + internal class CopyByParameterViewModel : OkCancelViewModelBase + { + } +} diff --git a/StructureHelper/Windows/ViewModels/SelectItemsViewModel.cs b/StructureHelper/Windows/ViewModels/SelectItemsViewModel.cs index 25dc64b..eb5f60f 100644 --- a/StructureHelper/Windows/ViewModels/SelectItemsViewModel.cs +++ b/StructureHelper/Windows/ViewModels/SelectItemsViewModel.cs @@ -25,7 +25,9 @@ namespace StructureHelper.Windows.ViewModels private ICommand? unSelectAllCommand; private ICommand? invertSelectionCommand; private IEnumerable selectedItems; - + /// + /// Class for item of collection + /// public class CollectionItem : ViewModelBase { bool isSelected; @@ -45,9 +47,17 @@ namespace StructureHelper.Windows.ViewModels } public DataTemplate ItemDataTemplate { get; set; } + /// + /// Turns buttons on or off + /// public bool ShowButtons { get; set; } + /// + /// Collections of items + /// public ObservableCollection CollectionItems { get; } - + /// + /// Selects all items + /// public ICommand SelectAllCommand { get @@ -55,9 +65,13 @@ namespace StructureHelper.Windows.ViewModels return selectAllCommand ??= new RelayCommand(o => SetIsSelected(true)); } } - + /// + /// Deselects all items + /// public ICommand UnSelectAllCommand => unSelectAllCommand ??= new RelayCommand(o => SetIsSelected(false)); - + /// + /// Reverts selection of item from on to off + /// public ICommand InvertSelectionCommand { get diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/GetPredicateLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/GetPredicateLogic.cs new file mode 100644 index 0000000..a9419a3 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/GetPredicateLogic.cs @@ -0,0 +1,30 @@ +using LoaderCalculator.Data.Ndms; +using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories +{ + public class GetPredicateLogic : IGetPredicateLogic + { + public IEnumerable Ndms { get; set; } + public PredicateTypes PredicateType { get; set; } + public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; } + + public Predicate GetPredicate() + { + var factory = new PredicateFactory() + { + Ndms = Ndms, + ConvertLogic = ConvertLogic + }; + var predicateType = PredicateType; + var predicate = factory.GetPredicate(predicateType); + return predicate; + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/IGetPredicateLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/IGetPredicateLogic.cs new file mode 100644 index 0000000..3bab380 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/IGetPredicateLogic.cs @@ -0,0 +1,9 @@ +using StructureHelperCommon.Models.Shapes; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories +{ + public interface IGetPredicateLogic + { + Predicate GetPredicate(); + } +} \ No newline at end of file diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveParameterLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveParameterLogic.cs index bec00db..e1b6603 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveParameterLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveParameterLogic.cs @@ -8,8 +8,9 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { - public interface ILimitCurveParameterLogic : IHasActionByResult + public interface ILimitCurveParameterLogic : IHasActionByResult, ICloneable { + Predicate LimitPredicate { get; set; } IPoint2D CurrentPoint { get; set; } double GetParameter(); } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveCalculator.cs index a80cbf8..5e5ef24 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveCalculator.cs @@ -33,8 +33,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces SurroundProcLogic = new RectSurroundProc(); } - public LimitCurveCalculator(Predicate limitPredicate) - : this(new LimitCurveLogic(limitPredicate)) + public LimitCurveCalculator(ILimitCurveParameterLogic parameterLogic) + : this(new LimitCurveLogic(parameterLogic)) { } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs index 3ee7f68..240d21f 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs @@ -1,5 +1,6 @@ using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories; //Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia //All rights reserved. @@ -10,37 +11,41 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { private FindParameterResult result; private List resultList; - private IPoint2D currentPoint; - private ILimitCurveParameterLogic parameterLogic; - public Predicate LimitPredicate { get; set; } + private int pointCount; + public ILimitCurveParameterLogic ParameterLogic { get; set; } + public IGetPredicateLogic GetPredicateLogic { get; private set; } + + private object lockObject = new object(); public Action ActionToOutputResults { get; set; } public LimitCurveLogic(ILimitCurveParameterLogic parameterLogic) { - this.parameterLogic = parameterLogic; + ParameterLogic = parameterLogic; } - public LimitCurveLogic(Predicate limitPredicate) : this (new LimitCurveParameterLogic(limitPredicate)) + public LimitCurveLogic(IGetPredicateLogic getPredicateLogic) { - LimitPredicate = limitPredicate; + ParameterLogic = new LimitCurveParameterLogic(); + GetPredicateLogic = getPredicateLogic; } /// public List GetPoints(IEnumerable points) { result = new(); resultList = new(); - if (LimitPredicate(new Point2D()) == true) + Predicate limitPredicate = GetPredicateLogic.GetPredicate(); + if (limitPredicate(new Point2D()) == true) { var range = points.Select(point => new Point2D { X = point.X * 0d, Y = point.Y * 0d }).ToList(); resultList.AddRange(range); return resultList; } - - //MultyProcessPoints(points); - MonoProcessPoints(points); + pointCount = 0; + MultyThreadProc(points); + //MonoThreadProc(points); return resultList; } - private void MultyProcessPoints(IEnumerable points) + private void MultyThreadProc(IEnumerable points) { Task[] tasks = new Task[points.Count()]; for (int i = 0; i < points.Count(); i++) @@ -54,12 +59,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { var taskResult = tasks[j].Result; resultList.Add(taskResult); - result.IterationNumber = resultList.Count; ActionToOutputResults?.Invoke(result); } } - private void MonoProcessPoints(IEnumerable points) + private void MonoThreadProc(IEnumerable points) { foreach (var point in points) { @@ -71,29 +75,49 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { IPoint2D resultPoint = FindResultPoint(point); resultList.Add(resultPoint); - result.IterationNumber = resultList.Count; + lock (lockObject) + { + pointCount++; + } + result.IterationNumber = pointCount; ActionToOutputResults?.Invoke(result); } private Point2D FindResultPoint(IPoint2D point) { double parameter; - currentPoint = point.Clone() as IPoint2D; - parameterLogic.CurrentPoint = currentPoint; - if (LimitPredicate(point) == false) + var locCurrentPoint = point.Clone() as IPoint2D; + Predicate limitPredicate; + lock (lockObject) + { + limitPredicate = GetPredicateLogic.GetPredicate(); + } + var logic = ParameterLogic.Clone() as ILimitCurveParameterLogic; + logic.CurrentPoint = locCurrentPoint; + logic.LimitPredicate = limitPredicate; + + if (limitPredicate(locCurrentPoint) == false) { parameter = 1d; } else { - parameter = parameterLogic.GetParameter(); + parameter = logic.GetParameter(); } + var resultPoint = new Point2D() { - X = currentPoint.X * parameter, - Y = currentPoint.Y * parameter + X = locCurrentPoint.X * parameter, + Y = locCurrentPoint.Y * parameter }; + lock (lockObject) + { + pointCount++; + } + result.IterationNumber = pointCount; + ActionToOutputResults?.Invoke(result); return resultPoint; + //} } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveParameterLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveParameterLogic.cs index b9eb182..7ca9727 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveParameterLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveParameterLogic.cs @@ -12,13 +12,13 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces public class LimitCurveParameterLogic : ILimitCurveParameterLogic { private FindParameterResult result; - private Predicate limitPredicate; + public Predicate LimitPredicate { get; set; } public IPoint2D CurrentPoint { get; set; } public Action ActionToOutputResults { get; set; } - public LimitCurveParameterLogic(Predicate limitPredicate) + public LimitCurveParameterLogic() { - this.limitPredicate = limitPredicate; + } public double GetParameter() @@ -49,7 +49,16 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces private bool GetFactorPredicate(double factor) { var newPoint = new Point2D() { X = CurrentPoint.X * factor, Y = CurrentPoint.Y * factor }; - return limitPredicate(newPoint); + return LimitPredicate(newPoint); + } + + public object Clone() + { + var newItem = new LimitCurveParameterLogic(); + newItem.LimitPredicate = LimitPredicate; + newItem.CurrentPoint = (CurrentPoint ?? new Point2D()).Clone() as IPoint2D; + newItem.ActionToOutputResults = ActionToOutputResults; + return newItem; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs index 74e90f2..122e56c 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs @@ -3,6 +3,7 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.Calculations.CalculationsResults; +using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories; using StructureHelperLogics.Services.NdmPrimitives; using System; using System.Collections.Generic; @@ -71,7 +72,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve foreach (var predicateEntry in InputData.PredicateEntries) { string calcName = $"{predicateEntry.Name}_{limitState}_{calcTerm}"; - LimitCurveCalculator calculator = GetCalculator(ndms, predicateEntry, calcName); + LimitCurveCalculator calculator = GetCalculator(ndms, predicateEntry.PredicateType, calcName); calculators.Add(calculator); } } @@ -79,18 +80,21 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve return calculators; } - private LimitCurveCalculator GetCalculator(List ndms, PredicateEntry predicateEntry, string calcName) + private LimitCurveCalculator GetCalculator(List ndms, PredicateTypes predicateType, string calcName) { var factory = new PredicateFactory() { Ndms = ndms, ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic }; - var predicateType = predicateEntry.PredicateType; var predicate = factory.GetPredicate(predicateType); - //Predicate predicate = factory.IsSectionCracked; - var logic = new LimitCurveLogic(predicate); - //var logic = new StabLimitCurveLogic(); + var getPredicateLogic = new GetPredicateLogic() + { + Ndms = ndms, + ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic, + PredicateType = predicateType + }; + var logic = new LimitCurveLogic(getPredicateLogic); var calculator = new LimitCurveCalculator(logic) { Name = calcName, diff --git a/StructureHelperTests/UnitTests/Calcuators/LimitCurveLogicTest.cs b/StructureHelperTests/UnitTests/Calcuators/LimitCurveLogicTest.cs index 9430a33..d8c294a 100644 --- a/StructureHelperTests/UnitTests/Calcuators/LimitCurveLogicTest.cs +++ b/StructureHelperTests/UnitTests/Calcuators/LimitCurveLogicTest.cs @@ -3,6 +3,7 @@ using NUnit.Framework; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories; namespace StructureHelperTests.UnitTests.Calcuators { @@ -16,8 +17,11 @@ namespace StructureHelperTests.UnitTests.Calcuators var parameterLogicMock = new Mock(); parameterLogicMock.Setup(p => p.GetParameter()).Returns(2.0); // Mocking the GetParameter method - var limitCurveLogic = new LimitCurveLogic(parameterLogicMock.Object); - limitCurveLogic.LimitPredicate = point => point.X >= 0.5d; // Example predicate + var getPredicateLogic = new Mock(); + getPredicateLogic.Setup(p => p.GetPredicate()).Returns(point => point.X >= 0.5d);// + + var limitCurveLogic = new LimitCurveLogic(getPredicateLogic.Object); + var inputPoints = new List { @@ -35,8 +39,8 @@ namespace StructureHelperTests.UnitTests.Calcuators for (int i = 0; i < inputPoints.Count; i++) { - Assert.AreEqual(inputPoints[i].X * 2.0, result[i].X); - Assert.AreEqual(inputPoints[i].Y * 2.0, result[i].Y); + Assert.AreEqual(inputPoints[i].X * 0.5, result[i].X); + Assert.AreEqual(inputPoints[i].Y * 0.5, result[i].Y); } // Verify that GetParameter was called @@ -50,8 +54,10 @@ namespace StructureHelperTests.UnitTests.Calcuators var parameterLogicMock = new Mock(); parameterLogicMock.Setup(p => p.GetParameter()).Returns(2.0); - var limitCurveLogic = new LimitCurveLogic(parameterLogicMock.Object); - limitCurveLogic.LimitPredicate = point => true; // Invalid predicate + var getPredicateLogic = new Mock(); + getPredicateLogic.Setup(p => p.GetPredicate()).Returns(point => point.X >= 0.5d);// + + var limitCurveLogic = new LimitCurveLogic(getPredicateLogic.Object); var inputPoints = new List { diff --git a/StructureHelperTests/ViewModelTests/GraphViewModelTest.cs b/StructureHelperTests/ViewModelTests/GraphViewModelTest.cs index 34894a4..bbce154 100644 --- a/StructureHelperTests/ViewModelTests/GraphViewModelTest.cs +++ b/StructureHelperTests/ViewModelTests/GraphViewModelTest.cs @@ -29,8 +29,8 @@ namespace StructureHelperTests.ViewModelTests var vm = new GraphViewModel(array); //Assert Assert.IsNotNull(vm); - Assert.AreEqual(columnCount, vm.XItems.Collection.Count()); - Assert.AreEqual(columnCount, vm.YItems.CollectionItems.Count()); + Assert.AreEqual(columnCount, vm.Series[0].XItems.Collection.Count()); + Assert.AreEqual(columnCount, vm.Series[0].YItems.CollectionItems.Count()); } } }