Long Progress Logics were added

This commit is contained in:
Evgeny Redikultsev
2023-11-12 20:38:11 +05:00
parent 36cb0878e9
commit ba797e7aaa
16 changed files with 513 additions and 242 deletions

View File

@@ -15,7 +15,7 @@
<Compile Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml.cs"> <Compile Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\CalculationWindows\ProgressViews\InterpolationProgressView.xaml.cs"> <Compile Update="Windows\CalculationWindows\ProgressViews\ShowProgressView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\Errors\ErrorMessage.xaml.cs"> <Compile Update="Windows\Errors\ErrorMessage.xaml.cs">
@@ -59,7 +59,7 @@
<Page Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml"> <Page Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\CalculationWindows\ProgressViews\InterpolationProgressView.xaml"> <Page Update="Windows\CalculationWindows\ProgressViews\ShowProgressView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\Errors\ErrorMessage.xaml"> <Page Update="Windows\Errors\ErrorMessage.xaml">

View File

@@ -0,0 +1,155 @@
using LoaderCalculator;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
internal class CrackDiagramLogic : ILongProcessLogic
{
static readonly CrackForceCalculator calculator = new();
private List<IForcesTupleResult> ValidTupleList { get; set; }
ArrayParameter<double> arrayParameter;
private IEnumerable<IForcesTupleResult> TupleList { get; set; }
private IEnumerable<INdmPrimitive> NdmPrimitives { get; set; }
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public Action<int> SetProgress { get; set; }
public bool Result { get; set; }
public int StepCount => ValidTupleList.Count();
public CrackDiagramLogic(IEnumerable<IForcesTupleResult> tupleList, IEnumerable<INdmPrimitive> ndmPrimitives)
{
TupleList = tupleList;
NdmPrimitives = ndmPrimitives;
ValidTupleList = TupleList.Where(x => x.IsValid == true).ToList();
}
public void WorkerDoWork(object sender, DoWorkEventArgs e)
{
ShowCracks();
Result = true;
}
public void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{
//nothing to do
}
public void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//nothing to do
}
public void ShowCracks()
{
var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
string[] labels = GetCrackLabels(unitForce, unitMoment, unitCurvature);
arrayParameter = new ArrayParameter<double>(ValidTupleList.Count(), labels.Count(), labels);
CalculateWithCrack(ValidTupleList, NdmPrimitives, unitForce, unitMoment, unitCurvature);
}
public void ShowWindow()
{
SafetyProcessor.RunSafeProcess(() =>
{
var wnd = new GraphView(arrayParameter);
wnd.ShowDialog();
},
"Errors appeared during showing a graph, see detailed information");
}
private void CalculateWithCrack(List<IForcesTupleResult> validTupleList, IEnumerable<INdmPrimitive> ndmPrimitives, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
var data = arrayParameter.Data;
for (int i = 0; i < validTupleList.Count(); i++)
{
var valueList = new List<double>
{
validTupleList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer
};
calculator.EndTuple = validTupleList[i].DesignForceTuple.ForceTuple;
var limitState = validTupleList[i].DesignForceTuple.LimitState;
var calcTerm = validTupleList[i].DesignForceTuple.CalcTerm;
var ndms = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
calculator.NdmCollection = ndms;
calculator.Run();
var result = (CrackForceResult)calculator.Result;
if (result.IsValid == false)
{
MessageBox.Show(
"Result is not valid",
"Crack results",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
valueList.Add(result.CrackedStrainTuple.Mx);
valueList.Add(result.CrackedStrainTuple.My);
valueList.Add(result.CrackedStrainTuple.Nz);
valueList.Add(result.ReducedStrainTuple.Mx);
valueList.Add(result.ReducedStrainTuple.My);
valueList.Add(result.ReducedStrainTuple.Nz);
valueList.Add(result.SofteningFactors.Mx);
valueList.Add(result.SofteningFactors.My);
valueList.Add(result.SofteningFactors.Nz);
valueList.Add(result.PsiS);
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
SetProgress?.Invoke(i);
}
}
private static string[] GetCrackLabels(IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
const string crc = "Crc";
const string crcFactor = "CrcSofteningFactor";
return new string[]
{
$"{GeometryNames.MomFstName}, {unitMoment.Name}",
$"{GeometryNames.MomSndName}, {unitMoment.Name}",
$"{GeometryNames.LongForceName}, {unitForce.Name}",
$"{GeometryNames.CurvFstName}, {unitCurvature.Name}",
$"{GeometryNames.CurvSndName}, {unitCurvature.Name}",
$"{GeometryNames.StrainTrdName}",
$"{crc}{GeometryNames.CurvFstName}, {unitCurvature.Name}",
$"{crc}{GeometryNames.CurvSndName}, {unitCurvature.Name}",
$"{crc}{GeometryNames.StrainTrdName}",
$"{crcFactor}Ix",
$"{crcFactor}Iy",
$"{crcFactor}Az",
$"PsiFactor"
};
}
}
}

