Value point diagram was repaired

This commit is contained in:
Evgeny Redikultsev
2024-03-23 20:27:37 +05:00
parent f2f6840ffb
commit f11b97de38
14 changed files with 428 additions and 231 deletions

View File

@@ -55,7 +55,7 @@
<Style TargetType="Image">
<Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="32"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Margin" Value="-2"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Style.Triggers>
@@ -69,7 +69,7 @@
<Setter Property="Height" Value="32"/>
<Setter Property="Margin" Value="2,0,2,0"/>
<Setter Property="Background" Value="#FFA19BC3"/>
<Setter Property="BorderBrush" Value="#FF857AB9"/>
<Setter Property="BorderBrush" Value="Black"/>
</Style>
<Style x:Key="ButtonImage16" TargetType="Image">

View File

@@ -43,7 +43,14 @@
<Button Content="Invert Selection" Command="{Binding InvertSelectionCommand}"/>
</StackPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Visible">
<ListBox ItemsSource="{Binding CollectionItems}" SelectedItem="SelectedItem">
<ListBox ItemsSource="{Binding CollectionItems}" SelectedItem="SelectedItem" HorizontalAlignment="Stretch">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Select All" Command="{Binding SelectAllCommand}"/>
<MenuItem Header="UnSelect All" Command="{Binding UnSelectAllCommand}"/>
<MenuItem Header="Unvert Selection" Command="{Binding InvertSelectionCommand}"/>
</ContextMenu>
</ListBox.ContextMenu>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>

View File

@@ -10,12 +10,18 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
/// <summary>
/// Create array of common values
/// </summary>
public class DiagramFactory
{
private ArrayParameter<double> arrayParameter;
/// <summary>
/// Collection of force results
/// </summary>
public List<IForcesTupleResult> TupleList { get; set; }
public Action<int> SetProgress { get; set; }
//public Action<int> SetProgress { get; set; }
public ArrayParameter<double> GetCommonArray()
{
@@ -35,7 +41,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
data[i, j] = valueList[j];
}
SetProgress?.Invoke(i);
//SetProgress?.Invoke(i);
}
}

View File

@@ -0,0 +1,18 @@
using StructureHelper.Windows.Forces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Parameters;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System.Collections.Generic;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
{
public interface IValuePointDiagramLogic
{
ForceCalculator Calculator { get; set; }
PointPrimitiveLogic PrimitiveLogic { get; set; }
IEnumerable<IForcesTupleResult> TupleList { get; set; }
ValueDelegatesLogic ValueDelegatesLogic { get; set; }
GenericResult<ArrayParameter<double>> GetArrayParameter();
}
}

View File

@@ -0,0 +1,86 @@
using StructureHelper.Windows.Forces;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
{
public class InterpolateValuePointsLogic
{
private InterpolationProgressLogic interpolationLogic;
private ValuePointsInterpolateViewModel viewModel;
private IResult result;
private ValuePointsInterpolationInputData inputData;
public ForcesTupleResult SelectedResult { get; set; }
public IEnumerable<INdmPrimitive> NdmPrimitives { get; set; }
public ForceCalculator ForceCalculator { get; set; }
public ILongProcessLogic ProgressLogic { get; set; }
public ShowProgressLogic ShowProgressLogic { get; set; }
public void InterpolateValuePoints()
{
var tuple = SelectedResult.DesignForceTuple ?? throw new StructureHelperException(ErrorStrings.NullReference + ": Design force combination");
PrepareInputData(tuple);
viewModel = new ValuePointsInterpolateViewModel(inputData);
if (ShowDialog() == false) { return; };
ShowDiagram(result);
}
private void PrepareInputData(IDesignForceTuple tuple)
{
inputData = new ValuePointsInterpolationInputData()
{
FinishDesignForce = tuple.Clone() as IDesignForceTuple,
LimitState = tuple.LimitState,
CalcTerm = tuple.CalcTerm,
};
inputData.PrimitiveBases.AddRange(PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(NdmPrimitives));
}
private bool ShowDialog()
{
var wnd = new ValuePointsInterpolateView(viewModel);
wnd.ShowDialog();
if (wnd.DialogResult != true) { return false; }
interpolationLogic = new InterpolationProgressLogic(ForceCalculator, viewModel.ForceInterpolationViewModel.Result);
ProgressLogic = interpolationLogic;
ShowProgressLogic = new(interpolationLogic)
{
WindowTitle = "Interpolate forces",
};
ShowProgressLogic.Show();
result = interpolationLogic.InterpolateCalculator.Result;
return true;
}
private void ShowDiagram(IResult result)
{
if (result.IsValid == false) { return; }
if (result is not IForcesResults)
{
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(IForcesResults), result));
}
var tupleResult = result as IForcesResults;
var pointGraphLogic = new ShowValuePointDiagramLogic()
{
Calculator = interpolationLogic.InterpolateCalculator,
PrimitiveLogic = viewModel.PrimitiveLogic,
ValueDelegatesLogic = viewModel.ValueDelegatesLogic,
TupleList = tupleResult.ForcesResultList
};
pointGraphLogic.ShowWindow();
}
}
}

