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:Stress x:Key="StressConverter"/>
<convertersUnits:Curvature x:Key="Curvature"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</ResourceDictionary>

View File

@@ -1,6 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="SourceToTarget">
<Grid>
<Grid.ColumnDefinitions>
@@ -19,4 +19,27 @@
SelectedItem="{Binding SelectedTargetItem}" ItemTemplate="{Binding ItemDataDemplate}"/>
</Grid>
</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>

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>
</ItemGroup>
<ItemGroup>
<Compile Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculator\GeometryCalculatorResultView.xaml.cs">
<Compile Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\Errors\ErrorMessage.xaml.cs">
@@ -38,7 +38,7 @@
<Page Update="Infrastructure\UI\Resources\Materials.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculator\GeometryCalculatorResultView.xaml">
<Page Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml">
<SubType>Designer</SubType>
</Page>
<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: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.GeometryCalculator"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculator"
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculatorVMs"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:GeometryCalculatorResultViewModel}"
Title="Geometry Properies" Height="450" Width="850" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="90"/>
</Grid.ColumnDefinitions>
<DataGrid x:Name="ResultGrid" IsReadOnly="True" AutoGenerateColumns="False" ItemsSource="{Binding TextParameters}">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
@@ -28,5 +32,8 @@
<DataGridTextColumn Header="Description" Width="400" Binding="{Binding Description}"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Column="1">
<Button Margin="3" Content="Export" ToolTip="Export results to *.csv" Command="{Binding ExportToCSVCommand}"/>
</StackPanel>
</Grid>
</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 StructureHelperLogics.NdmCalculations.Analyses.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -14,7 +15,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculator
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews
{
/// <summary>
/// Логика взаимодействия для GeometryCalculatorResultView.xaml
@@ -22,9 +23,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCa
public partial class GeometryCalculatorResultView : Window
{
GeometryCalculatorResultViewModel viewModel;
public GeometryCalculatorResultView(List<ITextParameter> textParameters)
public GeometryCalculatorResultView(IGeometryResult geometryResult)
{
viewModel = new GeometryCalculatorResultViewModel(textParameters);
viewModel = new GeometryCalculatorResultViewModel(geometryResult);
InitializeComponent();
this.DataContext = viewModel;
}

View File

@@ -7,40 +7,52 @@
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
d:DataContext="{d:DesignInstance vm:InterpolateTuplesViewModel}"
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.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition Width="90"/>
</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 StartDesignForce.ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding StartDesignForce.ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="3" Text="{Binding StartDesignForce.ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="2" Text="Finish Combination"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding FinishDesignForce.ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding FinishDesignForce.ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="2" Grid.Column="3" Text="{Binding FinishDesignForce.ForceTuple.Nz, 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>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="40"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition/>
<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>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource CancelButton}"/>
<Button Style="{StaticResource OkButton}" Click="Button_Click"/>

View File

@@ -10,12 +10,53 @@
mc:Ignorable="d"
Title="Material Diagram" Height="450" Width="800" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding MaterialName}"/>
<lvc:CartesianChart Grid.Row="1" Series="{Binding SeriesCollection}" LegendLocation="Right" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid>
<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:Axis Title="Stress"></lvc:Axis>
</lvc:CartesianChart.AxisY>

View File

@@ -31,7 +31,7 @@ namespace StructureHelper.Windows.MainWindow.Materials
InitializeComponent();
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">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="*"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<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>
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding Items}"/>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource CancelButton}"/>
<Button Style="{StaticResource OkButton}" Click="Button_Click"/>

View File

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

View File

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

View File

@@ -1,76 +1,166 @@
using LiveCharts;
using LiveCharts.Wpf;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Brushes = System.Windows.Media.Brushes;
namespace StructureHelper.Windows.ViewModels.Materials
{
public class MaterialDiagramViewModel
public class MaterialDiagramViewModel : ViewModelBase
{
private IHeadMaterial material;
public string MaterialName => material.Name;
private ICommand redrawLinesCommand;
double minValue;
double maxValue;
int stepCount;
bool positiveInTension;
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 List<string> Labels { 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;
minValue = -0.005d;
maxValue = 0.005d;
stepCount = 50;
positiveInTension = true;
SetLines();
}
private void SetLines()
{
var titles = new List<string>() { "ULS Short Term", "ULS Long Term", "SLS Short Term","SLS Long Term"};
var limitStates = new List<LimitStates> { LimitStates.ULS, LimitStates.SLS };
var calcTerms = new List<CalcTerms> { CalcTerms.ShortTerm, CalcTerms.LongTerm };
var materials = MaterialsModel.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item);
var limitStates = LimitStatesModel.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item);
var calcTerms = CalcTermsModel.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item); ;
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;
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;
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)
foreach (var material in materials)
{
double diagramValue = Math.Round(loaderMaterial.Diagram.Invoke(loaderMaterial.DiagramParameters,s)) * 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)));
var loaderMaterial = material.GetLoaderMaterial(limitState.LimitState, calcTerm.CalcTerm);
var lineSeries = new LineSeries()
{ Title = $"{material.Name} ({calcTerm.ShortName} {limitState.ShortName})",
PointGeometry = null,
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;
}
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;
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 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);
primitiveBase.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
Items.Add(primitiveBase);

View File

@@ -16,7 +16,7 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
public SelectPrimitivesViewModel(IEnumerable<INdmPrimitive> 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;
}
}

View File

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