Interpolation of results was added

This commit is contained in:
Evgeny Redikultsev
2022-12-22 11:42:32 +05:00
parent 52c6917a0d
commit b3952767c8
26 changed files with 524 additions and 96 deletions

View File

@@ -7,7 +7,7 @@
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators"
d:DataContext="{d:DesignInstance vm:ForcesResultsViewModel}"
mc:Ignorable="d"
Title="ForceResultsView" Height="350" Width="650" MinHeight="300" MinWidth="400">
Title="ForceResultsView" Height="350" Width="650" MinHeight="300" MinWidth="400" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
@@ -40,7 +40,8 @@
</DataGrid>
<StackPanel Grid.Column="1">
<Button Margin="3" Content="Graphic" Command="{Binding ShowIsoFieldCommand}"/>
<Button Margin="3" Content="Export" Command="{Binding ShowIsoFieldCommand}"/>
<Button Margin="3" Content="Interpolate" Command="{Binding InterpolateCommand}"/>
<Button Margin="3" Content="Export" Command="{Binding ExportToCSVCommand}"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -44,7 +44,6 @@
<Button Content="Delete primitive" Command="{Binding DeletePrimitive}"/>
</MenuItem>
<Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/>
<Button Content="Calculation properties" Command="{Binding Path=EditCalculationPropertyCommand}"/>
<Button Content="Move primitives to center" Command="{Binding Path=MovePrimitiveToGravityCenterCommand}"/>
<MenuItem Header="Templates">
<Button Content="Concrete beam" Command="{Binding AddBeamCase}"/>
@@ -52,9 +51,10 @@
<Button Content="Concrete slab" Command="{Binding AddSlabCase}"/>
</MenuItem>
</MenuItem>
<MenuItem Header="Analysis">
<Button Content="Solve problem" Command="{Binding Path=Calculate}"/>
<!--<MenuItem Header="Analysis">
</MenuItem>
<MenuItem Header="Help">
</MenuItem>-->
</Menu>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>

View File

@@ -9,7 +9,6 @@ using StructureHelper.Models.Primitives.Factories;
using StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow;
using StructureHelper.Windows.CalculationWindows.CalculationResultWindow;
using StructureHelper.Windows.ColorPickerWindow;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.MainWindow.Materials;
using StructureHelper.Windows.PrimitiveProperiesWindow;
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
@@ -24,6 +23,7 @@ using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.Models.Templates.CrossSections.RCs;
using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmCalculations;
@@ -342,7 +342,6 @@ namespace StructureHelper.Windows.MainWindow
repository.Primitives.Add(ndmPrimitive);
}
OnPropertyChanged(nameof(PrimitivesCount));
AddCaseLoads(-50e3d, 50e3d, 0d);
});
AddColumnCase = new RelayCommand(o =>
@@ -354,7 +353,6 @@ namespace StructureHelper.Windows.MainWindow
repository.Primitives.Add(ndmPrimitive);
}
OnPropertyChanged(nameof(PrimitivesCount));
AddCaseLoads(50e3d, 50e3d, -100e3d);
});
AddSlabCase = new RelayCommand(o =>
@@ -366,7 +364,6 @@ namespace StructureHelper.Windows.MainWindow
repository.Primitives.Add(ndmPrimitive);
}
OnPropertyChanged(nameof(PrimitivesCount));
AddCaseLoads(-20e3d, 0d, 0d);
});
Calculate = new RelayCommand(o =>
@@ -507,28 +504,25 @@ namespace StructureHelper.Windows.MainWindow
var view = new CalculationPropertyView(viewModel);
view.ShowDialog();
}
private void AddCaseLoads(double mx, double my, double nz)
{
ForceCombination combination = new ForceCombination();
combination.ForceMatrix.Mx = mx;
combination.ForceMatrix.My = my;
combination.ForceMatrix.Nz = nz;
calculationProperty.ForceCombinations.Add(combination);
}
private IEnumerable<PrimitiveBase> GetCasePrimitives(RectangleBeamTemplate template)
{
var wnd = new RectangleBeamView(template);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
var concrete = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40, ProgramSetting.CodeType);
concrete.Name = "Concrete";
var reinforcement = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforecement400, ProgramSetting.CodeType);
reinforcement.Name = "Reinforcement";
Model.Section.SectionRepository.HeadMaterials.Add(concrete);
Model.Section.SectionRepository.HeadMaterials.Add(reinforcement);
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var newRepository = newSection.SectionRepository;
repository.HeadMaterials.AddRange(newRepository.HeadMaterials);
repository.Primitives.AddRange(newRepository.Primitives);
repository.ForceCombinationLists.AddRange(newRepository.ForceCombinationLists);
repository.CalculatorsList.AddRange(newRepository.CalculatorsList);
OnPropertyChanged(nameof(HeadMaterials));
var primitives = PrimitiveFactory.GetRectangleRCElement(template, concrete, reinforcement);
CombinationsLogic.AddItems(newRepository.ForceCombinationLists);
CalculatorsLogic.AddItems(newRepository.CalculatorsList);
//OnPropertyChanged(nameof(CombinationsLogic.Items));
//OnPropertyChanged(nameof(CalculatorsLogic.Items));
var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(newRepository.Primitives);
foreach (var item in primitives)
{
item.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);

View File