View File

@@ -61,7 +61,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
var factory = new DiagramFactory()
{
TupleList = validTupleList,
SetProgress = SetProgress,
//SetProgress = SetProgress,
};
arrayParameter = factory.GetCommonArray();
}

View File

@@ -12,7 +12,7 @@ using System.Windows.Forms;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
internal class ShowProgressLogic
public class ShowProgressLogic
{
private ShowProgressViewModel progressViewModel;
private ShowProgressView wndProgress;

View File

@@ -1,6 +1,8 @@
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderCalculator.Data.Ndms;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
@@ -8,6 +10,7 @@ using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Models.Shapes;
@@ -20,128 +23,43 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
public class ShowValuePointDiagramLogic : ILongProcessLogic
public class ShowValuePointDiagramLogic //: ILongProcessLogic
{
private ArrayParameter<double> arrayParameter;
private IEnumerable<IForcesTupleResult> tupleList;
private IEnumerable<INdmPrimitive> ndmPrimitives;
private List<IForcesTupleResult> validTupleList;
private List<(PrimitiveBase PrimitiveBase, List<INamedAreaPoint> namedPoints)> valuePoints;
private List<IResultFunc> resultFuncList;
private IValuePointDiagramLogic pointDiagramLogic;
public IEnumerable<IForcesTupleResult> TupleList { get; set; }
public ForceCalculator Calculator { get; set; }
public PointPrimitiveLogic PrimitiveLogic { get; set; }
public ValueDelegatesLogic ValueDelegatesLogic { get; set; }
public int StepCount => throw new NotImplementedException();
//public int StepCount => throw new NotImplementedException();
public Action<int> SetProgress { get; set; }
public bool Result { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public ShowValuePointDiagramLogic(IEnumerable<IForcesTupleResult> tupleList, IEnumerable<INdmPrimitive> ndmPrimitives)
//public Action<int> SetProgress { get; set; }
//public bool Result { get; set; }
//public IShiftTraceLogger? TraceLogger { get; set; }
public ShowValuePointDiagramLogic(IValuePointDiagramLogic pointDiagramLogic)
{
this.tupleList = tupleList;
this.ndmPrimitives = ndmPrimitives;
validTupleList = this.tupleList.Where(x => x.IsValid == true).ToList();
valuePoints = new List<(PrimitiveBase PrimitiveBase, List<INamedAreaPoint>)>();
this.pointDiagramLogic = pointDiagramLogic;
}
public void SetParameters()
public ShowValuePointDiagramLogic() : this(new ValuePointDiagramLogic())
{
var factory = new DiagramFactory()
{
TupleList = validTupleList,
SetProgress = SetProgress,
};
arrayParameter = factory.GetCommonArray();
foreach (var item in PrimitiveLogic.Collection.CollectionItems)
{
var pointsCount = item.Item.ValuePoints.SelectedCount;
if (pointsCount > 0)
{
var points = item.Item.ValuePoints.SelectedItems.ToList();
var primitive = item.Item.PrimitiveBase;
valuePoints.Add((primitive, points));
}
}
var selectedDelegates = ValueDelegatesLogic.ResultFuncs.SelectedItems;
if (selectedDelegates.Count() == 0) { return; }
var labels = GetLabels(valuePoints, selectedDelegates);
var pointCount = valuePoints.Sum(x => x.namedPoints.Count());
List<double> values = new();
var tuplesList = tupleList
.Where(x => x.IsValid == true)
.ToList();
var newArray = new ArrayParameter<double>(tuplesList.Count(), labels);
for (int i = 0; i < tuplesList.Count(); i++)
{
var strainMatrix = tuplesList[i].LoaderResults.ForceStrainPair.StrainMatrix;
values.Clear();
foreach (var valuePoint in valuePoints)
{
foreach (var point in valuePoint.namedPoints)
{
var limitState = tuplesList[i].DesignForceTuple.LimitState;
var calcTerm = tuplesList[i].DesignForceTuple.CalcTerm;
var ndm = GetNdm(valuePoint, point, limitState, calcTerm);
foreach (var valDelegate in selectedDelegates)
{
double val = valDelegate.ResultFunction.Invoke(strainMatrix, ndm) * valDelegate.UnitFactor;
values.Add(val);
}
}
}
newArray.AddRow(i, values);
}
arrayParameter.AddArray(newArray);
}
private List<string> GetLabels(List<(PrimitiveBase PrimitiveBase, List<INamedAreaPoint> namedPoints)> valuePoints, IEnumerable<IResultFunc> selectedDelegates)
{
List<string> strings = new();
foreach (var valuePoint in valuePoints)
{
foreach (var item in valuePoint.namedPoints)
{
foreach (var deleg in selectedDelegates)
{
string s = valuePoint.PrimitiveBase.Name;
s += "_" + item.Name;
s += "_" + deleg.Name + ", " + deleg.UnitName;
strings.Add(s);
}
}
}
return strings;
}
private static RebarNdm GetNdm((PrimitiveBase PrimitiveBase, List<INamedAreaPoint> namedPoints) valuePoint, INamedAreaPoint point, LimitStates limitState, CalcTerms calcTerm)
{
var ndmPrimitive = valuePoint.PrimitiveBase.GetNdmPrimitive();
var material = ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
var userPrestrain = ndmPrimitive.UsersPrestrain;
var autoPrestrain = ndmPrimitive.AutoPrestrain;
var ndm = new RebarNdm()
{
Area = point.Area,
CenterX = point.Point.X,
CenterY = point.Point.Y,
Material = material,
};
ndm.Prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * point.Point.Y
+ (userPrestrain.My + autoPrestrain.My) * point.Point.X
+ userPrestrain.Nz + autoPrestrain.Nz;
return ndm;
}
public void ShowWindow()
{
var result = GetResult();
if (result.IsValid != true)
{
SafetyProcessor.ShowMessage(ErrorStrings.DataIsInCorrect, result.Description);
return;
}
arrayParameter = result.Value;
SafetyProcessor.RunSafeProcess(() =>
{
var series = new Series(arrayParameter)
@@ -157,39 +75,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
}, ErrorStrings.ErrorDuring("building chart"));
}
public void WorkerDoWork(object sender, DoWorkEventArgs e)
private GenericResult<ArrayParameter<double>> GetResult()
{
Show();
Result = true;
}
public void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{
//Nothing to do
}
public void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//Nothing to do
}
private void Show()
{
validTupleList = tupleList.Where(x => x.IsValid == true).ToList();
var factory = new DiagramFactory()
{
TupleList = validTupleList,
SetProgress = SetProgress,
};
arrayParameter = factory.GetCommonArray();
}
private List<string> GetColumnNames()
{
var columnNames = LabelsFactory.GetCommonLabels();
return columnNames;
pointDiagramLogic.TupleList = TupleList;
pointDiagramLogic.PrimitiveLogic = PrimitiveLogic;
pointDiagramLogic.Calculator = Calculator;
pointDiagramLogic.ValueDelegatesLogic = ValueDelegatesLogic;
var results = pointDiagramLogic.GetArrayParameter();
return results;
}
}
}

