Surrounding property was added

This commit is contained in:
Evgeny Redikultsev
2023-03-19 17:38:01 +05:00
parent edb8afe321
commit 9e7962fc3f
47 changed files with 716 additions and 261 deletions

View File

@@ -15,6 +15,7 @@
<ResourceDictionary Source="Infrastructure/UI/Resources/ShapeEditTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/PrimitiveToolTips.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ITemEditPanels.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ForceTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.Enums
{
public enum ActionType
{
ForceCombination,
ForceCombinationByFactor
}
}

View File

@@ -263,13 +263,13 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
public virtual INdmPrimitive GetNdmPrimitive()
{
RefreshNdmPrimitive();
//RefreshNdmPrimitive();
return primitive;
}
public virtual void RefreshNdmPrimitive()
{
}
//public virtual void RefreshNdmPrimitive()
//{
//}
public void RefreshColor()
{

View File

@@ -17,26 +17,37 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
public static ObservableCollection<PrimitiveBase> ConvertNdmPrimitivesToPrimitiveBase(IEnumerable<INdmPrimitive> primitives)
{
ObservableCollection<PrimitiveBase> viewItems = new ObservableCollection<PrimitiveBase>();
foreach (var item in primitives)
foreach (var primitive in primitives)
{
if (item is IRectanglePrimitive)
{
var rect = item as IRectanglePrimitive;
viewItems.Add(new RectangleViewPrimitive(rect));
}
else if (item is ICirclePrimitive)
{
var circle = item as ICirclePrimitive;
viewItems.Add(new CircleViewPrimitive(circle));
}
else if (item is IPointPrimitive)
{
var point = item as IPointPrimitive;
viewItems.Add(new PointViewPrimitive(point));
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
viewItems.Add(ConvertNdmPrimitiveToPrimitiveBase(primitive));
}
return viewItems;
}
public static PrimitiveBase ConvertNdmPrimitiveToPrimitiveBase(INdmPrimitive primitive)
{
PrimitiveBase viewItem;
if (primitive is IRectanglePrimitive)
{
var rect = primitive as IRectanglePrimitive;
viewItem = new RectangleViewPrimitive(rect);
}
else if (primitive is ICirclePrimitive)
{
var circle = primitive as ICirclePrimitive;
viewItem = new CircleViewPrimitive(circle);
}
else if (primitive is IPointPrimitive & primitive is not ReinforcementPrimitive)
{
var point = primitive as IPointPrimitive;
viewItem = new PointViewPrimitive(point);
}
else if (primitive is ReinforcementPrimitive)
{
var point = primitive as ReinforcementPrimitive;
viewItem = new ReinforcementViewPrimitive(point);
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Actual type: {primitive.GetType()}");
return viewItem;
}
}
}

View File

@@ -7,10 +7,23 @@ using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal class ReinforcementViewPrimitive : PointViewPrimitive
public class ReinforcementViewPrimitive : PointViewPrimitive, IHasSurroundingPrimitive
{
public ReinforcementViewPrimitive(IPointPrimitive _primitive) : base(_primitive)
ReinforcementPrimitive primitive;
public INdmPrimitive SurroundingPrimitive
{
get => primitive.SurroundingPrimitive;
set
{
primitive.SurroundingPrimitive = value;
OnPropertyChanged(nameof(SurroundingPrimitive));
}
}
public ReinforcementViewPrimitive(ReinforcementPrimitive _primitive) : base(_primitive)
{
primitive = _primitive;
}
}
}

View File

@@ -0,0 +1,47 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="ForceActionTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Name"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/>
<TextBlock Grid.Row="1" Text="Set force into initial Gravity Center"/>
<CheckBox Grid.Row="1" Grid.Column="1" Margin="3,5,3,5" IsChecked="{Binding SetInGravityCenter}"/>
<TextBlock Grid.Row="2" Text="Center X"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding CenterX}" IsEnabled="{Binding CoordEnable}"/>
<TextBlock Grid.Row="3" Text="Center Y"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding CenterY}" IsEnabled="{Binding CoordEnable}"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="CombinationListTemplate">
<Grid Grid.Row="1" DataContext="{Binding DesignForces}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<DataGrid x:Name="ForceGrid" Style="{StaticResource ItemsDataGrid}">
<DataGrid.Columns>
<DataGridComboBoxColumn Header="Limit state" Width="80" MinWidth="70" SelectedItemBinding="{Binding LimitState}" ItemsSource="{Binding Source={StaticResource LimitStateEnum}}"/>
<DataGridComboBoxColumn Header="Duration" Width="80" MinWidth="70" SelectedItemBinding="{Binding CalcTerm}" ItemsSource="{Binding Source={StaticResource CalcTermEnum}}"/>
<DataGridTextColumn Header="Moment Mx" Width="85" Binding="{Binding ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<DataGridTextColumn Header="Moment My" Width="85" Binding="{Binding ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<DataGridTextColumn Header="Force Nz" Width="85" Binding="{Binding ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Column="1">
<Button Style="{StaticResource AddButton}"/>
<Button Style="{StaticResource DeleteButton}"/>
<Button Style="{StaticResource CopyButton}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ResourceDictionary>

View File

@@ -9,6 +9,9 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Compile Update="Windows\Forces\ForceCombinationByFactorView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\MainWindow\AboutView.xaml.cs">
<SubType>Code</SubType>
</Compile>
@@ -17,6 +20,12 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="Infrastructure\UI\Resources\ForceTemplates.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\Forces\ForceCombinationByFactorView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\MainWindow\AboutView.xaml">
<SubType>Designer</SubType>
</Page>

View File

@@ -0,0 +1,53 @@
<Window x:Class="StructureHelper.Windows.Forces.ForceCombinationByFactorView"
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.Forces"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
d:DataContext="{d:DesignInstance vm:ForceCombinationByFactorVM}"
mc:Ignorable="d"
Title="Force Combination By Factor" Height="250" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="95"/>
<RowDefinition/>
</Grid.RowDefinitions>
<!--ForceTemplates.xaml-->
<ContentControl ContentTemplate="{StaticResource ResourceKey=ForceActionTemplate}" Content="{Binding}"/>
<StackPanel Grid.Row="1">
<TextBlock Text="Full service load combination"/>
<Grid DataContext="{Binding ForceTupleVM}">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Center" Text="Mx" />
<TextBlock Grid.Column="1" HorizontalAlignment="Center" Text="My" />
<TextBlock Grid.Column="2" HorizontalAlignment="Center" Text="Nz" />
<TextBox Grid.Row="1" Text="{Binding Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="Long Term factor"/>
<TextBox Grid.Column="1" Text="{Binding LongTermFactor, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="1" Text="ULS Safety Factor"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding ULSFactor, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
</Grid>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,32 @@
using StructureHelper.Windows.ViewModels.Forces;
using StructureHelperCommon.Models.Forces;
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.Forces
{
/// <summary>
/// Логика взаимодействия для ForceCombinationByFactor.xaml
/// </summary>
public partial class ForceCombinationByFactorView : Window
{
ForceCombinationByFactorVM viewModel;
public ForceCombinationByFactorView(IForceCombinationByFactor forceCombination)
{
InitializeComponent();
viewModel = new ForceCombinationByFactorVM(forceCombination);
DataContext = viewModel;
}
}
}

View File

@@ -9,56 +9,14 @@
mc:Ignorable="d"
Title="Force Combination" Height="250" Width="550" MinHeight="300" MinWidth="450" MaxWidth="500" WindowStartupLocation="CenterScreen">
<Window.Resources>
<DataTemplate x:Key="ForceTemplate">
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="95"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Name"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/>
<TextBlock Grid.Row="1" Text="Set force into initial Gravity Center"/>
<CheckBox Grid.Row="1" Grid.Column="1" Margin="3,5,3,5" IsChecked="{Binding SetInGravityCenter}"/>
<TextBlock Grid.Row="2" Text="Center X"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding CenterX}" IsEnabled="{Binding CoordEnable}"/>
<TextBlock Grid.Row="3" Text="Center Y"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding CenterY}" IsEnabled="{Binding CoordEnable}"/>
</Grid>
</StackPanel>
<Grid Grid.Row="1" DataContext="{Binding DesignForces}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<DataGrid x:Name="ForceGrid" Style="{StaticResource ItemsDataGrid}">
<DataGrid.Columns>
<DataGridComboBoxColumn Header="Limit state" Width="80" MinWidth="70" SelectedItemBinding="{Binding LimitState}" ItemsSource="{Binding Source={StaticResource LimitStateEnum}}"/>
<DataGridComboBoxColumn Header="Duration" Width="80" MinWidth="70" SelectedItemBinding="{Binding CalcTerm}" ItemsSource="{Binding Source={StaticResource CalcTermEnum}}"/>
<DataGridTextColumn Header="Moment Mx" Width="85" Binding="{Binding ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<DataGridTextColumn Header="Moment My" Width="85" Binding="{Binding ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<DataGridTextColumn Header="Force Nz" Width="85" Binding="{Binding ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Column="1">
<Button Style="{StaticResource AddButton}"/>
<Button Style="{StaticResource DeleteButton}"/>
<Button Style="{StaticResource CopyButton}"/>
</StackPanel>
</Grid>
<!--ForceTemplates.xaml-->
<ContentControl ContentTemplate="{StaticResource ResourceKey=ForceActionTemplate}" Content="{Binding}"/>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource ResourceKey=CombinationListTemplate}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -75,7 +75,10 @@
<Expander Header="Actions" MinWidth="20" DataContext="{Binding CombinationsLogic}">
<Expander.ContextMenu>
<ContextMenu>
<Button Content="Add Force Combination" Command="{Binding Add}"/>
<MenuItem Header="Add">
<Button Content="Combination" Command="{Binding Add}" CommandParameter="{x:Static enums:ActionType.ForceCombination}"/>
<Button Content="Combination By Factors" Command="{Binding Add}" CommandParameter="{x:Static enums:ActionType.ForceCombinationByFactor}"/>
</MenuItem>
</ContextMenu>
</Expander.ContextMenu>
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">

