Add graphic primitives
This commit is contained in:
@@ -14,9 +14,6 @@ namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
private IBeamShearSection beamShearSection;
|
||||
private IInclinedSection inclinedSection;
|
||||
|
||||
|
||||
public double CenterX { get; set; } = 0;
|
||||
public double CenterY { get; set; } = 0;
|
||||
public double FullDepth => inclinedSection.FullDepth;
|
||||
public double WebWidth => inclinedSection.WebWidth;
|
||||
public double ReinforcementArea => inclinedSection.BeamShearSection.ReinforcementArea;
|
||||
@@ -35,6 +32,8 @@ namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
|
||||
public PrimitiveVisualPropertyViewModel VisualProperty {get;}
|
||||
|
||||
public string Name => beamShearSection.Name;
|
||||
|
||||
public BeamShearSectionPrimitive(IBeamShearSection beamShearSection, IInclinedSection inclinedSection)
|
||||
{
|
||||
this.beamShearSection = beamShearSection;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
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;
|
||||
@@ -9,24 +12,47 @@ namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
public class ConcentratedForcePrimitive : IGraphicalPrimitive
|
||||
{
|
||||
private IConcentratedForce concentratedForce;
|
||||
private readonly double scaleFactor;
|
||||
private IInclinedSection inclinedSection;
|
||||
|
||||
public double ScaleFactor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (concentratedForce.ForceValue.Qy > 0) { return -1; }
|
||||
return 1;
|
||||
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 ConcentratedForcePrimitive(IConcentratedForce 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
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 DistributedLoadPrimitive : IGraphicalPrimitive
|
||||
{
|
||||
private IDistributedLoad distributedLoad;
|
||||
private IInclinedSection inclinedSection;
|
||||
|
||||
public double ScaleFactor
|
||||
{
|
||||
get
|
||||
{
|
||||
double forceValue = distributedLoad.LoadValue.Qy;
|
||||
return -1 * forceValue / MaxForce;
|
||||
}
|
||||
}
|
||||
|
||||
public double TranslateX => distributedLoad.StartCoordinate;
|
||||
public double TranslateY => GetAbsoluteLevel();
|
||||
public double Length => distributedLoad.EndCoordinate - distributedLoad.StartCoordinate;
|
||||
|
||||
|
||||
public PrimitiveVisualPropertyViewModel VisualProperty { get; } = new(new PrimitiveVisualProperty(Guid.Empty));
|
||||
public IDistributedLoad DistributedLoad => distributedLoad;
|
||||
|
||||
public string Name => distributedLoad.Name;
|
||||
|
||||
public double MaxForce { get; set; } = 1e6;
|
||||
|
||||
public DistributedLoadPrimitive(IDistributedLoad distributedLoad, IInclinedSection inclinedSection)
|
||||
{
|
||||
this.distributedLoad = distributedLoad;
|
||||
this.inclinedSection = inclinedSection;
|
||||
VisualProperty.Color = (Color)ColorConverter.ConvertFromString("LightBlue");
|
||||
VisualProperty.FactoredOpacity = 90;
|
||||
}
|
||||
|
||||
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) + $": distributed load {distributedLoad.Name} shape");
|
||||
}
|
||||
double level = (distributedLoad.RelativeLoadLevel + 0.5) * height;
|
||||
return level;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,10 @@
|
||||
using FieldVisualizer.Entities.Values.Primitives;
|
||||
using StructureHelper.Windows.UserControls;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelper.Windows.UserControls;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
{
|
||||
public interface IGraphicalPrimitive
|
||||
{
|
||||
string Name { get; }
|
||||
PrimitiveVisualPropertyViewModel VisualProperty { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
|
||||
public PrimitiveVisualPropertyViewModel VisualProperty { get; } = new(new PrimitiveVisualProperty(Guid.Empty));
|
||||
|
||||
public string Name => "Inclined section";
|
||||
|
||||
public InclinedSectionPrimitive(IBeamShearSectionLogicResult source)
|
||||
{
|
||||
this.source = source;
|
||||
|
||||
@@ -8,8 +8,6 @@ namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
{
|
||||
public IStirrupByDensity StirrupByDensity { get; }
|
||||
|
||||
public double CenterX => 0;
|
||||
public double CenterY => 0;
|
||||
public double StartPoinX => StirrupByDensity.StartCoordinate;
|
||||
public double BottomPointY => InclinedSection.FullDepth - InclinedSection.EffectiveDepth;
|
||||
public double TopPointY => InclinedSection.FullDepth;
|
||||
@@ -20,6 +18,8 @@ namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
|
||||
public PrimitiveVisualPropertyViewModel VisualProperty { get; }
|
||||
|
||||
public string Name => StirrupByDensity.Name;
|
||||
|
||||
public StirrupByDensityPrimitive(IStirrupByDensity stirrupByDensity, IInclinedSection inclinedSection)
|
||||
{
|
||||
StirrupByDensity = stirrupByDensity;
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
|
||||
public PrimitiveVisualPropertyViewModel VisualProperty { get; }
|
||||
|
||||
public string Name => StirrupByInclinedRebar.Name;
|
||||
|
||||
public StirrupByInclinedRebarPrimitive(IStirrupByInclinedRebar stirrupByInclinedRebar, IInclinedSection inclinedSection)
|
||||
{
|
||||
StirrupByInclinedRebar = stirrupByInclinedRebar;
|
||||
|
||||
@@ -11,8 +11,6 @@ namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
private readonly IStirrupByDensity stirrupByDensity;
|
||||
|
||||
public IStirrupByRebar StirrupByRebar { get; }
|
||||
public double CenterX => 0;
|
||||
public double CenterY => 0;
|
||||
public double StartPoinX => StirrupByRebar.StartCoordinate;
|
||||
public double BottomPointY => InclinedSection.FullDepth - InclinedSection.EffectiveDepth;
|
||||
public double TopPointY => InclinedSection.FullDepth;
|
||||
@@ -20,11 +18,12 @@ namespace StructureHelper.Infrastructure.UI.GraphicalPrimitives
|
||||
public double Depth => InclinedSection.EffectiveDepth;
|
||||
public double Density => Math.Round(stirrupByDensity.StirrupDensity);
|
||||
|
||||
|
||||
public IInclinedSection InclinedSection => inclinedSection;
|
||||
|
||||
public PrimitiveVisualPropertyViewModel VisualProperty { get; }
|
||||
|
||||
public string Name => StirrupByRebar.Name;
|
||||
|
||||
public StirrupByRebarPrimitive(IStirrupByRebar stirrupByRebar, IInclinedSection inclinedSection)
|
||||
{
|
||||
this.StirrupByRebar = stirrupByRebar;
|
||||
|
||||
@@ -343,8 +343,12 @@
|
||||
<Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform
|
||||
ScaleX="1"
|
||||
ScaleX="{Binding ScaleFactor}"
|
||||
ScaleY="{Binding ScaleFactor}"/>
|
||||
<TranslateTransform
|
||||
X="{Binding TranslateX}"
|
||||
Y="{Binding TranslateY}"
|
||||
/>
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>
|
||||
<Line
|
||||
@@ -368,7 +372,7 @@
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Margin="0,0,0,2" Text="Internal force: "/>
|
||||
<TextBlock Margin="0,0,0,2" Text="Force: "/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding ConcentratedForce.Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Force value: "/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding ConcentratedForce.ForceValue.Qy, Converter={StaticResource ForceConverter}}"/>
|
||||
@@ -377,6 +381,7 @@
|
||||
</Line>
|
||||
<Path
|
||||
Data="M 0 0 L 0.1 -0.1 L 0 -0.07 L -0.1 -0.1 Z"
|
||||
Visibility="{Binding VisualProperty.IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
StrokeThickness="0.005"
|
||||
>
|
||||
<Path.Fill>
|
||||
@@ -389,5 +394,55 @@
|
||||
</Canvas>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="DistributedLoadPrimitiveTemplate"
|
||||
DataType="primitives:DistributedLoadPrimitive">
|
||||
<Canvas Visibility="{Binding VisualProperty.IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" Opacity="{Binding VisualProperty.Opacity}">
|
||||
<Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform
|
||||
ScaleX="1"
|
||||
ScaleY="{Binding ScaleFactor}"/>
|
||||
<TranslateTransform
|
||||
X="{Binding TranslateX}"
|
||||
Y="{Binding TranslateY}"
|
||||
/>
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>
|
||||
<Rectangle Height="0.2" Width="{Binding Length}" StrokeThickness="0.01">
|
||||
<Rectangle.Stroke>
|
||||
<SolidColorBrush Color="{Binding VisualProperty.Color}"/>
|
||||
</Rectangle.Stroke>
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="{Binding VisualProperty.Color}" Offset="1"/>
|
||||
<GradientStop Color="White" Offset="0"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Fill>
|
||||
<Rectangle.ToolTip>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Margin="0,0,0,2" Text="Distributed load: "/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Force value: "/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding DistributedLoad.LoadValue.Qy, Converter={StaticResource DistributedLoadConverter}}"/>
|
||||
<TextBlock Grid.Row="2" Text="Start point: "/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding DistributedLoad.StartCoordinate, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBlock Grid.Row="3" Text="End point: "/>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding DistributedLoad.EndCoordinate, Converter={StaticResource LengthConverter}}"/>
|
||||
</Grid>
|
||||
</Rectangle.ToolTip>
|
||||
</Rectangle>
|
||||
</Canvas>
|
||||
</DataTemplate>
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,88 @@
|
||||
using StructureHelper.Infrastructure.UI.GraphicalPrimitives;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.BeamShears
|
||||
{
|
||||
internal class ActionToGraphicPrimitiveConvertLogic : IObjectConvertStrategy<List<IGraphicalPrimitive>, IBeamShearAction>
|
||||
{
|
||||
private IInclinedSection inclinedSection;
|
||||
private List<IGraphicalPrimitive> graphicalPrimitives;
|
||||
private double maxConcentratedForceValue = 1e6;
|
||||
private double maxDistributedLoadValue = 1e6;
|
||||
|
||||
public ActionToGraphicPrimitiveConvertLogic(IInclinedSection inclinedSection)
|
||||
{
|
||||
this.inclinedSection = inclinedSection;
|
||||
}
|
||||
|
||||
public List<IGraphicalPrimitive> Convert(IBeamShearAction source)
|
||||
{
|
||||
SetMaxForce(source);
|
||||
SetMaxDistributedForce(source);
|
||||
graphicalPrimitives = new();
|
||||
var supportInternalAction = source.SupportAction.SupportForce.ForceTuple;
|
||||
graphicalPrimitives.Add(GetConcentratedForcePrimitive(supportInternalAction, "Support reaction"));
|
||||
foreach (var item in source.SupportAction.ShearLoads)
|
||||
{
|
||||
if (item is IDistributedLoad distributedLoad)
|
||||
{
|
||||
graphicalPrimitives.Add(GetDistributedLoadPrimitive(distributedLoad));
|
||||
}
|
||||
else if (item is IConcentratedForce concentratedForce)
|
||||
{
|
||||
graphicalPrimitives.Add(GetConcentratedForcePrimitive(concentratedForce));
|
||||
}
|
||||
}
|
||||
return graphicalPrimitives;
|
||||
}
|
||||
|
||||
private void SetMaxDistributedForce(IBeamShearAction source)
|
||||
{
|
||||
var forceList = source.SupportAction.ShearLoads
|
||||
.Where(x => x is IDistributedLoad)
|
||||
.Select(x => Math.Abs((x as IDistributedLoad).LoadValue.Qy))
|
||||
.ToList();
|
||||
maxDistributedLoadValue = forceList.Max();
|
||||
}
|
||||
|
||||
private IGraphicalPrimitive GetDistributedLoadPrimitive(IDistributedLoad distributedLoad)
|
||||
{
|
||||
DistributedLoadPrimitive distributedLoadPrimitive = new(distributedLoad, inclinedSection) { MaxForce = maxDistributedLoadValue };
|
||||
return distributedLoadPrimitive;
|
||||
}
|
||||
|
||||
private ConcentratedForcePrimitive GetConcentratedForcePrimitive(IForceTuple supportInternalAction, string name)
|
||||
{
|
||||
ConcentratedForce force = new(Guid.Empty) { Name = name };
|
||||
force.ForceValue.Qy = supportInternalAction.Qy;
|
||||
force.RelativeLoadLevel = -0.5;
|
||||
force.ForceCoordinate = 0;
|
||||
ConcentratedForcePrimitive concentratedForcePrimitive = new(force, inclinedSection) { MaxForce = maxConcentratedForceValue};
|
||||
return concentratedForcePrimitive;
|
||||
}
|
||||
|
||||
private ConcentratedForcePrimitive GetConcentratedForcePrimitive(IConcentratedForce concentratedForce)
|
||||
{
|
||||
ConcentratedForcePrimitive concentratedForcePrimitive = new(concentratedForce, inclinedSection) { MaxForce = maxConcentratedForceValue };
|
||||
return concentratedForcePrimitive;
|
||||
}
|
||||
|
||||
private void SetMaxForce(IBeamShearAction source)
|
||||
{
|
||||
var forceList = source.SupportAction.ShearLoads
|
||||
.Where(x => x is IConcentratedForce)
|
||||
.Select(x => Math.Abs((x as IConcentratedForce).ForceValue.Qy))
|
||||
.ToList();
|
||||
forceList.Add(Math.Abs(source.ExternalForce.ForceTuple.Nz));
|
||||
forceList.Add(Math.Abs(source.SupportAction.SupportForce.ForceTuple.Qy));
|
||||
maxConcentratedForceValue = forceList.Max();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,26 @@
|
||||
xmlns:ucwp="clr-namespace:StructureHelper.Windows.UserControls.WorkPlanes"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:InclinedSectionViewerViewModel}"
|
||||
Title="Inclined Section Viewer" Height="650" Width="1000" WindowStartupLocation="CenterScreen">
|
||||
Title="Inclined Section Viewer" Height="650" Width="1000" MinHeight="600" MinWidth="500" WindowStartupLocation="CenterScreen">
|
||||
<Grid DataContext="{Binding WorkPlaneRoot}">
|
||||
<ucwp:WorkPlaneRoot/>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" MinWidth="200"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListBox ItemsSource="{Binding PrimitiveCollection.Primitives}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<CheckBox IsChecked="{Binding VisualProperty.IsVisible}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<ucwp:WorkPlaneRoot x:Name="WorkPlaneRootPanel" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace StructureHelper.Windows.BeamShears
|
||||
private InclinedSectionViewerViewModel viewModel;
|
||||
public InclinedSectionViewerView(InclinedSectionViewerViewModel viewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.viewModel = viewModel;
|
||||
this.DataContext = this.viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
public InclinedSectionViewerView(IBeamShearSectionLogicResult sectionResult) : this(new InclinedSectionViewerViewModel(sectionResult))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using StructureHelper.Infrastructure.UI.GraphicalPrimitives;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
@@ -10,6 +9,7 @@ namespace StructureHelper.Windows.BeamShears
|
||||
{
|
||||
public class SectionResultToGraphicalPrimitivesConvertLogic : IObjectConvertStrategy<List<IGraphicalPrimitive>, IBeamShearSectionLogicResult>
|
||||
{
|
||||
private IObjectConvertStrategy<List<IGraphicalPrimitive>, IBeamShearAction> actionLogic;
|
||||
private IObjectConvertStrategy<List<IGraphicalPrimitive>, IStirrup> stirrupLogic;
|
||||
private IInclinedSection inclinedSection;
|
||||
|
||||
@@ -17,23 +17,22 @@ namespace StructureHelper.Windows.BeamShears
|
||||
{
|
||||
inclinedSection = source.InputData.InclinedSection;
|
||||
InitializeStrategies();
|
||||
List<IGraphicalPrimitive> graphicalPrimitives = new List<IGraphicalPrimitive>();
|
||||
List<IGraphicalPrimitive> graphicalPrimitives = new();
|
||||
BeamShearSectionPrimitive beamShearSectionPrimitive = new(source.ResultInputData.InclinedSection.BeamShearSection, inclinedSection);
|
||||
graphicalPrimitives.Add(beamShearSectionPrimitive);
|
||||
var supportInternalAction = source.ResultInputData.BeamShearAction.SupportAction.SupportForce.ForceTuple;
|
||||
ConcentratedForce SupportForce = new(Guid.Empty);
|
||||
SupportForce.ForceValue.Qy = supportInternalAction.Qy;
|
||||
ConcentratedForcePrimitive concentratedForcePrimitive = new(SupportForce);
|
||||
graphicalPrimitives.Add((concentratedForcePrimitive));
|
||||
graphicalPrimitives.AddRange(actionLogic.Convert(source.ResultInputData.BeamShearAction));
|
||||
graphicalPrimitives.AddRange(stirrupLogic.Convert(source.ResultInputData.Stirrup));
|
||||
InclinedSectionPrimitive inclinedSectionPrimitive = new(source);
|
||||
graphicalPrimitives.Add((inclinedSectionPrimitive));
|
||||
graphicalPrimitives.Add(inclinedSectionPrimitive);
|
||||
return graphicalPrimitives;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
stirrupLogic ??= new StirrupToGraphicPrimitiveConvertLogic(inclinedSection);
|
||||
actionLogic ??= new ActionToGraphicPrimitiveConvertLogic(inclinedSection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
StructureHelper/Windows/Graphs/SaveCopyFWElementViewModel.cs
Normal file
24
StructureHelper/Windows/Graphs/SaveCopyFWElementViewModel.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.Graphs
|
||||
{
|
||||
public class SaveCopyFWElementViewModel : ViewModelBase
|
||||
{
|
||||
private IFrameWorkElementServiseLogic frameWorkElementServiseLogic = new FrameWorkElementServiseLogic();
|
||||
private RelayCommand saveImageCommand;
|
||||
private RelayCommand copyToClipboardCommand;
|
||||
|
||||
public ICommand SaveAsImageCommand
|
||||
{
|
||||
get => saveImageCommand ??= new RelayCommand(o => frameWorkElementServiseLogic.SaveImageToFile(FrameWorkElement));
|
||||
}
|
||||
|
||||
public ICommand CopyToClipboardCommand
|
||||
{
|
||||
get => copyToClipboardCommand ??= new RelayCommand(o => frameWorkElementServiseLogic.CopyImageToClipboard(FrameWorkElement));
|
||||
}
|
||||
public FrameworkElement FrameWorkElement { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,21 +2,9 @@
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Windows.Graphs;
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelper.Windows.ViewModels.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace StructureHelper.Windows.UserControls
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace StructureHelper.Windows.UserControls.WorkPlanes
|
||||
public DataTemplate StirrupByDensityTemplate { get; set; }
|
||||
public DataTemplate StirrupByInclinedRebarTemplate { get; set; }
|
||||
public DataTemplate ConcentratedForceTemplate { get; set; }
|
||||
public DataTemplate DistributedLoadTemplate { get; set; }
|
||||
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
@@ -23,6 +24,7 @@ namespace StructureHelper.Windows.UserControls.WorkPlanes
|
||||
StirrupByDensityPrimitive => StirrupByDensityTemplate,
|
||||
StirrupByInclinedRebarPrimitive => StirrupByInclinedRebarTemplate,
|
||||
ConcentratedForcePrimitive => ConcentratedForceTemplate,
|
||||
DistributedLoadPrimitive => DistributedLoadTemplate,
|
||||
_ => base.SelectTemplate(item, container)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
|
||||
@@ -4,13 +4,33 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.UserControls.WorkPlanes"
|
||||
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:WorkPlaneRootViewModel}"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<DockPanel>
|
||||
<ToolBarTray DockPanel.Dock="Top">
|
||||
<ToolBar>
|
||||
|
||||
<ToolBar DataContext="{Binding SaveCopyViewModel, RelativeSource={RelativeSource AncestorType=local:WorkPlaneRoot}}">
|
||||
<Button Style="{DynamicResource ToolButton}" Command="{Binding CopyToClipboardCommand}">
|
||||
<Button.ToolTip>
|
||||
<uc:ButtonToolTipEh HeaderText="Copy to clipboard"
|
||||
IconContent="{StaticResource CopyToClipboard}"
|
||||
DescriptionText="Copy chart to clipboard as image"/>
|
||||
</Button.ToolTip>
|
||||
<Viewbox>
|
||||
<ContentControl ContentTemplate="{DynamicResource CopyToClipboard}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Style="{DynamicResource ToolButton}" Command="{Binding SaveAsImageCommand}">
|
||||
<Button.ToolTip>
|
||||
<uc:ButtonToolTipEh HeaderText="Export to *.png"
|
||||
IconContent="{StaticResource PngImage}"
|
||||
DescriptionText="Export chart to *.png file"/>
|
||||
</Button.ToolTip>
|
||||
<Viewbox>
|
||||
<ContentControl ContentTemplate="{DynamicResource PngImage}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
<Grid>
|
||||
@@ -18,69 +38,72 @@
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" Background="White">
|
||||
<Canvas x:Name="RootCanvas" Width="{Binding WorkPlaneConfig.CanvasWidth}" Height="{Binding WorkPlaneConfig.CanvasHeight}">
|
||||
<Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<!-- Shift origin to canvas center -->
|
||||
<TranslateTransform
|
||||
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" Background="White">
|
||||
<Grid x:Name="WorkPlaneGrid" Background="White">
|
||||
<Canvas x:Name="RootCanvas" Width="{Binding WorkPlaneConfig.CanvasWidth}" Height="{Binding WorkPlaneConfig.CanvasHeight}">
|
||||
<Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<!-- Shift origin to canvas center -->
|
||||
<TranslateTransform
|
||||
X="{Binding WorkPlaneConfig.CenterOffsetX}"
|
||||
Y="{Binding WorkPlaneConfig.CenterOffsetY}" />
|
||||
|
||||
<!-- Apply zoom scale -->
|
||||
<ScaleTransform
|
||||
<!-- Apply zoom scale -->
|
||||
<ScaleTransform
|
||||
ScaleX="{Binding WorkPlaneConfig.ScaleValue}"
|
||||
ScaleY="{Binding WorkPlaneConfig.NegativeScaleValue}"
|
||||
CenterX="{Binding WorkPlaneConfig.ZoomCenterX}"
|
||||
CenterY="{Binding WorkPlaneConfig.ZoomCenterY}" />
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>
|
||||
|
||||
<!-- Grid layer -->
|
||||
<local:GridLayer
|
||||
<!-- Grid layer -->
|
||||
<local:GridLayer
|
||||
GridSize="{Binding WorkPlaneConfig.GridSize}"
|
||||
GridColorBrush="{Binding WorkPlaneConfig.GridColorBrush}"
|
||||
GridLineThickness="{Binding WorkPlaneConfig.GridLineThickness}"
|
||||
CanvasViewportSize="{Binding WorkPlaneConfig.CanvasViewportSize}" />
|
||||
|
||||
<!-- Axis layer -->
|
||||
<local:AxisLayer
|
||||
<!-- Axis layer -->
|
||||
<local:AxisLayer
|
||||
Width="{Binding WorkPlaneConfig.CanvasWidth}"
|
||||
Height="{Binding WorkPlaneConfig.CanvasHeight}"
|
||||
XAxisColorBrush="{Binding WorkPlaneConfig.XAxisColorBrush}"
|
||||
YAxisColorBrush="{Binding WorkPlaneConfig.YAxisColorBrush}"
|
||||
AxisLineThickness="{Binding WorkPlaneConfig.AxisLineThickness}" />
|
||||
|
||||
<!-- Primitives (ItemsControl) -->
|
||||
<ItemsControl ItemsSource="{Binding PrimitiveCollection.Primitives}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<!-- Primitives (ItemsControl) -->
|
||||
<ItemsControl ItemsSource="{Binding PrimitiveCollection.Primitives}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplateSelector>
|
||||
<local:PrimitiveTemplateSelector
|
||||
<ItemsControl.ItemTemplateSelector>
|
||||
<local:PrimitiveTemplateSelector
|
||||
BeamShearSectionTemplate="{StaticResource BeamShearSectionPrimitiveTemplate}"
|
||||
InclinedSectionTemplate="{StaticResource InclinedSectionPrimitiveTemplate}"
|
||||
StirrupByRebarTemplate="{StaticResource StirrupByRebarPrimitiveTemplate}"
|
||||
StirrupByDensityTemplate="{StaticResource StirrupByDensityPrimitiveTemplate}"
|
||||
StirrupByInclinedRebarTemplate="{StaticResource StirrupByInclinedRebarPrimitiveTemplate}"
|
||||
ConcentratedForceTemplate="{StaticResource ConcentratedForcePrimitiveTemplate}"
|
||||
DistributedLoadTemplate="{StaticResource DistributedLoadPrimitiveTemplate}"
|
||||
/>
|
||||
</ItemsControl.ItemTemplateSelector>
|
||||
</ItemsControl.ItemTemplateSelector>
|
||||
|
||||
<ItemsControl.ItemContainerStyle>
|
||||
<Style TargetType="ContentPresenter">
|
||||
<Setter Property="Canvas.Left" Value="{Binding CenterX}" />
|
||||
<Setter Property="Canvas.Top" Value="{Binding CenterY}" />
|
||||
<!--<Setter Property="Canvas.ZIndex" Value="{Binding WorkPlaneConfig.ZIndex}" />
|
||||
<ItemsControl.ItemContainerStyle>
|
||||
<Style TargetType="ContentPresenter">
|
||||
<Setter Property="Canvas.Left" Value="{Binding CenterX}" />
|
||||
<Setter Property="Canvas.Top" Value="{Binding CenterY}" />
|
||||
<!--<Setter Property="Canvas.ZIndex" Value="{Binding WorkPlaneConfig.ZIndex}" />
|
||||
<Setter Property="Visibility" Value="{Binding WorkPlaneConfig.IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" />-->
|
||||
</Style>
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
</ItemsControl>
|
||||
</Canvas>
|
||||
</ScrollViewer>
|
||||
</Style>
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
</ItemsControl>
|
||||
</Canvas>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
<StatusBar Grid.Row="1">
|
||||
<StatusBarItem>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using StructureHelper.Windows.Graphs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -21,6 +22,8 @@ namespace StructureHelper.Windows.UserControls.WorkPlanes
|
||||
public partial class WorkPlaneRoot : UserControl
|
||||
{
|
||||
private Point? _lastPanPoint;
|
||||
public SaveCopyFWElementViewModel SaveCopyViewModel { get; } = new();
|
||||
|
||||
public WorkPlaneRoot()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -28,6 +31,7 @@ namespace StructureHelper.Windows.UserControls.WorkPlanes
|
||||
this.MouseDown += WorkPlaneRoot_MouseDown;
|
||||
this.MouseMove += WorkPlaneRoot_MouseMove;
|
||||
this.MouseUp += WorkPlaneRoot_MouseUp;
|
||||
SaveCopyViewModel.FrameWorkElement = WorkPlaneGrid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelper.Windows.Graphs;
|
||||
|
||||
namespace StructureHelper.Windows.UserControls.WorkPlanes
|
||||
{
|
||||
@@ -11,5 +7,6 @@ namespace StructureHelper.Windows.UserControls.WorkPlanes
|
||||
{
|
||||
public WorkPlaneConfigViewModel WorkPlaneConfig { get; } = new();
|
||||
public PrimitiveCollectionViewModel PrimitiveCollection { get; } = new();
|
||||
//public SaveCopyFWElementViewModel SaveCopyViewModel { get; } = new();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user