Crack Calculator was added

This commit is contained in:
Evgeny Redikultsev
2023-07-16 17:21:28 +05:00
parent 3e0e51d0c9
commit d7a4b1f0a7
108 changed files with 1523 additions and 565 deletions

View File

@@ -53,5 +53,12 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
OnPropertyChanged(nameof(PrimitiveLeft));
OnPropertyChanged(nameof(PrimitiveTop));
}
public override void Refresh()
{
OnPropertyChanged(nameof(Diameter));
OnPropertyChanged(nameof(PrimitiveLeft));
OnPropertyChanged(nameof(PrimitiveTop));
base.Refresh();
}
}
}

View File

@@ -42,7 +42,11 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
return primitive;
}
public override void Refresh()
{
RefreshPlacement();
base.Refresh();
}
private void RefreshPlacement()
{
OnPropertyChanged(nameof(Area));

View File

@@ -39,19 +39,19 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
}
public double CenterX
{
get => primitive.CenterX;
get => primitive.Center.X;
set
{
primitive.CenterX = value;
primitive.Center.X = value;
OnPropertyChanged(nameof(CenterX));
}
}
public double CenterY
{
get => primitive.CenterY;
get => primitive.Center.Y;
set
{
primitive.CenterY = value;
primitive.Center.Y = value;
OnPropertyChanged(nameof(CenterY));
OnPropertyChanged(nameof(InvertedCenterY));
}
@@ -261,5 +261,16 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
OnPropertyChanged(nameof(Color));
}
public virtual void Refresh()
{
OnPropertyChanged(nameof(Name));
OnPropertyChanged(nameof(Color));
OnPropertyChanged(nameof(CenterX));
OnPropertyChanged(nameof(CenterY));
OnPropertyChanged(nameof(SetMaterialColor));
OnPropertyChanged(nameof(Triangulate));
OnPropertyChanged(nameof(PrimitiveWidth));
OnPropertyChanged(nameof(PrimitiveHeight));
}
}
}

View File

@@ -35,14 +35,14 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
var circle = primitive as ICirclePrimitive;
viewItem = new CircleViewPrimitive(circle);
}
else if (primitive is IPointPrimitive & primitive is not ReinforcementPrimitive)
else if (primitive is IPointPrimitive & primitive is not RebarPrimitive)
{
var point = primitive as IPointPrimitive;
viewItem = new PointViewPrimitive(point);
}
else if (primitive is ReinforcementPrimitive)
else if (primitive is RebarPrimitive)
{
var point = primitive as ReinforcementPrimitive;
var point = primitive as RebarPrimitive;
viewItem = new ReinforcementViewPrimitive(point);
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Actual type: {primitive.GetType()}");

View File

@@ -42,7 +42,12 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
primitive = _primitive;
DivisionViewModel = new HasDivisionViewModel(primitive);
}
public override void Refresh()
{
OnPropertyChanged(nameof(PrimitiveLeft));
OnPropertyChanged(nameof(PrimitiveTop));
base.Refresh();
}
public override INdmPrimitive GetNdmPrimitive()
{
return primitive;

View File

@@ -9,7 +9,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class ReinforcementViewPrimitive : PointViewPrimitive, IHasHostPrimitive
{
ReinforcementPrimitive primitive;
RebarPrimitive primitive;
public INdmPrimitive HostPrimitive
{
@@ -21,9 +21,14 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
}
}
public ReinforcementViewPrimitive(ReinforcementPrimitive _primitive) : base(_primitive)
public ReinforcementViewPrimitive(RebarPrimitive _primitive) : base(_primitive)
{
primitive = _primitive;
}
public override void Refresh()
{
OnPropertyChanged(nameof(HostPrimitive));
base.Refresh();
}
}
}

View File

