CrossSection view model was improved

This commit is contained in:
Evgeny Redikultsev
2024-02-02 22:27:18 +05:00
parent b1fc0c763f
commit 165a2846bb
22 changed files with 307 additions and 170 deletions

View File

@@ -25,12 +25,12 @@ namespace StructureHelper
builder.RegisterType<CrossSectionModel>().AsSelf().SingleInstance();
builder.RegisterType<CrossSectionViewModel>().AsSelf().SingleInstance();
builder.RegisterType<MainView>().AsSelf();
builder.RegisterType<CrossSectionView>().AsSelf();
Container = builder.Build();
Scope = Container.Resolve<ILifetimeScope>();
var window = Scope.Resolve<MainView>();
var window = Scope.Resolve<CrossSectionView>();
window.Show();
}

View File

@@ -1,4 +1,4 @@
<Window x:Class="StructureHelper.Windows.MainWindow.MainView"
<Window x:Class="StructureHelper.Windows.MainWindow.CrossSectionView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -13,7 +13,7 @@
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:MainViewModel}"
d:DataContext="{d:DesignInstance local:CrossSectionViewModel}"
Title="StructureHelper" Height="700" Width="1000" MinHeight="400" MinWidth="600">
<Window.Resources>
<DataTemplate DataType="{x:Type dataContexts:RectangleViewPrimitive}">
@@ -363,7 +363,7 @@
</i:EventTrigger>
</i:Interaction.Triggers>
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
<Canvas Name="WorkPlane" ClipToBounds="True" Width="{Binding CanvasWidth}" Height="{Binding CanvasHeight}">
<Canvas Name="WorkPlane" ClipToBounds="True" Width="{Binding VisualProperty.WorkPlainWidth}" Height="{Binding VisualProperty.WorkPlainHeight}">
<Canvas.ContextMenu>
<ContextMenu>
<MenuItem Header="Add" DataContext="{Binding PrimitiveLogic}">
@@ -438,8 +438,10 @@
</VisualBrush.Visual>
</VisualBrush>
</Canvas.Background>
<Line X1="0" X2="{Binding XX2}" Y1="{Binding XY1}" Y2="{Binding XY1}" Stroke="Red" StrokeThickness="{Binding AxisLineThickness}"/>
<Line X1="{Binding YX1}" X2="{Binding YX1}" Y1="0" Y2="{Binding YY2}" Stroke="ForestGreen" StrokeThickness="{Binding AxisLineThickness}"/>
<!--Horizontal axis line-->
<Line X1="0" X2="{Binding RightLimitX}" Y1="{Binding MiddleLimitY}" Y2="{Binding MiddleLimitY}" Stroke="Red" StrokeThickness="{Binding AxisLineThickness}"/>
<!--Vertical axis line-->
<Line X1="{Binding MiddleLimitX}" X2="{Binding MiddleLimitX}" Y1="0" Y2="{Binding BottomLimitY}" Stroke="ForestGreen" StrokeThickness="{Binding AxisLineThickness}"/>
<ItemsControl DataContext="{Binding PrimitiveLogic}" ItemsSource="{Binding Items}" ContextMenu="{StaticResource PrimitiveCRUD}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>

View File

