Add value diagram windows and view models

This commit is contained in:
Evgeny Redikultsev
2025-11-09 17:34:51 +05:00
parent 111b60a08d
commit 466b47f447
58 changed files with 1397 additions and 162 deletions

View File

@@ -1,10 +1,4 @@
using System; namespace StructureHelper.Infrastructure.Enums
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.Enums
{ {
public enum CalculatorTypes public enum CalculatorTypes
{ {
@@ -12,6 +6,7 @@ namespace StructureHelper.Infrastructure.Enums
LimitCurveCalculator, LimitCurveCalculator,
CrackCalculator, CrackCalculator,
FireCalculator, FireCalculator,
BeamShearCalculator BeamShearCalculator,
ValueDiagram
} }
} }

View File

@@ -888,6 +888,16 @@
</Canvas.Children> </Canvas.Children>
</Canvas> </Canvas>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="ValueDiagramCalculator">
<Canvas Style="{DynamicResource ButtonCalculatorCanvas}">
<Canvas.Children>
<ContentControl ContentTemplate="{DynamicResource ButtonCalculatorRectangle}"/>
<Path Data="M 12 6 h 12 v 6 l -12 6 z" Fill="{DynamicResource CalculatorFrame}"/>
<Path Data="M 12 26 h -6 v -4 l 6 -5 z" Fill="{DynamicResource CalculatorFrame}"/>
<Line X1="12" Y1="5" X2="12" Y2="26" Stroke="Black"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="ValuePointDiagram"> <DataTemplate x:Key="ValuePointDiagram">
<Canvas Style="{DynamicResource ButtonResultCanvas}"> <Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children> <Canvas.Children>

View File

@@ -36,5 +36,10 @@
<Image Width="16" Height="16" Source="/Windows/MainWindow/ToBackground.png" /> <Image Width="16" Height="16" Source="/Windows/MainWindow/ToBackground.png" />
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
<Separator/>
<MenuItem Header="Set as host" Command="{Binding SetAsHostCommand}">
</MenuItem>
<MenuItem Header="Set material to primitives" Command="{Binding SetMaterialToPrimitivesCommand}"/>
<MenuItem Header="Set host to primitives" Command="{Binding SetHostToPrimitivesCommand}"/>
</ContextMenu> </ContextMenu>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -78,6 +78,12 @@
<Compile Update="Windows\CalculationWindows\CalculatorsViews\SelectResultsForExportView.xaml.cs"> <Compile Update="Windows\CalculationWindows\CalculatorsViews\SelectResultsForExportView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\CalculationWindows\CalculatorsViews\ValueDiagrams\ValueDiagramCalculatorView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\CalculationWindows\CalculatorsViews\ValueDiagrams\ValueDiagramEntityView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\CalculationWindows\ProgressViews\ShowProgressView.xaml.cs"> <Compile Update="Windows\CalculationWindows\ProgressViews\ShowProgressView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>

View File

@@ -46,7 +46,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private ShowProgressLogic showProgressLogic; private ShowProgressLogic showProgressLogic;
private InteractionDiagramLogic interactionDiagramLogic; private InteractionDiagramLogic interactionDiagramLogic;
private static readonly ShowCrackResultLogic showCrackResultLogic = new(); private static readonly ShowCrackResultLogic showCrackResultLogic = new();
//private static readonly ShowCrackWidthLogic showCrackWidthLogic = new();
private IForceCalculatorResult resultModel; private IForceCalculatorResult resultModel;
private IEnumerable<INdmPrimitive> ndmPrimitives; private IEnumerable<INdmPrimitive> ndmPrimitives;
private IEnumerable<INdmPrimitive> selectedNdmPrimitives; private IEnumerable<INdmPrimitive> selectedNdmPrimitives;

View File

@@ -0,0 +1,55 @@
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Windows.UserControls.States;
using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
{
public class ValueDiagramCalculatorInputDataViewModel : ViewModelBase
{
private IValueDiagramCalculatorInputData inputData;
private ICrossSectionRepository repository;
public bool CheckStrainLimit
{
get => inputData.CheckStrainLimit;
set
{
inputData.CheckStrainLimit = value;
OnPropertyChanged(nameof(CheckStrainLimit));
}
}
public SourceTargetVM<IForceAction> CombinationViewModel { get; }
public SourceTargetVM<PrimitiveBase> PrimitivesViewModel { get; }
public StateCalcTermPairViewModel StateCalcTermPairViewModel { get; }
public ValueDiagramsViewModel ValueDiagramsViewModel { get; }
public ValueDiagramCalculatorInputDataViewModel(ICrossSectionRepository repository, IValueDiagramCalculatorInputData inputData)
{
this.inputData = inputData;
this.repository = repository;
StateCalcTermPairViewModel = new(inputData.StateTermPair);
ValueDiagramsViewModel = new(inputData.Digrams);
CombinationViewModel = SourceTargetFactory.GetSourceTargetVM(repository.ForceActions, inputData.ForceActions);
PrimitivesViewModel = SourceTargetFactory.GetSourceTargetVM(repository.Primitives, inputData.Primitives);
}
public void Refresh()
{
var combinations = CombinationViewModel.GetTargetItems();
inputData.ForceActions.Clear();
foreach (var item in combinations)
{
inputData.ForceActions.Add(item);
}
inputData.Primitives.Clear();
foreach (var item in PrimitivesViewModel.GetTargetItems())
{
inputData.Primitives.Add(item.GetNdmPrimitive());
}
}
}
}

View File

@@ -0,0 +1,115 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams.ValueDiagramCalculatorView"
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.CalculationWindows.CalculatorsViews.ValueDiagrams"
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums"
d:DataContext="{d:DesignInstance local:ValueDiagramCalculatorViewModel}"
mc:Ignorable="d"
Title="Value Diagram Calculator" Height="250" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Closing="Window_Closing">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="Main">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Name"/>
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Name}"/>
<TextBlock Grid.Row="1" Text="Show trace data"/>
<CheckBox Grid.Column="1" Grid.Row="1" Margin="0,3" IsChecked="{Binding ShowTraceData}"/>
<TextBlock Grid.Row="2" Text="Limit state"/>
<ComboBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding InputDataViewModel.StateCalcTermPairViewModel.LimitStatesCollection}" SelectedItem="{Binding InputDataViewModel.StateCalcTermPairViewModel.LimitState}"/>
<TextBlock Grid.Row="3" Text="Calc term"/>
<ComboBox Grid.Column="1" Grid.Row="3" ItemsSource="{Binding InputDataViewModel.StateCalcTermPairViewModel.CalcTermsCollection}" SelectedItem="{Binding InputDataViewModel.StateCalcTermPairViewModel.CalcTerm}"/>
</Grid>
</TabItem>
<TabItem Header="Forces">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding InputDataViewModel.CombinationViewModel}"/>
</TabItem>
<TabItem Header="Primitives">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding InputDataViewModel.PrimitivesViewModel}"/>
</TabItem>
<TabItem Header="Value diagrams" DataContext="{Binding InputDataViewModel.ValueDiagramsViewModel}">
<DockPanel>
<ToolBarTray DockPanel.Dock="Top">
<ToolBar Name="Add">
<Button Style="{DynamicResource ToolButton24}" Command="{Binding Add}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Add vertex"
IconContent="{StaticResource AddEntity}"
DescriptionText="Adds new vertex in the and of polygon"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{StaticResource AddEntity}"/>
</Viewbox>
</Button>
<Button Style="{StaticResource ToolButton24}" Command="{Binding Copy}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Copy Analysis"
IconContent="{StaticResource CopyAnalysis}"
DescriptionText="Creates copy of selected analysis"/>
</Button.ToolTip>
<Viewbox Width="24" Height="24">
<ContentControl ContentTemplate="{DynamicResource CopyAnalysis}"/>
</Viewbox>
</Button>
<Button Style="{StaticResource ToolButton24}" Command="{Binding Edit}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Edit Analysis"
IconContent="{StaticResource EditAnalysis}"
DescriptionText="Edit selected analysis"/>
</Button.ToolTip>
<Viewbox Width="24" Height="24">
<ContentControl ContentTemplate="{DynamicResource EditAnalysis}"/>
</Viewbox>
</Button>
</ToolBar>
<ToolBar Name="Delete">
<Button Style="{DynamicResource ToolButton24}" Command="{Binding Delete}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Delete digram"
IconContent="{StaticResource TableRowDelete}"
DescriptionText="Removes selected vertex"/>
</Button.ToolTip>
<Viewbox Width="24" Height="24">
<ContentControl ContentTemplate="{DynamicResource DeleteEntity}"/>
</Viewbox>
</Button>
</ToolBar>
</ToolBarTray>
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsTaken}"/>
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</TabItem>
</TabControl>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -0,0 +1,25 @@
using System.Windows;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
{
/// <summary>
/// Логика взаимодействия для ValueDiagramCalculatorView.xaml
/// </summary>
public partial class ValueDiagramCalculatorView : Window
{
private ValueDiagramCalculatorViewModel vm;
public ValueDiagramCalculatorView(ValueDiagramCalculatorViewModel vm)
{
this.vm = vm;
vm.ParentWindow = this;
this.DataContext = this.vm;
InitializeComponent();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
vm.Refresh();
}
}
}