View File

@@ -42,7 +42,7 @@ namespace StructureHelper.Windows.MainWindow
private readonly AnalysisVewModelLogic calculatorsLogic;
public AnalysisVewModelLogic CalculatorsLogic { get => calculatorsLogic;}
public ActionsViewModel CombinationsLogic { get => combinationsLogic; }
public IPrimitiveViewModelLogic PrimitiveLogic => primitiveLogic;
public PrimitiveViewModelLogic PrimitiveLogic => primitiveLogic;
public HelpLogic HelpLogic => new HelpLogic();
private MainModel Model { get; }
@@ -214,7 +214,7 @@ namespace StructureHelper.Windows.MainWindow
private double delta = 0.0005;
private ActionsViewModel combinationsLogic;
private IPrimitiveViewModelLogic primitiveLogic;
private PrimitiveViewModelLogic primitiveLogic;
private RelayCommand showVisualProperty;
private RelayCommand selectPrimitive;
@@ -225,7 +225,7 @@ namespace StructureHelper.Windows.MainWindow
section = model.Section;
combinationsLogic = new ActionsViewModel(repository);
calculatorsLogic = new AnalysisVewModelLogic(repository);
primitiveLogic = new PrimitiveViewModelLogic(repository) { CanvasWidth = CanvasWidth, CanvasHeight = CanvasHeight };
primitiveLogic = new PrimitiveViewModelLogic(section) { CanvasWidth = CanvasWidth, CanvasHeight = CanvasHeight };
XX2 = CanvasWidth;
XY1 = CanvasHeight / 2d;
YX1 = CanvasWidth / 2d;
@@ -342,11 +342,6 @@ namespace StructureHelper.Windows.MainWindow
}
}
private bool CheckAnalisysOptions()
{
if (CheckMaterials() == false) { return false; }
return true;
}
private bool CheckMaterials()
{
foreach (var item in primitiveLogic.Items)
@@ -405,10 +400,10 @@ namespace StructureHelper.Windows.MainWindow
var newRepository = newSection.SectionRepository;
repository.HeadMaterials.AddRange(newRepository.HeadMaterials);
repository.Primitives.AddRange(newRepository.Primitives);
repository.ForceCombinationLists.AddRange(newRepository.ForceCombinationLists);
repository.ForceActions.AddRange(newRepository.ForceActions);
repository.CalculatorsList.AddRange(newRepository.CalculatorsList);
OnPropertyChanged(nameof(HeadMaterials));
CombinationsLogic.AddItems(newRepository.ForceCombinationLists);
CombinationsLogic.AddItems(newRepository.ForceActions);
CalculatorsLogic.AddItems(newRepository.CalculatorsList);
var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(newRepository.Primitives);
foreach (var item in primitives)

View File

@@ -68,7 +68,7 @@
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Inside of"/>
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding PrimitiveMaterial}">
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding SurroundingPrimitives}" SelectedItem="{Binding SurroundingPrimitive}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>

View File

