diff --git a/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml b/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml index 0d0fd96..7c7acb2 100644 --- a/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml @@ -33,10 +33,10 @@ - + - + + diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs index a2b438e..6008109 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs @@ -1,6 +1,7 @@ using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Ndms; using StructureHelper.Infrastructure; +using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelper.Services.Exports; using StructureHelper.Services.Reports; using StructureHelper.Services.Reports.CalculationReports; @@ -52,17 +53,18 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu public static GeometryNames GeometryNames => ProgramSetting.GeometryNames; public ForcesTupleResult SelectedResult { get; set; } - private ICommand showIsoFieldCommand; - private ICommand exportToCSVCommand; - private ICommand interpolateCommand; - private ICommand setPrestrainCommand; - private ICommand showAnchorageCommand; - private ICommand showGeometryResultCommand; - private ICommand showGraphsCommand; - private ICommand showCrackResult; - private ICommand showCrackGraphsCommand; - private RelayCommand showCrackWidthResult; - private ICommand showInteractionDiagramCommand; + private ICommand? showIsoFieldCommand; + private ICommand? exportToCSVCommand; + private ICommand? interpolateCommand; + private ICommand? setPrestrainCommand; + private ICommand? showAnchorageCommand; + private ICommand? showGeometryResultCommand; + private ICommand? showGraphsCommand; + private ICommand? showCrackResult; + private ICommand? showCrackGraphsCommand; + private ICommand? showCrackWidthResult; + private ICommand? showInteractionDiagramCommand; + private ICommand? graphValuepointsCommand; public IForcesResults ForcesResults { @@ -155,7 +157,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples); if (wndTuples.DialogResult != true) return; - var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.Result); + var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.ForceInterpolationViewModel.Result); showProgressLogic = new(interpolationLogic) { WindowTitle = "Interpolate forces" @@ -186,7 +188,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples); if (wndTuples.DialogResult != true) return; - var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.Result); + var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.ForceInterpolationViewModel.Result); showProgressLogic = new(interpolationLogic) { WindowTitle = "Interpolate forces" @@ -259,13 +261,53 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples); if (wndTuples.DialogResult != true) return; - var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.Result); + var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.ForceInterpolationViewModel.Result); progressLogic = interpolationLogic; showProgressLogic = new(interpolationLogic); showProgressLogic.ShowResult = ShowInterpolationProgressDialog; showProgressLogic.Show(); } + public ICommand GraphValuePointsCommand + { + get + { + return graphValuepointsCommand ?? + (graphValuepointsCommand = new RelayCommand(o => + { + InterpolateValuePoints(); + }, o => SelectedResult != null)); + } + } + + private void InterpolateValuePoints() + { + var inputData = new ValuePointsInterpolationInputData() + { + FinishDesignForce = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple, + LimitState = SelectedResult.DesignForceTuple.LimitState, + CalcTerm = SelectedResult.DesignForceTuple.CalcTerm, + }; + inputData.PrimitiveBases.AddRange(PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(ndmPrimitives)); + var viewModel = new ValuePointsInterpolateViewModel(inputData); + var wnd = new ValuePointsInterpolateView(viewModel); + wnd.ShowDialog(); + if (wnd.DialogResult != true) { return; } + var interpolationLogic = new InterpolationProgressLogic(forceCalculator, viewModel.ForceInterpolationViewModel.Result); + ShowValuePointDiagramLogic pointGraphLogic = new() + { + Calculator = interpolationLogic.InterpolateCalculator, + PrimitiveLogic = viewModel.PrimitiveLogic, + ValueDelegatesLogic = viewModel.ValueDelegatesLogic + }; + progressLogic = interpolationLogic; + showProgressLogic = new(interpolationLogic) + { + ShowResult = pointGraphLogic.ShowGraph + }; + showProgressLogic.Show(); + } + private void ShowInterpolationWindow(out InterpolateTuplesViewModel interploateTuplesViewModel, out InterpolateTuplesView wndTuples) { IDesignForceTuple finishDesignTuple = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple; diff --git a/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml b/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml new file mode 100644 index 0000000..21362df --- /dev/null +++ b/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml.cs b/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml.cs new file mode 100644 index 0000000..0a95c0c --- /dev/null +++ b/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml.cs @@ -0,0 +1,67 @@ +using StructureHelper.Windows.UserControls; +using StructureHelper.Windows.ViewModels.Materials; +using StructureHelperCommon.Services.Forces; +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.Forces +{ + /// + /// Логика взаимодействия для ForceInterpolationControl.xaml + /// + public partial class ForceInterpolationControl : UserControl + { + private ForceTupleInterpolationViewModel? properties; + + public ForceTupleInterpolationViewModel? Properties + { + get => properties; set + { + properties = value; + DataContext = Properties; + } + } + public ForceInterpolationControl() + { + InitializeComponent(); + } + + private void StartValueChanged(object sender, EventArgs e) + { + var obj = (MultiplyDouble)sender; + var tmpTuple = ForceTupleService.MultiplyTuples(Properties.StartDesignForce.ForceTuple, obj.DoubleFactor); + ForceTupleService.CopyProperties(tmpTuple, Properties.StartDesignForce.ForceTuple, 1d); + Properties.RefreshStartTuple(); + } + + private void FinishValueChanged(object sender, EventArgs e) + { + var obj = (MultiplyDouble)sender; + var tmpTuple = ForceTupleService.MultiplyTuples(Properties.FinishDesignForce.ForceTuple, obj.DoubleFactor); + ForceTupleService.CopyProperties(tmpTuple, Properties.FinishDesignForce.ForceTuple, 1d); + Properties.RefreshFinishTuple(); + } + + private void StepCountValueChanged(object sender, EventArgs e) + { + var obj = (MultiplyDouble)sender; + var factor = obj.DoubleFactor; + if (factor > 0d) + { + Properties.StepCount = Convert.ToInt32(Properties.StepCount * factor); + } + } + } +} diff --git a/StructureHelper/Windows/Forces/ForceTupleControl.xaml b/StructureHelper/Windows/Forces/ForceTupleControl.xaml deleted file mode 100644 index 6166d4d..0000000 --- a/StructureHelper/Windows/Forces/ForceTupleControl.xaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml b/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml new file mode 100644 index 0000000..c106140 --- /dev/null +++ b/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/Forces/ForceTupleControl.xaml.cs b/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml.cs similarity index 76% rename from StructureHelper/Windows/Forces/ForceTupleControl.xaml.cs rename to StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml.cs index 446b197..ecc0032 100644 --- a/StructureHelper/Windows/Forces/ForceTupleControl.xaml.cs +++ b/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml.cs @@ -18,9 +18,10 @@ namespace StructureHelper.Windows.Forces /// /// Логика взаимодействия для ForceTupleControl.xaml /// - public partial class ForceTupleControl : UserControl + public partial class ForceTupleInterpolationControl : UserControl { - public ForceTupleControl() + public ForceTupleInterpolationViewModel? Properties { get; set; } + public ForceTupleInterpolationControl() { InitializeComponent(); } diff --git a/StructureHelper/Windows/Forces/ForceTupleInterpolationViewModel.cs b/StructureHelper/Windows/Forces/ForceTupleInterpolationViewModel.cs new file mode 100644 index 0000000..6259e1e --- /dev/null +++ b/StructureHelper/Windows/Forces/ForceTupleInterpolationViewModel.cs @@ -0,0 +1,212 @@ +using StructureHelper.Infrastructure; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models.Forces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace StructureHelper.Windows.Forces +{ + public class ForceTupleInterpolationViewModel : ViewModelBase + { + private RelayCommand invertForcesCommand; + private RelayCommand copyToStartCommand; + private RelayCommand copyToFinishCommand; + private int stepCount; + private IDesignForceTuple startDesignForce; + private IDesignForceTuple finishDesignForce; + + public IDesignForceTuple StartDesignForce + { + get => startDesignForce; set + { + startDesignForce = value; + } + } + public IDesignForceTuple FinishDesignForce + { + get => finishDesignForce; set + { + finishDesignForce = value; + } + } + + public double StartFactor { get; set; } + public double FinishFactor { get; set; } + public double StepCountFactor { get; set; } + + public bool StepCountVisible { get; set; } + public double StartMx + { + get => StartDesignForce.ForceTuple.Mx; + set + { + StartDesignForce.ForceTuple.Mx = value; + OnPropertyChanged(nameof(StartMx)); + } + } + public double StartMy + { + get => StartDesignForce.ForceTuple.My; + set + { + StartDesignForce.ForceTuple.My = value; + OnPropertyChanged(nameof(StartMy)); + } + } + public double StartNz + { + get => StartDesignForce.ForceTuple.Nz; + set + { + StartDesignForce.ForceTuple.Nz = value; + OnPropertyChanged(nameof(StartNz)); + } + } + public double FinishMx + { + get => FinishDesignForce.ForceTuple.Mx; + set + { + FinishDesignForce.ForceTuple.Mx = value; + OnPropertyChanged(nameof(FinishMx)); + } + } + public double FinishMy + { + get => FinishDesignForce.ForceTuple.My; + set + { + FinishDesignForce.ForceTuple.My = value; + OnPropertyChanged(nameof(FinishMy)); + } + } + public double FinishNz + { + get => FinishDesignForce.ForceTuple.Nz; + set + { + FinishDesignForce.ForceTuple.Nz = value; + OnPropertyChanged(nameof(FinishNz)); + } + } + public int StepCount + { + get => stepCount; set + { + stepCount = value; + OnPropertyChanged(nameof(StepCount)); + } + } + + public ICommand InvertForcesCommand + { + get => invertForcesCommand ??= new RelayCommand(o => InvertForces()); + } + public ICommand CopyToStartCommand + { + get => copyToStartCommand ??= new RelayCommand(o => CopyFinishToStart()); + } + public ICommand CopyToFinishCommand + { + get => copyToFinishCommand ??= new RelayCommand(o => CopyStartToFinish()); + } + public InterpolateTuplesResult Result + { + get => new() + { + StartTuple = StartDesignForce, + FinishTuple = FinishDesignForce, + StepCount = StepCount + }; + } + + private void InvertForces() + { + var tmpForce = StartDesignForce.Clone() as IDesignForceTuple; + StartDesignForce = FinishDesignForce; + FinishDesignForce = tmpForce; + StepCountVisible = true; + RefreshStartTuple(); + RefreshFinishTuple(); + } + + private void CopyStartToFinish() + { + FinishDesignForce = StartDesignForce.Clone() as IDesignForceTuple; + RefreshFinishTuple(); + } + + private void CopyFinishToStart() + { + StartDesignForce = FinishDesignForce.Clone() as IDesignForceTuple; + RefreshStartTuple(); + } + + public void RefreshFinishTuple() + { + OnPropertyChanged(nameof(FinishDesignForce)); + OnPropertyChanged(nameof(FinishMx)); + OnPropertyChanged(nameof(FinishMy)); + OnPropertyChanged(nameof(FinishNz)); + } + + public void RefreshStartTuple() + { + OnPropertyChanged(nameof(StartDesignForce)); + OnPropertyChanged(nameof(StartMx)); + OnPropertyChanged(nameof(StartMy)); + OnPropertyChanged(nameof(StartNz)); + } + + public ForceTupleInterpolationViewModel(IDesignForceTuple finishDesignForce, IDesignForceTuple startDesignForce = null, int stepCount = 100) + { + if (startDesignForce != null) + { + CheckDesignForces(finishDesignForce, startDesignForce); + StartDesignForce = startDesignForce; + } + else + { + GetNewDesignForce(finishDesignForce); + } + FinishDesignForce = finishDesignForce; + StepCount = stepCount; + StepCountVisible = true; + } + public ForceTupleInterpolationViewModel() + { + + } + + private static void CheckDesignForces(IDesignForceTuple finishDesignForce, IDesignForceTuple startDesignForce) + { + if (startDesignForce.LimitState != finishDesignForce.LimitState) + { + throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid); + } + if (startDesignForce.CalcTerm != finishDesignForce.CalcTerm) + { + throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid); + } + } + + private void GetNewDesignForce(IDesignForceTuple finishDesignForce) + { + StartDesignForce = new DesignForceTuple() + { + CalcTerm = finishDesignForce.CalcTerm, + LimitState = finishDesignForce.LimitState, + ForceTuple = new ForceTuple() + { + Mx = 0, + My = 0, + Nz = 0 + }, + }; + } + } +} diff --git a/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml b/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml index 5fa2abe..911b889 100644 --- a/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml +++ b/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml @@ -8,7 +8,7 @@ xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" d:DataContext="{d:DesignInstance local:InterpolateTuplesViewModel}" mc:Ignorable="d" - Title="Interpolate Combinations" Height="200" Width="460" MinHeight="180" MinWidth="460" WindowStartupLocation="CenterScreen"> + Title="Interpolate Combinations" Height="250" Width="460" MinHeight="250" MinWidth="460" WindowStartupLocation="CenterScreen">