Fix cloninng BeamShearAction

This commit is contained in:
Evgeny Redikultsev
2025-05-25 16:07:55 +05:00
parent f127594b5c
commit add2ed8777
31 changed files with 290 additions and 80 deletions

View File

@@ -0,0 +1,28 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Analyses;
using StructureHelperLogics.Models.Analyses;
using System.Windows.Media;
namespace DataAccess.DTOs.DTOEntities
{
public class BeamShearAnalysisDTO : IBeamShearAnalysis
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Tags")]
public string Tags { get; set; }
[JsonProperty("Comment")]
public string Comment { get; set; } = string.Empty;
[JsonProperty("Color")]
public Color Color { get; set; }
public IVersionProcessor VersionProcessor { get; set; } = new VersionProcessorDTO();
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,19 @@
using Newtonsoft.Json;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs.DTOEntities
{
public class BeamShearDTO : IBeamShear
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("Repository")]
public IBeamShearRepository Repository { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,26 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs.DTOEntities
{
public class BeamShearRepositoryDTO : IBeamShearRepository
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("Actions")]
public List<IBeamShearAction> Actions { get; } = new();
[JsonProperty("Calculators")]
public List<ICalculator> Calculators { get; } = new();
[JsonProperty("Sections")]
public List<IBeamShearSection> Sections { get; } = new();
[JsonProperty("Stirrups")]
public List<IStirrup> Stirrups { get; } = new();
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,29 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Forces;
namespace DataAccess.DTOs.DTOEntities
{
public class ConcentratedForceDTO : IConcentratedForce
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("Name")]
public string Name { get; set; } = string.Empty;
[JsonProperty("ForceValue")]
public IForceTuple ForceValue { get; set; }
[JsonProperty("ForceCoordinate")]
public double ForceCoordinate { get; set; }
[JsonProperty("RelativeLoadLevel")]
public double RelativeLoadLevel { get; set; }
[JsonProperty("LoadRatio")]
public double LoadRatio { get; set; }
[JsonProperty("CombinationProperty")]
public IFactoredCombinationProperty CombinationProperty { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,13 +1,6 @@
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using StructureHelperLogic.Models.Analyses;
using StructureHelperLogics.Models.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace DataAccess.DTOs
@@ -15,7 +8,7 @@ namespace DataAccess.DTOs
public class CrossSectionNdmAnalysisDTO : ICrossSectionNdmAnalysis
{
[JsonProperty("Id")]
public Guid Id { get; set; }
public Guid Id { get; set;}
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Tags")]

View File

@@ -0,0 +1,31 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Forces;
namespace DataAccess.DTOs.DTOEntities
{
public class DistributedLoadDTO : IDistributedLoad
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("Name")]
public string Name { get; set; } = string.Empty;
[JsonProperty("LoadValue")]
public IForceTuple LoadValue { get; set; }
[JsonProperty("StartCoordinate")]
public double StartCoordinate { get; set; }
[JsonProperty("EndCoordinate")]
public double EndCoordinate { get; set; }
[JsonProperty("RelativeLoadLevel")]
public double RelativeLoadLevel { get; set; }
[JsonProperty("LoadRatio")]
public double LoadRatio { get; set; }
[JsonProperty("CombinationProperty")]
public IFactoredCombinationProperty CombinationProperty { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -4,6 +4,7 @@ using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using StructureHelperLogics.Models.BeamShears;
using System.Collections.Generic;
using System.Windows.Forms;
namespace StructureHelper.Windows.BeamShears
{
@@ -36,8 +37,12 @@ namespace StructureHelper.Windows.BeamShears
}
public override void DeleteMethod(object parameter)
{
BeamShearRepositoryService.DeleteAction(shearRepository, SelectedItem);
base.DeleteMethod(parameter);
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
BeamShearRepositoryService.DeleteAction(shearRepository, SelectedItem);
base.DeleteMethod(parameter);
}
}
}
}

View File

@@ -10,6 +10,7 @@ using StructureHelperCommon.Models.Forces.BeamShearActions;
using StructureHelperLogics.Models.BeamShears;
using System;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
namespace StructureHelper.Windows.BeamShears
@@ -46,6 +47,15 @@ namespace StructureHelper.Windows.BeamShears
base.EditMethod(parameter);
}
public override void DeleteMethod(object parameter)
{
var dialogResult = System.Windows.Forms.MessageBox.Show("Delete calculator?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
base.DeleteMethod(parameter);
}
}
public BeamShearCalculatorsViewModel(IBeamShearRepository shearRepository) : base(shearRepository.Calculators)
{
this.shearRepository = shearRepository;

View File

@@ -6,6 +6,7 @@ using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Forms;
namespace StructureHelper.Windows.BeamShears
{
@@ -57,5 +58,13 @@ namespace StructureHelper.Windows.BeamShears
}
base.EditMethod(parameter);
}
public override void DeleteMethod(object parameter)
{
var dialogResult = System.Windows.Forms.MessageBox.Show("Delete load?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
base.DeleteMethod(parameter);
}
}
}
}

