Options for primitive series in limit curves were added

This commit is contained in:
Evgeny Redikultsev
2024-01-20 15:12:07 +05:00
parent d0f3ead51f
commit 3a1cf5fa71
40 changed files with 480 additions and 328 deletions

View File

@@ -45,6 +45,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
InputData = inputData;
stepCount = InputData.PointCount;
stepCount *= inputData.PrimitiveSeries.Count;
stepCount *= InputData.LimitStates.Count();
stepCount *= InputData.CalcTerms.Count();
stepCount *= InputData.PredicateEntries.Count();

View File

@@ -0,0 +1,14 @@
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
{
internal static class LimitCurveDataService
{
}
}

View File

@@ -6,49 +6,14 @@
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic"
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
xmlns:fc="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
d:DataContext ="{d:DesignInstance local:LimitCurveDataViewModel}"
mc:Ignorable="d"
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}"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition/>
<ColumnDefinition Width="120"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Point count"/>
<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}"/>-->
<fc:LimitCurveControl x:Name="CurveData" LimitCurveViewModel="{Binding}"/>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -1,5 +1,6 @@
using StructureHelper.Windows.UserControls;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -22,25 +23,13 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public partial class LimitCurveDataView : Window
{
private LimitCurveDataViewModel viewModel;
public LimitCurveDataView(SurroundData surroundData) : this(new LimitCurveDataViewModel(surroundData)) { }
public LimitCurveDataView(LimitCurveDataViewModel vm)
{
viewModel = vm;
viewModel.ParentWindow = this;
DataContext = viewModel;
InitializeComponent();
SurData.SurroundData = vm.SurroundData;
}
private void PointCountChanged(object sender, EventArgs e)
{
viewModel.PointCount = Convert.ToInt32(viewModel.PointCount * ChangeValue(sender));
}
private double ChangeValue(object sender)
{
var obj = (MultiplyDouble)sender;
var factor = obj.DoubleFactor;
return factor;
CurveData.LimitCurveViewModel = viewModel;
}
}
}

View File

@@ -1,4 +1,5 @@
using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
@@ -23,84 +24,76 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
public class LimitCurveDataViewModel : OkCancelViewModelBase, IDataErrorInfo
{
private int pointCount;
private LimitCurveInputData inputData;
//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 SurroundData SurroundData { get => inputData.SurroundData; }
public SelectPrimitivesSourceTarget PrimitiveSeries { get; private set; }
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
{
get => pointCount; set
get => inputData.PointCount; set
{
try
{
pointCount = value;
inputData.PointCount = value;
}
catch (Exception)
{
pointCount = 40;
inputData.PointCount = 40;
}
OnPropertyChanged(nameof(PointCount));
}
}
public LimitCurveDataViewModel(SurroundData surroundData)
public IEnumerable<INdmPrimitive> AllowedPrimitives { get; set; }
public LimitCurveDataViewModel(LimitCurveInputData inputData, IEnumerable<INdmPrimitive> allowedPrimitives)
{
//SurroundDataViewModel = new(surroundData);
SurroundData = surroundData;
this.inputData = inputData;
AllowedPrimitives = allowedPrimitives;
List<NamedValue<SourceTargetVM<PrimitiveBase>>> namedCollection = new List<NamedValue<SourceTargetVM<PrimitiveBase>>>();
foreach (var item in inputData.PrimitiveSeries)
{
var viewModel = SourceTargetFactory.GetSourceTargetVM(AllowedPrimitives, item.Collection);
var namedViewModel = new NamedValue<SourceTargetVM<PrimitiveBase>>()
{
Name = item.Name,
Value = viewModel
};
namedCollection.Add(namedViewModel);
}
PrimitiveSeries = new SelectPrimitivesSourceTarget(namedCollection);
PrimitiveSeries.AllowedPrimitives = allowedPrimitives.ToList();
GetPredicates();
GetLimitStates();
GetCalcTerms();
pointCount = 80;
}
private void GetCalcTerms()
public void RefreshInputData()
{
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())
{
}
public LimitCurveInputData GetLimitCurveInputData()
{
LimitCurveInputData inputData = new()
{
SurroundData = SurroundData,
PointCount = pointCount
};
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;
inputData.PrimitiveSeries.Clear();
foreach (var item in PrimitiveSeries.Collection)
{
var selectesPrimitives = item.Value.TargetItems.Select(x => x.NdmPrimitive).ToList();
inputData.PrimitiveSeries.Add
(
new NamedCollection<INdmPrimitive>()
{
Name = item.Name,
Collection = selectesPrimitives
}
);
}
}
public bool Check()
{
if (PredicateItems.SelectedCount == 0 ||
@@ -111,9 +104,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
}
return true;
}
public string Error => throw new NotImplementedException();
public string this[string columnName]
{
get
@@ -131,5 +124,31 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
return error;
}
}
private void GetCalcTerms()
{
CalcTermITems = new SelectItemsVM<CalcTermEntity>(ProgramSetting.CalcTermList.CalcTerms);
CalcTermITems.SelectedItems = ProgramSetting.CalcTermList.CalcTerms.Where(x => inputData.CalcTerms.Contains(x.CalcTerm));
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));
LimitStateItems.ShowButtons = true;
}
private void GetPredicates()
{
PredicateItems = new SelectItemsVM<PredicateEntry>(
new List<PredicateEntry>()
{
new PredicateEntry()
{ Name = "Strength", PredicateType = PredicateTypes.Strength },
new PredicateEntry()
{ Name = "Cracking", PredicateType = PredicateTypes.Cracking },
}
);
PredicateItems.ShowButtons = true;
}
}
}

