UnitSystem inplementation started, Calculation started

This commit is contained in:
NickAppLab
2022-08-26 01:49:22 +05:00
parent e73702d133
commit 51748407e8
29 changed files with 252 additions and 290 deletions

View File

@@ -1,5 +1,6 @@
using System;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.UnitSystem.Systems;
using StructureHelper.Windows.MainWindow;
using StructureHelperCommon.Models.Entities;
using StructureHelperCommon.Models.Materials;
@@ -9,36 +10,21 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class Point : PrimitiveBase
{
private double square;
public double Square
public Point(double d, double x, double y, MainViewModel mainViewModel) : base(PrimitiveType.Point, x, y, mainViewModel)
{
get => square;
set
{
square = value;
PrimitiveWidth = Math.Round(Math.Sqrt(4 * value / Math.PI), 2);
OnPropertyChanged(nameof(PrimitiveWidth));
OnPropertyChanged();
}
}
public Point(double square, double x, double y, MainViewModel mainViewModel) : base(PrimitiveType.Point, x, y, mainViewModel)
{
Square = square;
PrimitiveWidth = d;
ShowedX = 0;
ShowedY = 0;
}
public override INdmPrimitive GetNdmPrimitive()
public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
{
double strength = 0;
double centerX = 0;
double centerY = 0;
double area = 0;
string materialName = "s400";
ICenter center = new Center { X = centerX, Y = centerY };
var width = unitSystem.ConvertLength(PrimitiveWidth);
double area = Math.Round(width * width * Math.PI / 4, 2);
string materialName = MaterialName;
ICenter center = new Center { X = unitSystem.ConvertLength(ShowedX), Y = unitSystem.ConvertLength(ShowedY) };
IShape shape = new StructureHelperCommon.Models.Shapes.Point { Area = area };
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ;
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = Material.DesingTensileStrength }; ;
INdmPrimitive ndmPrimitive = new NdmPrimitive { Center = center, Shape = shape, PrimitiveMaterial = primitiveMaterial };
return ndmPrimitive;
}

View File

@@ -4,6 +4,7 @@ using System.Windows.Input;
using System.Windows.Media;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Models.Materials;
using StructureHelper.UnitSystem.Systems;
using StructureHelper.Windows.MainWindow;
using StructureHelperCommon.Models.Entities;
using StructureHelperCommon.Models.Materials;
@@ -62,9 +63,12 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
get => material;
set
{
MaterialName = material.MaterialClass;
OnPropertyChanged(value, ref material);
OnPropertyChanged(nameof(MaterialName));
if (value != null)
{
MaterialName = value.MaterialClass;
OnPropertyChanged(value, ref material);
OnPropertyChanged(nameof(MaterialName));
}
}
}
private string materialName = string.Empty;
@@ -276,7 +280,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
if (Type == PrimitiveType.Point) Y = -showedY + Xy1 - PrimitiveWidth / 2;
}
public abstract INdmPrimitive GetNdmPrimitive();
public abstract INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem);
public MaterialTypes GetMaterialTypes()
{
MaterialTypes materialTypes;

View File

@@ -1,4 +1,5 @@
using StructureHelper.Infrastructure.Enums;
using StructureHelper.UnitSystem.Systems;
using StructureHelper.Windows.MainWindow;
using StructureHelperCommon.Models.Entities;
using StructureHelperCommon.Models.Materials;
@@ -17,18 +18,17 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
ShowedY = 0;
}
public override INdmPrimitive GetNdmPrimitive()
public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
{
double strength = 0;
double centerX = 0;
double centerY = 0;
string materialName = "C20";
ICenter center = new Center() { X = centerX, Y = centerY };
double height = 0;
double width = 0;
IShape shape = new StructureHelperCommon.Models.Shapes.Rectangle() { Height = height, Width = width, Angle = 0 };
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial() { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ;
INdmPrimitive ndmPrimitive = new NdmPrimitive() { Center = center, Shape = shape, PrimitiveMaterial = primitiveMaterial };
var width = unitSystem.ConvertLength(PrimitiveWidth);
var height = unitSystem.ConvertLength(PrimitiveHeight);
double centerX = unitSystem.ConvertLength(ShowedX) + width / 2;
double centerY = unitSystem.ConvertLength(ShowedY) + height / 2;
string materialName = MaterialName;
ICenter center = new Center { X = centerX, Y = centerY };
IShape shape = new StructureHelperCommon.Models.Shapes.Rectangle { Height = height, Width = width, Angle = 0 };
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = Material.DesingTensileStrength };
INdmPrimitive ndmPrimitive = new NdmPrimitive { Center = center, Shape = shape, PrimitiveMaterial = primitiveMaterial };
return ndmPrimitive;
}
}