View File

@@ -6,6 +6,7 @@ using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.BeamShears;
using System;
using System.Windows;
using System.Windows.Forms;
namespace StructureHelper.Windows.BeamShears
{
@@ -66,8 +67,13 @@ namespace StructureHelper.Windows.BeamShears
public override void DeleteMethod(object parameter)
{
BeamShearRepositoryService.DeleteSection(shearRepository, SelectedItem);
base.DeleteMethod(parameter);
var dialogResult = System.Windows.Forms.MessageBox.Show("Delete stirrup?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
BeamShearRepositoryService.DeleteSection(shearRepository, SelectedItem);
base.DeleteMethod(parameter);
}
}
}
}

View File

@@ -8,6 +8,7 @@ using StructureHelperLogics.Models.BeamShears.Logics;
using StructureHelperLogics.Models.Materials;
using System;
using System.Windows;
using System.Windows.Forms;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
@@ -113,8 +114,12 @@ namespace StructureHelper.Windows.BeamShears
public override void DeleteMethod(object parameter)
{
BeamShearRepositoryService.DeleteStirrup(shearRepository, SelectedItem);
base.DeleteMethod(parameter);
var dialogResult = System.Windows.Forms.MessageBox.Show("Delete stirrup?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
BeamShearRepositoryService.DeleteStirrup(shearRepository, SelectedItem);
base.DeleteMethod(parameter);
}
}
}
}

View File

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Creates deep copy of object by dictionary (if copy of object is not created it create copy, otherwise take copy from dictionary)
/// Creates deep copy of object by dictionary (if copy of object is not created it creates copy, otherwise take copy from dictionary)
/// </summary>
public class DeepCloningStrategy : ICloningStrategy
{

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Creates deep clone of object

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Interface for cloning objects

View File

@@ -15,9 +15,9 @@ namespace StructureHelperCommon.Models.Forces.BeamShearActions
/// <inheritdoc/>
public string Name { get; set; }
/// <inheritdoc/>
public IFactoredForceTuple ExternalForce { get; } = new FactoredForceTuple(Guid.NewGuid());
public IFactoredForceTuple ExternalForce { get; set; } = new FactoredForceTuple(Guid.NewGuid());
/// <inheritdoc/>
public IBeamShearAxisAction SupportAction { get; } = new BeamShearAxisAction(Guid.NewGuid());
public IBeamShearAxisAction SupportAction { get; set; } = new BeamShearAxisAction(Guid.NewGuid());
public BeamShearAction(Guid id)
{
@@ -26,10 +26,10 @@ namespace StructureHelperCommon.Models.Forces.BeamShearActions
public object Clone()
{
BeamShearAction beamShearAction = new(Guid.NewGuid());
BeamShearAction newItem = new(Guid.NewGuid());
updateStrategy ??= new BeamShearActionUpdateStrategy();
updateStrategy.Update(beamShearAction, this);
return beamShearAction;
updateStrategy.Update(newItem, this);
return newItem;
}
}
}

View File

@@ -0,0 +1,19 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperCommon.Models.Forces.BeamShearActions
{
internal class BeamShearActionCloneStrategy : ICloneStrategy<IBeamShearAction>
{
private BeamShearAction targetObject;
public IBeamShearAction GetClone(IBeamShearAction sourceObject)
{
targetObject = new(Guid.NewGuid());
return targetObject;
}
}
}

View File

@@ -12,6 +12,7 @@ namespace StructureHelperCommon.Models.Forces.BeamShearActions
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name;
targetObject.ExternalForce = sourceObject.ExternalForce.Clone() as IFactoredForceTuple;
InitializeStrategies();
CheckObject.IsNull(sourceObject.SupportAction);
CheckObject.IsNull(targetObject.SupportAction);

View File

@@ -0,0 +1,40 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces.BeamShearActions
{
internal class BeamShearAxisActionCloneStrategy : ICloneStrategy<IBeamShearAxisAction>
{
private ICloningStrategy cloningStrategy;
private IUpdateStrategy<IBeamShearAxisAction> updateStrategy;
public BeamShearAxisActionCloneStrategy(ICloningStrategy cloningStrategy)
{
this.cloningStrategy = cloningStrategy;
}
private BeamShearAxisAction targetObject;
public IBeamShearAxisAction GetClone(IBeamShearAxisAction sourceObject)
{
InitializeStrategies();
targetObject = new(Guid.NewGuid());
updateStrategy.Update(targetObject, sourceObject);
targetObject.ShearLoads.Clear();
foreach (var shearLoad in sourceObject.ShearLoads)
{
targetObject.ShearLoads.Add(cloningStrategy.Clone(shearLoad));
}
return targetObject;
}
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearAxisActionUpdateStrategy();
}
}
}

View File

