LimitCarveCalculator Edit Window was changed

This commit is contained in:
Evgeny Redikultsev
2024-01-21 14:21:38 +05:00
parent 3a1cf5fa71
commit b9f13193af
27 changed files with 462 additions and 160 deletions

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.Enums
{
public enum CalculatorTypes
{
ForceCalculator,
LimitCurveCalculator,
FireCalculator
}
}

View File

@@ -0,0 +1,32 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Models.Calculators
{
internal class LimitCurveVisualCalculator : ISaveable, ICalculator
{
private LimitCurvesResult result;
public Guid Id { get; }
public string Name { get; set; }
public IResult Result => result;
public void Run()
{
throw new NotImplementedException();
}
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -33,7 +33,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public SelectItemsVM<PredicateEntry> PredicateItems { get; private set; }
public SelectItemsVM<LimitStateEntity> LimitStateItems { get; private set; }
public SelectItemsVM<CalcTermEntity> CalcTermITems { get; private set; }
public bool ShowPrimitivesTab { get; set; }
public int PointCount
{
@@ -77,8 +76,11 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public void RefreshInputData()
{
inputData.LimitStates.Clear();
inputData.LimitStates.AddRange(LimitStateItems.SelectedItems.Select(x => x.LimitState));
inputData.CalcTerms.Clear();
inputData.CalcTerms.AddRange(CalcTermITems.SelectedItems.Select(x => x.CalcTerm));
inputData.PredicateEntries.Clear();
inputData.PredicateEntries.AddRange(PredicateItems.SelectedItems);
inputData.PrimitiveSeries.Clear();
foreach (var item in PrimitiveSeries.Collection)
@@ -127,13 +129,15 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private void GetCalcTerms()
{
CalcTermITems = new SelectItemsVM<CalcTermEntity>(ProgramSetting.CalcTermList.CalcTerms);
CalcTermITems.SelectedItems = ProgramSetting.CalcTermList.CalcTerms.Where(x => inputData.CalcTerms.Contains(x.CalcTerm));
var selectedItems = ProgramSetting.CalcTermList.CalcTerms.Where(x => inputData.CalcTerms.Contains(x.CalcTerm));
CalcTermITems.SelectedItems = selectedItems;
CalcTermITems.ShowButtons = true;
}
private void GetLimitStates()
{
LimitStateItems = new SelectItemsVM<LimitStateEntity>(ProgramSetting.LimitStatesList.LimitStates);
LimitStateItems.SelectedItems = ProgramSetting.LimitStatesList.LimitStates.Where(x => inputData.LimitStates.Contains(x.LimitState));
var selectedItems = ProgramSetting.LimitStatesList.LimitStates.Where(x => inputData.LimitStates.Contains(x.LimitState));
LimitStateItems.SelectedItems = selectedItems;
LimitStateItems.ShowButtons = true;
}
@@ -148,6 +152,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ Name = "Cracking", PredicateType = PredicateTypes.Cracking },
}
);
PredicateItems.SelectedItems = inputData.PredicateEntries;
PredicateItems.ShowButtons = true;
}
}

View File

