Material diagram Window was changed

This commit is contained in:
Evgeny Redikultsev
2023-04-30 21:11:07 +05:00
parent df95e84789
commit 3cb6e60fc9
36 changed files with 999 additions and 267 deletions

View File

@@ -12,4 +12,5 @@
<convertersUnits:Moment x:Key="MomentConverter"/> <convertersUnits:Moment x:Key="MomentConverter"/>
<convertersUnits:Stress x:Key="StressConverter"/> <convertersUnits:Stress x:Key="StressConverter"/>
<convertersUnits:Curvature x:Key="Curvature"/> <convertersUnits:Curvature x:Key="Curvature"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -19,4 +19,27 @@
SelectedItem="{Binding SelectedTargetItem}" ItemTemplate="{Binding ItemDataDemplate}"/> SelectedItem="{Binding SelectedTargetItem}" ItemTemplate="{Binding ItemDataDemplate}"/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="SelectItems">
<StackPanel>
<StackPanel Height="25" Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding ShowButtons, Converter={StaticResource BooleanToVisibilityConverter}}">
<Button Content="Select All" Command="{Binding SelectAllCommand}"/>
<Button Content="Unselect All" Command="{Binding UnSelectAllCommand}"/>
<Button Content="Invert Selection" Command="{Binding InvertSelectionCommand}"/>
</StackPanel>
<ListBox ItemsSource="{Binding CollectionItems}" SelectedItem="SelectedItem">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="22"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsSelected}"/>
<ContentControl Grid.Column="1" ContentTemplate="{StaticResource ColoredItemTemplate}" Content="{Binding Item}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DataTemplate>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -0,0 +1,16 @@
using StructureHelperLogics.NdmCalculations.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.Exports
{
internal class ExportToFileInputData : IExportToFileInputData
{
public string FileName { get; set; }
public string Filter { get; set; }
public string Title { get; set; }
}
}

View File

@@ -0,0 +1,97 @@
using StructureHelper.Windows.Errors;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StructureHelper.Services.Exports
{
internal class ExportToFileService : IExportService
{
IExportToFileInputData inputData;
IExportResultLogic logic;
public ExportToFileService(IExportToFileInputData inputData, IExportResultLogic logic)
{
this.inputData = inputData;
this.logic = logic;
}
public void Export()
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = inputData.Filter;
saveFileDialog.Title = inputData.Title;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
var filename = saveFileDialog.FileName;
// If the file name is not an empty string open it for saving.
if (filename != "")
{
SaveFile(filename);
}
}
}
private void SaveFile(string filename)
{
if (File.Exists(filename))
{
DeleteFile(filename);
}
try
{
ExportFile(filename);
}
catch (Exception ex)
{
var vm = new ErrorProcessor()
{
ShortText = ErrorStrings.FileCantBeSaved + ex + filename,
DetailText = $"{ex}"
};
new ErrorMessage(vm).ShowDialog();
}
}
private void DeleteFile(string filename)
{
try
{
File.Delete(filename);
}
catch (Exception ex)
{
var vm = new ErrorProcessor()
{
ShortText = ErrorStrings.FileCantBeDeleted + ex + filename,
DetailText = $"{ex}"
};
new ErrorMessage(vm).ShowDialog();
}
}
private void ExportFile(string fileName)
{
logic.FileName = fileName;
logic.Export();
try
{
OpenFile(fileName);
}
catch (Exception) { }
}
private void OpenFile(string fileName)
{
var filopener = new Process();
var startInfo = new ProcessStartInfo(fileName) { UseShellExecute = true };
filopener.StartInfo = startInfo;
filopener.Start();
}
}
}

View File

@@ -0,0 +1,14 @@
using StructureHelperLogics.NdmCalculations.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.Exports
{
internal interface IExportService
{
void Export();
}
}

View File

@@ -0,0 +1,16 @@
using StructureHelperLogics.NdmCalculations.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.Exports
{
internal interface IExportToFileInputData
{
string FileName { get; set; }
string Filter { get; set; }
string Title { get; set; }
}
}

View File

@@ -9,7 +9,7 @@
</ApplicationDefinition> </ApplicationDefinition>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculator\GeometryCalculatorResultView.xaml.cs"> <Compile Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\Errors\ErrorMessage.xaml.cs"> <Compile Update="Windows\Errors\ErrorMessage.xaml.cs">
@@ -38,7 +38,7 @@
<Page Update="Infrastructure\UI\Resources\Materials.xaml"> <Page Update="Infrastructure\UI\Resources\Materials.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculator\GeometryCalculatorResultView.xaml"> <Page Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\Errors\ErrorMessage.xaml"> <Page Update="Windows\Errors\ErrorMessage.xaml">

View File

@@ -1,14 +1,18 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculator.GeometryCalculatorResultView" <Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews.GeometryCalculatorResultView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculator" xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculator" xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculatorVMs"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:GeometryCalculatorResultViewModel}" d:DataContext="{d:DesignInstance vm:GeometryCalculatorResultViewModel}"
Title="Geometry Properies" Height="450" Width="850" WindowStartupLocation="CenterScreen"> Title="Geometry Properies" Height="450" Width="850" WindowStartupLocation="CenterScreen">
<Grid> <Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="90"/>
</Grid.ColumnDefinitions>
<DataGrid x:Name="ResultGrid" IsReadOnly="True" AutoGenerateColumns="False" ItemsSource="{Binding TextParameters}"> <DataGrid x:Name="ResultGrid" IsReadOnly="True" AutoGenerateColumns="False" ItemsSource="{Binding TextParameters}">
<DataGrid.RowStyle> <DataGrid.RowStyle>
<Style TargetType="DataGridRow"> <Style TargetType="DataGridRow">
@@ -28,5 +32,8 @@
<DataGridTextColumn Header="Description" Width="400" Binding="{Binding Description}"/> <DataGridTextColumn Header="Description" Width="400" Binding="{Binding Description}"/>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
<StackPanel Grid.Column="1">
<Button Margin="3" Content="Export" ToolTip="Export results to *.csv" Command="{Binding ExportToCSVCommand}"/>
</StackPanel>
</Grid> </Grid>
</Window> </Window>

View File

