Add trace of primitives and material
This commit is contained in:
@@ -157,13 +157,19 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
||||
{
|
||||
const int columnWidth = 150;
|
||||
var rows = tableEntry.Table.GetAllRows();
|
||||
int rowCount = rows.Count();
|
||||
int columnCount = tableEntry.Table.RowSize;
|
||||
var table = new Table();
|
||||
for (int x = 0; x < columnCount; x++)
|
||||
{
|
||||
var tableColumn = new TableColumn();
|
||||
if (tableEntry.ColumnWidth[x] > 0d)
|
||||
{
|
||||
tableColumn.Width = new GridLength(tableEntry.ColumnWidth[x]);
|
||||
}
|
||||
else
|
||||
{
|
||||
tableColumn.Width = new GridLength(columnWidth);
|
||||
}
|
||||
table.Columns.Add(tableColumn);
|
||||
}
|
||||
foreach (var row in rows)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
|
||||
d:DataContext="{d:DesignInstance local:TraceDocumentVM}"
|
||||
mc:Ignorable="d"
|
||||
Title="Trace Document Viewer" Height="600" Width="800" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen">
|
||||
Title="Document Viewer" Height="600" Width="800" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<DockPanel>
|
||||
<ToolBarTray DockPanel.Dock="Top">
|
||||
|
||||
@@ -103,36 +103,6 @@
|
||||
</ContextMenu>
|
||||
</Window.Resources>
|
||||
<DockPanel>
|
||||
<!--<Menu DockPanel.Dock="Top" x:Name="menu">
|
||||
<MenuItem Header="File">
|
||||
</MenuItem>
|
||||
<MenuItem Header="Edit">
|
||||
<MenuItem Header="Primitives">
|
||||
<MenuItem Header="Add">
|
||||
<Button Content="Rectangle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
|
||||
<Button Content="Circle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}"/>
|
||||
<Button Content="Reinforcement" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}"/>
|
||||
<Button Content="Point" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
|
||||
</MenuItem>
|
||||
<Button Content="Edit primitive" Command="{Binding PrimitiveLogic.Edit}"/>
|
||||
<Button Content="Delete primitive" Command="{Binding PrimitiveLogic.Delete}"/>
|
||||
</MenuItem>
|
||||
<Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/>
|
||||
<Button Content="Move primitives to center" Command="{Binding MovePrimitiveToGravityCenterCommand}"/>
|
||||
<MenuItem Header="Templates">
|
||||
<Button Content="Concrete beam" Command="{Binding AddBeamCase}"/>
|
||||
<Button Content="Concrete column" Command="{Binding AddColumnCase}"/>
|
||||
<Button Content="Concrete slab" Command="{Binding AddSlabCase}"/>
|
||||
<Button Content="Concrete circle" Command="{Binding AddRCCircleCase}"/>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Tools">
|
||||
<Button Content="Settings" Command="{Binding ShowVisualProperty}"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Help">
|
||||
<Button Content="About..." Command="{Binding HelpLogic.ShowAbout}"/>
|
||||
</MenuItem>
|
||||
</Menu>-->
|
||||
<ToolBarTray DockPanel.Dock="Top">
|
||||
<ToolBar DataContext="{Binding CombinationsLogic}" ToolTip="Actions">
|
||||
<Button Style="{StaticResource ToolButton}"
|
||||
|
||||
@@ -21,6 +21,11 @@ using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
|
||||
namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
public class CrossSectionViewModel : ViewModelBase
|
||||
|
||||
@@ -5,16 +5,31 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow.Materials"
|
||||
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Materials"
|
||||
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
|
||||
d:DataContext="{d:DesignInstance vm:HeadMaterialsViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="Materials" Height="350" Width="680" MinHeight="350" MinWidth="680" WindowStartupLocation="CenterScreen">
|
||||
Title="Materials" Height="350" Width="480" MinHeight="350" MinWidth="480" WindowStartupLocation="CenterScreen">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary Source="/Infrastructure/UI/Resources/Materials.xaml"/>
|
||||
</Window.Resources>
|
||||
<DockPanel>
|
||||
<ToolBarTray DockPanel.Dock="Top">
|
||||
<ToolBar>
|
||||
<Button Style="{DynamicResource ToolButton}" Command="{Binding ShowMaterialDiagram}">
|
||||
<Button.ToolTip>
|
||||
<uc:ButtonToolTipEh HeaderText="Show material diagram"
|
||||
IconContent="{StaticResource MomentCurvatureDiagram}"
|
||||
DescriptionText="Show stress-strain diagram for selected material"/>
|
||||
</Button.ToolTip>
|
||||
<Viewbox>
|
||||
<ContentControl ContentTemplate="{DynamicResource MomentCurvatureDiagram}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -40,8 +55,6 @@
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
<StackPanel Grid.Column="1">
|
||||
<Button Content="Show diagram" Command="{Binding ShowMaterialDiagram}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
||||
@@ -9,6 +9,11 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Materials
|
||||
{
|
||||
public class MaterialsViewModel : SelectItemVM<IHeadMaterial>
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace StructureHelperCommon.Models
|
||||
/// </summary>
|
||||
public class TraceTablesFactory
|
||||
{
|
||||
|
||||
public int Priority { get; set; }
|
||||
/// <summary>
|
||||
/// Generates table entry for Point2D (2 columns, 2 rows)
|
||||
@@ -64,8 +65,10 @@ namespace StructureHelperCommon.Models
|
||||
/// <returns>Table entry</returns>
|
||||
public TableLogEntry GetByForceTuple(IEnumerable<IForceTuple> forceTuples)
|
||||
{
|
||||
var table = new TableLogEntry(6);
|
||||
table.Priority = Priority;
|
||||
var table = new TableLogEntry(6)
|
||||
{
|
||||
Priority = Priority
|
||||
};
|
||||
//type of force tuple for creating a header is taken by first member
|
||||
var firstMember = forceTuples.First();
|
||||
table.Table.AddRow(GetForceTupleHeaderRow(firstMember));
|
||||
@@ -86,54 +89,26 @@ namespace StructureHelperCommon.Models
|
||||
private ShTableRow<ITraceLoggerEntry> GetForceTupleHeaderRow(IForceTuple forceTuple)
|
||||
{
|
||||
const CellRole cellRole = CellRole.Header;
|
||||
const int rowSize = 6;
|
||||
string[] ColumnList = new string[] { "Mx", "My", "Nz", "Qx", "Qy", "Mz" };
|
||||
if (forceTuple is StrainTuple)
|
||||
{
|
||||
ColumnList = new string[] { "Kx", "Ky", "EpsZ", "GammaX", "GammaY", "Kz" };
|
||||
}
|
||||
|
||||
var forceTupleRow = new ShTableRow<ITraceLoggerEntry>(6);
|
||||
var forceTupleRow = new ShTableRow<ITraceLoggerEntry>(rowSize);
|
||||
foreach (var item in forceTupleRow.Elements)
|
||||
{
|
||||
item.Role = cellRole;
|
||||
}
|
||||
|
||||
forceTupleRow.Elements[0].Value = new StringLogEntry()
|
||||
for (int i = 0; i < rowSize; i++)
|
||||
{
|
||||
Message = ColumnList[0],
|
||||
forceTupleRow.Elements[i].Value = new StringLogEntry()
|
||||
{
|
||||
Message = ColumnList[i],
|
||||
Priority = Priority
|
||||
};
|
||||
|
||||
forceTupleRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = ColumnList[1],
|
||||
Priority = Priority
|
||||
};
|
||||
|
||||
forceTupleRow.Elements[2].Value = new StringLogEntry()
|
||||
{
|
||||
Message = ColumnList[2],
|
||||
Priority = Priority
|
||||
};
|
||||
|
||||
forceTupleRow.Elements[3].Value = new StringLogEntry()
|
||||
{
|
||||
Message = ColumnList[3],
|
||||
Priority = Priority
|
||||
};
|
||||
|
||||
forceTupleRow.Elements[4].Value = new StringLogEntry()
|
||||
{
|
||||
Message = ColumnList[4],
|
||||
Priority = Priority
|
||||
};
|
||||
|
||||
forceTupleRow.Elements[5].Value = new StringLogEntry()
|
||||
{
|
||||
Message = ColumnList[5],
|
||||
Priority = Priority
|
||||
};
|
||||
|
||||
}
|
||||
return forceTupleRow;
|
||||
}
|
||||
private ShTableRow<ITraceLoggerEntry> GetForceTupleRow(IForceTuple forceTuple)
|
||||
@@ -181,7 +156,6 @@ namespace StructureHelperCommon.Models
|
||||
|
||||
return forceTupleRow;
|
||||
}
|
||||
|
||||
private ShTableRow<ITraceLoggerEntry> GetPoint2DHeaderRow()
|
||||
{
|
||||
const CellRole cellRole = CellRole.Header;
|
||||
@@ -228,5 +202,6 @@ namespace StructureHelperCommon.Models
|
||||
};
|
||||
return pointRow;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
13
StructureHelperCommon/Models/Loggers/ITraceEntityFactory.cs
Normal file
13
StructureHelperCommon/Models/Loggers/ITraceEntityFactory.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StructureHelperCommon.Models
|
||||
{
|
||||
public interface ITraceEntityFactory<T> where T : class
|
||||
{
|
||||
IEnumerable<T>? Collection { get; set; }
|
||||
int Priority { get; set; }
|
||||
|
||||
List<ITraceLoggerEntry> GetTraceEntries();
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ namespace StructureHelperCommon.Models
|
||||
private ShTable<ITraceLoggerEntry> table;
|
||||
public ShTable<ITraceLoggerEntry> Table {get => table;}
|
||||
public DateTime TimeStamp { get; }
|
||||
public double[] ColumnWidth { get; }
|
||||
|
||||
public int Priority { get; set; }
|
||||
public TableLogEntry(int rowSize)
|
||||
@@ -20,6 +21,7 @@ namespace StructureHelperCommon.Models
|
||||
{
|
||||
throw new ArgumentException("Row size must be greater than 0.", nameof(rowSize));
|
||||
}
|
||||
ColumnWidth = new double[rowSize];
|
||||
table = new(rowSize);
|
||||
TimeStamp = DateTime.Now;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,14 @@ namespace StructureHelperCommon.Models.Tables
|
||||
table.Add(new ShTableRow<T>(RowSize));
|
||||
}
|
||||
|
||||
public void AddRows(IEnumerable<IShTableRow<T>> tableRows)
|
||||
{
|
||||
foreach (var item in tableRows)
|
||||
{
|
||||
AddRow(item);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all rows in the table
|
||||
/// </summary>
|
||||
|
||||
183
StructureHelperLogics/Models/Materials/TraceMaterialsFactory.cs
Normal file
183
StructureHelperLogics/Models/Materials/TraceMaterialsFactory.cs
Normal file
@@ -0,0 +1,183 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Models.Tables;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public class TraceMaterialsFactory : ITraceEntityFactory<IHeadMaterial>
|
||||
{
|
||||
const int rowSize = 2;
|
||||
private List<ITraceLoggerEntry> traceLoggerEntries;
|
||||
public IEnumerable<IHeadMaterial>? Collection { get; set; }
|
||||
public int Priority { get; set; } = LoggerService.GetPriorityByStatus(TraceLogStatuses.Info);
|
||||
|
||||
public List<ITraceLoggerEntry> GetTraceEntries()
|
||||
{
|
||||
Check();
|
||||
traceLoggerEntries = new();
|
||||
traceLoggerEntries.Add(new StringLogEntry()
|
||||
{
|
||||
Message = $"There are (is) {Collection.Count()} distinct material(s)",
|
||||
Priority = Priority
|
||||
}
|
||||
);
|
||||
ProcessCollection();
|
||||
return traceLoggerEntries;
|
||||
}
|
||||
|
||||
private void ProcessCollection()
|
||||
{
|
||||
var table = new TableLogEntry(rowSize)
|
||||
{
|
||||
Priority = Priority
|
||||
};
|
||||
table.ColumnWidth[1] = 400;
|
||||
foreach (var item in Collection)
|
||||
{
|
||||
table.Table.AddRow(GetHeader(item));
|
||||
table.Table.AddRows(GetCommonRows(item));
|
||||
}
|
||||
traceLoggerEntries.Add(table);
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
if (Collection is null)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ParameterIsNull + ": Collection of primitives");
|
||||
}
|
||||
}
|
||||
|
||||
private IShTableRow<ITraceLoggerEntry> GetHeader(IHeadMaterial headMaterial)
|
||||
{
|
||||
const CellRole cellRole = CellRole.Header;
|
||||
string[] ColumnList = new string[]
|
||||
{
|
||||
"Material name",
|
||||
headMaterial.Name
|
||||
};
|
||||
|
||||
var ndmRow = new ShTableRow<ITraceLoggerEntry>(rowSize);
|
||||
foreach (var item in ndmRow.Elements)
|
||||
{
|
||||
item.Role = cellRole;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rowSize; i++)
|
||||
{
|
||||
ndmRow.Elements[i].Value = new StringLogEntry()
|
||||
{
|
||||
Message = ColumnList[i],
|
||||
Priority = Priority
|
||||
};
|
||||
}
|
||||
return ndmRow;
|
||||
}
|
||||
|
||||
private List<IShTableRow<ITraceLoggerEntry>> GetCommonRows(IHeadMaterial headMaterial)
|
||||
{
|
||||
List<IShTableRow<ITraceLoggerEntry>> rows = new();
|
||||
rows.AddRange(ProcessSafetyFactors(headMaterial.HelperMaterial.SafetyFactors));
|
||||
return rows;
|
||||
}
|
||||
|
||||
private List<IShTableRow<ITraceLoggerEntry>> ProcessSafetyFactors(IEnumerable<IMaterialSafetyFactor> safetyFactors)
|
||||
{
|
||||
List<IShTableRow<ITraceLoggerEntry>> rows = new();
|
||||
foreach (var item in safetyFactors)
|
||||
{
|
||||
if (item.Take == false) { continue; }
|
||||
ShTableRow<ITraceLoggerEntry> ndmRow;
|
||||
ndmRow = new(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Factor name",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = item.Name,
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
ndmRow = new(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Factor description",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = item.Description,
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
ndmRow = new(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Partial factors",
|
||||
Priority = Priority
|
||||
};
|
||||
var table = new TableLogEntry(rowSize)
|
||||
{
|
||||
Priority = Priority
|
||||
};
|
||||
table.ColumnWidth[0] = 150;
|
||||
table.ColumnWidth[1] = 250;
|
||||
table.Table.AddRows(ProcessPartialFactors(item.PartialFactors));
|
||||
ndmRow.Elements[1].Value = table;
|
||||
rows.Add(ndmRow);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
private List<IShTableRow<ITraceLoggerEntry>> ProcessPartialFactors(IEnumerable<IMaterialPartialFactor> partialFactors)
|
||||
{
|
||||
List<IShTableRow<ITraceLoggerEntry>> rows = new();
|
||||
foreach (var item in partialFactors)
|
||||
{
|
||||
rows.AddRange(ProcessPartialFactor(item));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
private List<IShTableRow<ITraceLoggerEntry>> ProcessPartialFactor(IMaterialPartialFactor item)
|
||||
{
|
||||
List<IShTableRow<ITraceLoggerEntry>> rows = new();
|
||||
ShTableRow<ITraceLoggerEntry> ndmRow = new(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Factor conditions",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Limit state: " + item.LimitState.ToString() + ", Calculation term: " + item.CalcTerm + ", Stress state: " + item.StressState,
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
ndmRow = new(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Factor value",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = item.FactorValue.ToString(),
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,9 @@ using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Sections;
|
||||
using StructureHelperCommon.Models.Sections.Logics;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.NdmCalculations.Buckling;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
@@ -29,11 +31,34 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public ForcesResults GetForcesResults()
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
|
||||
TraceInputData();
|
||||
GetCombinations();
|
||||
CalculateResult();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void TraceInputData()
|
||||
{
|
||||
TracePrimitiveFactory tracePrimitiveFactory = new()
|
||||
{
|
||||
Collection = InputData.Primitives
|
||||
};
|
||||
List<ITraceLoggerEntry> traceEntries = tracePrimitiveFactory.GetTraceEntries();
|
||||
foreach (var item in traceEntries)
|
||||
{
|
||||
TraceLogger?.AddEntry(item);
|
||||
}
|
||||
TraceMaterialsFactory traceMaterialFactory = new()
|
||||
{
|
||||
Collection = InputData.Primitives.Select(x => x.NdmElement.HeadMaterial).Distinct()
|
||||
};
|
||||
traceEntries = traceMaterialFactory.GetTraceEntries();
|
||||
foreach (var item in traceEntries)
|
||||
{
|
||||
TraceLogger?.AddEntry(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void CalculateResult()
|
||||
{
|
||||
result = new ForcesResults()
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
using LoaderCalculator;
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using LoaderCalculator.Data.ResultData;
|
||||
using LoaderCalculator.Data.SourceData;
|
||||
using LoaderCalculator.Logics;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Services;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Models.Tables;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for creating of trace entries of primitives
|
||||
/// </summary>
|
||||
public class TracePrimitiveFactory : ITraceEntityFactory<INdmPrimitive>
|
||||
{
|
||||
const int rowSize = 2;
|
||||
private List<ITraceLoggerEntry> traceLoggerEntries;
|
||||
public int Priority { get; set; } = LoggerService.GetPriorityByStatus(TraceLogStatuses.Info);
|
||||
public IEnumerable<INdmPrimitive>? Collection { get; set; }
|
||||
public List<ITraceLoggerEntry> GetTraceEntries()
|
||||
{
|
||||
Check();
|
||||
traceLoggerEntries = new();
|
||||
traceLoggerEntries.Add(new StringLogEntry()
|
||||
{
|
||||
Message = $"There are (is) {Collection.Count()} primitive(s)",
|
||||
Priority = Priority
|
||||
}
|
||||
);
|
||||
ProcessCollection();
|
||||
return traceLoggerEntries;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
if (Collection is null)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ParameterIsNull + ": Collection of primitives");
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessCollection()
|
||||
{
|
||||
foreach (var item in Collection)
|
||||
{
|
||||
var table = new TableLogEntry(rowSize)
|
||||
{
|
||||
Priority = Priority
|
||||
};
|
||||
table.ColumnWidth[1] = 200;
|
||||
table.Table.AddRow(GetHeader(item));
|
||||
table.Table.AddRows(GetCommonRows(item));
|
||||
if (item is IRectangleNdmPrimitive rectangle)
|
||||
{
|
||||
table.Table.AddRows(ProcessRectangle(rectangle.Shape as IRectangleShape));
|
||||
}
|
||||
if (item is IEllipseNdmPrimitive ellipse)
|
||||
{
|
||||
IRectangleShape? rectShape = ellipse.Shape as IRectangleShape;
|
||||
if (rectShape.Width == rectShape.Height)
|
||||
{
|
||||
table.Table.AddRows(ProcessCircle(rectShape));
|
||||
}
|
||||
else
|
||||
{
|
||||
table.Table.AddRows(ProcessRectangle(rectShape));
|
||||
}
|
||||
}
|
||||
if (item is IPointNdmPrimitive point)
|
||||
{
|
||||
table.Table.AddRows(ProcessPoint(point));
|
||||
}
|
||||
traceLoggerEntries.Add(table);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<IShTableRow<ITraceLoggerEntry>> ProcessCircle(IRectangleShape rectShape)
|
||||
{
|
||||
List<IShTableRow<ITraceLoggerEntry>> rows = new();
|
||||
ShTableRow<ITraceLoggerEntry> ndmRow;
|
||||
ndmRow = new ShTableRow<ITraceLoggerEntry>(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Diameter",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = rectShape.Width.ToString(),
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
return rows;
|
||||
}
|
||||
|
||||
private List<IShTableRow<ITraceLoggerEntry>> ProcessPoint(IPointNdmPrimitive point)
|
||||
{
|
||||
List<IShTableRow<ITraceLoggerEntry>> rows = new();
|
||||
ShTableRow<ITraceLoggerEntry> ndmRow;
|
||||
ndmRow = new ShTableRow<ITraceLoggerEntry>(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Area",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = point.Area.ToString(),
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
return rows;
|
||||
}
|
||||
|
||||
private List<IShTableRow<ITraceLoggerEntry>> GetCommonRows(INdmPrimitive ndmPrimitive)
|
||||
{
|
||||
List<IShTableRow<ITraceLoggerEntry>> rows = new();
|
||||
ShTableRow<ITraceLoggerEntry> ndmRow;
|
||||
ndmRow = new(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Material",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = ndmPrimitive.NdmElement.HeadMaterial.Name,
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
ndmRow = new(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Center",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "X = " + ndmPrimitive.Center.X.ToString() + ", Y = " + ndmPrimitive.Center.Y.ToString(),
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
return rows;
|
||||
}
|
||||
|
||||
private List<IShTableRow<ITraceLoggerEntry>> ProcessRectangle(IRectangleShape rectShape)
|
||||
{
|
||||
List<IShTableRow<ITraceLoggerEntry>> rows = new();
|
||||
ShTableRow<ITraceLoggerEntry> ndmRow;
|
||||
ndmRow = new ShTableRow<ITraceLoggerEntry>(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Height",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = rectShape.Width.ToString(),
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
ndmRow = new ShTableRow<ITraceLoggerEntry>(rowSize);
|
||||
ndmRow.Elements[0].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Width",
|
||||
Priority = Priority
|
||||
};
|
||||
ndmRow.Elements[1].Value = new StringLogEntry()
|
||||
{
|
||||
Message = rectShape.Height.ToString(),
|
||||
Priority = Priority
|
||||
};
|
||||
rows.Add(ndmRow);
|
||||
return rows;
|
||||
}
|
||||
|
||||
private IShTableRow<ITraceLoggerEntry> GetHeader(INdmPrimitive ndmPrimitive)
|
||||
{
|
||||
const CellRole cellRole = CellRole.Header;
|
||||
string[] ColumnList = new string[]
|
||||
{
|
||||
"Primitive name",
|
||||
ndmPrimitive.Name
|
||||
};
|
||||
|
||||
var ndmRow = new ShTableRow<ITraceLoggerEntry>(rowSize);
|
||||
foreach (var item in ndmRow.Elements)
|
||||
{
|
||||
item.Role = cellRole;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rowSize; i++)
|
||||
{
|
||||
ndmRow.Elements[i].Value = new StringLogEntry()
|
||||
{
|
||||
Message = ColumnList[i],
|
||||
Priority = Priority
|
||||
};
|
||||
}
|
||||
return ndmRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user