@@ -86,9 +86,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
var inputData = new LimitCurveInputData(ndmPrimitives);
var vm = new LimitCurveDataViewModel(inputData, ndmPrimitives);
vm.LimitStateItems.SetIsSelected();
vm.CalcTermITems.SetIsSelected();
vm.ShowPrimitivesTab = true;
//vm.LimitStateItems.SetIsSelected();
//vm.CalcTermITems.SetIsSelected();
//vm.PredicateItems.SetIsSelected();
var wnd = new LimitCurveDataView(vm);
wnd.ShowDialog();
if (wnd.DialogResult != true) return;
@@ -382,6 +382,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
forcesResults = forceCalculator.Result as IForcesResults;
ndmPrimitives = forceCalculator.Primitives;
}
private void ShowIsoField()
{
try

View File

@@ -1,4 +1,4 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.InteractionDiagramCalculatorView"
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.LimitCurveCalculatorView"
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"
@@ -7,47 +7,25 @@
xmlns:fc="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
d:DataContext ="{d:DesignInstance local:LimitCurveCalculatorViewModel}"
mc:Ignorable="d"
Title="Limit Curve Calculator" Height="300" Width="400" MinHeight="300" MinWidth="400">
Title="Limit Curve Calculator" Height="390" Width="400" MinHeight="300" MinWidth="400" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="Logic">
<!--<local:SorroundDataControl/>-->
</TabItem>
<TabItem Header="Primitives">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding PrimitivesViewModel}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Column="1" Margin="2">
<Button Style="{StaticResource AddButton}"/>
<Button Style="{StaticResource DeleteButton}"/>
<Button Style="{StaticResource CopyButton}"/>
</StackPanel>
<TextBlock Text="Name"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/>
<fc:LimitCurveControl Grid.Row="1" Grid.ColumnSpan="2" x:Name="CurveData" LimitCurveViewModel="{Binding LimitCurveDataViewModel}"/>
</Grid>
</TabItem>
<TabItem Header="Predicates">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>
</TabItem>
<TabItem Header="States">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>
</TabItem>
<TabItem Header="Terms">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>
</TabItem>
</TabControl>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -17,11 +17,16 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
/// <summary>
/// Логика взаимодействия для InteractionDiagramCalculatorView.xaml
/// </summary>
public partial class InteractionDiagramCalculatorView : Window
public partial class LimitCurveCalculatorView : Window
{
public InteractionDiagramCalculatorView()
LimitCurveCalculatorViewModel viewModel;
public LimitCurveCalculatorView(LimitCurveCalculatorViewModel viewModel)
{
this.viewModel = viewModel;
this.viewModel.ParentWindow = this;
InitializeComponent();
this.DataContext = this.viewModel;
CurveData.LimitCurveViewModel = this.viewModel.LimitCurveDataViewModel;
}
}
}

View File

@@ -1,4 +1,8 @@
using StructureHelper.Windows.ViewModels;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.ViewModels;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,8 +14,29 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
internal class LimitCurveCalculatorViewModel : OkCancelViewModelBase
public class LimitCurveCalculatorViewModel : OkCancelViewModelBase
{
LimitCurvesCalculator calculator;
public string Name
{
get => calculator.Name;
set
{
calculator.Name = value;
OnPropertyChanged(nameof(Name));
}
}
public LimitCurveDataViewModel LimitCurveDataViewModel { get; }
public LimitCurveCalculatorViewModel(LimitCurvesCalculator calculator, IEnumerable<INdmPrimitive> allowedPrimitives)
{
this.calculator = calculator;
LimitCurveDataViewModel = new LimitCurveDataViewModel(calculator.InputData, allowedPrimitives);
}
public override void OkAction()
{
LimitCurveDataViewModel.RefreshInputData();
base.OkAction();
}
}
}

View File

@@ -7,8 +7,9 @@
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
xmlns:fr="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance fr:LimitCurveDataViewModel}"
d:DesignHeight="325" d:DesignWidth="400">
<Grid DataContext="{Binding LimitCurveViewModel}">
<Grid>
<TabControl>
<TabItem Header="Limits">
<Grid>
@@ -16,7 +17,7 @@
<RowDefinition Height="*"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<local:SurroundDataControl x:Name="Data" SurroundData="{Binding SurroundData}"/>
<local:SurroundDataControl x:Name="SurData"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
@@ -43,7 +44,9 @@
<DataTemplate>
<Expander>
<Expander.Header>
<Grid MinWidth="250">
<TextBox Margin="20,0,0,0" Text="{Binding Name}"/>
</Grid>
</Expander.Header>
<Grid Width="300" Height="200">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding Value}"/>

View File

