Primitive View Logic for Main View modael was added

This commit is contained in:
Evgeny Redikultsev
2023-01-04 18:43:11 +05:00
parent 913d31e04f
commit 2d7c8648ab
24 changed files with 557 additions and 341 deletions

View File

@@ -19,6 +19,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
double PrestrainKx { get; set; }
double PrestrainKy { get; set; }
double PrestrainEpsZ { get; set; }
IVisualProperty VisualProperty {get; }
IEnumerable<INdm> GetNdms(IMaterial material);
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public interface IVisualProperty
{
bool IsVisible { get; set; }
Color Color { get; set; }
bool SetMaterialColor { get; set; }
int ZIndex { get; set; }
double Opacity { get; set; }
}
}

View File

@@ -30,7 +30,8 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public IPoint2D StartPoint { get; set; }
public IPoint2D EndPoint { get; set; }
public double Thickness { get; set; }
public IVisualProperty VisualProperty => throw new NotImplementedException();
public LinePrimitive()
{

View File

@@ -25,18 +25,17 @@ namespace StructureHelperLogics.Models.Primitives
public double PrestrainKy { get; set; }
public double PrestrainEpsZ { get; set; }
public double Area { get; set; }
public IVisualProperty VisualProperty { get; }
public PointPrimitive()
{
Name = "New Point";
Area = 0.0005d;
VisualProperty = new VisualProperty();
}
public PointPrimitive(IHeadMaterial material)
{
HeadMaterial = material;
}
public PointPrimitive(IHeadMaterial material) : this() { HeadMaterial = material; }
public IEnumerable<INdm> GetNdms(IMaterial material)
{

View File

@@ -31,11 +31,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public double Height { get; set; }
public double Angle { get; set; }
public IVisualProperty VisualProperty { get; }
public RectanglePrimitive()
{
Name = "New Rectangle";
NdmMaxSize = 0.01d;
NdmMinDivision = 10;
VisualProperty = new VisualProperty();
}
public RectanglePrimitive(IHeadMaterial material) : this() { HeadMaterial = material; }

View File

@@ -0,0 +1,42 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Services.ColorServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class VisualProperty : IVisualProperty
{
public bool IsVisible { get; set; }
public Color Color { get; set; }
public bool SetMaterialColor { get; set; }
public int ZIndex { get; set; }
private double opacity;
public double Opacity
{
get { return opacity; }
set
{
if (value < 0d || value > 1d) { throw new StructureHelperException(ErrorStrings.VisualPropertyIsNotRight + nameof(Opacity) + value); }
opacity = value;
}
}
public VisualProperty()
{
IsVisible = true;
Color = ColorProcessor.GetRandomColor();
SetMaterialColor = true;
ZIndex = 0;
Opacity = 1;
}
}
}

View File

@@ -15,10 +15,22 @@ namespace StructureHelperLogics.Services.NdmPrimitives
{
public static class NdmPrimitivesService
{
public static void CopyVisualProperty(IVisualProperty source, IVisualProperty target)
{
target.IsVisible = source.IsVisible;
target.Color = source.Color;
target.SetMaterialColor = source.SetMaterialColor;
target.Opacity = source.Opacity;
target.ZIndex = source.ZIndex;
}
public static void CopyNdmProperties (INdmPrimitive source, INdmPrimitive target)
{
target.Name = source.Name + " - copy" ;
target.HeadMaterial = source.HeadMaterial;
target.Name = source.Name + " copy" ;
if (source.HeadMaterial != null) target.HeadMaterial = source.HeadMaterial;
CopyVisualProperty(source.VisualProperty, target.VisualProperty);
target.CenterX = source.CenterX;
target.CenterY = source.CenterY;
target.PrestrainKx = source.PrestrainKx;
target.PrestrainKy = source.PrestrainKy;
target.PrestrainEpsZ = source.PrestrainEpsZ;