Icons for force result were added

This commit is contained in:
Evgeny Redikultsev
2023-11-26 20:33:48 +05:00
parent b4b1720c70
commit 01e6f97429
41 changed files with 678 additions and 273 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,125 @@
using LoaderCalculator.Data.Ndms;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services.NdmPrimitives;
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
{
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 static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public int StepCount { get; }
public Action<int> SetProgress { get; set; }
public bool Result { get; set; }
public IEnumerable<INdmPrimitive> NdmPrimitives { get; set; }
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
public ForceTuple ForceTuple { get; set; }
private void Show()
{
var options = new TriangulationOptions() { LimiteState = LimitState, CalcTerm = CalcTerm };
var ndmCollection = NdmPrimitives.SelectMany(x => x.GetNdms(options));
//var ndmCollection = NdmPrimitivesService.GetNdms(NdmPrimitives, LimitState, CalcTerm);
var predicateFactory = new PredicateFactory()
{
My = ForceTuple.My,
Ndms = ndmCollection
};
Predicate<IPoint2D> predicate = predicateFactory.GetResult;
//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.Run();
var 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");
string[] labels = GetLabels(unitForce, unitMoment);
var items = interactionResult.Points;
arrayParameter = new ArrayParameter<double>(items.Count(), labels.Count(), labels);
var data = arrayParameter.Data;
for (int i = 0; i < items.Count(); i++)
{
var valueList = new List<double>
{
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 static string[] GetLabels(IUnit unitForce, IUnit unitMoment)
{
return new string[]
{
$"{GeometryNames.MomFstName}, {unitMoment.Name}",
$"{GeometryNames.LongForceName}, {unitForce.Name}"
};
}
public void ShowWindow()
{
Show();
Result = true;
SafetyProcessor.RunSafeProcess(() =>
{
var wnd = new GraphView(arrayParameter);
wnd.ShowDialog();
},
"Errors appeared during showing a graph, see detailed information");
}
public void WorkerDoWork(object sender, DoWorkEventArgs e)
{
Show();
Result = true;
}
public void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{
//nothing to do
}
public void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//nothing to do
}
}
}

View File

@@ -0,0 +1,84 @@
using StructureHelper.Windows.Errors;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmPrimitives;
using System.Collections.Generic;
using System.Windows.Forms;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
internal class ShowCrackResultLogic
{
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
public ForceTuple ForceTuple { get; set; }
public IEnumerable<INdmPrimitive> ndmPrimitives { get; set; }
public void Show(IDesignForceTuple finishDesignTuple)
{
var viewModel = new InterpolateTuplesViewModel(finishDesignTuple, null);
viewModel.StepCountVisible = false;
var wndTuples = new InterpolateTuplesView(viewModel);
wndTuples.ShowDialog();
if (wndTuples.DialogResult != true) return;
var startDesignTuple = viewModel.StartDesignForce.ForceTuple;
var endDesignTuple = viewModel.FinishDesignForce.ForceTuple;
FindCrackFactor(endDesignTuple, startDesignTuple);
}
private void FindCrackFactor(ForceTuple finishDesignTuple, ForceTuple startDesignTuple)
{
var calculator = new CrackForceCalculator();
calculator.StartTuple = startDesignTuple;
calculator.EndTuple = finishDesignTuple;
calculator.NdmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, LimitState, CalcTerm);
calculator.Run();
var result = (CrackForceResult)calculator.Result;
if (result.IsValid)
{
ShowResult(result);
}
else
{
ShowError(result);
}
}
private static void ShowError(CrackForceResult result)
{
var errorVM = new ErrorProcessor()
{
ShortText = "Error apeared while crack calculate",
DetailText = result.Description
};
var wnd = new ErrorMessage(errorVM);
wnd.ShowDialog();
}
private static void ShowResult(CrackForceResult result)
{
//var softLogic = new ExponentialSofteningLogic() { ForceRatio = result.ActualFactor };
string message = string.Empty;
if (result.IsSectionCracked)
{
message += $"Actual crack factor {result.FactorOfCrackAppearance}\n";
message += $"Softening crack factor PsiS={result.PsiS}\n";
message += $"{GeometryNames.MomFstName}={result.TupleOfCrackAppearance.Mx},\n {GeometryNames.MomSndName}={result.TupleOfCrackAppearance.My},\n {GeometryNames.LongForceName}={result.TupleOfCrackAppearance.Nz}";
}
else
{
message += "Cracks are not apeared";
}
MessageBox.Show(
message,
"Crack results",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
}

View File

@@ -0,0 +1,35 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
internal class ShowCrackWidthLogic
{
public List<INdmPrimitive> ndmPrimitives { get; set; }
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
public ForceTuple ForceTuple { get; set; }
internal void Show()
{
var inputData = new CrackWidthCalculatorInputData()
{
LimitState = LimitState,
CalcTerm = CalcTerm,
ForceTuple = ForceTuple,
NdmPrimitives = ndmPrimitives
};
var calculator = new CrackWidthCalculator() { InputData = inputData };
calculator.Run();
var result = calculator.Result;
}
}
}

View File

@@ -0,0 +1,115 @@
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.Primitives;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
internal class ShowDiagramLogic : ILongProcessLogic
{
ArrayParameter<double> arrayParameter;
private IEnumerable<IForcesTupleResult> TupleList;
private IEnumerable<INdmPrimitive> NdmPrimitives;
private List<IForcesTupleResult> ValidTupleList;
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public int StepCount => ValidTupleList.Count();
public Action<int> SetProgress { get; set; }
public bool Result { get; set; }
public void WorkerDoWork(object sender, DoWorkEventArgs e)
{
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 unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
string[] labels = GetLabels(unitForce, unitMoment, unitCurvature);
arrayParameter = new ArrayParameter<double>(ValidTupleList.Count(), labels.Count(), labels);
CalculateWithoutCrack(ValidTupleList, unitForce, unitMoment, unitCurvature);
}
public ShowDiagramLogic(IEnumerable<IForcesTupleResult> tupleList, IEnumerable<INdmPrimitive> ndmPrimitives)
{
TupleList = tupleList;
NdmPrimitives = ndmPrimitives;
ValidTupleList = TupleList.Where(x => x.IsValid == true).ToList();
}
private void CalculateWithoutCrack(List<IForcesTupleResult> resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
var data = arrayParameter.Data;
for (int i = 0; i < resultList.Count(); i++)
{
var valueList = ProcessResultWithouCrack(resultList, unitForce, unitMoment, unitCurvature, i);
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
SetProgress?.Invoke(i);
}
}
private static List<double> ProcessResultWithouCrack(List<IForcesTupleResult> resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature, int i)
{
return new List<double>
{
resultList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer,
resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer,
resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer,
resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ
};
}
private static string[] GetLabels(IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
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}"
};
}
}
}

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.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
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