View File

@@ -0,0 +1,173 @@
using LoaderCalculator.Data.Ndms;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.Forces;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Parameters;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
{
public class ValuePointDiagramLogic : IValuePointDiagramLogic
{
private ArrayParameter<double> arrayParameter;
private List<(INamedAreaPoint areaPoint, INdmPrimitive ndmPrimitive)> pointCollection;
private List<IForcesTupleResult> validTuplesList;
private ArrayParameter<double> arrayOfValuesByPoint;
private IEnumerable<IResultFunc> selectedDelegates;
private string exceptionMessage;
public IEnumerable<IForcesTupleResult> TupleList { get; set; }
public ForceCalculator Calculator { get; set; }
public PointPrimitiveLogic PrimitiveLogic { get; set; }
public ValueDelegatesLogic ValueDelegatesLogic { get; set; }
public GenericResult<ArrayParameter<double>> GetArrayParameter()
{
SetParameters();
var checkResult = CheckParameters();
if (checkResult != true)
{
return GetFalseResult();
}
PrepareArray();
return GetValidResult();
}
private GenericResult<ArrayParameter<double>> GetValidResult()
{
int i = 0;
foreach (var tuple in validTuplesList)
{
ProcessPointByTuple(tuple, i);
i++;
}
arrayParameter.AddArray(arrayOfValuesByPoint);
return new GenericResult<ArrayParameter<double>>()
{
IsValid = true,
Value = arrayParameter
};
}
private GenericResult<ArrayParameter<double>> GetFalseResult()
{
return new GenericResult<ArrayParameter<double>>()
{
IsValid = false,
Description = exceptionMessage
};
}
private void SetParameters()
{
GetPointCollection();
selectedDelegates = ValueDelegatesLogic.ResultFuncs.SelectedItems;
validTuplesList = TupleList
.Where(x => x.IsValid == true)
.ToList();
}
private bool CheckParameters()
{
var result = true;
exceptionMessage = ErrorStrings.DataIsInCorrect;
if (pointCollection.Any() == false)
{
exceptionMessage += ", point collection is null";
result = false;
}
if (selectedDelegates.Any() == false)
{
exceptionMessage += ", value expression collection is null";
result = false;
}
if (validTuplesList.Any() == false)
{
exceptionMessage += ", force list is empty";
result = false;
}
return result;
}
private void GetPointCollection()
{
pointCollection = new();
foreach (var primitiveValuePoint in PrimitiveLogic.Collection.CollectionItems)
{
foreach (var selectedPoint in primitiveValuePoint.Item.ValuePoints.SelectedItems)
{
var newPoint = (selectedPoint, primitiveValuePoint.Item.PrimitiveBase.GetNdmPrimitive());
pointCollection.Add(newPoint);
}
}
}
private void ProcessPointByTuple(IForcesTupleResult tuple, int i)
{
var values = new List<double>();
var strainMatrix = tuple.LoaderResults.ForceStrainPair.StrainMatrix;
foreach (var valuePoint in pointCollection)
{
var ndm = GetMockNdm(valuePoint, tuple);
foreach (var valDelegate in selectedDelegates)
{
double val = valDelegate.ResultFunction.Invoke(strainMatrix, ndm) * valDelegate.UnitFactor;
values.Add(val);
}
}
arrayOfValuesByPoint.AddRow(i, values);
}
private void PrepareArray()
{
var factory = new DiagramFactory()
{
TupleList = validTuplesList,
//SetProgress = SetProgress,
};
arrayParameter = factory.GetCommonArray();
var labels = GetValueLabels(selectedDelegates);
arrayOfValuesByPoint = new ArrayParameter<double>(validTuplesList.Count(), labels);
}
private INdm GetMockNdm((INamedAreaPoint areaPoint, INdmPrimitive ndmPrimitive) valuePoint, IForcesTupleResult tuple)
{
var limitState = tuple.DesignForceTuple.LimitState;
var calcTerm = tuple.DesignForceTuple.CalcTerm;
var material = valuePoint.ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
var userPrestrain = valuePoint.ndmPrimitive.UsersPrestrain;
var autoPrestrain = valuePoint.ndmPrimitive.AutoPrestrain;
var ndm = new RebarNdm()
{
Area = valuePoint.areaPoint.Area,
CenterX = valuePoint.areaPoint.Point.X,
CenterY = valuePoint.areaPoint.Point.Y,
Material = material,
};
ndm.Prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * valuePoint.areaPoint.Point.Y
+ (userPrestrain.My + autoPrestrain.My) * valuePoint.areaPoint.Point.X
+ userPrestrain.Nz + autoPrestrain.Nz;
return ndm;
}
private List<string> GetValueLabels(IEnumerable<IResultFunc> selectedDelegates)
{
List<string> strings = new();
foreach (var valuePoint in pointCollection)
{
foreach (var deleg in selectedDelegates)
{
string s = valuePoint.ndmPrimitive.Name;
s += "_" + valuePoint.areaPoint.Name;
s += "_" + deleg.Name + ", " + deleg.UnitName;
strings.Add(s);
}
}
return strings;
}
}
}

