From ed66da123cc901842df528486be6e9710d5a1957 Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Sun, 19 Oct 2025 17:37:17 +0500 Subject: [PATCH] Add polygon to DTO convert strategy --- ...EllipseNdmPrimitiveToDTOConvertStrategy.cs | 2 +- .../NdmElementToDTOConvertStrategy.cs | 7 +- .../NdmPrimitiveToDTOConvertStrategy.cs | 12 ++++ .../ShapeNdmPrimitiveToDTOConvertStrategy.cs | 50 +++++++++++++ .../CircleShapeFromDTOConvertStrategy.cs | 0 .../CircleShapeToDTOConvertStrategy.cs | 0 .../Shapes/LinePolygonToDTOConvertStrategy.cs | 36 ++++++++++ .../Point2DFromDTOConvertStrategy.cs | 0 .../Point2DToDTOConvertStrategy.cs | 0 .../RectangleShapeFromDTOConvertStrategy.cs | 0 .../RectangleShapeToDTOConvertStrategy.cs | 0 .../ShapeFromDTOConvertStrategy.cs | 0 .../{ => Shapes}/ShapeToDTOConvertStrategy.cs | 12 ++++ .../Shapes/VertexToDTOConvertStrategy.cs | 26 +++++++ .../VisualPropertyToDTOConvertStrategy.cs | 7 +- .../EllipseNdmPrimitiveDTO.cs | 7 +- .../NdmCrossSections/ShapeNdmPrimitiveDTO.cs | 67 ++++++++++++++++++ .../{ => Shapes}/CircleShapeDTO.cs | 5 -- .../DTOEntities/Shapes/LinePolygonShapeDTO.cs | 53 ++++++++++++++ .../DTOEntities/{ => Shapes}/Point2DDTO.cs | 0 .../{ => Shapes}/RectangleShapeDTO.cs | 0 .../DTOs/DTOEntities/Shapes/VertexDTO.cs | 23 ++++++ .../UI/DataContexts/PrimitiveOperations.cs | 2 +- .../UI/DataContexts/ShapeViewPrimitive.cs | 6 +- .../Forces/ForceCombinationFromFileVM.cs | 1 - .../Forces/ForceCombinationViewerVM.cs | 7 ++ .../Forces/ForceCombinationViewerView.xaml | 12 ++++ .../Windows/Forces/ForceFilePropertyVM.cs | 36 ++++++++-- .../Windows/Forces/ForceFilePropertyView.xaml | 9 ++- .../Windows/Forces/ListOfFilesVM.cs | 13 ++-- .../CrossSections/PrimitiveViewModelLogic.cs | 4 +- .../PrimitivePropertiesViewModel.cs | 4 +- ...onShapeToGraphicPrimitveConvertStrategy.cs | 4 +- .../Windows/Shapes/PolygonShapeViewModel.cs | 12 ++-- .../Interfaces/ConvertStrategy.cs | 2 +- .../Forces/Logics/ForceTupleUpdateStrategy.cs | 1 - .../Models/Shapes/ILinePolygonShape.cs | 19 +++++ .../Models/Shapes/IPolygonArcSegment.cs | 31 ++++++++ .../Models/Shapes/IPolygonLineSegment.cs | 15 ++++ .../Models/Shapes/IPolygonSegment.cs | 11 +++ .../Models/Shapes/IPolygonShape.cs | 25 +++---- .../Models/Shapes/LinePolygonShape.cs | 70 +++++++++++++++++++ .../Shapes/Logics/IPolygonCalculator.cs | 6 +- .../Logics/LinePolygonShapeUpdateStrategy.cs | 46 ++++++++++++ .../Models/Shapes/Logics/PolygonCalculator.cs | 6 +- .../Shapes/Logics/PolygonGeometryUtils.cs | 8 +-- .../Logics/PolygonShapeUpdateStrategy.cs | 48 ------------- .../Shapes/Logics/ShapeUpdateStrategy.cs | 8 +-- .../Shapes/Logics/VertexUpdateStrategy.cs | 26 +++++++ .../Models/Shapes/PolygonArcSegment.cs | 41 +++++++++++ .../Models/Shapes/PolygonLineSegment.cs | 22 ++++++ .../Models/Shapes/PolygonShape.cs | 58 +-------------- .../NdmCalculations/Primitives/INdmElement.cs | 7 -- .../Primitives/IShapeNDMPrimitive.cs | 2 +- .../Primitives/Logics/BaseUpdateStrategy.cs | 38 ---------- .../Logics/EllipsePrimitiveUpdateStrategy.cs | 2 +- .../Logics/NdmElementUpdateStrategy.cs | 15 ++-- .../Logics/NdmPrimitiveBaseUpdateStrategy.cs | 40 +++++++++++ .../Logics/NdmPrimitiveUpdateStrategy.cs | 4 +- .../Logics/PointNdmPrimitiveUpdateStrategy.cs | 2 +- .../Logics/RebarNdmPrimitiveUpdateStrategy.cs | 2 +- .../RectanglePrimitiveUpdateStrategy.cs | 2 +- .../Logics/ShapeNDMPrimitiveUpdateStrategy.cs | 34 ++++----- .../Primitives/ShapeNdmPrimitive.cs | 17 ++--- 64 files changed, 759 insertions(+), 266 deletions(-) create mode 100644 DataAccess/DTOs/Converters/NdmCrossSections/ShapeNdmPrimitiveToDTOConvertStrategy.cs rename DataAccess/DTOs/Converters/{ => Shapes}/CircleShapeFromDTOConvertStrategy.cs (100%) rename DataAccess/DTOs/Converters/{ => Shapes}/CircleShapeToDTOConvertStrategy.cs (100%) create mode 100644 DataAccess/DTOs/Converters/Shapes/LinePolygonToDTOConvertStrategy.cs rename DataAccess/DTOs/Converters/{ => Shapes}/Point2DFromDTOConvertStrategy.cs (100%) rename DataAccess/DTOs/Converters/{ => Shapes}/Point2DToDTOConvertStrategy.cs (100%) rename DataAccess/DTOs/Converters/{ => Shapes}/RectangleShapeFromDTOConvertStrategy.cs (100%) rename DataAccess/DTOs/Converters/{NdmCrossSections => Shapes}/RectangleShapeToDTOConvertStrategy.cs (100%) rename DataAccess/DTOs/Converters/{ => Shapes}/ShapeFromDTOConvertStrategy.cs (100%) rename DataAccess/DTOs/Converters/{ => Shapes}/ShapeToDTOConvertStrategy.cs (78%) create mode 100644 DataAccess/DTOs/Converters/Shapes/VertexToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/DTOEntities/NdmCrossSections/ShapeNdmPrimitiveDTO.cs rename DataAccess/DTOs/DTOEntities/{ => Shapes}/CircleShapeDTO.cs (76%) create mode 100644 DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs rename DataAccess/DTOs/DTOEntities/{ => Shapes}/Point2DDTO.cs (100%) rename DataAccess/DTOs/DTOEntities/{ => Shapes}/RectangleShapeDTO.cs (100%) create mode 100644 DataAccess/DTOs/DTOEntities/Shapes/VertexDTO.cs create mode 100644 StructureHelperCommon/Models/Shapes/ILinePolygonShape.cs create mode 100644 StructureHelperCommon/Models/Shapes/IPolygonArcSegment.cs create mode 100644 StructureHelperCommon/Models/Shapes/IPolygonLineSegment.cs create mode 100644 StructureHelperCommon/Models/Shapes/IPolygonSegment.cs create mode 100644 StructureHelperCommon/Models/Shapes/LinePolygonShape.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/LinePolygonShapeUpdateStrategy.cs delete mode 100644 StructureHelperCommon/Models/Shapes/Logics/PolygonShapeUpdateStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/VertexUpdateStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/PolygonArcSegment.cs create mode 100644 StructureHelperCommon/Models/Shapes/PolygonLineSegment.cs delete mode 100644 StructureHelperLogics/NdmCalculations/Primitives/Logics/BaseUpdateStrategy.cs create mode 100644 StructureHelperLogics/NdmCalculations/Primitives/Logics/NdmPrimitiveBaseUpdateStrategy.cs diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/EllipseNdmPrimitiveToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/EllipseNdmPrimitiveToDTOConvertStrategy.cs index 6927a57..77425d8 100644 --- a/DataAccess/DTOs/Converters/NdmCrossSections/EllipseNdmPrimitiveToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/NdmCrossSections/EllipseNdmPrimitiveToDTOConvertStrategy.cs @@ -70,7 +70,7 @@ namespace DataAccess.DTOs private EllipseNdmPrimitiveDTO GetNewPrimitive(IEllipseNdmPrimitive source) { - EllipseNdmPrimitiveDTO newItem = new() { Id = source.Id }; + EllipseNdmPrimitiveDTO newItem = new(source.Id); updateStrategy.Update(newItem, source); newItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement); newItem.RectangleShape = rectangleShapeConvertStrategy.Convert(source.Shape as IRectangleShape); diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementToDTOConvertStrategy.cs index baddf98..29895ec 100644 --- a/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementToDTOConvertStrategy.cs @@ -55,8 +55,11 @@ namespace DataAccess.DTOs headMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary; headMaterialConvertStrategy.TraceLogger = TraceLogger; var convertLogic = new DictionaryConvertStrategy(this, headMaterialConvertStrategy); - var headMaterial = convertLogic.Convert(source.HeadMaterial); - newItem.HeadMaterial = headMaterial; + if (source.HeadMaterial != null) + { + var headMaterial = convertLogic.Convert(source.HeadMaterial); + newItem.HeadMaterial = headMaterial; + } forceUpdateStrategy.Update(newItem.UsersPrestrain, source.UsersPrestrain); (newItem.UsersPrestrain as ForceTupleDTO).Id = source.UsersPrestrain.Id; forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain); diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/NdmPrimitiveToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/NdmPrimitiveToDTOConvertStrategy.cs index dd2b034..254a3a4 100644 --- a/DataAccess/DTOs/Converters/NdmCrossSections/NdmPrimitiveToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/NdmCrossSections/NdmPrimitiveToDTOConvertStrategy.cs @@ -11,6 +11,7 @@ namespace DataAccess.DTOs.Converters private readonly IConvertStrategy pointConvertStrategy; private readonly IConvertStrategy ellipseConvertStrategy; private readonly IConvertStrategy rectangleConvertStrategy; + private IConvertStrategy shapeConvertStrategy; public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } @@ -55,10 +56,21 @@ namespace DataAccess.DTOs.Converters { return ProcessRectangle(rectangle); } + if (source is IShapeNdmPrimitive shape) + { + return ProcessShape(shape); + } TraceLogger.AddMessage("Object type is unknown", TraceLogStatuses.Error); throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source)); } + private ShapeNdmPrimitiveDTO ProcessShape(IShapeNdmPrimitive shape) + { + shapeConvertStrategy = new DictionaryConvertStrategy(this, new ShapeNdmPrimitiveToDTOConvertStrategy(this)); + ShapeNdmPrimitiveDTO shapeNdmPrimitiveDTO = shapeConvertStrategy.Convert(shape); + return shapeNdmPrimitiveDTO; + } + private RebarNdmPrimitiveDTO ProcessRebar(IRebarNdmPrimitive rebar) { rebarConvertStrategy.ReferenceDictionary = ReferenceDictionary; diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/ShapeNdmPrimitiveToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/ShapeNdmPrimitiveToDTOConvertStrategy.cs new file mode 100644 index 0000000..94b026f --- /dev/null +++ b/DataAccess/DTOs/Converters/NdmCrossSections/ShapeNdmPrimitiveToDTOConvertStrategy.cs @@ -0,0 +1,50 @@ +using DataAccess.DTOs.Converters; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.NdmCalculations.Primitives; + +namespace DataAccess.DTOs +{ + public class ShapeNdmPrimitiveToDTOConvertStrategy : ConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy shapeConvertStrategy; + private IConvertStrategy ndmElementConvertStrategy; + private IConvertStrategy pointConvertStrategy; + private IConvertStrategy visualPropsConvertStrategy; + private IConvertStrategy divisionConvertStrategy; + + public ShapeNdmPrimitiveToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) + { + } + + public override ShapeNdmPrimitiveDTO GetNewItem(IShapeNdmPrimitive source) + { + ChildClass = this; + NewItem = new(source.Id); + InitializeStrategies(); + updateStrategy.Update(NewItem, source); + updateChildProperties(source); + return NewItem; + } + + private void updateChildProperties(IShapeNdmPrimitive source) + { + NewItem.SetShape(shapeConvertStrategy.Convert(source.Shape)); + NewItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement); + NewItem.Center = pointConvertStrategy.Convert(source.Center); + NewItem.VisualProperty = visualPropsConvertStrategy.Convert(source.VisualProperty); + NewItem.DivisionSize = divisionConvertStrategy.Convert(source.DivisionSize); + } + + private void InitializeStrategies() + { + updateStrategy = new ShapeNdmPrimitiveUpdateStrategy() { UpdateChildren = false }; + shapeConvertStrategy = new DictionaryConvertStrategy(this, new ShapeToDTOConvertStrategy(this)); + ndmElementConvertStrategy = new NdmElementToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger}; + pointConvertStrategy = new Point2DToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; + visualPropsConvertStrategy = new VisualPropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; + divisionConvertStrategy = new DivisionSizeToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; + } + } +} diff --git a/DataAccess/DTOs/Converters/CircleShapeFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/CircleShapeFromDTOConvertStrategy.cs similarity index 100% rename from DataAccess/DTOs/Converters/CircleShapeFromDTOConvertStrategy.cs rename to DataAccess/DTOs/Converters/Shapes/CircleShapeFromDTOConvertStrategy.cs diff --git a/DataAccess/DTOs/Converters/CircleShapeToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/CircleShapeToDTOConvertStrategy.cs similarity index 100% rename from DataAccess/DTOs/Converters/CircleShapeToDTOConvertStrategy.cs rename to DataAccess/DTOs/Converters/Shapes/CircleShapeToDTOConvertStrategy.cs diff --git a/DataAccess/DTOs/Converters/Shapes/LinePolygonToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/LinePolygonToDTOConvertStrategy.cs new file mode 100644 index 0000000..8a773c7 --- /dev/null +++ b/DataAccess/DTOs/Converters/Shapes/LinePolygonToDTOConvertStrategy.cs @@ -0,0 +1,36 @@ +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 DataAccess.DTOs +{ + public class LinePolygonToDTOConvertStrategy : ConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy vertexConvertStrategy; + + public LinePolygonToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) + { + } + + public override LinePolygonShapeDTO GetNewItem(ILinePolygonShape source) + { + ChildClass = this; + NewItem = new(source.Id); + updateStrategy = new LinePolygonShapeUpdateStrategy() { UpdateChildren = false }; + vertexConvertStrategy = new VertexToDTOConvertStrategy(this); + updateStrategy.Update(NewItem, source); + NewItem.Clear(); + foreach (var item in source.Vertices) + { + VertexDTO newVertex = vertexConvertStrategy.Convert(item); + NewItem.AddVertex(newVertex); + } + return NewItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/Point2DFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/Point2DFromDTOConvertStrategy.cs similarity index 100% rename from DataAccess/DTOs/Converters/Point2DFromDTOConvertStrategy.cs rename to DataAccess/DTOs/Converters/Shapes/Point2DFromDTOConvertStrategy.cs diff --git a/DataAccess/DTOs/Converters/Point2DToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/Point2DToDTOConvertStrategy.cs similarity index 100% rename from DataAccess/DTOs/Converters/Point2DToDTOConvertStrategy.cs rename to DataAccess/DTOs/Converters/Shapes/Point2DToDTOConvertStrategy.cs diff --git a/DataAccess/DTOs/Converters/RectangleShapeFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/RectangleShapeFromDTOConvertStrategy.cs similarity index 100% rename from DataAccess/DTOs/Converters/RectangleShapeFromDTOConvertStrategy.cs rename to DataAccess/DTOs/Converters/Shapes/RectangleShapeFromDTOConvertStrategy.cs diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/RectangleShapeToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/RectangleShapeToDTOConvertStrategy.cs similarity index 100% rename from DataAccess/DTOs/Converters/NdmCrossSections/RectangleShapeToDTOConvertStrategy.cs rename to DataAccess/DTOs/Converters/Shapes/RectangleShapeToDTOConvertStrategy.cs diff --git a/DataAccess/DTOs/Converters/ShapeFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/ShapeFromDTOConvertStrategy.cs similarity index 100% rename from DataAccess/DTOs/Converters/ShapeFromDTOConvertStrategy.cs rename to DataAccess/DTOs/Converters/Shapes/ShapeFromDTOConvertStrategy.cs diff --git a/DataAccess/DTOs/Converters/ShapeToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/ShapeToDTOConvertStrategy.cs similarity index 78% rename from DataAccess/DTOs/Converters/ShapeToDTOConvertStrategy.cs rename to DataAccess/DTOs/Converters/Shapes/ShapeToDTOConvertStrategy.cs index 861c6e6..b5e66eb 100644 --- a/DataAccess/DTOs/Converters/ShapeToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Shapes/ShapeToDTOConvertStrategy.cs @@ -9,6 +9,7 @@ namespace DataAccess.DTOs { private IConvertStrategy rectangleConvertStrategy; private IConvertStrategy circleConvertStrategy; + private IConvertStrategy linePolygonToDTOConvertStrategy; public ShapeToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) { @@ -32,6 +33,10 @@ namespace DataAccess.DTOs { ProcessCircle(circle); } + else if (source is ILinePolygonShape linePolygon) + { + ProcessLinePolygon(linePolygon); + } else { string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape type"; @@ -40,6 +45,13 @@ namespace DataAccess.DTOs TraceLogger?.AddMessage($"Shape converting Id = {NewItem.Id} has been has been finished successfully", TraceLogStatuses.Debug); } + private void ProcessLinePolygon(ILinePolygonShape linePolygon) + { + TraceLogger?.AddMessage($"Shape is line polygon", TraceLogStatuses.Debug); + linePolygonToDTOConvertStrategy = new DictionaryConvertStrategy(this, new LinePolygonToDTOConvertStrategy(this)); + NewItem = linePolygonToDTOConvertStrategy.Convert(linePolygon); + } + private void ProcessCircle(ICircleShape circle) { TraceLogger?.AddMessage($"Shape is circle", TraceLogStatuses.Debug); diff --git a/DataAccess/DTOs/Converters/Shapes/VertexToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/VertexToDTOConvertStrategy.cs new file mode 100644 index 0000000..f8f6bde --- /dev/null +++ b/DataAccess/DTOs/Converters/Shapes/VertexToDTOConvertStrategy.cs @@ -0,0 +1,26 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; + +namespace DataAccess.DTOs +{ + public class VertexToDTOConvertStrategy : ConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy pointConvertStrategy; + + public VertexToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) + { + } + + public override VertexDTO GetNewItem(IVertex source) + { + ChildClass = this; + NewItem = new(source.Id); + updateStrategy = new VertexUpdateStrategy() { UpdateChildren = false }; + pointConvertStrategy = new Point2DToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger}; + updateStrategy.Update(NewItem, source); + NewItem.Point = pointConvertStrategy.Convert(source.Point); + return NewItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/VisualPropertyToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/VisualPropertyToDTOConvertStrategy.cs index b11b4ca..3ad6812 100644 --- a/DataAccess/DTOs/Converters/VisualPropertyToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/VisualPropertyToDTOConvertStrategy.cs @@ -2,13 +2,8 @@ using StructureHelperCommon.Models; using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.NdmCalculations.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace DataAccess.DTOs.Converters +namespace DataAccess.DTOs { public class VisualPropertyToDTOConvertStrategy : IConvertStrategy { diff --git a/DataAccess/DTOs/DTOEntities/NdmCrossSections/EllipseNdmPrimitiveDTO.cs b/DataAccess/DTOs/DTOEntities/NdmCrossSections/EllipseNdmPrimitiveDTO.cs index 143d5d1..0cd8318 100644 --- a/DataAccess/DTOs/DTOEntities/NdmCrossSections/EllipseNdmPrimitiveDTO.cs +++ b/DataAccess/DTOs/DTOEntities/NdmCrossSections/EllipseNdmPrimitiveDTO.cs @@ -11,6 +11,11 @@ namespace DataAccess.DTOs { private IRectangleShape shape = new RectangleShapeDTO(Guid.Empty); + public EllipseNdmPrimitiveDTO(Guid id) + { + Id = id; + } + [JsonProperty("Id")] public Guid Id { get; set; } [JsonProperty("Name")] @@ -42,7 +47,7 @@ namespace DataAccess.DTOs public object Clone() { - throw new NotImplementedException(); + return this; } public IEnumerable GetNdms(ITriangulationOptions triangulationOptions) diff --git a/DataAccess/DTOs/DTOEntities/NdmCrossSections/ShapeNdmPrimitiveDTO.cs b/DataAccess/DTOs/DTOEntities/NdmCrossSections/ShapeNdmPrimitiveDTO.cs new file mode 100644 index 0000000..6c7c2eb --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/NdmCrossSections/ShapeNdmPrimitiveDTO.cs @@ -0,0 +1,67 @@ +using LoaderCalculator.Data.Ndms; +using Newtonsoft.Json; +using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.Models.CrossSections; +using StructureHelperLogics.NdmCalculations.Primitives; +using StructureHelperLogics.NdmCalculations.Triangulations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class ShapeNdmPrimitiveDTO : IShapeNdmPrimitive + { + private IShape shape; + + [JsonProperty("Id")] + public Guid Id { get; } + [JsonProperty("Name")] + public string? Name { get; set; } + [JsonProperty("Shape")] + public IShape Shape => shape; + [JsonProperty("NdmElement")] + public INdmElement NdmElement { get; set; } + [JsonProperty("Center")] + public IPoint2D Center { get; set; } + [JsonProperty("VisualProperty")] + public IVisualProperty VisualProperty { get; set; } + [JsonProperty("RotationAngle")] + public double RotationAngle { get; set; } + [JsonProperty("DivisionSize")] + public IDivisionSize DivisionSize { get; set; } + [JsonIgnore] + public ICrossSection? CrossSection { get; set; } + public ShapeNdmPrimitiveDTO(Guid id) + { + Id = id; + } + + public object Clone() + { + return this; + } + + public IEnumerable GetNdms(ITriangulationOptions triangulationOptions) + { + throw new NotImplementedException(); + } + + public List GetValuePoints() + { + throw new NotImplementedException(); + } + + public bool IsPointInside(IPoint2D point) + { + throw new NotImplementedException(); + } + + public void SetShape(IShape shape) + { + this.shape = shape; + } + } +} diff --git a/DataAccess/DTOs/DTOEntities/CircleShapeDTO.cs b/DataAccess/DTOs/DTOEntities/Shapes/CircleShapeDTO.cs similarity index 76% rename from DataAccess/DTOs/DTOEntities/CircleShapeDTO.cs rename to DataAccess/DTOs/DTOEntities/Shapes/CircleShapeDTO.cs index 6a7f22b..b68f71c 100644 --- a/DataAccess/DTOs/DTOEntities/CircleShapeDTO.cs +++ b/DataAccess/DTOs/DTOEntities/Shapes/CircleShapeDTO.cs @@ -1,10 +1,5 @@ using Newtonsoft.Json; using StructureHelperCommon.Models.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DataAccess.DTOs { diff --git a/DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs b/DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs new file mode 100644 index 0000000..3d8255e --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs @@ -0,0 +1,53 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Models.Shapes; + +namespace DataAccess.DTOs +{ + public class LinePolygonShapeDTO : ILinePolygonShape + { + private readonly List _vertices = []; + [JsonProperty("Id")] + public Guid Id { get; } + [JsonProperty("Vertices")] + public IReadOnlyList Vertices => _vertices; + [JsonProperty("IsClosed")] + public bool IsClosed { get; set; } + + + public LinePolygonShapeDTO(Guid id) + { + Id = id; + } + + public IVertex AddVertex(IVertex vertex) + { + _vertices.Add(vertex); + return vertex; + } + + public IVertex AddVertexAfter(IVertex existing, IVertex vertex) + { + throw new NotImplementedException(); + } + + public IVertex AddVertexBefore(IVertex existing, IVertex vertex) + { + throw new NotImplementedException(); + } + + public void Clear() + { + _vertices.Clear(); + } + + public IVertex InsertVertex(int index, IVertex vertex) + { + throw new NotImplementedException(); + } + + public void RemoveVertex(IVertex vertex) + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/DTOEntities/Point2DDTO.cs b/DataAccess/DTOs/DTOEntities/Shapes/Point2DDTO.cs similarity index 100% rename from DataAccess/DTOs/DTOEntities/Point2DDTO.cs rename to DataAccess/DTOs/DTOEntities/Shapes/Point2DDTO.cs diff --git a/DataAccess/DTOs/DTOEntities/RectangleShapeDTO.cs b/DataAccess/DTOs/DTOEntities/Shapes/RectangleShapeDTO.cs similarity index 100% rename from DataAccess/DTOs/DTOEntities/RectangleShapeDTO.cs rename to DataAccess/DTOs/DTOEntities/Shapes/RectangleShapeDTO.cs diff --git a/DataAccess/DTOs/DTOEntities/Shapes/VertexDTO.cs b/DataAccess/DTOs/DTOEntities/Shapes/VertexDTO.cs new file mode 100644 index 0000000..e60f9a9 --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/Shapes/VertexDTO.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class VertexDTO : IVertex + { + [JsonProperty("Id")] + public Guid Id { get; } + [JsonProperty("Point")] + public IPoint2D Point { get; set; } + + public VertexDTO(Guid id) + { + Id = id; + } + } +} diff --git a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveOperations.cs b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveOperations.cs index f30b7fe..87df00c 100644 --- a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveOperations.cs +++ b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveOperations.cs @@ -33,7 +33,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts { viewItem = new CircleViewPrimitive(circle); } - else if (primitive is IShapeNDMPrimitive shapeNDMPrimitive) + else if (primitive is IShapeNdmPrimitive shapeNDMPrimitive) { viewItem = new ShapeViewPrimitive(shapeNDMPrimitive); } diff --git a/StructureHelper/Infrastructure/UI/DataContexts/ShapeViewPrimitive.cs b/StructureHelper/Infrastructure/UI/DataContexts/ShapeViewPrimitive.cs index 7e4f289..4fa1de8 100644 --- a/StructureHelper/Infrastructure/UI/DataContexts/ShapeViewPrimitive.cs +++ b/StructureHelper/Infrastructure/UI/DataContexts/ShapeViewPrimitive.cs @@ -12,11 +12,11 @@ namespace StructureHelper.Infrastructure.UI.DataContexts { public class ShapeViewPrimitive : PrimitiveBase { - IShapeNDMPrimitive shapeNDMPrimitive; + IShapeNdmPrimitive shapeNDMPrimitive; public PathGeometry PathGeometry { get; set; } - public ShapeViewPrimitive(IShapeNDMPrimitive shapeNDMPrimitive) : base(shapeNDMPrimitive) + public ShapeViewPrimitive(IShapeNdmPrimitive shapeNDMPrimitive) : base(shapeNDMPrimitive) { this.shapeNDMPrimitive = shapeNDMPrimitive; DivisionViewModel = new HasDivisionViewModel(this.shapeNDMPrimitive.DivisionSize); @@ -35,7 +35,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts private void UpdatePath() { var shape = shapeNDMPrimitive.Shape; - if (shape is not IPolygonShape polygon) + if (shape is not ILinePolygonShape polygon) { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(shape)); } diff --git a/StructureHelper/Windows/Forces/ForceCombinationFromFileVM.cs b/StructureHelper/Windows/Forces/ForceCombinationFromFileVM.cs index bef535c..ec0d355 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationFromFileVM.cs +++ b/StructureHelper/Windows/Forces/ForceCombinationFromFileVM.cs @@ -35,7 +35,6 @@ namespace StructureHelper.Windows.Forces { return model.SkipWrongRows; } - set { model.SkipWrongRows = value; diff --git a/StructureHelper/Windows/Forces/ForceCombinationViewerVM.cs b/StructureHelper/Windows/Forces/ForceCombinationViewerVM.cs index caa3f3f..15ef0d8 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationViewerVM.cs +++ b/StructureHelper/Windows/Forces/ForceCombinationViewerVM.cs @@ -32,6 +32,10 @@ namespace StructureHelper.Windows.Forces } } + public int RowsNumber => Combinations.Count(); + //public double MxMin => Combinations.Min( x => x.ForceTuple.Mx); + //public double MxMax => Combinations.Max( x => x.ForceTuple.Mx); + private void Refresh() { Combinations.Clear(); @@ -41,6 +45,9 @@ namespace StructureHelper.Windows.Forces var combinationList = combination.DesignForces.Where(x => x.LimitState == limitState && x.CalcTerm == calcTerm).ToList(); combinationList.ForEach(x => Combinations.Add(x)); } + OnPropertyChanged(nameof(RowsNumber)); + //OnPropertyChanged(nameof(MxMin)); + //OnPropertyChanged(nameof(MxMax)); } public CalcTerms CalcTerm diff --git a/StructureHelper/Windows/Forces/ForceCombinationViewerView.xaml b/StructureHelper/Windows/Forces/ForceCombinationViewerView.xaml index 1ed4c21..944672c 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationViewerView.xaml +++ b/StructureHelper/Windows/Forces/ForceCombinationViewerView.xaml @@ -26,6 +26,10 @@ + + + + @@ -35,6 +39,14 @@ + + + + + + + + diff --git a/StructureHelper/Windows/Forces/ForceFilePropertyVM.cs b/StructureHelper/Windows/Forces/ForceFilePropertyVM.cs index adc8802..2d261d3 100644 --- a/StructureHelper/Windows/Forces/ForceFilePropertyVM.cs +++ b/StructureHelper/Windows/Forces/ForceFilePropertyVM.cs @@ -1,17 +1,16 @@ -using StructureHelper.Windows.ViewModels; +using StructureHelper.Infrastructure; +using StructureHelper.Windows.ViewModels; using StructureHelperCommon.Models.Forces; -using System; -using System.Collections.Generic; +using StructureHelperCommon.Services.FileServices; using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Windows.Input; namespace StructureHelper.Windows.Forces { public class ForceFilePropertyVM : OkCancelViewModelBase { private IColumnedFileProperty model; + private RelayCommand openFileCommand; public ForceFilePropertyVM(IColumnedFileProperty model) { @@ -59,6 +58,31 @@ namespace StructureHelper.Windows.Forces } } + + public ICommand OpenFileCommand => openFileCommand ??= new RelayCommand(o => OpenFileMethod()); + + private void OpenFileMethod() + { + var result = GetFilePath(); + if (result.IsValid == false) + { + return; + } + FilePath = result.FilePath; + } + + private OpenFileResult GetFilePath() + { + var inputData = new OpenFileInputData() + { + FilterString = "MS Excel file (*.xlsx)|*.xlsx|All Files (*.*)|*.*", + TraceLogger = null + }; + var fileDialog = new FileOpener(inputData); + var fileDialogResult = fileDialog.OpenFile(); + return fileDialogResult; + } + public ObservableCollection ColumnProperties { get; set; } = new(); public IColumnedFileProperty Model diff --git a/StructureHelper/Windows/Forces/ForceFilePropertyView.xaml b/StructureHelper/Windows/Forces/ForceFilePropertyView.xaml index 7051461..d6c5122 100644 --- a/StructureHelper/Windows/Forces/ForceFilePropertyView.xaml +++ b/StructureHelper/Windows/Forces/ForceFilePropertyView.xaml @@ -47,7 +47,14 @@ - + + + + + + +