View File

@@ -1,12 +1,12 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.ProgressViews.InterpolationProgressView" <Window x:Class="StructureHelper.Windows.CalculationWindows.ProgressViews.ShowProgressView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews" xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:InterpolationProgressViewModel}" d:DataContext="{d:DesignInstance local:ShowProgressViewModel}"
Title="InterpolationProgressView" Height="150" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None"> Title="{Binding WindowTitle}" Height="150" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None">
<Grid Margin="10"> <Grid Margin="10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/>
@@ -16,14 +16,16 @@
<RowDefinition Height="25"/> <RowDefinition Height="25"/>
<RowDefinition Height="25"/> <RowDefinition Height="25"/>
<RowDefinition Height="25"/> <RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="Progress"/> <TextBlock Grid.Row="0" Grid.ColumnSpan="2" Text="{Binding WindowTitle}"/>
<ProgressBar Grid.Column="1" Grid.Row="0" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" Value="{Binding ProgressValue}"/> <TextBlock Grid.Row="1" Text="Progress"/>
<TextBlock Grid.Row="1" Text="Total step"/> <ProgressBar Grid.Column="1" Grid.Row="1" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" Value="{Binding ProgressValue}"/>
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding MaxValue}" IsEnabled="False"/> <TextBlock Grid.Row="2" Text="Total step"/>
<TextBlock Grid.Row="2" Text="Current step"/> <TextBox Grid.Column="2" Grid.Row="2" Text="{Binding MaxValue}" IsEnabled="False"/>
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding ProgressValue}" IsEnabled="False"/> <TextBlock Grid.Row="3" Text="Current step"/>
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding ProgressValue}" IsEnabled="False"/>
</Grid> </Grid>
</Window> </Window>

View File