View File

@@ -285,40 +285,15 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
throw new StructureHelperException(ErrorStrings.NullReference + ": Nothing is selected");
}
var tuple = SelectedResult.DesignForceTuple ?? throw new StructureHelperException(ErrorStrings.NullReference + ": Design force combination");
var inputData = new ValuePointsInterpolationInputData()
var logic = new InterpolateValuePointsLogic()
{
FinishDesignForce = tuple.Clone() as IDesignForceTuple,
LimitState = tuple.LimitState,
CalcTerm = tuple.CalcTerm,
SelectedResult = SelectedResult,
ForceCalculator = forceCalculator,
NdmPrimitives = ndmPrimitives,
ProgressLogic = progressLogic,
ShowProgressLogic = showProgressLogic
};
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);
progressLogic = interpolationLogic;
showProgressLogic = new(interpolationLogic)
{
WindowTitle = "Interpolate forces",
};
showProgressLogic.Show();
var result = interpolationLogic.InterpolateCalculator.Result;
if (result.IsValid == false) { return; }
if (result is IForcesResults)
{
var tupleResult = result as IForcesResults;
var pointGraphLogic = new ShowValuePointDiagramLogic(tupleResult.ForcesResultList, ndmPrimitives)
{
Calculator = interpolationLogic.InterpolateCalculator,
PrimitiveLogic = viewModel.PrimitiveLogic,
ValueDelegatesLogic = viewModel.ValueDelegatesLogic
};
pointGraphLogic.SetParameters();
pointGraphLogic.ShowWindow();
}
logic.InterpolateValuePoints();
}
private void ShowInterpolationWindow(out InterpolateTuplesViewModel interploateTuplesViewModel, out InterpolateTuplesView wndTuples)