@@ -15,19 +15,27 @@ using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Calculations.CalculationResult
{
public class CalculationResultViewModel
public class CalculationResultViewModel : ViewModelBase
{
public ICalculationResult SelectedResult { get; set; }
public ICommand ShowIsoFieldCommand { get;}
private ObservableCollection<ICalculationResult> calculationResults;
private IEnumerable<INdm> ndms;
private IReport isoFieldReport;
private RelayCommand showIsoFieldCommand;
public RelayCommand ShowIsoFieldCommand
{ get
{
return showIsoFieldCommand ??
(
showIsoFieldCommand = new RelayCommand(o =>
ShowIsoField(),
o => !(SelectedResult is null) && SelectedResult.IsValid));
}
}
public CalculationResultViewModel(IEnumerable<ICalculationResult> results, IEnumerable<INdm> ndmCollection)
{
ShowIsoFieldCommand = new RelayCommand(o=>ShowIsoField(), o=> !(SelectedResult is null) && SelectedResult.IsValid);
//
calculationResults = new ObservableCollection<ICalculationResult>();
ndms = ndmCollection;
foreach (var result in results)

View File

@@ -6,14 +6,17 @@ using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Services.Reports;
using StructureHelper.Services.Reports.CalculationReports;
using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmCalculations;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
@@ -27,26 +30,69 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
private IReport isoFieldReport;
public ForcesResult SelectedResult { get; set; }
private ICommand showIsoFieldCommand;
private RelayCommand showIsoFieldCommand;
private RelayCommand exportToCSVCommand;
private RelayCommand interpolateCommand;
public IForcesResults ForcesResults
{
get => forcesResults;
}
public ICommand ShowIsoFieldCommand
public RelayCommand ShowIsoFieldCommand
{
get
{
return showIsoFieldCommand ??
(
showIsoFieldCommand = new RelayCommand(o =>
(showIsoFieldCommand = new RelayCommand(o =>
{
GetNdms();
ShowIsoField();
}, o => (SelectedResult != null) && SelectedResult.IsValid));
}
}
public RelayCommand ExportToCSVCommand
{
get
{
return exportToCSVCommand ??
(exportToCSVCommand = new RelayCommand(o =>
{
}
));
}
}
public RelayCommand InterpolateCommand
{
get
{
return interpolateCommand ??
(interpolateCommand = new RelayCommand(o =>
{
Interpolate();
}, o => SelectedResult != null));
}
}
private void Interpolate()
{
int stepCount = 100;
var calculator = InterpolateService.InterpolateForceCalculator(forceCalculator, SelectedResult.DesignForceTuple, stepCount);
calculator.Run();
var result = calculator.Result;
if (result is null || result.IsValid == false)
{
MessageBox.Show(result.Desctription, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
wnd.Show();
}
}
public ForcesResultsViewModel(IForceCalculator forceCalculator)

View File

@@ -16,5 +16,7 @@ namespace StructureHelper.Windows.ViewModels
RelayCommand Add { get; }
RelayCommand Delete { get; }
RelayCommand Edit { get; }
RelayCommand Copy { get; }
void AddItems(IEnumerable<TItem> items);
}
}

View File

@@ -1,6 +1,7 @@
using StructureHelper.Infrastructure;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
@@ -18,18 +19,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private readonly ICrossSectionRepository repository;
public INdmCalculator SelectedItem { get; set; }
public ObservableCollection<INdmCalculator> Items
{
get
{
var collection = new ObservableCollection<INdmCalculator>();
foreach (var item in repository.CalculatorsList)
{
collection.Add(item);
}
return collection;
}
}
public ObservableCollection<INdmCalculator> Items { get; private set; }
private RelayCommand addCalculatorCommand;
public RelayCommand Add
@@ -48,6 +38,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private void AddCalculator()
{
var item = new ForceCalculator() { Name = "New force calculator" };
Items.Add(item);
repository.CalculatorsList.Add(item);
}
private RelayCommand editCalculatorCommand;
@@ -115,6 +106,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
}
}
public RelayCommand Copy => throw new NotImplementedException();
private void DeleteCalculator()
{
var dialogResult = MessageBox.Show("Delete calculator?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
@@ -124,9 +117,20 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
OnPropertyChanged(nameof(Items));
}
}
public void AddItems(IEnumerable<INdmCalculator> items)
{
foreach (var item in items)
{
Items.Add(item);
}
}
public CalculatorsViewModelLogic(ICrossSectionRepository repository)
{
this.repository = repository;
Items = new ObservableCollection<INdmCalculator>();
AddItems(this.repository.CalculatorsList);
}
}
}

View File

@@ -20,18 +20,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
public IForceCombinationList SelectedItem { get; set; }
public ObservableCollection<IForceCombinationList> Items
{
get
{
var collection = new ObservableCollection<IForceCombinationList>();
foreach (var item in repository.ForceCombinationLists)
{
collection.Add(item);
}
return collection;
}
}
public ObservableCollection<IForceCombinationList> Items { get; private set; }
private RelayCommand addForceCombinationCommand;
public RelayCommand Add
@@ -50,6 +39,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private void AddCombination()
{
var item = new ForceCombinationList() { Name = "New Force Combination" };
Items.Add(item);
repository.ForceCombinationLists.Add(item);
}
private RelayCommand deleteForceCombinationCommand;
@@ -88,15 +78,28 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
}, o => SelectedItem != null));
}
}
public RelayCommand Copy => throw new NotImplementedException();
private void EditForceCombination()
{
var wnd = new ForceCombinationView(SelectedItem);
wnd.ShowDialog();
}
public void AddItems(IEnumerable<IForceCombinationList> items)
{
foreach (var item in items)
{
Items.Add(item);
}
}
public ForceCombinationViewModelLogic(ICrossSectionRepository repository)
{
this.repository = repository;
Items = new ObservableCollection<IForceCombinationList>();
AddItems(this.repository.ForceCombinationLists);
}
}
}