FixActionDeleting
This commit is contained in:
@@ -1,21 +1,13 @@
|
||||
using StructureHelper.Infrastructure.UI.Converters.Units;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Parameters;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.Units;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
|
||||
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Windows.PrimitivePropertiesWindow;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.Factories;
|
||||
using StructureHelper.Windows.Services;
|
||||
using StructureHelper.Windows.ViewModels.Errors;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
@@ -115,7 +116,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
|
||||
private void RemoveFromRepository(PrimitiveBase item)
|
||||
{
|
||||
repository.Primitives.Remove(item.NdmPrimitive);
|
||||
repository.Operations.Primitives.Remove(item.GetNdmPrimitive());
|
||||
Items.Remove(item);
|
||||
}
|
||||
|
||||
@@ -178,43 +179,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
|
||||
private void AddPrimitive(PrimitiveType primitiveType)
|
||||
{
|
||||
PrimitiveBase viewPrimitive;
|
||||
INdmPrimitive ndmPrimitive;
|
||||
if (primitiveType == PrimitiveType.Rectangle)
|
||||
{
|
||||
RectangleNdmPrimitive primitive = GetNewRectanglePrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new RectangleViewPrimitive(primitive);
|
||||
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Reinforcement)
|
||||
{
|
||||
RebarNdmPrimitive primitive = GetNewReinforcementPrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new ReinforcementViewPrimitive(primitive);
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Point)
|
||||
{
|
||||
PointNdmPrimitive primitive = GetNewPointPrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new PointViewPrimitive(primitive);
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Circle)
|
||||
{
|
||||
EllipseNdmPrimitive primitive = GetNewCirclePrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new CircleViewPrimitive(primitive);
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Polygon)
|
||||
{
|
||||
ShapeNdmPrimitive primitive = GetNewPolygonPrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new ShapeViewPrimitive(primitive);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + nameof(primitiveType));
|
||||
}
|
||||
PrimitiveBase viewPrimitive = PrimitiveBaseFactory.GetPrimitive(primitiveType);
|
||||
INdmPrimitive ndmPrimitive = viewPrimitive.GetNdmPrimitive();
|
||||
viewPrimitive.OnNext(this);
|
||||
repository.Primitives.Add(ndmPrimitive);
|
||||
ndmPrimitive.CrossSection = section;
|
||||
@@ -223,56 +189,6 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
OnPropertyChanged(nameof(PrimitivesCount));
|
||||
}
|
||||
|
||||
private ShapeNdmPrimitive GetNewPolygonPrimitive()
|
||||
{
|
||||
LinePolygonShape polygon = new(Guid.NewGuid());
|
||||
polygon.AddVertex(new Vertex(-0.2, 0.3));
|
||||
polygon.AddVertex(new Vertex(0.2, 0.3));
|
||||
polygon.AddVertex(new Vertex(0.1, 0));
|
||||
polygon.AddVertex(new Vertex(0.2, -0.3));
|
||||
polygon.AddVertex(new Vertex(-0.2, -0.3));
|
||||
polygon.AddVertex(new Vertex(-0.1, 0));
|
||||
ShapeNdmPrimitive shapeNdmPrimitive = new(Guid.NewGuid())
|
||||
{
|
||||
Name = "New polygon primitive"
|
||||
};
|
||||
shapeNdmPrimitive.SetShape(polygon);
|
||||
return shapeNdmPrimitive;
|
||||
}
|
||||
|
||||
private static EllipseNdmPrimitive GetNewCirclePrimitive()
|
||||
{
|
||||
return new EllipseNdmPrimitive
|
||||
{
|
||||
Width = 0.5d
|
||||
};
|
||||
}
|
||||
|
||||
private static PointNdmPrimitive GetNewPointPrimitive()
|
||||
{
|
||||
return new PointNdmPrimitive
|
||||
{
|
||||
Area = 0.0005d
|
||||
};
|
||||
}
|
||||
|
||||
private static RebarNdmPrimitive GetNewReinforcementPrimitive()
|
||||
{
|
||||
return new RebarNdmPrimitive
|
||||
{
|
||||
Area = 0.0005d
|
||||
};
|
||||
}
|
||||
|
||||
private static RectangleNdmPrimitive GetNewRectanglePrimitive()
|
||||
{
|
||||
return new RectangleNdmPrimitive
|
||||
{
|
||||
Width = 0.4d,
|
||||
Height = 0.6d
|
||||
};
|
||||
}
|
||||
|
||||
public ICommand Delete
|
||||
{
|
||||
get
|
||||
@@ -291,47 +207,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
var dialogResult = MessageBox.Show("Delete primitive?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
var ndmPrimitive = SelectedItem.GetNdmPrimitive();
|
||||
repository.Primitives.Remove(ndmPrimitive);
|
||||
foreach (var calc in repository.Calculators)
|
||||
{
|
||||
if (calc is IForceCalculator forceCalculator)
|
||||
{
|
||||
var forceCalc = forceCalculator.InputData as IHasPrimitives;
|
||||
forceCalc.Primitives.Remove(ndmPrimitive);
|
||||
}
|
||||
else if (calc is ILimitCurvesCalculator calculator)
|
||||
{
|
||||
//to do
|
||||
//var forceCalc = calculator.InputData as IHasPrimitives;
|
||||
//forceCalc.Primitives.Remove(ndmPrimitive);
|
||||
}
|
||||
else if (calc is ICrackCalculator crackCalculator)
|
||||
{
|
||||
var forceCalc = crackCalculator.InputData as IHasPrimitives;
|
||||
forceCalc.Primitives.Remove(ndmPrimitive);
|
||||
}
|
||||
else if (calc is IValueDiagramCalculator diagramCalculator)
|
||||
{
|
||||
var forceCalc = diagramCalculator.InputData as IHasPrimitives;
|
||||
forceCalc.Primitives.Remove(ndmPrimitive);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc));
|
||||
}
|
||||
}
|
||||
foreach (var primitive in repository.Primitives)
|
||||
{
|
||||
if (primitive is IHasHostPrimitive sPrimitive)
|
||||
{
|
||||
if (sPrimitive.HostPrimitive == ndmPrimitive)
|
||||
{
|
||||
sPrimitive.HostPrimitive = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Items.Remove(SelectedItem);
|
||||
RemoveFromRepository(SelectedItem);
|
||||
}
|
||||
OnPropertyChanged(nameof(Items));
|
||||
OnPropertyChanged(nameof(PrimitivesCount));
|
||||
@@ -409,38 +285,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
|
||||
private PrimitiveBase CopySelectedItem(INdmPrimitive oldPrimitive)
|
||||
{
|
||||
var newPrimitive = oldPrimitive.Clone() as INdmPrimitive;
|
||||
newPrimitive.Name += " copy";
|
||||
repository.Primitives.Add(newPrimitive);
|
||||
PrimitiveBase primitiveBase;
|
||||
if (newPrimitive is IRectangleNdmPrimitive rectangle)
|
||||
{
|
||||
primitiveBase = new RectangleViewPrimitive(rectangle);
|
||||
}
|
||||
else if (newPrimitive is IEllipseNdmPrimitive ellipse)
|
||||
{
|
||||
primitiveBase = new CircleViewPrimitive(ellipse);
|
||||
}
|
||||
else if (newPrimitive is IShapeNdmPrimitive shapeNDMPrimitive)
|
||||
{
|
||||
primitiveBase = new ShapeViewPrimitive(shapeNDMPrimitive);
|
||||
}
|
||||
else if (newPrimitive is IPointNdmPrimitive)
|
||||
{
|
||||
if (newPrimitive is RebarNdmPrimitive rebar)
|
||||
{
|
||||
primitiveBase = new ReinforcementViewPrimitive(rebar);
|
||||
}
|
||||
else
|
||||
{
|
||||
primitiveBase = new PointViewPrimitive(newPrimitive as IPointNdmPrimitive);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
|
||||
}
|
||||
PrimitiveBase primitiveBase = PrimitiveBaseFactory.GetCloneByNdmPrimitive(oldPrimitive);
|
||||
INdmPrimitive newNdmPrimitive = primitiveBase.GetNdmPrimitive();
|
||||
repository.Primitives.Add(newNdmPrimitive);
|
||||
primitiveBase.OnNext(this);
|
||||
Items.Add(primitiveBase);
|
||||
OnPropertyChanged(nameof(Items));
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelper.Windows.PrimitiveTemplates.Factories
|
||||
{
|
||||
public static class PrimitiveBaseFactory
|
||||
{
|
||||
public static PrimitiveBase GetPrimitive(PrimitiveType primitiveType)
|
||||
{
|
||||
PrimitiveBase viewPrimitive;
|
||||
INdmPrimitive ndmPrimitive;
|
||||
if (primitiveType == PrimitiveType.Rectangle)
|
||||
{
|
||||
RectangleNdmPrimitive primitive = GetNewRectanglePrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new RectangleViewPrimitive(primitive);
|
||||
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Reinforcement)
|
||||
{
|
||||
RebarNdmPrimitive primitive = GetNewReinforcementPrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new ReinforcementViewPrimitive(primitive);
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Point)
|
||||
{
|
||||
PointNdmPrimitive primitive = GetNewPointPrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new PointViewPrimitive(primitive);
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Circle)
|
||||
{
|
||||
EllipseNdmPrimitive primitive = GetNewCirclePrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new CircleViewPrimitive(primitive);
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Polygon)
|
||||
{
|
||||
ShapeNdmPrimitive primitive = GetNewPolygonPrimitive();
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new ShapeViewPrimitive(primitive);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + nameof(primitiveType));
|
||||
}
|
||||
return viewPrimitive;
|
||||
}
|
||||
|
||||
public static PrimitiveBase GetCloneByNdmPrimitive(INdmPrimitive ndmPrimitive)
|
||||
{
|
||||
var newPrimitive = ndmPrimitive.Clone() as INdmPrimitive;
|
||||
newPrimitive.Name += " copy";
|
||||
PrimitiveBase primitiveBase;
|
||||
if (newPrimitive is IRectangleNdmPrimitive rectangle)
|
||||
{
|
||||
primitiveBase = new RectangleViewPrimitive(rectangle);
|
||||
}
|
||||
else if (newPrimitive is IEllipseNdmPrimitive ellipse)
|
||||
{
|
||||
primitiveBase = new CircleViewPrimitive(ellipse);
|
||||
}
|
||||
else if (newPrimitive is IShapeNdmPrimitive shapeNDMPrimitive)
|
||||
{
|
||||
primitiveBase = new ShapeViewPrimitive(shapeNDMPrimitive);
|
||||
}
|
||||
else if (newPrimitive is IPointNdmPrimitive)
|
||||
{
|
||||
if (newPrimitive is RebarNdmPrimitive rebar)
|
||||
{
|
||||
primitiveBase = new ReinforcementViewPrimitive(rebar);
|
||||
}
|
||||
else
|
||||
{
|
||||
primitiveBase = new PointViewPrimitive(newPrimitive as IPointNdmPrimitive);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
|
||||
}
|
||||
return primitiveBase;
|
||||
}
|
||||
|
||||
|
||||
private static ShapeNdmPrimitive GetNewPolygonPrimitive()
|
||||
{
|
||||
LinePolygonShape polygon = new(Guid.NewGuid());
|
||||
polygon.AddVertex(new Vertex(-0.2, 0.3));
|
||||
polygon.AddVertex(new Vertex(0.2, 0.3));
|
||||
polygon.AddVertex(new Vertex(0.1, 0));
|
||||
polygon.AddVertex(new Vertex(0.2, -0.3));
|
||||
polygon.AddVertex(new Vertex(-0.2, -0.3));
|
||||
polygon.AddVertex(new Vertex(-0.1, 0));
|
||||
ShapeNdmPrimitive shapeNdmPrimitive = new(Guid.NewGuid())
|
||||
{
|
||||
Name = "New polygon primitive"
|
||||
};
|
||||
shapeNdmPrimitive.SetShape(polygon);
|
||||
return shapeNdmPrimitive;
|
||||
}
|
||||
|
||||
private static EllipseNdmPrimitive GetNewCirclePrimitive()
|
||||
{
|
||||
return new EllipseNdmPrimitive
|
||||
{
|
||||
Width = 0.5d
|
||||
};
|
||||
}
|
||||
|
||||
private static PointNdmPrimitive GetNewPointPrimitive()
|
||||
{
|
||||
return new PointNdmPrimitive
|
||||
{
|
||||
Area = 0.0005d
|
||||
};
|
||||
}
|
||||
|
||||
private static RebarNdmPrimitive GetNewReinforcementPrimitive()
|
||||
{
|
||||
return new RebarNdmPrimitive
|
||||
{
|
||||
Area = 0.0005d
|
||||
};
|
||||
}
|
||||
|
||||
private static RectangleNdmPrimitive GetNewRectanglePrimitive()
|
||||
{
|
||||
return new RectangleNdmPrimitive
|
||||
{
|
||||
Width = 0.4d,
|
||||
Height = 0.6d
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,9 @@ using StructureHelper.Windows.Forces;
|
||||
using StructureHelper.Windows.ViewModels.Errors;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
@@ -50,25 +44,24 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
|
||||
public override void AddMethod(object parameter)
|
||||
{
|
||||
if (parameter is not null)
|
||||
if (parameter is null) { return; }
|
||||
|
||||
var paramType = (ActionType)parameter;
|
||||
if (paramType == ActionType.ForceCombination)
|
||||
{
|
||||
var paramType = (ActionType)parameter;
|
||||
if (paramType == ActionType.ForceCombination)
|
||||
{
|
||||
NewItem = new ForceCombinationList() { Name = "New Force Combination" };
|
||||
}
|
||||
else if (paramType == ActionType.ForceCombinationByFactor)
|
||||
{
|
||||
NewItem = new ForceFactoredList() { Name = "New Factored Combination" };
|
||||
}
|
||||
else if (paramType == ActionType.ForceCombinationFromFile)
|
||||
{
|
||||
NewItem = new ForceCombinationFromFile { Name = "New Combination from file" };
|
||||
}
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $": Actual type: {nameof(paramType)}");
|
||||
//GlobalRepository.Actions.Create(NewItem);
|
||||
base.AddMethod(parameter);
|
||||
NewItem = new ForceCombinationList() { Name = "New Force Combination" };
|
||||
}
|
||||
else if (paramType == ActionType.ForceCombinationByFactor)
|
||||
{
|
||||
NewItem = new ForceFactoredList() { Name = "New Factored Combination" };
|
||||
}
|
||||
else if (paramType == ActionType.ForceCombinationFromFile)
|
||||
{
|
||||
NewItem = new ForceCombinationFromFile { Name = "New Combination from file" };
|
||||
}
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $": Actual type: {nameof(paramType)}");
|
||||
//GlobalRepository.Actions.Create(NewItem);
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
|
||||
public override void DeleteMethod(object parameter)
|
||||
@@ -128,34 +121,10 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
|
||||
private void DeleteAction()
|
||||
{
|
||||
var calcRepository = repository.Calculators;
|
||||
IHasForceActions forceCombinations;
|
||||
foreach (var calc in calcRepository)
|
||||
SafetyProcessor.RunSafeProcess(delegate ()
|
||||
{
|
||||
if (calc is IForceCalculator forceCalculator)
|
||||
{
|
||||
forceCombinations = forceCalculator.InputData;
|
||||
forceCombinations.ForceActions.Remove(SelectedItem);
|
||||
}
|
||||
else if (calc is ICrackCalculator crackCalculator)
|
||||
{
|
||||
forceCombinations = crackCalculator.InputData;
|
||||
forceCombinations.ForceActions.Remove(SelectedItem);
|
||||
}
|
||||
else if (calc is ILimitCurvesCalculator)
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
else if (calc is IValueDiagramCalculator diagramCalculator)
|
||||
{
|
||||
forceCombinations = diagramCalculator.InputData;
|
||||
forceCombinations.ForceActions.Remove(SelectedItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc));
|
||||
}
|
||||
}
|
||||
repository.Operations.Actions.Remove(SelectedItem);
|
||||
},"Error of action deleting");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,42 +45,15 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
IPoint3D point;
|
||||
if (ConstDirections == Directions.X)
|
||||
{
|
||||
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}");
|
||||
point = GetByX(point2D);
|
||||
}
|
||||
else if (ConstDirections == Directions.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}");
|
||||
point = GetByY(point2D);
|
||||
}
|
||||
else if (ConstDirections == Directions.Z)
|
||||
{
|
||||
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}");
|
||||
point = GetByZ(point2D);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -88,5 +61,50 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
private IPoint3D GetByZ(IPoint2D point2D)
|
||||
{
|
||||
IPoint3D point = new Point3D()
|
||||
{
|
||||
X = -point2D.X,
|
||||
Y = -point2D.Y,
|
||||
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}");
|
||||
return point;
|
||||
}
|
||||
|
||||
private IPoint3D GetByY(IPoint2D point2D)
|
||||
{
|
||||
IPoint3D 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}");
|
||||
return point;
|
||||
}
|
||||
|
||||
private IPoint3D GetByX(IPoint2D point2D)
|
||||
{
|
||||
IPoint3D 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}");
|
||||
return point;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -8,6 +9,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public interface IRepositoryOperationsLogic
|
||||
{
|
||||
IRepositoryOperation<ICrossSectionRepository, IForceAction> Actions { get; }
|
||||
IRepositoryOperation<ICrossSectionRepository, INdmPrimitive> Primitives { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
|
||||
namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class RepositoryActionOperations : IRepositoryOperation<ICrossSectionRepository, IForceAction>
|
||||
{
|
||||
private ICrossSectionRepository repository;
|
||||
|
||||
public RepositoryActionOperations(ICrossSectionRepository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public void Remove(IForceAction entity)
|
||||
{
|
||||
foreach (var calc in repository.Calculators)
|
||||
{
|
||||
if (calc is IForceCalculator forceCalculator)
|
||||
{
|
||||
forceCalculator.InputData.ForceActions.Remove(entity);
|
||||
}
|
||||
else if (calc is ICrackCalculator crackCalculator)
|
||||
{
|
||||
crackCalculator.InputData.ForceActions.Remove(entity);
|
||||
}
|
||||
else if (calc is ILimitCurvesCalculator)
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
else if (calc is IValueDiagramCalculator diagramCalculator)
|
||||
{
|
||||
diagramCalculator.InputData.ForceActions.Remove(entity);
|
||||
}
|
||||
else if (calc is ICurvatureCalculator curvatureCalculator)
|
||||
{
|
||||
curvatureCalculator.InputData.ForceActions.Remove(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc));
|
||||
}
|
||||
}
|
||||
repository.ForceActions.Remove(entity);
|
||||
}
|
||||
|
||||
public void Remove(IEnumerable<IForceAction> entities)
|
||||
{
|
||||
foreach (var item in entities)
|
||||
{
|
||||
Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using NLog.LayoutRenderers;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.Models.CrossSections
|
||||
@@ -7,6 +10,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
private ICrossSectionRepository repository;
|
||||
private RepositoryPrimitiveOperation primitiveLogic;
|
||||
private IRepositoryOperation<ICrossSectionRepository, IForceAction> actionLogic;
|
||||
|
||||
public RepositoryOperationsLogic(ICrossSectionRepository repository)
|
||||
{
|
||||
@@ -14,5 +18,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
}
|
||||
|
||||
public IRepositoryOperation<ICrossSectionRepository, INdmPrimitive> Primitives => primitiveLogic ??= new RepositoryPrimitiveOperation(repository);
|
||||
|
||||
public IRepositoryOperation<ICrossSectionRepository, IForceAction> Actions => actionLogic ??= new RepositoryActionOperations(repository);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,13 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
public void Remove(INdmPrimitive entity)
|
||||
{
|
||||
var childPrimitives = repository.Primitives
|
||||
.Where(x => x is IHasHostPrimitive)
|
||||
.Where(x => (x as IHasHostPrimitive).HostPrimitive == entity);
|
||||
foreach (var child in childPrimitives)
|
||||
{
|
||||
(child as IHasHostPrimitive).HostPrimitive = null;
|
||||
}
|
||||
foreach (var calculator in repository.Calculators)
|
||||
{
|
||||
if (calculator is IForceCalculator forceCalculator)
|
||||
|
||||
Reference in New Issue
Block a user