Operation Move primitives to center was added

This commit is contained in:
Evgeny Redikultsev
2022-11-14 21:26:19 +05:00
parent e68ae14963
commit 667b91cbfa
7 changed files with 62 additions and 9 deletions

View File

@@ -54,11 +54,19 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
{ {
primitiveSet = value; primitiveSet = value;
OnPropertyChanged(nameof(PrimitiveSet)); OnPropertyChanged(nameof(PrimitiveSet));
AreaTotal = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Sum(x => x.Area);
OnPropertyChanged(nameof(AreaTotal));
AreaNeg = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value < 0d).Sum(x => x.Area);
OnPropertyChanged(nameof(AreaNeg));
AreaZero = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value == 0d).Sum(x => x.Area);
OnPropertyChanged(nameof(AreaZero));
AreaPos = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value > 0d).Sum(x => x.Area);
OnPropertyChanged(nameof(AreaPos));
SumTotal = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Sum(x => x.Value); SumTotal = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Sum(x => x.Value);
OnPropertyChanged(nameof(SumTotal)); OnPropertyChanged(nameof(SumTotal));
SumNeg = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value < 0).Sum(x => x.Value); SumNeg = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value < 0d).Sum(x => x.Value);
OnPropertyChanged(nameof(SumNeg)); OnPropertyChanged(nameof(SumNeg));
SumPos = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value > 0).Sum(x => x.Value); SumPos = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value > 0d).Sum(x => x.Value);
OnPropertyChanged(nameof(SumPos)); OnPropertyChanged(nameof(SumPos));
} }
@@ -122,6 +130,10 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
} }
} }
} }
public double AreaTotal { get; private set; }
public double AreaNeg { get; private set; }
public double AreaZero { get; private set; }
public double AreaPos { get; private set; }
public double SumTotal { get; private set;} public double SumTotal { get; private set;}
public double SumNeg { get; private set; } public double SumNeg { get; private set; }
public double SumPos { get; private set; } public double SumPos { get; private set; }

View File

@@ -52,6 +52,14 @@
</Expander> </Expander>
<Expander Header="Summary information" IsExpanded="False"> <Expander Header="Summary information" IsExpanded="False">
<StackPanel> <StackPanel>
<TextBlock Text="Total area:"/>
<TextBlock Text="{Binding AreaTotal}"/>
<TextBlock Text="Negative value area:"/>
<TextBlock Text="{Binding AreaNeg}"/>
<TextBlock Text="Zero value area:"/>
<TextBlock Text="{Binding AreaZero}"/>
<TextBlock Text="Positive value area:"/>
<TextBlock Text="{Binding AreaPos}"/>
<TextBlock Text="Total sum: "/> <TextBlock Text="Total sum: "/>
<TextBlock Text="{Binding SumTotal}"/> <TextBlock Text="{Binding SumTotal}"/>
<TextBlock Text="Sum negative: "/> <TextBlock Text="Sum negative: "/>

Binary file not shown.

View File

@@ -15,7 +15,17 @@ namespace StructureHelperLogics.Models.Materials
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{ {
throw new NotImplementedException(); IMaterial material = new Material();
material.InitModulus = Modulus;
IEnumerable<double> parameters = new List<double>() { Modulus};
material.DiagramParameters = parameters;
material.Diagram = GetStress;
return material;
}
private double GetStress (IEnumerable<double> parameters, double strain)
{
return parameters.First() * strain;
} }
public object Clone() public object Clone()

View File

@@ -24,8 +24,12 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TabControl> <TabControl>
<TabItem Header="Forces"> <TabItem Header="Forces">
<StackPanel> <Grid>
<GroupBox Header="Combinations of forces" Height="160"> <Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<GroupBox Grid.Row="0" Header="Combinations of forces" Height="160">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
@@ -46,7 +50,7 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
</GroupBox> </GroupBox>
<Grid Height="80"> <Grid Grid.Row="1" Height="80">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
@@ -64,7 +68,7 @@
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
</Grid> </Grid>
</StackPanel> </Grid>
</TabItem> </TabItem>
<TabItem Header="Iterations"> <TabItem Header="Iterations">
<Grid> <Grid>