@@ -1,5 +1,6 @@
using StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculator; using StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculatorVMs;
using StructureHelperCommon.Models.Parameters; using StructureHelperCommon.Models.Parameters;
using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -14,7 +15,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculator namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews
{ {
/// <summary> /// <summary>
/// Логика взаимодействия для GeometryCalculatorResultView.xaml /// Логика взаимодействия для GeometryCalculatorResultView.xaml
@@ -22,9 +23,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCa
public partial class GeometryCalculatorResultView : Window public partial class GeometryCalculatorResultView : Window
{ {
GeometryCalculatorResultViewModel viewModel; GeometryCalculatorResultViewModel viewModel;
public GeometryCalculatorResultView(List<ITextParameter> textParameters) public GeometryCalculatorResultView(IGeometryResult geometryResult)
{ {
viewModel = new GeometryCalculatorResultViewModel(textParameters); viewModel = new GeometryCalculatorResultViewModel(geometryResult);
InitializeComponent(); InitializeComponent();
this.DataContext = viewModel; this.DataContext = viewModel;
} }

View File

@@ -7,40 +7,52 @@
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces" xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
d:DataContext="{d:DesignInstance vm:InterpolateTuplesViewModel}" d:DataContext="{d:DesignInstance vm:InterpolateTuplesViewModel}"
mc:Ignorable="d" mc:Ignorable="d"
Title="Interpolate Combinations" Height="200" Width="350" MinHeight="180" MinWidth="250" WindowStartupLocation="CenterScreen"> Title="Interpolate Combinations" Height="200" Width="440" MinHeight="180" MinWidth="440" WindowStartupLocation="CenterScreen">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="40"/> <RowDefinition Height="40"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid> <Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition Width="90"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Moment Mx" HorizontalAlignment="Center"/> <Grid>
<TextBlock Grid.Column="2" Text="Moment My" HorizontalAlignment="Center"/> <Grid.RowDefinitions>
<TextBlock Grid.Column="3" Text="Force Nz" HorizontalAlignment="Center"/> <RowDefinition Height="25"/>
<TextBlock Grid.Row="1" Text="Start Combination"/> <RowDefinition Height="25"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding StartDesignForce.ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/> <RowDefinition Height="25"/>
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding StartDesignForce.ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/> <RowDefinition Height="25"/>
<TextBox Grid.Row="1" Grid.Column="3" Text="{Binding StartDesignForce.ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/> <RowDefinition Height="40"/>
<TextBlock Grid.Row="2" Text="Finish Combination"/> <RowDefinition/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding FinishDesignForce.ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/> </Grid.RowDefinitions>
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding FinishDesignForce.ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/> <Grid.ColumnDefinitions>
<TextBox Grid.Row="2" Grid.Column="3" Text="{Binding FinishDesignForce.ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/> <ColumnDefinition Width="120"/>
<TextBlock Grid.Row="3" Text="Step count"/> <ColumnDefinition/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding StepCount, ValidatesOnExceptions=True}"/> <ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Moment Mx" HorizontalAlignment="Center"/>
<TextBlock Grid.Column="2" Text="Moment My" HorizontalAlignment="Center"/>
<TextBlock Grid.Column="3" Text="Force Nz" HorizontalAlignment="Center"/>
<TextBlock Grid.Row="1" Text="Start Combination"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding StartMx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding StartMy, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="3" Text="{Binding StartNz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="2" Text="Finish Combination"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding FinishMx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding FinishMy, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="2" Grid.Column="3" Text="{Binding FinishNz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="3" Text="Step count"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding StepCount, ValidatesOnExceptions=True}"/>
</Grid>
<StackPanel Grid.Column="1">
<Button Content="Invert comb's" Command="{Binding InvertForcesCommand}" />
</StackPanel>
</Grid> </Grid>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource CancelButton}"/> <Button Style="{StaticResource CancelButton}"/>
<Button Style="{StaticResource OkButton}" Click="Button_Click"/> <Button Style="{StaticResource OkButton}" Click="Button_Click"/>

View File

@@ -10,12 +10,53 @@
mc:Ignorable="d" mc:Ignorable="d"
Title="Material Diagram" Height="450" Width="800" WindowStartupLocation="CenterScreen"> Title="Material Diagram" Height="450" Width="800" WindowStartupLocation="CenterScreen">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.ColumnDefinitions>
<RowDefinition Height="22"/> <ColumnDefinition Width="250"/>
<RowDefinition/> <ColumnDefinition/>
</Grid.RowDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="{Binding MaterialName}"/> <Grid>
<lvc:CartesianChart Grid.Row="1" Series="{Binding SeriesCollection}" LegendLocation="Right" > <Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel>
<Expander Header="Materials" IsExpanded="True">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding MaterialsModel}"/>
</Expander>
<Expander Header="Limit States">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding LimitStatesModel}"/>
</Expander>
<Expander Header="Calculation terms">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding CalcTermsModel}"/>
</Expander>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<TextBlock Text="Minimum strain"/>
<TextBox Grid.Column="1" Text="{Binding MinValue, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
<TextBlock Grid.Row="1" Text="Maximum strain"/>
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding MaxValue, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
<TextBlock Grid.Row="2" Text="Step count"/>
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding StepCount, ValidatesOnDataErrors=True}"/>
<TextBlock Grid.Row="3" Text="Positive in tension"/>
<CheckBox Grid.Column="1" Grid.Row="3" Margin="4" IsChecked="{Binding PositiveInTension}"/>
</Grid>
</StackPanel>
</ScrollViewer>
<StackPanel Grid.Row="1" Orientation="Horizontal" FlowDirection="RightToLeft">
<Button Content="Redraw Lines" Command="{Binding RedrawLinesCommand}"/>
</StackPanel>
</Grid>
<lvc:CartesianChart Grid.Column="1" Series="{Binding SeriesCollection}" LegendLocation="Bottom" >
<lvc:CartesianChart.AxisY> <lvc:CartesianChart.AxisY>
<lvc:Axis Title="Stress"></lvc:Axis> <lvc:Axis Title="Stress"></lvc:Axis>
</lvc:CartesianChart.AxisY> </lvc:CartesianChart.AxisY>

View File

