diff --git a/App.xaml b/App.xaml
index bf23a8c..ffead6a 100644
--- a/App.xaml
+++ b/App.xaml
@@ -8,6 +8,7 @@
+
diff --git a/Infrastructure/UI/DataContexts/IHasCenter.cs b/Infrastructure/UI/DataContexts/IHasCenter.cs
new file mode 100644
index 0000000..073ac7c
--- /dev/null
+++ b/Infrastructure/UI/DataContexts/IHasCenter.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Infrastructure.UI.DataContexts
+{
+ internal interface IHasCenter
+ {
+ double PrimitiveLeft { get; }
+ double PrimitiveTop { get; }
+ }
+}
diff --git a/Infrastructure/UI/DataContexts/IHasDivision.cs b/Infrastructure/UI/DataContexts/IHasDivision.cs
new file mode 100644
index 0000000..463022d
--- /dev/null
+++ b/Infrastructure/UI/DataContexts/IHasDivision.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Infrastructure.UI.DataContexts
+{
+ internal interface IHasDivision
+ {
+ int NdmMinDivision { get; set; }
+ double NdmMaxSize { get; set; }
+ }
+}
diff --git a/Infrastructure/UI/DataContexts/LinePrimitive.cs b/Infrastructure/UI/DataContexts/LineViewPrimitive.cs
similarity index 57%
rename from Infrastructure/UI/DataContexts/LinePrimitive.cs
rename to Infrastructure/UI/DataContexts/LineViewPrimitive.cs
index c45f5bd..d9df827 100644
--- a/Infrastructure/UI/DataContexts/LinePrimitive.cs
+++ b/Infrastructure/UI/DataContexts/LineViewPrimitive.cs
@@ -4,6 +4,7 @@ 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;
@@ -12,16 +13,15 @@ using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
- internal class LinePrimitive : PrimitiveBase
+ internal class LineViewPrimitive : PrimitiveBase
{
- private ILineShape lineShape;
- public LinePrimitive(PrimitiveType type, double x, double y, MainViewModel ownerVM) : base(type, x, y, ownerVM)
+ public LineViewPrimitive(ILinePrimitive primitive) : base(primitive)
{
+
}
- public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
- {
- throw new NotImplementedException();
- }
+ //public LineViewPrimitive(double x, double y, MainViewModel ownerVM) : base(x, y, ownerVM)
+ //{
+ //}
}
}
diff --git a/Infrastructure/UI/DataContexts/Point.cs b/Infrastructure/UI/DataContexts/Point.cs
deleted file mode 100644
index 315f3f9..0000000
--- a/Infrastructure/UI/DataContexts/Point.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using StructureHelper.Infrastructure.Enums;
-using StructureHelper.UnitSystem.Systems;
-using StructureHelper.Windows.MainWindow;
-using StructureHelperLogics.Models.Primitives;
-using StructureHelperLogics.Models.Materials;
-using StructureHelperCommon.Models.Shapes;
-
-namespace StructureHelper.Infrastructure.UI.DataContexts
-{
- public class Point : PrimitiveBase
- {
- private double area;
- public double Area
- { get => area;
- set
- {
- area = value;
- OnPropertyChanged(nameof(Area));
- OnPropertyChanged(nameof(Diameter));
- }
- }
- public Point(double area, double x, double y, MainViewModel ownerVm) : base(PrimitiveType.Point, x, y, ownerVm)
- {
- Name = "New point";
- Area = area;
- 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);
- }
- });
- CenterX = x;
- CenterY = y;
- }
-
- public double Diameter { get => Math.Sqrt(area / Math.PI) * 2; }
-
- public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
- {
- string materialName = MaterialName;
- ICenter center = new Center { X = CenterX, Y = CenterY };
- IShape shape = new StructureHelperCommon.Models.Shapes.PointShape { Area = this.Area };
- INdmPrimitive ndmPrimitive = new NdmPrimitive(HeadMaterial)
- { Center = center, Shape = shape,
- PrestrainKx = PrestrainKx,
- PrestrainKy = PrestrainKy,
- PrestrainEpsZ = PrestrainEpsZ
- };
- return ndmPrimitive;
- }
- }
-}
diff --git a/Infrastructure/UI/DataContexts/PointViewPrimitive.cs b/Infrastructure/UI/DataContexts/PointViewPrimitive.cs
new file mode 100644
index 0000000..7e8537e
--- /dev/null
+++ b/Infrastructure/UI/DataContexts/PointViewPrimitive.cs
@@ -0,0 +1,49 @@
+using System;
+using StructureHelper.Infrastructure.Enums;
+using StructureHelper.UnitSystem.Systems;
+using StructureHelper.Windows.MainWindow;
+using StructureHelperLogics.Models.Primitives;
+using StructureHelperLogics.Models.Materials;
+using StructureHelperCommon.Models.Shapes;
+using StructureHelperLogics.NdmCalculations.Primitives;
+
+namespace StructureHelper.Infrastructure.UI.DataContexts
+{
+ public class PointViewPrimitive : PrimitiveBase, IHasCenter
+ {
+ const double lengthUnit = 1000d;
+
+ IPointPrimitive primitive;
+
+ public double Area
+ { get => primitive.Area;
+ set
+ {
+ primitive.Area = value;
+ OnPropertyChanged(nameof(Area));
+ OnPropertyChanged(nameof(Diameter));
+ }
+ }
+
+ public double PrimitiveLeft
+ {
+ get => DeltaX - Diameter / 2d * lengthUnit;
+ }
+ public double PrimitiveTop
+ {
+ get => DeltaY - Diameter / 2d * lengthUnit;
+ }
+
+ public PointViewPrimitive(IPointPrimitive _primitive) : base(_primitive)
+ {
+ primitive = _primitive;
+ }
+
+ public double Diameter { get => Math.Sqrt(primitive.Area / Math.PI) * 2; }
+
+ public override INdmPrimitive GetNdmPrimitive()
+ {
+ return primitive;
+ }
+ }
+}
diff --git a/Infrastructure/UI/DataContexts/PrimitiveBase.cs b/Infrastructure/UI/DataContexts/PrimitiveBase.cs
index 30619a5..16419e3 100644
--- a/Infrastructure/UI/DataContexts/PrimitiveBase.cs
+++ b/Infrastructure/UI/DataContexts/PrimitiveBase.cs
@@ -16,6 +16,7 @@ using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.Models.Materials;
using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.Primitives;
+using System.Windows.Controls;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
@@ -23,96 +24,84 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
#region Поля
private IPrimitiveRepository primitiveRepository;
- private readonly PrimitiveType type;
- private string name;
- private double centerX, centerY;
- private int minElementDivision;
- private double maxElementSize;
+ private INdmPrimitive primitive;
private bool captured, parameterCaptured, elementLock, paramsPanelVisibilty, popupCanBeClosed = true, borderCaptured;
- private Brush brush;
private bool setMaterialColor;
private Color color;
- private IHeadMaterial headMaterial;
- private MaterialDefinitionBase material;
- private double prestrainKx, prestrainKy, prestrainEpsZ;
- private double opacity = 1, showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight, showedX, showedY;
+ private double opacity = 1, showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight;
protected double delta = 0.5;
- private double stressValue;
- private double strainValue;
private int showedZIndex = 1, zIndex;
#endregion
#region Свойства
-
- public PrimitiveType Type
+ public INdmPrimitive NdmPrimitive
{
- get => type;
- set
- {
- OnPropertyChanged(value, type);
- OnPropertyChanged(nameof(RectangleFieldVisibility));
- OnPropertyChanged(nameof(PrimitiveDimension));
- OnPropertyChanged(nameof(HeightRowHeight));
- }
+ get => primitive;
}
-
public IPrimitiveRepository PrimitiveRepository => primitiveRepository;
-
+
public string Name
{
- get => name;
+ get => primitive.Name;
set
{
- OnPropertyChanged(value, ref name);
+ primitive.Name = value;
+ OnPropertyChanged(nameof(Name));
}
}
public double CenterX
{
- get => centerX;
+ get => primitive.CenterX;
set
{
- if (this is Rectangle)
- {
- ShowedX = value - primitiveWidth / 2d;
- }
- else if (this is Point)
- {
- Point point = this as Point;
- ShowedX = value - point.Diameter / 2;
- }
- else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown); }
- OnPropertyChanged(value, ref centerX);
+ primitive.CenterX = value;
+ OnPropertyChanged(nameof(CenterX));
}
}
public double CenterY
{
- get => centerY;
+ get => primitive.CenterY;
set
- {
- if (this is Rectangle)
- {
- ShowedY = value - primitiveHeight / 2d;
- }
- else if (this is Point)
- {
- Point point = this as Point;
- ShowedY = value - point.Diameter / 2;
- }
- else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown); }
- OnPropertyChanged(value, ref centerY);
+ {
+ primitive.CenterY = value;
+ OnPropertyChanged(nameof(CenterY));
+ OnPropertyChanged(nameof(InvertedCenterY));
+ }
+ }
+ public double InvertedCenterY => - CenterY;
+ public double PrestrainKx
+ { get => primitive.PrestrainKx;
+ set
+ {
+ primitive.PrestrainKx = value;
+ OnPropertyChanged(nameof(PrestrainKx));
+ }
+ }
+ public double PrestrainKy
+ { get => primitive.PrestrainKy;
+ set
+ {
+ primitive.PrestrainKy = value;
+ OnPropertyChanged(nameof(PrestrainKy));
+ }
+ }
+ public double PrestrainEpsZ
+ { get => primitive.PrestrainEpsZ;
+ set
+ {
+ primitive.PrestrainEpsZ = value;
+ OnPropertyChanged(nameof(PrestrainEpsZ));
}
}
- public double PrestrainKx { get; set; }
- public double PrestrainKy { get; set; }
- public double PrestrainEpsZ { get; set; }
public IHeadMaterial HeadMaterial
{
- get => headMaterial;
+ get => primitive.HeadMaterial;
set
{
- OnPropertyChanged(value, ref headMaterial);
+ primitive.HeadMaterial = value;
+ OnPropertyChanged(nameof(HeadMaterial));
OnPropertyChanged(nameof(Color));
}
}
@@ -120,27 +109,22 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
public bool SetMaterialColor
{
get => setMaterialColor;
- set { OnPropertyChanged(value, ref setMaterialColor);}
+ set
+ {
+ OnPropertyChanged(value, ref setMaterialColor);
+ OnPropertyChanged(nameof(Color));
+ }
+
}
public Color Color
{
- get => ((setMaterialColor == true) & (headMaterial !=null))? headMaterial.Color :color;
+ get => ((setMaterialColor == true) & (primitive.HeadMaterial !=null))? primitive.HeadMaterial.Color : color;
set
{
SetMaterialColor = false;
OnPropertyChanged(value, ref color);
}
}
- public int MinElementDivision
- {
- get => minElementDivision;
- set { OnPropertyChanged(value, ref minElementDivision); }
- }
- public double MaxElementSize
- {
- get => maxElementSize;
- set { OnPropertyChanged(value, ref maxElementSize); }
- }
public bool Captured
{
@@ -162,25 +146,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
get => new SolidColorBrush(Color);
set { }
}
- public MaterialDefinitionBase Material
- {
- get => material;
- set
- {
- if (value != null)
- {
- MaterialName = value.MaterialClass;
- OnPropertyChanged(value, ref material);
- OnPropertyChanged(nameof(MaterialName));
- }
- }
- }
- private string materialName = string.Empty;
- public string MaterialName
- {
- get => materialName;
- set => OnPropertyChanged(value, ref materialName);
- }
+
public bool ParamsPanelVisibilty
{
get => paramsPanelVisibilty;
@@ -221,16 +187,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
get => zIndex;
set => OnPropertyChanged(value, ref zIndex);
}
- public double X
- {
- get => x;
- set => OnPropertyChanged(value, ref x);
- }
- public double Y
- {
- get => y;
- set => OnPropertyChanged(value, ref y);
- }
+
public double Xy1
{
get => xY1;
@@ -241,62 +198,13 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
get => yX1;
set => OnPropertyChanged(value, ref yX1);
}
- public double PrimitiveWidth
- {
- get => primitiveWidth;
- set => OnPropertyChanged(value, ref primitiveWidth);
- }
- public double PrimitiveHeight
- {
- get => primitiveHeight;
- set => OnPropertyChanged(value, ref primitiveHeight);
- }
- public double StressValue
- {
- get { return stressValue; }
- set
- {
- OnPropertyChanged(value, ref stressValue);
- }
- }
- public double StrainValue
- {
- get { return strainValue; }
- set
- {
- OnPropertyChanged(value, ref strainValue);
- }
- }
- public double ShowedX
- {
- get => showedX;
- set
- {
- UpdateCoordinatesX(value);
- OnPropertyChanged(value, ref showedX);
- OnPropertyChanged(nameof(X));
- }
- }
- public double ShowedY
- {
- get => showedY;
- set
- {
- UpdateCoordinatesY(value);
- OnPropertyChanged(value, ref showedY);
- OnPropertyChanged(nameof(Y));
- }
- }
+ public virtual double PrimitiveWidth { get; set; }
+ public virtual double PrimitiveHeight { get;set; }
public bool BorderCaptured
{
get => borderCaptured;
set => OnPropertyChanged(value, ref borderCaptured);
}
-
- public Visibility RectangleFieldVisibility => Type == PrimitiveType.Rectangle ? Visibility.Visible : Visibility.Hidden;
- public string PrimitiveDimension => Type == PrimitiveType.Rectangle ? "Ширина" : "Диаметр";
- public double HeightRowHeight => Type == PrimitiveType.Rectangle ? 40 : 0;
-
#endregion
#region Команды
@@ -307,67 +215,33 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
#endregion
- protected PrimitiveBase(PrimitiveType type, double x, double y, MainViewModel ownerVM)
+ public PrimitiveBase(INdmPrimitive primitive)
{
- this.type = type;
- X = ownerVM.YX1 + x;
- Y = ownerVM.XY1 + y;
color = ColorProcessor.GetRandomColor();
- PrimitiveLeftButtonUp = new RelayCommand(o => Captured = false);
- PrimitiveLeftButtonDown = new RelayCommand(o => Captured = true);
-
- PrimitiveDoubleClick = new RelayCommand(o =>
- {
- //PopupCanBeClosed = false;
- //Captured = false;
- //ParamsPanelVisibilty = true;
- //ParameterCaptured = true;
-
- });
- OwnerVm = ownerVM;
SetMaterialColor = true;
- PrestrainKx = 0;
- PrestrainKy = 0;
- PrestrainEpsZ = 0;
+ this.primitive = primitive;
}
- protected readonly MainViewModel OwnerVm;
-
- private void UpdateCoordinatesX(double showedX)
+ public void RegisterDeltas(double dx, double dy)
{
- if (this is Rectangle)
- {
- X = showedX + OwnerVm.YX1 / UnitConstatnts.Length;
- }
- else if (this is Point)
- {
- Point point = this as Point;
- X = showedX + OwnerVm.YX1 / UnitConstatnts.Length;
- }
- else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown); }
- }
- private void UpdateCoordinatesY(double showedY)
- {
- if (this is Rectangle)
- {
- Y = -showedY + OwnerVm.XY1 / UnitConstatnts.Length - PrimitiveHeight;
- }
- else if (this is Point)
- {
- Point point = this as Point;
- Y = -showedY + OwnerVm.XY1 / UnitConstatnts.Length - point.Diameter;
- }
- else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown); }
+ DeltaX = dx;
+ DeltaY = dy;
}
- public abstract INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem);
- public MaterialTypes GetMaterialTypes()
+ public MainViewModel OwnerVM { get; private set; }
+
+ public double DeltaX { get; private set; }
+ public double DeltaY { get; private set; }
+
+ public virtual INdmPrimitive GetNdmPrimitive()
{
- MaterialTypes materialTypes;
- if (Material is ConcreteDefinition) { materialTypes = MaterialTypes.Concrete; }
- else if (Material is RebarDefinition) { materialTypes = MaterialTypes.Reinforcement; }
- else { throw new StructureHelperException(ErrorStrings.MaterialTypeIsUnknown); }
- return materialTypes;
+ RefreshNdmPrimitive();
+ return primitive;
+ }
+
+ public virtual void RefreshNdmPrimitive()
+ {
+
}
}
}
diff --git a/Infrastructure/UI/DataContexts/Rectangle.cs b/Infrastructure/UI/DataContexts/Rectangle.cs
deleted file mode 100644
index 4e67679..0000000
--- a/Infrastructure/UI/DataContexts/Rectangle.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using StructureHelper.Infrastructure.Enums;
-using StructureHelper.UnitSystem.Systems;
-using StructureHelper.Windows.MainWindow;
-using StructureHelperLogics.Models.Materials;
-using StructureHelperCommon.Models.Shapes;
-using System;
-using StructureHelperLogics.Models.Primitives;
-
-namespace StructureHelper.Infrastructure.UI.DataContexts
-{
- public class Rectangle : PrimitiveBase
- {
- public Rectangle(double primitiveWidth, double primitiveHeight, double x, double y, MainViewModel ownerVm) : base(PrimitiveType.Rectangle, x, y, ownerVm)
- {
- Type = PrimitiveType.Rectangle;
- Name = "New rectangle";
- PrimitiveWidth = primitiveWidth;
- PrimitiveHeight = primitiveHeight;
- PreviewMouseMove = new RelayCommand(o =>
- {
- if (!(o is Rectangle rect)) return;
- if (Captured && !rect.BorderCaptured && !ElementLock)
- {
- var deltaX = PrimitiveWidth / 2;
- var deltaY = PrimitiveHeight / 2;
-
- if (rect.ShowedX % 10 <= delta || rect.ShowedX % 10 >= 10 - delta)
- rect.ShowedX = Math.Round((OwnerVm.PanelX - deltaX - OwnerVm.YX1) / 10) * 10;
- else
- rect.ShowedX = OwnerVm.PanelX - deltaX - OwnerVm.YX1;
-
- if (rect.ShowedY % 10 <= delta || rect.ShowedY % 10 >= 10 - delta)
- rect.ShowedY = -(Math.Round((OwnerVm.PanelY - deltaY - OwnerVm.XY1 + rect.PrimitiveHeight) / 10) * 10);
- else
- rect.ShowedY = -(OwnerVm.PanelY - deltaY - OwnerVm.XY1 + rect.PrimitiveHeight);
- }
- });
- CenterX = x;
- CenterY = y;
- MinElementDivision = 10;
- MaxElementSize = Math.Min(Math.Min(PrimitiveWidth, PrimitiveHeight) / MinElementDivision, 0.01);
- }
-
- public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
- {
- var width = PrimitiveWidth;
- var height = PrimitiveHeight;
- double centerX = CenterX;
- double centerY = CenterY;
- ICenter center = new Center { X = centerX, Y = centerY };
- IShape shape = new StructureHelperCommon.Models.Shapes.RectangleShape { Height = height, Width = width, Angle = 0 };
- INdmPrimitive ndmPrimitive = new NdmPrimitive(HeadMaterial)
- { Center = center, Shape = shape,
- NdmMaxSize = MaxElementSize, NdmMinDivision = MinElementDivision,
- PrestrainKx = PrestrainKx,
- PrestrainKy = PrestrainKy,
- PrestrainEpsZ = PrestrainEpsZ };
- return ndmPrimitive;
- }
- }
-}
diff --git a/Infrastructure/UI/DataContexts/RectangleViewPrimitive.cs b/Infrastructure/UI/DataContexts/RectangleViewPrimitive.cs
new file mode 100644
index 0000000..9182354
--- /dev/null
+++ b/Infrastructure/UI/DataContexts/RectangleViewPrimitive.cs
@@ -0,0 +1,76 @@
+using StructureHelper.Infrastructure.Enums;
+using StructureHelper.UnitSystem.Systems;
+using StructureHelper.Windows.MainWindow;
+using StructureHelperLogics.Models.Materials;
+using StructureHelperCommon.Models.Shapes;
+using System;
+using StructureHelperLogics.Models.Primitives;
+using StructureHelperLogics.NdmCalculations.Primitives;
+
+namespace StructureHelper.Infrastructure.UI.DataContexts
+{
+ public class RectangleViewPrimitive : PrimitiveBase, IHasDivision, IHasCenter
+ {
+ const double lengthUnit = 1000d;
+
+ private IRectanglePrimitive primitive;
+
+ public override double PrimitiveWidth
+ {
+ get => primitive.Width;
+ set
+ {
+ primitive.Width = value;
+ OnPropertyChanged(nameof(PrimitiveLeft));
+ OnPropertyChanged(nameof(PrimitiveWidth));
+ }
+ }
+ public override double PrimitiveHeight
+ {
+ get => primitive.Height;
+ set
+ {
+ primitive.Height = value;
+ OnPropertyChanged(nameof(PrimitiveTop));
+ OnPropertyChanged(nameof(PrimitiveHeight));
+ }
+ }
+
+ public double PrimitiveLeft
+ {
+ get => DeltaX - primitive.Width / 2 * lengthUnit;
+ }
+ public double PrimitiveTop
+ {
+ get => DeltaY - primitive.Height / 2 * lengthUnit;
+ }
+ 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;
+ }
+
+ public override INdmPrimitive GetNdmPrimitive()
+ {
+ return primitive;
+ }
+ }
+}
diff --git a/Infrastructure/UI/DataTemplates/EllipseTemplate.xaml b/Infrastructure/UI/DataTemplates/EllipseTemplate.xaml
index 16d51c2..5ce0f74 100644
--- a/Infrastructure/UI/DataTemplates/EllipseTemplate.xaml
+++ b/Infrastructure/UI/DataTemplates/EllipseTemplate.xaml
@@ -10,21 +10,38 @@
xmlns:userControls="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
mc:Ignorable="d">
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Infrastructure/UI/DataTemplates/RectangleTemplate.xaml b/Infrastructure/UI/DataTemplates/RectangleTemplate.xaml
index 7b4053c..3dc1852 100644
--- a/Infrastructure/UI/DataTemplates/RectangleTemplate.xaml
+++ b/Infrastructure/UI/DataTemplates/RectangleTemplate.xaml
@@ -10,40 +10,46 @@
xmlns:userControls="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
mc:Ignorable="d"
- d:DataContext="{d:DesignInstance dataContexts:Rectangle}">
+ d:DataContext="{d:DesignInstance dataContexts:RectangleViewPrimitive}">
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Infrastructure/UI/Resources/PrimitiveToolTips.xaml b/Infrastructure/UI/Resources/PrimitiveToolTips.xaml
new file mode 100644
index 0000000..30c2688
--- /dev/null
+++ b/Infrastructure/UI/Resources/PrimitiveToolTips.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Infrastructure/UI/Styles.xaml b/Infrastructure/UI/Styles.xaml
index 1c53221..c2c1530 100644
--- a/Infrastructure/UI/Styles.xaml
+++ b/Infrastructure/UI/Styles.xaml
@@ -26,35 +26,6 @@
-
+
+
\ No newline at end of file
diff --git a/MaterialCatalogWindow/MaterialCatalogViewModel.cs b/MaterialCatalogWindow/MaterialCatalogViewModel.cs
index 98527d8..84a5c5d 100644
--- a/MaterialCatalogWindow/MaterialCatalogViewModel.cs
+++ b/MaterialCatalogWindow/MaterialCatalogViewModel.cs
@@ -103,11 +103,6 @@ namespace StructureHelper.MaterialCatalogWindow
OnPropertyChanged(nameof(RebarDefinitions));
}
});
- SelectMaterial = new RelayCommand(o =>
- {
- if (primitive != null)
- primitive.Material = SelectedMaterial;
- });
}
public event PropertyChangedEventHandler PropertyChanged;
diff --git a/Models/Primitives/Factories/PrimitiveFactory.cs b/Models/Primitives/Factories/PrimitiveFactory.cs
new file mode 100644
index 0000000..3f68c55
--- /dev/null
+++ b/Models/Primitives/Factories/PrimitiveFactory.cs
@@ -0,0 +1,81 @@
+using StructureHelper.Infrastructure.UI.DataContexts;
+using StructureHelper.Models.Materials;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperLogics.Models.Primitives;
+using StructureHelperLogics.Models.Templates.RCs;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Models.Primitives.Factories
+{
+ internal static class PrimitiveFactory
+ {
+ public static IEnumerable GetRectangleRCElement(RectangleBeamTemplate template, IHeadMaterial concrete, IHeadMaterial reinforcement)
+ {
+ List primitives = new List();
+ var rect = template.Shape as StructureHelperCommon.Models.Shapes.RectangleShape;
+ var width = rect.Width;
+ var height = rect.Height;
+ var area1 = Math.PI * template.BottomDiameter * template.BottomDiameter / 4d;
+ var area2 = Math.PI * template.TopDiameter * template.TopDiameter / 4d;
+ var gap = template.CoverGap;
+
+ double[] xs = new double[] { -width / 2 + gap, width / 2 - gap };
+ double[] ys = new double[] { -height / 2 + gap, height / 2 - gap };
+
+ var rectangle = new RectanglePrimitive() { Width = width, Height = height, Name = "Concrete block" };
+ primitives.Add(new RectangleViewPrimitive(rectangle) { HeadMaterial = concrete});
+ var point = new PointPrimitive() { CenterX = xs[0], CenterY = ys[0], Area = area1};
+ var viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Left bottom point" };
+ viewPoint.RegisterDeltas(xs[0], ys[0]);
+ primitives.Add(viewPoint);
+ point = new PointPrimitive() {CenterX = xs[1], CenterY = ys[0], Area = area1 };
+ viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Right bottom point" };
+ primitives.Add(viewPoint);
+ point = new PointPrimitive() { CenterX = xs[0], CenterY = ys[1], Area = area2 };
+ viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Left top point" };
+ primitives.Add(viewPoint);
+ point = new PointPrimitive() { CenterX = xs[1], CenterY = ys[1], Area = area2 };
+ viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Right top point" };
+ viewPoint.RegisterDeltas(xs[1], ys[1]);
+ primitives.Add(viewPoint);
+
+ if (template.WidthCount > 2)
+ {
+ int count = template.WidthCount - 1;
+ double dist = (xs[1] - xs[0]) / count;
+ for (int i = 1; i < count; i++)
+ {
+ point = new PointPrimitive() {CenterX = xs[0] + dist * i, CenterY = ys[0], Area = area1 };
+ viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Bottom point {i}" };
+ primitives.Add(viewPoint);
+
+ point = new PointPrimitive() { CenterX = xs[0] + dist * i, CenterY = ys[1], Area = area2 };
+ viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Top point {i}" };
+ primitives.Add(viewPoint);
+ }
+ }
+ if (template.HeightCount > 2)
+ {
+ int count = template.HeightCount - 1;
+ double dist = (ys[1] - ys[0]) / count;
+ for (int i = 1; i < count; i++)
+ {
+ point = new PointPrimitive() {CenterX = xs[0], CenterY = ys[0] + dist * i, Area = area1 };
+ viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Left point {i}" };
+ primitives.Add(viewPoint);
+
+ point = new PointPrimitive() { CenterX = xs[1], CenterY = ys[0] + dist * i, Area = area1 };
+ viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Right point {i}" };
+ primitives.Add(viewPoint);
+ }
+ }
+ return primitives;
+ }
+ }
+}
diff --git a/Services/Primitives/IPrimitiveRepository.cs b/Services/Primitives/IPrimitiveRepository.cs
index 93ddcb5..db5d678 100644
--- a/Services/Primitives/IPrimitiveRepository.cs
+++ b/Services/Primitives/IPrimitiveRepository.cs
@@ -5,8 +5,8 @@ using System.Text;
using System.Threading.Tasks;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelperCommon.Models.Shapes;
-using Point = StructureHelper.Infrastructure.UI.DataContexts.Point;
-using Rectangle = StructureHelper.Infrastructure.UI.DataContexts.Rectangle;
+using Point = StructureHelper.Infrastructure.UI.DataContexts.PointViewPrimitive;
+using Rectangle = StructureHelper.Infrastructure.UI.DataContexts.RectangleViewPrimitive;
namespace StructureHelper.Services.Primitives
{
diff --git a/StructureHelper.csproj b/StructureHelper.csproj
index e00d112..4359cf2 100644
--- a/StructureHelper.csproj
+++ b/StructureHelper.csproj
@@ -140,11 +140,14 @@
-
+
+
+
PrimitivePopup.xaml
+
@@ -184,11 +187,11 @@
-
+
-
+
EllipseTemplate.xaml
@@ -202,7 +205,7 @@
HeadMaterialsView.xaml
-
+
PrimitivePropertiesView.xaml
@@ -212,6 +215,7 @@
+
@@ -236,6 +240,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -284,7 +292,7 @@
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
diff --git a/StructureHelperCommon/Models/Shapes/IPoint.cs b/StructureHelperCommon/Models/Shapes/IPointShape.cs
similarity index 70%
rename from StructureHelperCommon/Models/Shapes/IPoint.cs
rename to StructureHelperCommon/Models/Shapes/IPointShape.cs
index c1077c7..9692b68 100644
--- a/StructureHelperCommon/Models/Shapes/IPoint.cs
+++ b/StructureHelperCommon/Models/Shapes/IPointShape.cs
@@ -1,6 +1,6 @@
namespace StructureHelperCommon.Models.Shapes
{
- public interface IPoint : IShape
+ public interface IPointShape : IShape
{
double Area { get; set; }
}
diff --git a/StructureHelperCommon/Models/Shapes/PointShape.cs b/StructureHelperCommon/Models/Shapes/PointShape.cs
index 31bdd6b..15e0d6b 100644
--- a/StructureHelperCommon/Models/Shapes/PointShape.cs
+++ b/StructureHelperCommon/Models/Shapes/PointShape.cs
@@ -1,6 +1,6 @@
namespace StructureHelperCommon.Models.Shapes
{
- public class PointShape : IPoint
+ public class PointShape : IPointShape
{
public double Area { get; set; }
}
diff --git a/StructureHelperCommon/StructureHelperCommon.csproj b/StructureHelperCommon/StructureHelperCommon.csproj
index ce92dbd..3204093 100644
--- a/StructureHelperCommon/StructureHelperCommon.csproj
+++ b/StructureHelperCommon/StructureHelperCommon.csproj
@@ -59,7 +59,7 @@
-
+
diff --git a/StructureHelperLogics/Models/Materials/HeadMaterial.cs b/StructureHelperLogics/Models/Materials/HeadMaterial.cs
index a622c20..7ae52e0 100644
--- a/StructureHelperLogics/Models/Materials/HeadMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/HeadMaterial.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
@@ -13,11 +14,21 @@ using StructureHelperLogics.Models.Materials;
namespace StructureHelper.Models.Materials
{
- public class HeadMaterial : IHeadMaterial
+ public class HeadMaterial : IHeadMaterial, INotifyPropertyChanged
{
+ private Color color;
+
public string Id { get; }
public string Name { get; set; }
- public Color Color { get; set; }
+ public Color Color
+ {
+ get => color;
+ set
+ {
+ color = value;
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Color)));
+ }
+ }
public IHelperMaterial HelperMaterial {get; set;}
public HeadMaterial()
@@ -26,6 +37,8 @@ namespace StructureHelper.Models.Materials
Color = ColorProcessor.GetRandomColor();
}
+ public event PropertyChangedEventHandler PropertyChanged;
+
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
return HelperMaterial.GetLoaderMaterial(limitState, calcTerm);
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/IHasDivisionSize.cs b/StructureHelperLogics/NdmCalculations/Primitives/IHasDivisionSize.cs
index 8ca8bfb..8590c48 100644
--- a/StructureHelperLogics/NdmCalculations/Primitives/IHasDivisionSize.cs
+++ b/StructureHelperLogics/NdmCalculations/Primitives/IHasDivisionSize.cs
@@ -1,4 +1,5 @@
-using System;
+using StructureHelperLogics.Models.Primitives;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
- internal interface IHasDivisionSize
+ public interface IHasDivisionSize : INdmPrimitive
{
double NdmMaxSize { get; set; }
int NdmMinDivision { get; set; }
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/ILinePrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/ILinePrimitive.cs
new file mode 100644
index 0000000..fc78d08
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Primitives/ILinePrimitive.cs
@@ -0,0 +1,13 @@
+using StructureHelperCommon.Models.Shapes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Primitives
+{
+ public interface ILinePrimitive : IHasDivisionSize, ILineShape
+ {
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/INdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/INdmPrimitive.cs
index 4c723c9..e37ee51 100644
--- a/StructureHelperLogics/NdmCalculations/Primitives/INdmPrimitive.cs
+++ b/StructureHelperLogics/NdmCalculations/Primitives/INdmPrimitive.cs
@@ -5,14 +5,16 @@ using System.Collections;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Materials;
using System.Collections.Generic;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
namespace StructureHelperLogics.Models.Primitives
{
- public interface INdmPrimitive
+ public interface INdmPrimitive : ISaveable, ICloneable
{
string Name { get; set; }
- ICenter Center { get; set; }
- IShape Shape { get; set; }
+ double CenterX { get; set; }
+ double CenterY { get; set; }
IHeadMaterial HeadMaterial { get; set; }
double PrestrainKx { get; set; }
double PrestrainKy { get; set; }
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/IPointPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/IPointPrimitive.cs
new file mode 100644
index 0000000..75ecff6
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Primitives/IPointPrimitive.cs
@@ -0,0 +1,14 @@
+using StructureHelperCommon.Models.Shapes;
+using StructureHelperLogics.Models.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Primitives
+{
+ public interface IPointPrimitive : INdmPrimitive, IPointShape
+ {
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/IRectanglePrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/IRectanglePrimitive.cs
new file mode 100644
index 0000000..a72f327
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Primitives/IRectanglePrimitive.cs
@@ -0,0 +1,13 @@
+using StructureHelperCommon.Models.Shapes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Primitives
+{
+ public interface IRectanglePrimitive : IHasDivisionSize, IRectangleShape
+ {
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs
index 72b61a7..cbf019e 100644
--- a/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs
+++ b/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs
@@ -14,13 +14,12 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
- public class LinePrimitive : INdmPrimitive, ILineShape, IHasDivisionSize, ISaveable, ICloneable
+ public class LinePrimitive : ILinePrimitive
{
- public ICenter Center { get; set; }
- public IShape Shape { get; set; }
-
public int Id { get; set; }
public string Name { get; set; }
+ public double CenterX { get; set; }
+ public double CenterY { get; set; }
public double NdmMaxSize { get; set; }
public int NdmMinDivision { get; set; }
public IHeadMaterial HeadMaterial { get; set; }
@@ -31,6 +30,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public ICenter StartPoint { get; set; }
public ICenter EndPoint { get; set; }
public double Thickness { get; set; }
+
public LinePrimitive()
{
@@ -44,8 +44,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public object Clone()
{
- LinePrimitive primitive = new LinePrimitive();
- NdmPrimitivesService.CopyNdmProperties(this, primitive);
+ var primitive = new LinePrimitive();
NdmPrimitivesService.CopyDivisionProperties(this, primitive);
ShapeService.CopyLineProperties(this, primitive);
return primitive;
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/NdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/PointPrimitive.cs
similarity index 50%
rename from StructureHelperLogics/NdmCalculations/Primitives/NdmPrimitive.cs
rename to StructureHelperLogics/NdmCalculations/Primitives/PointPrimitive.cs
index a67e9d2..460d809 100644
--- a/StructureHelperLogics/NdmCalculations/Primitives/NdmPrimitive.cs
+++ b/StructureHelperLogics/NdmCalculations/Primitives/PointPrimitive.cs
@@ -6,42 +6,56 @@ using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using StructureHelperLogics.NdmCalculations.Triangulations;
+using StructureHelperLogics.Services.NdmPrimitives;
namespace StructureHelperLogics.Models.Primitives
{
- public class NdmPrimitive : INdmPrimitive, ISaveable, ICloneable
+ public class PointPrimitive : IPointPrimitive
{
- public ICenter Center { get; set; }
- public IShape Shape { get; set; }
-
public int Id { get; set; }
public string Name { get; set; }
- public IHeadMaterial HeadMaterial { get; private set; }
+ public double CenterX { get; set; }
+ public double CenterY { get; set; }
+ public IHeadMaterial HeadMaterial { get; set; }
public double NdmMaxSize { get; set; }
public int NdmMinDivision { get; set; }
public double PrestrainKx { get; set; }
public double PrestrainKy { get; set; }
public double PrestrainEpsZ { get; set; }
+ public double Area { get; set; }
- public NdmPrimitive(IHeadMaterial material)
+ public PointPrimitive()
+ {
+ Name = "New Point";
+ Area = 0.0005d;
+ }
+
+ public PointPrimitive(IHeadMaterial material)
{
HeadMaterial = material;
}
public IEnumerable GetNdms(IMaterial material)
{
- throw new System.NotImplementedException();
+ var options = new PointTriangulationLogicOptions(this);
+ IPointTriangulationLogic logic = new PointTriangulationLogic(options);
+ return logic.GetNdmCollection(material);
}
public void Save()
{
- throw new System.NotImplementedException();
+ throw new NotImplementedException();
}
public object Clone()
- {
- throw new NotImplementedException();
+ {
+ var primitive = new PointPrimitive();
+ NdmPrimitivesService.CopyNdmProperties(this, primitive);
+ primitive.Area = Area;
+ return primitive;
}
}
}
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/RectanglePrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/RectanglePrimitive.cs
index ad7721d..399ef65 100644
--- a/StructureHelperLogics/NdmCalculations/Primitives/RectanglePrimitive.cs
+++ b/StructureHelperLogics/NdmCalculations/Primitives/RectanglePrimitive.cs
@@ -5,6 +5,7 @@ using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.ShapeServices;
using StructureHelperLogics.Models.Primitives;
+using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
@@ -14,27 +15,34 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
- public class RectanglePrimitive : INdmPrimitive, IRectangleShape, IHasDivisionSize, ISaveable, ICloneable
+ public class RectanglePrimitive : IRectanglePrimitive
{
+ public int Id { get; set; }
public string Name { get; set; }
- public ICenter Center { get; set; }
- public IShape Shape { get; set; }
+ public double CenterX { get; set; }
+ public double CenterY { get; set; }
public IHeadMaterial HeadMaterial { get; set; }
public double PrestrainKx { get; set; }
public double PrestrainKy { get; set; }
public double PrestrainEpsZ { get; set; }
public double NdmMaxSize { get; set; }
public int NdmMinDivision { get; set; }
- public int Id { get; set; }
-
public double Width { get; set; }
public double Height { get; set; }
public double Angle { get; set; }
+ public RectanglePrimitive()
+ {
+ Name = "New Rectangle";
+ Width = 0.4d;
+ Height = 0.6d;
+ NdmMaxSize = 0.01d;
+ NdmMinDivision = 10;
+ }
+
public object Clone()
{
RectanglePrimitive primitive = new RectanglePrimitive();
- NdmPrimitivesService.CopyNdmProperties(this, primitive);
NdmPrimitivesService.CopyDivisionProperties(this, primitive);
ShapeService.CopyRectangleProperties(this, primitive);
return primitive;
@@ -42,7 +50,11 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public IEnumerable GetNdms(IMaterial material)
{
- throw new NotImplementedException();
+ List ndms = new List();
+ var options = new RectangleTriangulationLogicOptions(this);
+ ITriangulationLogic logic = new RectangleTriangulationLogic(options);
+ ndms.AddRange(logic.GetNdmCollection(material));
+ return ndms;
}
public void Save()
diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs
index 7a56a01..00251a5 100644
--- a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs
+++ b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs
@@ -2,6 +2,7 @@
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Primitives;
+using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
@@ -29,13 +30,10 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
Area = area;
}
- public PointTriangulationLogicOptions(INdmPrimitive primitive)
+ public PointTriangulationLogicOptions(IPointPrimitive primitive)
{
- if (!(primitive.Shape is IPoint)) { throw new StructureHelperException(ErrorStrings.ShapeIsNotCorrect); }
- Center = primitive.Center;
- IPoint point = primitive.Shape as IPoint;
- Center = primitive.Center;
- Area = point.Area;
+ Center = new Center() { X = primitive.CenterX, Y = primitive.CenterY };
+ Area = primitive.Area;
PrestrainKx = primitive.PrestrainKx;
PrestrainKy = primitive.PrestrainKy;
PrestrainEpsZ = primitive.PrestrainEpsZ;
diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs
index 16aafbf..d844b6d 100644
--- a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs
+++ b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs
@@ -33,16 +33,12 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
NdmMinDivision = ndmMinDivision;
}
- public RectangleTriangulationLogicOptions(INdmPrimitive primitive)
+ public RectangleTriangulationLogicOptions(IRectanglePrimitive primitive)
{
- if (! (primitive.Shape is IRectangleShape)) { throw new StructureHelperException(ErrorStrings.ShapeIsNotCorrect); }
- Center = primitive.Center;
- Rectangle = primitive.Shape as IRectangleShape;
- if (primitive is IHasDivisionSize)
- {
- NdmMaxSize = (primitive as IHasDivisionSize).NdmMaxSize;
- NdmMinDivision = (primitive as IHasDivisionSize).NdmMinDivision;
- }
+ Center = new Center() { X = primitive.CenterX, Y = primitive.CenterY };
+ Rectangle = primitive;
+ NdmMaxSize = primitive.NdmMaxSize;
+ NdmMinDivision = primitive.NdmMinDivision;
PrestrainKx = primitive.PrestrainKx;
PrestrainKy = primitive.PrestrainKy;
PrestrainEpsZ = primitive.PrestrainEpsZ;
diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs b/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs
index c643b18..f9c887d 100644
--- a/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs
+++ b/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs
@@ -70,22 +70,23 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
private static IEnumerable GetNdmsByPrimitive(INdmPrimitive primitive, IMaterial material)
{
List ndms = new List();
- ITriangulationLogicOptions options;
- ICenter center = primitive.Center;
- IShape shape = primitive.Shape;
- if (shape is IRectangleShape)
- {
- options = new RectangleTriangulationLogicOptions(primitive);
- ITriangulationLogic logic = new RectangleTriangulationLogic(options);
- ndms.AddRange(logic.GetNdmCollection(material));
- }
- else if (shape is IPoint)
- {
- options = new PointTriangulationLogicOptions(primitive);
- IPointTriangulationLogic logic = new PointTriangulationLogic(options);
- ndms.AddRange(logic.GetNdmCollection(material));
- }
- else { throw new StructureHelperException($"{ErrorStrings.ShapeIsNotCorrect} :{nameof(primitive.Shape)}"); }
+ //ITriangulationLogicOptions options;
+ //ICenter center = primitive.Center;
+ //IShape shape = primitive.Shape;
+ ndms.AddRange(primitive.GetNdms(material));
+ //if (shape is IRectangleShape)
+ //{
+ // options = new RectangleTriangulationLogicOptions(primitive);
+ // ITriangulationLogic logic = new RectangleTriangulationLogic(options);
+ // ndms.AddRange(logic.GetNdmCollection(material));
+ //}
+ //else if (shape is IPoint)
+ //{
+ // options = new PointTriangulationLogicOptions(primitive);
+ // IPointTriangulationLogic logic = new PointTriangulationLogic(options);
+ // ndms.AddRange(logic.GetNdmCollection(material));
+ //}
+ //else { throw new StructureHelperException($"{ErrorStrings.ShapeIsNotCorrect} :{nameof(primitive.Shape)}"); }
return ndms;
}
}
diff --git a/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs b/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs
index 73a7847..c04d7fd 100644
--- a/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs
+++ b/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs
@@ -21,6 +21,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
public static void CopyDivisionProperties(IHasDivisionSize source, IHasDivisionSize target)
{
+ CopyNdmProperties(source, target);
target.NdmMaxSize = source.NdmMaxSize;
target.NdmMinDivision = source.NdmMinDivision;
}
diff --git a/Windows/MainWindow/MainModel.cs b/Windows/MainWindow/MainModel.cs
index 9680e7e..8790f3d 100644
--- a/Windows/MainWindow/MainModel.cs
+++ b/Windows/MainWindow/MainModel.cs
@@ -60,7 +60,7 @@ namespace StructureHelper.Windows.MainWindow
public IEnumerable GetNdms(ICalculationProperty calculationProperty)
{
var unitSystem = unitSystemService.GetCurrentSystem();
- var ndmPrimitives = primitiveRepository.Primitives.Select(x => x.GetNdmPrimitive(unitSystem)).ToArray();
+ var ndmPrimitives = primitiveRepository.Primitives.Select(x => x.GetNdmPrimitive()).ToArray();
//Настройки триангуляции, пока опции могут быть только такие
ITriangulationOptions options = new TriangulationOptions { LimiteState = calculationProperty.LimitState, CalcTerm = calculationProperty.CalcTerm };
diff --git a/Windows/MainWindow/MainView.xaml b/Windows/MainWindow/MainView.xaml
index b393f97..e44a63e 100644
--- a/Windows/MainWindow/MainView.xaml
+++ b/Windows/MainWindow/MainView.xaml
@@ -7,21 +7,18 @@
xmlns:infrastructure="clr-namespace:StructureHelper.Infrastructure"
xmlns:dataTemplates="clr-namespace:StructureHelper.Infrastructure.UI.DataTemplates"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
+ xmlns:vm="clr-namespace:StructureHelper.Windows.MainWindow"
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow"
xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums"
- xmlns:converters ="clr-namespace:StructureHelper.Infrastructure.UI.Converters.Units"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:MainViewModel}"
Title="StructureHelper" Height="700" Width="1000" MinHeight="400" MinWidth="600">
-
-
-
-
+
-
+
@@ -148,7 +145,7 @@
-