@@ -1,20 +1,8 @@
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.UserControls;
using StructureHelper.Windows.ViewModels.Materials;
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.Navigation;
using System.Windows.Shapes;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
@@ -24,17 +12,27 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public partial class LimitCurveControl : UserControl
{
public static readonly DependencyProperty LimitCurveViewModelProperty =
DependencyProperty.Register("LimitCurveViewModel", typeof(LimitCurveDataViewModel), typeof(LimitCurveControl));
DependencyProperty.Register(
"LimitCurveViewModel",
typeof(LimitCurveDataViewModel),
typeof(LimitCurveControl));
public LimitCurveDataViewModel LimitCurveViewModel
{
get { return (LimitCurveDataViewModel)GetValue(LimitCurveViewModelProperty); }
set { SetValue(LimitCurveViewModelProperty, value); }
set
{
this.DataContext = value;
SurData.ViewModel = new (value.SurroundData);
//SurData.SurroundData = value.SurroundData;
SurData.DataContext = SurData.ViewModel;
SetValue(LimitCurveViewModelProperty, value);
}
}
public LimitCurveControl()
{
InitializeComponent();
DataContext = this;
//DataContext = this;
}
private void PointCountChanged(object sender, EventArgs e)

View File

@@ -8,7 +8,7 @@
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid>
<StackPanel DataContext="{Binding ViewModel}">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>

View File

@@ -23,49 +23,41 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
/// </summary>
public partial class SurroundDataControl : UserControl
{
// Using a DependencyProperty as the backing store for SurroundData.
// This enables animation, styling, binding, etc...
public static readonly DependencyProperty SurroundDataProperty =
DependencyProperty.Register(
"SurroundData",
typeof(SurroundData),
typeof(SurroundDataControl),
new PropertyMetadata(null, OnSurroundDataChanged));
//// Using a DependencyProperty as the backing store for SurroundData.
//// This enables animation, styling, binding, etc...
//public static readonly DependencyProperty SurroundDataProperty =
// DependencyProperty.Register(
// "SurroundData",
// typeof(SurroundData),
// typeof(SurroundDataControl),
// new PropertyMetadata(null, OnSurroundDataChanged));
private static void OnSurroundDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
SurroundDataControl surroundDataControl = (SurroundDataControl)d;
SurroundData newValue = (SurroundData)e.NewValue;
//private static void OnSurroundDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
//{
// SurroundDataControl surroundDataControl = (SurroundDataControl)d;
// SurroundData newValue = (SurroundData)e.NewValue;
// Handle any additional logic when the SurroundData property changes
// // Handle any additional logic when the SurroundData property changes
// Example: Update ViewModel.SurroundData
surroundDataControl.ViewModel.SurroundData = newValue;
}
// // Example: Update ViewModel.SurroundData
// surroundDataControl.ViewModel.SurroundData = newValue;
//}
private SurroundData surroundData;
public SurroundDataViewModel ViewModel { get; private set; }
//private SurroundData surroundData;
public SurroundDataViewModel ViewModel { get; set; }
public SurroundData SurroundData
{
get => (SurroundData)GetValue(SurroundDataProperty);
set
{
SetValue(SurroundDataProperty, value);
}
}
//public SurroundData SurroundData
// {
// get => (SurroundData)GetValue(SurroundDataProperty);
// set
// {
// SetValue(SurroundDataProperty, value);
// }
// }
public SurroundDataControl()
{
if (SurroundData is null)
{
ViewModel = new SurroundDataViewModel(new());
}
else
{
ViewModel = new SurroundDataViewModel(SurroundData);
}
DataContext = this; // ViewModel;
DataContext = ViewModel;
InitializeComponent();
}

View File

@@ -31,7 +31,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
}
}
private void RefreshAll()
public void RefreshAll()
{
OnPropertyChanged(nameof(Logic));
OnPropertyChanged(nameof(XMax));

View File

@@ -325,11 +325,18 @@
</Expander.Header>
<Expander.ContextMenu>
<ContextMenu>
<MenuItem Header="Add" Command="{Binding Add}">
<MenuItem Header="Add" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ForceCalculator}">
<MenuItem Header="Add Force Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ForceCalculator}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Calculator32.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Add Interaction Diagram Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.LimitCurveCalculator}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Calculator32.png" />
</MenuItem.Icon>
</MenuItem>
</MenuItem>
</ContextMenu>
</Expander.ContextMenu>
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" ContextMenu="{StaticResource AnalisesCRUD}">

View File

