Calculations fix

This commit is contained in:
NickAppLab
2022-08-30 19:47:52 +05:00
parent 51748407e8
commit cf0392ad6f
9 changed files with 115 additions and 98 deletions

View File

@@ -10,21 +10,40 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class Point : PrimitiveBase
{
public Point(double d, double x, double y, MainViewModel mainViewModel) : base(PrimitiveType.Point, x, y, mainViewModel)
public Point(double d, double x, double y, MainViewModel ownerVm) : base(PrimitiveType.Point, x, y, ownerVm)
{
PrimitiveWidth = d;
ShowedX = 0;
ShowedY = 0;
PrimitiveHeight = d;
PreviewMouseMove = new RelayCommand(o =>
{
if (!(o is Point point)) return;
if (point.Captured && !point.ElementLock)
{
var pointDelta = point.PrimitiveWidth / 2;
if (point.ShowedX % 10 <= pointDelta || point.ShowedX % 10 >= 10 - pointDelta)
point.ShowedX = Math.Round((ownerVm.PanelX - OwnerVm.YX1) / 10) * 10;
else
point.ShowedX = ownerVm.PanelX - pointDelta - OwnerVm.YX1;
if (point.ShowedY % 10 <= pointDelta || point.ShowedY % 10 >= 10 - pointDelta)
point.ShowedY = -(Math.Round((ownerVm.PanelY - OwnerVm.XY1) / 10) * 10);
else
point.ShowedY = -(ownerVm.PanelY - pointDelta - OwnerVm.XY1);
}
});
ShowedX = x;
ShowedY = y;
}
public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
{
var width = unitSystem.ConvertLength(PrimitiveWidth);
double area = Math.Round(width * width * Math.PI / 4, 2);
var diam = unitSystem.ConvertLength(PrimitiveWidth);
double area = diam * diam * Math.PI / 4;
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 = Material.DesingTensileStrength }; ;
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = Material.DesignCompressiveStrength };
INdmPrimitive ndmPrimitive = new NdmPrimitive { Center = center, Shape = shape, PrimitiveMaterial = primitiveMaterial };
return ndmPrimitive;
}