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

View File

@@ -86,9 +86,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ {
var inputData = new LimitCurveInputData(ndmPrimitives); var inputData = new LimitCurveInputData(ndmPrimitives);
var vm = new LimitCurveDataViewModel(inputData, ndmPrimitives); var vm = new LimitCurveDataViewModel(inputData, ndmPrimitives);
vm.LimitStateItems.SetIsSelected(); //vm.LimitStateItems.SetIsSelected();
vm.CalcTermITems.SetIsSelected(); //vm.CalcTermITems.SetIsSelected();
vm.ShowPrimitivesTab = true; //vm.PredicateItems.SetIsSelected();
var wnd = new LimitCurveDataView(vm); var wnd = new LimitCurveDataView(vm);
wnd.ShowDialog(); wnd.ShowDialog();
if (wnd.DialogResult != true) return; if (wnd.DialogResult != true) return;
@@ -382,6 +382,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
forcesResults = forceCalculator.Result as IForcesResults; forcesResults = forceCalculator.Result as IForcesResults;
ndmPrimitives = forceCalculator.Primitives; ndmPrimitives = forceCalculator.Primitives;
} }
private void ShowIsoField() private void ShowIsoField()
{ {
try 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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -7,47 +7,25 @@
xmlns:fc="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews" xmlns:fc="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
d:DataContext ="{d:DesignInstance local:LimitCurveCalculatorViewModel}" d:DataContext ="{d:DesignInstance local:LimitCurveCalculatorViewModel}"
mc:Ignorable="d" 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>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="35"/> <RowDefinition Height="35"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TabControl> <Grid>
<TabItem Header="Logic"> <Grid.RowDefinitions>
<!--<local:SorroundDataControl/>--> <RowDefinition Height="25"/>
</TabItem> <RowDefinition/>
<TabItem Header="Primitives"> </Grid.RowDefinitions>
<Grid> <Grid.ColumnDefinitions>
<Grid.ColumnDefinitions> <ColumnDefinition Width="150"/>
<ColumnDefinition Width="*"/> <ColumnDefinition />
<ColumnDefinition Width="60"/> </Grid.ColumnDefinitions>
</Grid.ColumnDefinitions> <TextBlock Text="Name"/>
<ListBox> <TextBox Grid.Column="1" Text="{Binding Name}"/>
<ListBox.ItemTemplate> <fc:LimitCurveControl Grid.Row="1" Grid.ColumnSpan="2" x:Name="CurveData" LimitCurveViewModel="{Binding LimitCurveDataViewModel}"/>
<DataTemplate> </Grid>
<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>
</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}"/> <ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid> </Grid>
</Window> </Window>

View File

@@ -17,11 +17,16 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
/// <summary> /// <summary>
/// Логика взаимодействия для InteractionDiagramCalculatorView.xaml /// Логика взаимодействия для InteractionDiagramCalculatorView.xaml
/// </summary> /// </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(); 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -10,8 +14,29 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews 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:uc="clr-namespace:StructureHelper.Windows.UserControls"
xmlns:fr="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic" xmlns:fr="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance fr:LimitCurveDataViewModel}"
d:DesignHeight="325" d:DesignWidth="400"> d:DesignHeight="325" d:DesignWidth="400">
<Grid DataContext="{Binding LimitCurveViewModel}"> <Grid>
<TabControl> <TabControl>
<TabItem Header="Limits"> <TabItem Header="Limits">
<Grid> <Grid>
@@ -16,7 +17,7 @@
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="35"/> <RowDefinition Height="35"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<local:SurroundDataControl x:Name="Data" SurroundData="{Binding SurroundData}"/> <local:SurroundDataControl x:Name="SurData"/>
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="25"/> <RowDefinition Height="25"/>
@@ -43,7 +44,9 @@
<DataTemplate> <DataTemplate>
<Expander> <Expander>
<Expander.Header> <Expander.Header>
<TextBox Margin="20,0,0,0" Text="{Binding Name}"/> <Grid MinWidth="250">
<TextBox Margin="20,0,0,0" Text="{Binding Name}"/>
</Grid>
</Expander.Header> </Expander.Header>
<Grid Width="300" Height="200"> <Grid Width="300" Height="200">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding Value}"/> <ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding Value}"/>

View File

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

View File

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

View File

