LinePrimitive and RectanglePrimitive was added

This commit is contained in:
Evgeny Redikultsev
2022-11-19 21:12:55 +05:00
parent 667b91cbfa
commit b566373f16
37 changed files with 544 additions and 69 deletions

View File

@@ -0,0 +1,27 @@
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Services.Primitives;
using StructureHelper.UnitSystem.Systems;
using StructureHelper.Windows.MainWindow;
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 StructureHelper.Infrastructure.UI.DataContexts
{
internal class LinePrimitive : PrimitiveBase
{
private ILineShape lineShape;
public LinePrimitive(PrimitiveType type, double x, double y, MainViewModel ownerVM) : base(type, x, y, ownerVM)
{
}
public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
{
throw new NotImplementedException();
}
}
}

View File

@@ -52,7 +52,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
string materialName = MaterialName;
ICenter center = new Center { X = CenterX, Y = CenterY };
IShape shape = new StructureHelperCommon.Models.Shapes.Point { Area = this.Area };
IShape shape = new StructureHelperCommon.Models.Shapes.PointShape { Area = this.Area };
INdmPrimitive ndmPrimitive = new NdmPrimitive(HeadMaterial)
{ Center = center, Shape = shape,
PrestrainKx = PrestrainKx,

View File

@@ -48,7 +48,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
double centerX = CenterX;
double centerY = CenterY;
ICenter center = new Center { X = centerX, Y = centerY };
IShape shape = new StructureHelperCommon.Models.Shapes.Rectangle { Height = height, Width = width, Angle = 0 };
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,

View File

@@ -140,6 +140,7 @@
<Compile Include="Infrastructure\UI\Converters\Units\Length.cs" />
<Compile Include="Infrastructure\UI\Converters\Units\UnitBase.cs" />
<Compile Include="Infrastructure\UI\Converters\Units\UnitConstatnts.cs" />
<Compile Include="Infrastructure\UI\DataContexts\LinePrimitive.cs" />
<Compile Include="Infrastructure\UI\PrimitiveTemplates\IRectangleBeamProperties.cs" />
<Compile Include="Infrastructure\UI\UserControls\PrimitivePopup.xaml.cs">
<DependentUpon>PrimitivePopup.xaml</DependentUpon>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface ISaveable
{
int Id { get; set; }
void Save();
}
}

View File

