RemoveUnderlying property for primitives was added

This commit is contained in:
Evgeny Redikultsev
2023-03-05 19:50:24 +05:00
parent b29d7bfd58
commit edb8afe321
41 changed files with 693 additions and 160 deletions

View File

@@ -4,6 +4,7 @@
{
Point,
Rectangle,
Circle
Circle,
Reinforcement
}
}

View File

@@ -1,4 +1,5 @@
using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.NdmCalculations.Primitives;
@@ -10,7 +11,7 @@ using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class CircleViewPrimitive : PrimitiveBase, IHasDivision, IHasCenter
public class CircleViewPrimitive : PrimitiveBase, IHasCenter
{
ICirclePrimitive primitive;
public double Diameter
@@ -25,8 +26,6 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
RefreshPlacement();
}
}
public int NdmMinDivision { get; set; }
public double NdmMaxSize { get; set; }
public double PrimitiveLeft => DeltaX - Diameter / 2d;
public double PrimitiveTop => DeltaY - Diameter / 2d;
@@ -37,7 +36,9 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\nExpected: {nameof(ICirclePrimitive)}, But was: {nameof(primitive)}");
}
this.primitive = primitive as ICirclePrimitive;
var circle = primitive as ICirclePrimitive;
this.primitive = circle;
DivisionViewModel = new HasDivisionViewModel(circle);
}
public override INdmPrimitive GetNdmPrimitive()

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal static class ViewPrimitiveFactory
{
// to do public static PrimitiveBase GetViewPrimitive() { }
}
}

View File

@@ -1,4 +1,5 @@
using System;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,7 +9,6 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal interface IHasDivision
{
int NdmMinDivision { get; set; }
double NdmMaxSize { get; set; }
HasDivisionViewModel HasDivisionViewModel { get; }
}
}

View File

@@ -1,27 +0,0 @@
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Services.Primitives;
using StructureHelper.UnitSystem.Systems;
using StructureHelper.Windows.MainWindow;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal class LineViewPrimitive : PrimitiveBase
{
public LineViewPrimitive(ILinePrimitive primitive) : base(primitive)
{
}
//public LineViewPrimitive(double x, double y, MainViewModel ownerVM) : base(x, y, ownerVM)
//{
//}
}
}

View File

@@ -18,6 +18,7 @@ using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.Primitives;
using System.Windows.Controls;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
@@ -34,6 +35,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
#endregion
#region Свойства
public HasDivisionViewModel DivisionViewModel { get; set; }
public INdmPrimitive NdmPrimitive
{
get => primitive;
@@ -68,6 +70,15 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
OnPropertyChanged(nameof(InvertedCenterY));
}
}
public bool Triangulate
{
get => primitive.Triangulate;
set
{
primitive.Triangulate = value;
OnPropertyChanged(nameof(Triangulate));
}
}
public double InvertedCenterY => - CenterY;
public double PrestrainKx
{ get => primitive.UsersPrestrain.Kx;

View File

@@ -6,10 +6,13 @@ using StructureHelperCommon.Models.Shapes;
using System;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class RectangleViewPrimitive : PrimitiveBase, IHasDivision, IHasCenter
public class RectangleViewPrimitive : PrimitiveBase, IHasCenter
{
private IRectanglePrimitive primitive;
@@ -42,28 +45,11 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
get => DeltaY - primitive.Height / 2d;
}
public int NdmMinDivision
{
get => primitive.NdmMinDivision;
set
{
primitive.NdmMinDivision = value;
OnPropertyChanged(nameof(NdmMinDivision));
}
}
public double NdmMaxSize
{
get => primitive.NdmMaxSize;
set
{
primitive.NdmMaxSize = value;
OnPropertyChanged(nameof(NdmMaxSize));
}
}
public RectangleViewPrimitive(IRectanglePrimitive _primitive) : base(_primitive)
{
primitive = _primitive;
DivisionViewModel = new HasDivisionViewModel(primitive);
}
public override INdmPrimitive GetNdmPrimitive()

View File

@@ -0,0 +1,16 @@
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal class ReinforcementViewPrimitive : PointViewPrimitive
{
public ReinforcementViewPrimitive(IPointPrimitive _primitive) : base(_primitive)
{
}
}
}

View File