@@ -23,51 +23,43 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
/// </summary> /// </summary>
public partial class SurroundDataControl : UserControl public partial class SurroundDataControl : UserControl
{ {
// Using a DependencyProperty as the backing store for SurroundData. //// Using a DependencyProperty as the backing store for SurroundData.
// This enables animation, styling, binding, etc... //// This enables animation, styling, binding, etc...
public static readonly DependencyProperty SurroundDataProperty = //public static readonly DependencyProperty SurroundDataProperty =
DependencyProperty.Register( // DependencyProperty.Register(
"SurroundData", // "SurroundData",
typeof(SurroundData), // typeof(SurroundData),
typeof(SurroundDataControl), // typeof(SurroundDataControl),
new PropertyMetadata(null, OnSurroundDataChanged)); // new PropertyMetadata(null, OnSurroundDataChanged));
private static void OnSurroundDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) //private static void OnSurroundDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ //{
SurroundDataControl surroundDataControl = (SurroundDataControl)d; // SurroundDataControl surroundDataControl = (SurroundDataControl)d;
SurroundData newValue = (SurroundData)e.NewValue; // 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 // // Example: Update ViewModel.SurroundData
surroundDataControl.ViewModel.SurroundData = newValue; // surroundDataControl.ViewModel.SurroundData = newValue;
} //}
private SurroundData surroundData; //private SurroundData surroundData;
public SurroundDataViewModel ViewModel { get; private set; } public SurroundDataViewModel ViewModel { get; set; }
public SurroundData SurroundData //public SurroundData SurroundData
{ // {
get => (SurroundData)GetValue(SurroundDataProperty); // get => (SurroundData)GetValue(SurroundDataProperty);
set // set
{ // {
SetValue(SurroundDataProperty, value); // SetValue(SurroundDataProperty, value);
} // }
} // }
public SurroundDataControl() public SurroundDataControl()
{ {
if (SurroundData is null) DataContext = ViewModel;
{ InitializeComponent();
ViewModel = new SurroundDataViewModel(new()); }
}
else
{
ViewModel = new SurroundDataViewModel(SurroundData);
}
DataContext = this; // ViewModel;
InitializeComponent();
}
private void XmaxChanged(object sender, EventArgs e) private void XmaxChanged(object sender, EventArgs e)
{ {

View File

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

View File

@@ -325,10 +325,17 @@
</Expander.Header> </Expander.Header>
<Expander.ContextMenu> <Expander.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="Add" Command="{Binding Add}"> <MenuItem Header="Add" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ForceCalculator}">
<MenuItem.Icon> <MenuItem Header="Add Force Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ForceCalculator}">
<Image Width="16" Height="16" Source="/Windows/MainWindow/Calculator32.png" /> <MenuItem.Icon>
</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> </MenuItem>
</ContextMenu> </ContextMenu>
</Expander.ContextMenu> </Expander.ContextMenu>

View File

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

View File

@@ -1,22 +1,20 @@
using StructureHelper.Infrastructure; using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews; using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.ViewModels.Calculations.Calculators; using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using StructureHelper.Windows.ViewModels.Errors; using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; 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.Analyses.Logics;
using StructureHelperLogics.NdmCalculations.Primitives;
using System; using System;
using System.Collections.Generic; using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using MessageBox = System.Windows.Forms.MessageBox;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{ {
@@ -25,33 +23,89 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private ICrossSectionRepository repository; private ICrossSectionRepository repository;
private RelayCommand runCommand; private RelayCommand runCommand;
static readonly CalculatorUpdateStrategy calculatorUpdateStrategy = new(); static readonly CalculatorUpdateStrategy calculatorUpdateStrategy = new();
private ShowProgressLogic showProgressLogic;
private InteractionDiagramLogic interactionDiagramLogic;
public override void AddMethod(object parameter) 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); base.AddMethod(parameter);
} }
public override void EditMethod(object 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) if (SelectedItem is ForceCalculator)
{ {
var calculator = SelectedItem as ForceCalculator; var calculator = SelectedItem as ForceCalculator;
var calculatorCopy = (ICalculator)calculator.Clone(); EditForceCalculator(calculator);
var vm = new ForceCalculatorViewModel(repository.Primitives, repository.ForceActions, calculator); }
else if (SelectedItem is LimitCurvesCalculator)
var wnd = new ForceCalculatorView(vm); {
wnd.ShowDialog(); var calculator = SelectedItem as LimitCurvesCalculator;
if (wnd.DialogResult == true) EditLimitCurveCalculator(calculator);
{ }
// to do: update in repository else
} {
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
{
calculatorUpdateStrategy.Update(calculator, calculatorCopy);
}
} }
base.EditMethod(parameter);
} }
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)
{
// to do: update in repository
}
else
{
calculatorUpdateStrategy.Update(calculator, calculatorCopy);
}
}
public override void DeleteMethod(object parameter) public override void DeleteMethod(object parameter)
{ {
var dialogResult = MessageBox.Show("Delete calculator?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); var dialogResult = MessageBox.Show("Delete calculator?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
@@ -75,19 +129,52 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private void RunCalculator() private void RunCalculator()
{ {
SelectedItem.Run(); if (SelectedItem is LimitCurvesCalculator)
var result = SelectedItem.Result;
if (result.IsValid == false)
{ {
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning); var calculator = SelectedItem as LimitCurvesCalculator;
var inputData = calculator.InputData;
ShowInteractionDiagramByInputData(inputData);
} }
else 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 calculator = SelectedItem as ForceCalculator;
var vm = new ForcesResultsViewModel(calculator); var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm); var wnd = new ForceResultsView(vm);
wnd.ShowDialog(); wnd.ShowDialog();
} }
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
}
} }
public AnalysisVewModelLogic(ICrossSectionRepository sectionRepository) : base(sectionRepository.CalculatorsList) public AnalysisVewModelLogic(ICrossSectionRepository sectionRepository) : base(sectionRepository.CalculatorsList)