View File

@@ -0,0 +1,42 @@
using StructureHelper.Windows.ViewModels;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
{
public class ValueDiagramCalculatorViewModel : OkCancelViewModelBase
{
private IValueDiagramCalculator valueDiagramCalculator;
public bool ShowTraceData
{
get => valueDiagramCalculator.ShowTraceData;
set
{
valueDiagramCalculator.ShowTraceData = value;
OnPropertyChanged(nameof(ShowTraceData));
}
}
public string Name
{
get => valueDiagramCalculator.Name;
set
{
valueDiagramCalculator.Name = value;
OnPropertyChanged(nameof(Name));
}
}
public ValueDiagramCalculatorInputDataViewModel InputDataViewModel { get; set; }
public ValueDiagramCalculatorViewModel(ICrossSectionRepository repository, IValueDiagramCalculator valueDiagramCalculator)
{
this.valueDiagramCalculator = valueDiagramCalculator;
InputDataViewModel = new(repository, valueDiagramCalculator.InputData);
}
public void Refresh()
{
InputDataViewModel.Refresh();
}
}
}

View File

@@ -0,0 +1,58 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams.ValueDiagramEntityView"
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.CalculationWindows.CalculatorsViews.ValueDiagrams"
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums"
d:DataContext="{d:DesignInstance local:ValueDiagramEntityViewModel}"
mc:Ignorable="d"
Title="Value Diagram" Height="250" Width="300" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="15"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Take"/>
<CheckBox Grid.Column="1" Margin="0,3" IsChecked="{Binding IsTaken}"/>
<TextBlock Grid.Row="1" Text="Name"/>
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Name}"/>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="1" Grid.Row="0" Margin="30,0,0,0" Text="X"/>
<TextBlock Grid.Column="2" Grid.Row="0" Margin="30,0,0,0" Text="Y"/>
<TextBlock Grid.Row="1" Text="Start point"/>
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding ValueDiagram.Point2DRange.StartPoint.X, Converter={StaticResource LengthConverter}}"/>
<TextBox Grid.Column="2" Grid.Row="1" Text="{Binding ValueDiagram.Point2DRange.StartPoint.Y, Converter={StaticResource LengthConverter}}"/>
<TextBlock Grid.Row="2" Text="End point"/>
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding ValueDiagram.Point2DRange.EndPoint.X, Converter={StaticResource LengthConverter}}"/>
<TextBox Grid.Column="2" Grid.Row="2" Text="{Binding ValueDiagram.Point2DRange.EndPoint.Y, Converter={StaticResource LengthConverter}}"/>
</Grid>
</StackPanel>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -0,0 +1,20 @@
using System.Windows;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
{
/// <summary>
/// Логика взаимодействия для ValueDiagramEntityView.xaml
/// </summary>
public partial class ValueDiagramEntityView : Window
{
private readonly ValueDiagramEntityViewModel viewModel;
public ValueDiagramEntityView(ValueDiagramEntityViewModel viewModel)
{
InitializeComponent();
this.viewModel = viewModel;
this.DataContext = this.viewModel;
viewModel.ParentWindow = this;
}
}
}

View File

@@ -0,0 +1,37 @@
using StructureHelper.Windows.ViewModels;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
{
public class ValueDiagramEntityViewModel : OkCancelViewModelBase
{
private IValueDiagramEntity valueDiagramEntity;
public bool IsTaken
{
get => valueDiagramEntity.IsTaken;
set
{
valueDiagramEntity.IsTaken = value;
OnPropertyChanged(nameof(IsTaken));
}
}
public string Name
{
get => valueDiagramEntity.Name;
set
{
valueDiagramEntity.Name = value;
OnPropertyChanged(nameof(Name));
}
}
public ValueDiagramViewModel ValueDiagram { get; set; }
public ValueDiagramEntityViewModel(IValueDiagramEntity valueDiagramEntity)
{
this.valueDiagramEntity = valueDiagramEntity;
ValueDiagram = new(valueDiagramEntity.ValueDigram);
}
}
}

View File

@@ -0,0 +1,29 @@
using StructureHelper.Infrastructure;
using StructureHelper.Windows.Shapes;
using StructureHelper.Windows.ViewModels;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
{
public class ValueDiagramViewModel : ViewModelBase
{
private IValueDiagram valueDiagram;
public int StepNumber
{
get => valueDiagram.StepNumber;
set
{
valueDiagram.StepNumber = value;
OnPropertyChanged(nameof(StepNumber));
}
}
public Point2DRangeViewModel Point2DRange { get; set; }
public ValueDiagramViewModel(IValueDiagram valueDiagram)
{
this.valueDiagram = valueDiagram;
Point2DRange = new(valueDiagram.Point2DRange);
}
}
}

View File

@@ -0,0 +1,53 @@
using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.BeamShears;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
{
public class ValueDiagramsViewModel : SelectItemVM<IValueDiagramEntity>
{
private IUpdateStrategy<IValueDiagramEntity> updateStrategy;
public override void AddMethod(object parameter)
{
NewItem = new ValueDiagramEntity(Guid.NewGuid())
{
IsTaken = true,
Name = "New Value Diagram"
};
NewItem.ValueDigram.StepNumber = 50;
NewItem.ValueDigram.Point2DRange.StartPoint.Y = 0.25;
NewItem.ValueDigram.Point2DRange.EndPoint.Y = - 0.25;
base.AddMethod(parameter);
}
public override void EditMethod(object parameter)
{
if (SelectedItem is null) { return; }
IValueDiagramEntity cloneDiagram = (IValueDiagramEntity)SelectedItem.Clone();
var vm = new ValueDiagramEntityViewModel(SelectedItem);
var wnd = new ValueDiagramEntityView(vm);
wnd.ShowDialog();
if (wnd.DialogResult != true)
{
updateStrategy ??= new ValueDiagramEntityUpdateStrategy();
updateStrategy.Update(SelectedItem, cloneDiagram);
}
base.EditMethod(parameter);
}
public override void DeleteMethod(object parameter)
{
var dialogResult = MessageBox.Show("Delete diagram?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
base.DeleteMethod(parameter);
}
}
public ValueDiagramsViewModel(List<IValueDiagramEntity> collection) : base(collection)
{
}
}
}

View File