@@ -43,6 +43,7 @@
<MenuItem Header="Add">
<Button Content="Rectangle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Circle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}"/>
<Button Content="Reinforcement" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}"/>
<Button Content="Point" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
</MenuItem>
<Button Content="Edit primitive" Command="{Binding PrimitiveLogic.Edit}"/>
@@ -107,9 +108,10 @@
<Expander.ContextMenu>
<ContextMenu>
<MenuItem Header="Add">
<Button Content="Add Rectangle" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Add Circle" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}"/>
<Button Content="Add Point" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
<Button Content="Rectangle" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Circle" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}"/>
<Button Content="Reinforcement" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}"/>
<Button Content="Point" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
</MenuItem>
</ContextMenu>
</Expander.ContextMenu>
@@ -162,9 +164,10 @@
<Canvas.ContextMenu>
<ContextMenu>
<MenuItem Header="Add">
<Button Content="Add Rectangle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Add Circle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}"/>
<Button Content="Add Point" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
<Button Content="Rectangle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Circle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}"/>
<Button Content="Reinforcement" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}"/>
<Button Content="Point" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
</MenuItem>
<MenuItem Header="Templates">
<Button Content="Concrete beam" Command="{Binding AddBeamCase}"/>

View File

@@ -37,7 +37,7 @@ namespace StructureHelper.Windows.MainWindow
private readonly double scaleRate = 1.1d;
public PrimitiveBase SelectedPrimitive { get; set; }
public IForceCombinationList SelectedForceCombinationList { get; set; }
//public IForceCombinationList SelectedForceCombinationList { get; set; }
private readonly AnalysisVewModelLogic calculatorsLogic;
public AnalysisVewModelLogic CalculatorsLogic { get => calculatorsLogic;}

View File

@@ -58,12 +58,44 @@
</Grid>
</Expander>
</DataTemplate>
<DataTemplate x:Key="ReinforcementProperties">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Inside of"/>
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding PrimitiveMaterial}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Margin="3">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color}"/>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</DataTemplate>
<DataTemplate x:Key="TriangulationProperties">
<Expander Header="Triangulation" IsExpanded="False">
<Expander Header="Triangulation" DataContext="{Binding DivisionViewModel}" IsExpanded="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
@@ -71,8 +103,10 @@
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Minimum element division"/>
<TextBlock Grid.Row="1" Text="Maximum element size"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding MinElementDivision, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Text="{Binding MaxElementSize, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="2" Text="Clear underlying"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding NdmMinDivision, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Text="{Binding NdmMaxSize, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding ClearUnderlying}"/>
</Grid>
</Expander>
</DataTemplate>
@@ -88,6 +122,7 @@
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
@@ -97,6 +132,7 @@
<TextBlock Grid.Row="1" Text="Name of material"/>
<TextBlock Grid.Row="2" Text="Center X"/>
<TextBlock Grid.Row="3" Text="Center Y"/>
<TextBlock Grid.Row="4" Text="Triangulate"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding Name}"/>
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding PrimitiveMaterial}">
<ComboBox.ItemTemplate>
@@ -118,6 +154,7 @@
</ComboBox>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="3" Grid.Column="1" Margin="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<CheckBox Grid.Row="4" Grid.Column="1" IsChecked="{Binding Triangulate}"/>
</Grid>
</Expander>
<Expander Header="Prestrain" IsExpanded="False">

View File

@@ -43,10 +43,11 @@ namespace StructureHelper.Windows.PrimitiveProperiesWindow
private void AddPrimitiveProperties(PrimitiveType type)
{
List<string> names = new List<string>();
if (primitive is IHasDivision) { names.Add("TriangulationProperties");}
if (primitive.DivisionViewModel is not null) { names.Add("TriangulationProperties");}
if (primitive is RectangleViewPrimitive) { names.Add("RectangleProperties"); }
else if (primitive is CircleViewPrimitive) { names.Add("CircleProperties"); }
else if (primitive is PointViewPrimitive) { names.Add("PointProperties"); }
if (primitive is CircleViewPrimitive) { names.Add("CircleProperties"); }
if (primitive is PointViewPrimitive) { names.Add("PointProperties"); }
if (primitive is ReinforcementViewPrimitive) { names.Add("ReinforcementProperties"); }
foreach (var name in names)
{
ContentControl contentControl = new ContentControl();

View File

@@ -14,6 +14,7 @@ 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;
@@ -211,7 +212,24 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
var limitState = SelectedResult.DesignForceTuple.LimitState;
var calcTerm = SelectedResult.DesignForceTuple.CalcTerm;
ndms = NdmPrimitivesService.GetNdms(selectedNdmPrimitives, limitState, calcTerm);
var orderedNdmPrimitives = ndmPrimitives.OrderBy(x => x.VisualProperty.ZIndex);
var ndmRange = new List<INdm>();
foreach (var item in orderedNdmPrimitives)
{
if (item is IHasDivisionSize)
{
var hasDivision = item as IHasDivisionSize;
if (hasDivision.ClearUnderlying == true)
{
ndmRange.RemoveAll(x => hasDivision.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true);
}
}
if (selectedNdmPrimitives.Contains(item) & item.Triangulate == true)
{
ndmRange.AddRange(NdmPrimitivesService.GetNdms(item, limitState, calcTerm));
}
}
ndms = ndmRange;
}
}
}