View File

@@ -9,13 +9,13 @@ namespace StructureHelper.Windows.ViewModels
public Window ParentWindow { get; set; } public Window ParentWindow { get; set; }
public ICommand OkCommand => new RelayCommand(o => OkAction()); public ICommand OkCommand => new RelayCommand(o => OkAction());
public ICommand CancelCommand => new RelayCommand(o => CancelAction()); public ICommand CancelCommand => new RelayCommand(o => CancelAction());
private void CancelAction() public virtual void CancelAction()
{ {
ParentWindow.DialogResult = false; ParentWindow.DialogResult = false;
ParentWindow.Close(); ParentWindow.Close();
} }
private void OkAction() public virtual void OkAction()
{ {
ParentWindow.DialogResult = true; ParentWindow.DialogResult = true;
ParentWindow.Close(); 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 StructureHelperCommon.Services.ColorServices;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -19,5 +20,15 @@ namespace StructureHelperCommon.Infrastructures.Settings
{ {
Color = ColorProcessor.GetRandomColor(); 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(); 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 string Name { get; set; }
public PredicateTypes PredicateType { 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.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters; using StructureHelperCommon.Models.Parameters;
@@ -13,14 +14,14 @@ using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia //Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved. //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<LimitStates> LimitStates { get; private set; }
public List<CalcTerms> CalcTerms { get; } public List<CalcTerms> CalcTerms { get; private set; }
public List<NamedCollection<INdmPrimitive>> PrimitiveSeries {get;} public List<NamedCollection<INdmPrimitive>> PrimitiveSeries {get; private set; }
public List<PredicateEntry> PredicateEntries { get; } public List<PredicateEntry> PredicateEntries { get; private set; }
public SurroundData SurroundData { get; set; } public SurroundData SurroundData { get; set; }
public int PointCount { get; set; } public int PointCount { get; set; }
public LimitCurveInputData() 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 StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Calculations.CalculationsResults; using StructureHelperLogics.Models.Calculations.CalculationsResults;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.Services.NdmPrimitives; using StructureHelperLogics.Services.NdmPrimitives;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -14,12 +15,13 @@ using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia //Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved. //All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{ {
public class LimitCurvesCalculator : ISaveable, ICalculator, IHasActionByResult public class LimitCurvesCalculator : ISaveable, ICalculator, IHasActionByResult
{ {
private LimitCurvesResult result; private LimitCurvesResult result;
private int curvesIterationCount; private int curvesIterationCount;
private LimitCurvesCalculatorUpdateStrategy updateStrategy => new();
public Guid Id { get; } public Guid Id { get; }
public string Name { get; set; } public string Name { get; set; }
@@ -27,7 +29,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
public IResult Result => result; public IResult Result => result;
public Action<IResult> ActionToOutputResults { get; set; } public Action<IResult> ActionToOutputResults { get; set; }
public LimitCurvesCalculator()
{
Name = "New calculator";
InputData = new();
}
public void Run() public void Run()
{ {
GetNewResult(); GetNewResult();
@@ -110,12 +116,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
public object Clone() public object Clone()
{ {
throw new NotImplementedException(); var newItem = new LimitCurvesCalculator();
updateStrategy.Update(newItem, this);
return newItem;
} }
private void SetCurveCount(IResult locResult) private void SetCurveCount(IResult locResult)
{ {
var curveResult = locResult as IiterationResult;; var curveResult = locResult as IiterationResult;
result.IterationNumber = curvesIterationCount * InputData.PointCount + curveResult.IterationNumber; result.IterationNumber = curvesIterationCount * InputData.PointCount + curveResult.IterationNumber;
ActionToOutputResults?.Invoke(result); ActionToOutputResults?.Invoke(result);
} }

View File

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

View File

@@ -14,7 +14,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
/// <summary> /// <summary>
/// Limits of coordinates for workplane /// Limits of coordinates for workplane
/// </summary> /// </summary>
public class SurroundData public class SurroundData : ICloneable
{ {
public double XMax { get; set; } public double XMax { get; set; }
public double XMin { get; set; } public double XMin { get; set; }
@@ -39,5 +39,18 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
YMin = -1e7d; YMin = -1e7d;
ConvertLogicEntity = ConvertLogics.ConverterLogics[0]; 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.Models.Calculators;
using StructureHelperCommon.Services; using StructureHelperCommon.Services;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using System; using System;
@@ -19,9 +20,13 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Logics
{ {
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.CompareTypes(targetObject, sourceObject); 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 else
{ {