From 2f6c35482be670b007e64064ec08e312858d844a Mon Sep 17 00:00:00 2001 From: RedikultsevEvg Date: Thu, 7 Aug 2025 22:42:46 +0500 Subject: [PATCH] Add inclined section visualization --- .../BeamShearSectionFromDTOConvertStrategy.cs | 4 + .../BeamShearSectionToDTOConvertStrategy.cs | 4 + .../HasVisualPropertyToDTOUpdateStrategy.cs | 1 + .../BeamShears/BeamShearSectionDTO.cs | 7 + .../BeamShears/StirrupByRebarDTO.cs | 2 +- StructureHelper/App.xaml | 1 + .../BeamShearSectionPrimitive.cs | 38 +++ .../IGraphicalPrimitive.cs | 15 + .../InclinedSectionPrimitive.cs | 39 +++ .../UI/Resources/BeamShearTemplate.xaml | 117 ++++++++ .../UI/Resources/ButtonStyles.xaml | 9 + StructureHelper/StructureHelper.csproj.user | 15 + .../BeamShears/BeamShearActionResultView.xaml | 10 + .../BeamShearActionResultViewModel.cs | 8 + .../BeamShears/BeamShearResultView.xaml | 10 + .../BeamShears/BeamShearResultViewModel.cs | 18 +- .../BeamShears/InclinedSectionViewerView.xaml | 14 + .../InclinedSectionViewerView.xaml.cs | 35 +++ .../InclinedSectionViewerViewModel.cs | 34 +++ ...ResultToGraphicalPrimitivesConvertLogic.cs | 20 ++ .../Windows/BeamShears/SectionView.xaml | 4 + .../Windows/BeamShears/SectionViewModel.cs | 17 +- .../BeamShears/StirrupByDensityView.xaml | 4 + .../BeamShears/StirrupByDensityViewModel.cs | 17 +- .../StirrupByInclinedRebarViewModel.cs | 14 +- .../StirrupByInclinedReebarView.xaml | 3 + .../BeamShears/StirrupByRebarView.xaml | 4 + .../BeamShears/StirrupByRebarViewModel.cs | 19 +- .../Graphs/FrameWorkElementServiseLogic.cs | 10 +- .../Graphs/IFrameWorkElementServiseLogic.cs | 4 +- .../Windows/MainWindow/CrossSectionView.xaml | 1 - .../UserControls/PrimitiveVisualProperty.xaml | 48 ++++ .../PrimitiveVisualProperty.xaml.cs | 32 +++ .../PrimitiveVisualPropertyViewModel.cs | 69 +++++ .../Windows/UserControls/WorkPlane.xaml | 263 ++++++++++-------- .../Windows/UserControls/WorkPlane.xaml.cs | 16 +- .../UserControls/WorkPlanes/AxisLayer.xaml | 28 ++ .../UserControls/WorkPlanes/AxisLayer.xaml.cs | 56 ++++ .../UserControls/WorkPlanes/GridLayer.xaml | 30 ++ .../UserControls/WorkPlanes/GridLayer.xaml.cs | 65 +++++ .../PrimitiveCollectionViewModel.cs | 17 ++ .../WorkPlanes/PrimitiveTemplateSelector.cs | 30 ++ .../WorkPlanes/WorkPlaneConfigViewModel.cs | 124 +++++++++ .../WorkPlanes/WorkPlaneRoot.xaml | 92 ++++++ .../WorkPlanes/WorkPlaneRoot.xaml.cs | 79 ++++++ .../WorkPlanes/WorkPlaneRootViewModel.cs | 15 + .../Interfaces/IObjectConvertStrategy.cs | 13 + .../PrimitiveVisualProperty.cs | 4 +- .../Models/BeamShears/BeamShearSection.cs | 7 + .../Models/BeamShears/IBeamShearSection.cs | 3 +- .../Logics/StirrupByDensityStrengthLogic.cs | 10 + .../Logics/StirrupByRebarStrengthLogic.cs | 10 + .../Models/BeamShears/StirrupByDensity.cs | 2 +- .../BeamShears/StirrupByInclinedRebar.cs | 2 +- .../Models/BeamShears/StirrupByRebar.cs | 2 +- .../Analyses/ExportFrameWorkElementLogic.cs | 27 +- 56 files changed, 1392 insertions(+), 150 deletions(-) create mode 100644 StructureHelper/Infrastructure/UI/GraphicalPrimitives/BeamShearSectionPrimitive.cs create mode 100644 StructureHelper/Infrastructure/UI/GraphicalPrimitives/IGraphicalPrimitive.cs create mode 100644 StructureHelper/Infrastructure/UI/GraphicalPrimitives/InclinedSectionPrimitive.cs create mode 100644 StructureHelper/Infrastructure/UI/Resources/BeamShearTemplate.xaml create mode 100644 StructureHelper/Windows/BeamShears/InclinedSectionViewerView.xaml create mode 100644 StructureHelper/Windows/BeamShears/InclinedSectionViewerView.xaml.cs create mode 100644 StructureHelper/Windows/BeamShears/InclinedSectionViewerViewModel.cs create mode 100644 StructureHelper/Windows/BeamShears/SectionResultToGraphicalPrimitivesConvertLogic.cs create mode 100644 StructureHelper/Windows/UserControls/PrimitiveVisualProperty.xaml create mode 100644 StructureHelper/Windows/UserControls/PrimitiveVisualProperty.xaml.cs create mode 100644 StructureHelper/Windows/UserControls/PrimitiveVisualPropertyViewModel.cs create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/AxisLayer.xaml create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/AxisLayer.xaml.cs create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/GridLayer.xaml create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/GridLayer.xaml.cs create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/PrimitiveCollectionViewModel.cs create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/PrimitiveTemplateSelector.cs create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneConfigViewModel.cs create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRoot.xaml create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRoot.xaml.cs create mode 100644 StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRootViewModel.cs create mode 100644 StructureHelperCommon/Infrastructures/Interfaces/IObjectConvertStrategy.cs diff --git a/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionFromDTOConvertStrategy.cs index 7353ae9..106f0d7 100644 --- a/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionFromDTOConvertStrategy.cs @@ -3,6 +3,7 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Materials; using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.VisualProperties; using StructureHelperLogics.Models.BeamShears; using StructureHelperLogics.Models.Materials; @@ -15,6 +16,7 @@ namespace DataAccess.DTOs private IConvertStrategy concreteConvertStrategy; private IConvertStrategy reinforcementConvertStrategy; private IUpdateStrategy safetyFactorUpdateStrategy; + private IUpdateStrategy visualUpdateStrategy; public BeamShearSectionFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger) @@ -38,6 +40,7 @@ namespace DataAccess.DTOs throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ReinforcementMaterial)); } NewItem.ReinforcementMaterial = reinforcementConvertStrategy.Convert(reinforcement); + visualUpdateStrategy.Update(NewItem, source); return NewItem; } @@ -57,6 +60,7 @@ namespace DataAccess.DTOs TraceLogger = TraceLogger }; safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorsFromDTOLogic()); + visualUpdateStrategy = new HasVisualPropertyFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger); } } } diff --git a/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionToDTOConvertStrategy.cs index 1df95bd..3cfb1c1 100644 --- a/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionToDTOConvertStrategy.cs @@ -2,6 +2,7 @@ using StructureHelperCommon.Models; using StructureHelperCommon.Models.Materials; using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.VisualProperties; using StructureHelperLogics.Models.BeamShears; using StructureHelperLogics.Models.Materials; @@ -14,6 +15,7 @@ namespace DataAccess.DTOs private IConvertStrategy concreteConvertStrategy; private ReinforcementLibMaterialToDTOConvertStrategy reinforcementConvertStrategy; private IUpdateStrategy safetyFactorUpdateStrategy; + private IUpdateStrategy visualUpdateStrategy; public BeamShearSectionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger) @@ -46,6 +48,7 @@ namespace DataAccess.DTOs NewItem.ReinforcementMaterial = reinforcementConvertStrategy.Convert(source.ReinforcementMaterial); safetyFactorUpdateStrategy.Update(NewItem.ReinforcementMaterial, source.ReinforcementMaterial); TraceLogger?.AddMessage($"Beam shear section converting Id = {NewItem.Id} has been finished succesfully", TraceLogStatuses.Debug); + visualUpdateStrategy.Update(NewItem, source); } private void InitializeStrategies() @@ -62,6 +65,7 @@ namespace DataAccess.DTOs TraceLogger = TraceLogger }; safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic()); + visualUpdateStrategy = new HasVisualPropertyToDTOUpdateStrategy(ReferenceDictionary, TraceLogger); } } } diff --git a/DataAccess/DTOs/Converters/HasVisualPropertyToDTOUpdateStrategy.cs b/DataAccess/DTOs/Converters/HasVisualPropertyToDTOUpdateStrategy.cs index 663d320..263ff86 100644 --- a/DataAccess/DTOs/Converters/HasVisualPropertyToDTOUpdateStrategy.cs +++ b/DataAccess/DTOs/Converters/HasVisualPropertyToDTOUpdateStrategy.cs @@ -11,6 +11,7 @@ namespace DataAccess.DTOs private IShiftTraceLogger traceLogger; private IConvertStrategy convertStrategy; + public HasVisualPropertyToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) { this.referenceDictionary = referenceDictionary; diff --git a/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearSectionDTO.cs b/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearSectionDTO.cs index e1c6a78..4f40a86 100644 --- a/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearSectionDTO.cs +++ b/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearSectionDTO.cs @@ -1,7 +1,9 @@ using Newtonsoft.Json; using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.VisualProperties; using StructureHelperLogics.Models.BeamShears; using StructureHelperLogics.Models.Materials; +using System.Windows.Media; //Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia //All rights reserved. @@ -24,10 +26,15 @@ namespace DataAccess.DTOs public double ReinforcementArea { get; set; } [JsonProperty("ReinforcementMaterial")] public IReinforcementLibMaterial ReinforcementMaterial { get; set; } = new ReinforcementLibMaterial(Guid.NewGuid()); + public IPrimitiveVisualProperty VisualProperty { get; set; } public BeamShearSectionDTO(Guid id) { Id = id; + VisualProperty = new PrimitiveVisualPropertyDTO(Guid.NewGuid()) + { + Color = (Color)ColorConverter.ConvertFromString("DarkGray") + }; } public object Clone() diff --git a/DataAccess/DTOs/DTOEntities/BeamShears/StirrupByRebarDTO.cs b/DataAccess/DTOs/DTOEntities/BeamShears/StirrupByRebarDTO.cs index 1501b39..9d3dcf3 100644 --- a/DataAccess/DTOs/DTOEntities/BeamShears/StirrupByRebarDTO.cs +++ b/DataAccess/DTOs/DTOEntities/BeamShears/StirrupByRebarDTO.cs @@ -36,7 +36,7 @@ namespace DataAccess.DTOs Id = id; VisualProperty = new PrimitiveVisualPropertyDTO(Guid.NewGuid()) { - Color = (Color)ColorConverter.ConvertFromString("Black") + Color = (Color)ColorConverter.ConvertFromString("Brown") }; } diff --git a/StructureHelper/App.xaml b/StructureHelper/App.xaml index 1da3fb5..5ba44ad 100644 --- a/StructureHelper/App.xaml +++ b/StructureHelper/App.xaml @@ -23,6 +23,7 @@ + diff --git a/StructureHelper/Infrastructure/UI/GraphicalPrimitives/BeamShearSectionPrimitive.cs b/StructureHelper/Infrastructure/UI/GraphicalPrimitives/BeamShearSectionPrimitive.cs new file mode 100644 index 0000000..3200c44 --- /dev/null +++ b/StructureHelper/Infrastructure/UI/GraphicalPrimitives/BeamShearSectionPrimitive.cs @@ -0,0 +1,38 @@ +using StructureHelperCommon.Models.VisualProperties; +using StructureHelperLogics.Models.BeamShears; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives +{ + public class BeamShearSectionPrimitive : IGraphicalPrimitive + { + private IBeamShearSection beamShearSection; + private IInclinedSection inclinedSection; + + + public double CenterX { get; set; } = 0; + public double CenterY { get; set; } = 0; + public double FullDepth => inclinedSection.FullDepth; + public double EffectiveDepth => inclinedSection.EffectiveDepth; + public double BottomCover => FullDepth - EffectiveDepth; + public double PositiveLength => inclinedSection.EffectiveDepth * 3.5; + public double NegativeLength { get; set; } = -0.1; + public double SupportHeight { get; set; } = 0.1; + public double SupportWidth { get; set; } = 0.2; + public double SupportStartX => -SupportWidth / 2; + public double SupportStartY => -SupportHeight; + public string SupportPathData => $"M 0 0 L {SupportWidth / 2} {-SupportHeight} L {-SupportWidth / 2} {-SupportHeight} Z"; + + public IPrimitiveVisualProperty VisualProperty => beamShearSection.VisualProperty; + + public BeamShearSectionPrimitive(IBeamShearSection beamShearSection, IInclinedSection inclinedSection) + { + this.beamShearSection = beamShearSection; + this.inclinedSection = inclinedSection; + } + } +} diff --git a/StructureHelper/Infrastructure/UI/GraphicalPrimitives/IGraphicalPrimitive.cs b/StructureHelper/Infrastructure/UI/GraphicalPrimitives/IGraphicalPrimitive.cs new file mode 100644 index 0000000..87beba5 --- /dev/null +++ b/StructureHelper/Infrastructure/UI/GraphicalPrimitives/IGraphicalPrimitive.cs @@ -0,0 +1,15 @@ +using FieldVisualizer.Entities.Values.Primitives; +using StructureHelperCommon.Models.VisualProperties; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives +{ + public interface IGraphicalPrimitive : ICenter + { + IPrimitiveVisualProperty VisualProperty { get; } + } +} diff --git a/StructureHelper/Infrastructure/UI/GraphicalPrimitives/InclinedSectionPrimitive.cs b/StructureHelper/Infrastructure/UI/GraphicalPrimitives/InclinedSectionPrimitive.cs new file mode 100644 index 0000000..1cc4884 --- /dev/null +++ b/StructureHelper/Infrastructure/UI/GraphicalPrimitives/InclinedSectionPrimitive.cs @@ -0,0 +1,39 @@ +using StructureHelperCommon.Models.VisualProperties; +using StructureHelperLogics.Models.BeamShears; +using System; +using System.Windows.Media; + +namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives +{ + public class InclinedSectionPrimitive : IGraphicalPrimitive + { + private IBeamShearSectionLogicResult source; + private IInclinedSection inclinedSection => source.InputData.InclinedSection; + + public double SectionStartX => inclinedSection.StartCoord; + public double SectionEndX => inclinedSection.EndCoord; + public double SectionStartY => inclinedSection.FullDepth - inclinedSection.EffectiveDepth; + public double SectionEndY => inclinedSection.FullDepth; + public double FactorOfUsing => source.FactorOfUsing; + public double EffectiveDepth => inclinedSection.EffectiveDepth; + public double SpanRatio => (inclinedSection.EndCoord - inclinedSection.StartCoord) / inclinedSection.EffectiveDepth; + + public double CenterX => 0; + public double CenterY => 0; + public IPrimitiveVisualProperty VisualProperty { get; private set; } = new PrimitiveVisualProperty(Guid.Empty); + + public InclinedSectionPrimitive(IBeamShearSectionLogicResult source) + { + this.source = source; + if (source.FactorOfUsing >= 1) + { + VisualProperty.Color = (Color)ColorConverter.ConvertFromString("Red"); + } + else + { + VisualProperty.Color = (Color)ColorConverter.ConvertFromString("Green"); + } + } + + } +} diff --git a/StructureHelper/Infrastructure/UI/Resources/BeamShearTemplate.xaml b/StructureHelper/Infrastructure/UI/Resources/BeamShearTemplate.xaml new file mode 100644 index 0000000..a317762 --- /dev/null +++ b/StructureHelper/Infrastructure/UI/Resources/BeamShearTemplate.xaml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml index c89fc8c..47afc7f 100644 --- a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml @@ -170,6 +170,15 @@ + + + + + + + + + diff --git a/StructureHelper/StructureHelper.csproj.user b/StructureHelper/StructureHelper.csproj.user index 9769907..fc2ed95 100644 --- a/StructureHelper/StructureHelper.csproj.user +++ b/StructureHelper/StructureHelper.csproj.user @@ -33,6 +33,9 @@ Code + + Code + Code @@ -144,9 +147,21 @@ Code + + Code + Code + + Code + + + Code + + + Code + diff --git a/StructureHelper/Windows/BeamShears/BeamShearActionResultView.xaml b/StructureHelper/Windows/BeamShears/BeamShearActionResultView.xaml index 2587146..093208e 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearActionResultView.xaml +++ b/StructureHelper/Windows/BeamShears/BeamShearActionResultView.xaml @@ -31,6 +31,16 @@ + diff --git a/StructureHelper/Windows/BeamShears/BeamShearActionResultViewModel.cs b/StructureHelper/Windows/BeamShears/BeamShearActionResultViewModel.cs index 1eb7803..1ad3b16 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearActionResultViewModel.cs +++ b/StructureHelper/Windows/BeamShears/BeamShearActionResultViewModel.cs @@ -12,6 +12,7 @@ namespace StructureHelper.Windows.BeamShears private IBeamShearActionResult result; private RelayCommand showTraceCommand; private RelayCommand showDiagramCommand; + private RelayCommand showGraphResultsCommand; public IBeamShearSectionLogicResult SelectedResult { get; set; } public List SectionResults => result.SectionResults; @@ -25,6 +26,13 @@ namespace StructureHelper.Windows.BeamShears public ICommand ShowTraceCommand => showTraceCommand ??= new RelayCommand(ShowTrace, o => SelectedResult != null); public ICommand ShowDiagramCommand => showDiagramCommand ??= new RelayCommand(Show2DDiagram, o => SelectedResult != null); + public ICommand ShowGraphResultsCommand => showGraphResultsCommand ??= new RelayCommand(ShowGraphResults, o => SelectedResult != null); + + private void ShowGraphResults(object obj) + { + var window = new InclinedSectionViewerView(SelectedResult); + window.ShowDialog(); + } private void ShowTrace(object obj) { diff --git a/StructureHelper/Windows/BeamShears/BeamShearResultView.xaml b/StructureHelper/Windows/BeamShears/BeamShearResultView.xaml index 13e7dc0..f867636 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearResultView.xaml +++ b/StructureHelper/Windows/BeamShears/BeamShearResultView.xaml @@ -41,6 +41,16 @@ + diff --git a/StructureHelper/Windows/BeamShears/BeamShearResultViewModel.cs b/StructureHelper/Windows/BeamShears/BeamShearResultViewModel.cs index f645c02..ec2c943 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearResultViewModel.cs +++ b/StructureHelper/Windows/BeamShears/BeamShearResultViewModel.cs @@ -2,9 +2,8 @@ using StructureHelper.Services.Exports; using StructureHelper.Windows.CalculationWindows.CalculatorsViews; using StructureHelperLogics.Models.BeamShears; -using StructureHelperLogics.NdmCalculations.Analyses; -using System; using System.Collections.Generic; +using System.Linq; using System.Windows; using System.Windows.Input; @@ -16,6 +15,7 @@ namespace StructureHelper.Windows.BeamShears private RelayCommand showSectionResultsCommand; private RelayCommand showDiagramCommand; private RelayCommand exportToExcelCommand; + private RelayCommand showGraphResultsCommand; public IBeamShearActionResult SelectedResult { get; set; } public List ActionResults => result.ActionResults; @@ -28,8 +28,22 @@ namespace StructureHelper.Windows.BeamShears } public ICommand ShowSectionResultsCommand => showSectionResultsCommand ??= new RelayCommand(ShowSectionResults, o=>SelectedResult != null); + + public ICommand ShowDiagramCommand => showDiagramCommand ??= new RelayCommand(Show2DDiagram, o=>SelectedResult != null); public ICommand ExportToExcelCommand => exportToExcelCommand ??= new RelayCommand(ExportToExcel, o=>SelectedResult != null); + public ICommand ShowGraphResultsCommand => showGraphResultsCommand ??= new RelayCommand(ShowGraphResults, o => SelectedResult != null); + + private void ShowGraphResults(object obj) + { + if (SelectedResult is null) {return; } + if (SelectedResult.SectionResults is null) {return; } + var sectionResult = SelectedResult.SectionResults + .OrderByDescending(x => x.FactorOfUsing) + .FirstOrDefault(); + var window = new InclinedSectionViewerView(sectionResult); + window.ShowDialog(); + } private void ExportToExcel(object obj) { diff --git a/StructureHelper/Windows/BeamShears/InclinedSectionViewerView.xaml b/StructureHelper/Windows/BeamShears/InclinedSectionViewerView.xaml new file mode 100644 index 0000000..706a8b5 --- /dev/null +++ b/StructureHelper/Windows/BeamShears/InclinedSectionViewerView.xaml @@ -0,0 +1,14 @@ + + + + + diff --git a/StructureHelper/Windows/BeamShears/InclinedSectionViewerView.xaml.cs b/StructureHelper/Windows/BeamShears/InclinedSectionViewerView.xaml.cs new file mode 100644 index 0000000..0aacba6 --- /dev/null +++ b/StructureHelper/Windows/BeamShears/InclinedSectionViewerView.xaml.cs @@ -0,0 +1,35 @@ +using StructureHelperLogics.Models.BeamShears; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace StructureHelper.Windows.BeamShears +{ + /// + /// Логика взаимодействия для InclinedSectionViewerView.xaml + /// + public partial class InclinedSectionViewerView : Window + { + private InclinedSectionViewerViewModel viewModel; + public InclinedSectionViewerView(InclinedSectionViewerViewModel viewModel) + { + InitializeComponent(); + this.viewModel = viewModel; + this.DataContext = this.viewModel; + } + public InclinedSectionViewerView(IBeamShearSectionLogicResult sectionResult) : this(new InclinedSectionViewerViewModel(sectionResult)) + { + + } + } +} diff --git a/StructureHelper/Windows/BeamShears/InclinedSectionViewerViewModel.cs b/StructureHelper/Windows/BeamShears/InclinedSectionViewerViewModel.cs new file mode 100644 index 0000000..9a35dbf --- /dev/null +++ b/StructureHelper/Windows/BeamShears/InclinedSectionViewerViewModel.cs @@ -0,0 +1,34 @@ +using StructureHelper.Infrastructure; +using StructureHelper.Infrastructure.UI.GraphicalPrimitives; +using StructureHelper.Windows.UserControls.WorkPlanes; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperLogics.Models.BeamShears; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Windows.BeamShears +{ + public class InclinedSectionViewerViewModel : ViewModelBase + { + private IBeamShearSectionLogicResult sectionResult; + private IObjectConvertStrategy, IBeamShearSectionLogicResult> logic; + + public WorkPlaneRootViewModel WorkPlaneRoot { get; private set; } + + public InclinedSectionViewerViewModel(IBeamShearSectionLogicResult sectionResult) + { + this.sectionResult = sectionResult; + WorkPlaneRoot = new(); + logic = new SectionResultToGraphicalPrimitivesConvertLogic(); + var primitives = logic.Convert(sectionResult); + primitives.ForEach(primitive => + { + WorkPlaneRoot.PrimitiveCollection.Primitives.Add(primitive); + }); + + } + } +} diff --git a/StructureHelper/Windows/BeamShears/SectionResultToGraphicalPrimitivesConvertLogic.cs b/StructureHelper/Windows/BeamShears/SectionResultToGraphicalPrimitivesConvertLogic.cs new file mode 100644 index 0000000..2b2bedd --- /dev/null +++ b/StructureHelper/Windows/BeamShears/SectionResultToGraphicalPrimitivesConvertLogic.cs @@ -0,0 +1,20 @@ +using StructureHelper.Infrastructure.UI.GraphicalPrimitives; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperLogics.Models.BeamShears; +using System.Collections.Generic; + +namespace StructureHelper.Windows.BeamShears +{ + public class SectionResultToGraphicalPrimitivesConvertLogic : IObjectConvertStrategy, IBeamShearSectionLogicResult> + { + public List Convert(IBeamShearSectionLogicResult source) + { + List graphicalPrimitives = new List(); + BeamShearSectionPrimitive beamShearSectionPrimitive = new(source.InputData.InclinedSection.BeamShearSection, source.InputData.InclinedSection); + graphicalPrimitives.Add(beamShearSectionPrimitive); + InclinedSectionPrimitive inclinedSectionPrimitive = new(source); + graphicalPrimitives.Add((inclinedSectionPrimitive)); + return graphicalPrimitives; + } + } +} diff --git a/StructureHelper/Windows/BeamShears/SectionView.xaml b/StructureHelper/Windows/BeamShears/SectionView.xaml index 32332ca..943824e 100644 --- a/StructureHelper/Windows/BeamShears/SectionView.xaml +++ b/StructureHelper/Windows/BeamShears/SectionView.xaml @@ -4,6 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:StructureHelper.Windows.BeamShears" + xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" d:DataContext="{d:DesignInstance local:SectionViewModel}" mc:Ignorable="d" Title="Beam shear section" Height="400" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> @@ -55,6 +56,9 @@ + + + diff --git a/StructureHelper/Windows/BeamShears/SectionViewModel.cs b/StructureHelper/Windows/BeamShears/SectionViewModel.cs index 4e4becd..f528884 100644 --- a/StructureHelper/Windows/BeamShears/SectionViewModel.cs +++ b/StructureHelper/Windows/BeamShears/SectionViewModel.cs @@ -1,8 +1,10 @@ -using StructureHelper.Windows.ViewModels; +using StructureHelper.Windows.UserControls; +using StructureHelper.Windows.ViewModels; using StructureHelper.Windows.ViewModels.Materials; using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.BeamShears; using System; +using System.Windows.Media; //Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia //All rights reserved. @@ -12,6 +14,7 @@ namespace StructureHelper.Windows.BeamShears public class SectionViewModel : OkCancelViewModelBase { private readonly IBeamShearSection beamShearSection; + private PrimitiveVisualPropertyViewModel visual; public string Name { @@ -41,6 +44,17 @@ namespace StructureHelper.Windows.BeamShears beamShearSection.CenterCover = value; } } + + public PrimitiveVisualPropertyViewModel VisualProperty + { + get => visual; + private set + { + visual = value; + OnPropertyChanged(nameof(VisualProperty)); + } + } + public IShape Shape { get; } public ConcreteViewModel ConcreteMaterial { get; } public ReinforcementViewModel ReinforcementMaterial { get; } @@ -57,6 +71,7 @@ namespace StructureHelper.Windows.BeamShears }; Shape = beamShearSection.Shape; ReinforcementMaterial = new(beamShearSection.ReinforcementMaterial) { MaterialLogicVisibility = false }; + VisualProperty = new(this.beamShearSection.VisualProperty); } } } diff --git a/StructureHelper/Windows/BeamShears/StirrupByDensityView.xaml b/StructureHelper/Windows/BeamShears/StirrupByDensityView.xaml index 4ac48dc..23a4590 100644 --- a/StructureHelper/Windows/BeamShears/StirrupByDensityView.xaml +++ b/StructureHelper/Windows/BeamShears/StirrupByDensityView.xaml @@ -4,6 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:StructureHelper.Windows.BeamShears" + xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" d:DataContext="{d:DesignInstance local:StirrupByDensityViewModel}" mc:Ignorable="d" Title="Stirrups by uniform density" Height="200" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> @@ -47,6 +48,9 @@ + + + diff --git a/StructureHelper/Windows/BeamShears/StirrupByDensityViewModel.cs b/StructureHelper/Windows/BeamShears/StirrupByDensityViewModel.cs index d2e4a23..c7ac93c 100644 --- a/StructureHelper/Windows/BeamShears/StirrupByDensityViewModel.cs +++ b/StructureHelper/Windows/BeamShears/StirrupByDensityViewModel.cs @@ -1,12 +1,16 @@ -using StructureHelper.Windows.ViewModels; +using StructureHelper.Windows.UserControls; +using StructureHelper.Windows.ViewModels; using StructureHelperLogics.Models.BeamShears; using System.ComponentModel; +using System.Windows.Media; namespace StructureHelper.Windows.BeamShears { public class StirrupByDensityViewModel : OkCancelViewModelBase, IDataErrorInfo { private readonly IStirrupByDensity stirrupByDensity; + private PrimitiveVisualPropertyViewModel visual; + public double MinDensity { get; set; } = 0; public string Name @@ -50,6 +54,16 @@ namespace StructureHelper.Windows.BeamShears } } + public PrimitiveVisualPropertyViewModel VisualProperty + { + get => visual; + private set + { + visual = value; + OnPropertyChanged(nameof(VisualProperty)); + } + } + public string Error => null; public string this[string columnName] @@ -71,6 +85,7 @@ namespace StructureHelper.Windows.BeamShears public StirrupByDensityViewModel(IStirrupByDensity stirrupByDensity) { this.stirrupByDensity = stirrupByDensity; + VisualProperty = new(this.stirrupByDensity.VisualProperty); } } } diff --git a/StructureHelper/Windows/BeamShears/StirrupByInclinedRebarViewModel.cs b/StructureHelper/Windows/BeamShears/StirrupByInclinedRebarViewModel.cs index e30a67b..5a88c86 100644 --- a/StructureHelper/Windows/BeamShears/StirrupByInclinedRebarViewModel.cs +++ b/StructureHelper/Windows/BeamShears/StirrupByInclinedRebarViewModel.cs @@ -1,6 +1,8 @@ using StructureHelper.Windows.MainWindow.Materials; +using StructureHelper.Windows.UserControls; using StructureHelper.Windows.ViewModels; using StructureHelperLogics.Models.BeamShears; +using System.Windows.Media; namespace StructureHelper.Windows.BeamShears { @@ -8,7 +10,7 @@ namespace StructureHelper.Windows.BeamShears { private const double minTransferLengthValue = 0.01; private readonly IStirrupByInclinedRebar stirrupByInclinedRebar; - + private PrimitiveVisualPropertyViewModel visual; public string Name { @@ -73,6 +75,15 @@ namespace StructureHelper.Windows.BeamShears } public RebarSectionViewModel RebarSectionViewModel {get;} + public PrimitiveVisualPropertyViewModel VisualProperty + { + get => visual; + private set + { + visual = value; + OnPropertyChanged(nameof(VisualProperty)); + } + } public StirrupByInclinedRebarViewModel(IStirrupByInclinedRebar stirrupByInclinedRebar) { @@ -82,6 +93,7 @@ namespace StructureHelper.Windows.BeamShears MinRebarDiameter = 0.003, MaxRebarDiameter = 0.032 }; + VisualProperty = new(this.stirrupByInclinedRebar.VisualProperty); } } } diff --git a/StructureHelper/Windows/BeamShears/StirrupByInclinedReebarView.xaml b/StructureHelper/Windows/BeamShears/StirrupByInclinedReebarView.xaml index d21756d..b7ad395 100644 --- a/StructureHelper/Windows/BeamShears/StirrupByInclinedReebarView.xaml +++ b/StructureHelper/Windows/BeamShears/StirrupByInclinedReebarView.xaml @@ -53,6 +53,9 @@ + + + diff --git a/StructureHelper/Windows/BeamShears/StirrupByRebarView.xaml b/StructureHelper/Windows/BeamShears/StirrupByRebarView.xaml index d48c2a0..99c73b1 100644 --- a/StructureHelper/Windows/BeamShears/StirrupByRebarView.xaml +++ b/StructureHelper/Windows/BeamShears/StirrupByRebarView.xaml @@ -4,6 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:StructureHelper.Windows.BeamShears" + xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" d:DataContext="{d:DesignInstance local:StirrupByRebarViewModel}" mc:Ignorable="d" Title="Stirrup by uniformly distributed rebars" Height="350" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> @@ -61,6 +62,9 @@ + + + diff --git a/StructureHelper/Windows/BeamShears/StirrupByRebarViewModel.cs b/StructureHelper/Windows/BeamShears/StirrupByRebarViewModel.cs index a4218ec..64d74fa 100644 --- a/StructureHelper/Windows/BeamShears/StirrupByRebarViewModel.cs +++ b/StructureHelper/Windows/BeamShears/StirrupByRebarViewModel.cs @@ -1,6 +1,9 @@ -using StructureHelper.Windows.ViewModels; +using StructureHelper.Windows.UserControls; +using StructureHelper.Windows.ViewModels; using StructureHelper.Windows.ViewModels.Materials; +using StructureHelperCommon.Models.VisualProperties; using StructureHelperLogics.Models.BeamShears; +using System; using System.ComponentModel; namespace StructureHelper.Windows.BeamShears @@ -8,6 +11,8 @@ namespace StructureHelper.Windows.BeamShears public class StirrupByRebarViewModel : OkCancelViewModelBase, IDataErrorInfo { private readonly IStirrupByRebar stirrupByRebar; + private PrimitiveVisualPropertyViewModel visual; + private PrimitiveVisualPropertyViewModel visual2; public string Name { @@ -92,6 +97,17 @@ namespace StructureHelper.Windows.BeamShears } } + public PrimitiveVisualPropertyViewModel VisualProperty + { + get => visual; + private set + { + visual = value; + OnPropertyChanged(nameof(VisualProperty)); + } + } + + public ReinforcementViewModel Material { get; private set; } public string Error => null; @@ -151,6 +167,7 @@ namespace StructureHelper.Windows.BeamShears { this.stirrupByRebar = stirrupByRebar; Material = new(this.stirrupByRebar.Material) { MaterialLogicVisibility = false}; + VisualProperty = new(this.stirrupByRebar.VisualProperty); } } } diff --git a/StructureHelper/Windows/Graphs/FrameWorkElementServiseLogic.cs b/StructureHelper/Windows/Graphs/FrameWorkElementServiseLogic.cs index ecd2a6b..4480a28 100644 --- a/StructureHelper/Windows/Graphs/FrameWorkElementServiseLogic.cs +++ b/StructureHelper/Windows/Graphs/FrameWorkElementServiseLogic.cs @@ -13,19 +13,19 @@ namespace StructureHelper.Windows.Graphs { public class FrameWorkElementServiseLogic : IFrameWorkElementServiseLogic { - public void SaveImageToFile(FrameworkElement element) + public void SaveImageToFile(FrameworkElement element, double scaleFactor = 1) { var inputData = new ExportToFileInputData { Filter = "png |*.png", Title = "Save in *.png File" }; - var logic = new ExportFrameWorkElementLogic(element); + var logic = new ExportFrameWorkElementLogic(element, scaleFactor); var exportService = new ExportToFileService(inputData, logic); exportService.Export(); } - public void CopyImageToClipboard(FrameworkElement element) + public void CopyImageToClipboard(FrameworkElement element, double scaleFactor = 1) { if (element == null) return; @@ -35,8 +35,8 @@ namespace StructureHelper.Windows.Graphs // Render the element to a RenderTargetBitmap var renderTarget = new RenderTargetBitmap( - (int)element.ActualWidth, - (int)element.ActualHeight, + (int)(element.ActualWidth * scaleFactor), + (int)(element.ActualHeight * scaleFactor), 96, // DPI X 96, // DPI Y PixelFormats.Pbgra32); diff --git a/StructureHelper/Windows/Graphs/IFrameWorkElementServiseLogic.cs b/StructureHelper/Windows/Graphs/IFrameWorkElementServiseLogic.cs index 4089485..eb75fe1 100644 --- a/StructureHelper/Windows/Graphs/IFrameWorkElementServiseLogic.cs +++ b/StructureHelper/Windows/Graphs/IFrameWorkElementServiseLogic.cs @@ -4,7 +4,7 @@ namespace StructureHelper.Windows.Graphs { public interface IFrameWorkElementServiseLogic { - void CopyImageToClipboard(FrameworkElement element); - void SaveImageToFile(FrameworkElement element); + void CopyImageToClipboard(FrameworkElement element, double scaleFactor = 1); + void SaveImageToFile(FrameworkElement element, double scaleFactor = 1); } } \ No newline at end of file diff --git a/StructureHelper/Windows/MainWindow/CrossSectionView.xaml b/StructureHelper/Windows/MainWindow/CrossSectionView.xaml index db4096c..d154112 100644 --- a/StructureHelper/Windows/MainWindow/CrossSectionView.xaml +++ b/StructureHelper/Windows/MainWindow/CrossSectionView.xaml @@ -287,7 +287,6 @@ - diff --git a/StructureHelper/Windows/UserControls/PrimitiveVisualProperty.xaml b/StructureHelper/Windows/UserControls/PrimitiveVisualProperty.xaml new file mode 100644 index 0000000..3d29bf6 --- /dev/null +++ b/StructureHelper/Windows/UserControls/PrimitiveVisualProperty.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - - - - - + Height="{Binding Height}" + > + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - + + + - - + - - - - - + + + + + - - - - - + + + + - - - - - + + + + - - + - - - - - + + + + - - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + - + diff --git a/StructureHelper/Windows/UserControls/WorkPlane.xaml.cs b/StructureHelper/Windows/UserControls/WorkPlane.xaml.cs index 72c8df4..e5eaba0 100644 --- a/StructureHelper/Windows/UserControls/WorkPlane.xaml.cs +++ b/StructureHelper/Windows/UserControls/WorkPlane.xaml.cs @@ -1,4 +1,6 @@ -using StructureHelper.Infrastructure.UI.DataContexts; +using StructureHelper.Infrastructure; +using StructureHelper.Infrastructure.UI.DataContexts; +using StructureHelper.Windows.Graphs; using StructureHelper.Windows.MainWindow; using StructureHelper.Windows.ViewModels.Materials; using System; @@ -23,7 +25,9 @@ namespace StructureHelper.Windows.UserControls /// public partial class WorkPlane : UserControl { - + private IFrameWorkElementServiseLogic frameWorkElementServiseLogic = new FrameWorkElementServiseLogic(); + private RelayCommand saveImageCommand; + private RelayCommand copyToClipboardCommand; public CrossSectionViewModel ViewModel { @@ -35,7 +39,15 @@ namespace StructureHelper.Windows.UserControls public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register(nameof(ViewModel), typeof(CrossSectionViewModel), typeof(WorkPlane), new PropertyMetadata(null)); + public ICommand SaveAsImageCommand + { + get => saveImageCommand ??= new RelayCommand(o => frameWorkElementServiseLogic.SaveImageToFile(WorkPlaneGrid)); + } + public ICommand CopyToClipboardCommand + { + get => copyToClipboardCommand ??= new RelayCommand(o => frameWorkElementServiseLogic.CopyImageToClipboard(WorkPlaneGrid)); + } public WorkPlane() { diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/AxisLayer.xaml b/StructureHelper/Windows/UserControls/WorkPlanes/AxisLayer.xaml new file mode 100644 index 0000000..33b6121 --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/AxisLayer.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/AxisLayer.xaml.cs b/StructureHelper/Windows/UserControls/WorkPlanes/AxisLayer.xaml.cs new file mode 100644 index 0000000..ea2d42e --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/AxisLayer.xaml.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace StructureHelper.Windows.UserControls.WorkPlanes +{ + /// + /// Логика взаимодействия для AxisLayer.xaml + /// + public partial class AxisLayer : UserControl + { + public AxisLayer() + { + InitializeComponent(); + } + + public double HalfOfWidth => Width / 2; + public double HalfOfHeight => Height / 2; + + public Brush XAxisColorBrush + { + get => (Brush)GetValue(XAxisColorBrushProperty); + set => SetValue(XAxisColorBrushProperty, value); + } + public static readonly DependencyProperty XAxisColorBrushProperty = + DependencyProperty.Register(nameof(XAxisColorBrush), typeof(Brush), typeof(AxisLayer), new PropertyMetadata(Brushes.Black)); + + public Brush YAxisColorBrush + { + get => (Brush)GetValue(YAxisColorBrushProperty); + set => SetValue(YAxisColorBrushProperty, value); + } + public static readonly DependencyProperty YAxisColorBrushProperty = + DependencyProperty.Register(nameof(YAxisColorBrush), typeof(Brush), typeof(AxisLayer), new PropertyMetadata(Brushes.Black)); + + public double AxisLineThickness + { + get => (double)GetValue(AxisLineThicknessProperty); + set => SetValue(AxisLineThicknessProperty, value); + } + public static readonly DependencyProperty AxisLineThicknessProperty = + DependencyProperty.Register(nameof(AxisLineThickness), typeof(double), typeof(AxisLayer), new PropertyMetadata(1.0)); + } + +} diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/GridLayer.xaml b/StructureHelper/Windows/UserControls/WorkPlanes/GridLayer.xaml new file mode 100644 index 0000000..9523471 --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/GridLayer.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/GridLayer.xaml.cs b/StructureHelper/Windows/UserControls/WorkPlanes/GridLayer.xaml.cs new file mode 100644 index 0000000..f0bf7a2 --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/GridLayer.xaml.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace StructureHelper.Windows.UserControls.WorkPlanes +{ + /// + /// Логика взаимодействия для Gridlayer.xaml + /// + public partial class GridLayer : UserControl + { + public GridLayer() + { + InitializeComponent(); + } + + public static readonly DependencyProperty GridSizeProperty = + DependencyProperty.Register(nameof(GridSize), typeof(double), typeof(GridLayer), new PropertyMetadata(10.0)); + + public double GridSize + { + get => (double)GetValue(GridSizeProperty); + set => SetValue(GridSizeProperty, value); + } + + public static readonly DependencyProperty GridColorBrushProperty = + DependencyProperty.Register(nameof(GridColorBrush), typeof(Brush), typeof(GridLayer), new PropertyMetadata(Brushes.LightGray)); + + public Brush GridColorBrush + { + get => (Brush)GetValue(GridColorBrushProperty); + set => SetValue(GridColorBrushProperty, value); + } + + public static readonly DependencyProperty GridLineThicknessProperty = + DependencyProperty.Register(nameof(GridLineThickness), typeof(double), typeof(GridLayer), new PropertyMetadata(0.5)); + + public double GridLineThickness + { + get => (double)GetValue(GridLineThicknessProperty); + set => SetValue(GridLineThicknessProperty, value); + } + + public static readonly DependencyProperty CanvasViewportSizeProperty = + DependencyProperty.Register(nameof(CanvasViewportSize), typeof(Rect), typeof(GridLayer), new PropertyMetadata(new Rect(0, 0, 20, 20))); + + public Rect CanvasViewportSize + { + get => (Rect)GetValue(CanvasViewportSizeProperty); + set => SetValue(CanvasViewportSizeProperty, value); + } + } + +} diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/PrimitiveCollectionViewModel.cs b/StructureHelper/Windows/UserControls/WorkPlanes/PrimitiveCollectionViewModel.cs new file mode 100644 index 0000000..8b4cf30 --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/PrimitiveCollectionViewModel.cs @@ -0,0 +1,17 @@ +using StructureHelper.Infrastructure; +using StructureHelper.Infrastructure.UI.GraphicalPrimitives; +using StructureHelperLogics.Models.Primitives; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Windows.UserControls.WorkPlanes +{ + public class PrimitiveCollectionViewModel : ViewModelBase + { + public ObservableCollection Primitives { get; } = new(); + } +} diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/PrimitiveTemplateSelector.cs b/StructureHelper/Windows/UserControls/WorkPlanes/PrimitiveTemplateSelector.cs new file mode 100644 index 0000000..327eb6a --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/PrimitiveTemplateSelector.cs @@ -0,0 +1,30 @@ +using FieldVisualizer.Entities.Values.Primitives; +using StructureHelper.Infrastructure.UI.GraphicalPrimitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace StructureHelper.Windows.UserControls.WorkPlanes +{ + public class PrimitiveTemplateSelector : DataTemplateSelector + { + public DataTemplate BeamShearSectionTemplate { get; set; } + public DataTemplate InclinedSectionTemplate { get; set; } + public DataTemplate BeamShearStirrupByRebarTemplate { get; set; } + + public override DataTemplate SelectTemplate(object item, DependencyObject container) + { + return item switch + { + BeamShearSectionPrimitive => BeamShearSectionTemplate, + InclinedSectionPrimitive => InclinedSectionTemplate, + _ => base.SelectTemplate(item, container) + }; + } + } + +} diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneConfigViewModel.cs b/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneConfigViewModel.cs new file mode 100644 index 0000000..f2e185f --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneConfigViewModel.cs @@ -0,0 +1,124 @@ +using StructureHelper.Infrastructure; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; + +namespace StructureHelper.Windows.UserControls.WorkPlanes +{ + public class WorkPlaneConfigViewModel : ViewModelBase + { + private double zoomCenterX; + private double zoomCenterY; + private double scaleValue = 200; + private double canvasWidth = 3; + private double canvasHeight = 3; + private double axisFontSize = 14; + private double axisLineThickness = 2; + + public double CanvasWidth + { + get => canvasWidth; + set + { + canvasWidth = value; + Refresh(); + } + } + public double CanvasHeight + { + get => canvasHeight; + set + { + canvasHeight = value; + Refresh(); + } + } + public double ScaleValue + { + get => scaleValue; + set + { + scaleValue = value; + Refresh(); + } + } + + public double NegativeScaleValue + { + get => scaleValue * (-1); + } + + public double ZoomCenterX + { + get => zoomCenterX; + set + { + zoomCenterX = value; + Refresh(); + } + } + public double ZoomCenterY + { + get => zoomCenterY; + set + { + zoomCenterY = value; + Refresh(); + } + } + + private void Refresh() + { + OnPropertyChanged(nameof(CanvasWidth)); + OnPropertyChanged(nameof(CanvasHeight)); + OnPropertyChanged(nameof(ScaleValue)); + OnPropertyChanged(nameof(NegativeScaleValue)); + OnPropertyChanged(nameof(ZoomCenterX)); + OnPropertyChanged(nameof(ZoomCenterY)); + OnPropertyChanged(nameof(AxisFontSize)); + OnPropertyChanged(nameof(AxisLineThickness)); + } + + public double CenterOffsetX => 0;// CanvasWidth / 2; + public double CenterOffsetY => 0;// CanvasHeight / 2 * (-1); + + public double GridSize { get; set; } = 0.05; + public Brush GridColorBrush { get; set; } = Brushes.LightGray; + public double GridLineThickness { get; set; } = 0.005; + + public Size CanvasViewportSize => new(CanvasWidth, CanvasHeight); + + public Brush XAxisColorBrush { get; set; } = Brushes.DarkRed; + public Brush YAxisColorBrush { get; set; } = Brushes.DarkGreen; + public double AxisLineThickness + { + get + { + return axisLineThickness / scaleValue; + } + } + public void ZoomAt(Point position, double zoomFactor) + { + // Optional: zoom to cursor + ZoomCenterX *= zoomFactor;// position.X / scaleValue ;// - CenterOffsetX; + ZoomCenterY *= zoomFactor;// position.Y / NegativeScaleValue;// - CenterOffsetY; + + // Update scale + ScaleValue *= zoomFactor; + } + + public double AxisFontSize + { + get + { + return axisFontSize / scaleValue; + } + } + } +} diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRoot.xaml b/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRoot.xaml new file mode 100644 index 0000000..0bd7e2e --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRoot.xaml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRoot.xaml.cs b/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRoot.xaml.cs new file mode 100644 index 0000000..3e5e84a --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRoot.xaml.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace StructureHelper.Windows.UserControls.WorkPlanes +{ + /// + /// Логика взаимодействия для WorkPlaneRoot.xaml + /// + public partial class WorkPlaneRoot : UserControl + { + private Point? _lastPanPoint; + public WorkPlaneRoot() + { + InitializeComponent(); + this.PreviewMouseWheel += WorkPlaneRoot_PreviewMouseWheel; + this.MouseDown += WorkPlaneRoot_MouseDown; + this.MouseMove += WorkPlaneRoot_MouseMove; + this.MouseUp += WorkPlaneRoot_MouseUp; + } + + + private void WorkPlaneRoot_MouseDown(object sender, MouseButtonEventArgs e) + { + if (e.MiddleButton == MouseButtonState.Pressed) + _lastPanPoint = e.GetPosition(this); + } + + private void WorkPlaneRoot_MouseMove(object sender, MouseEventArgs e) + { + if (_lastPanPoint.HasValue && e.MiddleButton == MouseButtonState.Pressed) + { + var current = e.GetPosition(this); + var dx = current.X - _lastPanPoint.Value.X; + var dy = current.Y - _lastPanPoint.Value.Y; + + if (DataContext is WorkPlaneRootViewModel dc) + { + dc.WorkPlaneConfig.ZoomCenterX -= dx / dc.WorkPlaneConfig.ScaleValue; + dc.WorkPlaneConfig.ZoomCenterY -= dy / dc.WorkPlaneConfig.NegativeScaleValue; + } + + _lastPanPoint = current; + } + } + + private void WorkPlaneRoot_MouseUp(object sender, MouseButtonEventArgs e) + { + _lastPanPoint = null; + } + + + private void WorkPlaneRoot_PreviewMouseWheel(object sender, MouseWheelEventArgs e) + { + //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) + { + var pos = e.GetPosition(this); + + if (DataContext is WorkPlaneRootViewModel dc) + { + double zoomFactor = e.Delta > 0 ? 1.1 : 0.9; + dc.WorkPlaneConfig.ZoomAt(pos, zoomFactor); + e.Handled = true; + } + } + } + } +} diff --git a/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRootViewModel.cs b/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRootViewModel.cs new file mode 100644 index 0000000..8deddec --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlanes/WorkPlaneRootViewModel.cs @@ -0,0 +1,15 @@ +using StructureHelper.Infrastructure; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Windows.UserControls.WorkPlanes +{ + public class WorkPlaneRootViewModel : ViewModelBase + { + public WorkPlaneConfigViewModel WorkPlaneConfig { get; } = new(); + public PrimitiveCollectionViewModel PrimitiveCollection { get; } = new(); + } +} diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IObjectConvertStrategy.cs b/StructureHelperCommon/Infrastructures/Interfaces/IObjectConvertStrategy.cs new file mode 100644 index 0000000..ec5e42e --- /dev/null +++ b/StructureHelperCommon/Infrastructures/Interfaces/IObjectConvertStrategy.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Infrastructures.Interfaces +{ + public interface IObjectConvertStrategy + { + T Convert(V source); + } +} diff --git a/StructureHelperCommon/Models/VisualProperties/PrimitiveVisualProperty.cs b/StructureHelperCommon/Models/VisualProperties/PrimitiveVisualProperty.cs index 17a0030..7478114 100644 --- a/StructureHelperCommon/Models/VisualProperties/PrimitiveVisualProperty.cs +++ b/StructureHelperCommon/Models/VisualProperties/PrimitiveVisualProperty.cs @@ -7,7 +7,7 @@ namespace StructureHelperCommon.Models.VisualProperties /// public class PrimitiveVisualProperty : IPrimitiveVisualProperty { - private double opacity = 0; + private double opacity = 1; /// public Guid Id { get; } @@ -25,7 +25,7 @@ namespace StructureHelperCommon.Models.VisualProperties { if (value < 0) { - opacity = 1; + opacity = 0; return; } if (value > 1) diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearSection.cs b/StructureHelperLogics/Models/BeamShears/BeamShearSection.cs index edd416a..2d651cc 100644 --- a/StructureHelperLogics/Models/BeamShears/BeamShearSection.cs +++ b/StructureHelperLogics/Models/BeamShears/BeamShearSection.cs @@ -1,6 +1,8 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.VisualProperties; using StructureHelperLogics.Models.Materials; +using System.Windows.Media; namespace StructureHelperLogics.Models.BeamShears { @@ -17,6 +19,7 @@ namespace StructureHelperLogics.Models.BeamShears public double CenterCover { get; set; } = 0.05; public double ReinforcementArea { get; set; } = 0; public IReinforcementLibMaterial ReinforcementMaterial { get; set; } + public IPrimitiveVisualProperty VisualProperty { get; set; } public BeamShearSection(Guid id) { @@ -24,6 +27,10 @@ namespace StructureHelperLogics.Models.BeamShears ConcreteMaterial = ConcreteLibMaterialFactory.GetConcreteLibMaterial(ConcreteLibTypes.Concrete25); ReinforcementMaterial = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforcement500).HelperMaterial as IReinforcementLibMaterial; ConcreteMaterial.TensionForULS = true; + VisualProperty = new PrimitiveVisualProperty(Guid.NewGuid()) + { + Color = (Color)ColorConverter.ConvertFromString("DarkGray") + }; } public object Clone() diff --git a/StructureHelperLogics/Models/BeamShears/IBeamShearSection.cs b/StructureHelperLogics/Models/BeamShears/IBeamShearSection.cs index e6a5e02..87443a7 100644 --- a/StructureHelperLogics/Models/BeamShears/IBeamShearSection.cs +++ b/StructureHelperLogics/Models/BeamShears/IBeamShearSection.cs @@ -1,5 +1,6 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.VisualProperties; using StructureHelperLogics.Models.Materials; namespace StructureHelperLogics.Models.BeamShears @@ -7,7 +8,7 @@ namespace StructureHelperLogics.Models.BeamShears /// /// Properties of RC cross-section for shear strength of beam /// - public interface IBeamShearSection : ISaveable, ICloneable + public interface IBeamShearSection : ISaveable, ICloneable, IHasVisualProperty { string? Name { get; set; } /// diff --git a/StructureHelperLogics/Models/BeamShears/Logics/StirrupByDensityStrengthLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/StirrupByDensityStrengthLogic.cs index 828b81d..9bed4d4 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/StirrupByDensityStrengthLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/StirrupByDensityStrengthLogic.cs @@ -36,6 +36,16 @@ namespace StructureHelperLogics.Models.BeamShears Check(); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage("Calculation has been started", TraceLogStatuses.Debug); + if (stirrupByDensity.EndCoordinate < inclinedSection.StartCoord) + { + TraceLogger?.AddMessage($"Stirrup end coordinate Xend = {stirrupByDensity.EndCoordinate}(m) is less than incline section start coordinate Xstart = {inclinedSection.StartCoord}(m), stirrup {stirrupByDensity.Name} has been ignored"); + return 0; + } + if (stirrupByDensity.StartCoordinate > inclinedSection.EndCoord) + { + TraceLogger?.AddMessage($"Stirrup start coordinate Xstart = {stirrupByDensity.StartCoordinate}(m) is bigger than incline section end coordinate Xend = {inclinedSection.EndCoord}(m), stirrup {stirrupByDensity.Name} has been ignored"); + return 0; + } double crackLength = inclinedSection.EndCoord - inclinedSection.StartCoord; TraceLogger?.AddMessage($"Length of crack = {inclinedSection.EndCoord} - {inclinedSection.StartCoord} = {crackLength}(m)"); double crackEndCoord = Math.Min(stirrupByDensity.EndCoordinate, inclinedSection.EndCoord); diff --git a/StructureHelperLogics/Models/BeamShears/Logics/StirrupByRebarStrengthLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/StirrupByRebarStrengthLogic.cs index 3a67683..c4dd884 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/StirrupByRebarStrengthLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/StirrupByRebarStrengthLogic.cs @@ -52,6 +52,16 @@ namespace StructureHelperLogics.Models.BeamShears public double GetShearStrength() { InitializeStrategies(); + if (stirrupByRebar.EndCoordinate < inclinedSection.StartCoord) + { + TraceLogger?.AddMessage($"Stirrup end coordinate Xend = {stirrupByRebar.EndCoordinate}(m) is less than incline section start coordinate Xstart = {inclinedSection.StartCoord}(m), stirrup {stirrupByRebar.Name} has been ignored"); + return 0; + } + if (stirrupByRebar.StartCoordinate > inclinedSection.EndCoord) + { + TraceLogger?.AddMessage($"Stirrup start coordinate Xstart = {stirrupByRebar.StartCoordinate}(m) is bigger than incline section end coordinate Xend = {inclinedSection.EndCoord}(m), stirrup {stirrupByRebar.Name} has been ignored"); + return 0; + } TraceLogger?.AddMessage($"Stirrup diameter d = {stirrupByRebar.Diameter}(m)"); TraceLogger?.AddMessage($"Stirrup leg number n = {stirrupByRebar.LegCount}"); TraceLogger?.AddMessage($"Stirrup spacing S = {stirrupByRebar.Spacing}(m)"); diff --git a/StructureHelperLogics/Models/BeamShears/StirrupByDensity.cs b/StructureHelperLogics/Models/BeamShears/StirrupByDensity.cs index bd3ac60..ae87dfa 100644 --- a/StructureHelperLogics/Models/BeamShears/StirrupByDensity.cs +++ b/StructureHelperLogics/Models/BeamShears/StirrupByDensity.cs @@ -21,7 +21,7 @@ namespace StructureHelperLogics.Models.BeamShears Id = id; VisualProperty = new PrimitiveVisualProperty(Guid.NewGuid()) { - Color = (Color)ColorConverter.ConvertFromString("Black") + Color = (Color)ColorConverter.ConvertFromString("Gray") }; } diff --git a/StructureHelperLogics/Models/BeamShears/StirrupByInclinedRebar.cs b/StructureHelperLogics/Models/BeamShears/StirrupByInclinedRebar.cs index fd82cd9..c5f3162 100644 --- a/StructureHelperLogics/Models/BeamShears/StirrupByInclinedRebar.cs +++ b/StructureHelperLogics/Models/BeamShears/StirrupByInclinedRebar.cs @@ -73,7 +73,7 @@ namespace StructureHelperLogics.Models.BeamShears Id = id; VisualProperty = new PrimitiveVisualProperty(Guid.NewGuid()) { - Color = (Color)ColorConverter.ConvertFromString("Black") + Color = (Color)ColorConverter.ConvertFromString("Blue") }; } diff --git a/StructureHelperLogics/Models/BeamShears/StirrupByRebar.cs b/StructureHelperLogics/Models/BeamShears/StirrupByRebar.cs index eb96029..6701d37 100644 --- a/StructureHelperLogics/Models/BeamShears/StirrupByRebar.cs +++ b/StructureHelperLogics/Models/BeamShears/StirrupByRebar.cs @@ -74,7 +74,7 @@ namespace StructureHelperLogics.Models.BeamShears Material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforcement400).HelperMaterial as IReinforcementLibMaterial; VisualProperty = new PrimitiveVisualProperty(Guid.NewGuid()) { - Color = (Color)ColorConverter.ConvertFromString("Black") + Color = (Color)ColorConverter.ConvertFromString("Brown") }; } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ExportFrameWorkElementLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ExportFrameWorkElementLogic.cs index cdb07c0..ad9c671 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ExportFrameWorkElementLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ExportFrameWorkElementLogic.cs @@ -6,35 +6,40 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Xml.Linq; namespace StructureHelperLogics.NdmCalculations.Analyses { public class ExportFrameWorkElementLogic : IExportResultLogic { - private FrameworkElement visual; + private FrameworkElement element; + private double scaleFactor; public string FileName { get; set; } public void Export() { var encoder = new PngBitmapEncoder(); - EncodeVisual(visual, FileName, encoder); + EncodeVisual(element, FileName, encoder); } - public ExportFrameWorkElementLogic(FrameworkElement visual) + public ExportFrameWorkElementLogic(FrameworkElement visual, double scaleFactor = 1) { - this.visual = visual; + this.element = visual; + this.scaleFactor = scaleFactor; } - private static void EncodeVisual(FrameworkElement visual, string fileName, BitmapEncoder encoder) + private void EncodeVisual(FrameworkElement visual, string fileName, BitmapEncoder encoder) { // Measure and arrange the element to ensure it's fully rendered - visual.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); - Rect previousBounds = VisualTreeHelper.GetDescendantBounds(visual); - visual.Arrange(new Rect(0, 0, visual.ActualWidth, visual.ActualHeight)); + //visual.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); + //Rect previousBounds = VisualTreeHelper.GetDescendantBounds(visual); + //visual.Arrange(new Rect(0, 0, visual.ActualWidth, visual.ActualHeight)); + element.Measure(new Size(element.ActualWidth, element.ActualHeight)); + element.Arrange(new Rect(new Size(element.ActualWidth, element.ActualHeight))); var bitmap = new RenderTargetBitmap( - (int)visual.ActualWidth, - (int)visual.ActualHeight, + (int)(visual.ActualWidth * scaleFactor), + (int)(visual.ActualHeight * scaleFactor), 96, 96, PixelFormats.Pbgra32); @@ -43,7 +48,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses var frame = BitmapFrame.Create(bitmap); encoder.Frames.Add(frame); using (var stream = File.Create(fileName)) encoder.Save(stream); - visual.Arrange(previousBounds); + //visual.Arrange(previousBounds); } } }