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

@@ -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