View File

@@ -84,18 +84,25 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private void ShowInteractionDiagram()
{
var surroundDdata = new SurroundData();
var vm = new LimitCurveDataViewModel(surroundDdata);
var inputData = new LimitCurveInputData(ndmPrimitives);
var vm = new LimitCurveDataViewModel(inputData, ndmPrimitives);
vm.LimitStateItems.SetIsSelected();
vm.CalcTermITems.SetIsSelected();
vm.ShowPrimitivesTab = true;
var wnd = new LimitCurveDataView(vm);
wnd.ShowDialog();
if (wnd.DialogResult != true) return;
if (vm.Check() == false)
{
MessageBox.Show(ErrorStrings.DataIsInCorrect + ": nothing selected"); ;
return;
}
vm.Primitives = ndmPrimitives.ToList();
var wnd = new LimitCurveDataView(vm);
wnd.ShowDialog();
if (wnd.DialogResult != true) return;
var inputData = vm.GetLimitCurveInputData();
vm.RefreshInputData();
ShowInteractionDiagramByInputData(inputData);
}
private void ShowInteractionDiagramByInputData(LimitCurveInputData inputData)
{
interactionDiagramLogic = new(inputData);
showProgressLogic = new(interactionDiagramLogic)
{

View File

@@ -4,9 +4,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
d:DataContext ="{d:DesignInstance local:InteractionDiagramCalculatorViewModel}"
xmlns:fc="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
d:DataContext ="{d:DesignInstance local:LimitCurveCalculatorViewModel}"
mc:Ignorable="d"
Title="Interaction Diagram Calculator" Height="300" Width="400" MinHeight="300" MinWidth="400">
Title="Limit Curve Calculator" Height="300" Width="400" MinHeight="300" MinWidth="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
@@ -17,7 +18,25 @@
<!--<local:SorroundDataControl/>-->
</TabItem>
<TabItem Header="Primitives">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding PrimitivesViewModel}"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="60"/>
</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>
</Grid>
</TabItem>
<TabItem Header="Predicates">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>

View File

@@ -10,7 +10,8 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
internal class InteractionDiagramCalculatorViewModel : OkCancelViewModelBase
internal class LimitCurveCalculatorViewModel : OkCancelViewModelBase
{
}
}

View File

@@ -0,0 +1,72 @@
<UserControl x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.LimitCurveControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
xmlns:fr="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic"
mc:Ignorable="d"
d:DesignHeight="325" d:DesignWidth="400">
<Grid DataContext="{Binding LimitCurveViewModel}">
<TabControl>
<TabItem Header="Limits">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<local:SurroundDataControl x:Name="Data" SurroundData="{Binding SurroundData}"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition/>
<ColumnDefinition Width="120"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Point count"/>
<TextBox Grid.Column="1" Text="{Binding PointCount, ValidatesOnDataErrors=True}"/>
<uc:MultiplyDouble Margin="2" Grid.Column="3" ValueChanged="PointCountChanged"/>
</Grid>
</Grid>
</TabItem>
<TabItem Header="Primitives" DataContext="{Binding PrimitiveSeries}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">
<ListBox.ItemTemplate>
<DataTemplate>
<Expander>
<Expander.Header>
<TextBox Margin="20,0,0,0" Text="{Binding Name}"/>
</Expander.Header>
<Grid Width="300" Height="200">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding Value}"/>
</Grid>
</Expander>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Column="1" Margin="2">
<Button Style="{StaticResource AddButton}"/>
<Button Style="{StaticResource DeleteButton}"/>
</StackPanel>
</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>
</Grid>
</UserControl>

View File

@@ -0,0 +1,52 @@
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
{
/// <summary>
/// Логика взаимодействия для LimitCurveControl.xaml
/// </summary>
public partial class LimitCurveControl : UserControl
{
public static readonly DependencyProperty LimitCurveViewModelProperty =
DependencyProperty.Register("LimitCurveViewModel", typeof(LimitCurveDataViewModel), typeof(LimitCurveControl));
public LimitCurveDataViewModel LimitCurveViewModel
{
get { return (LimitCurveDataViewModel)GetValue(LimitCurveViewModelProperty); }
set { SetValue(LimitCurveViewModelProperty, value); }
}
public LimitCurveControl()
{
InitializeComponent();
DataContext = this;
}
private void PointCountChanged(object sender, EventArgs e)
{
LimitCurveViewModel.PointCount = Convert.ToInt32(LimitCurveViewModel.PointCount * ChangeValue(sender));
}
private double ChangeValue(object sender)
{
var obj = (MultiplyDouble)sender;
var factor = obj.DoubleFactor;
return factor;
}
}
}

View File

@@ -24,7 +24,6 @@
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<GroupBox Header="{Binding YLabel}">
<Grid Margin="30,0,0,0">
<Grid.RowDefinitions>

View File

@@ -28,7 +28,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public static readonly DependencyProperty SurroundDataProperty =
DependencyProperty.Register(
"SurroundData",
typeof(SurroundData), // Change to the actual type of SurroundData
typeof(SurroundData),
typeof(SurroundDataControl),
new PropertyMetadata(null, OnSurroundDataChanged));