@@ -18,10 +18,10 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
/// <summary> /// <summary>
/// Логика взаимодействия для InterpolationProgressView.xaml /// Логика взаимодействия для InterpolationProgressView.xaml
/// </summary> /// </summary>
public partial class InterpolationProgressView : Window public partial class ShowProgressView : Window
{ {
InterpolationProgressViewModel viewModel; ShowProgressViewModel viewModel;
public InterpolationProgressView(InterpolationProgressViewModel viewModel) public ShowProgressView(ShowProgressViewModel viewModel)
{ {
InitializeComponent(); InitializeComponent();
this.viewModel = viewModel; this.viewModel = viewModel;

View File

@@ -7,12 +7,14 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.ProgressViews namespace StructureHelper.Windows.CalculationWindows.ProgressViews
{ {
public class InterpolationProgressViewModel : ViewModelBase public class ShowProgressViewModel : ViewModelBase
{ {
private double progressValue; private double progressValue;
private double maxValue; private double maxValue;
private double minValue; private double minValue;
public string WindowTitle { get; set; }
public double MinValue public double MinValue
{ {
get => minValue; set get => minValue; set

View File

@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.Forces" xmlns:local="clr-namespace:StructureHelper.Windows.Forces"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces" xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
d:DataContext="{d:DesignInstance vm:InterpolateTuplesViewModel}" d:DataContext="{d:DesignInstance local:InterpolateTuplesViewModel}"
mc:Ignorable="d" mc:Ignorable="d"
Title="Interpolate Combinations" Height="200" Width="400" MinHeight="180" MinWidth="400" WindowStartupLocation="CenterScreen"> Title="Interpolate Combinations" Height="200" Width="400" MinHeight="180" MinWidth="400" WindowStartupLocation="CenterScreen">
<Window.Resources> <Window.Resources>

View File

@@ -1,14 +1,10 @@
using StructureHelper.Infrastructure; using StructureHelper.Infrastructure;
using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Forces namespace StructureHelper.Windows.Forces
{ {
public class InterpolateTuplesViewModel : OkCancelViewModelBase public class InterpolateTuplesViewModel : OkCancelViewModelBase
{ {
@@ -91,6 +87,16 @@ namespace StructureHelper.Windows.ViewModels.Forces
get => copyToFinishCommand ??= new RelayCommand(o => CopyStartToFinish()); get => copyToFinishCommand ??= new RelayCommand(o => CopyStartToFinish());
} }
public InterpolateTuplesResult Result
{
get => new()
{
StartTuple = StartDesignForce,
FinishTuple = FinishDesignForce,
StepCount = StepCount
};
}
private void InvertForces() private void InvertForces()
{ {
var tmpForce = StartDesignForce.Clone() as IDesignForceTuple; var tmpForce = StartDesignForce.Clone() as IDesignForceTuple;

View File

@@ -1,112 +0,0 @@
using LoaderCalculator;
using LoaderCalculator.Data.ResultData;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.CalculationWindows.ProgressViews;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.ViewModels.Forces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.Services.NdmCalculations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
internal class InterpolateLogic
{
private InterpolationProgressViewModel progressViewModel;
private InterpolationProgressView wndProgress;
private IForceCalculator forceCalculator;
private IDesignForceTuple finishDesignTuple;
private IDesignForceTuple startDesignTuple;
private int stepCount;
private IResult result;
private IForceCalculator interpolateCalculator;
public void Show(IDesignForceTuple finishTuple, IForceCalculator forceCalculator)
{
this.forceCalculator = forceCalculator;
var viewModel = new InterpolateTuplesViewModel(finishTuple, null);
var wndTuples = new InterpolateTuplesView(viewModel);
wndTuples.ShowDialog();
if (wndTuples.DialogResult != true) return;
startDesignTuple = viewModel.StartDesignForce;
finishDesignTuple = viewModel.FinishDesignForce;
stepCount = viewModel.StepCount;
progressViewModel = new()
{
MinValue = 0,
MaxValue = stepCount,
ProgressValue = 0
};
wndProgress =new InterpolationProgressView(progressViewModel);
wndProgress.Loaded += RunCalc;
wndProgress.ShowDialog();
}
private void RunCalc(object sender, RoutedEventArgs e)
{
BackgroundWorker worker = new();
worker.DoWork += WorkerDoWork;
worker.ProgressChanged += WorkerProgressChanged;
worker.RunWorkerCompleted += WorkerRunWorkCompleted;
worker.RunWorkerAsync();
}
private void ShowProgressResult(IResult result)
{
if (result is ForcesResults)
{
var forceResult = result as ForcesResults;
progressViewModel.ProgressValue = forceResult.ForcesResultList.Count();
}
}
private void WorkerDoWork(object sender, DoWorkEventArgs e)
{
interpolateCalculator = InterpolateService.InterpolateForceCalculator(forceCalculator, finishDesignTuple, startDesignTuple, stepCount);
interpolateCalculator.ActionToOutputResults = ShowProgressResult;
interpolateCalculator.Run();
result = interpolateCalculator.Result;
}
private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{
}
private void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
wndProgress.Close();
if (result is null || result.IsValid == false)
{
System.Windows.Forms.MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
var vm = new ForcesResultsViewModel(interpolateCalculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
}
}
catch (Exception ex)
{
throw;
}
}
}
}

View File

@@ -7,6 +7,7 @@ using StructureHelper.Windows.ViewModels.Errors;
using StructureHelper.Windows.ViewModels.Graphs; using StructureHelper.Windows.ViewModels.Graphs;
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Parameters; using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Services.Units; using StructureHelperCommon.Services.Units;
@@ -16,6 +17,7 @@ using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmPrimitives; using StructureHelperLogics.Services.NdmPrimitives;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -23,86 +25,62 @@ using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{ {
internal class ShowDiagramLogic internal class ShowDiagramLogic : ILongProcessLogic
{ {
static readonly CrackForceCalculator calculator = new();
ArrayParameter<double> arrayParameter; ArrayParameter<double> arrayParameter;
private IEnumerable<IForcesTupleResult> TupleList;
private IEnumerable<INdmPrimitive> NdmPrimitives;
private List<IForcesTupleResult> ValidTupleList;
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames; private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public void Show(List<IForcesTupleResult> results) public int StepCount => ValidTupleList.Count();
public Action<int> SetProgress { get ; set; }
public bool Result { get; set; }
public void WorkerDoWork(object sender, DoWorkEventArgs e)
{ {
var resultList = results.Where(x => x.IsValid == true).ToList(); Show();
Result = true;
}
public void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{
//nothing to do
}
public void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//nothing to do
}
public void ShowWindow()
{
SafetyProcessor.RunSafeProcess(() =>
{
var wnd = new GraphView(arrayParameter);
wnd.ShowDialog();
},
"Errors appeared during showing a graph, see detailed information");
}
private void Show()
{
ValidTupleList = TupleList.Where(x => x.IsValid == true).ToList();
var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN"); var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm"); var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m"); var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
string[] labels = GetLabels(unitForce, unitMoment, unitCurvature); string[] labels = GetLabels(unitForce, unitMoment, unitCurvature);
arrayParameter = new ArrayParameter<double>(resultList.Count(), labels.Count(), labels); arrayParameter = new ArrayParameter<double>(ValidTupleList.Count(), labels.Count(), labels);
CalculateWithoutCrack(resultList, unitForce, unitMoment, unitCurvature); CalculateWithoutCrack(ValidTupleList, unitForce, unitMoment, unitCurvature);
SafetyProcessor.RunSafeProcess(ShowWindow, "Errors appeared during showing a graph, see detail information");
}
public void ShowCracks(List<IForcesTupleResult> results, IEnumerable<INdmPrimitive> ndmPrimitives)
{
var resultList = results.Where(x => x.IsValid == true).ToList();
var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
string[] labels = GetCrackLabels(unitForce, unitMoment, unitCurvature);
arrayParameter = new ArrayParameter<double>(resultList.Count(), labels.Count(), labels);
CalculateWithCrack(resultList, ndmPrimitives, unitForce, unitMoment, unitCurvature);
SafetyProcessor.RunSafeProcess(ShowWindow, "Errors appeared during showing a graph, see detailed information");
} }
private void CalculateWithCrack(List<IForcesTupleResult> resultList, IEnumerable<INdmPrimitive> ndmPrimitives, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature) public ShowDiagramLogic(IEnumerable<IForcesTupleResult> tupleList, IEnumerable<INdmPrimitive> ndmPrimitives)
{ {
var data = arrayParameter.Data; TupleList = tupleList;
for (int i = 0; i < resultList.Count(); i++) NdmPrimitives = ndmPrimitives;
{ ValidTupleList = TupleList.Where(x => x.IsValid == true).ToList();
var valueList = new List<double>
{
resultList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer
};
calculator.EndTuple = resultList[i].DesignForceTuple.ForceTuple;
var limitState = resultList[i].DesignForceTuple.LimitState;
var calcTerm = resultList[i].DesignForceTuple.CalcTerm;
var ndms = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
calculator.NdmCollection = ndms;
calculator.Run();
var result = (CrackForceResult)calculator.Result;
if (result.IsValid == false)
{
MessageBox.Show(
"Result is not valid",
"Crack results",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
} }
valueList.Add(result.CrackedStrainTuple.Mx);
valueList.Add(result.CrackedStrainTuple.My);
valueList.Add(result.CrackedStrainTuple.Nz);
valueList.Add(result.ReducedStrainTuple.Mx);
valueList.Add(result.ReducedStrainTuple.My);
valueList.Add(result.ReducedStrainTuple.Nz);
valueList.Add(result.SofteningFactors.Mx);
valueList.Add(result.SofteningFactors.My);
valueList.Add(result.SofteningFactors.Nz);
valueList.Add(result.PsiS);
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
}
}
private void CalculateWithoutCrack(List<IForcesTupleResult> resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature) private void CalculateWithoutCrack(List<IForcesTupleResult> resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{ {
@@ -114,14 +92,10 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{ {
data[i, j] = valueList[j]; data[i, j] = valueList[j];
} }
SetProgress?.Invoke(i);
} }
} }
private void ShowWindow()
{
var wnd = new GraphView(arrayParameter);
wnd.ShowDialog();
}
private static List<double> ProcessResultWithouCrack(List<IForcesTupleResult> resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature, int i) private static List<double> ProcessResultWithouCrack(List<IForcesTupleResult> resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature, int i)
{ {
@@ -147,26 +121,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
$"{GeometryNames.StrainTrdName}" $"{GeometryNames.StrainTrdName}"
}; };
} }
private static string[] GetCrackLabels(IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
const string crc = "Crc";
const string crcFactor = "CrcSofteningFactor";
return new string[]
{
$"{GeometryNames.MomFstName}, {unitMoment.Name}",
$"{GeometryNames.MomSndName}, {unitMoment.Name}",
$"{GeometryNames.LongForceName}, {unitForce.Name}",
$"{GeometryNames.CurvFstName}, {unitCurvature.Name}",
$"{GeometryNames.CurvSndName}, {unitCurvature.Name}",
$"{GeometryNames.StrainTrdName}",
$"{crc}{GeometryNames.CurvFstName}, {unitCurvature.Name}",
$"{crc}{GeometryNames.CurvSndName}, {unitCurvature.Name}",
$"{crc}{GeometryNames.StrainTrdName}",
$"{crcFactor}Ix",
$"{crcFactor}Iy",
$"{crcFactor}Az",
$"PsiFactor"
};
}
} }
} }

View File

@@ -0,0 +1,89 @@
using StructureHelper.Windows.CalculationWindows.ProgressViews;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
internal class ShowProgressLogic
{
private ShowProgressViewModel progressViewModel;
private ShowProgressView wndProgress;
private bool result;
private string resultDescription;
private ILongProcessLogic processLogic;
public string WindowTitle { get; set; }
public void Show()
{
progressViewModel = new()
{
MinValue = 0,
MaxValue = processLogic.StepCount,
ProgressValue = 0,
WindowTitle = WindowTitle
};
wndProgress =new ShowProgressView(progressViewModel);
wndProgress.Loaded += RunCalc;
wndProgress.ShowDialog();
}
public Action ShowResult { get; set; }
public ShowProgressLogic(ILongProcessLogic processLogic)
{
this.processLogic = processLogic;
processLogic.SetProgress = ShowProgressResult;
}
public void ShowProgressResult(int progressValue)
{
progressViewModel.ProgressValue = progressValue;
}
private void RunCalc(object sender, RoutedEventArgs e)
{
BackgroundWorker worker = new();
worker.DoWork += processLogic.WorkerDoWork;
worker.ProgressChanged += WorkerProgressChanged;
worker.RunWorkerCompleted += WorkerRunWorkCompleted;
worker.RunWorkerAsync();
}
private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{
processLogic.WorkerProgressChanged(sender, e);
}
private void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
processLogic.WorkerRunWorkCompleted(sender, e);
wndProgress.Close();
result = processLogic.Result;
if (result == true)
{
ShowResult?.Invoke();
}
else
{
System.Windows.Forms.MessageBox.Show(resultDescription, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
throw;
}
}
}
}

View File

@@ -6,19 +6,23 @@ using StructureHelper.Services.Reports;
using StructureHelper.Services.Reports.CalculationReports; using StructureHelper.Services.Reports.CalculationReports;
using StructureHelper.Services.ResultViewers; using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews; using StructureHelper.Windows.CalculationWindows.CalculatorsViews;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews; using StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews;
using StructureHelper.Windows.Errors; using StructureHelper.Windows.Errors;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.PrimitivePropertiesWindow; using StructureHelper.Windows.PrimitivePropertiesWindow;
using StructureHelper.Windows.ViewModels.Calculations.Calculators.ForceResultLogic; using StructureHelper.Windows.ViewModels.Calculations.Calculators.ForceResultLogic;
using StructureHelper.Windows.ViewModels.Errors; using StructureHelper.Windows.ViewModels.Errors;
using StructureHelper.Windows.ViewModels.PrimitiveProperties; using StructureHelper.Windows.ViewModels.PrimitiveProperties;
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Forces; using StructureHelperCommon.Services.Forces;
using StructureHelperLogics.NdmCalculations.Analyses; using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Analyses.Geometry; using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations; using StructureHelperLogics.NdmCalculations.Triangulations;
@@ -32,11 +36,12 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{ {
public class ForcesResultsViewModel : ViewModelBase public class ForcesResultsViewModel : ViewModelBase
{ {
private static readonly ShowDiagramLogic showDiagramLogic = new(); private ShowDiagramLogic showDiagramLogic;
private static readonly InterpolateLogic interpolateLogic = new(); private ForceCalculator forceCalculator;
private ILongProcessLogic progressLogic;
private ShowProgressLogic showProgressLogic;
private static readonly ShowCrackResultLogic showCrackResultLogic = new(); private static readonly ShowCrackResultLogic showCrackResultLogic = new();
private static readonly ShowCrackWidthLogic showCrackWidthLogic = new(); private static readonly ShowCrackWidthLogic showCrackWidthLogic = new();
private IForceCalculator forceCalculator;
private IForcesResults forcesResults; private IForcesResults forcesResults;
private IEnumerable<INdmPrimitive> ndmPrimitives; private IEnumerable<INdmPrimitive> ndmPrimitives;
private IEnumerable<INdmPrimitive> selectedNdmPrimitives; private IEnumerable<INdmPrimitive> selectedNdmPrimitives;
@@ -101,7 +106,30 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{ {
get => showGraphsCommand ??= new RelayCommand(o => get => showGraphsCommand ??= new RelayCommand(o =>
{ {
showDiagramLogic.Show(forcesResults.ForcesResultList); InterpolateTuplesViewModel interploateTuplesViewModel;
InterpolateTuplesView wndTuples;
ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples);
if (wndTuples.DialogResult != true) return;
var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.Result);
showProgressLogic = new(interpolationLogic)
{
WindowTitle = "Interpolate forces"
};
showProgressLogic.Show();
var result = interpolationLogic.InterpolateCalculator.Result;
if (result is IForcesResults)
{
var tupleResult = result as IForcesResults;
var diagramLogic = new ShowDiagramLogic(tupleResult.ForcesResultList, ndmPrimitives);
showProgressLogic = new(diagramLogic)
{
ShowResult = diagramLogic.ShowWindow,
WindowTitle = "Calculate crack diagram"
};
showProgressLogic.Show();
}
} }
); );
} }
@@ -109,7 +137,30 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{ {
get => showCrackGraphsCommand ??= new RelayCommand(o => get => showCrackGraphsCommand ??= new RelayCommand(o =>
{ {
showDiagramLogic.ShowCracks(forcesResults.ForcesResultList, ndmPrimitives); InterpolateTuplesViewModel interploateTuplesViewModel;
InterpolateTuplesView wndTuples;
ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples);
if (wndTuples.DialogResult != true) return;
var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.Result);
showProgressLogic = new(interpolationLogic)
{
WindowTitle = "Interpolate forces"
};
showProgressLogic.Show();
var result = interpolationLogic.InterpolateCalculator.Result;
if (result is IForcesResults)
{
var tupleResult = result as IForcesResults;
var diagramLogic = new CrackDiagramLogic(tupleResult.ForcesResultList, ndmPrimitives);
showProgressLogic = new(diagramLogic)
{
ShowResult = diagramLogic.ShowWindow,
WindowTitle = "Calculate crack diagram"
};
showProgressLogic.Show();
}
} }
); );
} }
@@ -152,11 +203,45 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
return interpolateCommand ?? return interpolateCommand ??
(interpolateCommand = new RelayCommand(o => (interpolateCommand = new RelayCommand(o =>
{ {
IDesignForceTuple finishDesignTuple = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple; InterpolateCurrentTuple();
interpolateLogic.Show(finishDesignTuple, forceCalculator);
}, o => SelectedResult != null)); }, o => SelectedResult != null));
} }
} }
private void InterpolateCurrentTuple()
{
InterpolateTuplesViewModel interploateTuplesViewModel;
InterpolateTuplesView wndTuples;
ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples);
if (wndTuples.DialogResult != true) return;
var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.Result);
progressLogic = interpolationLogic;
showProgressLogic = new(interpolationLogic);
showProgressLogic.ShowResult = ShowInterpolationProgressDialog;
showProgressLogic.Show();
}
private void ShowInterpolationWindow(out InterpolateTuplesViewModel interploateTuplesViewModel, out InterpolateTuplesView wndTuples)
{
IDesignForceTuple finishDesignTuple = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple;
interploateTuplesViewModel = new InterpolateTuplesViewModel(finishDesignTuple, null);
wndTuples = new InterpolateTuplesView(interploateTuplesViewModel);
wndTuples.ShowDialog();
}
private void ShowInterpolationProgressDialog()
{
if (progressLogic is InterpolationProgressLogic)
{
var interpolationLogic = progressLogic as InterpolationProgressLogic;
var calculator = interpolationLogic.InterpolateCalculator;
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
}
}
public ICommand SetPrestrainCommand public ICommand SetPrestrainCommand
{ {
get get
@@ -243,11 +328,11 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
} }
} }
} }
public ForcesResultsViewModel(IForceCalculator forceCalculator) public ForcesResultsViewModel(ForceCalculator forceCalculator)
{ {
this.forceCalculator = forceCalculator; this.forceCalculator = forceCalculator;
this.forcesResults = this.forceCalculator.Result as IForcesResults; forcesResults = forceCalculator.Result as IForcesResults;
ndmPrimitives = this.forceCalculator.Primitives; ndmPrimitives = forceCalculator.Primitives;
} }
private void ShowIsoField() private void ShowIsoField()
{ {

View File

@@ -83,7 +83,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
} }
else else
{ {
var calculator = SelectedItem as IForceCalculator; var calculator = SelectedItem as ForceCalculator;
var vm = new ForcesResultsViewModel(calculator); var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm); var wnd = new ForceResultsView(vm);
wnd.ShowDialog(); wnd.ShowDialog();

View File

@@ -0,0 +1,22 @@
using StructureHelperCommon.Models.Calculators;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface ILongProcessLogic
{
int StepCount { get; }
Action<int> SetProgress { get; set; }
bool Result { get; set; }
void WorkerDoWork(object sender, DoWorkEventArgs e);
void WorkerProgressChanged(object sender, ProgressChangedEventArgs e);
void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e);
}
}