@@ -4,16 +4,25 @@
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"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators"
d:DataContext="{d:DesignInstance vm:ForcesResultsViewModel}"
d:DataContext="{d:DesignInstance local:ForcesResultsViewModel}"
mc:Ignorable="d"
Title="Calculation Results" Height="350" Width="850" MinHeight="300" MinWidth="400" WindowStartupLocation="CenterScreen">
<DockPanel>
<ToolBarTray DockPanel.Dock="Top">
<ToolBar>
<Button Style="{StaticResource ToolButton}"
Command="{Binding ShowCrackResultCommand}"
Content="Fcrc" ToolTip="Calc crack forces"/>
<Button Command="{Binding ShowCrackResultCommand}" ToolTip="Show force of cracking">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/32px_crack.png"/>
</Button>
<Button Command="{Binding InterpolateCommand}" ToolTip="Show result step by step">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/32px_interpolation_1_1.png"/>
</Button>
<Button Command="{Binding ShowGraphsCommand}" ToolTip="Show diagram moment-curvature">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/32px_graph_2.png"/>
</Button>
<Button Command="{Binding ShowInteractionDiagramCommand}" ToolTip="Show interaction diagram">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/32px_graph_1.png"/>
</Button>
</ToolBar>
</ToolBarTray>
<Grid>
@@ -48,14 +57,11 @@
</DataGrid>
<StackPanel Grid.Column="1">
<Button Margin="3" Content="Graphic" ToolTip="Show graphic results" Command="{Binding ShowIsoFieldCommand}"/>
<Button Margin="3" Content="Diagrams" ToolTip="Show diagrams" Command="{Binding ShowGraphsCommand}"/>
<Button Margin="3" Content="CrcDiagrams" ToolTip="Show diagrams for cracked section" Command="{Binding ShowCrackGraphsCommand}"/>
<Button Margin="3" Content="Interpolate" ToolTip="Create analysis by substep" Command="{Binding InterpolateCommand}"/>
<Button Margin="3" Content="Export" ToolTip="Export results to *.csv" Command="{Binding ExportToCSVCommand}"/>
<Button Margin="3" Content="Set Prestrain" ToolTip="Set strains as auto prestrain" Command="{Binding SetPrestrainCommand}"/>
<Button Margin="3" Content="Anchorage" ToolTip="Set strains as auto prestrain" Command="{Binding ShowAnchorageCommand}"/>
<Button Margin="3" Content="Geometry" ToolTip="Show Geometry Properties" Command="{Binding ShowGeometryResultCommand}"/>
<Button Margin="3" Content="Fcrc" ToolTip="Show crack force" Command="{Binding ShowCrackResultCommand}"/>
<Button Margin="3" Content="Acrc" ToolTip="Show crack width" Command="{Binding ShowCrackWidthResultCommand}"/>
</StackPanel>
</Grid>