@@ -1,7 +1,9 @@
using StructureHelper.Infrastructure; using LoaderCalculator;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums; using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews; using StructureHelper.Windows.CalculationWindows.CalculatorsViews;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews; using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams;
using StructureHelper.Windows.CalculationWindows.ProgressViews; using StructureHelper.Windows.CalculationWindows.ProgressViews;
using StructureHelper.Windows.Errors; using StructureHelper.Windows.Errors;
using StructureHelper.Windows.ViewModels.Calculations.Calculators; using StructureHelper.Windows.ViewModels.Calculations.Calculators;
@@ -12,7 +14,9 @@ using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.Logics; using StructureHelperLogics.NdmCalculations.Analyses.Logics;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Cracking;
using System;
using System.Windows; using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using MessageBox = System.Windows.Forms.MessageBox; using MessageBox = System.Windows.Forms.MessageBox;
@@ -49,12 +53,26 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{ {
AddCrackCalculator(); AddCrackCalculator();
} }
else if (parameterType == CalculatorTypes.ValueDiagram)
{
AddValueDiagramCalculator();
}
else else
{ {
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(parameterType)); throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(parameterType));
} }
} }
private void AddValueDiagramCalculator()
{
var calculator = new ValueDiagramCalculator(Guid.NewGuid())
{
Name = "New value diagram calculator",
ShowTraceData = false,
};
NewItem = calculator;
}
private void AddCrackCalculator() private void AddCrackCalculator()
{ {
var inputData = new CrackCalculatorInputData(); var inputData = new CrackCalculatorInputData();
@@ -113,9 +131,21 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
if (SelectedItem is ForceCalculator forceCalculator) { EditForceCalculator(forceCalculator);} if (SelectedItem is ForceCalculator forceCalculator) { EditForceCalculator(forceCalculator);}
else if (SelectedItem is LimitCurvesCalculator limitCurvesCalculator) { EditLimitCurveCalculator(limitCurvesCalculator); } else if (SelectedItem is LimitCurvesCalculator limitCurvesCalculator) { EditLimitCurveCalculator(limitCurvesCalculator); }
else if (SelectedItem is CrackCalculator crackCalculator) { EditCrackCalculator(crackCalculator);} else if (SelectedItem is CrackCalculator crackCalculator) { EditCrackCalculator(crackCalculator);}
else if (SelectedItem is IValueDiagramCalculator valueDiagramCalculator)
{
EditValueDiagramCalculator(valueDiagramCalculator);
}
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));} else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));}
} }
private void EditValueDiagramCalculator(IValueDiagramCalculator sourceCalculator)
{
var calculatorClone = sourceCalculator.Clone() as IValueDiagramCalculator;
var vm = new ValueDiagramCalculatorViewModel(repository, sourceCalculator);
var wnd = new ValueDiagramCalculatorView(vm);
ShowWindow(sourceCalculator, calculatorClone, wnd);
}
private void EditCrackCalculator(CrackCalculator calculator) private void EditCrackCalculator(CrackCalculator calculator)
{ {
var calculatorCopy = calculator.Clone() as CrackCalculator; var calculatorCopy = calculator.Clone() as CrackCalculator;

View File

@@ -15,7 +15,7 @@
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:CrossSectionViewModel}" d:DataContext="{d:DesignInstance local:CrossSectionViewModel}"
Title="Cross-Section NDM Analysis" Height="700" Width="1100" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen"> Title="Cross-Section NDM Analysis" Height="700" Width="1000" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen">
<Window.Resources> <Window.Resources>
<DataTemplate DataType="{x:Type dataContexts:RectangleViewPrimitive}"> <DataTemplate DataType="{x:Type dataContexts:RectangleViewPrimitive}">
<dataTemplates:RectangleTemplate/> <dataTemplates:RectangleTemplate/>
@@ -67,6 +67,66 @@
<Image Source="/Windows/MainWindow/Materials32.png"/> <Image Source="/Windows/MainWindow/Materials32.png"/>
</Button> </Button>
</ToolBar> </ToolBar>
<ToolBar ToolTip="RC Templates">
<Button Style="{StaticResource ToolButton}" Command="{Binding AddColumnCase}" ToolTip="Add Rectangle RC Column">
<Image Source="/Windows/MainWindow/RectangleColumn32.png"/>
</Button>
<Button Style="{StaticResource ToolButton}" Command="{Binding AddRCCircleCase}" ToolTip="Add Circle RC Column">
<Image Source="/Windows/MainWindow/CircleColumn32.png"/>
</Button>
<Button Style="{StaticResource ToolButton}" Command="{Binding AddBeamCase}" ToolTip="Add RC Beam">
<Image Source="/Windows/MainWindow/Beam32.png"/>
</Button>
<Button Style="{StaticResource ToolButton}" Command="{Binding AddSlabCase}" ToolTip="Add RC Slab">
<Image Source="/Windows/MainWindow/Slab32.png"/>
</Button>
</ToolBar>
<ToolBar ToolTip="Analises" DataContext="{Binding CalculatorsLogic}">
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ForceCalculator}" ToolTip="Add Force Calculator">
<Image Source="/Windows/MainWindow/Calculator32.png"/>
</Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.LimitCurveCalculator}" ToolTip="Add Interaction Diagram Calculator">
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource DiagramCalculator}"/>
</Viewbox>
</Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.CrackCalculator}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Add Crack Calculator"
IconContent="{StaticResource Polygon}"
DescriptionText="Adds calculator for design reinforced concrete cross-section for crack width"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource CrackCalculator}"/>
</Viewbox>
</Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ValueDiagram}" >
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Add Value Diagram Calctulator"
IconContent="{StaticResource ValueDiagramCalculator}"
DescriptionText="Adds new calculator for creating diagram of results on line of cross-section"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{StaticResource ValueDiagramCalculator}"/>
</Viewbox>
</Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding Run}" ToolTip="Run Calculations">
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource CalculatorRun}"/>
</Viewbox>
</Button>
</ToolBar>
<ToolBar ToolTip="Tools">
<Button Style="{StaticResource ToolButton}" Command="{Binding MovePrimitiveToGravityCenterCommand}" ToolTip="Move All Primitives to Gravity Center">
<Image Source="/Windows/MainWindow/MovePrimitivesToCenter.png"/>
</Button>
<Button Style="{StaticResource ToolButton}" Command="{Binding ShowVisualProperty}" ToolTip="Visual Settings">
<Image Source="/Windows/MainWindow/Tools_Settings.png"/>
</Button>
</ToolBar>
</ToolBarTray>
<ToolBarTray DockPanel.Dock="Top">
<ToolBar ToolTip="Base Primitives" DataContext="{Binding PrimitiveLogic}"> <ToolBar ToolTip="Base Primitives" DataContext="{Binding PrimitiveLogic}">
<Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Polygon}" > <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Polygon}" >
<Button.ToolTip> <Button.ToolTip>
@@ -91,47 +151,27 @@
<Image Source="/Windows/MainWindow/Point32.png"/> <Image Source="/Windows/MainWindow/Point32.png"/>
</Button> </Button>
</ToolBar> </ToolBar>
<ToolBar ToolTip="RC Templates"> <ToolBar Name="DxfOperation">
<Button Style="{StaticResource ToolButton}" Command="{Binding AddColumnCase}" ToolTip="Add Rectangle RC Column"> <Button Style="{DynamicResource ToolButton}" Command="{Binding ExportToDxfCommand}">
<Image Source="/Windows/MainWindow/RectangleColumn32.png"/> <Button.ToolTip>
</Button> <uc:ButtonToolTipEh HeaderText="Export to *.dxf file"
<Button Style="{StaticResource ToolButton}" Command="{Binding AddRCCircleCase}" ToolTip="Add Circle RC Column"> IconContent="{StaticResource ExportToDxf}"
<Image Source="/Windows/MainWindow/CircleColumn32.png"/> DescriptionText="Exports poligon to new *.dxf file"/>
</Button> </Button.ToolTip>
<Button Style="{StaticResource ToolButton}" Command="{Binding AddBeamCase}" ToolTip="Add RC Beam">
<Image Source="/Windows/MainWindow/Beam32.png"/>
</Button>
<Button Style="{StaticResource ToolButton}" Command="{Binding AddSlabCase}" ToolTip="Add RC Slab">
<Image Source="/Windows/MainWindow/Slab32.png"/>
</Button>
</ToolBar>
<ToolBar ToolTip="Analises" DataContext="{Binding CalculatorsLogic}">
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ForceCalculator}" ToolTip="Add Force Calculator">
<Image Source="/Windows/MainWindow/Calculator32.png"/>
</Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.LimitCurveCalculator}" ToolTip="Add Interaction Diagram Calculator">
<Viewbox> <Viewbox>
<ContentControl ContentTemplate="{DynamicResource DiagramCalculator}"/> <ContentControl ContentTemplate="{StaticResource ExportToDxf}"/>
</Viewbox> </Viewbox>
</Button> </Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.CrackCalculator}" ToolTip="Add Crack Calculator"> <Button Style="{DynamicResource ToolButton}" Command="{Binding ImportFromDxfCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Import from *.dxf file"
IconContent="{StaticResource ImportFromDxf}"
DescriptionText="Imports poligon from *.dxf file"/>
</Button.ToolTip>
<Viewbox> <Viewbox>
<ContentControl ContentTemplate="{DynamicResource CrackCalculator}"/> <ContentControl ContentTemplate="{StaticResource ImportFromDxf}"/>
</Viewbox> </Viewbox>
</Button> </Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding Run}" ToolTip="Run Calculations">
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource CalculatorRun}"/>
</Viewbox>
</Button>
</ToolBar>
<ToolBar ToolTip="Tools">
<Button Style="{StaticResource ToolButton}" Command="{Binding MovePrimitiveToGravityCenterCommand}" ToolTip="Move All Primitives to Gravity Center">
<Image Source="/Windows/MainWindow/MovePrimitivesToCenter.png"/>
</Button>
<Button Style="{StaticResource ToolButton}" Command="{Binding ShowVisualProperty}" ToolTip="Visual Settings">
<Image Source="/Windows/MainWindow/Tools_Settings.png"/>
</Button>
</ToolBar> </ToolBar>
</ToolBarTray> </ToolBarTray>
<Grid> <Grid>
@@ -214,8 +254,33 @@
</Expander.ContextMenu> </Expander.ContextMenu>
<ListBox ItemsSource="{Binding Items}" <ListBox ItemsSource="{Binding Items}"
SelectedItem="{Binding SelectedItem}" SelectedItem="{Binding SelectedItem}"
ItemTemplate="{StaticResource ColoredItemTemplate}" ItemTemplate="{StaticResource ColoredItemTemplate}">
ContextMenu="{StaticResource EditCopyDelete}"/> <ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Edit" Command="{Binding Edit}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Edit.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Copy" Command="{Binding Copy}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Copy.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Delete" Command="{Binding Delete}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Delete.png" />
</MenuItem.Icon>
</MenuItem>
<Separator/>
<MenuItem Header="Set material" Command="{Binding SetMaterialToPrimititveCommand}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Materials32.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
</Expander> </Expander>
<Expander Header="Geometry" MinWidth="20"> <Expander Header="Geometry" MinWidth="20">
<Expander.ContextMenu> <Expander.ContextMenu>
@@ -278,6 +343,13 @@
</Viewbox> </Viewbox>
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
<MenuItem Header="Add Value Diagram Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ValueDiagram}">
<MenuItem.Icon>
<Viewbox Width="16" Height="16">
<ContentControl ContentTemplate="{DynamicResource ValueDiagramCalculator}"/>
</Viewbox>
</MenuItem.Icon>
</MenuItem>
</MenuItem> </MenuItem>
</ContextMenu> </ContextMenu>
</Expander.ContextMenu> </Expander.ContextMenu>