View File

@@ -0,0 +1,9 @@
namespace StructureHelperCommon.Models.Forces
{
public class InterpolateTuplesResult
{
public IDesignForceTuple StartTuple { get; set; }
public IDesignForceTuple FinishTuple { get; set; }
public int StepCount { get; set; }
}
}

View File

@@ -0,0 +1,59 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Services.NdmCalculations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
{
public class InterpolationProgressLogic : ILongProcessLogic
{
private ForceCalculator forceCalculator;
private InterpolateTuplesResult interpolateTuplesResult;
public Action<int> SetProgress { get; set; }
public ForceCalculator InterpolateCalculator { get; private set; }
public bool Result { get; set; }
public int StepCount => interpolateTuplesResult.StepCount + 1;
public void WorkerDoWork(object sender, DoWorkEventArgs e)
{
InterpolateCalculator = InterpolateService.InterpolateForceCalculator(forceCalculator, interpolateTuplesResult);
InterpolateCalculator.ActionToOutputResults = ShowProgressResult;
InterpolateCalculator.Run();
}
public void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{
//nothing to do
}
public void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//nothing to do
}
public InterpolationProgressLogic(ForceCalculator forceCalculator, InterpolateTuplesResult interpolateTuplesResult)
{
this.forceCalculator = forceCalculator;
this.interpolateTuplesResult = interpolateTuplesResult;
}
private void ShowProgressResult(IResult result)
{
if (result is ForcesResults)
{
var forceResult = result as ForcesResults;
SetProgress?.Invoke(forceResult.ForcesResultList.Count());
Result = forceResult.IsValid;
}
}
}
}