@@ -10,11 +10,11 @@
/// Coordinate of center of rectangle by local axis X, m
/// Координата центра вдоль локальной оси X, м
/// </summary>
double X { get;}
double X { get; set; }
/// <summary>
/// Coordinate of center of rectangle by local axis Y, m
/// Координата центра вдоль локальной оси Y, м
/// </summary>
double Y { get;}
double Y { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Shapes
{
public interface ILineShape : IShape
{
ICenter StartPoint { get; set; }
ICenter EndPoint { get; set; }
double Thickness { get; set; }
}
}

View File

@@ -1,18 +1,18 @@
namespace StructureHelperCommon.Models.Shapes
{
public interface IRectangle : IShape
public interface IRectangleShape : IShape
{
/// <summary>
/// Width of rectangle, m
/// </summary>
double Width { get; }
double Width { get; set; }
/// <summary>
/// Height of rectangle, m
/// </summary>
double Height { get; }
double Height { get; set; }
/// <summary>
/// Angle of rotating rectangle, rad
/// </summary>
double Angle { get; }
double Angle { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Shapes
{
/// <inheritdoc />
public class LineShape : ILineShape
{
/// <inheritdoc />
public ICenter StartPoint { get; set; }
/// <inheritdoc />
public ICenter EndPoint { get; set; }
/// <inheritdoc />
public double Thickness { get; set; }
public LineShape()
{
StartPoint = new Center();
EndPoint = new Center();
Thickness = 0;
}
}
}

View File

@@ -1,6 +1,6 @@
namespace StructureHelperCommon.Models.Shapes
{
public class Point : IPoint
public class PointShape : IPoint
{
public double Area { get; set; }
}

View File

@@ -1,7 +1,7 @@
namespace StructureHelperCommon.Models.Shapes
{
/// <inheritdoc />
public class Rectangle : IRectangle
public class RectangleShape : IRectangleShape
{
/// <inheritdoc />
public double Width { get; set; }

View File

@@ -0,0 +1,27 @@
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Services.ShapeServices
{
public static class ShapeService
{
public static void CopyLineProperties(ILineShape source, ILineShape target)
{
target.StartPoint.X = source.StartPoint.X;
target.StartPoint.Y = source.StartPoint.Y;
target.EndPoint.X = source.EndPoint.X;
target.EndPoint.Y = source.EndPoint.Y;
}
public static void CopyRectangleProperties(IRectangleShape source, IRectangleShape target)
{
target.Width = source.Width;
target.Height = source.Height;
target.Angle = source.Angle;
}
}
}

View File

@@ -51,19 +51,23 @@
<Compile Include="Infrastructures\Enums\LimitStates.cs" />
<Compile Include="Infrastructures\Exceptions\StructureHelperException.cs" />
<Compile Include="Infrastructures\Interfaces\IHasParent.cs" />
<Compile Include="Infrastructures\Interfaces\ISaveable.cs" />
<Compile Include="Infrastructures\Strings\ErrorString.cs" />
<Compile Include="Infrastructures\Enums\MaterialTypes.cs" />
<Compile Include="Models\Shapes\Center.cs" />
<Compile Include="Models\Shapes\ICenter.cs" />
<Compile Include="Models\Shapes\ICenterShape.cs" />
<Compile Include="Models\Shapes\ICircle.cs" />
<Compile Include="Models\Shapes\ILineShape.cs" />
<Compile Include="Models\Shapes\IPoint.cs" />
<Compile Include="Models\Shapes\IRectangle.cs" />
<Compile Include="Models\Shapes\IRectangleShape.cs" />
<Compile Include="Models\Shapes\IShape.cs" />
<Compile Include="Models\Shapes\Point.cs" />
<Compile Include="Models\Shapes\Rectangle.cs" />
<Compile Include="Models\Shapes\LineShape.cs" />
<Compile Include="Models\Shapes\PointShape.cs" />
<Compile Include="Models\Shapes\RectangleShape.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ColorServices\ColorProcessor.cs" />
<Compile Include="Services\ShapeServices\ShapeService.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -12,12 +12,14 @@ namespace StructureHelperLogics.Models.Materials
public class ElasticMaterial : IElasticMaterial
{
public double Modulus { get; set; }
public double CompressiveStrength { get; set; }
public double TensileStrength { get; set; }
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
IMaterial material = new Material();
material.InitModulus = Modulus;
IEnumerable<double> parameters = new List<double>() { Modulus};
IEnumerable<double> parameters = new List<double>() { Modulus, CompressiveStrength, TensileStrength};
material.DiagramParameters = parameters;
material.Diagram = GetStress;
return material;
@@ -25,12 +27,17 @@ namespace StructureHelperLogics.Models.Materials
private double GetStress (IEnumerable<double> parameters, double strain)
{
return parameters.First() * strain;
double modulus = parameters.First();
double stress = modulus * strain;
double compressiveStrength = (-1d) * parameters.ElementAt(1);
double tensileStrength = parameters.ElementAt(2);
if (stress > tensileStrength || stress < compressiveStrength) { return 0d; }
else { return stress; }
}
public object Clone()
{
return new ElasticMaterial() { Modulus = Modulus };
return new ElasticMaterial() { Modulus = Modulus, CompressiveStrength = CompressiveStrength, TensileStrength = TensileStrength };
}
}
}

View File

@@ -9,5 +9,7 @@ namespace StructureHelperLogics.Models.Materials
public interface IElasticMaterial : IHelperMaterial
{
double Modulus { get; set; }
double CompressiveStrength { get; set; }
double TensileStrength { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Primitives
{
public interface IPrimitive : ISaveable, ICloneable
{
string Name { get; set; }
ICenter Center { get; }
IShape Shape { get; }
IEnumerable<INdmPrimitive> GetNdmPrimitives();
}
}

View File

@@ -0,0 +1,37 @@
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Primitives
{
public class LinePrimitive : IPrimitive
{
public int Id { get; set; }
public string Name { get; set; }
public ICenter Center { get; set; }
public IShape Shape { get; }
public LinePrimitive()
{
}
public IEnumerable<INdmPrimitive> GetNdmPrimitives()
{
throw new NotImplementedException();
}
public object Clone()
{
throw new NotImplementedException();
}
public void Save()
{
throw new NotImplementedException();
}
}
}

View File

@@ -18,7 +18,7 @@ namespace StructureHelperLogics.Models.Templates.RCs
public RectangleBeamTemplate()
{
Shape = new Rectangle() { Width = 0.4d, Height = 0.6d };
Shape = new RectangleShape() { Width = 0.4d, Height = 0.6d };
CoverGap = 0.05d;
TopDiameter = 0.016d;
BottomDiameter = 0.025d;
@@ -28,7 +28,7 @@ namespace StructureHelperLogics.Models.Templates.RCs
public RectangleBeamTemplate(double width, double height)
{
Shape = new Rectangle() { Width = width, Height = height };
Shape = new RectangleShape() { Width = width, Height = height };
CoverGap = 0.05d;
TopDiameter = 0.016d;
BottomDiameter = 0.025d;

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
internal interface IHasDivisionSize
{
double NdmMaxSize { get; set; }
int NdmMinDivision { get; set; }
}
}

View File

@@ -1,18 +1,23 @@
using StructureHelperLogics.Models.Materials;
using StructureHelperCommon.Models.Shapes;
using StructureHelper.Models.Materials;
using System.Collections;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Materials;
using System.Collections.Generic;
namespace StructureHelperLogics.Models.Primitives
{
public interface INdmPrimitive
{
string Name { get; set; }
ICenter Center { get; set; }
IShape Shape { get; set; }
IHeadMaterial HeadMaterial { get; }
double NdmMaxSize { get; set; }
int NdmMinDivision { get; set; }
IHeadMaterial HeadMaterial { get; set; }
double PrestrainKx { get; set; }
double PrestrainKy { get; set; }
double PrestrainEpsZ { get; set; }
IEnumerable<INdm> GetNdms(IMaterial material);
}
}

View File

@@ -0,0 +1,64 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Ndms;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.ShapeServices;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class LinePrimitive : INdmPrimitive, ILineShape, IHasDivisionSize, ISaveable, ICloneable
{
public ICenter Center { get; set; }
public IShape Shape { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public double NdmMaxSize { get; set; }
public int NdmMinDivision { get; set; }
public IHeadMaterial HeadMaterial { get; set; }
public double PrestrainKx { get; set; }
public double PrestrainKy { get; set; }
public double PrestrainEpsZ { get; set; }
public ICenter StartPoint { get; set; }
public ICenter EndPoint { get; set; }
public double Thickness { get; set; }
public LinePrimitive()
{
StartPoint = new Center();
EndPoint = new Center();
Name = "New Line";
NdmMaxSize = 0.01d;
NdmMinDivision = 10;
}
public object Clone()
{
LinePrimitive primitive = new LinePrimitive();
NdmPrimitivesService.CopyNdmProperties(this, primitive);
NdmPrimitivesService.CopyDivisionProperties(this, primitive);
ShapeService.CopyLineProperties(this, primitive);
return primitive;
}
public IEnumerable<INdm> GetNdms(IMaterial material)
{
throw new NotImplementedException();
}
public void Save()
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,25 +1,47 @@
using StructureHelperLogics.Models.Materials;
using StructureHelperCommon.Models.Shapes;
using StructureHelper.Models.Materials;
using System.Collections.Generic;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
namespace StructureHelperLogics.Models.Primitives
{
public class NdmPrimitive : INdmPrimitive
public class NdmPrimitive : INdmPrimitive, ISaveable, ICloneable
{
private IHeadMaterial headMaterial;
public ICenter Center { get; set; }
public IShape Shape { get; set; }
public IHeadMaterial HeadMaterial { get => headMaterial; }
public int Id { get; set; }
public string Name { get; set; }
public IHeadMaterial HeadMaterial { get; private 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 NdmPrimitive(IHeadMaterial material)
{
headMaterial = material;
HeadMaterial = material;
}
public IEnumerable<INdm> GetNdms(IMaterial material)
{
throw new System.NotImplementedException();
}
public void Save()
{
throw new System.NotImplementedException();
}
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,53 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Ndms;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.ShapeServices;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class RectanglePrimitive : INdmPrimitive, IRectangleShape, IHasDivisionSize, ISaveable, ICloneable
{
public string Name { get; set; }
public ICenter Center { get; set; }
public IShape Shape { 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 object Clone()
{
RectanglePrimitive primitive = new RectanglePrimitive();
NdmPrimitivesService.CopyNdmProperties(this, primitive);
NdmPrimitivesService.CopyDivisionProperties(this, primitive);
ShapeService.CopyRectangleProperties(this, primitive);
return primitive;
}
public IEnumerable<INdm> GetNdms(IMaterial material)
{
throw new NotImplementedException();
}
public void Save()
{
throw new NotImplementedException();
}
}
}

View File

@@ -15,7 +15,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
/// <summary>
///
/// </summary>
IRectangle Rectangle { get; }
IRectangleShape Rectangle { get; }
/// <summary>
/// Maximum size (width or height) of ndm part after triangulation
/// </summary>

View File

@@ -3,6 +3,7 @@ using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
@@ -12,7 +13,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
/// <inheritdoc />
public ICenter Center { get; }
/// <inheritdoc />
public IRectangle Rectangle { get; }
public IRectangleShape Rectangle { get; }
/// <inheritdoc />
public double NdmMaxSize { get; }
/// <inheritdoc />
@@ -24,7 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
/// <inheritdoc />
public double PrestrainEpsZ { get;}
public RectangleTriangulationLogicOptions(ICenter center, IRectangle rectangle, double ndmMaxSize, int ndmMinDivision)
public RectangleTriangulationLogicOptions(ICenter center, IRectangleShape rectangle, double ndmMaxSize, int ndmMinDivision)
{
Center = center;
Rectangle = rectangle;
@@ -34,11 +35,14 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
public RectangleTriangulationLogicOptions(INdmPrimitive primitive)
{
if (! (primitive.Shape is IRectangle)) { throw new StructureHelperException(ErrorStrings.ShapeIsNotCorrect); }
if (! (primitive.Shape is IRectangleShape)) { throw new StructureHelperException(ErrorStrings.ShapeIsNotCorrect); }
Center = primitive.Center;
Rectangle = primitive.Shape as IRectangle;
NdmMaxSize = primitive.NdmMaxSize;
NdmMinDivision = primitive.NdmMinDivision;
Rectangle = primitive.Shape as IRectangleShape;
if (primitive is IHasDivisionSize)
{
NdmMaxSize = (primitive as IHasDivisionSize).NdmMaxSize;
NdmMinDivision = (primitive as IHasDivisionSize).NdmMinDivision;
}
PrestrainKx = primitive.PrestrainKx;
PrestrainKy = primitive.PrestrainKy;
PrestrainEpsZ = primitive.PrestrainEpsZ;

View File

@@ -73,7 +73,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
ITriangulationLogicOptions options;
ICenter center = primitive.Center;
IShape shape = primitive.Shape;
if (shape is IRectangle)
if (shape is IRectangleShape)
{
options = new RectangleTriangulationLogicOptions(primitive);
ITriangulationLogic logic = new RectangleTriangulationLogic(options);

View File

@@ -0,0 +1,28 @@
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives
{
internal static class NdmPrimitivesService
{
public static void CopyNdmProperties (INdmPrimitive source, INdmPrimitive target)
{
target.Name = source.Name + " - copy" ;
target.HeadMaterial = source.HeadMaterial;
target.PrestrainKx = source.PrestrainKx;
target.PrestrainKy = source.PrestrainKy;
target.PrestrainEpsZ = source.PrestrainEpsZ;
}
public static void CopyDivisionProperties(IHasDivisionSize source, IHasDivisionSize target)
{
target.NdmMaxSize = source.NdmMaxSize;
target.NdmMinDivision = source.NdmMinDivision;
}
}
}

View File

@@ -62,7 +62,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
{
double strength = 40e6;
ICenter center = new Center { X = 0, Y = 0 };
IRectangle rectangle = new Rectangle { Width = width, Height = height, Angle = 0 };
IRectangleShape rectangle = new RectangleShape { 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 };
@@ -74,8 +74,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
{
double gap = 0.05d;
double strength = 4e8;
IShape topReinforcement = new Point { Area = topArea };
IShape bottomReinforcement = new Point { Area = bottomArea };
IShape topReinforcement = new PointShape { Area = topArea };
IShape bottomReinforcement = new PointShape { 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 };

View File

@@ -22,7 +22,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.SteelSections
{
//Arrange
ICenter center = new Center { X = 0, Y = 0 };
IRectangle rectangle = new Rectangle { Width = width, Height = height, Angle = 0 };
IRectangleShape rectangle = new RectangleShape { 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 };

View File

@@ -22,7 +22,7 @@ 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 };
IRectangleShape rectangle = new RectangleShape { 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

View File

@@ -66,6 +66,11 @@
</Grid.ColumnDefinitions>
<StackPanel>
<Expander Header="Materials" ExpandDirection="Down" MinWidth="20">
<Expander.ContextMenu>
<ContextMenu>
<Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/>
</ContextMenu>
</Expander.ContextMenu>
<ListBox ItemsSource="{Binding HeadMaterials}">
<ListBox.ItemTemplate>
<DataTemplate>
@@ -86,7 +91,21 @@
</ListBox>
</Expander>
<Expander Header="Geometry" ExpandDirection="Down" MinWidth="20" >
<Expander.ContextMenu>
<ContextMenu>
<MenuItem Header="Add">
<Button Content="Add Rectangle" Command="{Binding AddPrimitive}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Add Point" Command="{Binding AddPrimitive}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
</MenuItem>
</ContextMenu>
</Expander.ContextMenu>
<ListBox ItemsSource="{Binding Primitives}" SelectedItem="{Binding SelectedPrimitive}">
<ListBox.ContextMenu>
<ContextMenu>
<Button Content="Edit" Command="{Binding EditPrimitive}"/>
<Button Content="Delete" Command="{Binding DeletePrimitive}"/>
</ContextMenu>
</ListBox.ContextMenu>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
@@ -122,7 +141,6 @@
</ListBox>
</Expander>
</StackPanel>
<Border BorderBrush="Black" Background="White" BorderThickness="1" Margin="5" Grid.Column="1">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">

View File

@@ -324,6 +324,7 @@ namespace StructureHelper.Windows.MainWindow
MovePrimitiveToGravityCenterCommand = new RelayCommand(o =>
{
if (CheckMaterials() == false) { return;}
IEnumerable<INdm> ndms = Model.GetNdms(calculationProperty);
double[] center = GeometryOperations.GetGravityCenter(ndms);
foreach (var primitive in Model.PrimitiveRepository.Primitives)
@@ -404,6 +405,12 @@ namespace StructureHelper.Windows.MainWindow
}
private bool CheckAnalisysOptions()
{
if (CheckMaterials() == false) { return false; }
return true;
}
private bool CheckMaterials()
{
foreach (var item in PrimitiveRepository.Primitives)
{
@@ -454,16 +461,16 @@ namespace StructureHelper.Windows.MainWindow
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
var rect = template.Shape as StructureHelperCommon.Models.Shapes.Rectangle;
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;
IHeadMaterial concrete = new HeadMaterial() { Name = "Concrete 40" };
IHeadMaterial concrete = new HeadMaterial() { Name = "Concrete" };
concrete.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Concrete & x.Name.Contains("40"))).First();
IHeadMaterial reinforcement = new HeadMaterial() { Name = "Reinforcement 400" };
IHeadMaterial reinforcement = new HeadMaterial() { Name = "Reinforcement" };
reinforcement.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Reinforcement & x.Name.Contains("400"))).First();
headMaterials.Add(concrete);
headMaterials.Add(reinforcement);

View File

@@ -7,19 +7,53 @@
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Materials"
d:DataContext="{d:DesignInstance vm:HeadMaterialsViewModel}"
mc:Ignorable="d"
Title="Materials" Height="350" Width="400" WindowStartupLocation="CenterScreen">
Title="Materials" Height="350" Width="680" MinHeight="350" MinWidth="680" WindowStartupLocation="CenterScreen">
<Window.Resources>
<DataTemplate x:Key="LibMaterial">
<StackPanel>
<TextBlock Text="Library material"/>
<ComboBox Grid.Row="2" Height="25" VerticalAlignment="Top" ItemsSource="{Binding LibMaterials}" SelectedItem="{Binding SelectedLibMaterial}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ElasticMaterial">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<TextBlock Text="Elastic material"/>
<TextBlock Grid.Row="1" Text="Young's modulus"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Modulus, Converter={StaticResource StressConverter}, ValidatesOnDataErrors=True}"/>
<TextBlock Grid.Row="2" Text="Compressive strength"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding CompressiveStrength, Converter={StaticResource StressConverter}, ValidatesOnDataErrors=True}"/>
<TextBlock Grid.Row="3" Text="Tensile strength"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding TensileStrength, Converter={StaticResource StressConverter}, ValidatesOnDataErrors=True}"/>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="280"/>
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<ListBox ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding SelectedMaterial}">
<ListBox ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding SelectedMaterial}" SelectionChanged="ListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
@@ -38,21 +72,19 @@
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBox Grid.Row="1" Text="{Binding SelectedMaterial.Name}"/>
<ComboBox Grid.Row="2" ItemsSource="{Binding LibMaterials}" SelectedItem="{Binding SelectedLibMaterial}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<StackPanel Grid.Column="1">
<Button Content="New Material" Command="{Binding AddNewMaterialCommand}"/>
<Button Content="New Lib Material" Command="{Binding AddNewMaterialCommand}"/>
<Button Content="New Elastic Material" Command="{Binding AddElasticMaterialCommand}"/>
<Button Content="Edit color" Command="{Binding EditColorCommand}"/>
<Button Content="Copy" Command="{Binding CopyHeadMaterialCommand}"/>
<Button Content="Delete" Command="{Binding DeleteMaterialCommand}"/>
</StackPanel>
<StackPanel Grid.Column="2">
<TextBlock Text="Name"/>
<TextBox Text="{Binding SelectedMaterial.Name}"/>
<StackPanel x:Name="StpMaterialProperties"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -14,6 +14,7 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Xml.Linq;
namespace StructureHelper.Windows.MainWindow.Materials
{
@@ -22,20 +23,47 @@ namespace StructureHelper.Windows.MainWindow.Materials
/// </summary>
public partial class HeadMaterialsView : Window
{
private HeadMaterialsViewModel viewmodel;
private HeadMaterialsViewModel viewModel;
public HeadMaterialsView(IHeadMaterialRepository headMaterialRepository)
{
viewmodel = new HeadMaterialsViewModel(headMaterialRepository);
this.DataContext = viewmodel;
viewModel = new HeadMaterialsViewModel(headMaterialRepository);
this.DataContext = viewModel;
InitializeComponent();
}
public HeadMaterialsView(HeadMaterialsViewModel vm)
{
viewmodel = vm;
this.DataContext = viewmodel;
viewModel = vm;
this.DataContext = viewModel;
InitializeComponent();
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
StpMaterialProperties.Children.Clear();
var selectedMaterial = viewModel.SelectedMaterial;
if (selectedMaterial == null) { return; }
var helperMaterial = selectedMaterial.HelperMaterial;
string dataTemplateName = string.Empty;
Binding binding = new Binding();
if (helperMaterial is ILibMaterial)
{
dataTemplateName = "LibMaterial";
binding.Source = viewModel;
}
if (helperMaterial is IElasticMaterial)
{
dataTemplateName = "ElasticMaterial";
binding.Source = viewModel.SelectedMaterial.HelperMaterial;
}
if (dataTemplateName != string.Empty)
{
ContentControl contentControl = new ContentControl();
contentControl.SetResourceReference(ContentTemplateProperty, dataTemplateName);
contentControl.SetBinding(ContentProperty, binding);
StpMaterialProperties.Children.Add(contentControl);
}
}
}
}

View File

@@ -54,10 +54,9 @@ namespace StructureHelper.Windows.PrimitiveProperiesWindow
foreach (var name in names)
{
ContentControl contentControl = new ContentControl();
contentControl.SetResourceReference(ContentControl.ContentTemplateProperty, name);
Binding binding = new Binding();
binding.Source = viewModel;
contentControl.SetBinding(ContentControl.ContentProperty, binding);
contentControl.SetResourceReference(ContentTemplateProperty, name);
Binding binding = new Binding {Source = viewModel};
contentControl.SetBinding(ContentProperty, binding);
StpProperties.Children.Add(contentControl);
}
}

View File

@@ -27,11 +27,33 @@ namespace StructureHelper.Windows.ViewModels.Materials
ILibMaterial selectedLibMaterial;
public ICommand AddNewMaterialCommand { get; set; }
public ICommand AddElasticMaterialCommand
{
get
{
return addElasticMaterialCommand ??
(
addElasticMaterialCommand = new RelayCommand(o => AddElasticMaterial())
);
}
}
private void AddElasticMaterial()
{
IHeadMaterial material = new HeadMaterial() { Name = "New elastic material" };
material.HelperMaterial = new ElasticMaterial() { Modulus = 2e11d, CompressiveStrength = 4e8d, TensileStrength = 4e8d };
HeadMaterials.Add(material);
materialRepository.HeadMaterials.Add(material);
SelectedMaterial = material;
}
public ICommand CopyHeadMaterialCommand { get; set; }
public ICommand EditColorCommand { get; set; }
public ICommand DeleteMaterialCommand { get; set; }
public ICommand EditHeadMaterial;
private ICommand addElasticMaterialCommand;
public ObservableCollection<IHeadMaterial> HeadMaterials { get; private set; }
public IHeadMaterial SelectedMaterial
{
@@ -104,7 +126,6 @@ namespace StructureHelper.Windows.ViewModels.Materials
HeadMaterials.Add(material);
materialRepository.HeadMaterials.Add(material);
SelectedMaterial = material;
}
private void DeleteMaterial()

View File

@@ -17,7 +17,7 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveTemplates.RCs
{
public IRectangleBeamTemplate Model;
private Rectangle rectangle => (Model.Shape as Rectangle);
private RectangleShape rectangle => (Model.Shape as RectangleShape);
public Window ParentWindow { get; set; }