View File

@@ -1,5 +1,4 @@
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

View File

@@ -0,0 +1,413 @@
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using StructureHelper.Infrastructure;
using StructureHelper.Services.Exports;
using StructureHelper.Services.Reports;
using StructureHelper.Services.Reports.CalculationReports;
using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculatorViews;
using StructureHelper.Windows.Errors;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.PrimitivePropertiesWindow;
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelper.Windows.ViewModels.PrimitiveProperties;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Forces;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
public class ForcesResultsViewModel : ViewModelBase
{
private ShowDiagramLogic showDiagramLogic;
private ForceCalculator forceCalculator;
private ILongProcessLogic progressLogic;
private ShowProgressLogic showProgressLogic;
private InteractionDiagramLogic interactionDiagramLogic = new();
private static readonly ShowCrackResultLogic showCrackResultLogic = new();
private static readonly ShowCrackWidthLogic showCrackWidthLogic = new();
private IForcesResults forcesResults;
private IEnumerable<INdmPrimitive> ndmPrimitives;
private IEnumerable<INdmPrimitive> selectedNdmPrimitives;
private IEnumerable<INdm> ndms;
private IReport isoFieldReport;
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;
public IForcesResults ForcesResults
{
get => forcesResults;
}
public ICommand ShowInteractionDiagramCommand
{
get
{
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();
}, o => SelectedResult != null && SelectedResult.IsValid));
}
}
public ICommand ShowIsoFieldCommand
{
get
{
return showIsoFieldCommand ??
(showIsoFieldCommand = new RelayCommand(o =>
{
if (SelectPrimitives() == true)
{
ShowIsoField();
}
}, o => SelectedResult != null && SelectedResult.IsValid));
}
}
public ICommand ExportToCSVCommand
{
get
{
return exportToCSVCommand ??
(exportToCSVCommand = new RelayCommand(o =>
{
ExportToCSV();
}
));
}
}
private void ExportToCSV()
{
var inputData = new ExportToFileInputData();
inputData.FileName = "New File";
inputData.Filter = "csv |*.csv";
inputData.Title = "Save in csv File";
var logic = new ExportForceResultToCSVLogic(forcesResults);
var exportService = new ExportToFileService(inputData, logic);
exportService.Export();
}
public ICommand ShowGraphsCommand
{
get => showGraphsCommand ??= new RelayCommand(o =>
{
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();
}
}
);
}
public ICommand ShowCrackGraphsCommand
{
get => showCrackGraphsCommand ??= new RelayCommand(o =>
{
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();
}
}
);
}
public ICommand ShowCrackResultCommand
{
get => showCrackResult ??= new RelayCommand(o =>
{
SafetyProcessor.RunSafeProcess(ShowCrackResult);
}, o => SelectedResult != null && SelectedResult.IsValid);
}
private void ShowCrackResult()
{
showCrackResultLogic.LimitState = SelectedResult.DesignForceTuple.LimitState;
showCrackResultLogic.CalcTerm = CalcTerms.ShortTerm; //= SelectedResult.DesignForceTuple.CalcTerm;
showCrackResultLogic.ForceTuple = SelectedResult.DesignForceTuple.ForceTuple;
showCrackResultLogic.ndmPrimitives = ndmPrimitives;
showCrackResultLogic.Show(SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple);
}
public ICommand ShowCrackWidthResultCommand
{
get => showCrackWidthResult ??= new RelayCommand(o =>
{
SafetyProcessor.RunSafeProcess(ShowCrackWidthResult);
}, o => SelectedResult != null && SelectedResult.IsValid);
}
private void ShowCrackWidthResult()
{
showCrackWidthLogic.LimitState = SelectedResult.DesignForceTuple.LimitState;
showCrackWidthLogic.CalcTerm = SelectedResult.DesignForceTuple.CalcTerm;
showCrackWidthLogic.ForceTuple = SelectedResult.DesignForceTuple.ForceTuple;
showCrackWidthLogic.ndmPrimitives = ndmPrimitives.ToList();
showCrackWidthLogic.Show();
}
public ICommand InterpolateCommand
{
get
{
return interpolateCommand ??
(interpolateCommand = new RelayCommand(o =>
{
InterpolateCurrentTuple();
}, 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
{
get
{
return setPrestrainCommand ??
(setPrestrainCommand = new RelayCommand(o =>
{
SetPrestrain();
}, o => SelectedResult != null
));
}
}
private void SetPrestrain()
{
var source = TupleConverter.ConvertToStrainTuple(SelectedResult.LoaderResults.StrainMatrix);
var vm = new SetPrestrainViewModel(source);
var wnd = new SetPrestrainView(vm);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
foreach (var item in ndmPrimitives)
{
ForceTupleService.CopyProperties(wnd.StrainTuple, item.AutoPrestrain);
}
}
}
public ICommand ShowAnchorageCommand
{
get
{
return showAnchorageCommand ??
(showAnchorageCommand = new RelayCommand(o =>
{
showAnchorage();
}, o => SelectedResult != null && SelectedResult.IsValid
));
}
}
private void showAnchorage()
{
try
{
var strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix;
var limitState = SelectedResult.DesignForceTuple.LimitState;
var calcTerm = SelectedResult.DesignForceTuple.CalcTerm;
var primitiveSets = ShowAnchorageResult.GetPrimitiveSets(strainMatrix, limitState, calcTerm, ndmPrimitives);
isoFieldReport = new IsoFieldReport(primitiveSets);
isoFieldReport.Show();
}
catch (Exception ex)
{
var vm = new ErrorProcessor()
{
ShortText = "Errors apearred during showing isofield, see detailed information",
DetailText = $"{ex}"
};
new ErrorMessage(vm).ShowDialog();
}
}
public ICommand ShowGeometryResultCommand =>
showGeometryResultCommand ??= new RelayCommand(o =>
showGeometryResult(), o => SelectedResult != null && SelectedResult.IsValid);
private void showGeometryResult()
{
if (SelectPrimitives() == true)
{
try
{
var strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix;
var textParametrsLogic = new TextParametersLogic(ndms, strainMatrix);
var calculator = new GeometryCalculator(textParametrsLogic);
calculator.Run();
var result = calculator.Result as IGeometryResult;
var wnd = new GeometryCalculatorResultView(result);
wnd.ShowDialog();
}
catch (Exception ex)
{
var vm = new ErrorProcessor()
{
ShortText = "Errors apearred during showing isofield, see detailed information",
DetailText = $"{ex}"
};
new ErrorMessage(vm).ShowDialog();
}
}
}
public ForcesResultsViewModel(ForceCalculator forceCalculator)
{
this.forceCalculator = forceCalculator;
forcesResults = forceCalculator.Result as IForcesResults;
ndmPrimitives = forceCalculator.Primitives;
}
private void ShowIsoField()
{
try
{
IStrainMatrix strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix;
var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ResultFuncFactory.GetResultFuncs());
isoFieldReport = new IsoFieldReport(primitiveSets);
isoFieldReport.Show();
}
catch (Exception ex)
{
var vm = new ErrorProcessor()
{
ShortText = "Errors apearred during showing isofield, see detailed information",
DetailText = $"{ex}"
};
new ErrorMessage(vm).ShowDialog();
}
}
private void GetNdms()
{
var limitState = SelectedResult.DesignForceTuple.LimitState;
var calcTerm = SelectedResult.DesignForceTuple.CalcTerm;
var triangulationOptions = new TriangulationOptions() { LimiteState = limitState, CalcTerm = calcTerm };
var orderedNdmPrimitives = ndmPrimitives.OrderBy(x => x.VisualProperty.ZIndex);
var ndmRange = new List<INdm>();
foreach (var item in orderedNdmPrimitives)
{
if (item is IHasDivisionSize)
{
var hasDivision = item as IHasDivisionSize;
if (hasDivision.ClearUnderlying == true)
{
ndmRange.RemoveAll(x => hasDivision.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true);
}
}
if (selectedNdmPrimitives.Contains(item) & item.Triangulate == true)
{
ndmRange.AddRange(item.GetNdms(triangulationOptions));
}
}
ndms = ndmRange;
}
private bool SelectPrimitives()
{
var vm = new SelectPrimitivesViewModel(ndmPrimitives);
var wnd = new SelectPrimitivesView(vm);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive());
GetNdms();
return true;
}
return false;
}
}
}