View File

@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.Forces"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:ValuePointsInterpolateViewModel}"
Title="Value Poits Interpolation" Height="250" Width="460" MinHeight="250" MinWidth="460" MaxHeight="450" MaxWidth="460" WindowStartupLocation="CenterScreen">
Title="Value Points Interpolation" Height="250" Width="460" MinHeight="250" MinWidth="460" MaxHeight="450" MaxWidth="460" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
@@ -24,7 +24,7 @@
<Expander.Header>
<ContentControl ContentTemplate="{StaticResource ResourceKey=ColoredItemTemplate}" Content="{Binding Item.PrimitiveBase}"/>
</Expander.Header>
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding Item.ValuePoints}"/>
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding Item.ValuePoints}" Width="400"/>
</Expander>
</DataTemplate>
</ListBox.ItemTemplate>

View File

@@ -18,8 +18,9 @@
</ToolBarTray>-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250"/>
<ColumnDefinition/>
<ColumnDefinition MinWidth="250"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
@@ -31,7 +32,7 @@
<ListBox.ItemTemplate>
<DataTemplate>
<Expander Header="{Binding Name}" IsExpanded="True" Background="{Binding Color}">
<Grid >
<Grid HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="70"/>
<RowDefinition/>
@@ -81,7 +82,8 @@
<Button Margin="3" Content="Draw Lines" ToolTip="Draw Lines" Command="{Binding RedrawLinesCommand}"/>
</StackPanel>
</Grid>
<lvc:CartesianChart Name="MainChart" Grid.Column="1" Series="{Binding SeriesCollection}" LegendLocation="Bottom" Zoom="Xy">
<GridSplitter Grid.Column="1" Width="3" VerticalAlignment="Stretch" HorizontalAlignment="Center" ShowsPreview="False"/>
<lvc:CartesianChart Name="MainChart" Grid.Column="2" Series="{Binding SeriesCollection}" LegendLocation="Bottom" Zoom="Xy">
<lvc:CartesianChart.AxisY>
<lvc:Axis Title="y-value"></lvc:Axis>
</lvc:CartesianChart.AxisY>