@@ -2,6 +2,7 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials;
using StructureHelper.Windows.ViewModels.PrimitiveProperties;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
@@ -29,10 +30,10 @@ namespace StructureHelper.Windows.PrimitiveProperiesWindow
{
PrimitiveBase primitive;
private PrimitivePropertiesViewModel viewModel;
public PrimitivePropertiesView(PrimitiveBase primitive, IHasHeadMaterials headMaterials)
public PrimitivePropertiesView(PrimitiveBase primitive, ICrossSectionRepository sectionRepository)
{
this.primitive = primitive;
viewModel = new PrimitivePropertiesViewModel(this.primitive, headMaterials);
viewModel = new PrimitivePropertiesViewModel(this.primitive, sectionRepository);
this.DataContext = viewModel;
InitializeComponent();
if (primitive is RectangleViewPrimitive) { AddPrimitiveProperties(PrimitiveType.Rectangle); }
@@ -42,13 +43,13 @@ namespace StructureHelper.Windows.PrimitiveProperiesWindow
}
private void AddPrimitiveProperties(PrimitiveType type)
{
List<string> names = new List<string>();
if (primitive.DivisionViewModel is not null) { names.Add("TriangulationProperties");}
if (primitive is RectangleViewPrimitive) { names.Add("RectangleProperties"); }
if (primitive is CircleViewPrimitive) { names.Add("CircleProperties"); }
if (primitive is PointViewPrimitive) { names.Add("PointProperties"); }
if (primitive is ReinforcementViewPrimitive) { names.Add("ReinforcementProperties"); }
foreach (var name in names)
List<string> templateNames = new List<string>();
if (primitive.DivisionViewModel is not null) { templateNames.Add("TriangulationProperties");}
if (primitive is RectangleViewPrimitive) { templateNames.Add("RectangleProperties"); }
if (primitive is CircleViewPrimitive) { templateNames.Add("CircleProperties"); }
if (primitive is PointViewPrimitive) { templateNames.Add("PointProperties"); }
if (primitive is ReinforcementViewPrimitive) { templateNames.Add("ReinforcementProperties"); }
foreach (var name in templateNames)
{
ContentControl contentControl = new ContentControl();
contentControl.SetResourceReference(ContentTemplateProperty, name);

View File

@@ -24,7 +24,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
public class ForceCalculatorViewModel : ViewModelBase
{
IEnumerable<INdmPrimitive> allowedPrimitives;
IEnumerable<IForceCombinationList> allowedForceCombinations;
IEnumerable<IForceAction> allowedForceCombinations;
ForceCalculator forcesCalculator;
SecondOrderViewModel secondOrderViewModel;
@@ -53,7 +53,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
public bool ShortTerm { get; set; }
public bool LongTerm { get; set; }
public ISourceToTargetViewModel<IForceCombinationList> CombinationViewModel { get; }
public ISourceToTargetViewModel<IForceAction> CombinationViewModel { get; }
public ISourceToTargetViewModel<PrimitiveBase> PrimitivesViewModel { get; }
public PrimitiveBase SelectedAllowedPrimitive { get; set; }
@@ -146,15 +146,15 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
}
}
public ForceCalculatorViewModel(IEnumerable<INdmPrimitive> _allowedPrimitives, IEnumerable<IForceCombinationList> _allowedForceCombinations, ForceCalculator _forcesCalculator)
public ForceCalculatorViewModel(IEnumerable<INdmPrimitive> _allowedPrimitives, IEnumerable<IForceAction> _allowedForceCombinations, ForceCalculator _forcesCalculator)
{
allowedPrimitives = _allowedPrimitives;
allowedForceCombinations = _allowedForceCombinations;
forcesCalculator = _forcesCalculator;
secondOrderViewModel = new SecondOrderViewModel(forcesCalculator.CompressedMember);
CombinationViewModel = new SourceToTargetViewModel<IForceCombinationList>();
CombinationViewModel.SetTargetItems(forcesCalculator.ForceCombinationLists);
CombinationViewModel = new SourceToTargetViewModel<IForceAction>();
CombinationViewModel.SetTargetItems(forcesCalculator.ForceActions);
CombinationViewModel.SetSourceItems(allowedForceCombinations);
CombinationViewModel.ItemDataDemplate = Application.Current.Resources["SimpleItemTemplate"] as DataTemplate;
@@ -180,10 +180,10 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
public void Refresh()
{
var combinations = CombinationViewModel.GetTargetItems();
forcesCalculator.ForceCombinationLists.Clear();
forcesCalculator.ForceActions.Clear();
foreach (var item in combinations)
{
forcesCalculator.ForceCombinationLists.Add(item);
forcesCalculator.ForceActions.Add(item);
}
forcesCalculator.Primitives.Clear();
foreach (var item in PrimitivesViewModel.GetTargetItems())

View File

@@ -1,4 +1,7 @@
using StructureHelper.Windows.Forces;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.Forces;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
@@ -11,16 +14,29 @@ using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.Forces
{
public class ActionsViewModel : CRUDViewModelBase<IForceCombinationList>
public class ActionsViewModel : CRUDViewModelBase<IForceAction>
{
ICrossSectionRepository repository;
public override void AddMethod(object parameter)
{
if (parameter is not null)
{
ActionType paramType = (ActionType)parameter;
if (paramType == ActionType.ForceCombination)
{
NewItem = new ForceCombinationList() { Name = "New Force Combination" };
}
else if (paramType == ActionType.ForceCombinationByFactor)
{
NewItem = new ForceCombinationByFactor() { Name = "New Factored Combination" };
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $": Actual type: {nameof(paramType)}");
base.AddMethod(parameter);
}
}
public override void DeleteMethod(object parameter)
{
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
@@ -32,11 +48,11 @@ namespace StructureHelper.Windows.ViewModels.Forces
if (item is IForceCalculator)
{
var forceCalculator = item as IForceCalculator;
var containSelected = forceCalculator.ForceCombinationLists.Contains(SelectedItem);
var containSelected = forceCalculator.ForceActions.Contains(SelectedItem);
if (containSelected)
{
var dialogResultCalc = MessageBox.Show($"Action is contained in calculator {item.Name}", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResultCalc == DialogResult.OK) { forceCalculator.ForceCombinationLists.Remove(SelectedItem); }
if (dialogResultCalc == DialogResult.OK) { forceCalculator.ForceActions.Remove(SelectedItem); }
else return;
}
}
@@ -47,12 +63,23 @@ namespace StructureHelper.Windows.ViewModels.Forces
public override void EditMethod(object parameter)
{
var wnd = new ForceCombinationView(SelectedItem);
System.Windows.Window wnd;
if (SelectedItem is IForceCombinationList)
{
var item = (IForceCombinationList)SelectedItem;
wnd = new ForceCombinationView(item);
}
else if (SelectedItem is IForceCombinationByFactor)
{
var item = (IForceCombinationByFactor)SelectedItem;
wnd = new ForceCombinationByFactorView(item);
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"actual object type: {nameof(SelectedItem)}");
wnd.ShowDialog();
base.EditMethod(parameter);
}
public ActionsViewModel(ICrossSectionRepository repository) : base (repository.ForceCombinationLists)
public ActionsViewModel(ICrossSectionRepository repository) : base (repository.ForceActions)
{
this.repository = repository;
}

View File

@@ -0,0 +1,61 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Forces
{
public abstract class ForceActionVMBase : ViewModelBase
{
IForceAction forceAction;
public string Name
{
get => forceAction.Name;
set
{
forceAction.Name = value;
}
}
public bool SetInGravityCenter
{
get => forceAction.SetInGravityCenter;
set
{
forceAction.SetInGravityCenter = value;
OnPropertyChanged(nameof(SetInGravityCenter));
OnPropertyChanged(nameof(CoordEnable));
}
}
public bool CoordEnable => !SetInGravityCenter;
public double CenterX
{
get => forceAction.ForcePoint.X;
set
{
forceAction.ForcePoint.X = value;
OnPropertyChanged(nameof(CenterX));
}
}
public double CenterY
{
get => forceAction.ForcePoint.Y;
set
{
forceAction.ForcePoint.Y = value;
OnPropertyChanged(nameof(CenterY));
}
}
public ForceActionVMBase(IForceAction forceAction)
{
this.forceAction = forceAction;
}
}
}

View File

@@ -0,0 +1,73 @@
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Media3D;
namespace StructureHelper.Windows.ViewModels.Forces
{
public class ForceCombinationByFactorVM : ForceActionVMBase, IDataErrorInfo
{
IForceCombinationByFactor forceAction;
ForceTupleVM forceTupleVM;
public double ULSFactor
{
get => forceAction.ULSFactor;
set
{
forceAction.ULSFactor = value;
OnPropertyChanged(nameof(ULSFactor));
}
}
public ForceTupleVM ForceTupleVM => forceTupleVM;
public double LongTermFactor
{
get => forceAction.LongTermFactor;
set
{
if (value <0d) { value = 0d; }
if (value > 1d) { value = 1d; }
forceAction.LongTermFactor = value;
OnPropertyChanged(nameof(LongTermFactor));
}
}
public string Error => throw new NotImplementedException();
public string this[string columnName]
{
get
{
string error = null;
if (columnName == nameof(ULSFactor))
{
if (ULSFactor <= 0)
{
error = "Safety factor for ULS must be greater than zero";
}
}
if (columnName == nameof(LongTermFactor))
{
if (LongTermFactor < 0d || LongTermFactor > 1d)
{
error = "Long term factor must be between 0.0 and 1.0";
}
}
return error;
}
}
public ForceCombinationByFactorVM(IForceCombinationByFactor forceAction) : base(forceAction)
{
this.forceAction = forceAction;
forceTupleVM = new ForceTupleVM(forceAction.FullSLSForces);
}
}
}

View File

@@ -8,61 +8,15 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Forces
{
public class ForceCombinationViewModel : ViewModelBase
public class ForceCombinationViewModel : ForceActionVMBase
{
IForceCombinationList combinationList;
ForceTuplesViewModel designForces;
//public IDesignForceTuple SelectedTuple { get; set; }
public ForceTuplesViewModel DesignForces { get;}
public ForceTuplesViewModel DesignForces => designForces;
public string Name
public ForceCombinationViewModel(IForceCombinationList combinationList) : base(combinationList)
{
get => combinationList.Name;
set
{
combinationList.Name = value;
}
}
public bool SetInGravityCenter
{
get => combinationList.SetInGravityCenter;
set
{
combinationList.SetInGravityCenter = value;
OnPropertyChanged(nameof(SetInGravityCenter));
OnPropertyChanged(nameof(CoordEnable));
}
}
public bool CoordEnable => !SetInGravityCenter;
public double CenterX
{
get => combinationList.ForcePoint.X;
set
{
combinationList.ForcePoint.X = value;
OnPropertyChanged(nameof(CenterX));
}
}
public double CenterY
{
get => combinationList.ForcePoint.Y;
set
{
combinationList.ForcePoint.Y = value;
OnPropertyChanged(nameof(CenterY));
}
}
//public IEnumerable<IDesignForceTuple> ForceTuples { get => combinationList.DesignForces; }
public ForceCombinationViewModel(IForceCombinationList combinationList)
{
this.combinationList = combinationList;
DesignForces = new ForceTuplesViewModel(this.combinationList.DesignForces);
designForces = new ForceTuplesViewModel(combinationList.DesignForces);
}
}
}

View File

@@ -0,0 +1,73 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Forces
{
public class ForceTupleVM : ViewModelBase
{
IForceTuple forceTuple;
public double Mx
{
get => forceTuple.Mx;
set
{
forceTuple.Mx = value;
OnPropertyChanged(nameof(Mx));
}
}
public double My
{
get => forceTuple.My;
set
{
forceTuple.My = value;
OnPropertyChanged(nameof(My));
}
}
public double Nz
{
get => forceTuple.Nz;
set
{
forceTuple.Nz = value;
OnPropertyChanged(nameof(Nz));
}
}
public double Qx
{
get => forceTuple.Qx;
set
{
forceTuple.Qx = value;
OnPropertyChanged(nameof(Qx));
}
}
public double Qy
{
get => forceTuple.Qy;
set
{
forceTuple.Qy = value;
OnPropertyChanged(nameof(Qy));
}
}
public double Mz
{
get => forceTuple.Mz;
set
{
forceTuple.Mz = value;
OnPropertyChanged(nameof(Mz));
}
}
public ForceTupleVM(IForceTuple forceTuple)
{
this.forceTuple = forceTuple;
}
}
}

View File

@@ -30,7 +30,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
if (SelectedItem is ForceCalculator)
{
var calculator = SelectedItem as ForceCalculator;
var vm = new ForceCalculatorViewModel(repository.Primitives, repository.ForceCombinationLists, calculator);
var vm = new ForceCalculatorViewModel(repository.Primitives, repository.ForceActions, calculator);
var wnd = new ForceCalculatorView(vm);
wnd.ShowDialog();

View File

@@ -19,9 +19,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
private readonly ICrossSectionRepository repository;
public IForceCombinationList SelectedItem { get; set; }
public IForceAction SelectedItem { get; set; }
public ObservableCollection<IForceCombinationList> Items { get; private set; }
public ObservableCollection<IForceAction> Items { get; private set; }
private RelayCommand addForceCombinationCommand;
public RelayCommand Add
@@ -41,7 +41,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
var item = new ForceCombinationList() { Name = "New Force Combination" };
Items.Add(item);
repository.ForceCombinationLists.Add(item);
repository.ForceActions.Add(item);
}
private RelayCommand deleteForceCombinationCommand;
public RelayCommand Delete
@@ -62,7 +62,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
repository.ForceCombinationLists.Remove(SelectedItem);
repository.ForceActions.Remove(SelectedItem);
}
}
private RelayCommand editForceCombinationCommand;
@@ -78,7 +78,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
EditForceCombination();
Items.Clear();
AddItems(repository.ForceCombinationLists);
AddItems(repository.ForceActions);
OnPropertyChanged(nameof(Items));
}, o => SelectedItem != null));
}
@@ -93,7 +93,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
copyCommand = new RelayCommand(o =>
{
var item = SelectedItem.Clone() as IForceCombinationList;
repository.ForceCombinationLists.Add(item);
repository.ForceActions.Add(item);
Items.Add(item);
OnPropertyChanged(nameof(Items));
}, o => SelectedItem != null));
@@ -102,11 +102,11 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private void EditForceCombination()
{
var wnd = new ForceCombinationView(SelectedItem);
wnd.ShowDialog();
//var wnd = new ForceCombinationView(SelectedItem);
//wnd.ShowDialog();
}
public void AddItems(IEnumerable<IForceCombinationList> items)
public void AddItems(IEnumerable<IForceAction> items)
{
foreach (var item in items)
{
@@ -117,8 +117,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
public ForceCombinationViewModelLogic(ICrossSectionRepository repository)
{
this.repository = repository;
Items = new ObservableCollection<IForceCombinationList>();
AddItems(this.repository.ForceCombinationLists);
Items = new ObservableCollection<IForceAction>();
AddItems(this.repository.ForceActions);
}
}
}

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
public interface IForceCombinationViewModelLogic : ICRUDViewModel<IForceCombinationList>
public interface IForceCombinationViewModelLogic : ICRUDViewModel<IForceAction>
{
}
}