View File

@@ -48,6 +48,7 @@
</MenuItem> </MenuItem>
<Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/> <Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/>
<Button Content="Calculation properties" Command="{Binding Path=EditCalculationPropertyCommand}"/> <Button Content="Calculation properties" Command="{Binding Path=EditCalculationPropertyCommand}"/>
<Button Content="Move primitives to center" Command="{Binding Path=MovePrimitiveToGravityCenterCommand}"/>
<MenuItem Header="Templates"> <MenuItem Header="Templates">
<Button Content="Concrete beam" Command="{Binding AddBeamCase}"/> <Button Content="Concrete beam" Command="{Binding AddBeamCase}"/>
<Button Content="Concrete column" Command="{Binding AddColumnCase}"/> <Button Content="Concrete column" Command="{Binding AddColumnCase}"/>

View File

@@ -1,4 +1,5 @@
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Logics.Geometry;
using StructureHelper.Infrastructure; using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums; using StructureHelper.Infrastructure.Enums;
using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelper.Infrastructure.UI.DataContexts;
@@ -25,6 +26,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
@@ -133,6 +135,7 @@ namespace StructureHelper.Windows.MainWindow
public ICommand AddSlabCase { get; } public ICommand AddSlabCase { get; }
public ICommand LeftButtonDown { get; } public ICommand LeftButtonDown { get; }
public ICommand LeftButtonUp { get; } public ICommand LeftButtonUp { get; }
public ICommand MovePrimitiveToGravityCenterCommand { get; }
public ICommand PreviewMouseMove { get; } public ICommand PreviewMouseMove { get; }
public ICommand ClearSelection { get; } public ICommand ClearSelection { get; }
public ICommand OpenMaterialCatalog { get; } public ICommand OpenMaterialCatalog { get; }
@@ -313,10 +316,25 @@ namespace StructureHelper.Windows.MainWindow
Calculate = new RelayCommand(o => Calculate = new RelayCommand(o =>
{ {
CalculateResult(); CalculateResult();
});
},
o => Model.PrimitiveRepository.Primitives.Count() > 0);
EditCalculationPropertyCommand = new RelayCommand (o => EditCalculationProperty()); EditCalculationPropertyCommand = new RelayCommand (o => EditCalculationProperty());
MovePrimitiveToGravityCenterCommand = new RelayCommand(o =>
{
IEnumerable<INdm> ndms = Model.GetNdms(calculationProperty);
double[] center = GeometryOperations.GetGravityCenter(ndms);
foreach (var primitive in Model.PrimitiveRepository.Primitives)
{
primitive.CenterX -= center[0];
primitive.CenterY -= center[1];
}
},
o => Model.PrimitiveRepository.Primitives.Count() > 0
);
SetPopupCanBeClosedTrue = new RelayCommand(o => SetPopupCanBeClosedTrue = new RelayCommand(o =>
{ {
if (!(o is PrimitiveBase primitive)) return; if (!(o is PrimitiveBase primitive)) return;
@@ -345,8 +363,8 @@ namespace StructureHelper.Windows.MainWindow
var dialogResult = MessageBox.Show("Delete primitive?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); var dialogResult = MessageBox.Show("Delete primitive?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {
Primitives.Remove(SelectedPrimitive);
PrimitiveRepository.Delete(SelectedPrimitive); PrimitiveRepository.Delete(SelectedPrimitive);
Primitives.Remove(SelectedPrimitive);
} }
} }
else { MessageBox.Show("Selection is changed", "Please, select primitive", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } else { MessageBox.Show("Selection is changed", "Please, select primitive", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); }