@@ -1,81 +0,0 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Models.Primitives.Factories
{
internal static class PrimitiveFactory
{
public static IEnumerable<PrimitiveBase> GetRectangleRCElement(RectangleBeamTemplate template, IHeadMaterial concrete, IHeadMaterial reinforcement)
{
List<PrimitiveBase> primitives = new List<PrimitiveBase>();
var rect = template.Shape as StructureHelperCommon.Models.Shapes.RectangleShape;
var width = rect.Width;
var height = rect.Height;
var area1 = Math.PI * template.BottomDiameter * template.BottomDiameter / 4d;
var area2 = Math.PI * template.TopDiameter * template.TopDiameter / 4d;
var gap = template.CoverGap;
double[] xs = new double[] { -width / 2 + gap, width / 2 - gap };
double[] ys = new double[] { -height / 2 + gap, height / 2 - gap };
var rectangle = new RectanglePrimitive() { Width = width, Height = height, Name = "Concrete block" };
primitives.Add(new RectangleViewPrimitive(rectangle) { HeadMaterial = concrete});
var point = new PointPrimitive() { CenterX = xs[0], CenterY = ys[0], Area = area1};
var viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Left bottom point" };
viewPoint.RegisterDeltas(xs[0], ys[0]);
primitives.Add(viewPoint);
point = new PointPrimitive() {CenterX = xs[1], CenterY = ys[0], Area = area1 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Right bottom point" };
primitives.Add(viewPoint);
point = new PointPrimitive() { CenterX = xs[0], CenterY = ys[1], Area = area2 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Left top point" };
primitives.Add(viewPoint);
point = new PointPrimitive() { CenterX = xs[1], CenterY = ys[1], Area = area2 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Right top point" };
viewPoint.RegisterDeltas(xs[1], ys[1]);
primitives.Add(viewPoint);
if (template.WidthCount > 2)
{
int count = template.WidthCount - 1;
double dist = (xs[1] - xs[0]) / count;
for (int i = 1; i < count; i++)
{
point = new PointPrimitive() {CenterX = xs[0] + dist * i, CenterY = ys[0], Area = area1 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Bottom point {i}" };
primitives.Add(viewPoint);
point = new PointPrimitive() { CenterX = xs[0] + dist * i, CenterY = ys[1], Area = area2 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Top point {i}" };
primitives.Add(viewPoint);
}
}
if (template.HeightCount > 2)
{
int count = template.HeightCount - 1;
double dist = (ys[1] - ys[0]) / count;
for (int i = 1; i < count; i++)
{
point = new PointPrimitive() {CenterX = xs[0], CenterY = ys[0] + dist * i, Area = area1 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Left point {i}" };
primitives.Add(viewPoint);
point = new PointPrimitive() { CenterX = xs[1], CenterY = ys[0] + dist * i, Area = area1 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Right point {i}" };
primitives.Add(viewPoint);
}
}
return primitives;
}
}
}

View File

@@ -50,9 +50,9 @@ namespace StructureHelper.Services.ResultViewers
List<IValuePrimitive> primitives = new List<IValuePrimitive>();
foreach (var item in ndmPrimitives)
{
if (item is ReinforcementPrimitive)
if (item is RebarPrimitive)
{
var primitive = item as ReinforcementPrimitive;
var primitive = item as RebarPrimitive;
var inputData = InputDataFactory.GetInputData(primitive, strainMatrix, limitState, calcTerm, 1d);
if (fullStrength == true)
{
@@ -73,9 +73,9 @@ namespace StructureHelper.Services.ResultViewers
List<IValuePrimitive> primitives = new List<IValuePrimitive>();
foreach (var item in ndmPrimitives)
{
if (item is ReinforcementPrimitive)
if (item is RebarPrimitive)
{
var primitive = item as ReinforcementPrimitive;
var primitive = item as RebarPrimitive;
var inputData = InputDataFactory.GetInputData(primitive, strainMatrix, limitState, calcTerm, 1d);
var calculator = new AnchorageCalculator(inputData);
var val = calculator.GetBaseDevLength() * UnitConstants.Length;
@@ -92,9 +92,9 @@ namespace StructureHelper.Services.ResultViewers
List<IValuePrimitive> primitives = new List<IValuePrimitive>();
foreach (var item in ndmPrimitives)
{
if (item is ReinforcementPrimitive)
if (item is RebarPrimitive)
{
var primitive = item as ReinforcementPrimitive;
var primitive = item as RebarPrimitive;
var inputData = InputDataFactory.GetInputData(primitive, strainMatrix, limitState, calcTerm, 1d);
if (fullStrength == true)
{
@@ -116,9 +116,9 @@ namespace StructureHelper.Services.ResultViewers
List<IValuePrimitive> primitives = new List<IValuePrimitive>();
foreach (var item in ndmPrimitives)
{
if (item is ReinforcementPrimitive)
if (item is RebarPrimitive)
{
var primitive = item as ReinforcementPrimitive;
var primitive = item as RebarPrimitive;
var inputData = InputDataFactory.GetInputData(primitive, strainMatrix, limitState, calcTerm, lapperdCountRate);
if (fullStrength == true)
{
@@ -138,8 +138,8 @@ namespace StructureHelper.Services.ResultViewers
{
var valuePrimitive = new FieldVisualizer.Entities.Values.Primitives.CirclePrimitive()
{
CenterX = primitive.CenterX,
CenterY = primitive.CenterY,
CenterX = primitive.Center.X,
CenterY = primitive.Center.Y,
Diameter = Math.Sqrt(primitive.Area / Math.PI) * 2,
Value = val
};

View File

@@ -50,6 +50,7 @@
<ItemGroup>
<Folder Include="Documentation\Manuals\" />
<Folder Include="Infrastructure\UI\DataContexts\Logics\" />
</ItemGroup>
</Project>

View File

@@ -16,7 +16,7 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="20"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="General">
@@ -92,5 +92,6 @@
</Grid>
</TabItem>
</TabControl>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -25,6 +25,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public ForceCalculatorView(ForceCalculatorViewModel _forceCalculatorViewModel)
{
viewModel = _forceCalculatorViewModel;
viewModel.ParentWindow = this;
DataContext = viewModel;
InitializeComponent();
}

View File

@@ -46,6 +46,7 @@
<Button Margin="3" Content="Set Prestrain" ToolTip="Set strains as auto prestrain" Command="{Binding SetPrestrainCommand}"/>
<Button Margin="3" Content="Anchorage" ToolTip="Set strains as auto prestrain" Command="{Binding ShowAnchorageCommand}"/>
<Button Margin="3" Content="Geometry" ToolTip="Show Geometry Properties" Command="{Binding ShowGeometryResultCommand}"/>
<Button Margin="3" Content="Fcrc" ToolTip="Show crack force" Command="{Binding ShowCrackResultCommand}"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -127,7 +127,7 @@
<MenuItem Header="Add">
<Button Content="Rectangle" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Circle" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}"/>
<Button Content="Reinforcement" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}"/>
<Button Content="Rebar" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}"/>
<Button Content="Point" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
</MenuItem>
</ContextMenu>
@@ -183,7 +183,7 @@
<MenuItem Header="Add">
<Button Content="Rectangle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Circle" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}"/>
<Button Content="Reinforcement" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}"/>
<Button Content="Rebar" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}"/>
<Button Content="Point" Command="{Binding PrimitiveLogic.Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
</MenuItem>
<MenuItem Header="Templates">

View File

@@ -111,122 +111,129 @@
</Expander>
</DataTemplate>
</Window.Resources>
<TabControl>
<TabItem Header="Main">
<ScrollViewer>
<StackPanel x:Name="StpProperties">
<Expander Header="Common properties" IsExpanded="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Name"/>
<TextBlock Grid.Row="1" Text="Name of material"/>
<TextBlock Grid.Row="2" Text="Center X"/>
<TextBlock Grid.Row="3" Text="Center Y"/>
<TextBlock Grid.Row="4" Text="Triangulate"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding Name}"/>
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding PrimitiveMaterial}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Margin="3">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color}"/>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="3" Grid.Column="1" Margin="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<CheckBox Grid.Row="4" Grid.Column="1" IsChecked="{Binding Triangulate}"/>
</Grid>
</Expander>
<Expander Header="Prestrain" IsExpanded="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="1" Text="User's / Auto" HorizontalAlignment="Center"/>
<TextBlock Grid.Row="1" Text="k_x"/>
<TextBlock Grid.Row="3" Text="k_y"/>
<TextBlock Grid.Row="5" Text="epsilon_z"/>
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Text="{Binding PrestrainKx, Converter={StaticResource Curvature}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Row="3" Grid.Column="1" Margin="1" Text="{Binding PrestrainKy, Converter={StaticResource Curvature}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Row="5" Grid.Column="1" Margin="1" Text="{Binding PrestrainEpsZ, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" IsEnabled="False" Text="{Binding AutoPrestrainKx, Converter={StaticResource Curvature}, Mode=OneWay}"/>
<TextBox Grid.Row="4" Grid.Column="1" Margin="1" IsEnabled="False" Text="{Binding AutoPrestrainKy, Converter={StaticResource Curvature}, Mode=OneWay}"/>
<TextBox Grid.Row="6" Grid.Column="1" Margin="1" IsEnabled="False" Text="{Binding AutoPrestrainEpsZ, Converter={StaticResource PlainDouble}, Mode=OneWay}"/>
</Grid>
</Expander>
</StackPanel>
</ScrollViewer>
</TabItem>
<TabItem Header="Visual">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="30"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Visible"/>
<TextBlock Grid.Row="1" Text="Material color"/>
<TextBlock Grid.Row="2" Text="Z-index (integer)"/>
<TextBlock Grid.Row="3" Text="Opacity"/>
<CheckBox Grid.Column="1" IsChecked="{Binding IsVisible}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"/>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<CheckBox IsChecked="{Binding SetMaterialColor}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,20,0"/>
<Rectangle Width="50" Margin="5,0,10,0">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color}"/>
</Rectangle.Fill>
</Rectangle>
<Button Width="50" Content="..." Command="{Binding EditColorCommand}"/>
</StackPanel>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding ZIndex}"/>
<Grid Grid.Row="3" Grid.Column="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="Main">
<ScrollViewer>
<StackPanel x:Name="StpProperties">
<Expander Header="Common properties" IsExpanded="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Name"/>
<TextBlock Grid.Row="1" Text="Name of material"/>
<TextBlock Grid.Row="2" Text="Center X"/>
<TextBlock Grid.Row="3" Text="Center Y"/>
<TextBlock Grid.Row="4" Text="Triangulate"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding Name}"/>
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding PrimitiveMaterial}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Margin="3">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color}"/>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="3" Grid.Column="1" Margin="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<CheckBox Grid.Row="4" Grid.Column="1" IsChecked="{Binding Triangulate}"/>
</Grid>
</Expander>
<Expander Header="Prestrain" IsExpanded="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="1" Text="User's / Auto" HorizontalAlignment="Center"/>
<TextBlock Grid.Row="1" Text="k_x"/>
<TextBlock Grid.Row="3" Text="k_y"/>
<TextBlock Grid.Row="5" Text="epsilon_z"/>
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Text="{Binding PrestrainKx, Converter={StaticResource Curvature}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Row="3" Grid.Column="1" Margin="1" Text="{Binding PrestrainKy, Converter={StaticResource Curvature}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Row="5" Grid.Column="1" Margin="1" Text="{Binding PrestrainEpsZ, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" IsEnabled="False" Text="{Binding AutoPrestrainKx, Converter={StaticResource Curvature}, Mode=OneWay}"/>
<TextBox Grid.Row="4" Grid.Column="1" Margin="1" IsEnabled="False" Text="{Binding AutoPrestrainKy, Converter={StaticResource Curvature}, Mode=OneWay}"/>
<TextBox Grid.Row="6" Grid.Column="1" Margin="1" IsEnabled="False" Text="{Binding AutoPrestrainEpsZ, Converter={StaticResource PlainDouble}, Mode=OneWay}"/>
</Grid>
</Expander>
</StackPanel>
</ScrollViewer>
</TabItem>
<TabItem Header="Visual">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="30"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox Text="{Binding Opacity, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}" Margin="5"/>
<Slider Grid.Column="1" Value="{Binding Opacity}" Maximum="100" TickPlacement="BottomRight" TickFrequency="10" IsSnapToTickEnabled="True" Margin="2"/>
<TextBlock Grid.Row="0" Text="Visible"/>
<TextBlock Grid.Row="1" Text="Material color"/>
<TextBlock Grid.Row="2" Text="Z-index (integer)"/>
<TextBlock Grid.Row="3" Text="Opacity"/>
<CheckBox Grid.Column="1" IsChecked="{Binding IsVisible}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"/>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<CheckBox IsChecked="{Binding SetMaterialColor}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,20,0"/>
<Rectangle Width="50" Margin="5,0,10,0">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color}"/>
</Rectangle.Fill>
</Rectangle>
<Button Width="50" Content="..." Command="{Binding EditColorCommand}"/>
</StackPanel>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding ZIndex}"/>
<Grid Grid.Row="3" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox Text="{Binding Opacity, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}" Margin="5"/>
<Slider Grid.Column="1" Value="{Binding Opacity}" Maximum="100" TickPlacement="BottomRight" TickFrequency="10" IsSnapToTickEnabled="True" Margin="2"/>
</Grid>
</Grid>
</Grid>
</TabItem>
</TabControl>
</TabItem>
</TabControl>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -1,23 +1,12 @@
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials;
using StructureHelper.Windows.ViewModels.PrimitiveProperties;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.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.Shapes;
using System.Xml.Linq;
using PointViewPrimitive = StructureHelper.Infrastructure.UI.DataContexts.PointViewPrimitive;
using RectangleViewPrimitive = StructureHelper.Infrastructure.UI.DataContexts.RectangleViewPrimitive;
@@ -34,6 +23,7 @@ namespace StructureHelper.Windows.PrimitiveProperiesWindow
{
this.primitive = primitive;
viewModel = new PrimitivePropertiesViewModel(this.primitive, sectionRepository);
viewModel.ParentWindow = this;
this.DataContext = viewModel;
InitializeComponent();
if (primitive is RectangleViewPrimitive) { AddPrimitiveProperties(PrimitiveType.Rectangle); }

View File

@@ -14,9 +14,6 @@
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding Items}"/>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource CancelButton}"/>
<Button Style="{StaticResource OkButton}" Click="Button_Click"/>
</StackPanel>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -20,16 +20,13 @@ namespace StructureHelper.Windows.PrimitivePropertiesWindow
/// </summary>
public partial class SelectPrimitivesView : Window
{
SelectPrimitivesViewModel viewModel;
public SelectPrimitivesView(SelectPrimitivesViewModel vm)
{
viewModel = vm;
InitializeComponent();
DataContext = vm;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
this.Close();
DataContext = viewModel;
viewModel.ParentWindow = this;
}
}
}

View File

@@ -13,7 +13,7 @@ using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
public class ForceCalculatorViewModel : ViewModelBase
public class ForceCalculatorViewModel : OkCancelViewModelBase
{
IEnumerable<INdmPrimitive> allowedPrimitives;
IEnumerable<IForceAction> allowedForceCombinations;

View File

@@ -26,6 +26,7 @@ using StructureHelperCommon.Services.Units;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmCalculations;
using StructureHelperLogics.Services.NdmPrimitives;
@@ -34,6 +35,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Input;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
@@ -57,12 +59,13 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
private RelayCommand setPrestrainCommand;
private ICommand showAnchorageCommand;
private ICommand showGeometryResultCommand;
private ICommand showGraphsCommand;
private ICommand showCrackResult;
public IForcesResults ForcesResults
{
get => forcesResults;
}
public RelayCommand ShowIsoFieldCommand
{
get
@@ -77,7 +80,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
}, o => (SelectedResult != null) && SelectedResult.IsValid));
}
}
public ICommand ExportToCSVCommand
{
get
@@ -100,13 +102,59 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
var exportService = new ExportToFileService(inputData, logic);
exportService.Export();
}
private ICommand showGraphsCommand;
public ICommand ShowGraphsCommand
{
get => showGraphsCommand ??= new RelayCommand(o => showGraphs());
}
public ICommand ShowCrackResultCommand
{
get => showCrackResult ??= new RelayCommand(o =>
{
SafetyProcessor.RunSafeProcess(ShowCrackResult);
}, o => (SelectedResult != null) && SelectedResult.IsValid);
}
private void ShowCrackResult()
{
var limitState = SelectedResult.DesignForceTuple.LimitState;
var calcTerm = SelectedResult.DesignForceTuple.CalcTerm;
var calculator = new CrackForceCalculator();
calculator.EndTuple = SelectedResult.DesignForceTuple.ForceTuple;
calculator.NdmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
//Act
calculator.Run();
var result = (CrackForceResult)calculator.Result;
if (result.IsValid)
{
var softLogic = new ExponentialSofteningLogic() { ForceRatio = result.ActualFactor };
string message = string.Empty;
if (result.IsSectionCracked)
{
message += $"Actual crack factor {result.ActualFactor}\n";
message += $"Softening crack factor PsiS={softLogic.SofteningFactor()}\n";
message += $"M{firstAxisName}={result.ActualTuple.Mx}, M{secondAxisName}={result.ActualTuple.My}, N{thirdAxisName}={result.ActualTuple.Nz}";
}
else
{
message += "Cracks are not apeared";
}
MessageBox.Show(
message,
"Crack results",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
var errorVM = new ErrorProcessor()
{
ShortText = "Error apeared while crack calculate",
DetailText = result.Description
};
var wnd = new ErrorMessage(errorVM);
wnd.ShowDialog();
}
}
private void showGraphs()
{

View File

@@ -0,0 +1,30 @@
using StructureHelper.Windows.Errors;
using StructureHelperCommon.Infrastructures.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Errors
{
internal static class SafetyProcessor
{
public static void RunSafeProcess(Action action, string shortText = "")
{
try
{
action.Invoke();
}
catch (Exception ex)
{
var vm = new ErrorProcessor()
{
ShortText = shortText,
DetailText = $"{ex}"
};
new ErrorMessage(vm).ShowDialog();
}
}
}
}

View File

@@ -1,11 +1,15 @@
using StructureHelper.Infrastructure;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -15,10 +19,11 @@ using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
public class AnalysisVewModelLogic : SelectedItemViewModel<INdmCalculator>
public class AnalysisVewModelLogic : SelectedItemViewModel<ICalculator>
{
private ICrossSectionRepository repository;
private RelayCommand runCommand;
static readonly CalculatorUpdateStrategy calculatorUpdateStrategy = new();
public override void AddMethod(object parameter)
{
@@ -30,10 +35,19 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
if (SelectedItem is ForceCalculator)
{
var calculator = SelectedItem as ForceCalculator;
var calculatorCopy = (ICalculator)calculator.Clone();
var vm = new ForceCalculatorViewModel(repository.Primitives, repository.ForceActions, calculator);
var wnd = new ForceCalculatorView(vm);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
// to do: update in repository
}
else
{
calculatorUpdateStrategy.Update(calculator, calculatorCopy);
}
}
base.EditMethod(parameter);
}
@@ -53,30 +67,28 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
(
runCommand = new RelayCommand(o =>
{
try
{
SelectedItem.Run();
var result = SelectedItem.Result;
if (result.IsValid == false)
{
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
var calculator = SelectedItem as IForceCalculator;
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
}
}
catch (Exception ex)
{
MessageBox.Show($"{ex}", "There are some errors during solution", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
SafetyProcessor.RunSafeProcess(RunCalculator);
}, o => SelectedItem != null));
}
}
private void RunCalculator()
{
SelectedItem.Run();
var result = SelectedItem.Result;
if (result.IsValid == false)
{
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
var calculator = SelectedItem as IForceCalculator;
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
}
}
public AnalysisVewModelLogic(ICrossSectionRepository sectionRepository) : base(sectionRepository.CalculatorsList)
{
repository = sectionRepository;

View File

@@ -1,11 +1,12 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Analyses;
using System.Collections.ObjectModel;
using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
public interface ICalculatorsViewModelLogic : ICRUDViewModel<INdmCalculator>
public interface ICalculatorsViewModelLogic : ICRUDViewModel<ICalculator>
{
RelayCommand Run { get; }
}

View File

@@ -72,7 +72,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
}
else if (primitiveType == PrimitiveType.Reinforcement)
{
var primitive = new ReinforcementPrimitive
var primitive = new RebarPrimitive
{
Area = 0.0005d
};
@@ -162,8 +162,21 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private void EditSelectedItem()
{
var ndmPrimitive = SelectedItem.GetNdmPrimitive();
var primitiveCopy = ndmPrimitive.Clone() as INdmPrimitive;
var wnd = new PrimitivePropertiesView(SelectedItem, repository);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
// to do save into repository
}
else
{
var updateStrategy = new NdmPrimitiveUpdateStrategy();
updateStrategy.Update(ndmPrimitive, primitiveCopy);
SelectedItem.Refresh();
}
}
public ICommand Copy
@@ -183,15 +196,16 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
var oldPrimitive = SelectedItem.GetNdmPrimitive();
var newPrimitive = oldPrimitive.Clone() as INdmPrimitive;
newPrimitive.Name += " copy";
repository.Primitives.Add(newPrimitive);
PrimitiveBase primitiveBase;
if (newPrimitive is IRectanglePrimitive) { primitiveBase = new RectangleViewPrimitive(newPrimitive as IRectanglePrimitive); }
else if (newPrimitive is ICirclePrimitive) { primitiveBase = new CircleViewPrimitive(newPrimitive as ICirclePrimitive); }
else if (newPrimitive is IPointPrimitive)
{
if (newPrimitive is ReinforcementPrimitive)
if (newPrimitive is RebarPrimitive)
{
primitiveBase = new ReinforcementViewPrimitive(newPrimitive as ReinforcementPrimitive);
primitiveBase = new ReinforcementViewPrimitive(newPrimitive as RebarPrimitive);
}
else
{

View File

@@ -19,7 +19,7 @@ using RectangleViewPrimitive = StructureHelper.Infrastructure.UI.DataContexts.Re
namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
{
public class PrimitivePropertiesViewModel : ViewModelBase, IDataErrorInfo
public class PrimitivePropertiesViewModel : OkCancelViewModelBase, IDataErrorInfo
{
private PrimitiveBase primitive;
private ICrossSectionRepository sectionRepository;
@@ -316,11 +316,11 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
private void CheckHost(PrimitiveBase primitive, INdmPrimitive item)
{
var ndm = primitive.GetNdmPrimitive();
if (ndm is ReinforcementPrimitive)
if (ndm is RebarPrimitive)
{
var host = item as IHasDivisionSize;
var reinforcement = ndm as ReinforcementPrimitive;
if (host.IsPointInside(new Point2D() { X = reinforcement.CenterX, Y = reinforcement.CenterY })
var reinforcement = ndm as RebarPrimitive;
if (host.IsPointInside(new Point2D() { X = reinforcement.Center.X, Y = reinforcement.Center.Y })
&& reinforcement.HostPrimitive is null)
{
var dialogResult = MessageBox.Show($"Primitive {reinforcement.Name} is inside primitive {item.Name}",

View File

@@ -9,7 +9,7 @@ using System.Windows;
namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
{
public class SelectPrimitivesViewModel
public class SelectPrimitivesViewModel : OkCancelViewModelBase
{
public SelectItemsViewModel<PrimitiveBase> Items { get; }