From d16c0e1f79e064a615ba704f666615462c38b05c Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Sun, 13 Oct 2024 17:31:18 +0500 Subject: [PATCH] Add EllipsePrimitive to DTO Converter --- DataAccess/DTOs/CirclePrimitiveDTO.cs | 13 --- ...ssSectionRepositoryToDTOConvertStrategy.cs | 27 ++++- .../DivisionSizeToDTOConvertStrategy.cs | 51 +++++++++ .../EllipsePrimitiveDTOConvertStrategy.cs | 105 ++++++++++++++++++ .../NdmElementDTOConvertStrategy.cs | 71 ++++++++++++ .../RectangleShapeToDTOConvertStrategy.cs | 31 ++++++ .../VersionProcessorToDTOConvertStrategy.cs | 17 +++ .../VisualPropertyToDTOConvertStrategy.cs | 45 ++++++++ .../ConcreteLibMaterialDTO.cs | 0 .../DTOs/{ => DTOEntities}/CrossSectionDTO.cs | 0 .../CrossSectionNdmAnalysisDTO.cs | 0 .../CrossSectionRepositoryDTO.cs | 0 .../DTOs/{ => DTOEntities}/DateVersionDTO.cs | 0 .../{ => DTOEntities}/DesignForceTupleDTO.cs | 0 .../DTOs/DTOEntities/DivisionSizeDTO.cs | 23 ++++ .../{ => DTOEntities}/ElasticMaterialDTO.cs | 0 .../DTOEntities/EllipseNdmPrimitiveDTO.cs | 67 +++++++++++ .../DTOs/{ => DTOEntities}/FRMaterialDTO.cs | 0 .../DTOs/{ => DTOEntities}/FileVersionDTO.cs | 0 .../ForceCombinationByFactorDTO.cs | 0 .../ForceCombinationListDTO.cs | 0 .../DTOs/{ => DTOEntities}/ForceTupleDTO.cs | 0 .../DTOs/{ => DTOEntities}/HeadMaterialDTO.cs | 0 .../MaterialPartialFactorDTO.cs | 0 .../MaterialSafetyFactorDTO.cs | 0 .../NdmElementDTO.cs} | 13 +-- .../DTOs/{ => DTOEntities}/Point2DDTO.cs | 0 .../DTOs/{ => DTOEntities}/ProjectDTO.cs | 0 .../DTOs/DTOEntities/RectangleShapeDTO.cs | 23 ++++ .../ReinforcementLibMaterialDTO.cs | 0 .../DTOs/{ => DTOEntities}/TypeBinder.cs | 0 .../TypeBinderListFactory.cs | 7 +- .../{ => DTOEntities}/VersionProcessorDTO.cs | 0 .../{ => DTOEntities}/VisualAnalysisDTO.cs | 0 .../DTOs/DTOEntities/VisualPropertyDTO.cs | 28 +++++ .../MainWindow/AxisCanvases/AxisCanvasVM.cs | 2 + .../NdmCrossSections/HasDivisionViewModel.cs | 2 + .../PrimitiveViewModelLogic.cs | 2 + .../Interfaces/CheckConvertLogic.cs | 5 + .../Models/Shapes/CircleShape.cs | 11 ++ StructureHelperCommon/Models/Shapes/IShape.cs | 6 +- .../Models/Shapes/LineShape.cs | 22 ++-- .../Models/Shapes/PointShape.cs | 15 ++- .../Models/Shapes/RectangleShape.cs | 14 ++- .../Primitives/DivisionSize.cs | 11 ++ .../Primitives/IDivisionSize.cs | 5 +- .../NdmCalculations/Primitives/INdmElement.cs | 4 +- .../Primitives/IVisualProperty.cs | 5 +- .../Primitives/LinePrimitive.cs | 2 +- ...ategy.cs => DivisionSizeUpdateStrategy.cs} | 2 +- .../Logics/EllipsePrimitiveUpdateStrategy.cs | 4 +- .../RectanglePrimitiveUpdateStrategy.cs | 2 +- .../NdmCalculations/Primitives/NdmElement.cs | 4 +- .../Primitives/VisualProperty.cs | 28 +++-- 54 files changed, 605 insertions(+), 62 deletions(-) delete mode 100644 DataAccess/DTOs/CirclePrimitiveDTO.cs create mode 100644 DataAccess/DTOs/Converters/DivisionSizeToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/EllipsePrimitiveDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/NdmElementDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/RectangleShapeToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/VisualPropertyToDTOConvertStrategy.cs rename DataAccess/DTOs/{ => DTOEntities}/ConcreteLibMaterialDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/CrossSectionDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/CrossSectionNdmAnalysisDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/CrossSectionRepositoryDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/DateVersionDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/DesignForceTupleDTO.cs (100%) create mode 100644 DataAccess/DTOs/DTOEntities/DivisionSizeDTO.cs rename DataAccess/DTOs/{ => DTOEntities}/ElasticMaterialDTO.cs (100%) create mode 100644 DataAccess/DTOs/DTOEntities/EllipseNdmPrimitiveDTO.cs rename DataAccess/DTOs/{ => DTOEntities}/FRMaterialDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/FileVersionDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/ForceCombinationByFactorDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/ForceCombinationListDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/ForceTupleDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/HeadMaterialDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/MaterialPartialFactorDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/MaterialSafetyFactorDTO.cs (100%) rename DataAccess/DTOs/{NdmPrimitiveDTO.cs => DTOEntities/NdmElementDTO.cs} (62%) rename DataAccess/DTOs/{ => DTOEntities}/Point2DDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/ProjectDTO.cs (100%) create mode 100644 DataAccess/DTOs/DTOEntities/RectangleShapeDTO.cs rename DataAccess/DTOs/{ => DTOEntities}/ReinforcementLibMaterialDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/TypeBinder.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/TypeBinderListFactory.cs (91%) rename DataAccess/DTOs/{ => DTOEntities}/VersionProcessorDTO.cs (100%) rename DataAccess/DTOs/{ => DTOEntities}/VisualAnalysisDTO.cs (100%) create mode 100644 DataAccess/DTOs/DTOEntities/VisualPropertyDTO.cs rename StructureHelperLogics/NdmCalculations/Primitives/Logics/{DivisionPropsUpdateStrategy.cs => DivisionSizeUpdateStrategy.cs} (88%) diff --git a/DataAccess/DTOs/CirclePrimitiveDTO.cs b/DataAccess/DTOs/CirclePrimitiveDTO.cs deleted file mode 100644 index 8df3566..0000000 --- a/DataAccess/DTOs/CirclePrimitiveDTO.cs +++ /dev/null @@ -1,13 +0,0 @@ -using StructureHelperLogics.NdmCalculations.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DataAccess.DTOs -{ - public class CirclePrimitiveDTO - { - } -} diff --git a/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs index fc3f394..9b35ec0 100644 --- a/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs @@ -8,6 +8,7 @@ using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Materials; +using StructureHelperLogics.NdmCalculations.Primitives; using System; using System.Collections.Generic; using System.Linq; @@ -21,6 +22,7 @@ namespace DataAccess.DTOs private IConvertStrategy materialConvertStrategy; private IConvertStrategy forceCombinationByFactorConvertStrategy; private IConvertStrategy forceCombinationListConvertStrategy; + private IConvertStrategy ellipseConvertStrategy = new EllipsePrimitiveDTOConvertStrategy(); public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy materialConvertStrategy, IConvertStrategy forceCombinationByFactorConvertStrategy, @@ -66,12 +68,31 @@ namespace DataAccess.DTOs Id = source.Id }; List forceActions = ProcessForceActions(source); - List materials = ProcessMaterials(source); newItem.ForceActions.AddRange(forceActions); + List materials = ProcessMaterials(source); newItem.HeadMaterials.AddRange(materials); + List primitives = ProcessPrimitives(source); + newItem.Primitives.AddRange(primitives); return newItem; } + private List ProcessPrimitives(ICrossSectionRepository source) + { + List primitives = new(); + foreach (var item in source.Primitives) + { + if (item is IEllipsePrimitive ellipse) + { + ellipseConvertStrategy.ReferenceDictionary = ReferenceDictionary; + ellipseConvertStrategy.TraceLogger = TraceLogger; + INdmPrimitive ndmPrimitive; + ndmPrimitive = ellipseConvertStrategy.Convert(ellipse); + primitives.Add(ndmPrimitive); + } + } + return primitives; + } + private List ProcessForceActions(ICrossSectionRepository source) { List forceActions = new(); @@ -113,7 +134,7 @@ namespace DataAccess.DTOs return forceCombination; } - private List ProcessMaterials(ICrossSectionRepository source) + private List ProcessMaterials(ICrossSectionRepository source) { materialConvertStrategy.ReferenceDictionary = ReferenceDictionary; materialConvertStrategy.TraceLogger = TraceLogger; @@ -123,7 +144,7 @@ namespace DataAccess.DTOs ConvertStrategy = materialConvertStrategy, TraceLogger = TraceLogger }; - List materials = new(); + List materials = new(); foreach (var item in source.HeadMaterials) { materials.Add(convertLogic.Convert(item)); diff --git a/DataAccess/DTOs/Converters/DivisionSizeToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/DivisionSizeToDTOConvertStrategy.cs new file mode 100644 index 0000000..a19bd67 --- /dev/null +++ b/DataAccess/DTOs/Converters/DivisionSizeToDTOConvertStrategy.cs @@ -0,0 +1,51 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +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 +{ + public class DivisionSizeToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + + public DivisionSizeToDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public DivisionSizeToDTOConvertStrategy() : this (new DivisionSizeUpdateStrategy()) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public DivisionSizeDTO Convert(IDivisionSize source) + { + try + { + return GetNewDivisionSize(source); + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private DivisionSizeDTO GetNewDivisionSize(IDivisionSize source) + { + DivisionSizeDTO newItem = new() { Id = source.Id }; + updateStrategy.Update(newItem, source); + return newItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/EllipsePrimitiveDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/EllipsePrimitiveDTOConvertStrategy.cs new file mode 100644 index 0000000..a7e42eb --- /dev/null +++ b/DataAccess/DTOs/Converters/EllipsePrimitiveDTOConvertStrategy.cs @@ -0,0 +1,105 @@ +using DataAccess.DTOs.Converters; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class EllipsePrimitiveDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy rectangleShapeConvertStrategy; + private IConvertStrategy ndmElementConvertStrategy; + private IConvertStrategy pointConvertStrategy; + private IConvertStrategy visualPropsConvertStrategy; + private IConvertStrategy divisionConvertStrategy; + + public EllipsePrimitiveDTOConvertStrategy( + IUpdateStrategy updateStrategy, + IConvertStrategy rectangleShapeConvertStrategy, + IConvertStrategy ndmElementConvertStrategy, + IConvertStrategy pointConvertStrategy, + IConvertStrategy visualPropsConvertStrategy, + IConvertStrategy divisionConvertStrategy) + { + this.updateStrategy = updateStrategy; + this.rectangleShapeConvertStrategy = rectangleShapeConvertStrategy; + this.ndmElementConvertStrategy = ndmElementConvertStrategy; + this.pointConvertStrategy = pointConvertStrategy; + this.visualPropsConvertStrategy = visualPropsConvertStrategy; + this.divisionConvertStrategy = divisionConvertStrategy; + } + + public EllipsePrimitiveDTOConvertStrategy() : this( + new EllipsePrimitiveUpdateStrategy(), + new RectangleShapeToDTOConvertStrategy(), + new NdmElementDTOConvertStrategy(), + new Point2DToDTOConvertStrategy(), + new VisualPropertyToDTOConvertStrategy(), + new DivisionSizeToDTOConvertStrategy() + ) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public EllipseNdmPrimitiveDTO Convert(IEllipsePrimitive source) + { + try + { + Check(); + PrepareStrategies(); + return GetNewEllipsePrimitive(source); + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private EllipseNdmPrimitiveDTO GetNewEllipsePrimitive(IEllipsePrimitive source) + { + EllipseNdmPrimitiveDTO newItem = new() { Id = source.Id }; + updateStrategy.Update(newItem, source); + newItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement); + newItem.RectangleShape = rectangleShapeConvertStrategy.Convert(source.Shape as IRectangleShape); + newItem.Center = pointConvertStrategy.Convert(source.Center); + newItem.VisualProperty = visualPropsConvertStrategy.Convert(source.VisualProperty); + newItem.DivisionSize = divisionConvertStrategy.Convert(source.DivisionSize); + return newItem; + } + + private void PrepareStrategies() + { + rectangleShapeConvertStrategy.ReferenceDictionary = + ndmElementConvertStrategy.ReferenceDictionary = + pointConvertStrategy.ReferenceDictionary = + visualPropsConvertStrategy.ReferenceDictionary = + divisionConvertStrategy.ReferenceDictionary = + ReferenceDictionary; + rectangleShapeConvertStrategy.TraceLogger = + ndmElementConvertStrategy.TraceLogger = + pointConvertStrategy.TraceLogger = + visualPropsConvertStrategy.TraceLogger = + divisionConvertStrategy.TraceLogger = + TraceLogger; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(this); + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/NdmElementDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmElementDTOConvertStrategy.cs new file mode 100644 index 0000000..ebaec05 --- /dev/null +++ b/DataAccess/DTOs/Converters/NdmElementDTOConvertStrategy.cs @@ -0,0 +1,71 @@ +using DataAccess.DTOs.Converters; +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Loggers; +using StructureHelperLogics.NdmCalculations.Primitives; +using StructureHelperLogics.NdmCalculations.Primitives.Logics; + +namespace DataAccess.DTOs +{ + public class NdmElementDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy headMaterialConvertStrategy; + private IUpdateStrategy forceUpdateStrategy = new ForceTupleUpdateStrategy(); + + public NdmElementDTOConvertStrategy( + IUpdateStrategy updateStrategy, + IConvertStrategy headMaterialConvertStrategy) + { + this.updateStrategy = updateStrategy; + this.headMaterialConvertStrategy = headMaterialConvertStrategy; + } + + public NdmElementDTOConvertStrategy() : this( + new NdmElementUpdateStrategy(), + new HeadMaterialToDTOConvertStrategy()) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public NdmElementDTO Convert(INdmElement source) + { + Check(); + try + { + return GenNewNdmElementDTO(source); + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private NdmElementDTO GenNewNdmElementDTO(INdmElement source) + { + NdmElementDTO newItem = new() { Id = source.Id }; + updateStrategy.Update(newItem, source); + headMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary; + headMaterialConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, headMaterialConvertStrategy); + var headMaterial = convertLogic.Convert(source.HeadMaterial); + newItem.HeadMaterial = headMaterial; + forceUpdateStrategy.Update(newItem.UsersPrestrain, source.UsersPrestrain); + forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain); + return newItem; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(this); + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/RectangleShapeToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/RectangleShapeToDTOConvertStrategy.cs new file mode 100644 index 0000000..8a36005 --- /dev/null +++ b/DataAccess/DTOs/Converters/RectangleShapeToDTOConvertStrategy.cs @@ -0,0 +1,31 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Shapes; + +namespace DataAccess.DTOs +{ + public class RectangleShapeToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + + public RectangleShapeToDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public RectangleShapeToDTOConvertStrategy() : this (new RectangleShapeUpdateStrategy()) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public RectangleShapeDTO Convert(IRectangleShape source) + { + RectangleShapeDTO newItem = new() { Id = source.Id}; + updateStrategy.Update(newItem, source); + return newItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs index 6e141ff..cb389a8 100644 --- a/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs @@ -1,6 +1,7 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Analyses; +using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.Models.CrossSections; using System; using System.Collections.Generic; @@ -31,6 +32,21 @@ namespace DataAccess.DTOs public VersionProcessorDTO Convert(IVersionProcessor source) { Check(); + try + { + VersionProcessorDTO versionProcessorDTO = GetNewVersionProcessor(source); + return versionProcessorDTO; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private VersionProcessorDTO GetNewVersionProcessor(IVersionProcessor source) + { VersionProcessorDTO newItem = new() { Id = source.Id @@ -44,6 +60,7 @@ namespace DataAccess.DTOs } return newItem; } + private void Check() { checkLogic = new CheckConvertLogic(this); diff --git a/DataAccess/DTOs/Converters/VisualPropertyToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/VisualPropertyToDTOConvertStrategy.cs new file mode 100644 index 0000000..b11b4ca --- /dev/null +++ b/DataAccess/DTOs/Converters/VisualPropertyToDTOConvertStrategy.cs @@ -0,0 +1,45 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +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 +{ + public class VisualPropertyToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public VisualPropertyToDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public VisualPropertyToDTOConvertStrategy() : this (new VisualPropsUpdateStrategy()) + { + + } + + public VisualPropertyDTO Convert(IVisualProperty source) + { + try + { + VisualPropertyDTO newItem = new() { Id = source.Id }; + updateStrategy.Update(newItem, source); + return newItem; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + } +} diff --git a/DataAccess/DTOs/ConcreteLibMaterialDTO.cs b/DataAccess/DTOs/DTOEntities/ConcreteLibMaterialDTO.cs similarity index 100% rename from DataAccess/DTOs/ConcreteLibMaterialDTO.cs rename to DataAccess/DTOs/DTOEntities/ConcreteLibMaterialDTO.cs diff --git a/DataAccess/DTOs/CrossSectionDTO.cs b/DataAccess/DTOs/DTOEntities/CrossSectionDTO.cs similarity index 100% rename from DataAccess/DTOs/CrossSectionDTO.cs rename to DataAccess/DTOs/DTOEntities/CrossSectionDTO.cs diff --git a/DataAccess/DTOs/CrossSectionNdmAnalysisDTO.cs b/DataAccess/DTOs/DTOEntities/CrossSectionNdmAnalysisDTO.cs similarity index 100% rename from DataAccess/DTOs/CrossSectionNdmAnalysisDTO.cs rename to DataAccess/DTOs/DTOEntities/CrossSectionNdmAnalysisDTO.cs diff --git a/DataAccess/DTOs/CrossSectionRepositoryDTO.cs b/DataAccess/DTOs/DTOEntities/CrossSectionRepositoryDTO.cs similarity index 100% rename from DataAccess/DTOs/CrossSectionRepositoryDTO.cs rename to DataAccess/DTOs/DTOEntities/CrossSectionRepositoryDTO.cs diff --git a/DataAccess/DTOs/DateVersionDTO.cs b/DataAccess/DTOs/DTOEntities/DateVersionDTO.cs similarity index 100% rename from DataAccess/DTOs/DateVersionDTO.cs rename to DataAccess/DTOs/DTOEntities/DateVersionDTO.cs diff --git a/DataAccess/DTOs/DesignForceTupleDTO.cs b/DataAccess/DTOs/DTOEntities/DesignForceTupleDTO.cs similarity index 100% rename from DataAccess/DTOs/DesignForceTupleDTO.cs rename to DataAccess/DTOs/DTOEntities/DesignForceTupleDTO.cs diff --git a/DataAccess/DTOs/DTOEntities/DivisionSizeDTO.cs b/DataAccess/DTOs/DTOEntities/DivisionSizeDTO.cs new file mode 100644 index 0000000..cda2c58 --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/DivisionSizeDTO.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class DivisionSizeDTO : IDivisionSize + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("NdmMaxSize")] + public double NdmMaxSize { get; set; } + [JsonProperty("NdmMinDivision")] + public int NdmMinDivision { get; set; } + [JsonProperty("ClearUnderlying")] + public bool ClearUnderlying { get; set; } + + } +} diff --git a/DataAccess/DTOs/ElasticMaterialDTO.cs b/DataAccess/DTOs/DTOEntities/ElasticMaterialDTO.cs similarity index 100% rename from DataAccess/DTOs/ElasticMaterialDTO.cs rename to DataAccess/DTOs/DTOEntities/ElasticMaterialDTO.cs diff --git a/DataAccess/DTOs/DTOEntities/EllipseNdmPrimitiveDTO.cs b/DataAccess/DTOs/DTOEntities/EllipseNdmPrimitiveDTO.cs new file mode 100644 index 0000000..d3490a3 --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/EllipseNdmPrimitiveDTO.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 EllipseNdmPrimitiveDTO : IEllipsePrimitive + { + private IRectangleShape shape = new RectangleShapeDTO(); + + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Name")] + public string? Name { get; set; } + [JsonProperty("RectangleShape")] + public IRectangleShape RectangleShape + { + get => shape; + set => shape = value; + } + [JsonIgnore] + public IShape Shape => shape; + [JsonProperty("NdmElement")] + public INdmElement NdmElement { get; set; } = new NdmElementDTO(); + [JsonProperty("VisualProperty")] + public IVisualProperty VisualProperty { get; set; } = new VisualPropertyDTO(); + [JsonProperty("Center")] + public IPoint2D Center { get; set; } = new Point2DDTO(); + [JsonProperty("DivisionSize")] + public IDivisionSize DivisionSize { get; set; } = new DivisionSizeDTO(); + [JsonIgnore] + public double Width { get; set; } + [JsonIgnore] + public double Height {get; set; } + [JsonIgnore] + public double Angle { get; set; } + [JsonIgnore] + public ICrossSection? CrossSection { get; set; } + public object Clone() + { + throw new NotImplementedException(); + } + + public IEnumerable GetNdms(ITriangulationOptions triangulationOptions) + { + throw new NotImplementedException(); + } + + public List GetValuePoints() + { + throw new NotImplementedException(); + } + + public bool IsPointInside(IPoint2D point) + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/FRMaterialDTO.cs b/DataAccess/DTOs/DTOEntities/FRMaterialDTO.cs similarity index 100% rename from DataAccess/DTOs/FRMaterialDTO.cs rename to DataAccess/DTOs/DTOEntities/FRMaterialDTO.cs diff --git a/DataAccess/DTOs/FileVersionDTO.cs b/DataAccess/DTOs/DTOEntities/FileVersionDTO.cs similarity index 100% rename from DataAccess/DTOs/FileVersionDTO.cs rename to DataAccess/DTOs/DTOEntities/FileVersionDTO.cs diff --git a/DataAccess/DTOs/ForceCombinationByFactorDTO.cs b/DataAccess/DTOs/DTOEntities/ForceCombinationByFactorDTO.cs similarity index 100% rename from DataAccess/DTOs/ForceCombinationByFactorDTO.cs rename to DataAccess/DTOs/DTOEntities/ForceCombinationByFactorDTO.cs diff --git a/DataAccess/DTOs/ForceCombinationListDTO.cs b/DataAccess/DTOs/DTOEntities/ForceCombinationListDTO.cs similarity index 100% rename from DataAccess/DTOs/ForceCombinationListDTO.cs rename to DataAccess/DTOs/DTOEntities/ForceCombinationListDTO.cs diff --git a/DataAccess/DTOs/ForceTupleDTO.cs b/DataAccess/DTOs/DTOEntities/ForceTupleDTO.cs similarity index 100% rename from DataAccess/DTOs/ForceTupleDTO.cs rename to DataAccess/DTOs/DTOEntities/ForceTupleDTO.cs diff --git a/DataAccess/DTOs/HeadMaterialDTO.cs b/DataAccess/DTOs/DTOEntities/HeadMaterialDTO.cs similarity index 100% rename from DataAccess/DTOs/HeadMaterialDTO.cs rename to DataAccess/DTOs/DTOEntities/HeadMaterialDTO.cs diff --git a/DataAccess/DTOs/MaterialPartialFactorDTO.cs b/DataAccess/DTOs/DTOEntities/MaterialPartialFactorDTO.cs similarity index 100% rename from DataAccess/DTOs/MaterialPartialFactorDTO.cs rename to DataAccess/DTOs/DTOEntities/MaterialPartialFactorDTO.cs diff --git a/DataAccess/DTOs/MaterialSafetyFactorDTO.cs b/DataAccess/DTOs/DTOEntities/MaterialSafetyFactorDTO.cs similarity index 100% rename from DataAccess/DTOs/MaterialSafetyFactorDTO.cs rename to DataAccess/DTOs/DTOEntities/MaterialSafetyFactorDTO.cs diff --git a/DataAccess/DTOs/NdmPrimitiveDTO.cs b/DataAccess/DTOs/DTOEntities/NdmElementDTO.cs similarity index 62% rename from DataAccess/DTOs/NdmPrimitiveDTO.cs rename to DataAccess/DTOs/DTOEntities/NdmElementDTO.cs index 0e3b3a0..2f2c7f8 100644 --- a/DataAccess/DTOs/NdmPrimitiveDTO.cs +++ b/DataAccess/DTOs/DTOEntities/NdmElementDTO.cs @@ -1,7 +1,6 @@ using Newtonsoft.Json; using StructureHelper.Models.Materials; using StructureHelperCommon.Models.Forces; -using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.NdmCalculations.Primitives; using System; using System.Collections.Generic; @@ -11,18 +10,18 @@ using System.Threading.Tasks; namespace DataAccess.DTOs { - public class NdmPrimitiveDTO : INdmElement + public class NdmElementDTO : INdmElement { [JsonProperty("Id")] public Guid Id { get; set; } [JsonProperty("HeadMaterial")] - public IHeadMaterial? HeadMaterial { get; set; } + public IHeadMaterial? HeadMaterial { get; set; } = new HeadMaterial(); [JsonProperty("Triangulate")] public bool Triangulate { get; set; } - [JsonProperty("UserPrestrain")] - public StrainTuple UsersPrestrain { get; } = new StrainTuple(); - [JsonIgnore] - public StrainTuple AutoPrestrain => throw new NotImplementedException(); + [JsonProperty("UsersPrestrain")] + public IForceTuple UsersPrestrain { get; set; } = new ForceTupleDTO(); + [JsonProperty("AutoPrestrain")] + public IForceTuple AutoPrestrain { get; set; } = new ForceTupleDTO(); public object Clone() diff --git a/DataAccess/DTOs/Point2DDTO.cs b/DataAccess/DTOs/DTOEntities/Point2DDTO.cs similarity index 100% rename from DataAccess/DTOs/Point2DDTO.cs rename to DataAccess/DTOs/DTOEntities/Point2DDTO.cs diff --git a/DataAccess/DTOs/ProjectDTO.cs b/DataAccess/DTOs/DTOEntities/ProjectDTO.cs similarity index 100% rename from DataAccess/DTOs/ProjectDTO.cs rename to DataAccess/DTOs/DTOEntities/ProjectDTO.cs diff --git a/DataAccess/DTOs/DTOEntities/RectangleShapeDTO.cs b/DataAccess/DTOs/DTOEntities/RectangleShapeDTO.cs new file mode 100644 index 0000000..d46f87a --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/RectangleShapeDTO.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 RectangleShapeDTO : IRectangleShape + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Width")] + public double Width { get; set; } + [JsonProperty("Height")] + public double Height { get; set; } + [JsonProperty("Angle")] + public double Angle { get; set; } + + } +} diff --git a/DataAccess/DTOs/ReinforcementLibMaterialDTO.cs b/DataAccess/DTOs/DTOEntities/ReinforcementLibMaterialDTO.cs similarity index 100% rename from DataAccess/DTOs/ReinforcementLibMaterialDTO.cs rename to DataAccess/DTOs/DTOEntities/ReinforcementLibMaterialDTO.cs diff --git a/DataAccess/DTOs/TypeBinder.cs b/DataAccess/DTOs/DTOEntities/TypeBinder.cs similarity index 100% rename from DataAccess/DTOs/TypeBinder.cs rename to DataAccess/DTOs/DTOEntities/TypeBinder.cs diff --git a/DataAccess/DTOs/TypeBinderListFactory.cs b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs similarity index 91% rename from DataAccess/DTOs/TypeBinderListFactory.cs rename to DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs index 5a1d55e..34ad2e7 100644 --- a/DataAccess/DTOs/TypeBinderListFactory.cs +++ b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs @@ -36,13 +36,14 @@ namespace DataAccess.DTOs { return new List<(Type type, string name)> { - { (typeof(CirclePrimitiveDTO), "CircleNdmPrimitive") }, { (typeof(ConcreteLibMaterialDTO), "ConcreteLibMaterial") }, { (typeof(CrossSectionDTO), "CrossSection") }, { (typeof(CrossSectionNdmAnalysisDTO), "CrossSectionNdmAnalysis") }, { (typeof(CrossSectionRepositoryDTO), "CrossSectionRepository") }, { (typeof(DateVersionDTO), "DateVersion") }, + { (typeof(EllipseNdmPrimitiveDTO), "EllipseNdmPrimitive") }, { (typeof(DesignForceTupleDTO), "DesignForceTuple") }, + { (typeof(DivisionSizeDTO), "DivisionSize") }, { (typeof(ElasticMaterialDTO), "ElasticMaterial") }, { (typeof(FileVersionDTO), "FileVersion") }, { (typeof(ForceCombinationByFactorDTO), "ForceCombinationByFactor") }, @@ -51,7 +52,7 @@ namespace DataAccess.DTOs { (typeof(FRMaterialDTO), "FRMaterial") }, { (typeof(HeadMaterialDTO), "HeadMaterial") }, { (typeof(MaterialSafetyFactorDTO), "MaterialSafetyFactor") }, - { (typeof(NdmPrimitiveDTO), "NdmPrimitive") }, + { (typeof(NdmElementDTO), "NdmElement") }, { (typeof(IVisualAnalysis), "IVisualAnalysis") }, { (typeof(List), "ListOfICalculator") }, { (typeof(List), "ListOfIDateVersion") }, @@ -65,10 +66,12 @@ namespace DataAccess.DTOs { (typeof(List), "ListOfIVisualAnalysis") }, { (typeof(Point2DDTO), "Point2D") }, { (typeof(ProjectDTO), "Project") }, + { (typeof(RectangleShapeDTO), "RectangleShape") }, { (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") }, { (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") }, { (typeof(VersionProcessorDTO), "VersionProcessor") }, { (typeof(VisualAnalysisDTO), "VisualAnalysis") }, + { (typeof(VisualPropertyDTO), "VisualProperty") }, }; } } diff --git a/DataAccess/DTOs/VersionProcessorDTO.cs b/DataAccess/DTOs/DTOEntities/VersionProcessorDTO.cs similarity index 100% rename from DataAccess/DTOs/VersionProcessorDTO.cs rename to DataAccess/DTOs/DTOEntities/VersionProcessorDTO.cs diff --git a/DataAccess/DTOs/VisualAnalysisDTO.cs b/DataAccess/DTOs/DTOEntities/VisualAnalysisDTO.cs similarity index 100% rename from DataAccess/DTOs/VisualAnalysisDTO.cs rename to DataAccess/DTOs/DTOEntities/VisualAnalysisDTO.cs diff --git a/DataAccess/DTOs/DTOEntities/VisualPropertyDTO.cs b/DataAccess/DTOs/DTOEntities/VisualPropertyDTO.cs new file mode 100644 index 0000000..320fdad --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/VisualPropertyDTO.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace DataAccess.DTOs +{ + public class VisualPropertyDTO : IVisualProperty + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("IsVisible")] + public bool IsVisible { get; set; } + [JsonProperty("Color")] + public Color Color { get; set; } + [JsonProperty("SetMaterialColor")] + public bool SetMaterialColor { get; set; } + [JsonProperty("ZIndex")] + public int ZIndex { get; set; } + [JsonProperty("Opacity")] + public double Opacity { get; set; } + + } +} diff --git a/StructureHelper/Windows/MainWindow/AxisCanvases/AxisCanvasVM.cs b/StructureHelper/Windows/MainWindow/AxisCanvases/AxisCanvasVM.cs index ed20331..6c9e2f0 100644 --- a/StructureHelper/Windows/MainWindow/AxisCanvases/AxisCanvasVM.cs +++ b/StructureHelper/Windows/MainWindow/AxisCanvases/AxisCanvasVM.cs @@ -108,6 +108,8 @@ namespace StructureHelper.Windows.MainWindow } } + public Guid Id => throw new NotImplementedException(); + public AxisCanvasVM() { AxisLineThickness = 2d; diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/HasDivisionViewModel.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/HasDivisionViewModel.cs index dbd2778..d2cad19 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/HasDivisionViewModel.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/HasDivisionViewModel.cs @@ -13,6 +13,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections public class HasDivisionViewModel : ViewModelBase, IDivisionSize { private IDivisionSize primitive; + public Guid Id { get; } public double NdmMaxSize { @@ -42,6 +43,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections } } + public HasDivisionViewModel(IDivisionSize primitive) { this.primitive = primitive; diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs index d27516f..8ca44b7 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs @@ -323,6 +323,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections public double Angle { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public Guid Id => throw new NotImplementedException(); + public void AddItems(IEnumerable items) { foreach (var item in items) diff --git a/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs index 4d58b44..4d6d2c5 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs @@ -10,6 +10,11 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Infrastructures.Interfaces { + /// + /// Check parameters of strategy of converting of one class to another one + /// + /// Target type + /// Source type public class CheckConvertLogic : ICheckConvertLogic where T : ISaveable where V : ISaveable { diff --git a/StructureHelperCommon/Models/Shapes/CircleShape.cs b/StructureHelperCommon/Models/Shapes/CircleShape.cs index a48fb1f..7cc0d40 100644 --- a/StructureHelperCommon/Models/Shapes/CircleShape.cs +++ b/StructureHelperCommon/Models/Shapes/CircleShape.cs @@ -8,6 +8,17 @@ namespace StructureHelperCommon.Models.Shapes { public class CircleShape : ICircleShape { + public Guid Id { get; } public double Diameter { get; set; } + public CircleShape(Guid id) + { + Id = id; + } + + public CircleShape() : this (Guid.NewGuid()) + { + + } + } } diff --git a/StructureHelperCommon/Models/Shapes/IShape.cs b/StructureHelperCommon/Models/Shapes/IShape.cs index d916974..89bb54f 100644 --- a/StructureHelperCommon/Models/Shapes/IShape.cs +++ b/StructureHelperCommon/Models/Shapes/IShape.cs @@ -1,6 +1,8 @@ -namespace StructureHelperCommon.Models.Shapes +using StructureHelperCommon.Infrastructures.Interfaces; + +namespace StructureHelperCommon.Models.Shapes { - public interface IShape + public interface IShape : ISaveable { } } diff --git a/StructureHelperCommon/Models/Shapes/LineShape.cs b/StructureHelperCommon/Models/Shapes/LineShape.cs index 5034574..7355b51 100644 --- a/StructureHelperCommon/Models/Shapes/LineShape.cs +++ b/StructureHelperCommon/Models/Shapes/LineShape.cs @@ -1,20 +1,26 @@ -namespace StructureHelperCommon.Models.Shapes +using System; + +namespace StructureHelperCommon.Models.Shapes { /// public class LineShape : ILineShape { /// - public IPoint2D StartPoint { get; set; } + public Guid Id { get; } /// - public IPoint2D EndPoint { get; set; } + public IPoint2D StartPoint { get; set; } = new Point2D(); /// - public double Thickness { get; set; } + public IPoint2D EndPoint { get; set; } = new Point2D(); + /// + public double Thickness { get; set; } = 0d; - public LineShape() + public LineShape(Guid id) + { + Id = id; + } + + public LineShape() : this (Guid.NewGuid()) { - StartPoint = new Point2D(); - EndPoint = new Point2D(); - Thickness = 0; } } } diff --git a/StructureHelperCommon/Models/Shapes/PointShape.cs b/StructureHelperCommon/Models/Shapes/PointShape.cs index 15e0d6b..310fae8 100644 --- a/StructureHelperCommon/Models/Shapes/PointShape.cs +++ b/StructureHelperCommon/Models/Shapes/PointShape.cs @@ -1,7 +1,20 @@ -namespace StructureHelperCommon.Models.Shapes +using System; + +namespace StructureHelperCommon.Models.Shapes { public class PointShape : IPointShape { + public Guid Id { get; } public double Area { get; set; } + + public PointShape(Guid id) + { + Id = id; + } + + public PointShape() : this (Guid.NewGuid()) + { + + } } } diff --git a/StructureHelperCommon/Models/Shapes/RectangleShape.cs b/StructureHelperCommon/Models/Shapes/RectangleShape.cs index 12f0a64..b88026e 100644 --- a/StructureHelperCommon/Models/Shapes/RectangleShape.cs +++ b/StructureHelperCommon/Models/Shapes/RectangleShape.cs @@ -1,13 +1,25 @@ -namespace StructureHelperCommon.Models.Shapes +using System; + +namespace StructureHelperCommon.Models.Shapes { /// public class RectangleShape : IRectangleShape { + public Guid Id { get; } /// public double Width { get; set; } /// public double Height { get; set; } /// public double Angle { get; set; } + + public RectangleShape(Guid id) + { + Id = id; + } + public RectangleShape() : this (Guid.NewGuid()) + { + + } } } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/DivisionSize.cs b/StructureHelperLogics/NdmCalculations/Primitives/DivisionSize.cs index cc1bd12..dc1b408 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/DivisionSize.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/DivisionSize.cs @@ -9,11 +9,22 @@ namespace StructureHelperLogics.NdmCalculations.Primitives /// public class DivisionSize : IDivisionSize { + public Guid Id { get; } /// public double NdmMaxSize { get; set; } = 0.01d; /// public int NdmMinDivision { get; set; } = 10; /// public bool ClearUnderlying { get; set; } = false; + + public DivisionSize(Guid id) + { + Id = id; + } + + public DivisionSize() : this (Guid.NewGuid()) + { + + } } } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/IDivisionSize.cs b/StructureHelperLogics/NdmCalculations/Primitives/IDivisionSize.cs index 18d79ad..fa0838c 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/IDivisionSize.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/IDivisionSize.cs @@ -1,4 +1,5 @@ -using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.Primitives; using System; using System.Collections.Generic; @@ -11,7 +12,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives /// /// Include parameters of triangulation for shapes /// - public interface IDivisionSize + public interface IDivisionSize : ISaveable { /// /// Maximum size of Ndm part diff --git a/StructureHelperLogics/NdmCalculations/Primitives/INdmElement.cs b/StructureHelperLogics/NdmCalculations/Primitives/INdmElement.cs index 85ef870..df28f8b 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/INdmElement.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/INdmElement.cs @@ -24,10 +24,10 @@ namespace StructureHelperLogics.NdmCalculations.Primitives /// /// Prestrain assigned from user /// - StrainTuple UsersPrestrain { get; } + IForceTuple UsersPrestrain { get; } /// /// Prestrain assigned from calculations /// - StrainTuple AutoPrestrain { get; } + IForceTuple AutoPrestrain { get; } } } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/IVisualProperty.cs b/StructureHelperLogics/NdmCalculations/Primitives/IVisualProperty.cs index b0727f1..ae5f63b 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/IVisualProperty.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/IVisualProperty.cs @@ -1,4 +1,5 @@ -using System; +using StructureHelperCommon.Infrastructures.Interfaces; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -7,7 +8,7 @@ using System.Windows.Media; namespace StructureHelperLogics.NdmCalculations.Primitives { - public interface IVisualProperty + public interface IVisualProperty : ISaveable { /// /// Flag of visibility diff --git a/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs index c092739..738a758 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs @@ -9,7 +9,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives { public class LinePrimitive : ILinePrimitive { - public int Id { get; set; } + public Guid Id { get;} public string Name { get; set; } public double CenterX { get; set; } public double CenterY { get; set; } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/DivisionPropsUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/DivisionSizeUpdateStrategy.cs similarity index 88% rename from StructureHelperLogics/NdmCalculations/Primitives/Logics/DivisionPropsUpdateStrategy.cs rename to StructureHelperLogics/NdmCalculations/Primitives/Logics/DivisionSizeUpdateStrategy.cs index eb98e8d..e417ad6 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/Logics/DivisionPropsUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/DivisionSizeUpdateStrategy.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Primitives { - internal class DivisionPropsUpdateStrategy : IUpdateStrategy + public class DivisionSizeUpdateStrategy : IUpdateStrategy { public void Update(IDivisionSize targetObject, IDivisionSize sourceObject) { diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/EllipsePrimitiveUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/EllipsePrimitiveUpdateStrategy.cs index dc39906..2b13567 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/Logics/EllipsePrimitiveUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/EllipsePrimitiveUpdateStrategy.cs @@ -5,7 +5,7 @@ using StructureHelperCommon.Services; namespace StructureHelperLogics.NdmCalculations.Primitives { - internal class EllipsePrimitiveUpdateStrategy : IUpdateStrategy + public class EllipsePrimitiveUpdateStrategy : IUpdateStrategy { private IUpdateStrategy basePrimitiveUpdateStrategy; private IUpdateStrategy divisionPropsUpdateStrategy; @@ -22,7 +22,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives public EllipsePrimitiveUpdateStrategy() : this( new BaseUpdateStrategy(), new ShapeUpdateStrategy(), - new DivisionPropsUpdateStrategy()) + new DivisionSizeUpdateStrategy()) { } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/RectanglePrimitiveUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/RectanglePrimitiveUpdateStrategy.cs index 3002a80..3c43e59 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/Logics/RectanglePrimitiveUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/RectanglePrimitiveUpdateStrategy.cs @@ -27,7 +27,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives public RectanglePrimitiveUpdateStrategy() : this( new BaseUpdateStrategy(), new ShapeUpdateStrategy(), - new DivisionPropsUpdateStrategy()) + new DivisionSizeUpdateStrategy()) { } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/NdmElement.cs b/StructureHelperLogics/NdmCalculations/Primitives/NdmElement.cs index aa8f90f..8133135 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/NdmElement.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/NdmElement.cs @@ -22,9 +22,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives /// public bool Triangulate { get; set; } = true; /// - public StrainTuple UsersPrestrain { get; } = new(); + public IForceTuple UsersPrestrain { get; } = new StrainTuple(); /// - public StrainTuple AutoPrestrain { get; } = new(); + public IForceTuple AutoPrestrain { get; } = new StrainTuple(); public NdmElement(Guid id) { diff --git a/StructureHelperLogics/NdmCalculations/Primitives/VisualProperty.cs b/StructureHelperLogics/NdmCalculations/Primitives/VisualProperty.cs index 66635dc..524bb96 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/VisualProperty.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/VisualProperty.cs @@ -12,11 +12,15 @@ namespace StructureHelperLogics.NdmCalculations.Primitives public class VisualProperty : IVisualProperty { - public bool IsVisible { get; set; } - public Color Color { get; set; } - public bool SetMaterialColor { get; set; } - public int ZIndex { get; set; } - private double opacity; + public Guid Id { get; } + + + + public bool IsVisible { get; set; } = true; + public Color Color { get; set; } = ColorProcessor.GetRandomColor(); + public bool SetMaterialColor { get; set; } = true; + public int ZIndex { get; set; } = 0; + private double opacity = 1d; public double Opacity { @@ -28,14 +32,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives } } - - public VisualProperty() + public VisualProperty(Guid id) { - IsVisible = true; - Color = ColorProcessor.GetRandomColor(); - SetMaterialColor = true; - ZIndex = 0; - Opacity = 1; + Id = id; + } + + public VisualProperty() : this (Guid.NewGuid()) + { + } } }