@@ -1,11 +1,9 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces.Logics;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperCommon.Models.Forces.BeamShearActions
{
@@ -19,10 +17,7 @@ namespace StructureHelperCommon.Models.Forces.BeamShearActions
if (ReferenceEquals(targetObject, sourceObject)) { return; }
InitializeStrategies();
targetObject.Name = sourceObject.Name;
targetObject.SupportForce = sourceObject.SupportForce;
CheckObject.IsNull(targetObject.SupportForce.CombinationProperty);
CheckObject.IsNull(sourceObject.SupportForce.CombinationProperty);
combinationUpdateStrategy.Update(targetObject.SupportForce.CombinationProperty, sourceObject.SupportForce.CombinationProperty);
targetObject.SupportForce = sourceObject.SupportForce.Clone() as IFactoredForceTuple;
CheckObject.IsNull(targetObject.ShearLoads);
targetObject.ShearLoads.Clear();
CheckObject.IsNull(sourceObject.ShearLoads);

View File

@@ -13,7 +13,7 @@ namespace StructureHelperCommon.Models.Forces.BeamShearActions
if (ReferenceEquals(targetObject, sourceObject)) { return; }
InitializeStrategies();
baseUpdateStrategy.Update(targetObject, sourceObject);
targetObject.ForceValue = sourceObject.ForceValue;
targetObject.ForceValue = sourceObject.ForceValue.Clone() as IForceTuple;
targetObject.ForceCoordinate = sourceObject.ForceCoordinate;
}

View File

@@ -13,7 +13,7 @@ namespace StructureHelperCommon.Models.Forces.BeamShearActions
if (ReferenceEquals(targetObject, sourceObject)) { return; }
InitializeStrategies();
baseUpdateStrategy.Update(targetObject, sourceObject);
targetObject.LoadValue = sourceObject.LoadValue;
targetObject.LoadValue = sourceObject.LoadValue.Clone() as IForceTuple;
targetObject.StartCoordinate = sourceObject.StartCoordinate;
targetObject.EndCoordinate = sourceObject.EndCoordinate;
}

View File

@@ -17,10 +17,10 @@ namespace StructureHelperCommon.Models.Forces
/// <summary>
/// External force at the end of bar
/// </summary>
IFactoredForceTuple ExternalForce { get; }
IFactoredForceTuple ExternalForce { get; set; }
/// <summary>
/// Internal loads on bar
/// </summary>
IBeamShearAxisAction SupportAction { get; }
IBeamShearAxisAction SupportAction { get; set; }
}
}

View File

@@ -42,10 +42,10 @@ namespace StructureHelperCommon.Models.Forces
public object Clone()
{
DistributedLoad distributedLoad = new(Guid.NewGuid());
DistributedLoad newItem = new(Guid.NewGuid());
updateStrategy ??= new DistributedLoadUpdateStrategy();
updateStrategy.Update(distributedLoad, this);
return distributedLoad;
updateStrategy.Update(newItem, this);
return newItem;
}
}
}

View File

@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
namespace StructureHelperCommon.Models.Forces
{
public class FactoredForceTuple : IFactoredForceTuple
{
private IUpdateStrategy<IFactoredForceTuple> updateStrategy;
public Guid Id { get; }
public IForceTuple ForceTuple { get; set; } = new ForceTuple();
public IFactoredCombinationProperty CombinationProperty { get; set; } = new FactoredCombinationProperty(Guid.NewGuid());
@@ -19,7 +18,10 @@ namespace StructureHelperCommon.Models.Forces
public object Clone()
{
throw new NotImplementedException();
updateStrategy ??= new FactoredForceTupleUpdateStrategy();
FactoredForceTuple newItem = new(Guid.NewGuid());
updateStrategy.Update(newItem, this);
return newItem;
}
}
}

View File

@@ -1,10 +1,5 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces.Logics
{
@@ -15,10 +10,10 @@ namespace StructureHelperCommon.Models.Forces.Logics
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.LimitState = sourceObject.LimitState;
targetObject.ULSFactor = sourceObject.ULSFactor;
targetObject.LongTermFactor = sourceObject.LongTermFactor;
targetObject.CalcTerm = sourceObject.CalcTerm;
targetObject.LimitState = sourceObject.LimitState;
}
}
}

View File

@@ -0,0 +1,24 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
public class FactoredForceTupleUpdateStrategy : IUpdateStrategy<IFactoredForceTuple>
{
public void Update(IFactoredForceTuple targetObject, IFactoredForceTuple sourceObject)
{
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.IsNull(sourceObject.ForceTuple);
targetObject.ForceTuple = sourceObject.ForceTuple.Clone() as IForceTuple;
CheckObject.IsNull(sourceObject.CombinationProperty);
targetObject.CombinationProperty = sourceObject.CombinationProperty.Clone() as IFactoredCombinationProperty;
}
}
}

View File

@@ -1,14 +1,6 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes.Logics;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Forces.Logics;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.

View File

@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Services;
namespace StructureHelperLogics.Models.BeamShears

View File

@@ -1,5 +1,4 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.WorkPlanes;
using StructureHelperCommon.Services;

View File

@@ -1,9 +1,4 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
{