View File

@@ -2,6 +2,7 @@
using StructureHelper.Infrastructure; using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials; using StructureHelper.Models.Materials;
using StructureHelper.Services.Exports;
using StructureHelper.Windows.PrimitiveTemplates.RCs.Beams; using StructureHelper.Windows.PrimitiveTemplates.RCs.Beams;
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam; using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
using StructureHelper.Windows.ViewModels; using StructureHelper.Windows.ViewModels;
@@ -11,6 +12,8 @@ using StructureHelper.Windows.ViewModels.Materials;
using StructureHelper.Windows.ViewModels.NdmCrossSections; using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Services.Exports;
using StructureHelperCommon.Services.Exports.Factories;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Templates.CrossSections.RCs; using StructureHelperLogics.Models.Templates.CrossSections.RCs;
using StructureHelperLogics.Models.Templates.RCs; using StructureHelperLogics.Models.Templates.RCs;
@@ -125,10 +128,43 @@ namespace StructureHelper.Windows.MainWindow
} }
} }
public ICommand ExportToDxfCommand => exportToDxfCommand ??= new RelayCommand(ExportToDxf);
public ICommand ImportFromDxfCommand => importFromDxfCommand ??= new RelayCommand(ImportFromDxf);
private void ImportFromDxf(object obj)
{
SafetyProcessor.RunSafeProcess(ImportFromDxfFile, "Error of opening file");
}
private void ImportFromDxfFile()
{
FileIOInputData inputData = FileInputDataFactory.GetFileIOInputData(FileInputDataType.Dxf);
var logic = new GetPrimitivesByFile();
var importService = new ImportFromFileService(inputData, logic);
importService.Import();
var ndmPrimitives = logic.Primitives;
var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(ndmPrimitives);
repository.Primitives.AddRange(ndmPrimitives);
PrimitiveLogic.AddItems(primitives);
PrimitiveLogic.Refresh();
}
private void ExportToDxf(object commandParameter)
{
FileIOInputData inputData = FileInputDataFactory.GetFileIOInputData(FileInputDataType.Dxf);
var convertLogic = new NdmPrimitivesToDxfEntitiesConvertStrategy();
var entities = convertLogic.Convert(repository.Primitives);
var logic = new EntitiesToDxfExportLogic() { Entities = entities };
var exportService = new ExportToFileService(inputData, logic);
exportService.Export();
}
private RelayCommand showVisualProperty; private RelayCommand showVisualProperty;
private RelayCommand selectPrimitive; private RelayCommand selectPrimitive;
private RelayCommand fileDroppedCommand; private RelayCommand fileDroppedCommand;
private string fileName; private string fileName;
private RelayCommand exportToDxfCommand;
private RelayCommand importFromDxfCommand;
public ICommand FileDroppedCommand => fileDroppedCommand ??= new RelayCommand(OnFileDropped); public ICommand FileDroppedCommand => fileDroppedCommand ??= new RelayCommand(OnFileDropped);
@@ -136,15 +172,10 @@ namespace StructureHelper.Windows.MainWindow
{ {
if (obj is string[] files && files.Length > 0) if (obj is string[] files && files.Length > 0)
{ {
fileName = files.First(); foreach (var filenameString in files)
string extension = Path.GetExtension(fileName).ToLowerInvariant();
if (extension == ".dxf")
{ {
SafetyProcessor.RunSafeProcess(GetPrimitivesFromFile,"Error of obtaining of primitives, see detail information"); fileName = filenameString;
} ProcessDxfFile();
else
{
System.Windows.MessageBox.Show($"Unsupported file type: {extension}");
} }
} }
else else
@@ -153,6 +184,19 @@ namespace StructureHelper.Windows.MainWindow
} }
} }
private void ProcessDxfFile()
{
string extension = Path.GetExtension(fileName).ToLowerInvariant();
if (extension == ".dxf")
{
SafetyProcessor.RunSafeProcess(GetPrimitivesFromFile, "Error of obtaining of primitives, see detail information");
}
else
{
System.Windows.MessageBox.Show($"Unsupported file type: {extension}");
}
}
private void GetPrimitivesFromFile() private void GetPrimitivesFromFile()
{ {
var importFromFileLogic = new GetPrimitivesByFile() { FileName = fileName }; var importFromFileLogic = new GetPrimitivesByFile() { FileName = fileName };

View File

@@ -9,6 +9,7 @@ using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Primitives; using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using System; using System;
@@ -34,7 +35,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private ICommand setToFront; private ICommand setToFront;
private ICommand setToBack; private ICommand setToBack;
private ICommand copyToCommand; private ICommand copyToCommand;
private RelayCommand setAsHostCommand;
private RelayCommand setMaterialToPrimitivesCommand;
private RelayCommand setHostToPrimitivesCommand;
public double Width { get; set; } public double Width { get; set; }
public double Height { get; set; } public double Height { get; set; }
@@ -43,6 +46,72 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
public ObservableCollection<PrimitiveBase> Items { get; private set; } public ObservableCollection<PrimitiveBase> Items { get; private set; }
public ICommand SetAsHostCommand => setAsHostCommand ??= new RelayCommand(SetPrimititveAsHost,
o => SelectedItem != null
&& SelectedItem.NdmPrimitive is IHasDivisionSize);
public ICommand SetHostToPrimitivesCommand => setHostToPrimitivesCommand ??= new RelayCommand(SetHostToPrimitives,
o => SelectedItem != null
&& SelectedItem.NdmPrimitive is IHasHostPrimitive);
private void SetHostToPrimitives(object obj)
{
if (SelectedItem is null) { return; }
var newHost = (SelectedItem.NdmPrimitive as IHasHostPrimitive).HostPrimitive;
SetNewHost(newHost);
}
public ICommand SetMaterialToPrimitivesCommand => setMaterialToPrimitivesCommand ??= new RelayCommand(SetMaterialToPrimitives,
o => SelectedItem != null
&& SelectedItem
.NdmPrimitive
.NdmElement
.HeadMaterial != null);
private void SetMaterialToPrimitives(object obj)
{
if (SelectedItem is null) { return; }
var material = SelectedItem.NdmPrimitive.NdmElement.HeadMaterial;
if (material == null) { return; };
var vm = new SelectPrimitivesViewModel(repository.Primitives);
var wnd = new SelectPrimitivesView(vm);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
var selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive());
foreach (var item in selectedNdmPrimitives)
{
item.NdmElement.HeadMaterial = material;
}
Refresh();
}
}
private void SetPrimititveAsHost(object obj)
{
if (SelectedItem is null) { return; }
var newHost = SelectedItem.NdmPrimitive;
SetNewHost(newHost);
}
private void SetNewHost(INdmPrimitive newHost)
{
var vm = new SelectPrimitivesViewModel(repository.Primitives.Where(x => x is IHasHostPrimitive));
var wnd = new SelectPrimitivesView(vm);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
var selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive());
var hasHostPrimitives = selectedNdmPrimitives.Where(x => x is IHasHostPrimitive);
foreach (var item in hasHostPrimitives)
{
IHasHostPrimitive hostPrimitive = item as IHasHostPrimitive;
hostPrimitive.HostPrimitive = newHost;
}
Refresh();
}
}
public ICommand Add public ICommand Add
{ {
get get
@@ -191,6 +260,11 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
var forceCalc = crackCalculator.InputData as IHasPrimitives; var forceCalc = crackCalculator.InputData as IHasPrimitives;
forceCalc.Primitives.Remove(ndmPrimitive); forceCalc.Primitives.Remove(ndmPrimitive);
} }
else if (calc is IValueDiagramCalculator diagramCalculator)
{
var forceCalc = diagramCalculator.InputData as IHasPrimitives;
forceCalc.Primitives.Remove(ndmPrimitive);
}
else else
{ {
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc)); throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc));

View File