@@ -31,7 +31,7 @@ namespace StructureHelper.Windows.MainWindow.Materials
InitializeComponent(); InitializeComponent();
this.DataContext = this.vm; this.DataContext = this.vm;
} }
public MaterialDiagramView(IHeadMaterial material) : this(new MaterialDiagramViewModel(material)) public MaterialDiagramView(IEnumerable<IHeadMaterial> headMaterials, IHeadMaterial material) : this(new MaterialDiagramViewModel(headMaterials, material))
{ {
} }

View File

@@ -10,29 +10,10 @@
Title="Select Primitives" Height="250" Width="250" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> Title="Select Primitives" Height="250" Width="250" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="35"/> <RowDefinition Height="35"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding Items}"/>
<Button Content="Select All" Command="{Binding Items.SelectAllCommand}"/>
<Button Content="Unselect All" Command="{Binding Items.UnSelectAllCommand}"/>
<Button Content="Invert Selection" Command="{Binding Items.InvertSelectionCommand}"/>
</StackPanel>
<ListBox Grid.Row="1" ItemsSource="{Binding Items.CollectionItems}" SelectedItem="Items.SelectedItem">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="22"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsSelected}"/>
<ContentControl Grid.Column="1" ContentTemplate="{StaticResource ColoredItemTemplate}" Content="{Binding Item}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource CancelButton}"/> <Button Style="{StaticResource CancelButton}"/>
<Button Style="{StaticResource OkButton}" Click="Button_Click"/> <Button Style="{StaticResource OkButton}" Click="Button_Click"/>

View File