View File

@@ -53,19 +53,27 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
(
runCommand = new RelayCommand(o =>
{
SelectedItem.Run();
var result = SelectedItem.Result;
if (result.IsValid == false)
try
{
MessageBox.Show(result.Desctription, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
SelectedItem.Run();
var result = SelectedItem.Result;
if (result.IsValid == false)
{
MessageBox.Show(result.Desctription, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
var calculator = SelectedItem as IForceCalculator;
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
}
}
else
catch (Exception ex)
{
var calculator = SelectedItem as IForceCalculator;
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
MessageBox.Show($"{ex}", "There are some errors during solution", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}, o => SelectedItem != null));
}
}

View File

@@ -0,0 +1,56 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
public class HasDivisionViewModel : ViewModelBase, IHasDivisionSize
{
private IHasDivisionSize primitive;
public double NdmMaxSize
{
get { return primitive.NdmMaxSize; }
set
{
primitive.NdmMaxSize = value;
OnPropertyChanged(nameof(NdmMaxSize));
}
}
public int NdmMinDivision
{
get { return primitive.NdmMinDivision; }
set
{
primitive.NdmMinDivision = value;
OnPropertyChanged(nameof(NdmMinDivision));
}
}
public bool ClearUnderlying
{
get { return primitive.ClearUnderlying; }
set
{
primitive.ClearUnderlying = value;
OnPropertyChanged(nameof(ClearUnderlying));
}
}
public HasDivisionViewModel(IHasDivisionSize primitive)
{
this.primitive = primitive;
}
public bool IsPointInside(IPoint2D point)
{
//not required
throw new NotImplementedException();
}
}
}

View File

@@ -69,6 +69,15 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
viewPrimitive = new RectangleViewPrimitive(primitive);
}
else if (primitiveType == PrimitiveType.Reinforcement)
{
var primitive = new ReinforcementPrimitive
{
Area = 0.0005d
};
ndmPrimitive = primitive;
viewPrimitive = new ReinforcementViewPrimitive(primitive);
}
else if (primitiveType == PrimitiveType.Point)
{
var primitive = new PointPrimitive

View File

@@ -3,6 +3,7 @@ using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials;
using StructureHelper.Windows.ColorPickerWindow;
using StructureHelper.Windows.MainWindow.Materials;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.Materials;
@@ -73,7 +74,15 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
OnPropertyChanged(nameof(CenterY));
}
}
public bool Triangulate
{
get { return primitive.Triangulate; }
set
{
primitive.Triangulate = value;
OnPropertyChanged(nameof(Triangulate));
}
}
public double PrestrainKx
{
get => primitive.PrestrainKx;
@@ -94,25 +103,7 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
public double AutoPrestrainKy => primitive.AutoPrestrainKy;
public double AutoPrestrainEpsZ => primitive.AutoPrestrainEpsZ;
public int MinElementDivision
{
get => (primitive as IHasDivision).NdmMinDivision;
set
{
(primitive as IHasDivision).NdmMinDivision = value;
OnPropertyChanged(nameof(MinElementDivision));
}
}
public double MaxElementSize
{
get => (primitive as IHasDivision).NdmMaxSize;
set
{
(primitive as IHasDivision).NdmMaxSize = value;
OnPropertyChanged(nameof(MaxElementSize));
}
}
public HasDivisionViewModel DivisionViewModel => primitive.DivisionViewModel;
public double Width
{