@@ -2,9 +2,11 @@
using StructureHelper.Infrastructure.Enums; using StructureHelper.Infrastructure.Enums;
using StructureHelper.Models.Materials; using StructureHelper.Models.Materials;
using StructureHelper.Windows.MainWindow.Materials; using StructureHelper.Windows.MainWindow.Materials;
using StructureHelper.Windows.PrimitivePropertiesWindow;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials; using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Primitives;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
@@ -46,7 +48,6 @@ namespace StructureHelper.Windows.ViewModels.Materials
else if (parameterType == MaterialType.CarbonFiber) { AddCarbonFiber(); } else if (parameterType == MaterialType.CarbonFiber) { AddCarbonFiber(); }
else if (parameterType == MaterialType.GlassFiber) { AddGlassFiber(); } else if (parameterType == MaterialType.GlassFiber) { AddGlassFiber(); }
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)}, Actual type: {nameof(parameterType)}"); else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)}, Actual type: {nameof(parameterType)}");
//GlobalRepository.Materials.Create(NewItem);
base.AddMethod(parameter); base.AddMethod(parameter);
} }
public override void DeleteMethod(object parameter) public override void DeleteMethod(object parameter)
@@ -133,5 +134,25 @@ namespace StructureHelper.Windows.ViewModels.Materials
wnd.ShowDialog(); wnd.ShowDialog();
Refresh(); Refresh();
} }
private RelayCommand setMaterialToPrimititveCommand;
public ICommand SetMaterialToPrimititveCommand => setMaterialToPrimititveCommand ??= new RelayCommand(SetMaterialToPrimititve, o => SelectedItem != null);
private void SetMaterialToPrimititve(object commandParameter)
{
if (SelectedItem is null) { return; }
var vm = new SelectPrimitivesViewModel(repository.Primitives);
var wnd = new SelectPrimitivesView(vm);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
var selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive());
foreach (var item in selectedNdmPrimitives)
{
item.NdmElement.HeadMaterial = SelectedItem;
}
Refresh();
}
}
} }
} }

View File

@@ -0,0 +1,20 @@
using StructureHelperCommon.Models.Shapes;
namespace StructureHelper.Windows.Shapes
{
public class Point2DRangeViewModel
{
private IPoint2DRange point2DRange;
public string StartPointName { get; set; } = "Start point";
public string EndPointName { get; set; } = "End point";
public Point2DViewModel StartPoint { get; private set; }
public Point2DViewModel EndPoint { get; private set; }
public Point2DRangeViewModel(IPoint2DRange point2DRange)
{
this.point2DRange = point2DRange;
StartPoint = new(point2DRange.StartPoint);
EndPoint = new(point2DRange.EndPoint);
}
}
}

View File

@@ -0,0 +1,38 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.States;
using System.Collections.Generic;
namespace StructureHelper.Windows.UserControls.States
{
public class StateCalcTermPairViewModel : ViewModelBase
{
private IStateCalcTermPair stateCalcTermPair;
public List<LimitStates> LimitStatesCollection { get; set; } = [LimitStates.ULS, LimitStates.SLS];
public List<CalcTerms> CalcTermsCollection { get; set; } = [CalcTerms.ShortTerm, CalcTerms.LongTerm];
public LimitStates LimitState
{
get => stateCalcTermPair.LimitState;
set
{
stateCalcTermPair.LimitState = value;
OnPropertyChanged(nameof(LimitStates));
}
}
public CalcTerms CalcTerm
{
get => stateCalcTermPair.CalcTerm;
set
{
stateCalcTermPair.CalcTerm = value;
OnPropertyChanged(nameof(CalcTerms));
}
}
public StateCalcTermPairViewModel(IStateCalcTermPair stateCalcTermPair)
{
this.stateCalcTermPair = stateCalcTermPair;
}
}
}

View File