View File

@@ -143,67 +143,70 @@
Content="Fact" ToolTip="Add Factored Combination"/>
</ToolBar>
<ToolBar DataContext="{Binding MaterialsLogic}" ToolTip="Materials">
<Button Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Concrete}">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/ConMaterial32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Concrete}">
<Image Source="/Windows/MainWindow/ConMaterial32.png"/>
</Button>
<Button Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Reinforcement}" ToolTip="Add Reinforcement Material">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/RFMaterial32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Reinforcement}" ToolTip="Add Reinforcement Material">
<Image Source="/Windows/MainWindow/RFMaterial32.png"/>
</Button>
<Button Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Elastic}" ToolTip="Add Elastic Material">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/ElasticMaterial32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Elastic}" ToolTip="Add Elastic Material">
<Image Source="/Windows/MainWindow/ElasticMaterial32.png"/>
</Button>
<Button Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.CarbonFiber}" ToolTip="Add Carbon Fiber Material">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/СarbonMaterial32.png"/>
</Button>
<Button Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.GlassFiber}" ToolTip="Add Glass Fiber Material">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/GlassMaterial32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.GlassFiber}" ToolTip="Add Glass Fiber Material">
<Image Source="/Windows/MainWindow/GlassMaterial32.png"/>
</Button>
<Button Command="{Binding EditMaterialsCommand}" ToolTip="Show Materials">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/Materials32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding EditMaterialsCommand}" ToolTip="Show Materials">
<Image Source="/Windows/MainWindow/Materials32.png"/>
</Button>
</ToolBar>
<ToolBar ToolTip="Base Primitives" DataContext="{Binding PrimitiveLogic}">
<Button Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}" ToolTip="Add Rectangle Primitive">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/Rectangle32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}" ToolTip="Add Rectangle Primitive">
<Image Source="/Windows/MainWindow/Rectangle32.png"/>
</Button>
<Button Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}" ToolTip="Add Circle Primitive">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/Circle32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}" ToolTip="Add Circle Primitive">
<Image Source="/Windows/MainWindow/Circle32.png"/>
</Button>
<Button Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}" ToolTip="Add Rebar Primitive">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/Rebar32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}" ToolTip="Add Rebar Primitive">
<Image Source="/Windows/MainWindow/Rebar32.png"/>
</Button>
<Button Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}" ToolTip="Add Point Primitive">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/Point32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}" ToolTip="Add Point Primitive">
<Image Source="/Windows/MainWindow/Point32.png"/>
</Button>
</ToolBar>
<ToolBar ToolTip="RC Templates">
<Button Command="{Binding AddColumnCase}" ToolTip="Add Rectangle RC Column">
<Image Width="32" Height="32" Source="/Windows/MainWindow/RectangleColumn32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding AddColumnCase}" ToolTip="Add Rectangle RC Column">
<Image Source="/Windows/MainWindow/RectangleColumn32.png"/>
</Button>
<Button Command="{Binding AddRCCircleCase}" ToolTip="Add Circle RC Column">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/CircleColumn32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding AddRCCircleCase}" ToolTip="Add Circle RC Column">
<Image Source="/Windows/MainWindow/CircleColumn32.png"/>
</Button>
<Button Command="{Binding AddBeamCase}" ToolTip="Add RC Beam">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/Beam32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding AddBeamCase}" ToolTip="Add RC Beam">
<Image Source="/Windows/MainWindow/Beam32.png"/>
</Button>
<Button Command="{Binding AddSlabCase}" ToolTip="Add RC Slab">
<Image Width="32" Height="32" Source="/Windows/MainWindow/Slab32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding AddSlabCase}" ToolTip="Add RC Slab">
<Image Source="/Windows/MainWindow/Slab32.png"/>
</Button>
</ToolBar>
<ToolBar ToolTip="Analises" DataContext="{Binding CalculatorsLogic}">
<Button Command="{Binding Add}" ToolTip="Add Force Calculator">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/Calculator32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ForceCalculator}" ToolTip="Add Force Calculator">
<Image Source="/Windows/MainWindow/Calculator32.png"/>
</Button>
<Button Command="{Binding Run}" ToolTip="Run Calculations">
<Image Style="{StaticResource ButtonImage32}" Source="/Windows/MainWindow/Analysis32.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.LimitCurveCalculator}" ToolTip="Add Interaction Diagram Calculator">
<Image Source="/Windows/MainWindow/Calculator32.png"/>
</Button>
<Button Style="{StaticResource ToolButton}" Command="{Binding Run}" ToolTip="Run Calculations">
<Image Source="/Windows/MainWindow/Analysis32.png"/>
</Button>
</ToolBar>
<ToolBar ToolTip="Tools">
<Button Command="{Binding MovePrimitiveToGravityCenterCommand}" ToolTip="Move All Primitives to Gravity Center">
<Image Width="32" Height="32" Source="/Windows/MainWindow/MovePrimitivesToCenter.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding MovePrimitiveToGravityCenterCommand}" ToolTip="Move All Primitives to Gravity Center">
<Image Source="/Windows/MainWindow/MovePrimitivesToCenter.png"/>
</Button>
<Button Command="{Binding ShowVisualProperty}" ToolTip="Visual Settings">
<Image Width="32" Height="32" Source="/Windows/MainWindow/Tools_Settings.png"/>
<Button Style="{StaticResource ToolButton}" Command="{Binding ShowVisualProperty}" ToolTip="Visual Settings">
<Image Source="/Windows/MainWindow/Tools_Settings.png"/>
</Button>
</ToolBar>
</ToolBarTray>