@@ -6,12 +6,12 @@ using StructureHelper.Services.Primitives;
namespace StructureHelper.Windows.MainWindow
{
public partial class MainView : Window
public partial class CrossSectionView : Window
{
private CrossSectionViewModel viewModel;
public IPrimitiveRepository PrimitiveRepository { get; }
public MainView(IPrimitiveRepository primitiveRepository, CrossSectionViewModel viewModel)
public CrossSectionView(IPrimitiveRepository primitiveRepository, CrossSectionViewModel viewModel)
{
PrimitiveRepository = primitiveRepository;
this.viewModel = viewModel;

View File

@@ -27,21 +27,19 @@ namespace StructureHelper.Windows.MainWindow
{
public class CrossSectionViewModel : ViewModelBase
{
ICrossSection section;
ICrossSectionRepository repository => section.SectionRepository;
private CrossSectionViewVisualProperty visualProperty;
private ICrossSection section;
private ICrossSectionRepository repository => section.SectionRepository;
private readonly double scaleRate = 1.1d;
public PrimitiveBase SelectedPrimitive { get; set; }
//public IForceCombinationList SelectedForceCombinationList { get; set; }
public CrossSectionVisualPropertyVM VisualProperty { get; private set; }
private readonly AnalysisVewModelLogic calculatorsLogic;
public AnalysisVewModelLogic CalculatorsLogic { get => calculatorsLogic;}
public ActionsViewModel CombinationsLogic { get => combinationsLogic; }
public MaterialsViewModel MaterialsLogic { get => materialsLogic; }
public PrimitiveViewModelLogic PrimitiveLogic => primitiveLogic;
public PrimitiveBase SelectedPrimitive { get; set; }
public AnalysisVewModelLogic CalculatorsLogic { get; private set; }
public ActionsViewModel CombinationsLogic { get; }
public MaterialsViewModel MaterialsLogic { get; }
public PrimitiveViewModelLogic PrimitiveLogic { get; }
public HelpLogic HelpLogic => new HelpLogic();
private CrossSectionModel Model { get; }
@@ -84,37 +82,26 @@ namespace StructureHelper.Windows.MainWindow
public double AxisLineThickness
{
get => visualProperty.AxisLineThickness / scaleValue;
get => VisualProperty.AxisLineThickness / scaleValue;
}
public double GridLineThickness
{
get => visualProperty.GridLineThickness / scaleValue;
}
private double xX2, xY1, yX1, yY2;
public double CanvasWidth
{
get => visualProperty.WorkPlainWidth;
}
public double CanvasHeight
{
get => visualProperty.WorkPlainHeight;
}
get => VisualProperty.GridLineThickness / scaleValue;
}
public string CanvasViewportSize
{
get
{
string s = visualProperty.GridSize.ToString();
string s = VisualProperty.GridSize.ToString();
s = s.Replace(',', '.');
return $"0,0,{s},{s}";
}
}
public double GridSize { get => visualProperty.GridSize; }
public double GridSize => VisualProperty.GridSize;
public ObservableCollection<IHeadMaterial> HeadMaterials
{
@@ -129,26 +116,22 @@ namespace StructureHelper.Windows.MainWindow
}
}
public double XX2
{
get => xX2;
set => OnPropertyChanged(value, ref xX2);
}
public double XY1
{
get => xY1;
set => OnPropertyChanged(value, ref xY1);
}
public double YX1
{
get => yX1;
set => OnPropertyChanged(value, ref yX1);
}
public double YY2
{
get => yY2;
set => OnPropertyChanged(value, ref yY2);
}
/// <summary>
/// Right edge of work plane, coordinate X
/// </summary>
public double RightLimitX => VisualProperty.WorkPlainWidth;
/// <summary>
/// Bottom edge of work plane Y
/// </summary>
public double BottomLimitY => VisualProperty.WorkPlainHeight;
/// <summary>
/// Middle of coordinate X
/// </summary>
public double MiddleLimitX => VisualProperty.WorkPlainWidth / 2d;
/// <summary>
/// Middle of coordinate Y
/// </summary>
public double MiddleLimitY => VisualProperty.WorkPlainHeight / 2d;
public ICommand Calculate { get; }
public ICommand EditCalculationPropertyCommand { get; }
@@ -160,7 +143,7 @@ namespace StructureHelper.Windows.MainWindow
return new RelayCommand(o =>
{
PrimitiveLogic.AddItems(GetRCCirclePrimitives());
materialsLogic.Refresh();
MaterialsLogic.Refresh();
});
}
}
@@ -189,11 +172,18 @@ namespace StructureHelper.Windows.MainWindow
return showVisualProperty ??
(showVisualProperty = new RelayCommand(o=>
{
var wnd = new VisualPropertyView(visualProperty);
var wnd = new VisualPropertyView(VisualProperty);
wnd.ShowDialog();
OnPropertyChanged(nameof(AxisLineThickness));
OnPropertyChanged(nameof(CanvasViewportSize));
OnPropertyChanged(nameof(GridSize));
OnPropertyChanged(nameof(RightLimitX));
OnPropertyChanged(nameof(BottomLimitY));
OnPropertyChanged(nameof(MiddleLimitX));
OnPropertyChanged(nameof(MiddleLimitY));
PrimitiveLogic.WorkPlaneWidth = VisualProperty.WorkPlainWidth;
PrimitiveLogic.WorkPlaneHeight = VisualProperty.WorkPlainHeight;
PrimitiveLogic.Refresh();
}));
}
}
@@ -214,27 +204,24 @@ namespace StructureHelper.Windows.MainWindow
}
private double delta = 0.0005;
private ActionsViewModel combinationsLogic;
private PrimitiveViewModelLogic primitiveLogic;
private RelayCommand showVisualProperty;
private RelayCommand selectPrimitive;
private MaterialsViewModel materialsLogic;
public CrossSectionViewModel(CrossSectionModel model)
{
visualProperty = new CrossSectionViewVisualProperty();
VisualProperty = new CrossSectionVisualPropertyVM();
Model = model;
section = model.Section;
combinationsLogic = new ActionsViewModel(repository);
materialsLogic = new MaterialsViewModel(repository);
materialsLogic.AfterItemsEdit += afterMaterialEdit;
calculatorsLogic = new AnalysisVewModelLogic(repository);
primitiveLogic = new PrimitiveViewModelLogic(section) { CanvasWidth = CanvasWidth, CanvasHeight = CanvasHeight };
XX2 = CanvasWidth;
XY1 = CanvasHeight / 2d;
YX1 = CanvasWidth / 2d;
YY2 = CanvasHeight;
scaleValue = 300d;
CombinationsLogic = new ActionsViewModel(repository);
MaterialsLogic = new MaterialsViewModel(repository);
MaterialsLogic.AfterItemsEdit += afterMaterialEdit;
CalculatorsLogic = new AnalysisVewModelLogic(repository);
PrimitiveLogic = new PrimitiveViewModelLogic(section)
{
WorkPlaneWidth = VisualProperty.WorkPlainWidth,
WorkPlaneHeight = VisualProperty.WorkPlainHeight
};
scaleValue = 500d;
LeftButtonUp = new RelayCommand(o =>
{
@@ -260,13 +247,6 @@ namespace StructureHelper.Windows.MainWindow
}
});
//SetColor = new RelayCommand(o =>
//{
// var primitive = o as PrimitiveBase;
// var colorPickerView = new ColorPickerView(primitive);
// colorPickerView.ShowDialog();
//});
ScaleCanvasDown = new RelayCommand(o =>
{
ScrollPanelX = PanelX;
@@ -284,19 +264,19 @@ namespace StructureHelper.Windows.MainWindow
AddBeamCase = new RelayCommand(o =>
{
PrimitiveLogic.AddItems(GetBeamCasePrimitives());
materialsLogic.Refresh();
MaterialsLogic.Refresh();
});
AddColumnCase = new RelayCommand(o =>
{
PrimitiveLogic.AddItems(GetColumnCasePrimitives());
materialsLogic.Refresh();
MaterialsLogic.Refresh();
});
AddSlabCase = new RelayCommand(o =>
{
PrimitiveLogic.AddItems(GetSlabCasePrimitives());
materialsLogic.Refresh();
MaterialsLogic.Refresh();
});
MovePrimitiveToGravityCenterCommand = new RelayCommand(o =>
@@ -328,7 +308,7 @@ namespace StructureHelper.Windows.MainWindow
private void afterMaterialEdit(SelectItemVM<IHeadMaterial> sender, CRUDVMEventArgs e)
{
foreach (var primitive in primitiveLogic.Items)
foreach (var primitive in PrimitiveLogic.Items)
{
primitive.RefreshColor();
}
@@ -336,7 +316,7 @@ namespace StructureHelper.Windows.MainWindow
private bool CheckMaterials()
{
foreach (var item in primitiveLogic.Items)
foreach (var item in PrimitiveLogic.Items)
{
if (item.HeadMaterial == null)
{
@@ -400,7 +380,7 @@ namespace StructureHelper.Windows.MainWindow
var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(newRepository.Primitives);
foreach (var item in primitives)
{
item.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
item.RegisterDeltas(VisualProperty.WorkPlainWidth / 2, VisualProperty.WorkPlainHeight / 2);
}
PrimitiveLogic.Refresh();
foreach (var item in newRepository.HeadMaterials)

View File

@@ -0,0 +1,83 @@
using StructureHelper.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.MainWindow
{
public class CrossSectionVisualPropertyVM : ViewModelBase
{
private double axisLineThickness;
private double gridLineThickness;
private double gridSize;
private double workPlainWidth;
private double workPlainHeight;
/// <summary>
/// Thickness of x-, and y- axis line
/// </summary>
public double AxisLineThickness
{
get => axisLineThickness; set
{
axisLineThickness = value;
OnPropertyChanged(nameof(AxisLineThickness));
}
}
/// <summary>
/// Thickness of lines of coordinate mesh
/// </summary>
public double GridLineThickness
{
get => gridLineThickness; set
{
gridLineThickness = value;
OnPropertyChanged(nameof(GridLineThickness));
}
}
/// <summary>
/// Size of coordinate mesh
/// </summary>
public double GridSize
{
get => gridSize; set
{
gridSize = value;
OnPropertyChanged(nameof(GridSize));
}
}
/// <summary>
/// Width of work plane
/// </summary>
public double WorkPlainWidth
{
get => workPlainWidth; set
{
workPlainWidth = value;
OnPropertyChanged(nameof(WorkPlainWidth));
}
}
/// <summary>
/// Height of work plane
/// </summary>
public double WorkPlainHeight
{
get => workPlainHeight; set
{
workPlainHeight = value;
OnPropertyChanged(nameof(WorkPlainHeight));
}
}
public CrossSectionVisualPropertyVM()
{
AxisLineThickness = 2d;
GridLineThickness = 0.25d;
GridSize = 0.05d;
WorkPlainWidth = 1.2d;
WorkPlainHeight = 1.2d;
}
}
}

View File

@@ -4,10 +4,14 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow"
d:DataContext="{d:DesignInstance local:CrossSectionVisualPropertyVM}"
mc:Ignorable="d"
Title="Grid properies" Height="200" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition/>
@@ -18,7 +22,13 @@
</Grid.ColumnDefinitions>
<TextBlock Text="Axis grid thickness"/>
<TextBox Grid.Column="1" Text="{Binding AxisLineThickness, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="1" Text="Mesh size"/>
<TextBlock Grid.Row="1" Text="Grid size"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding GridSize, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="2" Text="Grid line thickness"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding GridLineThickness, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="3" Text="Work plane width"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding WorkPlainWidth, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="4" Text="Work plane height"/>
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding WorkPlainHeight, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
</Grid>
</Window>

View File

@@ -1,5 +1,4 @@
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -20,7 +19,7 @@ namespace StructureHelper.Windows.MainWindow
/// </summary>
public partial class VisualPropertyView : Window
{
public VisualPropertyView(CrossSectionViewVisualProperty vm)
public VisualPropertyView(CrossSectionVisualPropertyVM vm)
{
InitializeComponent();
DataContext = vm;

View File

@@ -81,7 +81,7 @@ namespace StructureHelper.Windows.Services
}
private void RefreshAngle()
{
Angle = Math.Atan2(deltaX, deltaY) * 180d / Math.PI - 90d;
Angle = Math.Atan2(deltaX, deltaY * (-1)) * 180d / Math.PI - 90d;
Angle = Math.Round(Angle, 1);
Distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
Distance = Math.Round(Distance, 3);

View File

@@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
public class CrossSectionViewVisualProperty
{
public double AxisLineThickness { get; set; }
public double GridLineThickness { get; set; }
public double GridSize { get; set; }
public double WorkPlainWidth { get; set; }
public double WorkPlainHeight { get; set; }
public CrossSectionViewVisualProperty()
{
AxisLineThickness = 2d;
GridLineThickness = 0.25d;
GridSize = 0.05d;
WorkPlainWidth = 2.4d;
WorkPlainHeight = 2.0d;
}
}
}

View File

@@ -1,26 +1,21 @@
using FieldVisualizer.ViewModels;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Windows.PrimitiveProperiesWindow;
using StructureHelper.Windows.Services;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelper.Services.Primitives;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperLogics.Models.Primitives;
using ViewModelBase = StructureHelper.Infrastructure.ViewModelBase;
using System.Windows.Forms;
using System.Windows.Documents;
using StructureHelper.Windows.PrimitiveProperiesWindow;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System.Windows.Input;
using StructureHelper.Windows.Services;
using StructureHelperCommon.Models.Shapes;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
@@ -36,8 +31,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private ICommand setToBack;
private ICommand copyToCommand;
public double CanvasWidth { get; set; }
public double CanvasHeight { get; set; }
public double WorkPlaneWidth { get; set; }
public double WorkPlaneHeight { get; set; }
public PrimitiveBase SelectedItem { get; set; }
@@ -101,7 +96,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
viewPrimitive = new CircleViewPrimitive(primitive);
}
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + nameof(primitiveType)); }
viewPrimitive.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
viewPrimitive.RegisterDeltas(WorkPlaneWidth / 2, WorkPlaneHeight / 2);
repository.Primitives.Add(ndmPrimitive);
ndmPrimitive.CrossSection = section;
Items.Add(viewPrimitive);
@@ -244,7 +239,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
primitiveBase.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
primitiveBase.RegisterDeltas(WorkPlaneWidth / 2, WorkPlaneHeight / 2);
Items.Add(primitiveBase);
OnPropertyChanged(nameof(Items));
OnPropertyChanged(nameof(PrimitivesCount));
@@ -306,6 +301,11 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
public void Refresh()
{
foreach (var item in Items)
{
item.RegisterDeltas(WorkPlaneWidth / 2, WorkPlaneHeight / 2);
item.Refresh();
}
OnPropertyChanged(nameof(PrimitivesCount));
}

View File

@@ -24,8 +24,8 @@ namespace StructureHelperCommon.Models
{
var table = new TableLogEntry(2);
table.Priority = Priority;
table.Table.AddRow(GetPointHeaderRow());
table.Table.AddRow(GetPointRow(point2D));
table.Table.AddRow(GetPoint2DHeaderRow());
table.Table.AddRow(GetPoint2DRow(point2D));
return table;
}
/// <summary>
@@ -50,10 +50,10 @@ namespace StructureHelperCommon.Models
{
var table = new TableLogEntry(2);
table.Priority = Priority;
table.Table.AddRow(GetPointHeaderRow());
table.Table.AddRow(GetPoint2DHeaderRow());
foreach (var item in points)
{
table.Table.AddRow(GetPointRow(item));
table.Table.AddRow(GetPoint2DRow(item));
}
return table;
}
@@ -182,7 +182,7 @@ namespace StructureHelperCommon.Models
return forceTupleRow;
}
private ShTableRow<ITraceLoggerEntry> GetPointHeaderRow()
private ShTableRow<ITraceLoggerEntry> GetPoint2DHeaderRow()
{
const CellRole cellRole = CellRole.Header;
@@ -213,7 +213,7 @@ namespace StructureHelperCommon.Models
headerRow.Elements[1] = tableCell;
return headerRow;
}
private ShTableRow<ITraceLoggerEntry> GetPointRow(IPoint2D point2D)
private ShTableRow<ITraceLoggerEntry> GetPoint2DRow(IPoint2D point2D)
{
var pointRow = new ShTableRow<ITraceLoggerEntry>(2);
pointRow.Elements[0].Value = new StringLogEntry()

View File

@@ -11,5 +11,6 @@ namespace StructureHelperCommon.Models
List<ITraceLoggerEntry> TraceLoggerEntries { get; }
void AddMessage(string message, TraceLogStatuses status = TraceLogStatuses.Info, int shiftPriority = 0);
void AddMessage(string message, int priority);
bool KeepErrorStatus { get; set; }
}
}

View File

@@ -12,15 +12,18 @@ namespace StructureHelperCommon.Models
public int ShiftPriority { get; set; }
public List<ITraceLoggerEntry> TraceLoggerEntries => Logger.TraceLoggerEntries;
public bool KeepErrorStatus { get => Logger.KeepErrorStatus; set => Logger.KeepErrorStatus = value; }
public ShiftTraceLogger(ITraceLogger logger)
{
Logger = logger;
KeepErrorStatus = true;
}
public ShiftTraceLogger() : this(new TraceLogger()) { }
public void AddMessage(string message, TraceLogStatuses status = TraceLogStatuses.Info, int shiftPrioriry = 0)
{
// if status in (fatal, error, warning) they must be kept as they are
if (status <= TraceLogStatuses.Warning)
if (status <= TraceLogStatuses.Warning & KeepErrorStatus == true)
{
Logger.AddMessage(message, status);
}

View File

@@ -11,10 +11,12 @@ namespace StructureHelperCommon.Models
public class TraceLogger : ITraceLogger
{
public List<ITraceLoggerEntry> TraceLoggerEntries { get; }
public bool KeepErrorStatus { get; set; }
public TraceLogger()
{
TraceLoggerEntries = new();
KeepErrorStatus = true;
}
public void AddMessage(string message, TraceLogStatuses status = TraceLogStatuses.Info, int shiftPrioriry = 0)

View File

@@ -12,7 +12,7 @@ namespace StructureHelperCommon.Models.Shapes
{
private Directions constDirections;
/// <summary>
/// Direction, for which canstant value is assigned
/// Direction, for which constant value is assigned
/// </summary>
public Directions ConstDirections
{
@@ -31,6 +31,8 @@ namespace StructureHelperCommon.Models.Shapes
/// Constant value for assigned direction
/// </summary>
public double ConstDirectionValue { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public ConstOneDirectionLogic(Directions constDirection, double constValue)
{
ConstDirections = constDirection;
@@ -39,18 +41,46 @@ namespace StructureHelperCommon.Models.Shapes
/// <inheritdoc/>
public IPoint3D GetPoint3D(IPoint2D point2D)
{
TraceLogger?.AddMessage($"Logic convert point from 2D-space to 3D-space");
IPoint3D point;
if (ConstDirections == Directions.X)
{
point = new Point3D() { X = ConstDirectionValue, Y = - point2D.X, Z = point2D.Y };
point = new Point3D()
{
X = ConstDirectionValue,
Y = - point2D.X,
Z = point2D.Y
};
TraceLogger?.AddMessage($"Constant direction is x-direction, so X = {point.X}");
TraceLogger?.AddMessage($"X = ConstantValue = {point.X}");
TraceLogger?.AddMessage($"Y = - point2D.X = {point.Y}");
TraceLogger?.AddMessage($"Z = point2D.Y = {point.Z}");
}
else if (ConstDirections == Directions.Y)
{
point = new Point3D() { X = point2D.X, Y = ConstDirectionValue, Z = point2D.Y };
point = new Point3D()
{
X = point2D.X,
Y = ConstDirectionValue,
Z = point2D.Y
};
TraceLogger?.AddMessage($"Constant direction is Y-direction");
TraceLogger?.AddMessage($"X = point2D.X = {point.X}");
TraceLogger?.AddMessage($"Y = ConstantValue = {point.Y}");
TraceLogger?.AddMessage($"Z = point2D.Y = {point.Z}");
}
else if (ConstDirections == Directions.Z)
{
point = new Point3D() { X = point2D.Y, Y = point2D.X, Z = ConstDirectionValue };
point = new Point3D()
{
X = point2D.Y,
Y = point2D.X,
Z = ConstDirectionValue
};
TraceLogger?.AddMessage($"Constant direction is Z-direction");
TraceLogger?.AddMessage($"X = point2D.Y = {point.X}");
TraceLogger?.AddMessage($"Y = point2D.X = {point.Y}");
TraceLogger?.AddMessage($"Z = ConstantValue = {point.Z}");
}
else
{

View File

@@ -1,4 +1,5 @@
using System;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -13,7 +14,7 @@ namespace StructureHelperCommon.Models.Shapes
/// <summary>
/// Logic for convert 2DPoint of some plane to point of 3DSpace
/// </summary>
public interface IConvert2DPointTo3DPointLogic
public interface IConvert2DPointTo3DPointLogic : ILogic
{
/// <summary>
/// Returns point in 3D-space by 2D point in some workplane

View File

@@ -1,4 +1,5 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
@@ -10,7 +11,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Fac
public PredicateTypes PredicateType { get; set; }
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
public string Name { get; set; }
public ITraceLogger? TraceLogger { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
public Predicate<IPoint2D> GetPredicate()
{
@@ -19,6 +25,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Fac
Ndms = Ndms,
ConvertLogic = ConvertLogic
};
if (TraceLogger is not null)
{
factory.TraceLogger = TraceLogger;
}
TraceLogger?.AddMessage($"Predicate factory was obtained succsefully", TraceLogStatuses.Debug);
var predicateType = PredicateType;
var predicate = factory.GetPredicate(predicateType);
return predicate;

View File

@@ -1,12 +1,12 @@
using StructureHelperCommon.Models;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
{
public interface IGetPredicateLogic
public interface IGetPredicateLogic : ILogic, ICloneable
{
string Name { get; set; }
Predicate<IPoint2D> GetPredicate();
ITraceLogger? TraceLogger { get; set; }
}
}

View File

@@ -1,5 +1,8 @@
using LoaderCalculator.Data.Ndms;
using LoaderCalculator;
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Cracking;
@@ -14,13 +17,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
Strength,
Cracking
}
public class PredicateFactory
public class PredicateFactory : ILogic
{
private ForceTupleCalculator calculator;
private ForceTuple tuple;
private ForceTupleInputData inputData;
private IShiftTraceLogger logger;
public IEnumerable<INdm> Ndms { get; set; }
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public PredicateFactory()
{
inputData = new();
@@ -28,6 +35,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
}
public Predicate<IPoint2D> GetPredicate(PredicateTypes predicateType)
{
if (TraceLogger is not null)
{
logger = new ShiftTraceLogger() { ShiftPriority = 500, KeepErrorStatus = false };
//calculator.TraceLogger = logger; // too much results
//ConvertLogic.TraceLogger = logger; //wrong work in different threads
}
if (predicateType == PredicateTypes.Strength)
{
return point2D => IsSectionFailure(point2D);
@@ -44,6 +57,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private bool IsSectionFailure(IPoint2D point2D)
{
logger?.TraceLoggerEntries.Clear();
var point3D = ConvertLogic.GetPoint3D(point2D);
tuple = new()
{
@@ -54,12 +68,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
inputData.Tuple = tuple;
inputData.NdmCollection = Ndms;
calculator.Run();
if (logger is not null)
{
TraceLogger?.TraceLoggerEntries.AddRange(logger.TraceLoggerEntries);
}
var result = calculator.Result;
return !result.IsValid;
}
private bool IsSectionCracked(IPoint2D point2D)
{
logger?.TraceLoggerEntries.Clear();
var logic = new HoleSectionCrackedLogic();
var point3D = ConvertLogic.GetPoint3D(point2D);
tuple = new()
@@ -72,6 +91,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
logic.NdmCollection = Ndms;
try
{
if (logger is not null)
{
TraceLogger?.TraceLoggerEntries.AddRange(logger.TraceLoggerEntries);
}
var result = logic.IsSectionCracked();
return result;
}

View File

@@ -33,7 +33,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
/// <inheritdoc/>
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
{
if (TraceLogger is not null) { ParameterLogic.TraceLogger = TraceLogger; }
if (TraceLogger is not null)
{
ParameterLogic.TraceLogger = TraceLogger;
}
result = new();
resultList = new();
TraceLogger?.AddMessage($"Predicate name is {GetPredicateLogic.Name}");
@@ -74,12 +77,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private Point2D FindResultPoint(IPoint2D point)
{
Predicate<IPoint2D> limitPredicate;
lock (lockObject)
{
limitPredicate = GetPredicateLogic.GetPredicate();
}
var resultPoint = FindResultPointByPredicate(point, limitPredicate);
var resultPoint = FindResultPointByPredicate(point);
lock (lockObject)
{
pointCount++;
@@ -89,14 +87,23 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
return resultPoint;
}
private Point2D FindResultPointByPredicate(IPoint2D point, Predicate<IPoint2D> limitPredicate)
private Point2D FindResultPointByPredicate(IPoint2D point)
{
ShiftTraceLogger newLogger;
Predicate<IPoint2D> limitPredicate;
lock (lockObject)
{
newLogger = new ShiftTraceLogger()
{
ShiftPriority = 100
};
GetPredicateLogic.TraceLogger = newLogger;
limitPredicate = GetPredicateLogic.GetPredicate();
}
var localCurrentPoint = point.Clone() as IPoint2D;
var logic = ParameterLogic.Clone() as ILimitCurveParameterLogic;
logic.TraceLogger = new ShiftTraceLogger()
{
ShiftPriority=100
};
logic.TraceLogger = newLogger;
logic.CurrentPoint = localCurrentPoint;
logic.LimitPredicate = limitPredicate;
double parameter;
@@ -119,7 +126,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
TraceLogger?.AddMessage($"Source point");
TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(localCurrentPoint));
TraceLogger?.TraceLoggerEntries.AddRange(logic.TraceLogger.TraceLoggerEntries);
TraceLogger?.TraceLoggerEntries.AddRange(newLogger.TraceLoggerEntries);
TraceLogger?.AddMessage($"Parameter value {parameter} was obtained");
TraceLogger?.AddMessage($"Calculated point\n(X={localCurrentPoint.X} * {parameter} = {resultPoint.X},\nY={localCurrentPoint.Y} * {parameter} = {resultPoint.Y})");
TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(resultPoint));

View File

@@ -106,7 +106,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic,
PredicateType = predicateType
};
if (TraceLogger is not null) { getPredicateLogic.TraceLogger = TraceLogger; }
if (TraceLogger is not null)
{
//getPredicateLogic.TraceLogger = TraceLogger;
}
var logic = new LimitCurveLogic(getPredicateLogic);
var calculator = new LimitCurveCalculator(logic)
{

View File

@@ -6,6 +6,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Cracking
{
public class ExpSofteningLogic : ICrackSofteningLogic
@@ -25,6 +28,9 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
powerFactor = value;
}
}
/// <summary>
/// Factor betta in exponential softening model of reinforced concrete
/// </summary>
public double BettaFactor { get; set; }
public double ForceRatio
{
@@ -42,6 +48,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
forceRatio = value;
}
}
/// <inheritdoc/>
public double PsiSMin {get;set;}
public IShiftTraceLogger? TraceLogger { get; set; }
@@ -51,6 +58,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
PowerFactor = 2d;
BettaFactor = 0.8d;
}
/// <inheritdoc/>
public double GetSofteningFactor()
{
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
@@ -59,7 +67,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
TraceLogger?.AddMessage($"But not less than psi_s_min = {PsiSMin}");
TraceLogger?.AddMessage($"BettaFactor = {BettaFactor}");
TraceLogger?.AddMessage($"ForceRatio = {ForceRatio}");
TraceLogger?.AddMessage($"PowerFactor = {BettaFactor}");
TraceLogger?.AddMessage($"PowerFactor = {PowerFactor}");
double psi;
psi = 1 - BettaFactor * Math.Pow(ForceRatio, PowerFactor);
TraceLogger?.AddMessage($"psi_s = 1 - BettaFactor * ForceRatio ^ PowerFactor = 1 - {BettaFactor} * {ForceRatio} ^ {PowerFactor} = {psi}");