@@ -1,26 +1,26 @@
using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using StructureHelper.Infrastructure; using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelper.Services.Exports;
using StructureHelper.Services.Reports; using StructureHelper.Services.Reports;
using StructureHelper.Services.Reports.CalculationReports; using StructureHelper.Services.Reports.CalculationReports;
using StructureHelper.Services.ResultViewers; using StructureHelper.Services.ResultViewers;
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.GeometryCalculator; using StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews;
using StructureHelper.Windows.Errors; using StructureHelper.Windows.Errors;
using StructureHelper.Windows.Forces; using StructureHelper.Windows.Forces;
using StructureHelper.Windows.PrimitivePropertiesWindow; using StructureHelper.Windows.PrimitivePropertiesWindow;
using StructureHelper.Windows.ViewModels.Errors; using StructureHelper.Windows.ViewModels.Errors;
using StructureHelper.Windows.ViewModels.Forces; using StructureHelper.Windows.ViewModels.Forces;
using StructureHelper.Windows.ViewModels.PrimitiveProperties; using StructureHelper.Windows.ViewModels.PrimitiveProperties;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings; using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Forces; using StructureHelperCommon.Services.Forces;
using StructureHelperLogics.NdmCalculations.Analyses; using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmCalculations; using StructureHelperLogics.Services.NdmCalculations;
using StructureHelperLogics.Services.NdmPrimitives; using StructureHelperLogics.Services.NdmPrimitives;
@@ -29,8 +29,6 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
@@ -87,56 +85,13 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
} }
private void ExportToCSV() private void ExportToCSV()
{ {
SaveFileDialog saveFileDialog = new SaveFileDialog(); var inputData = new ExportToFileInputData();
saveFileDialog.Filter = "csv |*.csv"; inputData.FileName = "New File";
saveFileDialog.Title = "Save in csv File"; inputData.Filter = "csv |*.csv";
if (saveFileDialog.ShowDialog() == DialogResult.OK) inputData.Title = "Save in csv File";
{ var logic = new ExportForceResultToCSVLogic(forcesResults);
var filename = saveFileDialog.FileName; var exportService = new ExportToFileService(inputData, logic);
// If the file name is not an empty string open it for saving. exportService.Export();
if (filename != "")
{
if (File.Exists(filename))
{
try
{
File.Delete(filename);
}
catch (Exception ex)
{
var vm = new ErrorProcessor()
{
ShortText = ErrorStrings.FileCantBeDeleted + ex + filename,
DetailText = $"{ex}"
};
new ErrorMessage(vm).ShowDialog();
}
}
try
{
var logic = new ExportToCSVLogic(saveFileDialog.FileName);
logic.Export(forcesResults);
try
{
var filopener = new Process();
var startInfo = new ProcessStartInfo(saveFileDialog.FileName) { UseShellExecute = true};
filopener.StartInfo = startInfo;
filopener.Start();
}
catch (Exception) { }
}
catch (Exception ex)
{
var vm = new ErrorProcessor()
{
ShortText = ErrorStrings.FileCantBeSaved + ex + filename,
DetailText = $"{ex}"
};
new ErrorMessage(vm).ShowDialog();
}
}
}
} }
public RelayCommand InterpolateCommand public RelayCommand InterpolateCommand
@@ -248,8 +203,10 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{ {
var strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix; var strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix;
var textParametrsLogic = new TextParametersLogic(ndms, strainMatrix); var textParametrsLogic = new TextParametersLogic(ndms, strainMatrix);
var textParameters = textParametrsLogic.GetTextParameters(); var calculator = new GeometryCalculator(textParametrsLogic);
var wnd = new GeometryCalculatorResultView(textParameters); calculator.Run();
var result = calculator.Result as IGeometryResult;
var wnd = new GeometryCalculatorResultView(result);
wnd.ShowDialog(); wnd.ShowDialog();
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -1,24 +0,0 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Models.Parameters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculator
{
internal class GeometryCalculatorResultViewModel : ViewModelBase
{
private List<ITextParameter> textParameters;
public List<ITextParameter> TextParameters
{ get => textParameters;
}
public GeometryCalculatorResultViewModel(List<ITextParameter> textParameters)
{
this.textParameters = textParameters;
}
}
}

View File

@@ -0,0 +1,44 @@
using StructureHelper.Infrastructure;
using StructureHelper.Services.Exports;
using StructureHelperCommon.Models.Parameters;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculatorVMs
{
internal class GeometryCalculatorResultViewModel : ViewModelBase
{
IGeometryResult result;
private ICommand exportToCSVCommand;
public List<ITextParameter> TextParameters
{
get => result.TextParameters;
}
public ICommand ExportToCSVCommand
{
get => exportToCSVCommand ??= new RelayCommand(o => ExportToCSV());
}
public GeometryCalculatorResultViewModel(IGeometryResult geometryResult)
{
this.result = geometryResult;
}
private void ExportToCSV()
{
var inputData = new ExportToFileInputData();
inputData.FileName = "New File";
inputData.Filter = "csv |*.csv";
inputData.Title = "Save in csv File";
var logic = new ExportGeometryResultToCSVLogic(result);
var exportService = new ExportToFileService(inputData, logic);
exportService.Export();
}
}
}

View File

@@ -7,15 +7,90 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Forces namespace StructureHelper.Windows.ViewModels.Forces
{ {
public class InterpolateTuplesViewModel : OkCancelViewModelBase public class InterpolateTuplesViewModel : OkCancelViewModelBase
{ {
public IDesignForceTuple StartDesignForce { get; } private RelayCommand invertForcesCommand;
public IDesignForceTuple FinishDesignForce { get; }
public IDesignForceTuple StartDesignForce { get; private set; }
public IDesignForceTuple FinishDesignForce { get; private set; }
public double StartMx
{
get => StartDesignForce.ForceTuple.Mx;
set
{
StartDesignForce.ForceTuple.Mx = value;
OnPropertyChanged(nameof(StartMx));
}
}
public double StartMy
{
get => StartDesignForce.ForceTuple.My;
set
{
StartDesignForce.ForceTuple.My = value;
OnPropertyChanged(nameof(StartMy));
}
}
public double StartNz
{
get => StartDesignForce.ForceTuple.Nz;
set
{
StartDesignForce.ForceTuple.Nz = value;
OnPropertyChanged(nameof(StartNz));
}
}
public double FinishMx
{
get => FinishDesignForce.ForceTuple.Mx;
set
{
FinishDesignForce.ForceTuple.Mx = value;
OnPropertyChanged(nameof(FinishMx));
}
}
public double FinishMy
{
get => FinishDesignForce.ForceTuple.My;
set
{
FinishDesignForce.ForceTuple.My = value;
OnPropertyChanged(nameof(FinishMy));
}
}
public double FinishNz
{
get => FinishDesignForce.ForceTuple.Nz;
set
{
FinishDesignForce.ForceTuple.Nz = value;
OnPropertyChanged(nameof(FinishNz));
}
}
public int StepCount { get; set; } public int StepCount { get; set; }
public ICommand InvertForcesCommand
{
get => invertForcesCommand ??= new RelayCommand(o => InvertForces());
}
private void InvertForces()
{
var tmpForce = StartDesignForce.Clone() as IDesignForceTuple;
StartDesignForce = FinishDesignForce;
FinishDesignForce = tmpForce;
OnPropertyChanged(nameof(StartMx));
OnPropertyChanged(nameof(StartMy));
OnPropertyChanged(nameof(StartNz));
OnPropertyChanged(nameof(FinishMx));
OnPropertyChanged(nameof(FinishMy));
OnPropertyChanged(nameof(FinishNz));
}
public InterpolateTuplesViewModel(IDesignForceTuple finishDesignForce, IDesignForceTuple startDesignForce=null, int stepCount = 100) public InterpolateTuplesViewModel(IDesignForceTuple finishDesignForce, IDesignForceTuple startDesignForce=null, int stepCount = 100)
{ {
if (startDesignForce !=null) if (startDesignForce !=null)

View File

@@ -92,7 +92,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
return showMaterialDiagram ??= new RelayCommand(o => return showMaterialDiagram ??= new RelayCommand(o =>
{ {
var material = selectedMaterial; var material = selectedMaterial;
var wnd = new MaterialDiagramView(material); var wnd = new MaterialDiagramView(headMaterials, material);
wnd.ShowDialog(); wnd.ShowDialog();
}, o => SelectedMaterial != null }, o => SelectedMaterial != null

View File

@@ -1,76 +1,166 @@
using LiveCharts; using LiveCharts;
using LiveCharts.Wpf; using LiveCharts.Wpf;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.Converters.Units; using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelper.Models.Materials; using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperLogics.Models.Materials; using StructureHelperLogics.Models.Materials;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using Brushes = System.Windows.Media.Brushes;
namespace StructureHelper.Windows.ViewModels.Materials namespace StructureHelper.Windows.ViewModels.Materials
{ {
public class MaterialDiagramViewModel public class MaterialDiagramViewModel : ViewModelBase
{ {
private IHeadMaterial material; private IHeadMaterial material;
private ICommand redrawLinesCommand;
double minValue;
double maxValue;
int stepCount;
bool positiveInTension;
public string MaterialName => material.Name; public string MaterialName => material.Name;
public double MinValue
{
get => minValue;
set
{
minValue = Math.Min(value, maxValue - 0.001d);
OnPropertyChanged(nameof(MinValue));
}
}
public double MaxValue
{
get => maxValue;
set
{
maxValue = Math.Max(value, minValue + 0.001d);
OnPropertyChanged(nameof(MaxValue));
}
}
public int StepCount
{
get => stepCount;
set
{
stepCount = value;
stepCount = Math.Max(stepCount, 10);
stepCount = Math.Min(stepCount, 500);
OnPropertyChanged(nameof(StepCount));
}
}
public bool PositiveInTension
{
get => positiveInTension;
set
{
positiveInTension = value;
var tmpMinValue = minValue;
minValue = maxValue * -1d;
maxValue = tmpMinValue * -1d;
OnPropertyChanged(nameof(PositiveInTension));
OnPropertyChanged(nameof(MinValue));
OnPropertyChanged(nameof(MaxValue));
}
}
public SelectItemsViewModel<IHeadMaterial> MaterialsModel { get; private set; }
public SelectItemsViewModel<LimitStateEntity> LimitStatesModel { get; private set; }
public SelectItemsViewModel<CalcTermEntity> CalcTermsModel { get; private set; }
public SeriesCollection SeriesCollection { get; set; } public SeriesCollection SeriesCollection { get; set; }
public List<string> Labels { get; set; } public List<string> Labels { get; set; }
public Func<double, string> YFormatter { get; set; } public Func<double, string> YFormatter { get; set; }
public MaterialDiagramViewModel(IHeadMaterial material) public ICommand RedrawLinesCommand
{ {
get => redrawLinesCommand ??= new RelayCommand(o => DrawLines(), b => IsDrawPossible());
}
public MaterialDiagramViewModel(IEnumerable<IHeadMaterial> headMaterials, IHeadMaterial material)
{
MaterialsModel = new SelectItemsViewModel<IHeadMaterial>(headMaterials) { ShowButtons = true};
LimitStatesModel = new SelectItemsViewModel<LimitStateEntity>(ProgramSetting.LimitStatesList.LimitStates) { ShowButtons = false};
CalcTermsModel = new SelectItemsViewModel<CalcTermEntity>(ProgramSetting.CalcTermList.CalcTerms) { ShowButtons = false};
foreach (var item in MaterialsModel.CollectionItems)
{
if (item.Item == material)
{
item.IsSelected = true;
}
else item.IsSelected = false;
}
this.material = material; this.material = material;
minValue = -0.005d;
maxValue = 0.005d;
stepCount = 50;
positiveInTension = true;
SetLines(); SetLines();
} }
private void SetLines() private void SetLines()
{ {
var titles = new List<string>() { "ULS Short Term", "ULS Long Term", "SLS Short Term","SLS Long Term"}; var materials = MaterialsModel.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item);
var limitStates = new List<LimitStates> { LimitStates.ULS, LimitStates.SLS }; var limitStates = LimitStatesModel.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item);
var calcTerms = new List<CalcTerms> { CalcTerms.ShortTerm, CalcTerms.LongTerm }; var calcTerms = CalcTermsModel.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item); ;
var labels = new List<string>(); var labels = new List<string>();
var factor = positiveInTension ? 1d : -1d;
double minValue = -0.005d;
double maxValue = 0.005d;
if (material.HelperMaterial is IConcreteLibMaterial)
{
maxValue = 0.0005d;
}
int stepCount = 100;
double step = (maxValue - minValue) / stepCount; double step = (maxValue - minValue) / stepCount;
SeriesCollection = new SeriesCollection(); SeriesCollection = new SeriesCollection();
for (int i = 0; i < limitStates.Count(); i++) foreach (var limitState in limitStates)
{ {
for (int j = 0; j < calcTerms.Count(); j++) foreach (var calcTerm in calcTerms)
{ {
int n = i * 2 + j; foreach (var material in materials)
var line = new LineSeries() { Title = titles[n], PointGeometry = null, Fill = Brushes.Transparent};
var chartValues = new ChartValues<double>();
var loaderMaterial = material.GetLoaderMaterial(limitStates[i], calcTerms[j]);
var title = titles[n];
for (double s = minValue; s < maxValue; s += step)
{ {
double diagramValue = Math.Round(loaderMaterial.Diagram.Invoke(loaderMaterial.DiagramParameters,s)) * UnitConstants.Stress; var loaderMaterial = material.GetLoaderMaterial(limitState.LimitState, calcTerm.CalcTerm);
//var point = new PointF() { X = (float)s, Y = (float)diagramValue }; var lineSeries = new LineSeries()
//chartValues.Add(point); { Title = $"{material.Name} ({calcTerm.ShortName} {limitState.ShortName})",
chartValues.Add(diagramValue); PointGeometry = null,
labels.Add(Convert.ToString(Math.Round(s,4))); Fill = Brushes.Transparent,
};
if (limitStates.Count() == 1 && calcTerms.Count() == 1)
{
lineSeries.Stroke = new SolidColorBrush(material.Color);
}
var chartValues = new ChartValues<double>();
for (double s = minValue; s < maxValue; s += step)
{
//var trueStep = s * factor;
double diagramValue = Math.Round(loaderMaterial.Diagram.Invoke(loaderMaterial.DiagramParameters, s * factor)) * factor * UnitConstants.Stress;
//var point = new PointF() { X = (float)s, Y = (float)diagramValue };
//chartValues.Add(point);
chartValues.Add(diagramValue);
labels.Add(Convert.ToString(Math.Round(s , 4)));
}
lineSeries.Values = chartValues;
SeriesCollection.Add(lineSeries);
} }
line.Values = chartValues;
SeriesCollection.Add(line);
} }
} }
Labels = labels; Labels = labels;
} }
private void DrawLines()
{
SetLines();
OnPropertyChanged(nameof(SeriesCollection));
OnPropertyChanged(nameof(Labels));
}
private bool IsDrawPossible()
{
if (MaterialsModel.CollectionItems.Count == 0) return false;
if (LimitStatesModel.CollectionItems.Count == 0) return false;
if (CalcTermsModel.CollectionItems.Count == 0) return false;
return true;
}
} }
} }

View File

@@ -188,7 +188,18 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
PrimitiveBase primitiveBase; PrimitiveBase primitiveBase;
if (newPrimitive is IRectanglePrimitive) { primitiveBase = new RectangleViewPrimitive(newPrimitive as IRectanglePrimitive); } if (newPrimitive is IRectanglePrimitive) { primitiveBase = new RectangleViewPrimitive(newPrimitive as IRectanglePrimitive); }
else if (newPrimitive is ICirclePrimitive) { primitiveBase = new CircleViewPrimitive(newPrimitive as ICirclePrimitive); } else if (newPrimitive is ICirclePrimitive) { primitiveBase = new CircleViewPrimitive(newPrimitive as ICirclePrimitive); }
else if (newPrimitive is IPointPrimitive) { primitiveBase = new PointViewPrimitive(newPrimitive as IPointPrimitive); } else if (newPrimitive is IPointPrimitive)
{
if (newPrimitive is ReinforcementPrimitive)
{
primitiveBase = new ReinforcementViewPrimitive(newPrimitive as ReinforcementPrimitive);
}
else
{
primitiveBase = new PointViewPrimitive(newPrimitive as IPointPrimitive);
}
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown); else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
primitiveBase.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2); primitiveBase.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
Items.Add(primitiveBase); Items.Add(primitiveBase);

View File

@@ -16,7 +16,7 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
public SelectPrimitivesViewModel(IEnumerable<INdmPrimitive> primitives) public SelectPrimitivesViewModel(IEnumerable<INdmPrimitive> primitives)
{ {
var primitiveViews = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(primitives); var primitiveViews = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(primitives);
Items = new SelectItemsViewModel<PrimitiveBase>(primitiveViews); Items = new SelectItemsViewModel<PrimitiveBase>(primitiveViews) { ShowButtons = true };
Items.ItemDataDemplate = Application.Current.Resources["ColoredItemTemplate"] as DataTemplate; Items.ItemDataDemplate = Application.Current.Resources["ColoredItemTemplate"] as DataTemplate;
} }
} }

View File

@@ -36,7 +36,7 @@ namespace StructureHelper.Windows.ViewModels
} }
public DataTemplate ItemDataDemplate { get; set; } public DataTemplate ItemDataDemplate { get; set; }
public bool ShowButtons { get; set; }
public ObservableCollection<CollectionItem> CollectionItems { get; } public ObservableCollection<CollectionItem> CollectionItems { get; }
public ICommand SelectAllCommand public ICommand SelectAllCommand

View File

@@ -0,0 +1,23 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.ColorServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace StructureHelperCommon.Infrastructures.Settings
{
public class CalcTermEntity
{
public CalcTerms CalcTerm { get; set; }
public Color Color { get; set; }
public string? Name { get; set; }
public string ShortName { get; set; }
public CalcTermEntity()
{
Color = ColorProcessor.GetRandomColor();
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace StructureHelperCommon.Infrastructures.Settings
{
public class CalcTermList
{
public List<CalcTermEntity> CalcTerms { get; private set; }
public CalcTermList()
{
CalcTerms = new List<CalcTermEntity>()
{
new CalcTermEntity()
{CalcTerm = Enums.CalcTerms.ShortTerm,
Name = "Short term",
ShortName = "Short term",
Color = (Color)ColorConverter.ConvertFromString("Red")},
new CalcTermEntity()
{CalcTerm = Enums.CalcTerms.LongTerm,
Name = "Long term",
ShortName = "Long term",
Color = (Color)ColorConverter.ConvertFromString("Green")}
};
}
}
}

View File

@@ -0,0 +1,23 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.ColorServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace StructureHelperCommon.Infrastructures.Settings
{
public class LimitStateEntity
{
public LimitStates LimitState { get; set; }
public Color Color { get; set; }
public string? Name { get; set; }
public string ShortName { get; set; }
public LimitStateEntity()
{
Color = ColorProcessor.GetRandomColor();
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace StructureHelperCommon.Infrastructures.Settings
{
public class LimitStatesList
{
public List<LimitStateEntity> LimitStates { get; private set; }
public LimitStatesList()
{
LimitStates = new List<LimitStateEntity>()
{
new LimitStateEntity()
{LimitState = Enums.LimitStates.ULS,
Name = "Ultimate limit state",
ShortName = "ULS",
Color = (Color)ColorConverter.ConvertFromString("Red")},
new LimitStateEntity()
{LimitState = Enums.LimitStates.SLS,
Name = "Serviceability limit state",
ShortName = "SLS",
Color = (Color)ColorConverter.ConvertFromString("Green")}
};
}
}
}

View File

@@ -7,5 +7,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
{ {
public static CodeTypes CodeType => CodeTypes.SP63_13330_2018; public static CodeTypes CodeType => CodeTypes.SP63_13330_2018;
public static CrossSectionAxisNames CrossSectionAxisNames => new CrossSectionAxisNames(); public static CrossSectionAxisNames CrossSectionAxisNames => new CrossSectionAxisNames();
public static LimitStatesList LimitStatesList => new LimitStatesList();
public static CalcTermList CalcTermList => new CalcTermList();
} }
} }

View File

@@ -0,0 +1,80 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses
{
public class ExportForceResultToCSVLogic : IExportResultLogic
{
const string separator = ";";
StringBuilder output;
IForcesResults results;
public string FileName { get; set; }
public void Export()
{
ExportHeadings();
ExportBoby();
try
{
File.AppendAllText(FileName, output.ToString());
}
catch (Exception ex)
{
Console.WriteLine("Data could not be written to the CSV file.");
return;
}
}
public ExportForceResultToCSVLogic(IForcesResults forcesResults)
{
this.results = forcesResults;
output = new StringBuilder();
}
private void ExportHeadings()
{
string[] headings =
{
"Limit State",
"Calc duration",
"Mx",
"My",
"Nz",
"kx",
"ky",
"epsz"
};
output.AppendLine(string.Join(separator, headings));
}
private void ExportBoby()
{
foreach (var item in results.ForcesResultList)
{
if (item.IsValid == true)
{
var tuple = item.DesignForceTuple.ForceTuple;
var strainMatrix = item.LoaderResults.StrainMatrix;
string[] newLine =
{
item.DesignForceTuple.LimitState.ToString(),
item.DesignForceTuple.CalcTerm.ToString(),
tuple.Mx.ToString(),
tuple.My.ToString(),
tuple.Nz.ToString(),
strainMatrix.Kx.ToString(),
strainMatrix.Ky.ToString(),
strainMatrix.EpsZ.ToString()
};
output.AppendLine(string.Join(separator, newLine));
}
}
}
}
}

View File

@@ -0,0 +1,67 @@
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses
{
public class ExportGeometryResultToCSVLogic : IExportResultLogic
{
const string separator = ";";
StringBuilder output;
IGeometryResult result;
public string FileName { get; set; }
public ExportGeometryResultToCSVLogic(IGeometryResult geometryResult)
{
this.result = geometryResult;
output = new StringBuilder();
}
public void Export()
{
ExportHeadings();
ExportBoby();
try
{
File.AppendAllText(FileName, output.ToString());
}
catch (Exception ex)
{
Console.WriteLine("Data could not be written to the CSV file.");
return;
}
}
private void ExportHeadings()
{
string[] headings =
{
"Name",
"Short",
"Measerement Unit",
"Value",
"Description",
};
output.AppendLine(string.Join(separator, headings));
}
private void ExportBoby()
{
foreach (var item in result.TextParameters)
{
if (item.IsValid == true)
{
string[] newLine =
{
item.Name,
item.ShortName,
item.MeasurementUnit,
item.Value.ToString(),
item.Description
};
output.AppendLine(string.Join(separator, newLine));
}
}
}
}
}

View File

@@ -1,75 +0,0 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses
{
public class ExportToCSVLogic : IExportResultLogic
{
string filename;
public void Export(INdmResult ndmResult)
{
string separator = ";";
StringBuilder output = new StringBuilder();
if (ndmResult is ForcesResults)
{
var forceResults = ndmResult as ForcesResults;
string[] headings =
{
"Limit State",
"Calc duration",
"Mx",
"My",
"Nz",
"kx",
"ky",
"epsz"
};
output.AppendLine(string.Join(separator, headings));
foreach (var item in forceResults.ForcesResultList)
{
if (item.IsValid == true)
{
var tuple = item.DesignForceTuple.ForceTuple;
var strainMatrix = item.LoaderResults.StrainMatrix;
string[] newLine =
{
item.DesignForceTuple.LimitState.ToString(),
item.DesignForceTuple.CalcTerm.ToString(),
tuple.Mx.ToString(),
tuple.My.ToString(),
tuple.Nz.ToString(),
strainMatrix.Kx.ToString(),
strainMatrix.Ky.ToString(),
strainMatrix.EpsZ.ToString()
};
output.AppendLine(string.Join(separator, newLine));
}
}
try
{
File.AppendAllText(filename, output.ToString());
}
catch (Exception ex)
{
Console.WriteLine("Data could not be written to the CSV file.");
return;
}
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown +": "+ nameof(ndmResult));
}
public ExportToCSVLogic(string filename)
{
this.filename = filename;
}
}
}

View File

@@ -0,0 +1,45 @@
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.Geometry
{
public class GeometryCalculator : IGeometryCalculator
{
TextParametersLogic parametersLogic;
IGeometryResult geometryResult;
public string Name { get; set; }
public INdmResult Result => geometryResult;
public GeometryCalculator(IEnumerable<INdm> ndms, IStrainMatrix strainMatrix)
{
parametersLogic = new TextParametersLogic(ndms, strainMatrix);
}
public GeometryCalculator(TextParametersLogic parametersLogic)
{
this.parametersLogic = parametersLogic;
}
public void Run()
{
geometryResult = new GeometryResult() { IsValid = true };
geometryResult.TextParameters = parametersLogic.GetTextParameters();
}
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,16 @@
using StructureHelperCommon.Models.Parameters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.Geometry
{
public class GeometryResult : IGeometryResult
{
public bool IsValid { get; set; }
public List<ITextParameter> TextParameters { get; set; }
public string Description { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.Geometry
{
public interface IGeometryCalculator : INdmCalculator
{
}
}

View File

@@ -0,0 +1,14 @@
using StructureHelperCommon.Models.Parameters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.Geometry
{
public interface IGeometryResult : INdmResult
{
List<ITextParameter> TextParameters { get; set; }
}
}

View File

@@ -8,6 +8,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses
{ {
public interface IExportResultLogic public interface IExportResultLogic
{ {
void Export(INdmResult ndmResult); string FileName { get; set; }
void Export();
} }
} }

View File

@@ -27,17 +27,51 @@ namespace StructureHelperLogics.Services.NdmPrimitives
{ {
var parameters = new List<ITextParameter>(); var parameters = new List<ITextParameter>();
parameters.AddRange(GetGravityCenter(prefixInitial, ndms)); parameters.AddRange(GetGravityCenter(prefixInitial, ndms));
parameters.AddRange(GetSimpleArea(ndms));
parameters.AddRange(GetArea(prefixInitial, ndms)); parameters.AddRange(GetArea(prefixInitial, ndms));
parameters.AddRange(GetSecondMomentOfArea(prefixInitial, ndms)); parameters.AddRange(GetMomentOfInertia(prefixInitial, ndms));
parameters.AddRange(GetGravityCenter(prefixActual, ndms, strainMatrix)); parameters.AddRange(GetGravityCenter(prefixActual, ndms, strainMatrix));
parameters.AddRange(GetArea(prefixActual, ndms, strainMatrix)); parameters.AddRange(GetArea(prefixActual, ndms, strainMatrix));
parameters.AddRange(GetSecondMomentOfArea(prefixActual, ndms, strainMatrix)); parameters.AddRange(GetMomentOfInertia(prefixActual, ndms, strainMatrix));
parameters.AddRange(GetAreaRatio(ndms, strainMatrix));
parameters.AddRange(GetMomentOfInertiaRatio(ndms, strainMatrix));
return parameters; return parameters;
} }
private IEnumerable<ITextParameter> GetSecondMomentOfArea(string prefix, IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix = null) private IEnumerable<ITextParameter> GetSimpleArea(IEnumerable<INdm> ndms)
{ {
const string name = "Moment of inertia"; const string name = "Summary Area";
const string shortName = "A";
var parameters = new List<ITextParameter>();
var unitArea = CommonOperation.GetUnit(UnitTypes.Area, "mm2");
var unitName = $"{unitArea.Name}";
var unitMultiPlayer = unitArea.Multiplyer;
var firstParameter = new TextParameter()
{
IsValid = true,
Name = $"{name}",
ShortName = $"{shortName}",
MeasurementUnit = unitName,
Description = $"{name} of cross-section without reduction"
};
try
{
firstParameter.Value = ndms.Sum(x => x.Area) * unitMultiPlayer;
}
catch (Exception ex)
{
firstParameter.IsValid = false;
firstParameter.Value = double.NaN;
firstParameter.Description += $": {ex}";
}
parameters.Add(firstParameter);
return parameters;
}
private IEnumerable<ITextParameter> GetMomentOfInertia(string prefix, IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix = null)
{
const string name = "Bending stiffness";
const string shortName = "EI";
var parameters = new List<ITextParameter>(); var parameters = new List<ITextParameter>();
var unitArea = CommonOperation.GetUnit(UnitTypes.Area, "mm2"); var unitArea = CommonOperation.GetUnit(UnitTypes.Area, "mm2");
var unitStress = CommonOperation.GetUnit(UnitTypes.Stress, "MPa"); var unitStress = CommonOperation.GetUnit(UnitTypes.Stress, "MPa");
@@ -47,7 +81,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
{ {
IsValid = true, IsValid = true,
Name = $"{prefix} {name} {firstAxisName.ToUpper()}", Name = $"{prefix} {name} {firstAxisName.ToUpper()}",
ShortName = $"I{firstAxisName}", ShortName = $"{shortName}{firstAxisName}",
MeasurementUnit = unitName, MeasurementUnit = unitName,
Description = $"{prefix} {name} of cross-section arbitrary {firstAxisName}-axis multiplied by {prefix} modulus" Description = $"{prefix} {name} of cross-section arbitrary {firstAxisName}-axis multiplied by {prefix} modulus"
}; };
@@ -55,7 +89,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
{ {
IsValid = true, IsValid = true,
Name = $"{prefix} {name} {secondAxisName}", Name = $"{prefix} {name} {secondAxisName}",
ShortName = $"I{secondAxisName}", ShortName = $"{shortName}{secondAxisName}",
MeasurementUnit = unitName, MeasurementUnit = unitName,
Description = $"{prefix} {name} of cross-section arbitrary {secondAxisName}-axis multiplied by {prefix} modulus" Description = $"{prefix} {name} of cross-section arbitrary {secondAxisName}-axis multiplied by {prefix} modulus"
}; };
@@ -78,9 +112,51 @@ namespace StructureHelperLogics.Services.NdmPrimitives
parameters.Add(secondParameter); parameters.Add(secondParameter);
return parameters; return parameters;
} }
private IEnumerable<ITextParameter> GetMomentOfInertiaRatio(IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix = null)
{
const string name = "Bending stiffness";
const string shortName = "EI";
var parameters = new List<ITextParameter>();
var firstParameter = new TextParameter()
{
IsValid = true,
Name = $"{prefixActual}/{prefixInitial} {name} {firstAxisName.ToUpper()} ratio",
ShortName = $"{shortName}{firstAxisName}-ratio",
MeasurementUnit = "-",
Description = $"{prefixActual}/{prefixInitial} {name} of cross-section arbitrary {firstAxisName}-axis ratio"
};
var secondParameter = new TextParameter()
{
IsValid = true,
Name = $"{prefixActual}/{prefixInitial} {name} {secondAxisName} ratio",
ShortName = $"{shortName}{secondAxisName}-ratio",
MeasurementUnit = "-",
Description = $"{prefixActual}/{prefixInitial} {name} of cross-section arbitrary {secondAxisName}-axis ratio"
};
try
{
var initialMoments = GeometryOperations.GetReducedMomentsOfInertia(locNdms);
var actualMoments = GeometryOperations.GetReducedMomentsOfInertia(locNdms, locStrainMatrix);
firstParameter.Value = actualMoments.MomentX / initialMoments.MomentX;
secondParameter.Value = actualMoments.MomentY / initialMoments.MomentY;
}
catch (Exception ex)
{
firstParameter.IsValid = false;
firstParameter.Value = double.NaN;
firstParameter.Description += $": {ex}";
secondParameter.IsValid = false;
secondParameter.Value = double.NaN;
secondParameter.Description += $": {ex}";
}
parameters.Add(firstParameter);
parameters.Add(secondParameter);
return parameters;
}
private IEnumerable<ITextParameter> GetArea(string prefix, IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix = null) private IEnumerable<ITextParameter> GetArea(string prefix, IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix = null)
{ {
const string name = "Longitudinal stiffness";
const string shortName = "EA";
var parameters = new List<ITextParameter>(); var parameters = new List<ITextParameter>();
var unitArea = CommonOperation.GetUnit(UnitTypes.Area, "mm2"); var unitArea = CommonOperation.GetUnit(UnitTypes.Area, "mm2");
var unitStress = CommonOperation.GetUnit(UnitTypes.Stress, "MPa"); var unitStress = CommonOperation.GetUnit(UnitTypes.Stress, "MPa");
@@ -89,10 +165,10 @@ namespace StructureHelperLogics.Services.NdmPrimitives
var firstParameter = new TextParameter() var firstParameter = new TextParameter()
{ {
IsValid = true, IsValid = true,
Name = $"{prefix} Area", Name = $"{prefix} {name}",
ShortName = "EA", ShortName = $"{shortName}",
MeasurementUnit = unitName, MeasurementUnit = unitName,
Description = $"{prefix} Area of cross-section multiplied by {prefix} modulus" Description = $"{prefix} {name} of cross-section multiplied by {prefix} modulus"
}; };
try try
{ {
@@ -107,13 +183,39 @@ namespace StructureHelperLogics.Services.NdmPrimitives
parameters.Add(firstParameter); parameters.Add(firstParameter);
return parameters; return parameters;
} }
private IEnumerable<ITextParameter> GetAreaRatio(IEnumerable<INdm> locNdms, IStrainMatrix locStrainMatrix)
{
const string name = "Longitudinal stiffness";
const string shortName = "EA";
var parameters = new List<ITextParameter>();
var firstParameter = new TextParameter()
{
IsValid = true,
Name = $"{prefixActual}/{prefixInitial} {name} ratio",
ShortName = $"{shortName}-ratio",
MeasurementUnit = "-",
Description = $"{prefixActual}/{prefixInitial} {name}-ratio of cross-section"
};
try
{
var actual = GeometryOperations.GetReducedArea(locNdms, locStrainMatrix);
var initial = GeometryOperations.GetReducedArea(locNdms);
firstParameter.Value = actual / initial;
}
catch (Exception ex)
{
firstParameter.IsValid = false;
firstParameter.Value = double.NaN;
firstParameter.Description += $": {ex}";
}
parameters.Add(firstParameter);
return parameters;
}
public TextParametersLogic(IEnumerable<INdm> ndms, IStrainMatrix strainMatrix) public TextParametersLogic(IEnumerable<INdm> ndms, IStrainMatrix strainMatrix)
{ {
this.ndms = ndms; this.ndms = ndms;
this.strainMatrix = strainMatrix; this.strainMatrix = strainMatrix;
} }
private IEnumerable<ITextParameter> GetGravityCenter(string prefix, IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix = null) private IEnumerable<ITextParameter> GetGravityCenter(string prefix, IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix = null)
{ {
var parameters = new List<ITextParameter>(); var parameters = new List<ITextParameter>();