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

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

View File

@@ -48,6 +48,7 @@
</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}"/>
<Button Content="Concrete column" Command="{Binding AddColumnCase}"/>

View File

@@ -1,4 +1,5 @@
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Logics.Geometry;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Infrastructure.UI.DataContexts;
@@ -25,6 +26,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Security.Cryptography;
using System.Windows.Forms;
using System.Windows.Input;
@@ -133,6 +135,7 @@ namespace StructureHelper.Windows.MainWindow
public ICommand AddSlabCase { get; }
public ICommand LeftButtonDown { get; }
public ICommand LeftButtonUp { get; }
public ICommand MovePrimitiveToGravityCenterCommand { get; }
public ICommand PreviewMouseMove { get; }
public ICommand ClearSelection { get; }
public ICommand OpenMaterialCatalog { get; }
@@ -313,10 +316,25 @@ namespace StructureHelper.Windows.MainWindow
Calculate = new RelayCommand(o =>
{
CalculateResult();
});
},
o => Model.PrimitiveRepository.Primitives.Count() > 0);
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 =>
{
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);
if (dialogResult == DialogResult.Yes)
{
Primitives.Remove(SelectedPrimitive);
PrimitiveRepository.Delete(SelectedPrimitive);
Primitives.Remove(SelectedPrimitive);
}
}
else { MessageBox.Show("Selection is changed", "Please, select primitive", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); }