@@ -35,13 +35,13 @@ namespace StructureHelper.Windows.ViewModels.Materials
public override void AddMethod(object parameter)
{
CheckParameters(parameter);
var paramType = (MaterialType)parameter;
if (paramType == MaterialType.Concrete) { AddConcrete(); }
else if (paramType == MaterialType.Reinforcement) { AddReinforcement(); }
else if (paramType == MaterialType.Elastic) { AddElastic(); }
else if (paramType == MaterialType.CarbonFiber) { AddCarbonFiber(); }
else if (paramType == MaterialType.GlassFiber) { AddGlassFiber(); }
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)}, Actual type: {nameof(paramType)}");
var parameterType = (MaterialType)parameter;
if (parameterType == MaterialType.Concrete) { AddConcrete(); }
else if (parameterType == MaterialType.Reinforcement) { AddReinforcement(); }
else if (parameterType == MaterialType.Elastic) { AddElastic(); }
else if (parameterType == MaterialType.CarbonFiber) { AddCarbonFiber(); }
else if (parameterType == MaterialType.GlassFiber) { AddGlassFiber(); }
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)}, Actual type: {nameof(parameterType)}");
GlobalRepository.Materials.Create(NewItem);
base.AddMethod(parameter);
}

View File

@@ -1,22 +1,20 @@
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using MessageBox = System.Windows.Forms.MessageBox;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
@@ -25,21 +23,78 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private ICrossSectionRepository repository;
private RelayCommand runCommand;
static readonly CalculatorUpdateStrategy calculatorUpdateStrategy = new();
private ShowProgressLogic showProgressLogic;
private InteractionDiagramLogic interactionDiagramLogic;
public override void AddMethod(object parameter)
{
NewItem = new ForceCalculator() { Name = "New force calculator" };
var parameterType = (CalculatorTypes)parameter;
if (parameterType == CalculatorTypes.ForceCalculator)
{
NewItem = new ForceCalculator()
{
Name = "New force calculator"
};
}
else if (parameterType == CalculatorTypes.LimitCurveCalculator)
{
var inputData = new LimitCurveInputData(repository.Primitives);
NewItem = new LimitCurvesCalculator()
{
Name = "New interaction diagram calculator",
InputData = inputData
};
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(parameterType));
}
base.AddMethod(parameter);
}
public override void EditMethod(object parameter)
{
SafetyProcessor.RunSafeProcess(EditCalculator, $"Error of editing: {SelectedItem.Name}");
base.EditMethod(parameter);
}
private void EditCalculator()
{
if (SelectedItem is ForceCalculator)
{
var calculator = SelectedItem as ForceCalculator;
EditForceCalculator(calculator);
}
else if (SelectedItem is LimitCurvesCalculator)
{
var calculator = SelectedItem as LimitCurvesCalculator;
EditLimitCurveCalculator(calculator);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
}
}
private void EditLimitCurveCalculator(LimitCurvesCalculator calculator)
{
var calculatorCopy = calculator.Clone() as LimitCurvesCalculator;
var vm = new LimitCurveCalculatorViewModel(calculator, repository.Primitives);
var wnd = new LimitCurveCalculatorView(vm);
ShowWindow(calculator, calculatorCopy, wnd);
}
private void EditForceCalculator(ForceCalculator calculator)
{
var calculatorCopy = (ICalculator)calculator.Clone();
var vm = new ForceCalculatorViewModel(repository.Primitives, repository.ForceActions, calculator);
var wnd = new ForceCalculatorView(vm);
ShowWindow(calculator, calculatorCopy, wnd);
}
private static void ShowWindow(ICalculator calculator, ICalculator calculatorCopy, Window wnd)
{
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
@@ -50,8 +105,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
calculatorUpdateStrategy.Update(calculator, calculatorCopy);
}
}
base.EditMethod(parameter);
}
public override void DeleteMethod(object parameter)
{
var dialogResult = MessageBox.Show("Delete calculator?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
@@ -74,20 +128,53 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
}
private void RunCalculator()
{
if (SelectedItem is LimitCurvesCalculator)
{
var calculator = SelectedItem as LimitCurvesCalculator;
var inputData = calculator.InputData;
ShowInteractionDiagramByInputData(inputData);
}
else
{
SelectedItem.Run();
var result = SelectedItem.Result;
if (result.IsValid == false)
{
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else
{
ProcessResult();
}
}
}
private void ShowInteractionDiagramByInputData(LimitCurveInputData inputData)
{
interactionDiagramLogic = new(inputData);
showProgressLogic = new(interactionDiagramLogic)
{
WindowTitle = "Diagram creating...",
ShowResult = interactionDiagramLogic.ShowWindow
};
showProgressLogic.Show();
}
private void ProcessResult()
{
if (SelectedItem is IForceCalculator)
{
var calculator = SelectedItem as ForceCalculator;
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
}
}
public AnalysisVewModelLogic(ICrossSectionRepository sectionRepository) : base(sectionRepository.CalculatorsList)

View File

@@ -9,13 +9,13 @@ namespace StructureHelper.Windows.ViewModels
public Window ParentWindow { get; set; }
public ICommand OkCommand => new RelayCommand(o => OkAction());
public ICommand CancelCommand => new RelayCommand(o => CancelAction());
private void CancelAction()
public virtual void CancelAction()
{
ParentWindow.DialogResult = false;
ParentWindow.Close();
}
private void OkAction()
public virtual void OkAction()
{
ParentWindow.DialogResult = true;
ParentWindow.Close();

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.ColorServices;
using System;
using System.Collections.Generic;
@@ -19,5 +20,15 @@ namespace StructureHelperCommon.Infrastructures.Settings
{
Color = ColorProcessor.GetRandomColor();
}
public override bool Equals(object? obj)
{
var item = obj as CalcTermEntity;
if (item.CalcTerm == CalcTerm & item.Name == Name & item.ShortName == ShortName)
{
return true;
}
return false;
}
}
}

View File

@@ -19,5 +19,15 @@ namespace StructureHelperCommon.Infrastructures.Settings
{
Color = ColorProcessor.GetRandomColor();
}
public override bool Equals(object? obj)
{
var item = obj as LimitStateEntity;
if (item.LimitState == LimitState & item.Name == Name & item.ShortName == ShortName)
{
return true;
}
return false;
}
}
}