View File

@@ -1,13 +0,0 @@
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
public interface IPrimitiveViewModelLogic : ICRUDViewModel<PrimitiveBase>
{
RelayCommand SetToFront { get; }
RelayCommand SetToBack { get; }
int PrimitivesCount { get; }
void Refresh();
}
}

View File

@@ -22,9 +22,10 @@ using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
public class PrimitiveViewModelLogic : ViewModelBase, IPrimitiveViewModelLogic
public class PrimitiveViewModelLogic : ViewModelBase, ICRUDViewModel<PrimitiveBase>
{
private readonly ICrossSectionRepository repository;
private ICrossSection section;
private ICrossSectionRepository repository => section.SectionRepository;
private RelayCommand addCommand;
private RelayCommand deleteCommand;
private RelayCommand editCommand;
@@ -99,6 +100,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + nameof(primitiveType)); }
viewPrimitive.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
repository.Primitives.Add(ndmPrimitive);
ndmPrimitive.CrossSection = section;
Items.Add(viewPrimitive);
OnPropertyChanged(nameof(Items));
OnPropertyChanged(nameof(PrimitivesCount));
@@ -132,6 +134,14 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
forceCalc.Primitives.Remove(ndmPrimitive);
}
}
foreach (var primitive in repository.Primitives)
{
if (primitive is IHasSurroundingPrimitive)
{
var sPrimitive = primitive as IHasSurroundingPrimitive;
if (sPrimitive.SurroundingPrimitive == ndmPrimitive) { sPrimitive.SurroundingPrimitive = null; }
}
}
Items.Remove(SelectedItem);
}
OnPropertyChanged(nameof(Items));
@@ -243,9 +253,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
OnPropertyChanged(nameof(PrimitivesCount));
}
public PrimitiveViewModelLogic(ICrossSectionRepository repository)
public PrimitiveViewModelLogic(ICrossSection section)
{
this.repository = repository;
this.section = section;
Items = new ObservableCollection<PrimitiveBase>();
AddItems(PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(this.repository.Primitives));
}