View File

@@ -2,6 +2,7 @@
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.CalculationWindows.ProgressViews;
using StructureHelper.Windows.Errors;
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Exceptions;
@@ -10,6 +11,7 @@ using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
using System;
using System.Windows;
using System.Windows.Forms;
using MessageBox = System.Windows.Forms.MessageBox;
@@ -25,32 +27,64 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private InteractionDiagramLogic interactionDiagramLogic;
public override void AddMethod(object parameter)
{
if (CheckParameter(parameter) == false) { return; }
AddCalculator(parameter);
base.AddMethod(parameter);
}
private void AddCalculator(object parameter)
{
var parameterType = (CalculatorTypes)parameter;
if (parameterType == CalculatorTypes.ForceCalculator)
{
NewItem = new ForceCalculator()
{
Name = "New force calculator",
TraceLogger = new ShiftTraceLogger(),
};
AddForceCalculator();
}
else if (parameterType == CalculatorTypes.LimitCurveCalculator)
{
var inputData = new LimitCurveInputData(repository.Primitives);
NewItem = new LimitCurvesCalculator()
{
Name = "New interaction diagram calculator",
InputData = inputData,
TraceLogger = new ShiftTraceLogger(),
};
AddLimitCurveCalculator();
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(parameterType));
}
base.AddMethod(parameter);
}
private void AddLimitCurveCalculator()
{
var inputData = new LimitCurveInputData(repository.Primitives);
NewItem = new LimitCurvesCalculator()
{
Name = "New interaction diagram calculator",
InputData = inputData,
TraceLogger = new ShiftTraceLogger(),
};
}
private void AddForceCalculator()
{
NewItem = new ForceCalculator()
{
Name = "New force calculator",
TraceLogger = new ShiftTraceLogger(),
};
}
private bool CheckParameter(object parameter)
{
if (parameter is null)
{
SafetyProcessor.ShowMessage(ErrorStrings.ParameterIsNull, "It is imposible to add object cause parameter is null");
return false;
}
if (parameter is not CalculatorTypes)
{
SafetyProcessor.ShowMessage(ErrorStrings.ExpectedWas(typeof(CalculatorTypes), parameter), "Parameter is not correspondent to any type of calculator");
return false;
}
return true;
}
public override void EditMethod(object parameter)
{
SafetyProcessor.RunSafeProcess(EditCalculator, $"Error of editing: {SelectedItem.Name}");