diff --git a/Infrastructure/UI/DataContexts/Point.cs b/Infrastructure/UI/DataContexts/Point.cs
index ef1b857..b52fde7 100644
--- a/Infrastructure/UI/DataContexts/Point.cs
+++ b/Infrastructure/UI/DataContexts/Point.cs
@@ -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;
}
diff --git a/Infrastructure/UI/DataContexts/PrimitiveBase.cs b/Infrastructure/UI/DataContexts/PrimitiveBase.cs
index 1b6fad6..413a824 100644
--- a/Infrastructure/UI/DataContexts/PrimitiveBase.cs
+++ b/Infrastructure/UI/DataContexts/PrimitiveBase.cs
@@ -19,7 +19,8 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
private bool captured, parameterCaptured, elementLock, paramsPanelVisibilty, popupCanBeClosed = true, borderCaptured;
private Brush brush;
private MaterialDefinitionBase material;
- private double opacity = 1, showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight, showedX, showedY, delta = 0.5;
+ private double opacity = 1, showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight, showedX, showedY;
+ protected double delta = 0.5;
private int showedZIndex = 1, zIndex;
#endregion
@@ -182,102 +183,45 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
#region Команды
public ICommand PrimitiveLeftButtonDown { get; }
public ICommand PrimitiveLeftButtonUp { get; }
- public ICommand RectanglePreviewMouseMove { get; }
- public ICommand PointPreviewMouseMove { get; }
+ public ICommand PreviewMouseMove { get; protected set; }
public ICommand PrimitiveDoubleClick { get; }
#endregion
-
- protected PrimitiveBase(PrimitiveType type, double rectX, double rectY, MainViewModel mainViewModel)
+
+ protected PrimitiveBase(PrimitiveType type, double x, double y, MainViewModel ownerVM)
{
this.type = type;
- Yx1 = rectX;
- Xy1 = rectY;
- var randomR = new Random().Next(150, 255);
- var randomG = new Random().Next(0, 255);
- var randomB = new Random().Next(30, 130);
+ X = ownerVM.YX1 + x;
+ Y = ownerVM.XY1 + y;
+ var randomR = new Random(new Random((int)DateTime.Now.Ticks % 1000).Next(50)).Next(0, 255);
+ var randomG = new Random(new Random((int)DateTime.Now.Ticks % 200).Next(100, 200)).Next(0, 255);
+ var randomB = new Random(new Random((int)DateTime.Now.Ticks % 50).Next(500, 1000)).Next(0, 255);
var color = Color.FromRgb((byte)randomR, (byte)randomG, (byte)randomB);
Brush = new SolidColorBrush(color);
PrimitiveLeftButtonUp = new RelayCommand(o => Captured = false);
PrimitiveLeftButtonDown = new RelayCommand(o => Captured = true);
- RectanglePreviewMouseMove = 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((mainViewModel.PanelX - deltaX - Yx1) / 10) * 10;
- else
- rect.ShowedX = mainViewModel.PanelX - deltaX - Yx1;
-
- if (rect.ShowedY % 10 <= delta || rect.ShowedY % 10 >= 10 - delta)
- rect.ShowedY = -(Math.Round((mainViewModel.PanelY - deltaY - Xy1 + rect.PrimitiveHeight) / 10) * 10);
- else
- rect.ShowedY = -(mainViewModel.PanelY - deltaY - Xy1 + rect.PrimitiveHeight);
- }
- if (ParameterCaptured)
- {
- //RectParameterX = rect.ShowedX;
- //RectParameterY = rect.ShowedY;
- //RectParameterWidth = rect.PrimitiveWidth;
- //RectParameterHeight = rect.PrimitiveHeight;
- //ParameterOpacity = rect.ShowedOpacity;
- //ElementLock = rect.ElementLock;
- }
- });
- PointPreviewMouseMove = 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((mainViewModel.PanelX - Yx1) / 10) * 10;
- else
- point.ShowedX = mainViewModel.PanelX - pointDelta - Yx1;
-
- if (point.ShowedY % 10 <= pointDelta || point.ShowedY % 10 >= 10 - pointDelta)
- point.ShowedY = -(Math.Round((mainViewModel.PanelY - Xy1) / 10) * 10);
- else
- point.ShowedY = -(mainViewModel.PanelY - pointDelta - Xy1);
- }
- if (ParameterCaptured)
- {
- //EllipseParameterX = point.ShowedX;
- //EllipseParameterY = point.ShowedY;
- //EllipseParameterSquare = point.Square;
- //ParameterOpacity = point.ShowedOpacity;
- //ElementLock = point.ElementLock;
- }
- });
+
PrimitiveDoubleClick = new RelayCommand(o =>
{
PopupCanBeClosed = false;
Captured = false;
ParamsPanelVisibilty = true;
ParameterCaptured = true;
-
-
-
- //if (primitive is Rectangle rect)
- // rect.BorderCaptured = false;
});
-
+ OwnerVm = ownerVM;
}
+ protected readonly MainViewModel OwnerVm;
+
private void UpdateCoordinatesX(double showedX)
{
- if (Type == PrimitiveType.Rectangle) X = showedX + Yx1;
- if (Type == PrimitiveType.Point) X = showedX + Yx1 - PrimitiveWidth / 2;
+ if (Type == PrimitiveType.Rectangle) X = showedX + OwnerVm.YX1;
+ if (Type == PrimitiveType.Point) X = showedX + OwnerVm.YX1 - PrimitiveWidth / 2;
}
private void UpdateCoordinatesY(double showedY)
{
- if (Type == PrimitiveType.Rectangle) Y = -showedY + Xy1 - PrimitiveHeight;
- if (Type == PrimitiveType.Point) Y = -showedY + Xy1 - PrimitiveWidth / 2;
+ if (Type == PrimitiveType.Rectangle) Y = -showedY + OwnerVm.XY1 - PrimitiveHeight;
+ if (Type == PrimitiveType.Point) Y = -showedY + OwnerVm.XY1 - PrimitiveWidth / 2;
}
public abstract INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem);
diff --git a/Infrastructure/UI/DataContexts/Rectangle.cs b/Infrastructure/UI/DataContexts/Rectangle.cs
index 7a1dcda..273266d 100644
--- a/Infrastructure/UI/DataContexts/Rectangle.cs
+++ b/Infrastructure/UI/DataContexts/Rectangle.cs
@@ -4,18 +4,39 @@ using StructureHelper.Windows.MainWindow;
using StructureHelperCommon.Models.Entities;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Shapes;
+using System;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class Rectangle : PrimitiveBase
{
- public Rectangle(double primitiveWidth, double primitiveHeight, double rectX, double rectY, MainViewModel mainViewModel) : base(PrimitiveType.Rectangle, rectX, rectY, mainViewModel)
+ public Rectangle(double primitiveWidth, double primitiveHeight, double x, double y, MainViewModel ownerVm) : base(PrimitiveType.Rectangle, x, y, ownerVm)
{
Type = PrimitiveType.Rectangle;
PrimitiveWidth = primitiveWidth;
PrimitiveHeight = primitiveHeight;
- ShowedX = 0;
- ShowedY = 0;
+ 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);
+ }
+ });
+
+ ShowedX = x;
+ ShowedY = y;
}
public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
@@ -27,8 +48,8 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
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 };
+ IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = Material.DesignCompressiveStrength };
+ INdmPrimitive ndmPrimitive = new NdmPrimitive { Center = center, Shape = shape, PrimitiveMaterial = primitiveMaterial, NdmMaxSize = 1, NdmMinDivision = 20 };
return ndmPrimitive;
}
}
diff --git a/Infrastructure/UI/DataTemplates/EllipseTemplate.xaml b/Infrastructure/UI/DataTemplates/EllipseTemplate.xaml
index 30795d1..60bba73 100644
--- a/Infrastructure/UI/DataTemplates/EllipseTemplate.xaml
+++ b/Infrastructure/UI/DataTemplates/EllipseTemplate.xaml
@@ -19,7 +19,7 @@
-
+
diff --git a/Infrastructure/UI/DataTemplates/RectangleTemplate.xaml b/Infrastructure/UI/DataTemplates/RectangleTemplate.xaml
index e4432fc..600342e 100644
--- a/Infrastructure/UI/DataTemplates/RectangleTemplate.xaml
+++ b/Infrastructure/UI/DataTemplates/RectangleTemplate.xaml
@@ -22,7 +22,7 @@
-
+
diff --git a/StructureHelperLogics/Services/CalculationService.cs b/StructureHelperLogics/Services/CalculationService.cs
index af62cc0..3558321 100644
--- a/StructureHelperLogics/Services/CalculationService.cs
+++ b/StructureHelperLogics/Services/CalculationService.cs
@@ -18,7 +18,7 @@ namespace StructureHelperLogics.Services
var ndmCollection = new List();
//Настройки триангуляции, пока опции могут быть только такие
ITriangulationOptions options = new TriangulationOptions { LimiteState = LimitStates.Collapse, CalcTerm = CalcTerms.ShortTerm };
-
+
//Формируем коллекцию элементарных участков для расчета в библитеке (т.е. выполняем триангуляцию)
ndmCollection.AddRange(Triangulation.GetNdms(ndmPrimitives, options));
var loaderData = new LoaderOptions
@@ -32,7 +32,6 @@ namespace StructureHelperLogics.Services
NdmCollection = ndmCollection
};
var calculator = new Calculator();
- //Act
calculator.Run(loaderData, new CancellationToken());
return calculator.Result.StrainMatrix;
}
diff --git a/Windows/MainWindow/MainModel.cs b/Windows/MainWindow/MainModel.cs
index b886b6e..320d936 100644
--- a/Windows/MainWindow/MainModel.cs
+++ b/Windows/MainWindow/MainModel.cs
@@ -22,9 +22,9 @@ namespace StructureHelper.Windows.MainWindow
public IStrainMatrix Calculate(double mx, double my, double nz)
{
var unitSystem = unitSystemService.GetCurrentSystem();
- return calculationService.GetPrimitiveStrainMatrix(primitiveRepository.GetPoints()
+ return calculationService.GetPrimitiveStrainMatrix(primitiveRepository.GetRectangles()
.Select(x => x.GetNdmPrimitive(unitSystem))
- .Concat(primitiveRepository.GetRectangles().Select(x => x.GetNdmPrimitive(unitSystem))).ToArray(), mx, my, nz);
+ .Concat(primitiveRepository.GetPoints().Select(x => x.GetNdmPrimitive(unitSystem))).ToArray(), mx, my, nz);
}
}
}
diff --git a/Windows/MainWindow/MainView.xaml b/Windows/MainWindow/MainView.xaml
index 8f45269..97aa213 100644
--- a/Windows/MainWindow/MainView.xaml
+++ b/Windows/MainWindow/MainView.xaml
@@ -94,6 +94,7 @@
+
diff --git a/Windows/MainWindow/MainViewModel.cs b/Windows/MainWindow/MainViewModel.cs
index 5975fb0..6e1cb5b 100644
--- a/Windows/MainWindow/MainViewModel.cs
+++ b/Windows/MainWindow/MainViewModel.cs
@@ -1,6 +1,8 @@
using System;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Windows.Forms;
using System.Windows.Input;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
@@ -10,6 +12,7 @@ using StructureHelper.MaterialCatalogWindow;
using StructureHelper.Services;
using StructureHelper.Windows.ColorPickerWindow;
using StructureHelper.UnitSystem;
+using StructureHelper.Models.Materials;
namespace StructureHelper.Windows.MainWindow
{
@@ -89,6 +92,7 @@ namespace StructureHelper.Windows.MainWindow
set => OnPropertyChanged(value, ref yY2);
}
public ICommand AddPrimitive { get; }
+ public ICommand AddTestCase { get; }
public ICommand LeftButtonDown { get; }
public ICommand LeftButtonUp { get; }
public ICommand PreviewMouseMove { get; }
@@ -190,14 +194,14 @@ namespace StructureHelper.Windows.MainWindow
primitive.ShowedZIndex = 1;
OnPropertyChanged(nameof(primitive.ShowedZIndex));
});
-
+
ScaleCanvasDown = new RelayCommand(o =>
{
ScrollPanelX = PanelX;
ScrollPanelY = PanelY;
ScaleValue *= scaleRate;
});
-
+
ScaleCanvasUp = new RelayCommand(o =>
{
ScrollPanelX = PanelX;
@@ -206,20 +210,34 @@ namespace StructureHelper.Windows.MainWindow
});
Primitives = new ObservableCollection();
-
+
AddPrimitive = new RelayCommand(o =>
{
if (!(o is PrimitiveType primitiveType)) return;
- var primitive = primitiveType == PrimitiveType.Point
- ? (PrimitiveBase) new Point(50, YX1, XY1, this)
- : (PrimitiveBase) new Rectangle(60, 40, YX1, XY1, this);
+ var primitive = primitiveType == PrimitiveType.Point
+ ? (PrimitiveBase)new Point(50, 0, 0, this)
+ : (PrimitiveBase)new Rectangle(60, 40, 0, 0, this);
Primitives.Add(primitive);
PrimitiveRepository.Add(primitive);
});
+ AddTestCase = new RelayCommand(o =>
+ {
+ foreach (var primitive in GetTestCasePrimitives())
+ {
+ Primitives.Add(primitive);
+ PrimitiveRepository.Add(primitive);
+ }
+ });
+
Calculate = new RelayCommand(o =>
{
- model.Calculate(-50e3, 0d, 0d);
+ var matrix = model.Calculate(10e3, 0d, 0d);
+ MessageBox.Show(
+ $"{nameof(matrix.EpsZ)} = {matrix.EpsZ};\n" +
+ $"{nameof(matrix.Kx)} = {matrix.Kx};\n" +
+ $"{nameof(matrix.Ky)} = {matrix.Ky}",
+ "StructureHelper");
});
SetPopupCanBeClosedTrue = new RelayCommand(o =>
@@ -234,5 +252,20 @@ namespace StructureHelper.Windows.MainWindow
primitive.PopupCanBeClosed = false;
});
}
+
+ private IEnumerable GetTestCasePrimitives()
+ {
+ var width = 400;
+ var height = 600;
+ var d1 = 12;
+ var d2 = 25;
+ var rectMaterial = new ConcreteDefinition("C40", 0, 40, 0, 1.3, 1.5);
+ var pointMaterial = new RebarDefinition("S400", 2, 400, 400, 1.15, 1.15);
+ yield return new Rectangle(width, height, -width / 2, -height / 2, this) { Material = rectMaterial, MaterialName = rectMaterial.MaterialClass };
+ yield return new Point(d1, -width / 2 + 50, -height / 2 + 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
+ yield return new Point(d1, width / 2 - 50, -height / 2 + 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
+ yield return new Point(d2, -width / 2 + 50, height / 2 - 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
+ yield return new Point(d2, width / 2 - 50, height / 2 - 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
+ }
}
}
\ No newline at end of file