View File

@@ -4,14 +4,19 @@ using StructureHelper.Models.Materials;
using StructureHelper.Windows.ColorPickerWindow;
using StructureHelper.Windows.MainWindow.Materials;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
@@ -25,12 +30,13 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
public class PrimitivePropertiesViewModel : ViewModelBase, IDataErrorInfo
{
private PrimitiveBase primitive;
private IHasHeadMaterials hasHeadMaterials;
private ICrossSectionRepository sectionRepository;
public ICommand EditColorCommand { get; private set; }
public ICommand EditMaterialCommand { get; private set; }
public ObservableCollection<IHeadMaterial> HeadMaterials { get; private set; }
public ObservableCollection<PrimitiveBase> SurroundingPrimitives { get; private set; }
public string Name
{
@@ -54,7 +60,42 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
}
}
}
public PrimitiveBase? SurroundingPrimitive
{
get
{
if (primitive is not IHasSurroundingPrimitive)
{
return null;
}
else
{
var sPrimitive = ((IHasSurroundingPrimitive)primitive).SurroundingPrimitive;
if (sPrimitive is null) { return null; }
foreach (var item in SurroundingPrimitives)
{
if (item.GetNdmPrimitive() == sPrimitive)
{
return item;
}
}
return null;
}
}
set
{
if (value is not null)
{
if (primitive is IHasSurroundingPrimitive)
{
var sPrimitive = value.GetNdmPrimitive();
((IHasSurroundingPrimitive)primitive).SurroundingPrimitive = sPrimitive;
OnPropertyChanged(nameof(SurroundingPrimitive));
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $", Actual type: {value.GetType()}");
}
}
}
public double CenterX
{
get => primitive.CenterX;
@@ -126,7 +167,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
CenterX = CenterX;
}
}
public double Height
{
get
@@ -148,7 +188,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
CenterY = CenterY; ;
}
}
public double Area
{
get
@@ -171,7 +210,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
}
}
}
public double Diameter
{
get
@@ -194,7 +232,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
}
}
}
public Color Color
{
get => primitive.Color;
@@ -204,7 +241,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
OnPropertyChanged(nameof(Color));
}
}
public bool SetMaterialColor
{
get => primitive.SetMaterialColor;
@@ -215,7 +251,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
OnPropertyChanged(nameof(SetMaterialColor));
}
}
public int ZIndex
{ get => primitive.ZIndex;
set
@@ -223,7 +258,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
primitive.ZIndex = value;
}
}
public bool IsVisible
{
get => primitive.IsVisible;
@@ -233,7 +267,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
OnPropertyChanged(nameof(IsVisible));
}
}
public double Opacity
{
get => primitive.Opacity * 100d;
@@ -245,7 +278,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
OnPropertyChanged(nameof(Opacity));
}
}
public string this[string columnName]
{
get
@@ -267,23 +299,28 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
public string Error => throw new NotImplementedException();
public PrimitivePropertiesViewModel(PrimitiveBase primitive, IHasHeadMaterials hasHeadMaterials)
public PrimitivePropertiesViewModel(PrimitiveBase primitive, ICrossSectionRepository sectionRepository)
{
this.primitive = primitive;
this.hasHeadMaterials = hasHeadMaterials;
this.sectionRepository = sectionRepository;
HeadMaterials = new ObservableCollection<IHeadMaterial>();
foreach (var material in hasHeadMaterials.HeadMaterials)
foreach (var material in sectionRepository.HeadMaterials)
{
HeadMaterials.Add(material);
}
EditColorCommand = new RelayCommand(o => EditColor(), o => !SetMaterialColor);
EditMaterialCommand = new RelayCommand(o => EditMaterial());
SurroundingPrimitives = new ObservableCollection<PrimitiveBase>();
foreach (var item in sectionRepository.Primitives)
{
if (item is RectanglePrimitive || item is CirclePrimitive)
{SurroundingPrimitives.Add(PrimitiveOperations.ConvertNdmPrimitiveToPrimitiveBase(item));}
}
}
private void EditMaterial()
{
var wnd = new HeadMaterialsView(hasHeadMaterials);
var wnd = new HeadMaterialsView(sectionRepository);
wnd.ShowDialog();
}

View File

@@ -5,6 +5,6 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IHasForceCombinations
{
List<IForceCombinationList> ForceCombinationLists { get; }
List<IForceAction> ForceActions { get; }
}
}

