Limit curve vindow was changed
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
</StackPanel>
|
||||
<TextBlock Text="Filling opacity" Margin="0,5,0,5"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Slider x:Name="OpacitySlider" Width="195" Minimum="0" Maximum="1" Value="{Binding Opacity}"/>
|
||||
<Slider x:Name="OpacitySlider" Width="195" Minimum="0" Maximum="1" Value="{Binding Opacity}" TickFrequency="0.05" />
|
||||
<TextBox Width="40" Text="{Binding Opacity,Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
<Compile Update="Windows\PrimitiveTemplates\RCs\Beams\CircleView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\Services\CopyByParameterView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\UserControls\MultiplyDouble.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -101,6 +104,9 @@
|
||||
<Page Update="Windows\PrimitiveTemplates\RCs\Beams\CircleView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\Services\CopyByParameterView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\UserControls\MultiplyDouble.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
|
||||
@@ -8,11 +8,18 @@
|
||||
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">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
|
||||
<RowDefinition Height="35"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TabControl>
|
||||
<TabItem Header="Limits">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="35"/>
|
||||
</Grid.RowDefinitions>
|
||||
<fc:SurroundDataControl x:Name="SurData" SurroundData="{Binding SurroundData}"/>
|
||||
@@ -29,7 +36,19 @@
|
||||
<TextBox Grid.Column="1" Text="{Binding PointCount, ValidatesOnDataErrors=True}"/>
|
||||
<uc:MultiplyDouble Margin="2" Grid.Column="3" ValueChanged="PointCountChanged"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Predicates">
|
||||
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding PredicateItems}"/>
|
||||
</TabItem>
|
||||
<TabItem Header="States">
|
||||
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding LimitStateItems}"/>
|
||||
</TabItem>
|
||||
<TabItem Header="Terms">
|
||||
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding CalcTermITems}"/>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<!--<ContentControl ContentTemplate="{StaticResource SurroundData}" Content="{Binding SurroundDataViewModel}"/>-->
|
||||
<ContentControl Grid.Row="2" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -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<INdmPrimitive> Primitives { get; set; }
|
||||
public SelectItemsViewModel<PredicateEntry> PredicateItems { get; private set; }
|
||||
public SelectItemsViewModel<LimitStateEntity> LimitStateItems { get; private set; }
|
||||
public SelectItemsViewModel<CalcTermEntity> 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<CalcTermEntity>(ProgramSetting.CalcTermList.CalcTerms);
|
||||
CalcTermITems.ShowButtons = true;
|
||||
}
|
||||
|
||||
private void GetLimitStates()
|
||||
{
|
||||
LimitStateItems = new SelectItemsViewModel<LimitStateEntity>(ProgramSetting.LimitStatesList.LimitStates);
|
||||
LimitStateItems.ShowButtons = true;
|
||||
}
|
||||
|
||||
private void GetPredicates()
|
||||
{
|
||||
PredicateItems = new SelectItemsViewModel<PredicateEntry>(
|
||||
new List<PredicateEntry>()
|
||||
{
|
||||
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]
|
||||
|
||||
@@ -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
|
||||
@@ -74,9 +76,21 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
{
|
||||
return showInteractionDiagramCommand ??
|
||||
(showInteractionDiagramCommand = new RelayCommand(o =>
|
||||
{
|
||||
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();
|
||||
@@ -89,9 +103,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
ShowResult = interactionDiagramLogic.ShowWindow
|
||||
};
|
||||
showProgressLogic.Show();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand ShowIsoFieldCommand
|
||||
{
|
||||
get
|
||||
|
||||
@@ -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 };
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
62
StructureHelper/Windows/Services/CopyByParameterView.xaml
Normal file
62
StructureHelper/Windows/Services/CopyByParameterView.xaml
Normal file
@@ -0,0 +1,62 @@
|
||||
<Window x:Class="StructureHelper.Windows.Services.CopyByParameterView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.Services"
|
||||
d:DataContext ="{d:DesignInstance local:CopyByParameterViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="Copy To" Height="260" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterOwner">
|
||||
<Window.Resources>
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Margin" Value="2"/>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="35"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel>
|
||||
<GroupBox Header="Coordinates">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="160"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Delta X"/>
|
||||
<TextBlock Grid.Row="1" Text="Delta Y"/>
|
||||
<TextBlock Grid.Row="2" Text="Angle"/>
|
||||
<TextBlock Grid.Row="3" Text="Distance"/>
|
||||
<TextBox Grid.Column="1" Text=""/>
|
||||
<TextBox Grid.Column="1" Grid.Row="1" Text=""/>
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Text="" IsEnabled="False"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="3" Text="" IsEnabled="False"/>
|
||||
<CheckBox Grid.Row="4" Content="Relative coordinates"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Copy count">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="160"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="27"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Grid.Column="1" Text=""/>
|
||||
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
27
StructureHelper/Windows/Services/CopyByParameterView.xaml.cs
Normal file
27
StructureHelper/Windows/Services/CopyByParameterView.xaml.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для CopyByParameterView.xaml
|
||||
/// </summary>
|
||||
public partial class CopyByParameterView : Window
|
||||
{
|
||||
public CopyByParameterView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
13
StructureHelper/Windows/Services/CopyByParameterViewModel.cs
Normal file
13
StructureHelper/Windows/Services/CopyByParameterViewModel.cs
Normal file
@@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,9 @@ namespace StructureHelper.Windows.ViewModels
|
||||
private ICommand? unSelectAllCommand;
|
||||
private ICommand? invertSelectionCommand;
|
||||
private IEnumerable<TItem> selectedItems;
|
||||
|
||||
/// <summary>
|
||||
/// Class for item of collection
|
||||
/// </summary>
|
||||
public class CollectionItem : ViewModelBase
|
||||
{
|
||||
bool isSelected;
|
||||
@@ -45,9 +47,17 @@ namespace StructureHelper.Windows.ViewModels
|
||||
}
|
||||
|
||||
public DataTemplate ItemDataTemplate { get; set; }
|
||||
/// <summary>
|
||||
/// Turns buttons on or off
|
||||
/// </summary>
|
||||
public bool ShowButtons { get; set; }
|
||||
/// <summary>
|
||||
/// Collections of items
|
||||
/// </summary>
|
||||
public ObservableCollection<CollectionItem> CollectionItems { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Selects all items
|
||||
/// </summary>
|
||||
public ICommand SelectAllCommand
|
||||
{
|
||||
get
|
||||
@@ -55,9 +65,13 @@ namespace StructureHelper.Windows.ViewModels
|
||||
return selectAllCommand ??= new RelayCommand(o => SetIsSelected(true));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deselects all items
|
||||
/// </summary>
|
||||
public ICommand UnSelectAllCommand => unSelectAllCommand ??= new RelayCommand(o => SetIsSelected(false));
|
||||
|
||||
/// <summary>
|
||||
/// Reverts selection of item from on to off
|
||||
/// </summary>
|
||||
public ICommand InvertSelectionCommand
|
||||
{
|
||||
get
|
||||
|
||||
@@ -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<INdm> Ndms { get; set; }
|
||||
public PredicateTypes PredicateType { get; set; }
|
||||
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
|
||||
|
||||
public Predicate<IPoint2D> GetPredicate()
|
||||
{
|
||||
var factory = new PredicateFactory()
|
||||
{
|
||||
Ndms = Ndms,
|
||||
ConvertLogic = ConvertLogic
|
||||
};
|
||||
var predicateType = PredicateType;
|
||||
var predicate = factory.GetPredicate(predicateType);
|
||||
return predicate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
||||
{
|
||||
public interface IGetPredicateLogic
|
||||
{
|
||||
Predicate<IPoint2D> GetPredicate();
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
public interface ILimitCurveParameterLogic : IHasActionByResult
|
||||
public interface ILimitCurveParameterLogic : IHasActionByResult, ICloneable
|
||||
{
|
||||
Predicate<Point2D> LimitPredicate { get; set; }
|
||||
IPoint2D CurrentPoint { get; set; }
|
||||
double GetParameter();
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
SurroundProcLogic = new RectSurroundProc();
|
||||
}
|
||||
|
||||
public LimitCurveCalculator(Predicate<IPoint2D> limitPredicate)
|
||||
: this(new LimitCurveLogic(limitPredicate))
|
||||
public LimitCurveCalculator(ILimitCurveParameterLogic parameterLogic)
|
||||
: this(new LimitCurveLogic(parameterLogic))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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<IPoint2D> resultList;
|
||||
private IPoint2D currentPoint;
|
||||
private ILimitCurveParameterLogic parameterLogic;
|
||||
public Predicate<IPoint2D> LimitPredicate { get; set; }
|
||||
private int pointCount;
|
||||
public ILimitCurveParameterLogic ParameterLogic { get; set; }
|
||||
public IGetPredicateLogic GetPredicateLogic { get; private set; }
|
||||
|
||||
private object lockObject = new object();
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
|
||||
public LimitCurveLogic(ILimitCurveParameterLogic parameterLogic)
|
||||
{
|
||||
this.parameterLogic = parameterLogic;
|
||||
ParameterLogic = parameterLogic;
|
||||
}
|
||||
public LimitCurveLogic(Predicate<IPoint2D> limitPredicate) : this (new LimitCurveParameterLogic(limitPredicate))
|
||||
public LimitCurveLogic(IGetPredicateLogic getPredicateLogic)
|
||||
{
|
||||
LimitPredicate = limitPredicate;
|
||||
ParameterLogic = new LimitCurveParameterLogic();
|
||||
GetPredicateLogic = getPredicateLogic;
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
result = new();
|
||||
resultList = new();
|
||||
if (LimitPredicate(new Point2D()) == true)
|
||||
Predicate<IPoint2D> 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<IPoint2D> points)
|
||||
private void MultyThreadProc(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
Task<IPoint2D>[] tasks = new Task<IPoint2D>[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<IPoint2D> points)
|
||||
private void MonoThreadProc(IEnumerable<IPoint2D> 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<IPoint2D> 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;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public class LimitCurveParameterLogic : ILimitCurveParameterLogic
|
||||
{
|
||||
private FindParameterResult result;
|
||||
private Predicate<Point2D> limitPredicate;
|
||||
public Predicate<Point2D> LimitPredicate { get; set; }
|
||||
public IPoint2D CurrentPoint { get; set; }
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
|
||||
public LimitCurveParameterLogic(Predicate<Point2D> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<INdm> ndms, PredicateEntry predicateEntry, string calcName)
|
||||
private LimitCurveCalculator GetCalculator(List<INdm> 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<IPoint2D> 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,
|
||||
|
||||
@@ -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<ILimitCurveParameterLogic>();
|
||||
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<IGetPredicateLogic>();
|
||||
getPredicateLogic.Setup(p => p.GetPredicate()).Returns(point => point.X >= 0.5d);//
|
||||
|
||||
var limitCurveLogic = new LimitCurveLogic(getPredicateLogic.Object);
|
||||
|
||||
|
||||
var inputPoints = new List<IPoint2D>
|
||||
{
|
||||
@@ -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<ILimitCurveParameterLogic>();
|
||||
parameterLogicMock.Setup(p => p.GetParameter()).Returns(2.0);
|
||||
|
||||
var limitCurveLogic = new LimitCurveLogic(parameterLogicMock.Object);
|
||||
limitCurveLogic.LimitPredicate = point => true; // Invalid predicate
|
||||
var getPredicateLogic = new Mock<IGetPredicateLogic>();
|
||||
getPredicateLogic.Setup(p => p.GetPredicate()).Returns(point => point.X >= 0.5d);//
|
||||
|
||||
var limitCurveLogic = new LimitCurveLogic(getPredicateLogic.Object);
|
||||
|
||||
var inputPoints = new List<IPoint2D>
|
||||
{
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user