59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
using StructureHelper.Windows.UserControls;
|
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
|
using StructureHelperCommon.Models.Forces;
|
|
using StructureHelperCommon.Models.Shapes;
|
|
using StructureHelperLogics.Models.BeamShears;
|
|
using System;
|
|
using System.Windows.Media;
|
|
using PrimitiveVisualProperty = StructureHelperCommon.Models.VisualProperties.PrimitiveVisualProperty;
|
|
|
|
namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
|
{
|
|
public class ConcentratedForcePrimitive : IGraphicalPrimitive
|
|
{
|
|
private IConcentratedForce concentratedForce;
|
|
private IInclinedSection inclinedSection;
|
|
|
|
public double ScaleFactor
|
|
{
|
|
get
|
|
{
|
|
double forceValue = concentratedForce.ForceValue.Qy;
|
|
return forceValue / MaxForce;
|
|
}
|
|
}
|
|
|
|
public double TranslateX => concentratedForce.ForceCoordinate;
|
|
public double TranslateY => GetAbsoluteLevel();
|
|
|
|
|
|
public PrimitiveVisualPropertyViewModel VisualProperty { get; } = new(new PrimitiveVisualProperty(Guid.Empty));
|
|
public IConcentratedForce ConcentratedForce => concentratedForce;
|
|
|
|
public string Name => concentratedForce.Name;
|
|
|
|
public double MaxForce { get; set; } = 1e6;
|
|
|
|
public ConcentratedForcePrimitive(IConcentratedForce concentratedForce, IInclinedSection inclinedSection)
|
|
{
|
|
this.concentratedForce = concentratedForce;
|
|
this.inclinedSection = inclinedSection;
|
|
VisualProperty.Color = (Color)ColorConverter.ConvertFromString("Black");
|
|
}
|
|
|
|
private double GetAbsoluteLevel()
|
|
{
|
|
double height;
|
|
IShape shape = inclinedSection.BeamShearSection.Shape;
|
|
if (shape is IRectangleShape rectangle) { height = rectangle.Height; }
|
|
else if (shape is ICircleShape circle) { height = circle.Diameter; }
|
|
else
|
|
{
|
|
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(shape) + $": concentrated force {concentratedForce.Name} shape");
|
|
}
|
|
double level = (concentratedForce.RelativeLoadLevel + 0.5) * height;
|
|
return level;
|
|
}
|
|
}
|
|
}
|