View File

@@ -16,7 +16,7 @@ namespace StructureHelperCommon.Models.Forces
public string Name { get; set; }
public bool SetInGravityCenter { get; set; }
/// <inheritdoc/>
public IPoint2D ForcePoint { get; private set; }
public IPoint2D ForcePoint { get; set; }
/// <inheritdoc/>
public IForceTuple FullSLSForces { get; private set; }
/// <inheritdoc/>
@@ -29,10 +29,15 @@ namespace StructureHelperCommon.Models.Forces
SetInGravityCenter = true;
ForcePoint = new Point2D();
FullSLSForces = new ForceTuple();
LongTermFactor = 1d;
ULSFactor = 1.2d;
}
public List<IDesignForceTuple> GetCombination()
public IForceCombinationList GetCombinations()
{
var result = new List<IDesignForceTuple>();
var result = new ForceCombinationList();
result.SetInGravityCenter = this.SetInGravityCenter;
result.ForcePoint = this.ForcePoint;
result.DesignForces.Clear();
var limitStates = new List<LimitStates>() { LimitStates.ULS, LimitStates.SLS };
var calcTerms = new List<CalcTerms>() { CalcTerms.ShortTerm, CalcTerms.LongTerm };
foreach (var limitState in limitStates)
@@ -42,11 +47,21 @@ namespace StructureHelperCommon.Models.Forces
{
var termFactor = calcTerm is CalcTerms.ShortTerm ? 1d : LongTermFactor;
var designForceTuple = new DesignForceTuple() { LimitState = limitState, CalcTerm = calcTerm };
designForceTuple.ForceTuple = ForceTupleService.MultiplyTuples(designForceTuple.ForceTuple, stateFactor * termFactor);
result.Add(designForceTuple);
designForceTuple.ForceTuple = ForceTupleService.MultiplyTuples(FullSLSForces, stateFactor * termFactor);
result.DesignForces.Add(designForceTuple);
}
}
return result;
}
public object Clone()
{
var newItem = new ForceCombinationByFactor();
ForceActionService.CopyActionProps(this, newItem);
newItem.FullSLSForces = FullSLSForces.Clone() as IForceTuple;
newItem.LongTermFactor = LongTermFactor;
newItem.ULSFactor = ULSFactor;
return newItem;
}
}
}

View File

@@ -15,7 +15,7 @@ namespace StructureHelperCommon.Models.Forces
/// <inheritdoc/>
public bool SetInGravityCenter { get; set; }
/// <inheritdoc/>
public IPoint2D ForcePoint { get; private set; }
public IPoint2D ForcePoint { get; set; }
/// <inheritdoc/>
public List<IDesignForceTuple> DesignForces { get; private set; }
@@ -35,10 +35,7 @@ namespace StructureHelperCommon.Models.Forces
public object Clone()
{
var newItem = new ForceCombinationList();
newItem.Name = Name + " copy";
newItem.SetInGravityCenter = SetInGravityCenter;
newItem.ForcePoint.X = ForcePoint.X;
newItem.ForcePoint.Y = ForcePoint.Y;
ForceActionService.CopyActionProps(this, newItem);
newItem.DesignForces.Clear();
foreach (var item in DesignForces)
{
@@ -48,9 +45,10 @@ namespace StructureHelperCommon.Models.Forces
return newItem;
}
/// <inheritdoc/>
public List<IDesignForceTuple> GetCombination()
public IForceCombinationList GetCombinations()
{
var result = new List<IDesignForceTuple>();
var result = Clone() as IForceCombinationList;
result.DesignForces.Clear();
var limitStates = new List<LimitStates>() { LimitStates.ULS, LimitStates.SLS };
var calcTerms = new List<CalcTerms>() { CalcTerms.ShortTerm, CalcTerms.LongTerm };
foreach (var limitState in limitStates)
@@ -63,7 +61,7 @@ namespace StructureHelperCommon.Models.Forces
{
designForceTuple.ForceTuple = ForceTupleService.SumTuples(designForceTuple.ForceTuple, item.ForceTuple);
}
result.Add(designForceTuple);
result.DesignForces.Add(designForceTuple);
}
}
return result;

View File

@@ -7,10 +7,10 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
public interface IForceAction : IAction
public interface IForceAction : IAction, ICloneable
{
bool SetInGravityCenter { get; set; }
IPoint2D ForcePoint { get; }
List<IDesignForceTuple> GetCombination();
IPoint2D ForcePoint { get; set; }
IForceCombinationList GetCombinations();
}
}

View File

@@ -4,8 +4,8 @@ using StructureHelperCommon.Models.Shapes;
namespace StructureHelperCommon.Models.Forces
{
public interface IForceCombinationList : IForceAction, ICloneable
public interface IForceCombinationList : IForceAction
{
List<IDesignForceTuple> DesignForces { get; }
List<IDesignForceTuple> DesignForces { get;}
}
}

View File

@@ -0,0 +1,21 @@
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace StructureHelperCommon.Services.Forces
{
internal static class ForceActionService
{
public static void CopyActionProps(IForceAction source, IForceAction target)
{
target.Name = source.Name;
target.SetInGravityCenter = source.SetInGravityCenter;
target.ForcePoint.X = source.ForcePoint.X;
target.ForcePoint.Y = source.ForcePoint.Y;
}
}
}

View File

