Interactin diagram was added

This commit is contained in:
Evgeny Redikultsev
2023-12-02 21:50:10 +05:00
parent 8de8c00182
commit 1b635cbf69
47 changed files with 619 additions and 146 deletions

View File

@@ -2,8 +2,10 @@
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Models.Shapes;
@@ -18,20 +20,18 @@ using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
internal class InteractionDiagramLogic : ILongProcessLogic
{
const double xmax = 0.7e6d;
const double xmin = -0.7e6d;
const double ymax = 1.5e6d;
const double ymin = -9e6d;
private ArrayParameter<double> arrayParameter;
private IResult result;
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public int StepCount { get; }
public int StepCount => SurroundData.PointCount;
public Action<int> SetProgress { get; set; }
public bool Result { get; set; }
@@ -40,29 +40,40 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public CalcTerms CalcTerm { get; set; }
public ForceTuple ForceTuple { get; set; }
private void Show()
public SurroundData SurroundData { get; set; }
public InteractionDiagramLogic(SurroundData surroundData)
{
var options = new TriangulationOptions() { LimiteState = LimitState, CalcTerm = CalcTerm };
var ndmCollection = NdmPrimitives.SelectMany(x => x.GetNdms(options));
//var ndmCollection = NdmPrimitivesService.GetNdms(NdmPrimitives, LimitState, CalcTerm);
SurroundData = surroundData;
}
private void DoCalculations()
{
var ndmCollection = NdmPrimitivesService.GetNdms(NdmPrimitives, LimitState, CalcTerm);
var predicateFactory = new PredicateFactory()
{
My = ForceTuple.My,
My = SurroundData.ConstZ,
Ndms = ndmCollection
};
Predicate<IPoint2D> predicate = predicateFactory.GetResult;
Predicate<IPoint2D> predicate = predicateFactory.IsSectionFailure;
//Predicate<IPoint2D> predicate = predicateFactory.IsSectionCracked;
//var logic = new StabLimitCurveLogic();
var logic = new LimitCurveLogic(predicate);
var calculator = new LimitCurveCalculator(logic);
calculator.SurroundData.XMax = xmax;
calculator.SurroundData.XMin = xmin;
calculator.SurroundData.YMax = ymax;
calculator.SurroundData.YMin = ymin;
calculator.SurroundData.PointCount = 40;
calculator.SurroundData = SurroundData;
calculator.ActionToOutputResults = SetProgressByResult;
SafetyProcessor.RunSafeProcess(() =>
{
CalcResult(calculator);
}, "Errors appeared during showing a graph, see detailed information");
}
private void CalcResult(LimitCurveCalculator calculator)
{
calculator.Run();
var result = calculator.Result;
if (result.IsValid = false) { return; }
result = calculator.Result;
if (result.IsValid == false) { return; }
var interactionResult = result as LimitCurveResult;
var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
@@ -73,18 +84,27 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
for (int i = 0; i < items.Count(); i++)
{
var valueList = new List<double>
{
items[i].X * unitForce.Multiplyer,
items[i].Y * unitMoment.Multiplyer
};
{
items[i].X * unitForce.Multiplyer,
items[i].Y * unitMoment.Multiplyer
};
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
SetProgress?.Invoke(i);
}
}
private void SetProgressByResult(IResult calcResult)
{
if (calcResult is not LimitCurveResult)
{
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(LimitCurveResult), calcResult));
}
var parameterResult = calcResult as LimitCurveResult;
SetProgress?.Invoke(parameterResult.IterationNumber);
}
private static string[] GetLabels(IUnit unitForce, IUnit unitMoment)
{
return new string[]
@@ -96,19 +116,25 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public void ShowWindow()
{
Show();
Result = true;
SafetyProcessor.RunSafeProcess(() =>
{
var wnd = new GraphView(arrayParameter);
wnd.ShowDialog();
if (result.IsValid == true)
{
var wnd = new GraphView(arrayParameter);
wnd.ShowDialog();
}
else
{
MessageBox.Show(result.Description);
}
},
"Errors appeared during showing a graph, see detailed information");
}
public void WorkerDoWork(object sender, DoWorkEventArgs e)
{
Show();
DoCalculations();
Result = true;
}

View File

@@ -0,0 +1,52 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic.SurroundDataView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic"
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
d:DataContext ="{d:DesignInstance local:SurroundDataViewModel}"
mc:Ignorable="d"
Title="Diagram properties" Height="250" Width="400" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/>
<ColumnDefinition/>
<ColumnDefinition Width="120"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Maximum axial force"/>
<TextBlock Grid.Row="1" Text="Minimum axial force"/>
<TextBlock Grid.Row="2" Text="Maximum bending moment Mx"/>
<TextBlock Grid.Row="3" Text="Minimum bending moment Mx"/>
<TextBlock Grid.Row="4" Text="Minimum bending moment My"/>
<TextBlock Grid.Row="5" Text="Point count"/>
<TextBox Grid.Column="1" Text="{Binding YMax, Converter={StaticResource ForceConverter}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding YMin, Converter={StaticResource ForceConverter}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding XMax, Converter={StaticResource MomentConverter}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding XMin, Converter={StaticResource MomentConverter}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Column="1" Grid.Row="4" Text="{Binding ConstZ, Converter={StaticResource MomentConverter}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Column="1" Grid.Row="5" Text="{Binding PointCount, ValidatesOnDataErrors=True}"/>
<uc:MultiplyDouble Margin="2" Grid.Column="4" Grid.Row="0" ValueChanged="YmaxChanged"/>
<uc:MultiplyDouble Margin="2" Grid.Column="4" Grid.Row="1" ValueChanged="YminChanged"/>
<uc:MultiplyDouble Margin="2" Grid.Column="4" Grid.Row="2" ValueChanged="XmaxChanged"/>
<uc:MultiplyDouble Margin="2" Grid.Column="4" Grid.Row="3" ValueChanged="XminChanged"/>
<uc:MultiplyDouble Margin="2" Grid.Column="4" Grid.Row="4" ValueChanged="ConstZChanged"/>
<uc:MultiplyDouble Margin="2" Grid.Column="4" Grid.Row="5" ValueChanged="PointCountChanged"/>
</Grid>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -0,0 +1,67 @@
using StructureHelper.Windows.UserControls;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
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.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
{
/// <summary>
/// Логика взаимодействия для SurroundDataView.xaml
/// </summary>
public partial class SurroundDataView : Window
{
private SurroundDataViewModel viewModel;
public SurroundDataView(SurroundData surroundData) : this(new SurroundDataViewModel(surroundData)) { }
public SurroundDataView(SurroundDataViewModel vm)
{
viewModel = vm;
viewModel.ParentWindow = this;
DataContext = viewModel;
InitializeComponent();
}
private void XmaxChanged(object sender, EventArgs e)
{
viewModel.XMax *= ChangeValue(sender);
}
private void XminChanged(object sender, EventArgs e)
{
viewModel.XMin *= ChangeValue(sender);
}
private void YmaxChanged(object sender, EventArgs e)
{
viewModel.YMax *= ChangeValue(sender);
}
private void YminChanged(object sender, EventArgs e)
{
viewModel.YMin *= ChangeValue(sender);
}
private void ConstZChanged(object sender, EventArgs e)
{
viewModel.ConstZ *= ChangeValue(sender);
}
private void PointCountChanged(object sender, EventArgs e)
{
viewModel.PointCount = Convert.ToInt32(viewModel.PointCount * ChangeValue(sender));
}
private double ChangeValue(object sender)
{
var obj = (MultiplyDouble)sender;
var factor = obj.DoubleFactor;
return factor;
}
}
}

View File

@@ -0,0 +1,107 @@
using StructureHelper.Windows.ViewModels;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
{
public class SurroundDataViewModel : OkCancelViewModelBase, IDataErrorInfo
{
private readonly SurroundData surroundData;
public double XMax
{
get => surroundData.XMax; set
{
surroundData.XMax = value;
OnPropertyChanged(nameof(XMax));
}
}
public double XMin
{
get => surroundData.XMin; set
{
surroundData.XMin = value;
OnPropertyChanged(nameof(XMin));
}
}
public double YMax
{
get => surroundData.YMax; set
{
surroundData.YMax = value;
OnPropertyChanged(nameof(YMax));
}
}
public double YMin
{
get => surroundData.YMin; set
{
surroundData.YMin = value;
OnPropertyChanged(nameof(YMin));
}
}
public double ConstZ
{
get => surroundData.ConstZ; set
{
surroundData.ConstZ = value;
OnPropertyChanged(nameof(ConstZ));
}
}
public int PointCount
{
get => surroundData.PointCount; set
{
try
{
surroundData.PointCount = value;
}
catch (Exception)
{
surroundData.PointCount = 40;
}
OnPropertyChanged(nameof(PointCount));
}
}
public string Error => throw new NotImplementedException();
public string this[string columnName]
{
get
{
string error = String.Empty;
switch (columnName)
{
case nameof(PointCount):
if (PointCount < 24)
{
error = "Point count must be greater than 24";
}
break;
}
return error;
}
}
public SurroundDataViewModel(SurroundData surroundData)
{
this.surroundData = surroundData;
}
internal void RefreshAll()
{
OnPropertyChanged(nameof(XMax));
OnPropertyChanged(nameof(XMin));
OnPropertyChanged(nameof(YMax));
OnPropertyChanged(nameof(YMin));
OnPropertyChanged(nameof(ConstZ));
OnPropertyChanged(nameof(PointCount));
}
}
}

View File

@@ -5,6 +5,7 @@ using StructureHelper.Services.Exports;
using StructureHelper.Services.Reports;
using StructureHelper.Services.Reports.CalculationReports;
using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews;
using StructureHelper.Windows.Errors;
using StructureHelper.Windows.Forces;
@@ -38,7 +39,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private ForceCalculator forceCalculator;
private ILongProcessLogic progressLogic;
private ShowProgressLogic showProgressLogic;
private InteractionDiagramLogic interactionDiagramLogic = new();
private InteractionDiagramLogic interactionDiagramLogic;
private static readonly ShowCrackResultLogic showCrackResultLogic = new();
private static readonly ShowCrackWidthLogic showCrackWidthLogic = new();
private IForcesResults forcesResults;
@@ -73,11 +74,25 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
return showInteractionDiagramCommand ??
(showInteractionDiagramCommand = new RelayCommand(o =>
{
interactionDiagramLogic.ForceTuple = SelectedResult.DesignForceTuple.ForceTuple.Clone() as ForceTuple;
interactionDiagramLogic.LimitState = SelectedResult.DesignForceTuple.LimitState;
interactionDiagramLogic.CalcTerm = SelectedResult.DesignForceTuple.CalcTerm;
interactionDiagramLogic.NdmPrimitives = ndmPrimitives;
interactionDiagramLogic.ShowWindow();
var tuple = SelectedResult.DesignForceTuple.ForceTuple.Clone() as ForceTuple;
var data = new SurroundData();
data.ConstZ = tuple.My;
var wnd = new SurroundDataView(data);
wnd.ShowDialog();
if (wnd.DialogResult != true) return;
interactionDiagramLogic = new(data)
{
ForceTuple = tuple,
LimitState = SelectedResult.DesignForceTuple.LimitState,
CalcTerm = SelectedResult.DesignForceTuple.CalcTerm,
NdmPrimitives = ndmPrimitives
};
showProgressLogic = new(interactionDiagramLogic)
{
WindowTitle = "Diagram creating...",
ShowResult = interactionDiagramLogic.ShowWindow
};
showProgressLogic.Show();
}, o => SelectedResult != null && SelectedResult.IsValid));
}
}