@@ -10,6 +10,7 @@ using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics; using StructureHelperCommon.Models.Forces.Logics;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Cracking;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -75,8 +76,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {
if (DeleteAction() != true) return; DeleteAction();
//GlobalRepository.Actions.Delete(SelectedItem.Id);
base.DeleteMethod(parameter); base.DeleteMethod(parameter);
} }
} }
@@ -126,48 +126,36 @@ namespace StructureHelper.Windows.ViewModels.Forces
this.repository = repository; this.repository = repository;
} }
private bool DeleteAction() private void DeleteAction()
{ {
bool result = true;
var calcRepository = repository.Calculators; var calcRepository = repository.Calculators;
IHasForceActions forceCombinations;
foreach (var calc in calcRepository) foreach (var calc in calcRepository)
{ {
if (calc is ForceCalculator forceCalculator) if (calc is IForceCalculator forceCalculator)
{ {
var forceCombinations = forceCalculator.InputData as IHasForceActions; forceCombinations = forceCalculator.InputData;
result = DeleteActionFromHost(result, calc, forceCombinations); forceCombinations.ForceActions.Remove(SelectedItem);
} }
else if (calc is CrackCalculator crackCalculator) else if (calc is ICrackCalculator crackCalculator)
{ {
var forceCombinations = crackCalculator.InputData as IHasForceActions; forceCombinations = crackCalculator.InputData;
result = DeleteActionFromHost(result, calc, forceCombinations); forceCombinations.ForceActions.Remove(SelectedItem);
} }
else if (calc is ILimitCurvesCalculator) else if (calc is ILimitCurvesCalculator)
{ {
//nothing to do //nothing to do
} }
else if (calc is IValueDiagramCalculator diagramCalculator)
{
forceCombinations = diagramCalculator.InputData;
forceCombinations.ForceActions.Remove(SelectedItem);
}
else else
{ {
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc)); throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc));
} }
} }
return result;
}
private bool DeleteActionFromHost(bool result, ICalculator item, IHasForceActions? forceCombinations)
{
var containSelected = forceCombinations.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.Yes)
{
forceCombinations.ForceActions.Remove(SelectedItem);
}
else result = false;
}
return result;
} }
} }
} }

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Shapes namespace StructureHelperCommon.Models.Shapes
{ {
public interface IPoint2DRange : ISaveable public interface IPoint2DRange : ISaveable, ICloneable
{ {
IPoint2D StartPoint { get; set; } IPoint2D StartPoint { get; set; }
IPoint2D EndPoint { get; set; } IPoint2D EndPoint { get; set; }

View File

@@ -0,0 +1,24 @@
using netDxf;
using netDxf.Entities;
using StructureHelperCommon.Infrastructures.Interfaces;
namespace StructureHelperCommon.Models.Shapes.Logics
{
public class CircleToDxfCircleConvertStrategy : IShapeConvertStrategy<Circle, ICircleShape>
{
public double Dx { get; set; } = 0;
public double Dy { get; set; } = 0;
public double Scale { get; set; } = 1;
public Circle Convert(ICircleShape source)
{
Vector3 center = new Vector3() { X = Dx * Scale, Y = Dy * Scale};
Circle circle = new Circle()
{
Radius = source.Diameter / 2 * Scale,
Center = center,
};
return circle;
}
}
}

View File

@@ -0,0 +1,30 @@
using netDxf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StrMath = StructureMath.Geometry.Points;
namespace StructureHelperCommon.Models.Shapes
{
public class GetPointListByRange : IGetPointListByRange
{
public int StepNumber { get; set; } = 50;
public List<IPoint2D> GetPoints(IPoint2DRange range)
{
StrMath.Point2D StartPoint2D = new(range.StartPoint.X, range.StartPoint.Y);
StrMath.Point2D EndPoint2D = new(range.EndPoint.X, range.EndPoint.Y);
StrMath.PointRange pointRange = new() { StartPoint = StartPoint2D, EndPoint = EndPoint2D };
var logic = new StrMath.PointRangeInterpolate() { DivisionNumber = StepNumber };
var pointList = logic.InterpolateRange(pointRange);
List<IPoint2D> result = [];
foreach (var point in pointList)
{
result.Add(new Point2D(point.X, point.Y));
}
return result;
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Shapes
{
public interface IGetPointListByRange
{
int StepNumber { get; set; }
List<IPoint2D> GetPoints(IPoint2DRange range);
}
}

View File

@@ -0,0 +1,11 @@
using StructureHelperCommon.Infrastructures.Interfaces;
namespace StructureHelperCommon.Models.Shapes
{
public interface IShapeConvertStrategy<T, V> : IObjectConvertStrategy<T, V>
{
double Dx { get; set; }
double Dy { get; set; }
double Scale { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using netDxf.Entities;
using StructureHelperCommon.Infrastructures.Interfaces;
using System.Collections.Generic;
namespace StructureHelperCommon.Models.Shapes
{
public class LinePolygonToPolyline2DConvertStrategy : IObjectConvertStrategy<Polyline2D, ILinePolygonShape>
{
public double Dx { get; set; } = 0;
public double Dy { get; set; } = 0;
public double Scale { get; set; } = 1;
public Polyline2D Convert(ILinePolygonShape linePolygon)
{
List<Polyline2DVertex> polylineVertices = [];
foreach (var item in linePolygon.Vertices)
{
Polyline2DVertex vertex = new Polyline2DVertex((item.Point.X + Dx) * Scale, (item.Point.Y + Dy) * Scale);
polylineVertices.Add(vertex);
}
Polyline2D polyline2D = new Polyline2D(polylineVertices)
{
IsClosed = linePolygon.IsClosed,
};
return polyline2D;
}
}
}

View File

@@ -0,0 +1,20 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
namespace StructureHelperCommon.Models.Shapes
{
public class Point2DRangeUpdateStrategy : IUpdateStrategy<IPoint2DRange>
{
private IUpdateStrategy<IPoint2D> pointUpdateStrategy;
public void Update(IPoint2DRange targetObject, IPoint2DRange sourceObject)
{
CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.IsNull(targetObject.StartPoint, ": range start point");
pointUpdateStrategy ??= new Point2DUpdateStrategy();
pointUpdateStrategy.Update(targetObject.StartPoint, sourceObject.StartPoint);
CheckObject.IsNull(targetObject.EndPoint, ": range end point");
pointUpdateStrategy.Update(targetObject.EndPoint, sourceObject.EndPoint);
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
namespace StructureHelperCommon.Models.Shapes
{
public class RectangleToLinePolygonConvertStrategy : IShapeConvertStrategy<LinePolygonShape, IRectangleShape>
{
private IRectangleShape rectangle;
public double Dx { get; set; } = 0.0;
public double Dy { get; set; } = 0.0;
public double Scale { get; set; } = 1.0;
public LinePolygonShape Convert(IRectangleShape source)
{
rectangle = source;
LinePolygonShape polygon = new(Guid.NewGuid());
polygon.AddVertex(GetVertex(-1.0, 1.0));
polygon.AddVertex(GetVertex(1.0, 1.0));
polygon.AddVertex(GetVertex(1.0, -1.0));
polygon.AddVertex(GetVertex(-1.0, -1.0));
polygon.IsClosed = true;
return polygon;
}
private Vertex GetVertex(double kx, double ky)
{
double x = (kx * rectangle.Width / 2 + Dx) * Scale;
double y = (ky * rectangle.Height / 2 + Dy) * Scale;
return new(x, y);
}
}
}

View File

@@ -0,0 +1,40 @@
using netDxf.Entities;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Shapes.Logics;
namespace StructureHelperCommon.Models.Shapes
{
public class ShapeToDxfEntityConvertStrategy : IShapeConvertStrategy<EntityObject, IShape>
{
private const string ShapeTypeIsUnknown = ": Shape is unknown";
public double Dx { get; set; } = 0.0;
public double Dy { get; set; } = 0.0;
public double Scale { get; set; } = 1.0;
public EntityObject Convert(IShape source)
{
if (source is IRectangleShape rectangle)
{
var retangleConvertStrategy = new RectangleToLinePolygonConvertStrategy();
var polyline2D = Convert(retangleConvertStrategy.Convert(rectangle));
return polyline2D;
}
else if (source is ICircleShape circle)
{
var circleConvertStrategy = new CircleToDxfCircleConvertStrategy() { Dx = Dx, Dy = Dy, Scale = Scale };
var circleEntity = circleConvertStrategy.Convert(circle);
return circleEntity;
}
else if (source is ILinePolygonShape linePolygon)
{
var polygonConvertStrategy = new LinePolygonToPolyline2DConvertStrategy() { Dx = Dx, Dy = Dy, Scale = Scale };
Polyline2D polyline2D = polygonConvertStrategy.Convert(linePolygon);
return polyline2D;
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ShapeTypeIsUnknown);
}
}
}
}

View File

@@ -16,5 +16,13 @@ namespace StructureHelperCommon.Models.Shapes
{ {
Id = id; Id = id;
} }
public object Clone()
{
Point2DRange newItem = new(Guid.NewGuid());
var updateStrategy = new Point2DRangeUpdateStrategy();
updateStrategy.Update(newItem, this);
return newItem;
}
} }
} }

View File

@@ -0,0 +1,34 @@
using netDxf;
using netDxf.Entities;
using netDxf.Tables;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Services.Exports
{
public class EntitiesToDxfExportLogic : IExportToFileLogic
{
private const double metresToMillimeters = 1000.0;
private IGetDxfLayerLogic layerLogic = new GetDxfLayerLogic();
public List<(EntityObject entity, LayerNames layerName)> Entities { get; set; } = [];
public string FileName { get; set; }
public void Export()
{
DxfDocument dxf = new DxfDocument();
foreach (var shape in Entities)
{
Layer layer = layerLogic.GetOrCreateLayer(dxf, shape.layerName);
var entity = shape.entity;
entity.Layer = layer;
dxf.Entities.Add(entity);
}
dxf.Save(FileName);
}
}
}

View File

@@ -1,7 +1,6 @@
using netDxf; using netDxf;
using netDxf.Entities; using netDxf.Entities;
using netDxf.Tables; using netDxf.Tables;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using System.Collections.Generic; using System.Collections.Generic;
@@ -15,19 +14,19 @@ namespace StructureHelperCommon.Services.Exports
} }
public class ShapesExportToDxfLogic : IExportToFileLogic public class ShapesExportToDxfLogic : IExportToFileLogic
{ {
private const string ShapeTypeIsUnknown = ": Shape is unknown";
private const double metresToMillimeters = 1000.0; private const double metresToMillimeters = 1000.0;
private readonly List<(IShape shape, LayerNames layerName)> shapes = [];
private IGetDxfLayerLogic layerLogic = new GetDxfLayerLogic(); private IGetDxfLayerLogic layerLogic = new GetDxfLayerLogic();
private IShapeConvertStrategy<EntityObject, IShape> shapeConvertStrategy = new ShapeToDxfEntityConvertStrategy() { Scale = metresToMillimeters};
public List<(IShape shape, LayerNames layerName)> Shapes { get; set; } = [];
public ShapesExportToDxfLogic(List<(IShape shape, LayerNames layerName)> shapes) public ShapesExportToDxfLogic(List<(IShape shape, LayerNames layerName)> shapes)
{ {
this.shapes.AddRange(shapes); this.Shapes.AddRange(shapes);
} }
public ShapesExportToDxfLogic(IShape shape, LayerNames layerName) public ShapesExportToDxfLogic(IShape shape, LayerNames layerName)
{ {
shapes.Add((shape, layerName)); Shapes.Add((shape, layerName));
} }
public string FileName { get; set; } public string FileName { get; set; }
@@ -35,45 +34,14 @@ namespace StructureHelperCommon.Services.Exports
public void Export() public void Export()
{ {
DxfDocument dxf = new DxfDocument(); DxfDocument dxf = new DxfDocument();
foreach (var shape in shapes) foreach (var shape in Shapes)
{ {
ProcessShape(dxf, shape); Layer layer = layerLogic.GetOrCreateLayer(dxf, shape.layerName);
var entity = shapeConvertStrategy.Convert(shape.shape);
entity.Layer = layer;
dxf.Entities.Add(entity);
} }
dxf.Save(FileName); dxf.Save(FileName);
} }
private void ProcessShape(DxfDocument dxf, (IShape shape, LayerNames layerName) shape)
{
Layer layer = layerLogic.GetOrCreateLayer(dxf, shape.layerName);
ProcessShape(dxf, shape.shape, layer);
}
private void ProcessShape(DxfDocument dxf, IShape shape, Layer layer)
{
if (shape is ILinePolygonShape linePolygon)
{
ProcessLinePolygon(dxf, linePolygon, layer);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(shape) + ShapeTypeIsUnknown);
}
}
private void ProcessLinePolygon(DxfDocument dxf, ILinePolygonShape linePolygon, Layer layer)
{
List<Polyline2DVertex> polylineVertices = [];
foreach (var item in linePolygon.Vertices)
{
Polyline2DVertex vertex = new Polyline2DVertex(item.Point.X * metresToMillimeters, item.Point.Y * metresToMillimeters);
polylineVertices.Add(vertex);
}
Polyline2D polyline2D = new Polyline2D(polylineVertices)
{
Layer = layer,
IsClosed = linePolygon.IsClosed,
};
dxf.Entities.Add(polyline2D);
}
} }
} }

View File

@@ -19,6 +19,9 @@
<Reference Include="LoaderCalculator"> <Reference Include="LoaderCalculator">
<HintPath>..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath> <HintPath>..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>
</Reference> </Reference>
<Reference Include="StructureMath">
<HintPath>..\StructureHelper\Libraries\StructureMath.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,10 +1,4 @@
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {

View File

@@ -1,6 +1,7 @@
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Cracking;
namespace StructureHelperLogics.Models.Templates.CrossSections namespace StructureHelperLogics.Models.Templates.CrossSections
@@ -10,12 +11,36 @@ namespace StructureHelperLogics.Models.Templates.CrossSections
public IEnumerable<ICalculator> GetNdmCalculators() public IEnumerable<ICalculator> GetNdmCalculators()
{ {
var calculators = new List<ICalculator>(); var calculators = new List<ICalculator>();
var forceCalculator = new ForceCalculator() ForceCalculator forceCalculator = GetForceCalculator();
calculators.Add(forceCalculator);
CrackCalculator crackCalculator = GetCrackCalculator();
calculators.Add(crackCalculator);
ValueDiagramCalculator diagramCalculator = GetDiagramCalculator();
calculators.Add(diagramCalculator);
return calculators;
}
private ValueDiagramCalculator GetDiagramCalculator()
{
ValueDiagramCalculator diagramCalculator = new(Guid.NewGuid()) { Name = "New value diagram calcualtor"};
ValueDiagramEntity diagramEntity = new(Guid.NewGuid()) { Name = "New diagram" };
diagramEntity.ValueDigram.Point2DRange.StartPoint.Y = 0.25;
diagramEntity.ValueDigram.Point2DRange.EndPoint.Y = - 0.25;
diagramCalculator.InputData.Digrams.Add(diagramEntity);
return diagramCalculator;
}
private static ForceCalculator GetForceCalculator()
{
return new ForceCalculator()
{ {
Name = "New Force Calculator", Name = "New Force Calculator",
TraceLogger = new ShiftTraceLogger() TraceLogger = new ShiftTraceLogger()
}; };
calculators.Add(forceCalculator); }
private static CrackCalculator GetCrackCalculator()
{
var newInputData = new CrackCalculatorInputData(); var newInputData = new CrackCalculatorInputData();
var checkLogic = new CheckCrackCalculatorInputDataLogic var checkLogic = new CheckCrackCalculatorInputDataLogic
{ {
@@ -28,8 +53,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections
TraceLogger = new ShiftTraceLogger() TraceLogger = new ShiftTraceLogger()
}; };
crackCalculator.InputData = newInputData; crackCalculator.InputData = newInputData;
calculators.Add(crackCalculator); return crackCalculator;
return calculators;
} }
} }
} }