@@ -13,14 +13,14 @@ namespace StructureHelperLogics.Models.CrossSections
{
public class CrossSectionRepository : ICrossSectionRepository
{
public List<IForceCombinationList> ForceCombinationLists { get; private set; }
public List<IForceAction> ForceActions { get; private set; }
public List<IHeadMaterial> HeadMaterials { get; private set; }
public List<INdmPrimitive> Primitives { get; }
public List<INdmCalculator> CalculatorsList { get; private set; }
public CrossSectionRepository()
{
ForceCombinationLists = new List<IForceCombinationList>();
ForceActions = new List<IForceAction>();
HeadMaterials = new List<IHeadMaterial>();
Primitives = new List<INdmPrimitive>();
CalculatorsList = new List<INdmCalculator>();

View File

@@ -14,7 +14,7 @@ namespace StructureHelperLogics.Models.CrossSections
{
public interface ICrossSectionRepository : IHasHeadMaterials, IHasPrimitives
{
List<IForceCombinationList> ForceCombinationLists { get; }
List<IForceAction> ForceActions { get; }
List<INdmCalculator> CalculatorsList { get; }
}
}

View File

@@ -13,7 +13,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
public class CircleGeometryLogic : IRCGeometryLogic
{
ICircleTemplate template;
CirclePrimitive concreteBlock;
public IEnumerable<IHeadMaterial> HeadMaterials { get; set; }
@@ -35,8 +35,8 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
var diameter = template.Shape.Diameter;
var concreteMaterial = HeadMaterials.ToList()[0];
var primitives = new List<INdmPrimitive>();
var rectangle = new CirclePrimitive() { Diameter = diameter, Name = "Concrete block", HeadMaterial = concreteMaterial };
primitives.Add(rectangle);
concreteBlock = new CirclePrimitive() { Diameter = diameter, Name = "Concrete block", HeadMaterial = concreteMaterial };
primitives.Add(concreteBlock);
return primitives;
}
@@ -52,7 +52,13 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
var angle = i * dAngle;
var x = radius * Math.Sin(angle);
var y = radius * Math.Cos(angle);
var point = new PointPrimitive() { CenterX = x, CenterY = y, Area = barArea, Name = "Left bottom point", HeadMaterial = reinforcementMaterial };
var point = new ReinforcementPrimitive()
{ CenterX = x,
CenterY = y,
Area = barArea,
Name = "Left bottom point",
HeadMaterial = reinforcementMaterial,
SurroundingPrimitive=concreteBlock };
primitives.Add(point);
}
return primitives;

View File

@@ -17,6 +17,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
IRectangleBeamTemplate template;
IHeadMaterial concrete => HeadMaterials.ToList()[0];
IHeadMaterial reinforcement => HeadMaterials.ToList()[1];
RectanglePrimitive concreteBlock;
RectangleShape rect => template.Shape as RectangleShape;
double width => rect.Width;
@@ -47,8 +48,8 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
private IEnumerable<INdmPrimitive> GetConcretePrimitives()
{
var primitives = new List<INdmPrimitive>();
var rectangle = new RectanglePrimitive(concrete) { Width = width, Height = height, Name = "Concrete block" };
primitives.Add(rectangle);
concreteBlock = new RectanglePrimitive(concrete) { Width = width, Height = height, Name = "Concrete block" };
primitives.Add(concreteBlock);
return primitives;
}
@@ -58,13 +59,13 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
double[] ys = new double[] { -height / 2 + gap, height / 2 - gap };
List<INdmPrimitive> primitives = new List<INdmPrimitive>();
var point = new PointPrimitive(reinforcement) { CenterX = xs[0], CenterY = ys[0], Area = area1, Name = "Left bottom point" };
var point = new ReinforcementPrimitive() { CenterX = xs[0], CenterY = ys[0], Area = area1, Name = "Left bottom point", HeadMaterial = reinforcement, SurroundingPrimitive=concreteBlock };
primitives.Add(point);
point = new PointPrimitive(reinforcement) { CenterX = xs[1], CenterY = ys[0], Area = area1, Name = "Right bottom point" };
point = new ReinforcementPrimitive() { CenterX = xs[1], CenterY = ys[0], Area = area1, Name = "Right bottom point", HeadMaterial = reinforcement, SurroundingPrimitive = concreteBlock };
primitives.Add(point);
point = new PointPrimitive(reinforcement) { CenterX = xs[0], CenterY = ys[1], Area = area2, Name = "Left top point" };
point = new ReinforcementPrimitive() { CenterX = xs[0], CenterY = ys[1], Area = area2, Name = "Left top point", HeadMaterial = reinforcement, SurroundingPrimitive = concreteBlock };
primitives.Add(point);
point = new PointPrimitive(reinforcement) { CenterX = xs[1], CenterY = ys[1], Area = area2, Name = "Right top point" };
point = new ReinforcementPrimitive() { CenterX = xs[1], CenterY = ys[1], Area = area2, Name = "Right top point", HeadMaterial = reinforcement, SurroundingPrimitive = concreteBlock };
primitives.Add(point);
return primitives;
}
@@ -82,9 +83,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
double dist = (xs[1] - xs[0]) / count;
for (int i = 1; i < count; i++)
{
point = new PointPrimitive(reinforcement) { CenterX = xs[0] + dist * i, CenterY = ys[0], Area = area1, Name = $"Bottom point {i}" };
point = new ReinforcementPrimitive() { CenterX = xs[0] + dist * i, CenterY = ys[0], Area = area1, Name = $"Bottom point {i}", HeadMaterial = reinforcement, SurroundingPrimitive = concreteBlock };
primitives.Add(point);
point = new PointPrimitive(reinforcement) { CenterX = xs[0] + dist * i, CenterY = ys[1], Area = area2, Name = $"Top point {i}" };
point = new ReinforcementPrimitive() { CenterX = xs[0] + dist * i, CenterY = ys[1], Area = area2, Name = $"Top point {i}", HeadMaterial = reinforcement, SurroundingPrimitive = concreteBlock };
primitives.Add(point);
}
}
@@ -94,9 +95,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
double dist = (ys[1] - ys[0]) / count;
for (int i = 1; i < count; i++)
{
point = new PointPrimitive(reinforcement) { CenterX = xs[0], CenterY = ys[0] + dist * i, Area = area1, Name = $"Left point {i}" };
point = new ReinforcementPrimitive() { CenterX = xs[0], CenterY = ys[0] + dist * i, Area = area1, Name = $"Left point {i}", HeadMaterial = reinforcement, SurroundingPrimitive = concreteBlock };
primitives.Add(point);
point = new PointPrimitive(reinforcement) { CenterX = xs[1], CenterY = ys[0] + dist * i, Area = area1, Name = $"Right point {i}" };
point = new ReinforcementPrimitive() { CenterX = xs[1], CenterY = ys[0] + dist * i, Area = area1, Name = $"Right point {i}", HeadMaterial = reinforcement, SurroundingPrimitive = concreteBlock };
primitives.Add(point);
}
}

View File

@@ -37,10 +37,14 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
var materials = materialLogic.GetHeadMaterials();
geometryLogic.HeadMaterials = materials;
primitives = geometryLogic.GetNdmPrimitives();
foreach (var primitive in primitives)
{
primitive.CrossSection = section;
}
repository.HeadMaterials.AddRange(materials);
repository.Primitives.AddRange(primitives);
combinations = forceLogic.GetCombinationList();
repository.ForceCombinationLists.AddRange(combinations);
repository.ForceActions.AddRange(combinations);
calculators = calculatorLogic.GetNdmCalculators();
AddAllForcesToCalculators();
AddAllPrimitivesToCalculator();
@@ -55,7 +59,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
if (calculator is IHasForceCombinations)
{
var forceCalculator = calculator as IHasForceCombinations;
forceCalculator.ForceCombinationLists.AddRange(combinations);
forceCalculator.ForceActions.AddRange(combinations);
}
}
}

View File