View File

@@ -13,5 +13,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public string Name { get; set; }
public PredicateTypes PredicateType { get; set; }
public override bool Equals(object? obj)
{
if (obj is null) { return false; }
var item = obj as PredicateEntry;
if (item.PredicateType == PredicateType & item.Name == Name) { return true; }
return false;
}
}
}

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters;
@@ -13,14 +14,14 @@ using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class LimitCurveInputData : IInputData
public class LimitCurveInputData : IInputData, ICloneable
{
public List<LimitStates> LimitStates { get; }
public List<CalcTerms> CalcTerms { get; }
public List<NamedCollection<INdmPrimitive>> PrimitiveSeries {get;}
public List<PredicateEntry> PredicateEntries { get; }
public List<LimitStates> LimitStates { get; private set; }
public List<CalcTerms> CalcTerms { get; private set; }
public List<NamedCollection<INdmPrimitive>> PrimitiveSeries {get; private set; }
public List<PredicateEntry> PredicateEntries { get; private set; }
public SurroundData SurroundData { get; set; }
public int PointCount { get; set; }
public LimitCurveInputData()
@@ -42,5 +43,31 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
}
);
}
public object Clone()
{
var newItem = new LimitCurveInputData()
{
LimitStates = LimitStates.ToList(),
CalcTerms = CalcTerms.ToList(),
PredicateEntries = PredicateEntries.ToList(),
SurroundData = SurroundData.Clone() as SurroundData,
PointCount = PointCount
};
foreach (var item in PrimitiveSeries)
{
var collection = item.Collection.ToList();
newItem.PrimitiveSeries.Add
(
new NamedCollection<INdmPrimitive>()
{
Name = item.Name,
Collection = collection
}
);
}
return newItem;
}
}
}

View File