View File

@@ -8,18 +8,18 @@ namespace StructureHelperLogics.Services.NdmCalculations
public static class InterpolateService public static class InterpolateService
{ {
static readonly CompressedMemberUpdateStrategy compressedMemberUpdateStrategy = new(); static readonly CompressedMemberUpdateStrategy compressedMemberUpdateStrategy = new();
public static IForceCalculator InterpolateForceCalculator(IForceCalculator source, IDesignForceTuple finishDesignForce,IDesignForceTuple startDesignForce, int stepCount) public static ForceCalculator InterpolateForceCalculator(IForceCalculator source, InterpolateTuplesResult interpolateTuplesResult)
{ {
IForceCalculator calculator = new ForceCalculator(); ForceCalculator calculator = new ForceCalculator();
calculator.LimitStatesList.Clear(); calculator.LimitStatesList.Clear();
calculator.LimitStatesList.Add(finishDesignForce.LimitState); calculator.LimitStatesList.Add(interpolateTuplesResult.StartTuple.LimitState);
calculator.CalcTermsList.Clear(); calculator.CalcTermsList.Clear();
calculator.CalcTermsList.Add(finishDesignForce.CalcTerm); calculator.CalcTermsList.Add(interpolateTuplesResult.FinishTuple.CalcTerm);
compressedMemberUpdateStrategy.Update(calculator.CompressedMember, source.CompressedMember); compressedMemberUpdateStrategy.Update(calculator.CompressedMember, source.CompressedMember);
calculator.Accuracy = source.Accuracy; calculator.Accuracy = source.Accuracy;
calculator.Primitives.AddRange(source.Primitives); calculator.Primitives.AddRange(source.Primitives);
calculator.ForceActions.Clear(); calculator.ForceActions.Clear();
var forceTuples = ForceTupleService.InterpolateDesignTuple(finishDesignForce, startDesignForce, stepCount); var forceTuples = ForceTupleService.InterpolateDesignTuple(interpolateTuplesResult.FinishTuple, interpolateTuplesResult.StartTuple, interpolateTuplesResult.StepCount);
foreach (var forceTuple in forceTuples) foreach (var forceTuple in forceTuples)
{ {
var combination = new ForceCombinationList() var combination = new ForceCombinationList()