From 466b47f447fc001635bccd4940c8966ffae6d1bd Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Sun, 9 Nov 2025 17:34:51 +0500 Subject: [PATCH] Add value diagram windows and view models --- .../Infrastructure/Enums/CalculatorTypes.cs | 11 +- .../UI/Resources/ButtonStyles.xaml | 10 ++ .../UI/Resources/ScrollableWorkPlane.xaml | 5 + StructureHelper/Libraries/StructureMath.dll | Bin 8192 -> 9728 bytes StructureHelper/StructureHelper.csproj.user | 6 + .../ForcesResultsViewModel.cs | 1 - ...alueDiagramCalculatorInputDataViewModel.cs | 55 +++++++ .../ValueDiagramCalculatorView.xaml | 115 ++++++++++++++ .../ValueDiagramCalculatorView.xaml.cs | 25 +++ .../ValueDiagramCalculatorViewModel.cs | 42 +++++ .../ValueDiagrams/ValueDiagramEntityView.xaml | 58 +++++++ .../ValueDiagramEntityView.xaml.cs | 20 +++ .../ValueDiagramEntityViewModel.cs | 37 +++++ .../ValueDiagrams/ValueDiagramViewModel.cs | 29 ++++ .../ValueDiagrams/ValueDiagramsViewModel.cs | 53 +++++++ .../CrossSections/AnalysisViewModelLogic.cs | 32 +++- .../CrossSections/CrossSectionView.xaml | 148 +++++++++++++----- .../CrossSections/CrossSectionViewModel.cs | 60 ++++++- .../CrossSections/PrimitiveViewModelLogic.cs | 76 ++++++++- .../Materials/MaterialsViewModel.cs | 23 ++- .../Windows/Shapes/Point2DRangeViewModel.cs | 20 +++ .../States/StateCalcTermPairViewModel.cs | 38 +++++ .../ViewModels/Forces/ActionsViewModel.cs | 42 ++--- .../Models/Shapes/IPoint2DRange.cs | 2 +- .../CircleToDxfCircleConvertStrategy.cs | 24 +++ .../Shapes/Logics/GetPointListByRange.cs | 30 ++++ .../Shapes/Logics/IGetPointListByRange.cs | 14 ++ .../Shapes/Logics/IShapeConvertStrategy.cs | 11 ++ .../LinePolygonToPolyline2DConvertStrategy.cs | 28 ++++ .../Logics/Point2DRangeUpdateStrategy.cs | 20 +++ .../RectangleToLinePolygonConvertStrategy.cs | 33 ++++ .../Logics/ShapeToDxfEntityConvertStrategy.cs | 40 +++++ .../Models/Shapes/Point2DRange.cs | 8 + .../Exports/EntitiesToDxfExportLogic.cs | 34 ++++ .../Exports/ShapesExportToDxfLogic.cs | 50 ++---- .../StructureHelperCommon.csproj | 3 + .../Logics/BeamShearRepositoryService.cs | 6 - .../CrossSections/CalculatorLogic.cs | 32 +++- .../CrossSections/RCs/SectionTemplate.cs | 9 ++ .../Logics/CalculatorUpdateStrategy.cs | 5 + .../{IValueDigram.cs => IValueDiagram.cs} | 8 +- .../ValueDiagrams/IValueDiagramCalculator.cs | 2 +- .../IValueDiagramCalculatorInputData.cs | 8 +- .../IValueDiagramCalculatorResult.cs | 2 +- .../ValueDiagrams/IValueDiagramEntity.cs | 11 ++ ...iagramCalculatorInputDataUpdateStrategy.cs | 45 ++++++ .../ValueDiagramCalculatorUpdateStrategy.cs | 26 +++ .../ValueDiagramEntityUpdateStrategy.cs | 35 +++++ .../Logics/ValueDiagramUpdateStrategy.cs | 24 +++ .../Analyses/ValueDiagrams/ValueDiagram.cs | 25 +++ .../ValueDiagrams/ValueDiagramCalculator.cs | 12 +- .../ValueDiagramCalculatorInputData.cs | 2 +- .../ValueDiagramCalculatorResult.cs | 2 +- .../ValueDiagrams/ValueDiagramEntity.cs | 24 +++ ...EntitiesToNdmPrimitivesConvertStrategy.cs} | 8 +- .../Primitives/Logics/GetPrimitivesByFile.cs | 4 +- ...mPrimitivesToDxfEntitiesConvertStrategy.cs | 65 ++++++++ .../Primitives/ShapeNdmPrimitive.cs | 1 + 58 files changed, 1397 insertions(+), 162 deletions(-) create mode 100644 StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorInputDataViewModel.cs create mode 100644 StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorView.xaml create mode 100644 StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorView.xaml.cs create mode 100644 StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorViewModel.cs create mode 100644 StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityView.xaml create mode 100644 StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityView.xaml.cs create mode 100644 StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityViewModel.cs create mode 100644 StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramViewModel.cs create mode 100644 StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramsViewModel.cs create mode 100644 StructureHelper/Windows/Shapes/Point2DRangeViewModel.cs create mode 100644 StructureHelper/Windows/UserControls/States/StateCalcTermPairViewModel.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/CircleToDxfCircleConvertStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/GetPointListByRange.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/IGetPointListByRange.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/IShapeConvertStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/LinePolygonToPolyline2DConvertStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/Point2DRangeUpdateStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/RectangleToLinePolygonConvertStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/ShapeToDxfEntityConvertStrategy.cs create mode 100644 StructureHelperCommon/Services/Exports/EntitiesToDxfExportLogic.cs rename StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/{IValueDigram.cs => IValueDiagram.cs} (59%) create mode 100644 StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramEntity.cs create mode 100644 StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorInputDataUpdateStrategy.cs create mode 100644 StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorUpdateStrategy.cs create mode 100644 StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramEntityUpdateStrategy.cs create mode 100644 StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramUpdateStrategy.cs create mode 100644 StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagram.cs create mode 100644 StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramEntity.cs rename StructureHelperLogics/NdmCalculations/Primitives/Logics/{GetPrimitivesByDxfEntities.cs => DxfEntitiesToNdmPrimitivesConvertStrategy.cs} (91%) create mode 100644 StructureHelperLogics/NdmCalculations/Primitives/Logics/NdmPrimitivesToDxfEntitiesConvertStrategy.cs diff --git a/StructureHelper/Infrastructure/Enums/CalculatorTypes.cs b/StructureHelper/Infrastructure/Enums/CalculatorTypes.cs index ac3c4bd..c47f3d8 100644 --- a/StructureHelper/Infrastructure/Enums/CalculatorTypes.cs +++ b/StructureHelper/Infrastructure/Enums/CalculatorTypes.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StructureHelper.Infrastructure.Enums +namespace StructureHelper.Infrastructure.Enums { public enum CalculatorTypes { @@ -12,6 +6,7 @@ namespace StructureHelper.Infrastructure.Enums LimitCurveCalculator, CrackCalculator, FireCalculator, - BeamShearCalculator + BeamShearCalculator, + ValueDiagram } } diff --git a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml index 2ca388d..3e7728f 100644 --- a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml @@ -888,6 +888,16 @@ + + + + + + + + + + diff --git a/StructureHelper/Infrastructure/UI/Resources/ScrollableWorkPlane.xaml b/StructureHelper/Infrastructure/UI/Resources/ScrollableWorkPlane.xaml index d99f36a..b8fe786 100644 --- a/StructureHelper/Infrastructure/UI/Resources/ScrollableWorkPlane.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/ScrollableWorkPlane.xaml @@ -36,5 +36,10 @@ + + + + + \ No newline at end of file diff --git a/StructureHelper/Libraries/StructureMath.dll b/StructureHelper/Libraries/StructureMath.dll index caf72350505fc4f15b5b5f71cfaeda3c46ccd260..e9be9dade6d0ceaaee583d05a7ab9af876f98a4d 100644 GIT binary patch literal 9728 zcmeHMeQX@pai6#M!Q+ufk<OS;UcOQ+|YhAgZ-Cw77%=HAv*dD ztMY&G?vuNOEb;0|zW94lqvafU$7uyPw43t|JQI8-c;Aze) z8vABYgc>#xWmgd?;r`~J-a*fqrg~=!-|jU+DI`DMbdPZc4uzX`8lk#W4LI{c5-o3z z(04Hmdes#d?4J~Mz zG*(MohP#48WN(cWVu?2)&Jdx5cv@;ohAfF=%x7z#B|PytzUgo@dU!O2N#Q(dd&nnZ z4|9U&1py-xFa!xS59%J62oB5$r#KRx4;a_|1p%WhUGe@2m(e$zz_rsRIAnyq{B#UV;@u7*+s66Fg2qJkjEM$^?-=dfZK*sNMp2? z*7vODsN%KcJb`jctrlFXrqFRS1aFrLxVJAzVfN#xwE!;cNB_`Bwd1Dywhyxs53pxp zfa|4p*q2~{$5qM5Y~xo9z&>=02Ltpi4B(d9DRI=f(*Vwoi#=|Qrits#M7^Onkh@}N zZDmFZJ8QHlVDd=JY}HIAbrQznnyK~2qE7@pIQX%Ovcr{H5*uBp%0~@%2ZZwpjO!Q5 zbM8)XHk}ccjm<8u@sPca@w)jcE`bY%D1>b6_;HPg?e&b;&130@ji!TvMpARJtAP8c zk?LZHrMKM(Q4@-&$ZGnjafS!jQsG=jvizAo!zRJnViZ|y53Elvuuy+J!;khTe~{sWb|;qhVGiyZ-D z(1u4I@9)EX6m%uadh+%JE2Du_hw8piUe1I4L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JR9%Y1PNW`+X(*=IoeEzo*YdZAac#wWTs^Im#;SZmz6vc$VhYE3zcOat66y14{Uzo*^rOKN14r)lDPVJj~F{vS40!w(jY*o{Cj}46d`zOvbSFN~V$0vUE>ei1xyWBP6q;BO1=dB_1>hxapuw`m7=!@T$?Vn)H8mF)*s3wSH`anIpX zZUj=kKjQy5GPV@;0AwEYIEFklf^+YUY;@w#P~~{{!Umu6m9bqoIXlZ2`)q?gXDB$! zZA4>LMg02lW^g~Y@JBeiHP{%2uUQ$*v(MwZ21h=NnfcI3;TjfSyFxx^mVK4x%M?F< zTqs8spFy5SVaq`rK|bGXo;&fDs;GAC!c0~2MD#AnX)p5VA-;L6w1wHFP-V5*t&HIu ZzYQ8D!CyeWQguGP4QBQKDZI%H{1*_jEExa* diff --git a/StructureHelper/StructureHelper.csproj.user b/StructureHelper/StructureHelper.csproj.user index b138752..b92a324 100644 --- a/StructureHelper/StructureHelper.csproj.user +++ b/StructureHelper/StructureHelper.csproj.user @@ -78,6 +78,12 @@ Code + + Code + + + Code + Code diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs index 68d14da..a3541ba 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs @@ -46,7 +46,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu private ShowProgressLogic showProgressLogic; private InteractionDiagramLogic interactionDiagramLogic; private static readonly ShowCrackResultLogic showCrackResultLogic = new(); - //private static readonly ShowCrackWidthLogic showCrackWidthLogic = new(); private IForceCalculatorResult resultModel; private IEnumerable ndmPrimitives; private IEnumerable selectedNdmPrimitives; diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorInputDataViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorInputDataViewModel.cs new file mode 100644 index 0000000..7e8dddc --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorInputDataViewModel.cs @@ -0,0 +1,55 @@ +using StructureHelper.Infrastructure; +using StructureHelper.Infrastructure.UI.DataContexts; +using StructureHelper.Windows.UserControls.States; +using StructureHelper.Windows.ViewModels; +using StructureHelperCommon.Models.Forces; +using StructureHelperLogics.Models.CrossSections; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams +{ + public class ValueDiagramCalculatorInputDataViewModel : ViewModelBase + { + private IValueDiagramCalculatorInputData inputData; + private ICrossSectionRepository repository; + + public bool CheckStrainLimit + { + get => inputData.CheckStrainLimit; + set + { + inputData.CheckStrainLimit = value; + OnPropertyChanged(nameof(CheckStrainLimit)); + } + } + public SourceTargetVM CombinationViewModel { get; } + public SourceTargetVM PrimitivesViewModel { get; } + public StateCalcTermPairViewModel StateCalcTermPairViewModel { get; } + public ValueDiagramsViewModel ValueDiagramsViewModel { get; } + + public ValueDiagramCalculatorInputDataViewModel(ICrossSectionRepository repository, IValueDiagramCalculatorInputData inputData) + { + this.inputData = inputData; + this.repository = repository; + StateCalcTermPairViewModel = new(inputData.StateTermPair); + ValueDiagramsViewModel = new(inputData.Digrams); + CombinationViewModel = SourceTargetFactory.GetSourceTargetVM(repository.ForceActions, inputData.ForceActions); + PrimitivesViewModel = SourceTargetFactory.GetSourceTargetVM(repository.Primitives, inputData.Primitives); + } + + public void Refresh() + { + var combinations = CombinationViewModel.GetTargetItems(); + inputData.ForceActions.Clear(); + foreach (var item in combinations) + { + inputData.ForceActions.Add(item); + } + inputData.Primitives.Clear(); + foreach (var item in PrimitivesViewModel.GetTargetItems()) + { + inputData.Primitives.Add(item.GetNdmPrimitive()); + } + } + } +} diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorView.xaml new file mode 100644 index 0000000..d78f738 --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorView.xaml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorView.xaml.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorView.xaml.cs new file mode 100644 index 0000000..24dcf1e --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorView.xaml.cs @@ -0,0 +1,25 @@ +using System.Windows; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams +{ + /// + /// Логика взаимодействия для ValueDiagramCalculatorView.xaml + /// + public partial class ValueDiagramCalculatorView : Window + { + private ValueDiagramCalculatorViewModel vm; + + public ValueDiagramCalculatorView(ValueDiagramCalculatorViewModel vm) + { + this.vm = vm; + vm.ParentWindow = this; + this.DataContext = this.vm; + InitializeComponent(); + } + + private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + vm.Refresh(); + } + } +} diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorViewModel.cs new file mode 100644 index 0000000..a5655eb --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramCalculatorViewModel.cs @@ -0,0 +1,42 @@ +using StructureHelper.Windows.ViewModels; +using StructureHelperLogics.Models.CrossSections; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams +{ + public class ValueDiagramCalculatorViewModel : OkCancelViewModelBase + { + private IValueDiagramCalculator valueDiagramCalculator; + + public bool ShowTraceData + { + get => valueDiagramCalculator.ShowTraceData; + set + { + valueDiagramCalculator.ShowTraceData = value; + OnPropertyChanged(nameof(ShowTraceData)); + } + } + public string Name + { + get => valueDiagramCalculator.Name; + set + { + valueDiagramCalculator.Name = value; + OnPropertyChanged(nameof(Name)); + } + } + public ValueDiagramCalculatorInputDataViewModel InputDataViewModel { get; set; } + + public ValueDiagramCalculatorViewModel(ICrossSectionRepository repository, IValueDiagramCalculator valueDiagramCalculator) + { + this.valueDiagramCalculator = valueDiagramCalculator; + InputDataViewModel = new(repository, valueDiagramCalculator.InputData); + } + + public void Refresh() + { + InputDataViewModel.Refresh(); + } + } +} diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityView.xaml new file mode 100644 index 0000000..51984fc --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityView.xaml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityView.xaml.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityView.xaml.cs new file mode 100644 index 0000000..c804e1f --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityView.xaml.cs @@ -0,0 +1,20 @@ +using System.Windows; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams +{ + /// + /// Логика взаимодействия для ValueDiagramEntityView.xaml + /// + public partial class ValueDiagramEntityView : Window + { + private readonly ValueDiagramEntityViewModel viewModel; + + public ValueDiagramEntityView(ValueDiagramEntityViewModel viewModel) + { + InitializeComponent(); + this.viewModel = viewModel; + this.DataContext = this.viewModel; + viewModel.ParentWindow = this; + } + } +} diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityViewModel.cs new file mode 100644 index 0000000..35791e3 --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramEntityViewModel.cs @@ -0,0 +1,37 @@ +using StructureHelper.Windows.ViewModels; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams +{ + public class ValueDiagramEntityViewModel : OkCancelViewModelBase + { + private IValueDiagramEntity valueDiagramEntity; + + public bool IsTaken + { + get => valueDiagramEntity.IsTaken; + set + { + valueDiagramEntity.IsTaken = value; + OnPropertyChanged(nameof(IsTaken)); + } + } + + public string Name + { + get => valueDiagramEntity.Name; + set + { + valueDiagramEntity.Name = value; + OnPropertyChanged(nameof(Name)); + } + } + + public ValueDiagramViewModel ValueDiagram { get; set; } + public ValueDiagramEntityViewModel(IValueDiagramEntity valueDiagramEntity) + { + this.valueDiagramEntity = valueDiagramEntity; + ValueDiagram = new(valueDiagramEntity.ValueDigram); + } + } +} diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramViewModel.cs new file mode 100644 index 0000000..e87da02 --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramViewModel.cs @@ -0,0 +1,29 @@ +using StructureHelper.Infrastructure; +using StructureHelper.Windows.Shapes; +using StructureHelper.Windows.ViewModels; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams +{ + public class ValueDiagramViewModel : ViewModelBase + { + private IValueDiagram valueDiagram; + + public int StepNumber + { + get => valueDiagram.StepNumber; + set + { + valueDiagram.StepNumber = value; + OnPropertyChanged(nameof(StepNumber)); + } + } + public Point2DRangeViewModel Point2DRange { get; set; } + + public ValueDiagramViewModel(IValueDiagram valueDiagram) + { + this.valueDiagram = valueDiagram; + Point2DRange = new(valueDiagram.Point2DRange); + } + } +} diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramsViewModel.cs new file mode 100644 index 0000000..78b1888 --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ValueDiagrams/ValueDiagramsViewModel.cs @@ -0,0 +1,53 @@ +using StructureHelper.Windows.ViewModels; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperLogics.Models.BeamShears; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams +{ + public class ValueDiagramsViewModel : SelectItemVM + { + private IUpdateStrategy updateStrategy; + + public override void AddMethod(object parameter) + { + NewItem = new ValueDiagramEntity(Guid.NewGuid()) + { + IsTaken = true, + Name = "New Value Diagram" + }; + NewItem.ValueDigram.StepNumber = 50; + NewItem.ValueDigram.Point2DRange.StartPoint.Y = 0.25; + NewItem.ValueDigram.Point2DRange.EndPoint.Y = - 0.25; + base.AddMethod(parameter); + } + public override void EditMethod(object parameter) + { + if (SelectedItem is null) { return; } + IValueDiagramEntity cloneDiagram = (IValueDiagramEntity)SelectedItem.Clone(); + var vm = new ValueDiagramEntityViewModel(SelectedItem); + var wnd = new ValueDiagramEntityView(vm); + wnd.ShowDialog(); + if (wnd.DialogResult != true) + { + updateStrategy ??= new ValueDiagramEntityUpdateStrategy(); + updateStrategy.Update(SelectedItem, cloneDiagram); + } + base.EditMethod(parameter); + } + public override void DeleteMethod(object parameter) + { + var dialogResult = MessageBox.Show("Delete diagram?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (dialogResult == DialogResult.Yes) + { + base.DeleteMethod(parameter); + } + } + public ValueDiagramsViewModel(List collection) : base(collection) + { + } + } +} diff --git a/StructureHelper/Windows/MainWindow/CrossSections/AnalysisViewModelLogic.cs b/StructureHelper/Windows/MainWindow/CrossSections/AnalysisViewModelLogic.cs index 6820da6..f03c72d 100644 --- a/StructureHelper/Windows/MainWindow/CrossSections/AnalysisViewModelLogic.cs +++ b/StructureHelper/Windows/MainWindow/CrossSections/AnalysisViewModelLogic.cs @@ -1,7 +1,9 @@ -using StructureHelper.Infrastructure; +using LoaderCalculator; +using StructureHelper.Infrastructure; using StructureHelper.Infrastructure.Enums; using StructureHelper.Windows.CalculationWindows.CalculatorsViews; using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews; +using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams; using StructureHelper.Windows.CalculationWindows.ProgressViews; using StructureHelper.Windows.Errors; using StructureHelper.Windows.ViewModels.Calculations.Calculators; @@ -12,7 +14,9 @@ using StructureHelperCommon.Models.Calculators; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.Logics; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; using StructureHelperLogics.NdmCalculations.Cracking; +using System; using System.Windows; using System.Windows.Forms; using MessageBox = System.Windows.Forms.MessageBox; @@ -49,12 +53,26 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections { AddCrackCalculator(); } + else if (parameterType == CalculatorTypes.ValueDiagram) + { + AddValueDiagramCalculator(); + } else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(parameterType)); } } + private void AddValueDiagramCalculator() + { + var calculator = new ValueDiagramCalculator(Guid.NewGuid()) + { + Name = "New value diagram calculator", + ShowTraceData = false, + }; + NewItem = calculator; + } + private void AddCrackCalculator() { var inputData = new CrackCalculatorInputData(); @@ -113,9 +131,21 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections if (SelectedItem is ForceCalculator forceCalculator) { EditForceCalculator(forceCalculator);} else if (SelectedItem is LimitCurvesCalculator limitCurvesCalculator) { EditLimitCurveCalculator(limitCurvesCalculator); } else if (SelectedItem is CrackCalculator crackCalculator) { EditCrackCalculator(crackCalculator);} + else if (SelectedItem is IValueDiagramCalculator valueDiagramCalculator) + { + EditValueDiagramCalculator(valueDiagramCalculator); + } else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));} } + private void EditValueDiagramCalculator(IValueDiagramCalculator sourceCalculator) + { + var calculatorClone = sourceCalculator.Clone() as IValueDiagramCalculator; + var vm = new ValueDiagramCalculatorViewModel(repository, sourceCalculator); + var wnd = new ValueDiagramCalculatorView(vm); + ShowWindow(sourceCalculator, calculatorClone, wnd); + } + private void EditCrackCalculator(CrackCalculator calculator) { var calculatorCopy = calculator.Clone() as CrackCalculator; diff --git a/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml b/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml index 00f291f..1ef32dd 100644 --- a/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml +++ b/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml @@ -15,7 +15,7 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" d:DataContext="{d:DesignInstance local:CrossSectionViewModel}" - Title="Cross-Section NDM Analysis" Height="700" Width="1100" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen"> + Title="Cross-Section NDM Analysis" Height="700" Width="1000" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen"> @@ -67,6 +67,66 @@ + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - @@ -214,8 +254,33 @@ + ItemTemplate="{StaticResource ColoredItemTemplate}"> + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -278,6 +343,13 @@ + + + + + + + diff --git a/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionViewModel.cs b/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionViewModel.cs index 1c6afe0..02553a8 100644 --- a/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionViewModel.cs +++ b/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionViewModel.cs @@ -2,6 +2,7 @@ using StructureHelper.Infrastructure; using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelper.Models.Materials; +using StructureHelper.Services.Exports; using StructureHelper.Windows.PrimitiveTemplates.RCs.Beams; using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam; using StructureHelper.Windows.ViewModels; @@ -11,6 +12,8 @@ using StructureHelper.Windows.ViewModels.Materials; using StructureHelper.Windows.ViewModels.NdmCrossSections; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Services.Exports; +using StructureHelperCommon.Services.Exports.Factories; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Templates.CrossSections.RCs; using StructureHelperLogics.Models.Templates.RCs; @@ -125,10 +128,43 @@ namespace StructureHelper.Windows.MainWindow } } + public ICommand ExportToDxfCommand => exportToDxfCommand ??= new RelayCommand(ExportToDxf); + public ICommand ImportFromDxfCommand => importFromDxfCommand ??= new RelayCommand(ImportFromDxf); + + private void ImportFromDxf(object obj) + { + SafetyProcessor.RunSafeProcess(ImportFromDxfFile, "Error of opening file"); + } + + private void ImportFromDxfFile() + { + FileIOInputData inputData = FileInputDataFactory.GetFileIOInputData(FileInputDataType.Dxf); + var logic = new GetPrimitivesByFile(); + var importService = new ImportFromFileService(inputData, logic); + importService.Import(); + var ndmPrimitives = logic.Primitives; + var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(ndmPrimitives); + repository.Primitives.AddRange(ndmPrimitives); + PrimitiveLogic.AddItems(primitives); + PrimitiveLogic.Refresh(); + } + + private void ExportToDxf(object commandParameter) + { + FileIOInputData inputData = FileInputDataFactory.GetFileIOInputData(FileInputDataType.Dxf); + var convertLogic = new NdmPrimitivesToDxfEntitiesConvertStrategy(); + var entities = convertLogic.Convert(repository.Primitives); + var logic = new EntitiesToDxfExportLogic() { Entities = entities }; + var exportService = new ExportToFileService(inputData, logic); + exportService.Export(); + } + private RelayCommand showVisualProperty; private RelayCommand selectPrimitive; private RelayCommand fileDroppedCommand; private string fileName; + private RelayCommand exportToDxfCommand; + private RelayCommand importFromDxfCommand; public ICommand FileDroppedCommand => fileDroppedCommand ??= new RelayCommand(OnFileDropped); @@ -136,15 +172,10 @@ namespace StructureHelper.Windows.MainWindow { if (obj is string[] files && files.Length > 0) { - fileName = files.First(); - string extension = Path.GetExtension(fileName).ToLowerInvariant(); - if (extension == ".dxf") + foreach (var filenameString in files) { - SafetyProcessor.RunSafeProcess(GetPrimitivesFromFile,"Error of obtaining of primitives, see detail information"); - } - else - { - System.Windows.MessageBox.Show($"Unsupported file type: {extension}"); + fileName = filenameString; + ProcessDxfFile(); } } else @@ -153,6 +184,19 @@ namespace StructureHelper.Windows.MainWindow } } + private void ProcessDxfFile() + { + string extension = Path.GetExtension(fileName).ToLowerInvariant(); + if (extension == ".dxf") + { + SafetyProcessor.RunSafeProcess(GetPrimitivesFromFile, "Error of obtaining of primitives, see detail information"); + } + else + { + System.Windows.MessageBox.Show($"Unsupported file type: {extension}"); + } + } + private void GetPrimitivesFromFile() { var importFromFileLogic = new GetPrimitivesByFile() { FileName = fileName }; diff --git a/StructureHelper/Windows/MainWindow/CrossSections/PrimitiveViewModelLogic.cs b/StructureHelper/Windows/MainWindow/CrossSections/PrimitiveViewModelLogic.cs index 6fcfcd2..e2112e3 100644 --- a/StructureHelper/Windows/MainWindow/CrossSections/PrimitiveViewModelLogic.cs +++ b/StructureHelper/Windows/MainWindow/CrossSections/PrimitiveViewModelLogic.cs @@ -9,6 +9,7 @@ using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Primitives; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Primitives; using System; @@ -34,7 +35,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections private ICommand setToFront; private ICommand setToBack; private ICommand copyToCommand; - + private RelayCommand setAsHostCommand; + private RelayCommand setMaterialToPrimitivesCommand; + private RelayCommand setHostToPrimitivesCommand; public double Width { get; set; } public double Height { get; set; } @@ -43,6 +46,72 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections public ObservableCollection Items { get; private set; } + public ICommand SetAsHostCommand => setAsHostCommand ??= new RelayCommand(SetPrimititveAsHost, + o => SelectedItem != null + && SelectedItem.NdmPrimitive is IHasDivisionSize); + + public ICommand SetHostToPrimitivesCommand => setHostToPrimitivesCommand ??= new RelayCommand(SetHostToPrimitives, + o => SelectedItem != null + && SelectedItem.NdmPrimitive is IHasHostPrimitive); + + private void SetHostToPrimitives(object obj) + { + if (SelectedItem is null) { return; } + var newHost = (SelectedItem.NdmPrimitive as IHasHostPrimitive).HostPrimitive; + SetNewHost(newHost); + } + + public ICommand SetMaterialToPrimitivesCommand => setMaterialToPrimitivesCommand ??= new RelayCommand(SetMaterialToPrimitives, + o => SelectedItem != null + && SelectedItem + .NdmPrimitive + .NdmElement + .HeadMaterial != null); + + private void SetMaterialToPrimitives(object obj) + { + if (SelectedItem is null) { return; } + var material = SelectedItem.NdmPrimitive.NdmElement.HeadMaterial; + if (material == null) { return; }; + var vm = new SelectPrimitivesViewModel(repository.Primitives); + var wnd = new SelectPrimitivesView(vm); + wnd.ShowDialog(); + if (wnd.DialogResult == true) + { + var selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive()); + foreach (var item in selectedNdmPrimitives) + { + item.NdmElement.HeadMaterial = material; + } + Refresh(); + } + } + + private void SetPrimititveAsHost(object obj) + { + if (SelectedItem is null) { return; } + var newHost = SelectedItem.NdmPrimitive; + SetNewHost(newHost); + } + + private void SetNewHost(INdmPrimitive newHost) + { + var vm = new SelectPrimitivesViewModel(repository.Primitives.Where(x => x is IHasHostPrimitive)); + var wnd = new SelectPrimitivesView(vm); + wnd.ShowDialog(); + if (wnd.DialogResult == true) + { + var selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive()); + var hasHostPrimitives = selectedNdmPrimitives.Where(x => x is IHasHostPrimitive); + foreach (var item in hasHostPrimitives) + { + IHasHostPrimitive hostPrimitive = item as IHasHostPrimitive; + hostPrimitive.HostPrimitive = newHost; + } + Refresh(); + } + } + public ICommand Add { get @@ -191,6 +260,11 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections var forceCalc = crackCalculator.InputData as IHasPrimitives; forceCalc.Primitives.Remove(ndmPrimitive); } + else if (calc is IValueDiagramCalculator diagramCalculator) + { + var forceCalc = diagramCalculator.InputData as IHasPrimitives; + forceCalc.Primitives.Remove(ndmPrimitive); + } else { throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc)); diff --git a/StructureHelper/Windows/MainWindow/Materials/MaterialsViewModel.cs b/StructureHelper/Windows/MainWindow/Materials/MaterialsViewModel.cs index 5b67892..ff310c7 100644 --- a/StructureHelper/Windows/MainWindow/Materials/MaterialsViewModel.cs +++ b/StructureHelper/Windows/MainWindow/Materials/MaterialsViewModel.cs @@ -2,9 +2,11 @@ using StructureHelper.Infrastructure.Enums; using StructureHelper.Models.Materials; using StructureHelper.Windows.MainWindow.Materials; +using StructureHelper.Windows.PrimitivePropertiesWindow; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Materials; +using StructureHelperLogics.NdmCalculations.Primitives; using System.Linq; using System.Windows.Forms; using System.Windows.Input; @@ -46,7 +48,6 @@ namespace StructureHelper.Windows.ViewModels.Materials else if (parameterType == MaterialType.CarbonFiber) { AddCarbonFiber(); } else if (parameterType == MaterialType.GlassFiber) { AddGlassFiber(); } else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)}, Actual type: {nameof(parameterType)}"); - //GlobalRepository.Materials.Create(NewItem); base.AddMethod(parameter); } public override void DeleteMethod(object parameter) @@ -133,5 +134,25 @@ namespace StructureHelper.Windows.ViewModels.Materials wnd.ShowDialog(); Refresh(); } + + private RelayCommand setMaterialToPrimititveCommand; + public ICommand SetMaterialToPrimititveCommand => setMaterialToPrimititveCommand ??= new RelayCommand(SetMaterialToPrimititve, o => SelectedItem != null); + + private void SetMaterialToPrimititve(object commandParameter) + { + if (SelectedItem is null) { return; } + var vm = new SelectPrimitivesViewModel(repository.Primitives); + var wnd = new SelectPrimitivesView(vm); + wnd.ShowDialog(); + if (wnd.DialogResult == true) + { + var selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive()); + foreach (var item in selectedNdmPrimitives) + { + item.NdmElement.HeadMaterial = SelectedItem; + } + Refresh(); + } + } } } diff --git a/StructureHelper/Windows/Shapes/Point2DRangeViewModel.cs b/StructureHelper/Windows/Shapes/Point2DRangeViewModel.cs new file mode 100644 index 0000000..2f5a70b --- /dev/null +++ b/StructureHelper/Windows/Shapes/Point2DRangeViewModel.cs @@ -0,0 +1,20 @@ +using StructureHelperCommon.Models.Shapes; + +namespace StructureHelper.Windows.Shapes +{ + public class Point2DRangeViewModel + { + private IPoint2DRange point2DRange; + public string StartPointName { get; set; } = "Start point"; + public string EndPointName { get; set; } = "End point"; + public Point2DViewModel StartPoint { get; private set; } + public Point2DViewModel EndPoint { get; private set; } + + public Point2DRangeViewModel(IPoint2DRange point2DRange) + { + this.point2DRange = point2DRange; + StartPoint = new(point2DRange.StartPoint); + EndPoint = new(point2DRange.EndPoint); + } + } +} diff --git a/StructureHelper/Windows/UserControls/States/StateCalcTermPairViewModel.cs b/StructureHelper/Windows/UserControls/States/StateCalcTermPairViewModel.cs new file mode 100644 index 0000000..484c803 --- /dev/null +++ b/StructureHelper/Windows/UserControls/States/StateCalcTermPairViewModel.cs @@ -0,0 +1,38 @@ +using StructureHelper.Infrastructure; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models.States; +using System.Collections.Generic; + +namespace StructureHelper.Windows.UserControls.States +{ + public class StateCalcTermPairViewModel : ViewModelBase + { + private IStateCalcTermPair stateCalcTermPair; + + public List LimitStatesCollection { get; set; } = [LimitStates.ULS, LimitStates.SLS]; + public List CalcTermsCollection { get; set; } = [CalcTerms.ShortTerm, CalcTerms.LongTerm]; + public LimitStates LimitState + { + get => stateCalcTermPair.LimitState; + set + { + stateCalcTermPair.LimitState = value; + OnPropertyChanged(nameof(LimitStates)); + } + } + + public CalcTerms CalcTerm + { + get => stateCalcTermPair.CalcTerm; + set + { + stateCalcTermPair.CalcTerm = value; + OnPropertyChanged(nameof(CalcTerms)); + } + } + public StateCalcTermPairViewModel(IStateCalcTermPair stateCalcTermPair) + { + this.stateCalcTermPair = stateCalcTermPair; + } + } +} diff --git a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs index 0cff04e..105c4c1 100644 --- a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs +++ b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs @@ -10,6 +10,7 @@ using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces.Logics; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; using StructureHelperLogics.NdmCalculations.Cracking; using System; using System.Collections.Generic; @@ -75,8 +76,7 @@ namespace StructureHelper.Windows.ViewModels.Forces var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { - if (DeleteAction() != true) return; - //GlobalRepository.Actions.Delete(SelectedItem.Id); + DeleteAction(); base.DeleteMethod(parameter); } } @@ -126,48 +126,36 @@ namespace StructureHelper.Windows.ViewModels.Forces this.repository = repository; } - private bool DeleteAction() + private void DeleteAction() { - bool result = true; var calcRepository = repository.Calculators; + IHasForceActions forceCombinations; foreach (var calc in calcRepository) { - if (calc is ForceCalculator forceCalculator) + if (calc is IForceCalculator forceCalculator) { - var forceCombinations = forceCalculator.InputData as IHasForceActions; - result = DeleteActionFromHost(result, calc, forceCombinations); + forceCombinations = forceCalculator.InputData; + forceCombinations.ForceActions.Remove(SelectedItem); } - else if (calc is CrackCalculator crackCalculator) + else if (calc is ICrackCalculator crackCalculator) { - var forceCombinations = crackCalculator.InputData as IHasForceActions; - result = DeleteActionFromHost(result, calc, forceCombinations); + forceCombinations = crackCalculator.InputData; + forceCombinations.ForceActions.Remove(SelectedItem); } else if (calc is ILimitCurvesCalculator) { //nothing to do } + else if (calc is IValueDiagramCalculator diagramCalculator) + { + forceCombinations = diagramCalculator.InputData; + forceCombinations.ForceActions.Remove(SelectedItem); + } else { throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc)); } } - return result; - } - - private bool DeleteActionFromHost(bool result, ICalculator item, IHasForceActions? forceCombinations) - { - var containSelected = forceCombinations.ForceActions.Contains(SelectedItem); - if (containSelected) - { - var dialogResultCalc = MessageBox.Show($"Action is contained in calculator {item.Name}", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); - if (dialogResultCalc == DialogResult.Yes) - { - forceCombinations.ForceActions.Remove(SelectedItem); - } - else result = false; - } - - return result; } } } diff --git a/StructureHelperCommon/Models/Shapes/IPoint2DRange.cs b/StructureHelperCommon/Models/Shapes/IPoint2DRange.cs index ac0deea..4a28930 100644 --- a/StructureHelperCommon/Models/Shapes/IPoint2DRange.cs +++ b/StructureHelperCommon/Models/Shapes/IPoint2DRange.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Models.Shapes { - public interface IPoint2DRange : ISaveable + public interface IPoint2DRange : ISaveable, ICloneable { IPoint2D StartPoint { get; set; } IPoint2D EndPoint { get; set; } diff --git a/StructureHelperCommon/Models/Shapes/Logics/CircleToDxfCircleConvertStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/CircleToDxfCircleConvertStrategy.cs new file mode 100644 index 0000000..8e6389d --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/CircleToDxfCircleConvertStrategy.cs @@ -0,0 +1,24 @@ +using netDxf; +using netDxf.Entities; +using StructureHelperCommon.Infrastructures.Interfaces; + +namespace StructureHelperCommon.Models.Shapes.Logics +{ + public class CircleToDxfCircleConvertStrategy : IShapeConvertStrategy + { + public double Dx { get; set; } = 0; + public double Dy { get; set; } = 0; + public double Scale { get; set; } = 1; + + public Circle Convert(ICircleShape source) + { + Vector3 center = new Vector3() { X = Dx * Scale, Y = Dy * Scale}; + Circle circle = new Circle() + { + Radius = source.Diameter / 2 * Scale, + Center = center, + }; + return circle; + } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Logics/GetPointListByRange.cs b/StructureHelperCommon/Models/Shapes/Logics/GetPointListByRange.cs new file mode 100644 index 0000000..fa6e30a --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/GetPointListByRange.cs @@ -0,0 +1,30 @@ +using netDxf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using StrMath = StructureMath.Geometry.Points; + +namespace StructureHelperCommon.Models.Shapes +{ + public class GetPointListByRange : IGetPointListByRange + { + public int StepNumber { get; set; } = 50; + + public List GetPoints(IPoint2DRange range) + { + StrMath.Point2D StartPoint2D = new(range.StartPoint.X, range.StartPoint.Y); + StrMath.Point2D EndPoint2D = new(range.EndPoint.X, range.EndPoint.Y); + StrMath.PointRange pointRange = new() { StartPoint = StartPoint2D, EndPoint = EndPoint2D }; + var logic = new StrMath.PointRangeInterpolate() { DivisionNumber = StepNumber }; + var pointList = logic.InterpolateRange(pointRange); + List result = []; + foreach (var point in pointList) + { + result.Add(new Point2D(point.X, point.Y)); + } + return result; + } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Logics/IGetPointListByRange.cs b/StructureHelperCommon/Models/Shapes/Logics/IGetPointListByRange.cs new file mode 100644 index 0000000..3eec716 --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/IGetPointListByRange.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Shapes +{ + public interface IGetPointListByRange + { + int StepNumber { get; set; } + List GetPoints(IPoint2DRange range); + } +} diff --git a/StructureHelperCommon/Models/Shapes/Logics/IShapeConvertStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/IShapeConvertStrategy.cs new file mode 100644 index 0000000..1b8d8e5 --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/IShapeConvertStrategy.cs @@ -0,0 +1,11 @@ +using StructureHelperCommon.Infrastructures.Interfaces; + +namespace StructureHelperCommon.Models.Shapes +{ + public interface IShapeConvertStrategy : IObjectConvertStrategy + { + double Dx { get; set; } + double Dy { get; set; } + double Scale { get; set; } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Logics/LinePolygonToPolyline2DConvertStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/LinePolygonToPolyline2DConvertStrategy.cs new file mode 100644 index 0000000..800ffac --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/LinePolygonToPolyline2DConvertStrategy.cs @@ -0,0 +1,28 @@ +using netDxf.Entities; +using StructureHelperCommon.Infrastructures.Interfaces; +using System.Collections.Generic; + +namespace StructureHelperCommon.Models.Shapes +{ + public class LinePolygonToPolyline2DConvertStrategy : IObjectConvertStrategy + { + public double Dx { get; set; } = 0; + public double Dy { get; set; } = 0; + public double Scale { get; set; } = 1; + + public Polyline2D Convert(ILinePolygonShape linePolygon) + { + List polylineVertices = []; + foreach (var item in linePolygon.Vertices) + { + Polyline2DVertex vertex = new Polyline2DVertex((item.Point.X + Dx) * Scale, (item.Point.Y + Dy) * Scale); + polylineVertices.Add(vertex); + } + Polyline2D polyline2D = new Polyline2D(polylineVertices) + { + IsClosed = linePolygon.IsClosed, + }; + return polyline2D; + } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Logics/Point2DRangeUpdateStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/Point2DRangeUpdateStrategy.cs new file mode 100644 index 0000000..8cd865b --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/Point2DRangeUpdateStrategy.cs @@ -0,0 +1,20 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; + +namespace StructureHelperCommon.Models.Shapes +{ + public class Point2DRangeUpdateStrategy : IUpdateStrategy + { + private IUpdateStrategy pointUpdateStrategy; + public void Update(IPoint2DRange targetObject, IPoint2DRange sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + CheckObject.IsNull(targetObject.StartPoint, ": range start point"); + pointUpdateStrategy ??= new Point2DUpdateStrategy(); + pointUpdateStrategy.Update(targetObject.StartPoint, sourceObject.StartPoint); + CheckObject.IsNull(targetObject.EndPoint, ": range end point"); + pointUpdateStrategy.Update(targetObject.EndPoint, sourceObject.EndPoint); + } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Logics/RectangleToLinePolygonConvertStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/RectangleToLinePolygonConvertStrategy.cs new file mode 100644 index 0000000..d6b0c02 --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/RectangleToLinePolygonConvertStrategy.cs @@ -0,0 +1,33 @@ +using System; + +namespace StructureHelperCommon.Models.Shapes +{ + public class RectangleToLinePolygonConvertStrategy : IShapeConvertStrategy + { + private IRectangleShape rectangle; + + public double Dx { get; set; } = 0.0; + public double Dy { get; set; } = 0.0; + public double Scale { get; set; } = 1.0; + + + public LinePolygonShape Convert(IRectangleShape source) + { + rectangle = source; + LinePolygonShape polygon = new(Guid.NewGuid()); + polygon.AddVertex(GetVertex(-1.0, 1.0)); + polygon.AddVertex(GetVertex(1.0, 1.0)); + polygon.AddVertex(GetVertex(1.0, -1.0)); + polygon.AddVertex(GetVertex(-1.0, -1.0)); + polygon.IsClosed = true; + return polygon; + } + + private Vertex GetVertex(double kx, double ky) + { + double x = (kx * rectangle.Width / 2 + Dx) * Scale; + double y = (ky * rectangle.Height / 2 + Dy) * Scale; + return new(x, y); + } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Logics/ShapeToDxfEntityConvertStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/ShapeToDxfEntityConvertStrategy.cs new file mode 100644 index 0000000..a5e495a --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/ShapeToDxfEntityConvertStrategy.cs @@ -0,0 +1,40 @@ +using netDxf.Entities; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models.Shapes.Logics; + +namespace StructureHelperCommon.Models.Shapes +{ + public class ShapeToDxfEntityConvertStrategy : IShapeConvertStrategy + { + private const string ShapeTypeIsUnknown = ": Shape is unknown"; + public double Dx { get; set; } = 0.0; + public double Dy { get; set; } = 0.0; + public double Scale { get; set; } = 1.0; + + public EntityObject Convert(IShape source) + { + if (source is IRectangleShape rectangle) + { + var retangleConvertStrategy = new RectangleToLinePolygonConvertStrategy(); + var polyline2D = Convert(retangleConvertStrategy.Convert(rectangle)); + return polyline2D; + } + else if (source is ICircleShape circle) + { + var circleConvertStrategy = new CircleToDxfCircleConvertStrategy() { Dx = Dx, Dy = Dy, Scale = Scale }; + var circleEntity = circleConvertStrategy.Convert(circle); + return circleEntity; + } + else if (source is ILinePolygonShape linePolygon) + { + var polygonConvertStrategy = new LinePolygonToPolyline2DConvertStrategy() { Dx = Dx, Dy = Dy, Scale = Scale }; + Polyline2D polyline2D = polygonConvertStrategy.Convert(linePolygon); + return polyline2D; + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ShapeTypeIsUnknown); + } + } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Point2DRange.cs b/StructureHelperCommon/Models/Shapes/Point2DRange.cs index 9cce473..210203b 100644 --- a/StructureHelperCommon/Models/Shapes/Point2DRange.cs +++ b/StructureHelperCommon/Models/Shapes/Point2DRange.cs @@ -16,5 +16,13 @@ namespace StructureHelperCommon.Models.Shapes { Id = id; } + + public object Clone() + { + Point2DRange newItem = new(Guid.NewGuid()); + var updateStrategy = new Point2DRangeUpdateStrategy(); + updateStrategy.Update(newItem, this); + return newItem; + } } } diff --git a/StructureHelperCommon/Services/Exports/EntitiesToDxfExportLogic.cs b/StructureHelperCommon/Services/Exports/EntitiesToDxfExportLogic.cs new file mode 100644 index 0000000..83897d8 --- /dev/null +++ b/StructureHelperCommon/Services/Exports/EntitiesToDxfExportLogic.cs @@ -0,0 +1,34 @@ +using netDxf; +using netDxf.Entities; +using netDxf.Tables; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Services.Exports +{ + public class EntitiesToDxfExportLogic : IExportToFileLogic + { + private const double metresToMillimeters = 1000.0; + private IGetDxfLayerLogic layerLogic = new GetDxfLayerLogic(); + public List<(EntityObject entity, LayerNames layerName)> Entities { get; set; } = []; + + public string FileName { get; set; } + + public void Export() + { + DxfDocument dxf = new DxfDocument(); + foreach (var shape in Entities) + { + Layer layer = layerLogic.GetOrCreateLayer(dxf, shape.layerName); + var entity = shape.entity; + entity.Layer = layer; + dxf.Entities.Add(entity); + } + dxf.Save(FileName); + } + } +} diff --git a/StructureHelperCommon/Services/Exports/ShapesExportToDxfLogic.cs b/StructureHelperCommon/Services/Exports/ShapesExportToDxfLogic.cs index 70d5953..83127d4 100644 --- a/StructureHelperCommon/Services/Exports/ShapesExportToDxfLogic.cs +++ b/StructureHelperCommon/Services/Exports/ShapesExportToDxfLogic.cs @@ -1,7 +1,6 @@ using netDxf; using netDxf.Entities; using netDxf.Tables; -using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models.Shapes; using System.Collections.Generic; @@ -15,19 +14,19 @@ namespace StructureHelperCommon.Services.Exports } public class ShapesExportToDxfLogic : IExportToFileLogic { - private const string ShapeTypeIsUnknown = ": Shape is unknown"; private const double metresToMillimeters = 1000.0; - private readonly List<(IShape shape, LayerNames layerName)> shapes = []; private IGetDxfLayerLogic layerLogic = new GetDxfLayerLogic(); + private IShapeConvertStrategy shapeConvertStrategy = new ShapeToDxfEntityConvertStrategy() { Scale = metresToMillimeters}; + public List<(IShape shape, LayerNames layerName)> Shapes { get; set; } = []; public ShapesExportToDxfLogic(List<(IShape shape, LayerNames layerName)> shapes) { - this.shapes.AddRange(shapes); + this.Shapes.AddRange(shapes); } public ShapesExportToDxfLogic(IShape shape, LayerNames layerName) { - shapes.Add((shape, layerName)); + Shapes.Add((shape, layerName)); } public string FileName { get; set; } @@ -35,45 +34,14 @@ namespace StructureHelperCommon.Services.Exports public void Export() { DxfDocument dxf = new DxfDocument(); - foreach (var shape in shapes) + foreach (var shape in Shapes) { - ProcessShape(dxf, shape); + Layer layer = layerLogic.GetOrCreateLayer(dxf, shape.layerName); + var entity = shapeConvertStrategy.Convert(shape.shape); + entity.Layer = layer; + dxf.Entities.Add(entity); } dxf.Save(FileName); } - - private void ProcessShape(DxfDocument dxf, (IShape shape, LayerNames layerName) shape) - { - Layer layer = layerLogic.GetOrCreateLayer(dxf, shape.layerName); - ProcessShape(dxf, shape.shape, layer); - } - - private void ProcessShape(DxfDocument dxf, IShape shape, Layer layer) - { - if (shape is ILinePolygonShape linePolygon) - { - ProcessLinePolygon(dxf, linePolygon, layer); - } - else - { - throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(shape) + ShapeTypeIsUnknown); - } - } - - private void ProcessLinePolygon(DxfDocument dxf, ILinePolygonShape linePolygon, Layer layer) - { - List polylineVertices = []; - foreach (var item in linePolygon.Vertices) - { - Polyline2DVertex vertex = new Polyline2DVertex(item.Point.X * metresToMillimeters, item.Point.Y * metresToMillimeters); - polylineVertices.Add(vertex); - } - Polyline2D polyline2D = new Polyline2D(polylineVertices) - { - Layer = layer, - IsClosed = linePolygon.IsClosed, - }; - dxf.Entities.Add(polyline2D); - } } } diff --git a/StructureHelperCommon/StructureHelperCommon.csproj b/StructureHelperCommon/StructureHelperCommon.csproj index 94c46ef..819d17b 100644 --- a/StructureHelperCommon/StructureHelperCommon.csproj +++ b/StructureHelperCommon/StructureHelperCommon.csproj @@ -19,6 +19,9 @@ ..\StructureHelper\Libraries\LoaderCalculator.dll + + ..\StructureHelper\Libraries\StructureMath.dll + diff --git a/StructureHelperLogics/Models/BeamShears/Logics/BeamShearRepositoryService.cs b/StructureHelperLogics/Models/BeamShears/Logics/BeamShearRepositoryService.cs index b48ce80..34deaa1 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/BeamShearRepositoryService.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/BeamShearRepositoryService.cs @@ -1,10 +1,4 @@ using StructureHelperCommon.Models.Forces; -using StructureHelperCommon.Models.Forces.BeamShearActions; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.Models.BeamShears { diff --git a/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs b/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs index 88e2548..752eb61 100644 --- a/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs +++ b/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs @@ -1,6 +1,7 @@ using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; using StructureHelperLogics.NdmCalculations.Cracking; namespace StructureHelperLogics.Models.Templates.CrossSections @@ -10,12 +11,36 @@ namespace StructureHelperLogics.Models.Templates.CrossSections public IEnumerable GetNdmCalculators() { var calculators = new List(); - var forceCalculator = new ForceCalculator() + ForceCalculator forceCalculator = GetForceCalculator(); + calculators.Add(forceCalculator); + CrackCalculator crackCalculator = GetCrackCalculator(); + calculators.Add(crackCalculator); + ValueDiagramCalculator diagramCalculator = GetDiagramCalculator(); + calculators.Add(diagramCalculator); + return calculators; + } + + private ValueDiagramCalculator GetDiagramCalculator() + { + ValueDiagramCalculator diagramCalculator = new(Guid.NewGuid()) { Name = "New value diagram calcualtor"}; + ValueDiagramEntity diagramEntity = new(Guid.NewGuid()) { Name = "New diagram" }; + diagramEntity.ValueDigram.Point2DRange.StartPoint.Y = 0.25; + diagramEntity.ValueDigram.Point2DRange.EndPoint.Y = - 0.25; + diagramCalculator.InputData.Digrams.Add(diagramEntity); + return diagramCalculator; + } + + private static ForceCalculator GetForceCalculator() + { + return new ForceCalculator() { Name = "New Force Calculator", TraceLogger = new ShiftTraceLogger() }; - calculators.Add(forceCalculator); + } + + private static CrackCalculator GetCrackCalculator() + { var newInputData = new CrackCalculatorInputData(); var checkLogic = new CheckCrackCalculatorInputDataLogic { @@ -28,8 +53,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections TraceLogger = new ShiftTraceLogger() }; crackCalculator.InputData = newInputData; - calculators.Add(crackCalculator); - return calculators; + return crackCalculator; } } } diff --git a/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs b/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs index 0a7291b..6220977 100644 --- a/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs +++ b/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs @@ -5,6 +5,7 @@ using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Templates.RCs; using StructureHelperLogics.NdmCalculations.Analyses; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Primitives; using System; @@ -67,6 +68,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs { crackCalculator.InputData.ForceActions.AddRange(combinations); } + if (calculator is IValueDiagramCalculator diagramCalculator) + { + diagramCalculator.InputData.ForceActions.AddRange(combinations); + } } } private void AddAllPrimitivesToCalculator() @@ -81,6 +86,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs { crackCalculator.InputData.Primitives.AddRange(primitives); } + if (calculator is IValueDiagramCalculator diagramCalculator) + { + diagramCalculator.InputData.Primitives.AddRange(primitives); + } } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs index c8850df..14d5ae7 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs @@ -5,6 +5,7 @@ using StructureHelperCommon.Services; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Primitives; using System; @@ -33,6 +34,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Logics { new CrackCalculatorUpdateStrategy().Update(crackCalculator, (CrackCalculator)sourceObject); } + else if (targetObject is IValueDiagramCalculator diagramCalculator) + { + new ValueDiagramCalculatorUpdateStrategy().Update(diagramCalculator, (IValueDiagramCalculator)sourceObject); + } else { ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(INdmPrimitive), sourceObject.GetType()); diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDigram.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagram.cs similarity index 59% rename from StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDigram.cs rename to StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagram.cs index c784fd9..66c5ef3 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDigram.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagram.cs @@ -1,15 +1,11 @@ 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.NdmCalculations.Analyses.ValueDiagrams { - public interface IValueDigram : ISaveable + public interface IValueDiagram : ISaveable, ICloneable { IPoint2DRange Point2DRange { get; } + public int StepNumber { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculator.cs index 0d6d258..1c861b4 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculator.cs @@ -9,6 +9,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams { public interface IValueDiagramCalculator : ICalculator { - + IValueDiagramCalculatorInputData InputData { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorInputData.cs index cdf2b79..1155d8f 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorInputData.cs @@ -1,5 +1,5 @@ -using StructureHelperCommon.Infrastructures.Enums; -using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.States; using StructureHelperLogics.NdmCalculations.Primitives; @@ -8,13 +8,13 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams /// /// Implements input data for Value diagram calculator /// - public interface IValueDiagramCalculatorInputData : ISaveable, IHasForceActions, IHasPrimitives + public interface IValueDiagramCalculatorInputData : ISaveable, IInputData, IHasForceActions, IHasPrimitives { IStateCalcTermPair StateTermPair { get; set; } /// /// Collection of diagram for calculation /// - List Digrams { get; } + List Digrams { get; } bool CheckStrainLimit { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorResult.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorResult.cs index 9678551..819f370 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorResult.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorResult.cs @@ -8,6 +8,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams { IValueDiagramCalculatorInputData? InputData { get; set; } List Points { get; set; } - List ForceTupleResults { get; set; } + List ForceTupleResults { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramEntity.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramEntity.cs new file mode 100644 index 0000000..3c5aa89 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramEntity.cs @@ -0,0 +1,11 @@ +using StructureHelperCommon.Infrastructures.Interfaces; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public interface IValueDiagramEntity : ISaveable, ICloneable + { + string Name { get; set; } + bool IsTaken { get; set; } + IValueDiagram ValueDigram { get; set; } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorInputDataUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorInputDataUpdateStrategy.cs new file mode 100644 index 0000000..8bfeb61 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorInputDataUpdateStrategy.cs @@ -0,0 +1,45 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public class ValueDiagramCalculatorInputDataUpdateStrategy : IParentUpdateStrategy + { + private IUpdateStrategy entityUpdateStrategy; + + public ValueDiagramCalculatorInputDataUpdateStrategy(IUpdateStrategy entityUpdateStrategy) + { + this.entityUpdateStrategy = entityUpdateStrategy; + } + + public ValueDiagramCalculatorInputDataUpdateStrategy() + { + + } + + public bool UpdateChildren { get; set; } = true; + + public void Update(IValueDiagramCalculatorInputData targetObject, IValueDiagramCalculatorInputData sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.CheckStrainLimit = sourceObject.CheckStrainLimit; + targetObject.StateTermPair.LimitState = sourceObject.StateTermPair.LimitState; + targetObject.StateTermPair.CalcTerm = sourceObject.StateTermPair.CalcTerm; + if (UpdateChildren == true) + { + targetObject.Primitives.Clear(); + targetObject.Primitives.AddRange(sourceObject.Primitives); + targetObject.ForceActions.Clear(); + targetObject.ForceActions.AddRange(sourceObject.ForceActions); + targetObject.Digrams.Clear(); + entityUpdateStrategy ??= new ValueDiagramEntityUpdateStrategy(); + foreach (var entity in sourceObject.Digrams) + { + var newItem = entity.Clone() as IValueDiagramEntity; + targetObject.Digrams.Add(newItem); + } + } + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorUpdateStrategy.cs new file mode 100644 index 0000000..1c853ed --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorUpdateStrategy.cs @@ -0,0 +1,26 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public class ValueDiagramCalculatorUpdateStrategy : IParentUpdateStrategy + { + private IUpdateStrategy inputDataUpdateStrategy; + public bool UpdateChildren { get; set; } = true; + + public void Update(IValueDiagramCalculator targetObject, IValueDiagramCalculator sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.Name = sourceObject.Name; + targetObject.ShowTraceData = sourceObject.ShowTraceData; + if (UpdateChildren == true) + { + CheckObject.IsNull(targetObject.InputData, ": target value diagram calculator input data"); + CheckObject.IsNull(sourceObject.InputData, ": source value diagram calculator input data"); + inputDataUpdateStrategy ??= new ValueDiagramCalculatorInputDataUpdateStrategy(); + inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData); + } + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramEntityUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramEntityUpdateStrategy.cs new file mode 100644 index 0000000..c46ea1a --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramEntityUpdateStrategy.cs @@ -0,0 +1,35 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public class ValueDiagramEntityUpdateStrategy : IParentUpdateStrategy + { + private IUpdateStrategy valueDiagramUpdateStrategy; + + public ValueDiagramEntityUpdateStrategy(IUpdateStrategy valueDiagramUpdateStrategy) + { + this.valueDiagramUpdateStrategy = valueDiagramUpdateStrategy; + } + + public ValueDiagramEntityUpdateStrategy() + { + + } + + public bool UpdateChildren { get; set; } = true; + + public void Update(IValueDiagramEntity targetObject, IValueDiagramEntity sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.IsTaken = sourceObject.IsTaken; + targetObject.Name = sourceObject.Name; + if (UpdateChildren == true) + { + valueDiagramUpdateStrategy ??= new ValueDiagramUpdateStrategy(); + valueDiagramUpdateStrategy.Update(targetObject.ValueDigram, sourceObject.ValueDigram); + } + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramUpdateStrategy.cs new file mode 100644 index 0000000..8534d78 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramUpdateStrategy.cs @@ -0,0 +1,24 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Services; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + internal class ValueDiagramUpdateStrategy : IParentUpdateStrategy + { + private IUpdateStrategy rangeUpdateStrategy; + public bool UpdateChildren { get; set; } = true; + + public void Update(IValueDiagram targetObject, IValueDiagram sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.StepNumber = sourceObject.StepNumber; + if (UpdateChildren == true) + { + rangeUpdateStrategy ??= new Point2DRangeUpdateStrategy(); + rangeUpdateStrategy.Update(targetObject.Point2DRange, sourceObject.Point2DRange); + } + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagram.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagram.cs new file mode 100644 index 0000000..7f3ed6d --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagram.cs @@ -0,0 +1,25 @@ +using StructureHelperCommon.Models.Shapes; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public class ValueDiagram : IValueDiagram + { + public Guid Id { get; } + public int StepNumber { get; set; } = 50; + public IPoint2DRange Point2DRange { get; } = new Point2DRange(Guid.NewGuid()); + + + public ValueDiagram(Guid id) + { + Id = id; + } + + public object Clone() + { + ValueDiagram newItem = new(Guid.NewGuid()); + var updateStrategy = new ValueDiagramUpdateStrategy(); + updateStrategy.Update(newItem, this); + return newItem; + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculator.cs index c71ecfe..45a9d77 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculator.cs @@ -11,14 +11,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams { public class ValueDiagramCalculator : IValueDiagramCalculator { + private IValueDiagramCalculatorResult result; + + public Guid Id { get; } public string Name { get; set; } public bool ShowTraceData { get; set; } - public IResult Result => throw new NotImplementedException(); + public IResult Result => result; public IShiftTraceLogger? TraceLogger { get; set; } - public Guid Id { get; } + public IValueDiagramCalculatorInputData InputData { get; set; } = new ValueDiagramCalculatorInputData(Guid.NewGuid()); public ValueDiagramCalculator(Guid id) { @@ -27,7 +30,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams public object Clone() { - throw new NotImplementedException(); + ValueDiagramCalculator newItem = new ValueDiagramCalculator(Guid.NewGuid()); + var updateLogic = new ValueDiagramCalculatorUpdateStrategy(); + updateLogic.Update(newItem, this); + return newItem; } public void Run() diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorInputData.cs index 1abea78..3282409 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorInputData.cs @@ -17,7 +17,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams public Guid Id { get; } /// - public List Digrams { get; } = []; + public List Digrams { get; } = []; /// public List ForceActions { get; } = []; /// diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorResult.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorResult.cs index 4c579cc..2b2b433 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorResult.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorResult.cs @@ -9,7 +9,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams public List Points { get; set; } = []; - public List ForceTupleResults { get; set; } = []; + public List ForceTupleResults { get; set; } = []; public bool IsValid { get; set; } = true; public string? Description { get; set; } = string.Empty; diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramEntity.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramEntity.cs new file mode 100644 index 0000000..b71c676 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramEntity.cs @@ -0,0 +1,24 @@ +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public class ValueDiagramEntity : IValueDiagramEntity + { + public Guid Id { get; } + public string Name { get; set; } = string.Empty; + public bool IsTaken { get; set; } = true; + + public IValueDiagram ValueDigram { get; set; } = new ValueDiagram(Guid.NewGuid()); + + public ValueDiagramEntity(Guid id) + { + Id = id; + } + + public object Clone() + { + ValueDiagramEntity newItem = new ValueDiagramEntity(Guid.NewGuid()); + var updateStrategy = new ValueDiagramEntityUpdateStrategy(); + updateStrategy.Update(newItem, this); + return newItem; + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/GetPrimitivesByDxfEntities.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/DxfEntitiesToNdmPrimitivesConvertStrategy.cs similarity index 91% rename from StructureHelperLogics/NdmCalculations/Primitives/Logics/GetPrimitivesByDxfEntities.cs rename to StructureHelperLogics/NdmCalculations/Primitives/Logics/DxfEntitiesToNdmPrimitivesConvertStrategy.cs index 01f21f6..6277a25 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/Logics/GetPrimitivesByDxfEntities.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/DxfEntitiesToNdmPrimitivesConvertStrategy.cs @@ -1,14 +1,11 @@ -using netDxf; -using netDxf.Entities; -using StructureHelperCommon.Infrastructures.Exceptions; +using netDxf.Entities; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Exports; -using System.Runtime.CompilerServices; namespace StructureHelperLogics.NdmCalculations.Primitives { - public class GetPrimitivesByDxfEntities : IObjectConvertStrategy, IEnumerable> + public class DxfEntitiesToNdmPrimitivesConvertStrategy : IObjectConvertStrategy, IEnumerable> { private const double metresToMillimeters = 1000.0; private List primitives = []; @@ -68,7 +65,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives primitive = ellipse; } primitive.Center = new Point2D(circle.Center.X / metresToMillimeters, circle.Center.Y / metresToMillimeters); - return primitive; } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/GetPrimitivesByFile.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/GetPrimitivesByFile.cs index 6bd2458..fa794e5 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/Logics/GetPrimitivesByFile.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/GetPrimitivesByFile.cs @@ -2,7 +2,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives { - public class GetPrimitivesByFile : IGetPrimitivesLogic + public class GetPrimitivesByFile : IImportFromFileLogic { private List primitives = []; @@ -16,7 +16,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives importEntitiesLogic.Import(); if (importEntitiesLogic.Entities.Count != 0) { - var primitivesLogic = new GetPrimitivesByDxfEntities(); + var primitivesLogic = new DxfEntitiesToNdmPrimitivesConvertStrategy(); primitives = primitivesLogic.Convert(importEntitiesLogic.Entities); } } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/NdmPrimitivesToDxfEntitiesConvertStrategy.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/NdmPrimitivesToDxfEntitiesConvertStrategy.cs new file mode 100644 index 0000000..0e1f54b --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/NdmPrimitivesToDxfEntitiesConvertStrategy.cs @@ -0,0 +1,65 @@ +using netDxf.Entities; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Services.Exports; + +namespace StructureHelperLogics.NdmCalculations.Primitives +{ + public class NdmPrimitivesToDxfEntitiesConvertStrategy : IObjectConvertStrategy, IEnumerable> + { + private const double metresToMillimeters = 1000.0; + private List<(EntityObject, LayerNames)> entities = []; + private IShapeConvertStrategy shapeConvertStrategy = new ShapeToDxfEntityConvertStrategy() { Scale = metresToMillimeters }; + + + public List<(EntityObject, LayerNames)> Convert(IEnumerable source) + { + entities.Clear(); + foreach (var ndmPrimitive in source) + { + shapeConvertStrategy.Dx = ndmPrimitive.Center.X; + shapeConvertStrategy.Dy = ndmPrimitive.Center.Y; + if (ndmPrimitive is IRectangleNdmPrimitive rectangleNdmPrimitive) + { + var rectangle = shapeConvertStrategy.Convert(rectangleNdmPrimitive); + entities.Add((rectangle, LayerNames.StructiralPrimitives)); + } + else if (ndmPrimitive is IShapeNdmPrimitive shapeNdmPrimitive) + { + var polygon = shapeConvertStrategy.Convert(shapeNdmPrimitive.Shape); + entities.Add((polygon, LayerNames.StructiralPrimitives)); + } + else if (ndmPrimitive is IEllipseNdmPrimitive ellipseNdmPrimitive) + { + CircleShape circleShape = new CircleShape() { Diameter = ellipseNdmPrimitive.Width}; + var circle = shapeConvertStrategy.Convert(circleShape); + entities.Add((circle, LayerNames.StructiralPrimitives)); + } + else if (ndmPrimitive is IRebarNdmPrimitive rebar) + { + LayerNames layerName = LayerNames.StructuralRebars; + convertPoint(rebar, layerName); + } + else if (ndmPrimitive is IPointNdmPrimitive point) + { + LayerNames layerName = LayerNames.StructiralPrimitives; + convertPoint(point, layerName); + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(ndmPrimitive)); + } + } + return entities; + } + + private void convertPoint(IPointNdmPrimitive point, LayerNames layerName) + { + double diameter = Math.Sqrt(point.Area / Math.PI * 4.0); + CircleShape circleShape = new CircleShape() { Diameter = diameter }; + var circle = shapeConvertStrategy.Convert(circleShape); + entities.Add((circle, layerName)); + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Primitives/ShapeNdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/ShapeNdmPrimitive.cs index 84aa9ea..7edcc53 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/ShapeNdmPrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/ShapeNdmPrimitive.cs @@ -77,6 +77,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives if (shape is ILinePolygonShape polygon) { var newShape = PolygonGeometryUtils.GetTransfromedPolygon(polygon, Center.X, Center.Y); + newShape.IsClosed = true; var calculator = new PolygonCalculator(); return calculator.ContainsPoint(newShape, point); }