@@ -4,6 +4,7 @@ using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Calculations.CalculationsResults;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
@@ -14,12 +15,13 @@ using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class LimitCurvesCalculator : ISaveable, ICalculator, IHasActionByResult
{
private LimitCurvesResult result;
private int curvesIterationCount;
private LimitCurvesCalculatorUpdateStrategy updateStrategy => new();
public Guid Id { get; }
public string Name { get; set; }
@@ -27,7 +29,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
public IResult Result => result;
public Action<IResult> ActionToOutputResults { get; set; }
public LimitCurvesCalculator()
{
Name = "New calculator";
InputData = new();
}
public void Run()
{
GetNewResult();
@@ -110,12 +116,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
public object Clone()
{
throw new NotImplementedException();
var newItem = new LimitCurvesCalculator();
updateStrategy.Update(newItem, this);
return newItem;
}
private void SetCurveCount(IResult locResult)
{
var curveResult = locResult as IiterationResult;;
var curveResult = locResult as IiterationResult;
result.IterationNumber = curvesIterationCount * InputData.PointCount + curveResult.IterationNumber;
ActionToOutputResults?.Invoke(result);
}

View File

@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class LimitCurvesResult : IResult, IiterationResult
{

View File

@@ -14,7 +14,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
/// <summary>
/// Limits of coordinates for workplane
/// </summary>
public class SurroundData
public class SurroundData : ICloneable
{
public double XMax { get; set; }
public double XMin { get; set; }
@@ -39,5 +39,18 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
YMin = -1e7d;
ConvertLogicEntity = ConvertLogics.ConverterLogics[0];
}
public object Clone()
{
var newItem = new SurroundData()
{
XMax = XMax,
XMin = XMin,
YMax = YMax,
YMin = YMin,
ConvertLogicEntity = ConvertLogics.ConverterLogics[0],
};
return newItem;
}
}
}

View File

@@ -0,0 +1,28 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
{
internal class LimitCurveInputDataUpdateStrategy : IUpdateStrategy<LimitCurveInputData>
{
SurroundDataUpdateStrategy surroundDataUpdateStrategy => new();
public void Update(LimitCurveInputData targetObject, LimitCurveInputData sourceObject)
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.LimitStates.Clear();
targetObject.LimitStates.AddRange(sourceObject.LimitStates);
targetObject.CalcTerms.Clear();
targetObject.CalcTerms.AddRange(sourceObject.CalcTerms);
targetObject.PredicateEntries.Clear();
targetObject.PredicateEntries.AddRange(sourceObject.PredicateEntries);
targetObject.PointCount = sourceObject.PointCount;
surroundDataUpdateStrategy.Update(targetObject.SurroundData, sourceObject.SurroundData);
}
}
}

View File

@@ -0,0 +1,22 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
{
internal class LimitCurvesCalculatorUpdateStrategy : IUpdateStrategy<LimitCurvesCalculator>
{
LimitCurveInputDataUpdateStrategy inputDataUpdateStrategy => new();
public void Update(LimitCurvesCalculator targetObject, LimitCurvesCalculator sourceObject)
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name;
targetObject.ActionToOutputResults = sourceObject.ActionToOutputResults;
inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData);
}
}
}

View File

@@ -0,0 +1,23 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
{
internal class SurroundDataUpdateStrategy : IUpdateStrategy<SurroundData>
{
public void Update(SurroundData targetObject, SurroundData sourceObject)
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.XMax = sourceObject.XMax;
targetObject.XMin = sourceObject.XMin;
targetObject.YMax = sourceObject.YMax;
targetObject.YMin = sourceObject.YMin;
targetObject.ConvertLogicEntity = sourceObject.ConvertLogicEntity;
}
}
}

View File

@@ -3,6 +3,7 @@ using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Services;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
@@ -19,9 +20,13 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Logics
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.CompareTypes(targetObject, sourceObject);
if (targetObject is IForceCalculator force)
if (targetObject is IForceCalculator target)
{
new ForceCalculatorUpdateStrategy().Update(force, (IForceCalculator)sourceObject);
new ForceCalculatorUpdateStrategy().Update(target, (IForceCalculator)sourceObject);
}
else if (targetObject is LimitCurvesCalculator limitCurves)
{
new LimitCurvesCalculatorUpdateStrategy().Update(limitCurves, (LimitCurvesCalculator)sourceObject);
}
else
{