View primitives was fixed
This commit is contained in:
@@ -60,7 +60,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public IEnumerable<INdm> GetNdms(ICalculationProperty calculationProperty)
|
||||
{
|
||||
var unitSystem = unitSystemService.GetCurrentSystem();
|
||||
var ndmPrimitives = primitiveRepository.Primitives.Select(x => x.GetNdmPrimitive(unitSystem)).ToArray();
|
||||
var ndmPrimitives = primitiveRepository.Primitives.Select(x => x.GetNdmPrimitive()).ToArray();
|
||||
|
||||
//Настройки триангуляции, пока опции могут быть только такие
|
||||
ITriangulationOptions options = new TriangulationOptions { LimiteState = calculationProperty.LimitState, CalcTerm = calculationProperty.CalcTerm };
|
||||
|
||||
@@ -7,21 +7,18 @@
|
||||
xmlns:infrastructure="clr-namespace:StructureHelper.Infrastructure"
|
||||
xmlns:dataTemplates="clr-namespace:StructureHelper.Infrastructure.UI.DataTemplates"
|
||||
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
|
||||
xmlns:vm="clr-namespace:StructureHelper.Windows.MainWindow"
|
||||
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow"
|
||||
xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums"
|
||||
xmlns:converters ="clr-namespace:StructureHelper.Infrastructure.UI.Converters.Units"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:MainViewModel}"
|
||||
Title="StructureHelper" Height="700" Width="1000" MinHeight="400" MinWidth="600">
|
||||
<Window.Resources>
|
||||
<converters:Length x:Key="LengthConverter"/>
|
||||
<converters:Area x:Key="AreaConverter"/>
|
||||
|
||||
<DataTemplate DataType="{x:Type dataContexts:Rectangle}">
|
||||
<DataTemplate DataType="{x:Type dataContexts:RectangleViewPrimitive}">
|
||||
<dataTemplates:RectangleTemplate/>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type dataContexts:Point}">
|
||||
<DataTemplate DataType="{x:Type dataContexts:PointViewPrimitive}">
|
||||
<dataTemplates:EllipseTemplate/>
|
||||
</DataTemplate>
|
||||
</Window.Resources>
|
||||
@@ -148,7 +145,7 @@
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
|
||||
<Canvas ClipToBounds="True" Width="{Binding CanvasWidth}" Height="{Binding CanvasHeight}">
|
||||
<Canvas Name="WorkPlane" ClipToBounds="True" Width="{Binding CanvasWidth}" Height="{Binding CanvasHeight}">
|
||||
<i:Interaction.Behaviors>
|
||||
<infrastructure:MouseBehaviour MouseX="{Binding PanelX, Mode=OneWayToSource}" MouseY="{Binding PanelY, Mode=OneWayToSource}"/>
|
||||
</i:Interaction.Behaviors>
|
||||
@@ -180,9 +177,9 @@
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
</Canvas.Background>
|
||||
<Line X1="0" X2="{Binding XX2}" Y1="{Binding XY1}" Y2="{Binding XY1}" Stroke="Red" StrokeThickness="1"/>
|
||||
<Line X1="{Binding YX1}" X2="{Binding YX1}" Y1="0" Y2="{Binding YY2}" Stroke="ForestGreen" StrokeThickness="1"/>
|
||||
<ItemsControl ItemsSource="{Binding Primitives}" d:DataContext="{d:DesignInstance dataContexts:PrimitiveBase}">
|
||||
<Line X1="0" X2="{Binding XX2}" Y1="{Binding XY1}" Y2="{Binding XY1}" Stroke="Red" StrokeThickness="{Binding AxisLineThickness}"/>
|
||||
<Line X1="{Binding YX1}" X2="{Binding YX1}" Y1="0" Y2="{Binding YY2}" Stroke="ForestGreen" StrokeThickness="{Binding AxisLineThickness}"/>
|
||||
<ItemsControl ItemsSource="{Binding Primitives}" d:DataContext="{d:DesignInstance vm:MainViewModel}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas/>
|
||||
@@ -191,8 +188,8 @@
|
||||
<ItemsControl.ItemContainerStyle>
|
||||
<Style TargetType="ContentPresenter">
|
||||
<Setter Property="Canvas.ZIndex" Value="{Binding ZIndex}"/>
|
||||
<Setter Property="Canvas.Left" Value="{Binding X, Converter={StaticResource LengthConverter}}"/>
|
||||
<Setter Property="Canvas.Top" Value="{Binding Y, Converter={StaticResource LengthConverter}}"/>
|
||||
<Setter Property="Canvas.Left" Value="{Binding PrimitiveLeft}"/>
|
||||
<Setter Property="Canvas.Top" Value="{Binding PrimitiveTop}"/>
|
||||
</Style>
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
</ItemsControl>
|
||||
|
||||
@@ -6,6 +6,7 @@ using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Infrastructure.UI.PrimitiveTemplates;
|
||||
using StructureHelper.MaterialCatalogWindow;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelper.Models.Primitives.Factories;
|
||||
using StructureHelper.Services.Primitives;
|
||||
using StructureHelper.UnitSystem;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow;
|
||||
@@ -20,7 +21,9 @@ using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationProperties;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.Services.NdmCalculations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -34,14 +37,14 @@ namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
public class MainViewModel : ViewModelBase
|
||||
{
|
||||
const double ConstAxisLineThickness = 2d;
|
||||
|
||||
private List<IHeadMaterial> headMaterials;
|
||||
private readonly double scaleRate = 1.1;
|
||||
|
||||
private IPrimitiveRepository PrimitiveRepository { get; }
|
||||
public PrimitiveBase SelectedPrimitive { get; set; }
|
||||
|
||||
private readonly UnitSystemService unitSystemService;
|
||||
|
||||
private MainModel Model { get; }
|
||||
public ObservableCollection<PrimitiveBase> Primitives { get; set; }
|
||||
|
||||
@@ -75,7 +78,18 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public double ScaleValue
|
||||
{
|
||||
get => scaleValue;
|
||||
set => OnPropertyChanged(value, ref scaleValue);
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(value, ref scaleValue);
|
||||
axisLineThickness = ConstAxisLineThickness / scaleValue;
|
||||
OnPropertyChanged(nameof(AxisLineThickness));
|
||||
}
|
||||
}
|
||||
|
||||
public double AxisLineThickness
|
||||
{
|
||||
get =>axisLineThickness == 0d? ConstAxisLineThickness: axisLineThickness;
|
||||
set { axisLineThickness = value; }
|
||||
}
|
||||
|
||||
private double canvasWidth, canvasHeight, xX2, xY1, yX1, yY2;
|
||||
@@ -149,16 +163,14 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public ICommand SetPopupCanBeClosedTrue { get; }
|
||||
public ICommand SetPopupCanBeClosedFalse { get; }
|
||||
|
||||
public string UnitsSystemName => unitSystemService.GetCurrentSystem().Name;
|
||||
|
||||
private double delta = 0.0005;
|
||||
private double axisLineThickness;
|
||||
|
||||
public MainViewModel(MainModel model, IPrimitiveRepository primitiveRepository, UnitSystemService unitSystemService)
|
||||
{
|
||||
PrimitiveRepository = primitiveRepository;
|
||||
Model = model;
|
||||
headMaterials = Model.HeadMaterialRepository.HeadMaterials;
|
||||
this.unitSystemService = unitSystemService;
|
||||
CanvasWidth = 1500;
|
||||
CanvasHeight = 1000;
|
||||
XX2 = CanvasWidth;
|
||||
@@ -169,25 +181,25 @@ namespace StructureHelper.Windows.MainWindow
|
||||
|
||||
LeftButtonUp = new RelayCommand(o =>
|
||||
{
|
||||
if (o is Rectangle rect) rect.BorderCaptured = false;
|
||||
if (o is RectangleViewPrimitive rect) rect.BorderCaptured = false;
|
||||
});
|
||||
LeftButtonDown = new RelayCommand(o =>
|
||||
{
|
||||
if (o is Rectangle rect) rect.BorderCaptured = true;
|
||||
if (o is RectangleViewPrimitive rect) rect.BorderCaptured = true;
|
||||
});
|
||||
PreviewMouseMove = new RelayCommand(o =>
|
||||
{
|
||||
if (o is Rectangle rect && rect.BorderCaptured && !rect.ElementLock)
|
||||
if (o is RectangleViewPrimitive rect && rect.BorderCaptured && !rect.ElementLock)
|
||||
{
|
||||
if (rect.PrimitiveWidth % 10d < delta || rect.PrimitiveWidth % 10d >= delta)
|
||||
rect.PrimitiveWidth = Math.Round(PanelX / 10d) * 10d - rect.X + 10d;
|
||||
rect.PrimitiveWidth = Math.Round(PanelX / 10d) * 10d - rect.PrimitiveLeft + 10d;
|
||||
else
|
||||
rect.PrimitiveWidth = PanelX - rect.X + 10d;
|
||||
rect.PrimitiveWidth = PanelX - rect.PrimitiveLeft + 10d;
|
||||
|
||||
if (rect.PrimitiveHeight % 10d < delta || rect.PrimitiveHeight % 10d >= delta)
|
||||
rect.PrimitiveHeight = Math.Round(PanelY / 10d) * 10d - rect.Y + 10d;
|
||||
rect.PrimitiveHeight = Math.Round(PanelY / 10d) * 10d - rect.PrimitiveTop + 10d;
|
||||
else
|
||||
rect.PrimitiveHeight = PanelY - rect.Y + 10d;
|
||||
rect.PrimitiveHeight = PanelY - rect.PrimitiveTop + 10d;
|
||||
}
|
||||
});
|
||||
ClearSelection = new RelayCommand(o =>
|
||||
@@ -211,10 +223,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
var materialCatalogView = new MaterialCatalogView(true, primitive);
|
||||
materialCatalogView.ShowDialog();
|
||||
});
|
||||
OpenUnitsSystemSettings = new RelayCommand(o =>
|
||||
{
|
||||
OnPropertyChanged(nameof(UnitsSystemName));
|
||||
});
|
||||
|
||||
SetColor = new RelayCommand(o =>
|
||||
{
|
||||
var primitive = o as PrimitiveBase;
|
||||
@@ -259,18 +268,33 @@ namespace StructureHelper.Windows.MainWindow
|
||||
AddPrimitive = new RelayCommand(o =>
|
||||
{
|
||||
if (!(o is PrimitiveType primitiveType)) return;
|
||||
PrimitiveBase primitive;
|
||||
PrimitiveBase viewPrimitive;
|
||||
INdmPrimitive ndmPrimitive;
|
||||
if (primitiveType == PrimitiveType.Rectangle)
|
||||
{
|
||||
primitive = new Rectangle(0.60, 0.40, 0, 0, this);
|
||||
var primitive = new RectanglePrimitive
|
||||
{
|
||||
Width = 0.4d,
|
||||
Height = 0.6d
|
||||
};
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new RectangleViewPrimitive(primitive);
|
||||
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Point)
|
||||
{
|
||||
primitive = new Point(0.0005d, 0d, 0d, this);
|
||||
var primitive = new PointPrimitive
|
||||
{
|
||||
Area = 0.0005d
|
||||
};
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new PointViewPrimitive(primitive);
|
||||
}
|
||||
|
||||
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + nameof(primitiveType)); }
|
||||
Primitives.Add(primitive);
|
||||
PrimitiveRepository.Add(primitive);
|
||||
viewPrimitive.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
|
||||
Primitives.Add(viewPrimitive);
|
||||
PrimitiveRepository.Add(viewPrimitive);
|
||||
});
|
||||
|
||||
DeletePrimitive = new RelayCommand(
|
||||
@@ -461,13 +485,6 @@ namespace StructureHelper.Windows.MainWindow
|
||||
wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
{
|
||||
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;
|
||||
|
||||
IHeadMaterial concrete = new HeadMaterial() { Name = "Concrete" };
|
||||
concrete.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Concrete & x.Name.Contains("40"))).First();
|
||||
IHeadMaterial reinforcement = new HeadMaterial() { Name = "Reinforcement" };
|
||||
@@ -475,38 +492,14 @@ namespace StructureHelper.Windows.MainWindow
|
||||
headMaterials.Add(concrete);
|
||||
headMaterials.Add(reinforcement);
|
||||
OnPropertyChanged(nameof(headMaterials));
|
||||
|
||||
double[] xs = new double[] { -width / 2 + gap, width / 2 - gap };
|
||||
double[] ys = new double[] { -height / 2 + gap, height / 2 - gap };
|
||||
|
||||
yield return new Rectangle(width, height, 0, 0, this) { HeadMaterial = concrete, Name = "Concrete block" };
|
||||
yield return new Point(area1, xs[0], ys[0], this) { HeadMaterial = reinforcement, Name = "Left bottom point" };
|
||||
yield return new Point(area1, xs[1], ys[0], this) { HeadMaterial = reinforcement, Name = "Right bottom point" };
|
||||
yield return new Point(area2, xs[0], ys[1], this) { HeadMaterial = reinforcement, Name = "Left top point" };
|
||||
yield return new Point(area2, xs[1], ys[1], this) { HeadMaterial = reinforcement, Name = "Right top point" };
|
||||
|
||||
if (template.WidthCount > 2)
|
||||
var primitives = PrimitiveFactory.GetRectangleRCElement(template, concrete, reinforcement);
|
||||
foreach (var item in primitives)
|
||||
{
|
||||
int count = template.WidthCount - 1;
|
||||
double dist = (xs[1] - xs[0]) / count;
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
yield return new Point(area1, xs[0] + dist * i, ys[0], this) { HeadMaterial = reinforcement, Name = $"Bottom point {i}" };
|
||||
yield return new Point(area2, xs[0] + dist * i, ys[1], this) { HeadMaterial = reinforcement, Name = $"Top point {i}" };
|
||||
}
|
||||
}
|
||||
|
||||
if (template.HeightCount > 2)
|
||||
{
|
||||
int count = template.HeightCount - 1;
|
||||
double dist = (ys[1] - ys[0]) / count;
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
yield return new Point(area1, xs[0], ys[0] + dist * i, this) { HeadMaterial = reinforcement, Name = $"Left point {i}" };
|
||||
yield return new Point(area1, xs[1], ys[0] + dist * i, this) { HeadMaterial = reinforcement, Name = $"Right point {i}" };
|
||||
}
|
||||
item.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
|
||||
}
|
||||
return primitives;
|
||||
}
|
||||
return new List<PrimitiveBase>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user