@@ -25,12 +25,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public string Name { get; set; }
public List<LimitStates> LimitStatesList { get; }
public List<CalcTerms> CalcTermsList { get; }
public List<IForceCombinationList> ForceCombinationLists { get; }
public List<IForceAction> ForceActions { get; }
public List<INdmPrimitive> Primitives { get; }
public INdmResult Result { get; private set; }
public ICompressedMember CompressedMember { get; }
public IAccuracy Accuracy { get; set; }
public List<IForceCombinationList> ForceCombinationLists { get; private set; }
public void Run()
{
var checkResult = CheckInputData();
@@ -39,7 +39,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
Result = new ForcesResults() { IsValid = false, Desctription = checkResult };
return;
}
else { CalculateResult(); }
else
{
GetCombinations();
CalculateResult();
}
}
private void CalculateResult()
@@ -103,6 +107,15 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
Result = ndmResult;
}
private void GetCombinations()
{
ForceCombinationLists = new List<IForceCombinationList>();
foreach (var item in ForceActions)
{
ForceCombinationLists.Add(item.GetCombinations());
}
}
private IForceTuple GetLongTuple(List<IDesignForceTuple> designForces, LimitStates limitState)
{
IForceTuple longTuple;
@@ -143,7 +156,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
string result = "";
NdmPrimitivesService.CheckPrimitives(Primitives);
if (ForceCombinationLists.Count == 0) { result += "Calculator does not contain any forces \n"; }
if (ForceActions.Count == 0) { result += "Calculator does not contain any forces \n"; }
if (LimitStatesList.Count == 0) { result += "Calculator does not contain any limit states \n"; }
if (CalcTermsList.Count == 0) { result += "Calculator does not contain any duration \n"; }
return result;
@@ -151,7 +164,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public ForceCalculator()
{
ForceCombinationLists = new List<IForceCombinationList>();
ForceActions = new List<IForceAction>();
Primitives = new List<INdmPrimitive>();
CompressedMember = new CompressedMember() { Buckling = false };
Accuracy = new Accuracy() { IterationAccuracy = 0.001d, MaxIterationCount = 1000 };
@@ -177,7 +190,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
AccuracyService.CopyProperties(Accuracy, target.Accuracy);
CompressedMemberServices.CopyProperties(CompressedMember, target.CompressedMember);
target.Primitives.AddRange(Primitives);
target.ForceCombinationLists.AddRange(ForceCombinationLists);
target.ForceActions.AddRange(ForceActions);
return target;
}
}

View File

@@ -15,5 +15,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
List<LimitStates> LimitStatesList { get; }
ICompressedMember CompressedMember { get; }
IAccuracy Accuracy { get; set; }
List<IForceCombinationList> ForceCombinationLists { get;}
}
}

View File

@@ -4,6 +4,7 @@ using StructureHelper.Models.Materials;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.ShapeServices;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
@@ -29,6 +30,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public int NdmMinDivision { get; set; }
public bool ClearUnderlying { get; set; }
public bool Triangulate { get; set; }
public ICrossSection? CrossSection { get; set; }
public CirclePrimitive()
{

View File

@@ -6,8 +6,8 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public interface IHasSorroundingPrimitive
public interface IHasSurroundingPrimitive
{
INdmPrimitive SorroundingPrimitive { get; set; }
INdmPrimitive? SurroundingPrimitive { get; set; }
}
}

View File

@@ -8,6 +8,7 @@ using System.Collections.Generic;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
@@ -16,6 +17,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
string? Name { get; set; }
double CenterX { get; set; }
double CenterY { get; set; }
ICrossSection? CrossSection { get; set; }
IHeadMaterial? HeadMaterial { get; set; }
/// <summary>
/// Flag of triangulation

View File

@@ -10,6 +10,7 @@ using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services.NdmPrimitives;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
namespace StructureHelperLogics.Models.Primitives
{
@@ -28,6 +29,7 @@ namespace StructureHelperLogics.Models.Primitives
public IVisualProperty VisualProperty { get; }
public bool Triangulate { get; set; }
public ICrossSection? CrossSection { get; set; }
public PointPrimitive()
{

View File

@@ -5,6 +5,7 @@ using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.ShapeServices;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services.NdmPrimitives;
@@ -33,7 +34,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public bool ClearUnderlying { get; set; }
public bool Triangulate { get; set; }
public IVisualProperty VisualProperty { get; }
public ICrossSection? CrossSection { get; set; }
public RectanglePrimitive()
{

View File

@@ -2,6 +2,7 @@
using LoaderCalculator.Data.Ndms;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services.NdmPrimitives;
@@ -15,7 +16,7 @@ using System.Windows.Media.Media3D;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
/// <inheritdoc/>
public class ReinforcementPrimitive : IPointPrimitive, IHasSorroundingPrimitive
public class ReinforcementPrimitive : IPointPrimitive, IHasSurroundingPrimitive
{
/// <inheritdoc/>
public string Name { get; set; }
@@ -35,7 +36,8 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public int Id { get; set; }
public double Area { get; set; }
public INdmPrimitive SorroundingPrimitive { get; set; }
public INdmPrimitive SurroundingPrimitive { get; set; }
public ICrossSection? CrossSection { get; set; }
public ReinforcementPrimitive()
{
@@ -52,7 +54,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
var primitive = new ReinforcementPrimitive();
NdmPrimitivesService.CopyNdmProperties(this, primitive);
primitive.Area = Area;
primitive.SorroundingPrimitive = this.SorroundingPrimitive;
primitive.SurroundingPrimitive = SurroundingPrimitive;
return primitive;
}

View File

@@ -23,17 +23,21 @@ namespace StructureHelperLogics.Services.NdmCalculations
CompressedMemberServices.CopyProperties(source.CompressedMember, calculator.CompressedMember);
calculator.Accuracy = source.Accuracy;
calculator.Primitives.AddRange(source.Primitives);
calculator.ForceCombinationLists.Clear();
calculator.ForceActions.Clear();
var forceTuples = ForceTupleService.InterpolateDesignTuple(finishDesignForce, startDesignForce, stepCount);
foreach (var forceTuple in forceTuples)
{
var combination = new ForceCombinationList()
{
Name = "New combination",
SetInGravityCenter = false
};
combination.DesignForces.Clear();
combination.DesignForces.AddRange(ForceTupleService.InterpolateDesignTuple(finishDesignForce, startDesignForce, stepCount));
combination.DesignForces.Add(forceTuple);
combination.ForcePoint.X = 0;
combination.ForcePoint.Y = 0;
calculator.ForceCombinationLists.Add(combination);
calculator.ForceActions.Add(combination);
}
return calculator;
}
}

View File

@@ -33,6 +33,18 @@ namespace StructureHelperTests.ViewModelTests
Assert.NotNull(vm);
}
public void Circle_Run_ShouldPass()
{
//Arrange
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40, CodeTypes.SP63_13330_2018);
var primitive = new CirclePrimitive() { HeadMaterial = material};
var primitiveBase = new CircleViewPrimitive(primitive);
//Act
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
//Assert
Assert.NotNull(vm);
}
[Test]
public void Point_Run_ShouldPass()
{
@@ -45,5 +57,17 @@ namespace StructureHelperTests.ViewModelTests
//Assert
Assert.NotNull(vm);
}
public void Reinforcement_Run_ShouldPass()
{
//Arrange
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40, CodeTypes.SP63_13330_2018);
var primitive = new ReinforcementPrimitive() { HeadMaterial = material };
var primitiveBase = new ReinforcementViewPrimitive(primitive);
//Act
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
//Assert
Assert.NotNull(vm);
}
}
}