UnitSystem inplementation started, Calculation started
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System.Windows;
|
||||
using Autofac;
|
||||
using StructureHelper.Services;
|
||||
using StructureHelper.UnitSystem;
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelperLogics.Services;
|
||||
|
||||
namespace StructureHelper
|
||||
{
|
||||
@@ -18,7 +20,8 @@ namespace StructureHelper
|
||||
base.OnStartup(e);
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterType<PrimitiveRepository>().As<IPrimitiveRepository>().SingleInstance();
|
||||
builder.RegisterType<PrimitiveService>().As<IPrimitiveService>().SingleInstance();
|
||||
builder.RegisterType<UnitSystemService>().AsSelf().SingleInstance();
|
||||
builder.RegisterType<CalculationService>().AsSelf().SingleInstance();
|
||||
builder.RegisterType<MainModel>().AsSelf().SingleInstance();
|
||||
builder.RegisterType<MainViewModel>().AsSelf().SingleInstance();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,11 +63,14 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
get => material;
|
||||
set
|
||||
{
|
||||
MaterialName = material.MaterialClass;
|
||||
if (value != null)
|
||||
{
|
||||
MaterialName = value.MaterialClass;
|
||||
OnPropertyChanged(value, ref material);
|
||||
OnPropertyChanged(nameof(MaterialName));
|
||||
}
|
||||
}
|
||||
}
|
||||
private string materialName = string.Empty;
|
||||
public string MaterialName
|
||||
{
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="170"/>
|
||||
@@ -61,14 +59,12 @@
|
||||
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Width="50" Margin="10"
|
||||
Text="{Binding ShowedZIndex, Mode=TwoWay}"/>
|
||||
<TextBlock VerticalAlignment="Center" Text="Max = "/>
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitivesCount, Mode=TwoWay}"/>
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitivesCount}"/>
|
||||
</StackPanel>
|
||||
<Button Grid.Row="9" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Установить впереди всех" Margin="10"
|
||||
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetInFrontOfAll}" CommandParameter="{Binding}"/>
|
||||
<Button Grid.Row="9" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Установить позади всех" Margin="10"
|
||||
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetInBackOfAll}" CommandParameter="{Binding}"/>
|
||||
<Button Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Content="Установить параметры"
|
||||
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetParameters}" CommandParameter="{Binding}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace StructureHelper.MaterialCatalogWindow
|
||||
|
||||
private void InitializeRebarDefinitions()
|
||||
{
|
||||
RebarDefinitions = new NamedList<MaterialDefinitionBase>()
|
||||
RebarDefinitions = new NamedList<MaterialDefinitionBase>
|
||||
{
|
||||
new RebarDefinition("S240", 2, 240, 240, 1.15, 1.15),
|
||||
new RebarDefinition("S400", 2, 400, 400, 1.15, 1.15),
|
||||
@@ -38,7 +38,7 @@ namespace StructureHelper.MaterialCatalogWindow
|
||||
|
||||
private void InitializeConcreteDefinitions()
|
||||
{
|
||||
ConcreteDefinitions = new NamedList<MaterialDefinitionBase>()
|
||||
ConcreteDefinitions = new NamedList<MaterialDefinitionBase>
|
||||
{
|
||||
new ConcreteDefinition("C10", 0, 10, 0, 1.3, 1.5),
|
||||
new ConcreteDefinition("C15", 0, 15, 0, 1.3, 1.5),
|
||||
|
||||
@@ -52,24 +52,4 @@ namespace StructureHelper.Services
|
||||
|
||||
public IEnumerable<Rectangle> GetRectangles() => rectangles;
|
||||
}
|
||||
|
||||
public class PrimitiveService : IPrimitiveService
|
||||
{
|
||||
IPrimitiveRepository primitiveRepository;
|
||||
|
||||
public PrimitiveService(IPrimitiveRepository primitiveRepository)
|
||||
{
|
||||
this.primitiveRepository = primitiveRepository;
|
||||
}
|
||||
|
||||
public PointPrimitive[] GetInnerPoints(RectanglePrimitive rectanglePrimitive)
|
||||
{
|
||||
return new[] { new PointPrimitive(new Center(), new StructureHelperCommon.Models.Shapes.Point()) };
|
||||
}
|
||||
}
|
||||
|
||||
public interface IPrimitiveService
|
||||
{
|
||||
PointPrimitive[] GetInnerPoints(RectanglePrimitive rectanglePrimitive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,10 @@
|
||||
<DependentUpon>PrimitivePopup.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Services\PrimitiveService.cs" />
|
||||
<Compile Include="UnitSystem\UnitSystemService.cs" />
|
||||
<Compile Include="UnitSystem\Enums\SystemTypes.cs" />
|
||||
<Compile Include="UnitSystem\Systems\SystemSi.cs" />
|
||||
<Compile Include="UnitSystem\Systems\IUnitSystem.cs" />
|
||||
<Compile Include="Windows\AddMaterialWindow\AddMaterialView.xaml.cs">
|
||||
<DependentUpon>AddMaterialView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -193,6 +197,10 @@
|
||||
<Project>{5dfec3fd-9677-47bb-9e88-eb71828b5913}</Project>
|
||||
<Name>StructureHelperCommon</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="StructureHelperLogics\StructureHelperLogics.csproj">
|
||||
<Project>{330bef5b-15be-4d2c-a750-b1ae50fb2be3}</Project>
|
||||
<Name>StructureHelperLogics</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -17,8 +17,8 @@ namespace StructureHelperCommon.Models.NdmPrimitives
|
||||
{
|
||||
double strength = 400e6d;
|
||||
string materialName = "s400";
|
||||
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial() { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ;
|
||||
INdmPrimitive ndmPrimitive = new NdmPrimitive() { Center = _center, Shape = _shape, PrimitiveMaterial = primitiveMaterial };
|
||||
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ;
|
||||
INdmPrimitive ndmPrimitive = new NdmPrimitive { Center = _center, Shape = _shape, PrimitiveMaterial = primitiveMaterial };
|
||||
return ndmPrimitive;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace StructureHelperCommon.Models.NdmPrimitives
|
||||
{
|
||||
double strength = 40e6d;
|
||||
string materialName = "C40/45";
|
||||
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial() { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ;
|
||||
INdmPrimitive ndmPrimitive = new NdmPrimitive() { Center = _center, Shape = _shape, PrimitiveMaterial = primitiveMaterial, NdmMaxSize = 1, NdmMinDivision = 20 };
|
||||
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ;
|
||||
INdmPrimitive ndmPrimitive = new NdmPrimitive { Center = _center, Shape = _shape, PrimitiveMaterial = primitiveMaterial, NdmMaxSize = 1, NdmMinDivision = 20 };
|
||||
return ndmPrimitive;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
ICenter center = options.Center;
|
||||
double area = options.Area;
|
||||
List<INdm> ndmCollection = new List<INdm>();
|
||||
INdm ndm = new Ndm() { CenterX = center.X, CenterY = center.Y, Area = area, Material = material };
|
||||
INdm ndm = new Ndm { CenterX = center.X, CenterY = center.Y, Area = area, Material = material };
|
||||
ndmCollection.Add(ndm);
|
||||
return ndmCollection;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
using Autofac;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using LoaderCalculator;
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using LoaderCalculator.Data.SourceData;
|
||||
using StructureHelper;
|
||||
using StructureHelper.Services;
|
||||
using StructureHelperCommon.Models.Entities;
|
||||
using StructureHelperCommon.Models.NdmPrimitives;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using StructureHelperLogics.Infrastructures.CommonEnums;
|
||||
|
||||
@@ -17,51 +12,29 @@ namespace StructureHelperLogics.Services
|
||||
{
|
||||
public class CalculationService
|
||||
{
|
||||
public IStrainMatrix GetPrimitiveStrainMatrix(double topArea, double bottomArea, RectanglePrimitive concreteRectangle, double mx, double my, double nz)
|
||||
public IStrainMatrix GetPrimitiveStrainMatrix(INdmPrimitive[] ndmPrimitives, double mx, double my, double nz)
|
||||
{
|
||||
var ndmPrimitives = new List<INdmPrimitive>();
|
||||
//Добавляем прямоугольник бетонного сечения
|
||||
|
||||
ndmPrimitives.Add(concreteRectangle.GetNdmPrimitive());
|
||||
|
||||
using (var scope = App.Container.BeginLifetimeScope())
|
||||
{
|
||||
var primitiveService = scope.Resolve<PrimitiveService>();
|
||||
//Добавляем точки внутри прямоугольника
|
||||
ndmPrimitives.AddRange(primitiveService.GetInnerPoints(concreteRectangle).Select(x=>x.GetNdmPrimitive()));
|
||||
}
|
||||
|
||||
//Коллекция для хранения элементарных участков
|
||||
var ndmCollection = new List<INdm>();
|
||||
//Настройки триангуляции, пока опции могут быть только такие
|
||||
ITriangulationOptions options = new TriangulationOptions
|
||||
{
|
||||
LimiteState = LimitStates.Collapse,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
};
|
||||
ITriangulationOptions options = new TriangulationOptions { LimiteState = LimitStates.Collapse, CalcTerm = CalcTerms.ShortTerm };
|
||||
|
||||
//Формируем коллекцию элементарных участков для расчета в библитеке (т.е. выполняем триангуляцию)
|
||||
ndmCollection.AddRange(Triangulation.GetNdms(ndmPrimitives, options));
|
||||
|
||||
var calculator = new Calculator();
|
||||
var calculationData = new LoaderOptions
|
||||
var loaderData = new LoaderOptions
|
||||
{
|
||||
Preconditions = new Preconditions
|
||||
{
|
||||
ConditionRate = 0.01,
|
||||
MaxIterationCount = 100,
|
||||
StartForceMatrix = new ForceMatrix
|
||||
{
|
||||
Mx = mx,
|
||||
My = my,
|
||||
Nz = nz
|
||||
}
|
||||
StartForceMatrix = new ForceMatrix { Mx = mx, My = my, Nz = nz }
|
||||
},
|
||||
NdmCollection = ndmCollection
|
||||
};
|
||||
calculator.Run(calculationData, new CancellationToken());
|
||||
var results = calculator.Result;
|
||||
return results.StrainMatrix;
|
||||
var calculator = new Calculator();
|
||||
//Act
|
||||
calculator.Run(loaderData, new CancellationToken());
|
||||
return calculator.Result.StrainMatrix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StructureHelper.csproj" />
|
||||
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -37,22 +37,22 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
|
||||
//Коллекция для хранения элементарных участков
|
||||
var ndmCollection = new List<INdm>();
|
||||
//Настройки триангуляции, пока опции могут быть только такие
|
||||
ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
|
||||
ITriangulationOptions options = new TriangulationOptions { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
|
||||
var ndmPrimitives = new List<INdmPrimitive>();
|
||||
//Добавляем прямоугольник бетонного сечения
|
||||
var concreteRectangle = new RectanglePrimitive(new Center() { X = 0, Y = 0 }, new Rectangle() { Width = width, Height = height, Angle = 0 });
|
||||
var concreteRectangle = new RectanglePrimitive(new Center { X = 0, Y = 0 }, new Rectangle { Width = width, Height = height, Angle = 0 });
|
||||
ndmPrimitives.Add(concreteRectangle.GetNdmPrimitive());
|
||||
//Добавляем 4 точки для арматуры
|
||||
// 0.05 - величина защитного слоя (расстояние от грани прямоугольника до центра арматуры
|
||||
//С площадью нижней арматуры
|
||||
var leftBottomReinforcementPoint = new PointPrimitive(new Center() { X = -width / 2 + 0.05d, Y = -height / 2 + 0.05 }, new Point() { Area = bottomArea });
|
||||
var leftBottomReinforcementPoint = new PointPrimitive(new Center { X = -width / 2 + 0.05d, Y = -height / 2 + 0.05 }, new Point { Area = bottomArea });
|
||||
ndmPrimitives.Add(leftBottomReinforcementPoint.GetNdmPrimitive());
|
||||
var rightBottomReinforcementPoint = new PointPrimitive(new Center() { X = width / 2 - 0.05d, Y = -height / 2 + 0.05 }, new Point() { Area = bottomArea });
|
||||
var rightBottomReinforcementPoint = new PointPrimitive(new Center { X = width / 2 - 0.05d, Y = -height / 2 + 0.05 }, new Point { Area = bottomArea });
|
||||
ndmPrimitives.Add(rightBottomReinforcementPoint.GetNdmPrimitive());
|
||||
//С площадью верхней арматуры
|
||||
var leftTopReinforcementPoint = new PointPrimitive(new Center() { X = -width / 2 + 0.05d, Y = height / 2 - 0.05 }, new Point() { Area = topArea });
|
||||
var leftTopReinforcementPoint = new PointPrimitive(new Center { X = -width / 2 + 0.05d, Y = height / 2 - 0.05 }, new Point { Area = topArea });
|
||||
ndmPrimitives.Add(leftTopReinforcementPoint.GetNdmPrimitive());
|
||||
var rightTopReinforcementPoint = new PointPrimitive(new Center() { X = width / 2 - 0.05d, Y = height / 2 - 0.05 }, new Point() { Area = topArea });
|
||||
var rightTopReinforcementPoint = new PointPrimitive(new Center { X = width / 2 - 0.05d, Y = height / 2 - 0.05 }, new Point { Area = topArea });
|
||||
ndmPrimitives.Add(rightTopReinforcementPoint.GetNdmPrimitive());
|
||||
//Формируем коллекцию элементарных участков для расчета в библитеке (т.е. выполняем триангуляцию)
|
||||
ndmCollection.AddRange(Triangulation.GetNdms(ndmPrimitives, options));
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
|
||||
double width = 0.4;
|
||||
double height = 0.6;
|
||||
var ndmCollection = new List<INdm>();
|
||||
ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
|
||||
ITriangulationOptions options = new TriangulationOptions { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
|
||||
var primitives = new List<INdmPrimitive>();
|
||||
primitives.AddRange(GetConcreteNdms(width, height));
|
||||
primitives.AddRange(GetReinforcementNdms(width, height, topArea, bottomArea));
|
||||
@@ -60,11 +60,11 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
|
||||
private IEnumerable<INdmPrimitive> GetConcreteNdms(double width, double height)
|
||||
{
|
||||
double strength = 40e6;
|
||||
ICenter center = new Center() { X = 0, Y = 0 };
|
||||
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = 0 };
|
||||
IPrimitiveMaterial material = new PrimitiveMaterial() { MaterialType = MaterialTypes.Concrete, ClassName = "С40", Strength = strength };
|
||||
ICenter center = new Center { X = 0, Y = 0 };
|
||||
IRectangle rectangle = new Rectangle { Width = width, Height = height, Angle = 0 };
|
||||
IPrimitiveMaterial material = new PrimitiveMaterial { MaterialType = MaterialTypes.Concrete, ClassName = "С40", Strength = strength };
|
||||
//ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
|
||||
INdmPrimitive primitive = new NdmPrimitive() { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 20 };
|
||||
INdmPrimitive primitive = new NdmPrimitive { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 20 };
|
||||
List<INdmPrimitive> primitives = new List<INdmPrimitive> {primitive};
|
||||
return primitives;
|
||||
}
|
||||
@@ -73,27 +73,27 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
|
||||
{
|
||||
double gap = 0.05d;
|
||||
double strength = 4e8;
|
||||
IShape topReinforcement = new Point() { Area = topArea };
|
||||
IShape bottomReinforcement = new Point() { Area = bottomArea };
|
||||
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial() { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength };
|
||||
IShape topReinforcement = new Point { Area = topArea };
|
||||
IShape bottomReinforcement = new Point { Area = bottomArea };
|
||||
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength };
|
||||
//ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
|
||||
ICenter centerRT = new Center() { X = width / 2 - gap, Y = height / 2 - gap };
|
||||
ICenter centerLT = new Center() { X = - (width / 2 - gap), Y = height / 2 - gap };
|
||||
ICenter centerRB = new Center() { X = width / 2 - gap, Y = - (height / 2 - gap) };
|
||||
ICenter centerLB = new Center() { X = -(width / 2 - gap), Y = - (height / 2 - gap) };
|
||||
ICenter centerRT = new Center { X = width / 2 - gap, Y = height / 2 - gap };
|
||||
ICenter centerLT = new Center { X = - (width / 2 - gap), Y = height / 2 - gap };
|
||||
ICenter centerRB = new Center { X = width / 2 - gap, Y = - (height / 2 - gap) };
|
||||
ICenter centerLB = new Center { X = -(width / 2 - gap), Y = - (height / 2 - gap) };
|
||||
List<INdmPrimitive> primitives = new List<INdmPrimitive>();
|
||||
INdmPrimitive primitive;
|
||||
//Right top bar
|
||||
primitive = new NdmPrimitive() { Center = centerRT, Shape = topReinforcement, PrimitiveMaterial = primitiveMaterial};
|
||||
primitive = new NdmPrimitive { Center = centerRT, Shape = topReinforcement, PrimitiveMaterial = primitiveMaterial};
|
||||
primitives.Add(primitive);
|
||||
//Left top bar
|
||||
primitive = new NdmPrimitive() { Center = centerLT, Shape = topReinforcement, PrimitiveMaterial = primitiveMaterial };
|
||||
primitive = new NdmPrimitive { Center = centerLT, Shape = topReinforcement, PrimitiveMaterial = primitiveMaterial };
|
||||
primitives.Add(primitive);
|
||||
//Right bottom bar
|
||||
primitive = new NdmPrimitive() { Center = centerRB, Shape = bottomReinforcement, PrimitiveMaterial = primitiveMaterial };
|
||||
primitive = new NdmPrimitive { Center = centerRB, Shape = bottomReinforcement, PrimitiveMaterial = primitiveMaterial };
|
||||
primitives.Add(primitive);
|
||||
//Left bottom bar
|
||||
primitive = new NdmPrimitive() { Center = centerLB, Shape = bottomReinforcement, PrimitiveMaterial = primitiveMaterial };
|
||||
primitive = new NdmPrimitive { Center = centerLB, Shape = bottomReinforcement, PrimitiveMaterial = primitiveMaterial };
|
||||
primitives.Add(primitive);
|
||||
return primitives;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace StructureHelperTests.FunctionalTests.Ndms.SteelSections
|
||||
public void Run_ShouldPass(double width, double height, double strength, double mx, double my, double nz, double expectedKx, double expectedKy, double expectedEpsilonZ)
|
||||
{
|
||||
//Arrange
|
||||
ICenter center = new Center() { X = 0, Y = 0 };
|
||||
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = 0 };
|
||||
IPrimitiveMaterial material = new PrimitiveMaterial() { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength };
|
||||
ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
|
||||
INdmPrimitive primitive = new NdmPrimitive() { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 100 };
|
||||
ICenter center = new Center { X = 0, Y = 0 };
|
||||
IRectangle rectangle = new Rectangle { Width = width, Height = height, Angle = 0 };
|
||||
IPrimitiveMaterial material = new PrimitiveMaterial { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength };
|
||||
ITriangulationOptions options = new TriangulationOptions { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
|
||||
INdmPrimitive primitive = new NdmPrimitive { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 100 };
|
||||
List<INdmPrimitive> primitives = new List<INdmPrimitive>();
|
||||
primitives.Add(primitive);
|
||||
var ndmCollection = Triangulation.GetNdms(primitives, options);
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace LoaderCalculator.Tests.FunctionalTests.SectionTests
|
||||
double height = 0.6;
|
||||
ArrangeMaterial(LimitStates.Collapse, true);
|
||||
List<INdm> ndmList = new List<INdm>();
|
||||
IStrainMatrix prestrainMatrix = new StrainMatrix() { Kx = prestrainKx, Ky = prestrainKy, EpsZ = prestrainEpsZ };
|
||||
IStrainMatrix prestrainMatrix = new StrainMatrix { Kx = prestrainKx, Ky = prestrainKy, EpsZ = prestrainEpsZ };
|
||||
ndmList.AddRange(GetConcreteNdms(width, height));
|
||||
var reinforcement = GetReinforcementNdms(width, height, topArea, bottomArea);
|
||||
NdmTransform.SetPrestrain(reinforcement, prestrainMatrix);
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
{
|
||||
//Arrange
|
||||
IMaterial material = new Material();
|
||||
ICenter center = new Center() { X = centerX, Y = centerY };
|
||||
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = angle };
|
||||
ICenter center = new Center { X = centerX, Y = centerY };
|
||||
IRectangle rectangle = new Rectangle { Width = width, Height = height, Angle = angle };
|
||||
IRectangleTriangulationLogicOptions options = new StructureHelperLogics.NdmCalculations.Triangulations.RectangleTriangulationLogicOptions(center, rectangle, ndmMaxSize, ndmMinDivision);
|
||||
IRectangleTriangulationLogic logic = new StructureHelperLogics.NdmCalculations.Triangulations.RectangleTriangulationLogic(options);
|
||||
//Act
|
||||
|
||||
23
UnitSystem/Enums/SystemTypes.cs
Normal file
23
UnitSystem/Enums/SystemTypes.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.UnitSystem.Enums
|
||||
{
|
||||
public enum Force
|
||||
{
|
||||
}
|
||||
public enum Pressure
|
||||
{
|
||||
}
|
||||
public enum Length
|
||||
{
|
||||
M
|
||||
}
|
||||
public enum MultiplyPrefix
|
||||
{
|
||||
m
|
||||
}
|
||||
}
|
||||
14
UnitSystem/Systems/IUnitSystem.cs
Normal file
14
UnitSystem/Systems/IUnitSystem.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using StructureHelper.UnitSystem.Enums;
|
||||
|
||||
namespace StructureHelper.UnitSystem.Systems
|
||||
{
|
||||
public interface IUnitSystem
|
||||
{
|
||||
string Name { get; }
|
||||
Tuple<Force, MultiplyPrefix> ForceUnits { get; }
|
||||
Tuple<Pressure, MultiplyPrefix> PressureUnits { get; }
|
||||
Tuple<Length, MultiplyPrefix> LengthUnits { get; }
|
||||
double ConvertLength(double length);
|
||||
}
|
||||
}
|
||||
29
UnitSystem/Systems/SystemSi.cs
Normal file
29
UnitSystem/Systems/SystemSi.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using StructureHelper.UnitSystem.Enums;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
|
||||
namespace StructureHelper.UnitSystem
|
||||
{
|
||||
internal class SystemSi : IUnitSystem
|
||||
{
|
||||
public SystemSi()
|
||||
{
|
||||
LengthUnits = new Tuple<Length, MultiplyPrefix>(Length.M, MultiplyPrefix.m);
|
||||
}
|
||||
|
||||
public string Name => "СИ";
|
||||
public Tuple<Force, MultiplyPrefix> ForceUnits { get; }
|
||||
public Tuple<Pressure, MultiplyPrefix> PressureUnits { get; }
|
||||
public Tuple<Length, MultiplyPrefix> LengthUnits { get; }
|
||||
public double ConvertLength(double length)
|
||||
{
|
||||
switch (LengthUnits.Item2)
|
||||
{
|
||||
case MultiplyPrefix.m:
|
||||
return length / 1000;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
UnitSystem/UnitSystemService.cs
Normal file
19
UnitSystem/UnitSystemService.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
|
||||
namespace StructureHelper.UnitSystem
|
||||
{
|
||||
public class UnitSystemService
|
||||
{
|
||||
private IUnitSystem currentSystem;
|
||||
public IUnitSystem GetCurrentSystem() => currentSystem;
|
||||
public UnitSystemService()
|
||||
{
|
||||
currentSystem = new SystemSi();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,9 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:StructureHelper"
|
||||
xmlns:colorPickerWindow="clr-namespace:StructureHelper.Windows.ColorPickerWindow"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:ColorPickerViewModel}"
|
||||
d:DataContext="{d:DesignInstance colorPickerWindow:ColorPickerViewModel}"
|
||||
Title="Выбрать цвет" Height="200" Width="500" Topmost="True" ResizeMode="NoResize">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -28,6 +29,7 @@
|
||||
<Rectangle Fill="{Binding SelectedColor}"/>
|
||||
</Border>
|
||||
|
||||
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Зеленый"/>
|
||||
<Slider Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="10" Value="{Binding Green}" Minimum="0" Maximum="255"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="10" Text="{Binding Green}"/>
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace StructureHelper.Windows.ColorPickerWindow
|
||||
public Brush SelectedColor
|
||||
{
|
||||
get => selectedColor;
|
||||
set => OnPropertyChanged(value, selectedColor);
|
||||
set => OnPropertyChanged(value, ref selectedColor);
|
||||
}
|
||||
public ICommand SetColor { get; }
|
||||
public ColorPickerViewModel(PrimitiveBase primitive)
|
||||
|
||||
@@ -1,7 +1,30 @@
|
||||
namespace StructureHelper.Windows.MainWindow
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using StructureHelper.Services;
|
||||
using StructureHelper.UnitSystem;
|
||||
using StructureHelperLogics.Services;
|
||||
using System.Linq;
|
||||
|
||||
namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
public class MainModel
|
||||
{
|
||||
private IPrimitiveRepository primitiveRepository;
|
||||
private CalculationService calculationService;
|
||||
private UnitSystemService unitSystemService;
|
||||
|
||||
public MainModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService)
|
||||
{
|
||||
this.primitiveRepository = primitiveRepository;
|
||||
this.calculationService = calculationService;
|
||||
this.unitSystemService = unitSystemService;
|
||||
}
|
||||
|
||||
public IStrainMatrix Calculate(double mx, double my, double nz)
|
||||
{
|
||||
var unitSystem = unitSystemService.GetCurrentSystem();
|
||||
return calculationService.GetPrimitiveStrainMatrix(primitiveRepository.GetPoints()
|
||||
.Select(x => x.GetNdmPrimitive(unitSystem))
|
||||
.Concat(primitiveRepository.GetRectangles().Select(x => x.GetNdmPrimitive(unitSystem))).ToArray(), mx, my, nz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
|
||||
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow"
|
||||
xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:MainViewModel}"
|
||||
Title="StructureHelper" Height="700" Width="1000">
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Command="{Binding SetParameters}" Key="Enter"/>
|
||||
</Window.InputBindings>
|
||||
<Window.Resources>
|
||||
<DataTemplate DataType="{x:Type dataContexts:Rectangle}">
|
||||
<dataTemplates:RectangleTemplate/>
|
||||
@@ -29,7 +27,10 @@
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border BorderBrush="Black" Background="White" BorderThickness="1" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border BorderBrush="Black" Background="White" BorderThickness="1" Margin="5" Grid.ColumnSpan="5">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="PreviewMouseDown">
|
||||
<i:InvokeCommandAction Command="{Binding ClearSelection}" CommandParameter="{Binding}"/>
|
||||
@@ -87,8 +88,15 @@
|
||||
</Canvas>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
<Button Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Content="Справочник" Command="{Binding OpenMaterialCatalog}"/>
|
||||
<Button Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Content="Добавить прямоугольник" Command="{Binding AddRectangle}"/>
|
||||
<Button Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Content="Добавить точку" Command="{Binding AddEllipse}"/>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||
<Button VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Content="Справочник" Command="{Binding OpenMaterialCatalog}"/>
|
||||
<Button VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Content="Система едениц" Command="{Binding OpenUnitsSystemSettings}"/>
|
||||
<Label VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Content="{Binding UnitsSystemName}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button VerticalAlignment="Center" Margin="5" Content="Добавить прямоугольник" Command="{Binding AddPrimitive}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
|
||||
<Button VerticalAlignment="Center" Margin="5" Content="Добавить точку" Command="{Binding AddPrimitive}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
|
||||
</StackPanel>
|
||||
<Button Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5" Content="Рассчитать" Command="{Binding Calculate}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -6,12 +6,10 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public partial class MainView : Window
|
||||
{
|
||||
public IPrimitiveRepository PrimitiveRepository { get; }
|
||||
public IPrimitiveService PrimitiveService { get; }
|
||||
|
||||
public MainView(IPrimitiveRepository primitiveRepository, IPrimitiveService primitiveService, MainViewModel viewModel)
|
||||
public MainView(IPrimitiveRepository primitiveRepository, MainViewModel viewModel)
|
||||
{
|
||||
PrimitiveRepository = primitiveRepository;
|
||||
PrimitiveService = primitiveService;
|
||||
DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@@ -3,21 +3,25 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Input;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Infrastructure.Extensions;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.MaterialCatalogWindow;
|
||||
using StructureHelper.Services;
|
||||
using StructureHelper.Windows.ColorPickerWindow;
|
||||
using StructureHelper.UnitSystem;
|
||||
|
||||
namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
public class MainViewModel : ViewModelBase
|
||||
{
|
||||
private IPrimitiveService PrimitiveService { get; }
|
||||
private readonly double scaleRate = 1.1;
|
||||
|
||||
private IPrimitiveRepository PrimitiveRepository { get; }
|
||||
private readonly UnitSystemService unitSystemService;
|
||||
|
||||
private MainModel Model { get; }
|
||||
public ObservableCollection<PrimitiveBase> Primitives { get; set; }
|
||||
public ICommand AddRectangle { get; }
|
||||
|
||||
private double panelX, panelY, scrollPanelX, scrollPanelY;
|
||||
|
||||
@@ -42,85 +46,9 @@ namespace StructureHelper.Windows.MainWindow
|
||||
set => OnPropertyChanged(value, ref scrollPanelY);
|
||||
}
|
||||
|
||||
private double rectParameterX, rectParameterY, rectParameterWidth, rectParameterHeight;
|
||||
|
||||
public double RectParameterX
|
||||
{
|
||||
get => rectParameterX;
|
||||
set => OnPropertyChanged(value, ref rectParameterX);
|
||||
}
|
||||
public double RectParameterY
|
||||
{
|
||||
get => rectParameterY;
|
||||
set => OnPropertyChanged(value, ref rectParameterY);
|
||||
}
|
||||
public double RectParameterWidth
|
||||
{
|
||||
get => rectParameterWidth;
|
||||
set => OnPropertyChanged(value, ref rectParameterWidth);
|
||||
}
|
||||
public double RectParameterHeight
|
||||
{
|
||||
get => rectParameterHeight;
|
||||
set => OnPropertyChanged(value, ref rectParameterHeight);
|
||||
}
|
||||
|
||||
private double parameterOpacity = 0;
|
||||
|
||||
public double ParameterOpacity
|
||||
{
|
||||
get => parameterOpacity;
|
||||
set
|
||||
{
|
||||
if (value >= 0 && value <= 100)
|
||||
OnPropertyChanged(value, ref parameterOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
private double pointParameterX, pointParameterY, pointParameterSquare;
|
||||
public double EllipseParameterX
|
||||
{
|
||||
get => pointParameterX;
|
||||
set => OnPropertyChanged(value, ref pointParameterX);
|
||||
}
|
||||
|
||||
public double EllipseParameterY
|
||||
{
|
||||
get => pointParameterY;
|
||||
set => OnPropertyChanged(value, ref pointParameterY);
|
||||
}
|
||||
|
||||
public double EllipseParameterSquare
|
||||
{
|
||||
get => pointParameterSquare;
|
||||
set => OnPropertyChanged(value, ref pointParameterSquare);
|
||||
}
|
||||
private bool elementLock;
|
||||
public bool ElementLock
|
||||
{
|
||||
get => elementLock;
|
||||
set => OnPropertyChanged(value, ref elementLock);
|
||||
}
|
||||
|
||||
private int primitivesCount;
|
||||
public int PrimitivesCount
|
||||
{
|
||||
get => primitivesCount;
|
||||
set => OnPropertyChanged(value, ref primitivesCount);
|
||||
}
|
||||
|
||||
private int primitiveIndex = 1;
|
||||
public int PrimitiveIndex
|
||||
{
|
||||
get => primitiveIndex;
|
||||
set
|
||||
{
|
||||
if (value >= 0 && value <= primitivesCount)
|
||||
OnPropertyChanged(value, ref primitiveIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public int PrimitivesCount => Primitives.Count;
|
||||
private double scaleValue = 1.0;
|
||||
|
||||
public double ScaleValue
|
||||
{
|
||||
get => scaleValue;
|
||||
@@ -160,42 +88,37 @@ namespace StructureHelper.Windows.MainWindow
|
||||
get => yY2;
|
||||
set => OnPropertyChanged(value, ref yY2);
|
||||
}
|
||||
|
||||
public ICommand AddPrimitive { get; }
|
||||
public ICommand LeftButtonDown { get; }
|
||||
public ICommand LeftButtonUp { get; }
|
||||
public ICommand PreviewMouseMove { get; }
|
||||
|
||||
public ICommand SetParameters { get; }
|
||||
public ICommand ClearSelection { get; }
|
||||
|
||||
public ICommand OpenMaterialCatalog { get; }
|
||||
public ICommand OpenMaterialCatalogWithSelection { get; }
|
||||
public ICommand OpenUnitsSystemSettings { get; }
|
||||
public ICommand SetColor { get; }
|
||||
public ICommand SetInFrontOfAll { get; }
|
||||
public ICommand SetInBackOfAll { get; }
|
||||
public ICommand ScaleCanvasDown { get; }
|
||||
public ICommand ScaleCanvasUp { get; }
|
||||
public ICommand AddEllipse { get; }
|
||||
public ICommand Calculate { get; }
|
||||
public ICommand SetPopupCanBeClosedTrue { get; }
|
||||
public ICommand SetPopupCanBeClosedFalse { get; }
|
||||
public string UnitsSystemName => unitSystemService.GetCurrentSystem().Name;
|
||||
|
||||
private double delta = 0.5;
|
||||
|
||||
public MainViewModel(MainModel model, IPrimitiveService primitiveService, IPrimitiveRepository primitiveRepository)
|
||||
public MainViewModel(MainModel model, IPrimitiveRepository primitiveRepository, UnitSystemService unitSystemService)
|
||||
{
|
||||
PrimitiveService = primitiveService;
|
||||
PrimitiveRepository = primitiveRepository;
|
||||
Model = model;
|
||||
|
||||
this.unitSystemService = unitSystemService;
|
||||
CanvasWidth = 1500;
|
||||
CanvasHeight = 1000;
|
||||
XX2 = CanvasWidth;
|
||||
XY1 = CanvasHeight / 2;
|
||||
YX1 = CanvasWidth / 2;
|
||||
YY2 = CanvasHeight;
|
||||
|
||||
|
||||
|
||||
LeftButtonUp = new RelayCommand(o =>
|
||||
{
|
||||
if (o is Rectangle rect) rect.BorderCaptured = false;
|
||||
@@ -219,44 +142,15 @@ namespace StructureHelper.Windows.MainWindow
|
||||
rect.PrimitiveHeight = PanelY - rect.Y + 10;
|
||||
}
|
||||
});
|
||||
SetParameters = new RelayCommand(o =>
|
||||
{
|
||||
var primitive = Primitives.FirstOrDefault(x => x.ParameterCaptured);
|
||||
if (primitive != null)
|
||||
{
|
||||
primitive.ElementLock = ElementLock;
|
||||
primitive.ShowedOpacity = ParameterOpacity;
|
||||
Primitives.MoveElementToSelectedIndex(primitive, PrimitiveIndex);
|
||||
foreach (var primitiveDefinition in Primitives)
|
||||
primitiveDefinition.ShowedZIndex = Primitives.IndexOf(primitiveDefinition) + 1;
|
||||
|
||||
switch (primitive)
|
||||
{
|
||||
case Rectangle rectangle:
|
||||
rectangle.ShowedX = RectParameterX;
|
||||
rectangle.ShowedY = RectParameterY;
|
||||
rectangle.PrimitiveWidth = RectParameterWidth;
|
||||
rectangle.PrimitiveHeight = RectParameterHeight;
|
||||
break;
|
||||
case Point point:
|
||||
point.Square = EllipseParameterSquare;
|
||||
point.ShowedX = EllipseParameterX;
|
||||
point.ShowedY = EllipseParameterY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
ClearSelection = new RelayCommand(o =>
|
||||
{
|
||||
var primitive = Primitives.FirstOrDefault(x => x.ParamsPanelVisibilty);
|
||||
var primitive = Primitives?.FirstOrDefault(x => x.ParamsPanelVisibilty);
|
||||
if (primitive != null && primitive.PopupCanBeClosed)
|
||||
{
|
||||
primitive.ParamsPanelVisibilty = false;
|
||||
primitive.ParameterCaptured = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
OpenMaterialCatalog = new RelayCommand(o =>
|
||||
{
|
||||
var materialCatalogView = new MaterialCatalogView();
|
||||
@@ -268,6 +162,10 @@ namespace StructureHelper.Windows.MainWindow
|
||||
var materialCatalogView = new MaterialCatalogView(true, primitive);
|
||||
materialCatalogView.ShowDialog();
|
||||
});
|
||||
OpenUnitsSystemSettings = new RelayCommand(o =>
|
||||
{
|
||||
OnPropertyChanged(nameof(UnitsSystemName));
|
||||
});
|
||||
SetColor = new RelayCommand(o =>
|
||||
{
|
||||
var primitive = o as PrimitiveBase;
|
||||
@@ -287,21 +185,21 @@ namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
if (!(o is PrimitiveBase primitive)) return;
|
||||
foreach (var primitiveDefinition in Primitives)
|
||||
if (primitiveDefinition.ShowedZIndex < primitive.ShowedZIndex && primitiveDefinition != primitive)
|
||||
if (primitiveDefinition != primitive && primitiveDefinition.ShowedZIndex < primitive.ShowedZIndex)
|
||||
primitiveDefinition.ShowedZIndex++;
|
||||
primitive.ShowedZIndex = 1;
|
||||
OnPropertyChanged(nameof(primitive.ShowedZIndex));
|
||||
});
|
||||
|
||||
ScaleCanvasDown = new RelayCommand(o =>
|
||||
{
|
||||
var scaleRate = 1.1;
|
||||
ScrollPanelX = PanelX;
|
||||
ScrollPanelY = PanelY;
|
||||
ScaleValue *= scaleRate;
|
||||
});
|
||||
|
||||
ScaleCanvasUp = new RelayCommand(o =>
|
||||
{
|
||||
var scaleRate = 1.1;
|
||||
ScrollPanelX = PanelX;
|
||||
ScrollPanelY = PanelY;
|
||||
ScaleValue /= scaleRate;
|
||||
@@ -309,20 +207,19 @@ namespace StructureHelper.Windows.MainWindow
|
||||
|
||||
Primitives = new ObservableCollection<PrimitiveBase>();
|
||||
|
||||
AddRectangle = new RelayCommand(o =>
|
||||
AddPrimitive = new RelayCommand(o =>
|
||||
{
|
||||
var rectangle = new Rectangle(60, 40, YX1, XY1, this);
|
||||
Primitives.Add(rectangle);
|
||||
PrimitivesCount = Primitives.Count;
|
||||
PrimitiveRepository.Add(rectangle);
|
||||
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);
|
||||
Primitives.Add(primitive);
|
||||
PrimitiveRepository.Add(primitive);
|
||||
});
|
||||
|
||||
AddEllipse = new RelayCommand(o =>
|
||||
Calculate = new RelayCommand(o =>
|
||||
{
|
||||
var point = new Point(2000, YX1, XY1, this);
|
||||
Primitives.Add(point);
|
||||
PrimitivesCount = Primitives.Count;
|
||||
PrimitiveRepository.Add(point);
|
||||
model.Calculate(-50e3, 0d, 0d);
|
||||
});
|
||||
|
||||
SetPopupCanBeClosedTrue = new RelayCommand(o =>
|
||||
@@ -330,6 +227,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
if (!(o is PrimitiveBase primitive)) return;
|
||||
primitive.PopupCanBeClosed = true;
|
||||
});
|
||||
|
||||
SetPopupCanBeClosedFalse = new RelayCommand(o =>
|
||||
{
|
||||
if (!(o is PrimitiveBase primitive)) return;
|
||||
|
||||
Reference in New Issue
Block a user