View File

@@ -5,6 +5,7 @@ using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Templates.RCs; using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.NdmCalculations.Analyses; using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using System; using System;
@@ -67,6 +68,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
crackCalculator.InputData.ForceActions.AddRange(combinations); crackCalculator.InputData.ForceActions.AddRange(combinations);
} }
if (calculator is IValueDiagramCalculator diagramCalculator)
{
diagramCalculator.InputData.ForceActions.AddRange(combinations);
}
} }
} }
private void AddAllPrimitivesToCalculator() private void AddAllPrimitivesToCalculator()
@@ -81,6 +86,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
crackCalculator.InputData.Primitives.AddRange(primitives); crackCalculator.InputData.Primitives.AddRange(primitives);
} }
if (calculator is IValueDiagramCalculator diagramCalculator)
{
diagramCalculator.InputData.Primitives.AddRange(primitives);
}
} }
} }
} }

View File

@@ -5,6 +5,7 @@ using StructureHelperCommon.Services;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using System; using System;
@@ -33,6 +34,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Logics
{ {
new CrackCalculatorUpdateStrategy().Update(crackCalculator, (CrackCalculator)sourceObject); new CrackCalculatorUpdateStrategy().Update(crackCalculator, (CrackCalculator)sourceObject);
} }
else if (targetObject is IValueDiagramCalculator diagramCalculator)
{
new ValueDiagramCalculatorUpdateStrategy().Update(diagramCalculator, (IValueDiagramCalculator)sourceObject);
}
else else
{ {
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(INdmPrimitive), sourceObject.GetType()); ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(INdmPrimitive), sourceObject.GetType());

View File

@@ -1,15 +1,11 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{ {
public interface IValueDigram : ISaveable public interface IValueDiagram : ISaveable, ICloneable
{ {
IPoint2DRange Point2DRange { get; } IPoint2DRange Point2DRange { get; }
public int StepNumber { get; set; }
} }
} }

View File

@@ -9,6 +9,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{ {
public interface IValueDiagramCalculator : ICalculator public interface IValueDiagramCalculator : ICalculator
{ {
IValueDiagramCalculatorInputData InputData { get; set; }
} }
} }

View File

@@ -1,5 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.States; using StructureHelperCommon.Models.States;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
@@ -8,13 +8,13 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
/// <summary> /// <summary>
/// Implements input data for Value diagram calculator /// Implements input data for Value diagram calculator
/// </summary> /// </summary>
public interface IValueDiagramCalculatorInputData : ISaveable, IHasForceActions, IHasPrimitives public interface IValueDiagramCalculatorInputData : ISaveable, IInputData, IHasForceActions, IHasPrimitives
{ {
IStateCalcTermPair StateTermPair { get; set; } IStateCalcTermPair StateTermPair { get; set; }
/// <summary> /// <summary>
/// Collection of diagram for calculation /// Collection of diagram for calculation
/// </summary> /// </summary>
List<IValueDigram> Digrams { get; } List<IValueDiagramEntity> Digrams { get; }
bool CheckStrainLimit { get; set; } bool CheckStrainLimit { get; set; }
} }
} }

View File

@@ -8,6 +8,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{ {
IValueDiagramCalculatorInputData? InputData { get; set; } IValueDiagramCalculatorInputData? InputData { get; set; }
List<IPoint2D> Points { get; set; } List<IPoint2D> Points { get; set; }
List<IForceTupleCalculatorResult> ForceTupleResults { get; set; } List<IExtendedForceTupleCalculatorResult> ForceTupleResults { get; set; }
} }
} }

View File

