Add version processor window
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelperLogic.Models.Analyses
|
||||
{
|
||||
@@ -11,6 +13,8 @@ namespace StructureHelperLogic.Models.Analyses
|
||||
public string Name { get; set; }
|
||||
public string Tags { get; set; }
|
||||
public IVersionProcessor VersionProcessor { get; set; }
|
||||
public string Comment { get; set; } = string.Empty;
|
||||
public Color Color { get; set; } = Color.FromRgb(128, 0, 0);
|
||||
|
||||
public CrossSectionNdmAnalysis(Guid id, IVersionProcessor versionProcessor)
|
||||
{
|
||||
@@ -33,6 +37,10 @@ namespace StructureHelperLogic.Models.Analyses
|
||||
{
|
||||
CrossSectionNdmAnalysis newAnalysis = new();
|
||||
updateStrategy.Update(newAnalysis, this);
|
||||
var currentVersion = VersionProcessor.GetCurrentVersion().AnalysisVersion as ICloneable;
|
||||
ISaveable newCrossSection = currentVersion.Clone() as ISaveable;
|
||||
newAnalysis.VersionProcessor.Versions.Clear();
|
||||
newAnalysis.VersionProcessor.AddVersion(newCrossSection);
|
||||
return newAnalysis;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -8,6 +9,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class CrossSection : ICrossSection
|
||||
{
|
||||
private ICloneStrategy<ICrossSection> cloneStrategy = new CrossSectionCloneStrategy();
|
||||
public ICrossSectionRepository SectionRepository { get; set; } = new CrossSectionRepository();
|
||||
|
||||
public Guid Id { get; private set; }
|
||||
@@ -24,7 +26,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return cloneStrategy.GetClone(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class CrossSectionCloneStrategy : ICloneStrategy<ICrossSection>
|
||||
{
|
||||
private ICloneStrategy<ICrossSectionRepository> repositoryCloneStrategy;
|
||||
private CrossSection targetObject;
|
||||
|
||||
public CrossSectionCloneStrategy(ICloneStrategy<ICrossSectionRepository> repositoryCloneStrategy)
|
||||
{
|
||||
this.repositoryCloneStrategy = repositoryCloneStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionCloneStrategy() : this (new CrossSectionRepositoryCloneStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ICrossSection GetClone(ICrossSection sourceObject)
|
||||
{
|
||||
ICrossSectionRepository newRepository = repositoryCloneStrategy.GetClone(sourceObject.SectionRepository);
|
||||
targetObject = new()
|
||||
{
|
||||
SectionRepository = newRepository
|
||||
};
|
||||
return targetObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Parameters;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class CrossSectionRepositoryCloneStrategy : ICloneStrategy<ICrossSectionRepository>
|
||||
{
|
||||
private ICloningStrategy cloningStrategy;
|
||||
private CrossSectionRepository targetRepository;
|
||||
private IUpdateStrategy<ILimitCurvesCalculatorInputData> limitCurvesInputDataUpdateStrategy;
|
||||
|
||||
public CrossSectionRepositoryCloneStrategy(
|
||||
ICloningStrategy cloningStrategy,
|
||||
IUpdateStrategy<ILimitCurvesCalculatorInputData> limitCurvesInputDataUpdateStrategy)
|
||||
{
|
||||
this.cloningStrategy = cloningStrategy;
|
||||
this.limitCurvesInputDataUpdateStrategy = limitCurvesInputDataUpdateStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionRepositoryCloneStrategy() : this (
|
||||
new DeepCloningStrategy(),
|
||||
new LimitCurvesCalculatorInputDataUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ICrossSectionRepository GetClone(ICrossSectionRepository sourceObject)
|
||||
{
|
||||
targetRepository = new();
|
||||
ProcessForces(targetRepository, sourceObject);
|
||||
ProcessMaterials(targetRepository, sourceObject);
|
||||
ProcessPrimitives(targetRepository, sourceObject);
|
||||
ProcessCalculators(targetRepository, sourceObject);
|
||||
return targetRepository;
|
||||
}
|
||||
|
||||
private void ProcessCalculators(IHasCalculators targetObject, IHasCalculators sourceObject)
|
||||
{
|
||||
targetObject.Calculators.Clear();
|
||||
foreach (var calculator in sourceObject.Calculators)
|
||||
{
|
||||
var newCalculator = cloningStrategy.Clone(calculator);
|
||||
if (calculator is IForceCalculator forceCalculator)
|
||||
{
|
||||
ProcessForceCalculator(newCalculator, forceCalculator);
|
||||
}
|
||||
else if (calculator is CrackCalculator crackCalculator)
|
||||
{
|
||||
ProcessCrackCalculator(newCalculator, crackCalculator);
|
||||
}
|
||||
else if (calculator is ILimitCurvesCalculator limitCalculator)
|
||||
{
|
||||
ProcessLimitCurvesCalculator(newCalculator, limitCalculator);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(calculator));
|
||||
}
|
||||
targetRepository.Calculators.Add(newCalculator);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessLimitCurvesCalculator(ICalculator newCalculator, ILimitCurvesCalculator limitCalculator)
|
||||
{
|
||||
var sourceData = limitCalculator.InputData;
|
||||
var targetData = ((ILimitCurvesCalculator)newCalculator).InputData;
|
||||
limitCurvesInputDataUpdateStrategy.Update(targetData, sourceData);
|
||||
foreach (var series in targetData.PrimitiveSeries)
|
||||
{
|
||||
List<INdmPrimitive> collection = UpdatePrimitivesCollection(series);
|
||||
series.Collection.AddRange(collection);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessCrackCalculator(ICalculator newCalculator, CrackCalculator crackCalculator)
|
||||
{
|
||||
var sourceData = crackCalculator.InputData;
|
||||
var targetData = ((ICrackCalculator)newCalculator).InputData;
|
||||
ProcessPrimitives(targetData, sourceData);
|
||||
ProcessForces(targetData, sourceData);
|
||||
}
|
||||
|
||||
private void ProcessForceCalculator(ICalculator newCalculator, IForceCalculator forceCalculator)
|
||||
{
|
||||
var sourceData = forceCalculator.InputData;
|
||||
var targetData = ((IForceCalculator)newCalculator).InputData;
|
||||
ProcessPrimitives(targetData, sourceData);
|
||||
ProcessForces(targetData, sourceData);
|
||||
}
|
||||
|
||||
private List<INdmPrimitive> UpdatePrimitivesCollection(NamedCollection<INdmPrimitive> series)
|
||||
{
|
||||
List<INdmPrimitive> collection = new();
|
||||
foreach (var item in series.Collection)
|
||||
{
|
||||
var newItem = cloningStrategy.Clone(item);
|
||||
collection.Add(newItem);
|
||||
}
|
||||
series.Collection.Clear();
|
||||
return collection;
|
||||
}
|
||||
|
||||
private void ProcessMaterials(IHasHeadMaterials targetObject, IHasHeadMaterials sourceObject)
|
||||
{
|
||||
targetObject.HeadMaterials.Clear();
|
||||
foreach (var material in sourceObject.HeadMaterials)
|
||||
{
|
||||
var newMaterial = cloningStrategy.Clone(material);
|
||||
targetRepository.HeadMaterials.Add(newMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessForces(IHasForceActions targetObject, IHasForceActions sourceObject)
|
||||
{
|
||||
targetObject.ForceActions.Clear();
|
||||
foreach (var force in sourceObject.ForceActions)
|
||||
{
|
||||
var newForce = cloningStrategy.Clone(force);
|
||||
targetObject.ForceActions.Add(newForce);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives targetObject, IHasPrimitives sourceObject)
|
||||
{
|
||||
targetObject.Primitives.Clear();
|
||||
foreach (var primitive in sourceObject.Primitives)
|
||||
{
|
||||
var newPrimitive = cloningStrategy.Clone(primitive);
|
||||
var material = cloningStrategy.Clone(primitive.NdmElement.HeadMaterial);
|
||||
newPrimitive.NdmElement.HeadMaterial = material;
|
||||
targetObject.Primitives.Add(newPrimitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
|
||||
@@ -6,21 +6,29 @@ namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public class HeadMaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IHeadMaterial> updateStrategy = new HeadMaterialBaseUpdateStrategy();
|
||||
private IUpdateStrategy<IHeadMaterial> baseUpdateStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy;
|
||||
|
||||
public HeadMaterialUpdateStrategy(IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy)
|
||||
public HeadMaterialUpdateStrategy(
|
||||
IUpdateStrategy<IHeadMaterial> baseUpdateStrategy,
|
||||
IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy)
|
||||
{
|
||||
this.baseUpdateStrategy = baseUpdateStrategy;
|
||||
this.helperMaterialUpdateStrategy = helperMaterialUpdateStrategy;
|
||||
}
|
||||
public HeadMaterialUpdateStrategy() : this(new HelperMaterialUpdateStrategy()) { }
|
||||
public HeadMaterialUpdateStrategy() : this(
|
||||
new HeadMaterialBaseUpdateStrategy(),
|
||||
new HelperMaterialUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
updateStrategy.Update(targetObject, sourceObject);
|
||||
baseUpdateStrategy.Update(targetObject, sourceObject);
|
||||
targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial;
|
||||
helperMaterialUpdateStrategy.Update(targetObject.HelperMaterial, sourceObject.HelperMaterial);
|
||||
}
|
||||
|
||||
@@ -63,13 +63,13 @@ namespace StructureHelperLogics.Models.Materials
|
||||
|
||||
private void UpdateLibMaterial(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||
{
|
||||
if (sourceObject is IConcreteLibMaterial)
|
||||
if (sourceObject is IConcreteLibMaterial concreteLibMaterial)
|
||||
{
|
||||
concreteStrategy.Update(targetObject as IConcreteLibMaterial, sourceObject as IConcreteLibMaterial);
|
||||
concreteStrategy.Update(targetObject as IConcreteLibMaterial, concreteLibMaterial);
|
||||
}
|
||||
else if (sourceObject is IReinforcementLibMaterial)
|
||||
else if (sourceObject is IReinforcementLibMaterial reinforcementLibMaterial)
|
||||
{
|
||||
reinforcementStrategy.Update(targetObject as IReinforcementLibMaterial, sourceObject as IReinforcementLibMaterial);
|
||||
reinforcementStrategy.Update(targetObject as IReinforcementLibMaterial, reinforcementLibMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user