@@ -0,0 +1,11 @@
using StructureHelperCommon.Infrastructures.Interfaces;
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{
public interface IValueDiagramEntity : ISaveable, ICloneable
{
string Name { get; set; }
bool IsTaken { get; set; }
IValueDiagram ValueDigram { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{
public class ValueDiagramCalculatorInputDataUpdateStrategy : IParentUpdateStrategy<IValueDiagramCalculatorInputData>
{
private IUpdateStrategy<IValueDiagramEntity> entityUpdateStrategy;
public ValueDiagramCalculatorInputDataUpdateStrategy(IUpdateStrategy<IValueDiagramEntity> entityUpdateStrategy)
{
this.entityUpdateStrategy = entityUpdateStrategy;
}
public ValueDiagramCalculatorInputDataUpdateStrategy()
{
}
public bool UpdateChildren { get; set; } = true;
public void Update(IValueDiagramCalculatorInputData targetObject, IValueDiagramCalculatorInputData sourceObject)
{
CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.CheckStrainLimit = sourceObject.CheckStrainLimit;
targetObject.StateTermPair.LimitState = sourceObject.StateTermPair.LimitState;
targetObject.StateTermPair.CalcTerm = sourceObject.StateTermPair.CalcTerm;
if (UpdateChildren == true)
{
targetObject.Primitives.Clear();
targetObject.Primitives.AddRange(sourceObject.Primitives);
targetObject.ForceActions.Clear();
targetObject.ForceActions.AddRange(sourceObject.ForceActions);
targetObject.Digrams.Clear();
entityUpdateStrategy ??= new ValueDiagramEntityUpdateStrategy();
foreach (var entity in sourceObject.Digrams)
{
var newItem = entity.Clone() as IValueDiagramEntity;
targetObject.Digrams.Add(newItem);
}
}
}
}
}

View File

@@ -0,0 +1,26 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{
public class ValueDiagramCalculatorUpdateStrategy : IParentUpdateStrategy<IValueDiagramCalculator>
{
private IUpdateStrategy<IValueDiagramCalculatorInputData> inputDataUpdateStrategy;
public bool UpdateChildren { get; set; } = true;
public void Update(IValueDiagramCalculator targetObject, IValueDiagramCalculator sourceObject)
{
CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name;
targetObject.ShowTraceData = sourceObject.ShowTraceData;
if (UpdateChildren == true)
{
CheckObject.IsNull(targetObject.InputData, ": target value diagram calculator input data");
CheckObject.IsNull(sourceObject.InputData, ": source value diagram calculator input data");
inputDataUpdateStrategy ??= new ValueDiagramCalculatorInputDataUpdateStrategy();
inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData);
}
}
}
}

View File

@@ -0,0 +1,35 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{
public class ValueDiagramEntityUpdateStrategy : IParentUpdateStrategy<IValueDiagramEntity>
{
private IUpdateStrategy<IValueDiagram> valueDiagramUpdateStrategy;
public ValueDiagramEntityUpdateStrategy(IUpdateStrategy<IValueDiagram> valueDiagramUpdateStrategy)
{
this.valueDiagramUpdateStrategy = valueDiagramUpdateStrategy;
}
public ValueDiagramEntityUpdateStrategy()
{
}
public bool UpdateChildren { get; set; } = true;
public void Update(IValueDiagramEntity targetObject, IValueDiagramEntity sourceObject)
{
CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.IsTaken = sourceObject.IsTaken;
targetObject.Name = sourceObject.Name;
if (UpdateChildren == true)
{
valueDiagramUpdateStrategy ??= new ValueDiagramUpdateStrategy();
valueDiagramUpdateStrategy.Update(targetObject.ValueDigram, sourceObject.ValueDigram);
}
}
}
}

View File

@@ -0,0 +1,24 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services;
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{
internal class ValueDiagramUpdateStrategy : IParentUpdateStrategy<IValueDiagram>
{
private IUpdateStrategy<IPoint2DRange> rangeUpdateStrategy;
public bool UpdateChildren { get; set; } = true;
public void Update(IValueDiagram targetObject, IValueDiagram sourceObject)
{
CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.StepNumber = sourceObject.StepNumber;
if (UpdateChildren == true)
{
rangeUpdateStrategy ??= new Point2DRangeUpdateStrategy();
rangeUpdateStrategy.Update(targetObject.Point2DRange, sourceObject.Point2DRange);
}
}
}
}

View File

@@ -0,0 +1,25 @@
using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{
public class ValueDiagram : IValueDiagram
{
public Guid Id { get; }
public int StepNumber { get; set; } = 50;
public IPoint2DRange Point2DRange { get; } = new Point2DRange(Guid.NewGuid());
public ValueDiagram(Guid id)
{
Id = id;
}
public object Clone()
{
ValueDiagram newItem = new(Guid.NewGuid());
var updateStrategy = new ValueDiagramUpdateStrategy();
updateStrategy.Update(newItem, this);
return newItem;
}
}
}

View File

@@ -11,14 +11,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{ {
public class ValueDiagramCalculator : IValueDiagramCalculator public class ValueDiagramCalculator : IValueDiagramCalculator
{ {
private IValueDiagramCalculatorResult result;
public Guid Id { get; }
public string Name { get; set; } public string Name { get; set; }
public bool ShowTraceData { get; set; } public bool ShowTraceData { get; set; }
public IResult Result => throw new NotImplementedException(); public IResult Result => result;
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public Guid Id { get; } public IValueDiagramCalculatorInputData InputData { get; set; } = new ValueDiagramCalculatorInputData(Guid.NewGuid());
public ValueDiagramCalculator(Guid id) public ValueDiagramCalculator(Guid id)
{ {
@@ -27,7 +30,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
public object Clone() public object Clone()
{ {
throw new NotImplementedException(); ValueDiagramCalculator newItem = new ValueDiagramCalculator(Guid.NewGuid());
var updateLogic = new ValueDiagramCalculatorUpdateStrategy();
updateLogic.Update(newItem, this);
return newItem;
} }
public void Run() public void Run()

View File

@@ -17,7 +17,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
public Guid Id { get; } public Guid Id { get; }
/// <inheritdoc/> /// <inheritdoc/>
public List<IValueDigram> Digrams { get; } = []; public List<IValueDiagramEntity> Digrams { get; } = [];
/// <inheritdoc/> /// <inheritdoc/>
public List<IForceAction> ForceActions { get; } = []; public List<IForceAction> ForceActions { get; } = [];
/// <inheritdoc/> /// <inheritdoc/>

View File

@@ -9,7 +9,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
public List<IPoint2D> Points { get; set; } = []; public List<IPoint2D> Points { get; set; } = [];
public List<IForceTupleCalculatorResult> ForceTupleResults { get; set; } = []; public List<IExtendedForceTupleCalculatorResult> ForceTupleResults { get; set; } = [];
public bool IsValid { get; set; } = true; public bool IsValid { get; set; } = true;
public string? Description { get; set; } = string.Empty; public string? Description { get; set; } = string.Empty;

View File

@@ -0,0 +1,24 @@
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
{
public class ValueDiagramEntity : IValueDiagramEntity
{
public Guid Id { get; }
public string Name { get; set; } = string.Empty;
public bool IsTaken { get; set; } = true;
public IValueDiagram ValueDigram { get; set; } = new ValueDiagram(Guid.NewGuid());
public ValueDiagramEntity(Guid id)
{
Id = id;
}
public object Clone()
{
ValueDiagramEntity newItem = new ValueDiagramEntity(Guid.NewGuid());
var updateStrategy = new ValueDiagramEntityUpdateStrategy();
updateStrategy.Update(newItem, this);
return newItem;
}
}
}

View File

@@ -1,14 +1,11 @@
using netDxf; using netDxf.Entities;
using netDxf.Entities;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Exports; using StructureHelperCommon.Services.Exports;
using System.Runtime.CompilerServices;
namespace StructureHelperLogics.NdmCalculations.Primitives namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
public class GetPrimitivesByDxfEntities : IObjectConvertStrategy<List<INdmPrimitive>, IEnumerable<EntityObject>> public class DxfEntitiesToNdmPrimitivesConvertStrategy : IObjectConvertStrategy<List<INdmPrimitive>, IEnumerable<EntityObject>>
{ {
private const double metresToMillimeters = 1000.0; private const double metresToMillimeters = 1000.0;
private List<INdmPrimitive> primitives = []; private List<INdmPrimitive> primitives = [];
@@ -68,7 +65,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
primitive = ellipse; primitive = ellipse;
} }
primitive.Center = new Point2D(circle.Center.X / metresToMillimeters, circle.Center.Y / metresToMillimeters); primitive.Center = new Point2D(circle.Center.X / metresToMillimeters, circle.Center.Y / metresToMillimeters);
return primitive; return primitive;
} }

View File

@@ -2,7 +2,7 @@
namespace StructureHelperLogics.NdmCalculations.Primitives namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
public class GetPrimitivesByFile : IGetPrimitivesLogic public class GetPrimitivesByFile : IImportFromFileLogic
{ {
private List<INdmPrimitive> primitives = []; private List<INdmPrimitive> primitives = [];
@@ -16,7 +16,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
importEntitiesLogic.Import(); importEntitiesLogic.Import();
if (importEntitiesLogic.Entities.Count != 0) if (importEntitiesLogic.Entities.Count != 0)
{ {
var primitivesLogic = new GetPrimitivesByDxfEntities(); var primitivesLogic = new DxfEntitiesToNdmPrimitivesConvertStrategy();
primitives = primitivesLogic.Convert(importEntitiesLogic.Entities); primitives = primitivesLogic.Convert(importEntitiesLogic.Entities);
} }
} }

View File

@@ -0,0 +1,65 @@
using netDxf.Entities;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Exports;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class NdmPrimitivesToDxfEntitiesConvertStrategy : IObjectConvertStrategy<List<(EntityObject, LayerNames)>, IEnumerable<INdmPrimitive>>
{
private const double metresToMillimeters = 1000.0;
private List<(EntityObject, LayerNames)> entities = [];
private IShapeConvertStrategy<EntityObject, IShape> shapeConvertStrategy = new ShapeToDxfEntityConvertStrategy() { Scale = metresToMillimeters };
public List<(EntityObject, LayerNames)> Convert(IEnumerable<INdmPrimitive> source)
{
entities.Clear();
foreach (var ndmPrimitive in source)
{
shapeConvertStrategy.Dx = ndmPrimitive.Center.X;
shapeConvertStrategy.Dy = ndmPrimitive.Center.Y;
if (ndmPrimitive is IRectangleNdmPrimitive rectangleNdmPrimitive)
{
var rectangle = shapeConvertStrategy.Convert(rectangleNdmPrimitive);
entities.Add((rectangle, LayerNames.StructiralPrimitives));
}
else if (ndmPrimitive is IShapeNdmPrimitive shapeNdmPrimitive)
{
var polygon = shapeConvertStrategy.Convert(shapeNdmPrimitive.Shape);
entities.Add((polygon, LayerNames.StructiralPrimitives));
}
else if (ndmPrimitive is IEllipseNdmPrimitive ellipseNdmPrimitive)
{
CircleShape circleShape = new CircleShape() { Diameter = ellipseNdmPrimitive.Width};
var circle = shapeConvertStrategy.Convert(circleShape);
entities.Add((circle, LayerNames.StructiralPrimitives));
}
else if (ndmPrimitive is IRebarNdmPrimitive rebar)
{
LayerNames layerName = LayerNames.StructuralRebars;
convertPoint(rebar, layerName);
}
else if (ndmPrimitive is IPointNdmPrimitive point)
{
LayerNames layerName = LayerNames.StructiralPrimitives;
convertPoint(point, layerName);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(ndmPrimitive));
}
}
return entities;
}
private void convertPoint(IPointNdmPrimitive point, LayerNames layerName)
{
double diameter = Math.Sqrt(point.Area / Math.PI * 4.0);
CircleShape circleShape = new CircleShape() { Diameter = diameter };
var circle = shapeConvertStrategy.Convert(circleShape);
entities.Add((circle, layerName));
}
}
}

View File

@@ -77,6 +77,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
if (shape is ILinePolygonShape polygon) if (shape is ILinePolygonShape polygon)
{ {
var newShape = PolygonGeometryUtils.GetTransfromedPolygon(polygon, Center.X, Center.Y); var newShape = PolygonGeometryUtils.GetTransfromedPolygon(polygon, Center.X, Center.Y);
newShape.IsClosed = true;
var calculator = new PolygonCalculator(); var calculator = new PolygonCalculator();
return calculator.ContainsPoint(newShape, point); return calculator.ContainsPoint(newShape, point);
} }