diff --git a/FieldVisualizer/Entities/ColorMaps/Factories/ColorMapFactory.cs b/FieldVisualizer/Entities/ColorMaps/Factories/ColorMapFactory.cs
index b5c0010..e259a79 100644
--- a/FieldVisualizer/Entities/ColorMaps/Factories/ColorMapFactory.cs
+++ b/FieldVisualizer/Entities/ColorMaps/Factories/ColorMapFactory.cs
@@ -1,12 +1,18 @@
-using FieldVisualizer.InfraStructures.Enums;
-using FieldVisualizer.InfraStructures.Exceptions;
+using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings;
-using System;
using System.Collections.Generic;
using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps.Factories
{
+ public enum ColorMapsTypes
+ {
+ LiraSpectrum = 0, //Lira
+ FullSpectrum = 1, //StaDiCon
+ RedToWhite = 2,
+ RedToBlue = 3,
+ BlueToWhite = 4,
+ }
///
/// Factory for creating of different color maps
///
@@ -18,13 +24,39 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
if (mapsTypes == ColorMapsTypes.RedToWhite) { return GetRedToWhite(); }
if (mapsTypes == ColorMapsTypes.RedToBlue) { return GetRedToBlue(); }
if (mapsTypes == ColorMapsTypes.BlueToWhite) { return GetBlueToWhite(); }
+ if (mapsTypes == ColorMapsTypes.LiraSpectrum) { return GetLiraSpectrum(); }
else { throw new FieldVisulizerException(ErrorStrings.ColorMapTypeIsUnknown); }
}
+ private static IColorMap GetLiraSpectrum()
+ {
+ ColorMap colorMap = new()
+ {
+ Name = "LiraSpectrumColorMap"
+ };
+ List colors = new();
+ byte Alpha = 0xff;
+ colors.AddRange(new Color[]{
+ Color.FromArgb(Alpha, 0, 0, 128) ,//Dark Blue
+ Color.FromArgb(Alpha, 0, 0, 255) ,//Blue
+ Color.FromArgb(Alpha, 0, 128, 255) ,//Blue
+ Color.FromArgb(Alpha, 0, 200, 255) ,//Blue
+ Color.FromArgb(Alpha, 60, 255, 255) ,//Light Blue
+ Color.FromArgb(Alpha, 255, 255, 128) ,//Light Yellow
+ Color.FromArgb(Alpha, 255, 255, 0) ,//Yellow
+ Color.FromArgb(Alpha, 255, 215, 0) ,//Gold
+ Color.FromArgb(Alpha, 255, 128, 0) ,//Orange Red
+ Color.FromArgb(Alpha, 255, 0, 0) ,//Red
+ });
+ colorMap.Colors = colors;
+ return colorMap;
+ }
private static IColorMap GetFullSpectrum()
{
- ColorMap colorMap = new ColorMap();
- colorMap.Name = "FullSpectrumColorMap";
+ ColorMap colorMap = new()
+ {
+ Name = "FullSpectrumColorMap"
+ };
List colors = new List();
byte Alpha = 0xff;
colors.AddRange(new Color[]{
@@ -43,7 +75,6 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
colorMap.Colors = colors;
return colorMap;
}
-
private static IColorMap GetRedToWhite()
{
ColorMap colorMap = new ColorMap();
@@ -57,7 +88,6 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
colorMap.Colors = colors;
return colorMap;
}
-
private static IColorMap GetRedToBlue()
{
ColorMap colorMap = new ColorMap();
@@ -71,7 +101,6 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
colorMap.Colors = colors;
return colorMap;
}
-
private static IColorMap GetBlueToWhite()
{
ColorMap colorMap = new ColorMap();
diff --git a/FieldVisualizer/Entities/ColorMaps/IValueColorRange.cs b/FieldVisualizer/Entities/ColorMaps/IValueColorRange.cs
index d4da2bc..395993c 100644
--- a/FieldVisualizer/Entities/ColorMaps/IValueColorRange.cs
+++ b/FieldVisualizer/Entities/ColorMaps/IValueColorRange.cs
@@ -1,19 +1,35 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Media;
+using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps
{
+ ///
+ /// Colored range for building color legend
+ ///
public interface IValueColorRange
{
+ ///
+ /// Flag of activity
+ ///
bool IsActive { get; set; }
+ ///
+ /// Minimum value of range
+ ///
double BottomValue { get; set; }
+ ///
+ /// Average value of range
+ ///
double AverageValue { get; set; }
+ ///
+ /// Maximum value of range
+ ///
double TopValue {get;set;}
+ ///
+ /// Color correspondent to minimum value
+ ///
Color BottomColor { get; set; }
+ ///
+ /// Color correspondent to maximum value
+ ///
Color TopColor { get; set; }
}
}
diff --git a/FieldVisualizer/Entities/ColorMaps/ValueColorRange.cs b/FieldVisualizer/Entities/ColorMaps/ValueColorRange.cs
index 92eaff5..695cca3 100644
--- a/FieldVisualizer/Entities/ColorMaps/ValueColorRange.cs
+++ b/FieldVisualizer/Entities/ColorMaps/ValueColorRange.cs
@@ -1,19 +1,21 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Media;
+using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps
{
+ ///
public class ValueColorRange : IValueColorRange
{
+ ///
public bool IsActive { get; set; }
+ ///
public double BottomValue { get; set; }
+ ///
public double AverageValue { get; set; }
+ ///
public double TopValue { get; set; }
+ ///
public Color BottomColor { get; set; }
+ ///
public Color TopColor { get; set; }
}
}
diff --git a/FieldVisualizer/FieldVisualizer.csproj b/FieldVisualizer/FieldVisualizer.csproj
index 0a3b622..dc9183b 100644
--- a/FieldVisualizer/FieldVisualizer.csproj
+++ b/FieldVisualizer/FieldVisualizer.csproj
@@ -8,4 +8,12 @@
7.0
+
+
+
+
+
+
+
+
diff --git a/FieldVisualizer/InfraStructures/Enums/ColorMapsTypes.cs b/FieldVisualizer/InfraStructures/Enums/ColorMapsTypes.cs
deleted file mode 100644
index 5be9d8c..0000000
--- a/FieldVisualizer/InfraStructures/Enums/ColorMapsTypes.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace FieldVisualizer.InfraStructures.Enums
-{
- public enum ColorMapsTypes
- {
- FullSpectrum = 0,
- RedToWhite = 1,
- RedToBlue = 2,
- BlueToWhite = 3
- }
-}
diff --git a/FieldVisualizer/Services/ColorServices/ColorOperations.cs b/FieldVisualizer/Services/ColorServices/ColorOperations.cs
index dd4c7c7..9b3148d 100644
--- a/FieldVisualizer/Services/ColorServices/ColorOperations.cs
+++ b/FieldVisualizer/Services/ColorServices/ColorOperations.cs
@@ -1,5 +1,6 @@
using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.Values;
+using StructureHelperCommon.Infrastructures.Exceptions;
using System;
using System.Collections.Generic;
using System.Text;
@@ -10,54 +11,123 @@ namespace FieldVisualizer.Services.ColorServices
public static class ColorOperations
{
const byte Alpha = 0xff;
- public static Color GetColorByValue(IValueRange range, IColorMap map, double val)
- {
- if (range.TopValue == range.BottomValue || map.Colors.Count == 0) { return map.Colors[0]; }
- double minVal = range.BottomValue - 1e-15d*(Math.Abs(range.BottomValue));
- double maxVal = range.TopValue + 1e-15d * (Math.Abs(range.TopValue));
- if (val > maxVal || val < minVal) { return Colors.Gray; }
- if (val == minVal) { return map.Colors[0]; }
- if (val == maxVal) { return map.Colors[map.Colors.Count - 1]; }
-
- double valPerc = (val - minVal) / (maxVal - minVal);// value%
- if (valPerc >= 1d)
- { return map.Colors[map.Colors.Count - 1]; }
- double colorPerc = 1d / (map.Colors.Count - 1d); // % of each block of color. the last is the "100% Color"
- double blockOfColor = valPerc / colorPerc;// the integer part repersents how many block to skip
- int blockIdx = (int)Math.Truncate(blockOfColor);// Idx of
- double valPercResidual = valPerc - (blockIdx * colorPerc);//remove the part represented of block
- double percOfColor = valPercResidual / colorPerc;// % of color of this block that will be filled
-
- Color cTarget = map.Colors[blockIdx];
- Color cNext = map.Colors[blockIdx + 1];
-
- var deltaR = cNext.R - cTarget.R;
- var deltaG = cNext.G - cTarget.G;
- var deltaB = cNext.B - cTarget.B;
-
- var R = cTarget.R + (deltaR * percOfColor);
- var G = cTarget.G + (deltaG * percOfColor);
- var B = cTarget.B + (deltaB * percOfColor);
-
- Color c = map.Colors[0];
- c = Color.FromArgb(Alpha, (byte)R, (byte)G, (byte)B);
- return c;
- }
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public static IEnumerable GetValueColorRanges(IValueRange fullRange, IEnumerable valueRanges, IColorMap colorMap)
{
var colorRanges = new List();
foreach (var valueRange in valueRanges)
{
- IValueColorRange valueColorRange = new ValueColorRange();
- valueColorRange.IsActive = true;
- valueColorRange.BottomValue = valueRange.BottomValue;
- valueColorRange.AverageValue = (valueRange.BottomValue + valueRange.TopValue) / 2;
- valueColorRange.TopValue = valueRange.TopValue;
+ IValueColorRange valueColorRange = new ValueColorRange
+ {
+ IsActive = true,
+ BottomValue = valueRange.BottomValue,
+ AverageValue = (valueRange.BottomValue + valueRange.TopValue) / 2,
+ TopValue = valueRange.TopValue
+ };
valueColorRange.BottomColor = GetColorByValue(fullRange, colorMap, valueColorRange.BottomValue);
valueColorRange.TopColor = GetColorByValue(fullRange, colorMap, valueColorRange.TopValue);
colorRanges.Add(valueColorRange);
}
return colorRanges;
}
+ ///
+ /// Returns color by value, range of value an color map
+ ///
+ /// Range of valoue
+ /// Color map
+ /// Value
+ ///
+ public static Color GetColorByValue(IValueRange range, IColorMap map, double val)
+ {
+ CheckColorMap(map);
+ if (range.TopValue == range.BottomValue || map.Colors.Count == 1) //if range width is zero or map contain just 1 color
+ {
+ return map.Colors[0];
+ }
+ var valueRange = GetExtendedRange(range);
+ if (val >= valueRange.TopValue || val <= valueRange.BottomValue)
+ {
+ return GetColorValueIsOutOfRange(valueRange, map, val);
+ }
+ return GetColorValueIsInRange(valueRange, map, val);
+ }
+
+ private static Color GetColorValueIsOutOfRange(IValueRange range, IColorMap map, double val)
+ {
+ if (val > range.TopValue || val < range.BottomValue)
+ {
+ return Colors.Gray;
+ }
+ if (val == range.BottomValue)
+ {
+ return map.Colors[0];
+ }
+ if (val == range.TopValue)
+ {
+ return map.Colors[^1];
+ }
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect);
+ }
+
+ private static Color GetColorValueIsInRange(IValueRange range, IColorMap map, double val)
+ {
+ var deltaVal = val - range.BottomValue;
+ var rangeWidth = range.TopValue - range.BottomValue;
+ var valPerc = deltaVal / rangeWidth; // percent of value on the distance from minValue to maxValue
+ if (valPerc >= 1d)
+ {
+ return map.Colors[^1];
+ }
+ double colorPerc = 1d / (map.Colors.Count - 1d); // % of each block of color. the last is the "100% Color"
+ double blockOfColor = valPerc / colorPerc;// the integer part repersents how many block to skip
+ int blockIdx = (int)Math.Truncate(blockOfColor);// Idx of
+ double valPercResidual = valPerc - (blockIdx * colorPerc);//remove the part represented of block
+ double percOfColor = valPercResidual / colorPerc;// % of color of this block that will be filled
+
+ Color c = GetColorByColorMap(map, blockIdx, percOfColor);
+ return c;
+ }
+
+ private static IValueRange GetExtendedRange(IValueRange range)
+ {
+ var minVal = range.BottomValue - 1e-15d * Math.Abs(range.BottomValue);
+ var maxVal = range.TopValue + 1e-15d * Math.Abs(range.TopValue);
+ return new ValueRange()
+ {
+ BottomValue = minVal,
+ TopValue = maxVal
+ };
+ }
+
+ private static Color GetColorByColorMap(IColorMap map, int blockIdx, double percOfColor)
+ {
+ Color cTarget = map.Colors[blockIdx];
+ Color cNext = map.Colors[blockIdx + 1];
+
+ var deltaRed = cNext.R - cTarget.R;
+ var deltaGreen = cNext.G - cTarget.G;
+ var deltaBlue = cNext.B - cTarget.B;
+
+ var Red = cTarget.R + (deltaRed * percOfColor);
+ var Green = cTarget.G + (deltaGreen * percOfColor);
+ var Blue = cTarget.B + (deltaBlue * percOfColor);
+
+ Color c = Color.FromArgb(Alpha, (byte)Red, (byte)Green, (byte)Blue);
+ return c;
+ }
+
+ private static void CheckColorMap(IColorMap map)
+ {
+ if (map.Colors.Count == 0)
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": Color map is empty");
+ }
+ }
}
}
diff --git a/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs b/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs
index 4f16ce6..540abf1 100644
--- a/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs
+++ b/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs
@@ -1,27 +1,22 @@
-using FieldVisualizer.Entities.ColorMaps.Factories;
-using FieldVisualizer.Entities.ColorMaps;
-using FieldVisualizer.Entities.Values.Primitives;
+using FieldVisualizer.Entities.ColorMaps;
+using FieldVisualizer.Entities.ColorMaps.Factories;
using FieldVisualizer.Entities.Values;
+using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Infrastructure.Commands;
-using FieldVisualizer.InfraStructures.Enums;
using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings;
using FieldVisualizer.Services.ColorServices;
using FieldVisualizer.Services.PrimitiveServices;
using FieldVisualizer.Services.ValueRanges;
+using FieldVisualizer.Windows.UserControls;
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.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
-using FieldVisualizer.Windows.UserControls;
-using System.ComponentModel;
-using System.Xml.Serialization;
namespace FieldVisualizer.ViewModels.FieldViewerViewModels
{
@@ -177,7 +172,7 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
public FieldViewerViewModel()
{
- _ColorMapType = ColorMapsTypes.FullSpectrum;
+ _ColorMapType = ColorMapsTypes.LiraSpectrum;
RebuildCommand = new RelayCommand(o => ProcessPrimitives(), o => PrimitiveValidation());
ZoomInCommand = new RelayCommand(o => Zoom(1.2), o => PrimitiveValidation());
ZoomOutCommand = new RelayCommand(o => Zoom(0.8), o => PrimitiveValidation());
diff --git a/FieldVisualizer/Windows/UserControls/FieldViewer.xaml.cs b/FieldVisualizer/Windows/UserControls/FieldViewer.xaml.cs
index 1166be2..96e6753 100644
--- a/FieldVisualizer/Windows/UserControls/FieldViewer.xaml.cs
+++ b/FieldVisualizer/Windows/UserControls/FieldViewer.xaml.cs
@@ -1,23 +1,7 @@
-using FieldVisualizer.Entities.ColorMaps;
-using FieldVisualizer.Entities.ColorMaps.Factories;
-using FieldVisualizer.Entities.Values;
-using FieldVisualizer.Entities.Values.Primitives;
-using FieldVisualizer.Infrastructure.Commands;
-using FieldVisualizer.InfraStructures.Enums;
-using FieldVisualizer.InfraStructures.Exceptions;
-using FieldVisualizer.InfraStructures.Strings;
-using FieldVisualizer.Services.ColorServices;
-using FieldVisualizer.Services.PrimitiveServices;
-using FieldVisualizer.Services.ValueRanges;
+using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.ViewModels.FieldViewerViewModels;
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Shapes;
namespace FieldVisualizer.Windows.UserControls
{
@@ -39,17 +23,6 @@ namespace FieldVisualizer.Windows.UserControls
viewModel.Legend = LegendViewer;
}
- //public FieldViewer(FieldViewerViewModel vm)
- //{
- // InitializeComponent();
- // viewModel = vm;
- // this.DataContext = viewModel;
- // PrimitiveSet = viewModel.PrimitiveSet;
- // viewModel.WorkPlaneBox = WorkPlaneBox;
- // viewModel.WorkPlaneCanvas = WorkPlaneCanvas;
- // viewModel.Legend = LegendViewer;
- //}
-
public IPrimitiveSet PrimitiveSet { get => viewModel.PrimitiveSet; set { viewModel.PrimitiveSet = value; } }
internal void Refresh()
diff --git a/StructureHelper.sln b/StructureHelper.sln
index 10d38cf..7bf9930 100644
--- a/StructureHelper.sln
+++ b/StructureHelper.sln
@@ -14,6 +14,9 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{C9192AE7-EE6D-409C-A05C-3549D78CBB34}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualizer", "FieldVisualizer\FieldVisualizer.csproj", "{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A} = {F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}
+ EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/StructureHelper/App.xaml.cs b/StructureHelper/App.xaml.cs
index 0f7f3b1..86d7f43 100644
--- a/StructureHelper/App.xaml.cs
+++ b/StructureHelper/App.xaml.cs
@@ -22,15 +22,15 @@ namespace StructureHelper
builder.RegisterType().As().SingleInstance();
builder.RegisterType().AsSelf().SingleInstance();
builder.RegisterType().AsSelf().SingleInstance();
- builder.RegisterType().AsSelf().SingleInstance();
- builder.RegisterType().AsSelf().SingleInstance();
+ builder.RegisterType().AsSelf().SingleInstance();
+ builder.RegisterType().AsSelf().SingleInstance();
- builder.RegisterType().AsSelf();
+ builder.RegisterType().AsSelf();
Container = builder.Build();
Scope = Container.Resolve();
- var window = Scope.Resolve();
+ var window = Scope.Resolve();
window.Show();
}
diff --git a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs
index 39f4dbd..47bfe52 100644
--- a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs
+++ b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs
@@ -2,13 +2,15 @@
using StructureHelper.Services.Primitives;
using StructureHelper.Windows.MainWindow;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
+using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
using System.Windows.Input;
using System.Windows.Media;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
- public abstract class PrimitiveBase : ViewModelBase
+ public abstract class PrimitiveBase : ViewModelBase, IObserver
{
#region Поля
private IPrimitiveRepository primitiveRepository;
@@ -236,13 +238,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
this.primitive = primitive;
}
- public void RegisterDeltas(double dx, double dy)
- {
- DeltaX = dx;
- DeltaY = dy;
- }
-
- public MainViewModel OwnerVM { get; private set; }
+ public CrossSectionViewModel OwnerVM { get; private set; }
public double DeltaX { get; private set; }
public double DeltaY { get; private set; }
@@ -253,14 +249,6 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
return primitive;
}
- //public virtual void RefreshNdmPrimitive()
- //{
- //}
-
- public void RefreshColor()
- {
- OnPropertyChanged(nameof(Color));
- }
public virtual void Refresh()
{
OnPropertyChanged(nameof(Name));
@@ -273,5 +261,22 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
OnPropertyChanged(nameof(PrimitiveWidth));
OnPropertyChanged(nameof(PrimitiveHeight));
}
+
+ public void OnCompleted()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnError(Exception error)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnNext(IRectangleShape value)
+ {
+ DeltaX = value.Width / 2d;
+ DeltaY = value.Height / 2d;
+ Refresh();
+ }
}
}
diff --git a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml
index 90a84a8..deaeb92 100644
--- a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml
+++ b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml
@@ -51,6 +51,20 @@
+
diff --git a/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml b/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml
index 0d0fd96..7c7acb2 100644
--- a/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml
+++ b/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml
@@ -33,10 +33,10 @@
-
+
-
+
diff --git a/StructureHelper/Libraries/LoaderCalculator.dll b/StructureHelper/Libraries/LoaderCalculator.dll
index f2db256..7a3289f 100644
Binary files a/StructureHelper/Libraries/LoaderCalculator.dll and b/StructureHelper/Libraries/LoaderCalculator.dll differ
diff --git a/StructureHelper/Models/Calculators/LimitCurveVisualCalculator.cs b/StructureHelper/Models/Calculators/LimitCurveVisualCalculator.cs
index 0330cc8..c106fc6 100644
--- a/StructureHelper/Models/Calculators/LimitCurveVisualCalculator.cs
+++ b/StructureHelper/Models/Calculators/LimitCurveVisualCalculator.cs
@@ -1,12 +1,8 @@
using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
-using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace StructureHelper.Models.Calculators
{
diff --git a/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user b/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user
index 6310abc..7cc792e 100644
--- a/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
- True|2023-02-25T08:37:39.2738786Z;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00;
+ True|2024-02-02T07:22:50.1454015Z;True|2023-02-25T13:37:39.2738786+05:00;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00;
\ No newline at end of file
diff --git a/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs b/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs
index 60b9db3..d4dc1ac 100644
--- a/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs
+++ b/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs
@@ -1,5 +1,6 @@
using LoaderCalculator.Logics;
using StructureHelper.Infrastructure.UI.Converters.Units;
+using StructureHelperCommon.Infrastructures.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,19 +9,63 @@ using System.Threading.Tasks;
namespace StructureHelper.Services.ResultViewers
{
+ public enum FuncsTypes
+ {
+ Strain,
+ Stress,
+ Forces,
+ Full,
+ }
public static class ResultFuncFactory
{
- public static IEnumerable GetResultFuncs()
+ static readonly IStressLogic stressLogic = new StressLogic();
+ public static List GetResultFuncs(FuncsTypes funcsType = FuncsTypes.Full)
+ {
+ List results = new();
+ if (funcsType == FuncsTypes.Strain)
+ {
+ results.AddRange(GetStrainResultFuncs());
+ }
+ else if (funcsType == FuncsTypes.Stress)
+ {
+ results.AddRange(GetStressResultFuncs());
+ }
+ else if (funcsType == FuncsTypes.Forces)
+ {
+ results.AddRange(GetForcesResultFuncs());
+ }
+ else if (funcsType == FuncsTypes.Full)
+ {
+ results.AddRange(GetStrainResultFuncs());
+ results.AddRange(GetStressResultFuncs());
+ results.AddRange(GetForcesResultFuncs());
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(funcsType));
+ }
+ return results;
+ }
+ private static List GetStrainResultFuncs()
{
List resultFuncs = new List();
- IStressLogic stressLogic = new StressLogic();
resultFuncs.Add(new ResultFunc() { Name = "Total Strain", ResultFunction = stressLogic.GetTotalStrain });
resultFuncs.Add(new ResultFunc() { Name = "Total Strain with prestrain", ResultFunction = stressLogic.GetTotalStrainWithPresrain });
resultFuncs.Add(new ResultFunc() { Name = "Elastic Strain", ResultFunction = stressLogic.GetElasticStrain });
resultFuncs.Add(new ResultFunc() { Name = "Plastic Strain", ResultFunction = stressLogic.GetPlasticStrain });
+ return resultFuncs;
+ }
+ private static List GetStressResultFuncs()
+ {
+ List resultFuncs = new List();
resultFuncs.Add(new ResultFunc() { Name = "Stress", ResultFunction = stressLogic.GetStress, UnitFactor = UnitConstants.Stress });
resultFuncs.Add(new ResultFunc() { Name = "Secant modulus", ResultFunction = stressLogic.GetSecantModulus, UnitFactor = UnitConstants.Stress });
resultFuncs.Add(new ResultFunc() { Name = "Modulus degradation", ResultFunction = stressLogic.GetModulusDegradation });
+ return resultFuncs;
+ }
+ private static List GetForcesResultFuncs()
+ {
+ List resultFuncs = new List();
resultFuncs.Add(new ResultFunc() { Name = "Force", ResultFunction = stressLogic.GetForce, UnitFactor = UnitConstants.Force });
resultFuncs.Add(new ResultFunc() { Name = "Moment X", ResultFunction = stressLogic.GetMomentX, UnitFactor = UnitConstants.Force });
resultFuncs.Add(new ResultFunc() { Name = "Moment Y", ResultFunction = stressLogic.GetMomentY, UnitFactor = UnitConstants.Force });
diff --git a/StructureHelper/StructureHelper.csproj.user b/StructureHelper/StructureHelper.csproj.user
index 6fee5a1..c6ef7d2 100644
--- a/StructureHelper/StructureHelper.csproj.user
+++ b/StructureHelper/StructureHelper.csproj.user
@@ -36,6 +36,15 @@
Code
+
+ Code
+
+
+ Code
+
+
+ Code
+
Code
@@ -101,6 +110,15 @@
Designer
+
+ Designer
+
+
+ Designer
+
+
+ Designer
+
Designer
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs
index c3025d0..b514987 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs
@@ -1,10 +1,10 @@
-using LoaderCalculator;
+using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
-using StructureHelperCommon.Models.Loggers;
+using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
@@ -15,8 +15,6 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Forms;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
@@ -63,21 +61,27 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
public void ShowCracks()
{
- var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
- var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
- var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
-
- string[] labels = GetCrackLabels(unitForce, unitMoment, unitCurvature);
- arrayParameter = new ArrayParameter(ValidTupleList.Count(), labels.Count(), labels);
- CalculateWithCrack(ValidTupleList, NdmPrimitives, unitForce, unitMoment, unitCurvature);
+ List labels = GetCrackLabels();
+ arrayParameter = new ArrayParameter(ValidTupleList.Count(), labels);
+ CalculateWithCrack(ValidTupleList,
+ NdmPrimitives,
+ CommonOperation.GetUnit(UnitTypes.Force),
+ CommonOperation.GetUnit(UnitTypes.Moment),
+ CommonOperation.GetUnit(UnitTypes.Curvature));
}
public void ShowWindow()
{
SafetyProcessor.RunSafeProcess(() =>
{
- var series = new Series(arrayParameter) { Name = "Forces and curvatures" };
- var vm = new GraphViewModel(new List() { series });
+ var series = new Series(arrayParameter)
+ {
+ Name = "Forces and curvatures"
+ };
+ var vm = new GraphViewModel(new List()
+ {
+ series
+ });
var wnd = new GraphView(vm);
wnd.ShowDialog();
},
@@ -134,18 +138,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
}
}
- private static string[] GetCrackLabels(IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
+ private static List GetCrackLabels()
{
const string crc = "Crc";
const string crcFactor = "CrcSofteningFactor";
- return new string[]
+ var labels = LabelsFactory.GetCommonLabels();
+ IUnit unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature);
+ var crclabels = new List
{
- $"{GeometryNames.MomFstName}, {unitMoment.Name}",
- $"{GeometryNames.MomSndName}, {unitMoment.Name}",
- $"{GeometryNames.LongForceName}, {unitForce.Name}",
- $"{GeometryNames.CurvFstName}, {unitCurvature.Name}",
- $"{GeometryNames.CurvSndName}, {unitCurvature.Name}",
- $"{GeometryNames.StrainTrdName}",
$"{crc}{GeometryNames.CurvFstName}, {unitCurvature.Name}",
$"{crc}{GeometryNames.CurvSndName}, {unitCurvature.Name}",
$"{crc}{GeometryNames.StrainTrdName}",
@@ -154,6 +154,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
$"{crcFactor}Az",
$"PsiFactor"
};
+ labels.AddRange(crclabels);
+ return labels;
}
}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs
index a4e48d2..2a5f059 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs
@@ -4,15 +4,11 @@ using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
+using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
-using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Parameters;
-using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
-using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
-using StructureHelperLogics.NdmCalculations.Primitives;
-using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -94,7 +90,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private ArrayParameter GetParametersByCurveResult(LimitCurveResult curveResult)
{
- string[] labels = GetLabels();
+ var labels = GetLabels();
var items = curveResult.Points;
var arrayParameter = new ArrayParameter(items.Count(), labels.Count(), labels);
var data = arrayParameter.Data;
@@ -125,11 +121,13 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
SetProgress?.Invoke(parameterResult.IterationNumber);
}
- private string[] GetLabels()
+ private List GetLabels()
{
- string[] strings = new string[2];
- strings[0] = GetLabel(InputData.SurroundData.ConvertLogicEntity.XForceType);
- strings[1] = GetLabel(InputData.SurroundData.ConvertLogicEntity.YForceType);
+ List strings = new()
+ {
+ GetLabel(InputData.SurroundData.ConvertLogicEntity.XForceType),
+ GetLabel(InputData.SurroundData.ConvertLogicEntity.YForceType)
+ };
return strings;
}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs
new file mode 100644
index 0000000..db6552e
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs
@@ -0,0 +1,32 @@
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Infrastructures.Settings;
+using StructureHelperCommon.Services.Units;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ public static class LabelsFactory
+ {
+ private static IUnit unitForce = CommonOperation.GetUnit(UnitTypes.Force);
+ private static IUnit unitMoment = CommonOperation.GetUnit(UnitTypes.Moment);
+ private static IUnit unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature);
+ private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
+ public static List GetCommonLabels()
+ {
+ var labels = new List
+ {
+ $"{GeometryNames.MomFstName}, {unitMoment.Name}",
+ $"{GeometryNames.MomSndName}, {unitMoment.Name}",
+ $"{GeometryNames.LongForceName}, {unitForce.Name}",
+ $"{GeometryNames.CurvFstName}, {unitCurvature.Name}",
+ $"{GeometryNames.CurvSndName}, {unitCurvature.Name}",
+ $"{GeometryNames.StrainTrdName}",
+ };
+ return labels;
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs
index 797ce0a..04445c5 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs
@@ -1,8 +1,11 @@
-using StructureHelper.Windows.Errors;
+using LoaderCalculator;
+using StructureHelper.Windows.CalculationWindows.ProgressViews;
+using StructureHelper.Windows.Errors;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
+using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
@@ -14,26 +17,29 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
internal class ShowCrackResultLogic
{
+ private CrackForceCalculator calculator;
+
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
- public ForceTuple ForceTuple { get; set; }
+ public IForceTuple ForceTuple { get; set; }
public IEnumerable ndmPrimitives { get; set; }
public void Show(IDesignForceTuple finishDesignTuple)
{
var viewModel = new InterpolateTuplesViewModel(finishDesignTuple, null);
- viewModel.StepCountVisible = false;
+ viewModel.ForceInterpolationViewModel.StepCountVisible = false;
var wndTuples = new InterpolateTuplesView(viewModel);
wndTuples.ShowDialog();
if (wndTuples.DialogResult != true) return;
- var startDesignTuple = viewModel.StartDesignForce.ForceTuple;
- var endDesignTuple = viewModel.FinishDesignForce.ForceTuple;
+ var startDesignTuple = viewModel.ForceInterpolationViewModel.StartDesignForce.ForceTuple;
+ var endDesignTuple = viewModel.ForceInterpolationViewModel.FinishDesignForce.ForceTuple;
FindCrackFactor(endDesignTuple, startDesignTuple);
}
- private void FindCrackFactor(ForceTuple finishDesignTuple, ForceTuple startDesignTuple)
+ private void FindCrackFactor(IForceTuple finishDesignTuple, IForceTuple startDesignTuple)
{
- var calculator = new CrackForceCalculator();
+ calculator = new CrackForceCalculator();
+ calculator.TraceLogger = new ShiftTraceLogger();
calculator.StartTuple = startDesignTuple;
calculator.EndTuple = finishDesignTuple;
calculator.NdmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, LimitState, CalcTerm);
@@ -41,7 +47,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
var result = (CrackForceResult)calculator.Result;
if (result.IsValid)
{
- ShowResult(result);
+ ShowTraceResult();
+ //ShowResult(result);
}
else
{
@@ -80,5 +87,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
+
+ private void ShowTraceResult()
+ {
+ if (calculator.TraceLogger is not null)
+ {
+ var wnd = new TraceDocumentView(calculator.TraceLogger.TraceLoggerEntries);
+ wnd.ShowDialog();
+ }
+ }
}
}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs
index 950f84c..4410f59 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs
@@ -15,7 +15,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public List ndmPrimitives { get; set; }
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
- public ForceTuple ForceTuple { get; set; }
+ public IForceTuple ForceTuple { get; set; }
internal void Show()
{
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs
index 89a6d65..8e42820 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs
@@ -1,9 +1,10 @@
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
-using StructureHelperCommon.Models.Loggers;
+using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
@@ -17,14 +18,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
internal class ShowDiagramLogic : ILongProcessLogic
{
- ArrayParameter arrayParameter;
- private IEnumerable TupleList;
- private IEnumerable NdmPrimitives;
- private List ValidTupleList;
+ private ArrayParameter arrayParameter;
+ private IEnumerable tupleList;
+ private IEnumerable ndmPrimitives;
+ private List validTupleList;
- private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
-
- public int StepCount => ValidTupleList.Count();
+ public int StepCount => validTupleList.Count();
public Action SetProgress { get; set; }
public bool Result { get; set; }
@@ -50,37 +49,33 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
SafetyProcessor.RunSafeProcess(() =>
{
var series = new Series(arrayParameter) { Name = "Forces and curvatures" };
- var vm = new GraphViewModel(new List() { series});
+ var vm = new GraphViewModel(new List() { series });
var wnd = new GraphView(vm);
wnd.ShowDialog();
- },
- "Errors appeared during showing a graph, see detailed information");
+ }, ErrorStrings.ErrorDuring("building chart"));
}
private void Show()
{
- ValidTupleList = TupleList.Where(x => x.IsValid == true).ToList();
- var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
- var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
- var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
+ validTupleList = tupleList.Where(x => x.IsValid == true).ToList();
- string[] labels = GetLabels(unitForce, unitMoment, unitCurvature);
- arrayParameter = new ArrayParameter(ValidTupleList.Count(), labels.Count(), labels);
- CalculateWithoutCrack(ValidTupleList, unitForce, unitMoment, unitCurvature);
+ var labels = LabelsFactory.GetCommonLabels();
+ arrayParameter = new ArrayParameter(validTupleList.Count(), labels);
+ Calculate();
}
public ShowDiagramLogic(IEnumerable tupleList, IEnumerable ndmPrimitives)
{
- TupleList = tupleList;
- NdmPrimitives = ndmPrimitives;
- ValidTupleList = TupleList.Where(x => x.IsValid == true).ToList();
+ this.tupleList = tupleList;
+ this.ndmPrimitives = ndmPrimitives;
+ validTupleList = tupleList.Where(x => x.IsValid == true).ToList();
}
- private void CalculateWithoutCrack(List resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
+ private void Calculate()
{
var data = arrayParameter.Data;
- for (int i = 0; i < resultList.Count(); i++)
+ for (int i = 0; i < validTupleList.Count(); i++)
{
- var valueList = ProcessResultWithouCrack(resultList, unitForce, unitMoment, unitCurvature, i);
+ var valueList = ProcessResult(i);
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
@@ -90,30 +85,21 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
}
- private static List ProcessResultWithouCrack(List resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature, int i)
+ private List ProcessResult(int i)
{
+ var unitForce = CommonOperation.GetUnit(UnitTypes.Force);
+ var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment);
+ var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature);
+
return new List
{
- resultList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
- resultList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
- resultList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer,
- resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer,
- resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer,
- resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ
+ validTupleList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
+ validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
+ validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer,
+ validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer,
+ validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer,
+ validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ
};
}
- private static string[] GetLabels(IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
- {
- return new string[]
- {
- $"{GeometryNames.MomFstName}, {unitMoment.Name}",
- $"{GeometryNames.MomSndName}, {unitMoment.Name}",
- $"{GeometryNames.LongForceName}, {unitForce.Name}",
- $"{GeometryNames.CurvFstName}, {unitCurvature.Name}",
- $"{GeometryNames.CurvSndName}, {unitCurvature.Name}",
- $"{GeometryNames.StrainTrdName}"
- };
- }
-
}
}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs
new file mode 100644
index 0000000..f527fcc
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs
@@ -0,0 +1,102 @@
+using StructureHelper.Infrastructure.UI.DataContexts;
+using StructureHelper.Services.ResultViewers;
+using StructureHelper.Windows.Forces;
+using StructureHelper.Windows.Graphs;
+using StructureHelper.Windows.ViewModels.Errors;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models;
+using StructureHelperCommon.Models.Parameters;
+using StructureHelperCommon.Models.Shapes;
+using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ public class ShowValuePointDiagramLogic : ILongProcessLogic
+ {
+ private ArrayParameter arrayParameter;
+ private IEnumerable tupleList;
+ private IEnumerable ndmPrimitives;
+ private List validTupleList;
+ private List<(PrimitiveBase PrimitiveBase, List>)> valuePoints;
+ private List resultFuncList;
+
+ public ForceCalculator Calculator { get; set; }
+ public PointPrimitiveLogic PrimitiveLogic { get; set; }
+ public ValueDelegatesLogic ValueDelegatesLogic { get; set; }
+
+ public int StepCount => throw new NotImplementedException();
+
+ public Action SetProgress { get; set; }
+ public bool Result { get; set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public ShowValuePointDiagramLogic(IEnumerable tupleList, IEnumerable ndmPrimitives)
+ {
+ this.tupleList = tupleList;
+ this.ndmPrimitives = ndmPrimitives;
+ validTupleList = this.tupleList.Where(x => x.IsValid == true).ToList();
+ valuePoints = new List<(PrimitiveBase PrimitiveBase, List>)>();
+ foreach (var item in PrimitiveLogic.Collection.CollectionItems)
+ {
+ var pointsCount = item.Item.ValuePoints.SelectedCount;
+ if (pointsCount > 0)
+ {
+ var points = item.Item.ValuePoints.SelectedItems.ToList();
+ var primitive = item.Item.PrimitiveBase;
+ valuePoints.Add((primitive, points));
+ }
+ }
+ }
+ public void ShowWindow()
+ {
+ SafetyProcessor.RunSafeProcess(() =>
+ {
+ var series = new Series(arrayParameter)
+ {
+ Name = "Forces and curvatures"
+ };
+ var vm = new GraphViewModel(new List()
+ {
+ series
+ });
+ var wnd = new GraphView(vm);
+ wnd.ShowDialog();
+ }, ErrorStrings.ErrorDuring("building chart"));
+ }
+
+ public void WorkerDoWork(object sender, DoWorkEventArgs e)
+ {
+ Show();
+ Result = true;
+ }
+
+ public void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
+ {
+ //Nothing to do
+ }
+
+ public void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
+ {
+ //Nothing to do
+ }
+
+ private void Show()
+ {
+
+ }
+
+ private List GetColumnNames()
+ {
+ var columnNames = LabelsFactory.GetCommonLabels();
+
+ return columnNames;
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml
index 3d1cbee..4b48b33 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml
@@ -10,17 +10,20 @@
-
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs
index 5062bfe..cac1378 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs
@@ -1,6 +1,7 @@
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using StructureHelper.Infrastructure;
+using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Services.Exports;
using StructureHelper.Services.Reports;
using StructureHelper.Services.Reports.CalculationReports;
@@ -12,7 +13,6 @@ using StructureHelper.Windows.Forces;
using StructureHelper.Windows.PrimitivePropertiesWindow;
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using StructureHelper.Windows.ViewModels.Errors;
-using StructureHelper.Windows.ViewModels.PrimitiveProperties;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
@@ -22,7 +22,6 @@ using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Forces;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
-using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Analyses.Geometry;
using StructureHelperLogics.NdmCalculations.Primitives;
@@ -54,17 +53,18 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public ForcesTupleResult SelectedResult { get; set; }
- private ICommand showIsoFieldCommand;
- private ICommand exportToCSVCommand;
- private ICommand interpolateCommand;
- private ICommand setPrestrainCommand;
- private ICommand showAnchorageCommand;
- private ICommand showGeometryResultCommand;
- private ICommand showGraphsCommand;
- private ICommand showCrackResult;
- private ICommand showCrackGraphsCommand;
- private RelayCommand showCrackWidthResult;
- private ICommand showInteractionDiagramCommand;
+ private ICommand? showIsoFieldCommand;
+ private ICommand? exportToCSVCommand;
+ private ICommand? interpolateCommand;
+ private ICommand? setPrestrainCommand;
+ private ICommand? showAnchorageCommand;
+ private ICommand? showGeometryResultCommand;
+ private ICommand? showGraphsCommand;
+ private ICommand? showCrackResult;
+ private ICommand? showCrackGraphsCommand;
+ private ICommand? showCrackWidthResult;
+ private ICommand? showInteractionDiagramCommand;
+ private ICommand? graphValuepointsCommand;
public IForcesResults ForcesResults
{
@@ -157,7 +157,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples);
if (wndTuples.DialogResult != true) return;
- var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.Result);
+ var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.ForceInterpolationViewModel.Result);
showProgressLogic = new(interpolationLogic)
{
WindowTitle = "Interpolate forces"
@@ -176,8 +176,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
};
showProgressLogic.Show();
}
- }, o => SelectedResult != null && SelectedResult.IsValid
- );
+ }, o => SelectedResult != null);
}
public ICommand ShowCrackGraphsCommand
{
@@ -188,7 +187,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples);
if (wndTuples.DialogResult != true) return;
- var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.Result);
+ var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.ForceInterpolationViewModel.Result);
showProgressLogic = new(interpolationLogic)
{
WindowTitle = "Interpolate forces"
@@ -261,13 +260,58 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples);
if (wndTuples.DialogResult != true) return;
- var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.Result);
+ var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.ForceInterpolationViewModel.Result);
progressLogic = interpolationLogic;
showProgressLogic = new(interpolationLogic);
showProgressLogic.ShowResult = ShowInterpolationProgressDialog;
showProgressLogic.Show();
}
+ public ICommand GraphValuePointsCommand
+ {
+ get
+ {
+ return graphValuepointsCommand ??
+ (graphValuepointsCommand = new RelayCommand(o =>
+ {
+ InterpolateValuePoints();
+ }, o => SelectedResult != null));
+ }
+ }
+
+ private void InterpolateValuePoints()
+ {
+ if (SelectedResult is null)
+ {
+ throw new StructureHelperException(ErrorStrings.NullReference + ": Nothing is selected");
+ }
+ var tuple = SelectedResult.DesignForceTuple ?? throw new StructureHelperException(ErrorStrings.NullReference + ": Design force combination");
+ var inputData = new ValuePointsInterpolationInputData()
+ {
+ FinishDesignForce = tuple.Clone() as IDesignForceTuple,
+ LimitState = tuple.LimitState,
+ CalcTerm = tuple.CalcTerm,
+ };
+ inputData.PrimitiveBases.AddRange(PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(ndmPrimitives));
+ var viewModel = new ValuePointsInterpolateViewModel(inputData);
+ var wnd = new ValuePointsInterpolateView(viewModel);
+ wnd.ShowDialog();
+ if (wnd.DialogResult != true) { return; }
+ var interpolationLogic = new InterpolationProgressLogic(forceCalculator, viewModel.ForceInterpolationViewModel.Result);
+ ShowValuePointDiagramLogic pointGraphLogic = new(ForcesResults.ForcesResultList, ndmPrimitives)
+ {
+ Calculator = interpolationLogic.InterpolateCalculator,
+ PrimitiveLogic = viewModel.PrimitiveLogic,
+ ValueDelegatesLogic = viewModel.ValueDelegatesLogic
+ };
+ progressLogic = interpolationLogic;
+ showProgressLogic = new(interpolationLogic)
+ {
+ ShowResult = pointGraphLogic.ShowWindow
+ };
+ showProgressLogic.Show();
+ }
+
private void ShowInterpolationWindow(out InterpolateTuplesViewModel interploateTuplesViewModel, out InterpolateTuplesView wndTuples)
{
IDesignForceTuple finishDesignTuple = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple;
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs
index 4234dda..db1f181 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs
@@ -157,6 +157,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
var factor = GetFactor(SurroundData.ConvertLogicEntity.ZForceType);
SurroundData.ConstZ = value / factor;
+ SurroundData.ConvertLogicEntity.ConstDirectionValue = SurroundData.ConstZ;
OnPropertyChanged(nameof(ConstZ));
}
}
diff --git a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs
index e4ea30a..cc5339f 100644
--- a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs
+++ b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs
@@ -1,16 +1,11 @@
using StructureHelper.Infrastructure;
-using StructureHelper.Windows.AddMaterialWindow;
using StructureHelper.Windows.ViewModels.Errors;
-using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Models.Loggers;
+using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Runtime.ConstrainedExecution;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
@@ -21,31 +16,35 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
{
public class TraceDocumentVM : ViewModelBase
{
- IEnumerable loggerEntries;
- IEnumerable selectedLoggerEntries;
- FlowDocument document;
+ const double tabFactor = 500d;
+ private readonly IEnumerable loggerEntries;
+ private IEnumerable selectedLoggerEntries;
+ private FlowDocument document;
private ICommand rebuildCommand;
private ICommand printDocumentCommand;
- private int maxPriority;
+ private int priorityLimit;
private int tabGap;
public FlowDocumentReader DocumentReader { get; set; }
- public int MaxPriority
+ public int PriorityLimit
{
- get => maxPriority; set
+ get => priorityLimit; set
{
- var oldValue = maxPriority;
+ var oldValue = priorityLimit;
try
{
- maxPriority = Math.Max(value, 0);
- OnPropertyChanged(nameof(MaxPriority));
+ priorityLimit = Math.Max(value, 0);
+ OnPropertyChanged(nameof(PriorityLimit));
}
catch (Exception)
{
- maxPriority = oldValue;
+ priorityLimit = oldValue;
}
}
}
+
+ public int MaxPriority => loggerEntries.Max(x => x.Priority);
+
public int TabGap
{
get => tabGap; set
@@ -65,8 +64,8 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
public TraceDocumentVM(IEnumerable loggerEntries)
{
this.loggerEntries = loggerEntries;
- maxPriority = 350;
- tabGap = 50;
+ priorityLimit = 350;
+ tabGap = 30;
}
public ICommand RebuildCommand =>
@@ -81,40 +80,82 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
SafetyProcessor.RunSafeProcess(DocumentReader.Print, "Error of printing document");
});
+
+ public void Prepare()
+ {
+ document = new();
+ selectedLoggerEntries = loggerEntries.Where(x => x.Priority <= PriorityLimit);
+ var blocks = selectedLoggerEntries.Select(x => GetBlockByEntry(x));
+ document.Blocks.AddRange(blocks);
+ }
+ public void ShowPrepared()
+ {
+ DocumentReader.Document = document;
+ }
public void Show()
{
Prepare();
ShowPrepared();
}
- public void Prepare()
+ private Block GetBlockByEntry(ITraceLoggerEntry traceEntry)
{
- document = new();
- selectedLoggerEntries = loggerEntries.Where(x => x.Priority <= MaxPriority);
- foreach (var item in selectedLoggerEntries)
+ Block block;
+ if (traceEntry is StringLogEntry stringEntry)
{
- ProcessLoggerEntries(item);
+ block = GetBlockByStringEntry(stringEntry);
}
- }
-
- private void ProcessLoggerEntries(ITraceLoggerEntry item)
- {
- if (item is StringLoggerEntry stringEntry)
+ else if (traceEntry is TableLogEntry tableEntry)
{
- ProcessStringEntry(stringEntry);
- }
- else if (item is TableLoggerEntry tableEntry)
- {
- ProcessTableEntry(tableEntry);
+ block = GetBlockByTableEntry(tableEntry);
}
else
{
- throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(item));
+ throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(traceEntry));
}
+ block.Margin = new Thickness(traceEntry.Priority / tabFactor * tabGap, 7, 0, 7);
+ return block;
}
- private void ProcessTableEntry(TableLoggerEntry tableEntry)
+ private Block GetBlockByStringEntry(StringLogEntry stringEntry)
{
+ var paragraph = new Paragraph(new Run(stringEntry.Message));
+ if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLogStatuses.Fatal))
+ {
+ paragraph.FontSize = 14;
+ paragraph.Background = Brushes.Red;
+ paragraph.Foreground = Brushes.Black;
+ paragraph.FontStyle = FontStyles.Italic;
+ }
+ else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLogStatuses.Error))
+ {
+ paragraph.FontSize = 14;
+ paragraph.Background = Brushes.Pink;
+ paragraph.Foreground = Brushes.Black;
+ }
+ else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLogStatuses.Warning))
+ {
+ paragraph.FontSize = 14;
+ paragraph.Background = Brushes.Yellow;
+ paragraph.Foreground = Brushes.Black;
+ }
+ else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLogStatuses.Debug))
+ {
+ paragraph.FontSize = 12;
+ paragraph.Foreground = Brushes.Black;
+ }
+ else
+ {
+ paragraph.FontSize = 10;
+ paragraph.Foreground = Brushes.Gray;
+ }
+
+ return paragraph;
+ }
+
+ private Table GetBlockByTableEntry(TableLogEntry tableEntry)
+ {
+ const int columnWidth = 150;
var rows = tableEntry.Table.GetAllRows();
int rowCount = rows.Count();
int columnCount = tableEntry.Table.RowSize;
@@ -122,96 +163,53 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
for (int x = 0; x < columnCount; x++)
{
var tableColumn = new TableColumn();
- tableColumn.Width = new GridLength(150);
+ tableColumn.Width = new GridLength(columnWidth);
table.Columns.Add(tableColumn);
}
foreach (var row in rows)
{
- var newRow = new TableRow();
- foreach (var cell in row.Elements)
- {
- TableCell tableCell;
- if (cell is null)
- {
- tableCell = new TableCell(new Paragraph(new Run(string.Empty)));
- }
- else
- {
- if (cell.Value is StringLoggerEntry stringEntry)
- {
- tableCell = new TableCell(GetParagraphByStringEntry(stringEntry));
- tableCell.ColumnSpan = cell.ColumnSpan;
- if (cell.Role == CellRole.Regular)
- {
- tableCell.TextAlignment = TextAlignment.Left;
- tableCell.Background = Brushes.LightYellow;
- }
- else if (cell.Role == CellRole.Header)
- {
- tableCell.TextAlignment = TextAlignment.Center;
- tableCell.Background = Brushes.AliceBlue;
- }
- }
- else
- {
- throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(cell));
- }
- }
- newRow.Cells.Add(tableCell);
- }
+ TableRow newRow = GetTableRow(row);
table.RowGroups.Add(new TableRowGroup());
table.RowGroups[0].Rows.Add(newRow);
}
- document.Blocks.Add(table);
+ return table;
}
- private void ProcessStringEntry(StringLoggerEntry stringEntry)
+ private TableRow GetTableRow(IShTableRow row)
{
- var paragraph = GetParagraphByStringEntry(stringEntry);
- document.Blocks.Add(paragraph);
+ var newRow = new TableRow();
+ foreach (var cell in row.Elements)
+ {
+ TableCell tableCell;
+ if (cell is null)
+ {
+ tableCell = new TableCell(new Paragraph(new Run(string.Empty)));
+ }
+ else
+ {
+ var cellvalue = GetBlockByEntry(cell.Value);
+ tableCell = new TableCell(cellvalue);
+ AdjustTableCell(cell, tableCell);
+ }
+ newRow.Cells.Add(tableCell);
+ }
+
+ return newRow;
}
- private Paragraph GetParagraphByStringEntry(StringLoggerEntry stringEntry)
+ private static void AdjustTableCell(IShTableCell? cell, TableCell tableCell)
{
- var paragraph = new Paragraph(new Run(stringEntry.Message));
- paragraph.Margin = new Thickness(stringEntry.Priority / tabGap);
- if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Fatal))
+ tableCell.ColumnSpan = cell.ColumnSpan;
+ if (cell.Role == CellRole.Regular)
{
- paragraph.FontSize = 14;
- paragraph.Background = Brushes.Red;
- paragraph.Foreground = Brushes.Black;
- paragraph.FontStyle = FontStyles.Italic;
+ tableCell.TextAlignment = TextAlignment.Left;
+ tableCell.Background = Brushes.LightYellow;
}
- else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Error))
+ else if (cell.Role == CellRole.Header)
{
- paragraph.FontSize = 14;
- paragraph.Background = Brushes.Pink;
- paragraph.Foreground = Brushes.Black;
+ tableCell.TextAlignment = TextAlignment.Center;
+ tableCell.Background = Brushes.AliceBlue;
}
- else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Warning))
- {
- paragraph.FontSize = 14;
- paragraph.Background = Brushes.Yellow;
- paragraph.Foreground = Brushes.Black;
- }
- else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Debug))
- {
- paragraph.FontSize = 12;
- paragraph.Foreground = Brushes.Black;
- }
- else
- {
- paragraph.FontSize = 8;
- paragraph.Foreground = Brushes.Gray;
-
- }
-
- return paragraph;
- }
-
- public void ShowPrepared()
- {
- DocumentReader.Document = document;
}
}
}
diff --git a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml
index c1c5a39..5d8f958 100644
--- a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml
+++ b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml
@@ -10,7 +10,7 @@
-
+
@@ -18,7 +18,13 @@
-
+
+
+
+
+
+
+
diff --git a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml.cs b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml.cs
index 497e819..655eb25 100644
--- a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml.cs
+++ b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml.cs
@@ -1,17 +1,6 @@
-using StructureHelperCommon.Models.Loggers;
-using System;
+using StructureHelperCommon.Models;
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;
namespace StructureHelper.Windows.CalculationWindows.ProgressViews
{
diff --git a/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml b/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml
new file mode 100644
index 0000000..21362df
--- /dev/null
+++ b/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml.cs b/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml.cs
new file mode 100644
index 0000000..0a95c0c
--- /dev/null
+++ b/StructureHelper/Windows/Forces/ForceInterpolationControl.xaml.cs
@@ -0,0 +1,67 @@
+using StructureHelper.Windows.UserControls;
+using StructureHelper.Windows.ViewModels.Materials;
+using StructureHelperCommon.Services.Forces;
+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.Forces
+{
+ ///
+ /// Логика взаимодействия для ForceInterpolationControl.xaml
+ ///
+ public partial class ForceInterpolationControl : UserControl
+ {
+ private ForceTupleInterpolationViewModel? properties;
+
+ public ForceTupleInterpolationViewModel? Properties
+ {
+ get => properties; set
+ {
+ properties = value;
+ DataContext = Properties;
+ }
+ }
+ public ForceInterpolationControl()
+ {
+ InitializeComponent();
+ }
+
+ private void StartValueChanged(object sender, EventArgs e)
+ {
+ var obj = (MultiplyDouble)sender;
+ var tmpTuple = ForceTupleService.MultiplyTuples(Properties.StartDesignForce.ForceTuple, obj.DoubleFactor);
+ ForceTupleService.CopyProperties(tmpTuple, Properties.StartDesignForce.ForceTuple, 1d);
+ Properties.RefreshStartTuple();
+ }
+
+ private void FinishValueChanged(object sender, EventArgs e)
+ {
+ var obj = (MultiplyDouble)sender;
+ var tmpTuple = ForceTupleService.MultiplyTuples(Properties.FinishDesignForce.ForceTuple, obj.DoubleFactor);
+ ForceTupleService.CopyProperties(tmpTuple, Properties.FinishDesignForce.ForceTuple, 1d);
+ Properties.RefreshFinishTuple();
+ }
+
+ private void StepCountValueChanged(object sender, EventArgs e)
+ {
+ var obj = (MultiplyDouble)sender;
+ var factor = obj.DoubleFactor;
+ if (factor > 0d)
+ {
+ Properties.StepCount = Convert.ToInt32(Properties.StepCount * factor);
+ }
+ }
+ }
+}
diff --git a/StructureHelper/Windows/Forces/ForceTupleControl.xaml b/StructureHelper/Windows/Forces/ForceTupleControl.xaml
deleted file mode 100644
index 6166d4d..0000000
--- a/StructureHelper/Windows/Forces/ForceTupleControl.xaml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml b/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml
new file mode 100644
index 0000000..c106140
--- /dev/null
+++ b/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/StructureHelper/Windows/Forces/ForceTupleControl.xaml.cs b/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml.cs
similarity index 76%
rename from StructureHelper/Windows/Forces/ForceTupleControl.xaml.cs
rename to StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml.cs
index 446b197..ecc0032 100644
--- a/StructureHelper/Windows/Forces/ForceTupleControl.xaml.cs
+++ b/StructureHelper/Windows/Forces/ForceTupleInterpolationControl.xaml.cs
@@ -18,9 +18,10 @@ namespace StructureHelper.Windows.Forces
///
/// Логика взаимодействия для ForceTupleControl.xaml
///
- public partial class ForceTupleControl : UserControl
+ public partial class ForceTupleInterpolationControl : UserControl
{
- public ForceTupleControl()
+ public ForceTupleInterpolationViewModel? Properties { get; set; }
+ public ForceTupleInterpolationControl()
{
InitializeComponent();
}
diff --git a/StructureHelper/Windows/Forces/ForceTupleInterpolationViewModel.cs b/StructureHelper/Windows/Forces/ForceTupleInterpolationViewModel.cs
new file mode 100644
index 0000000..6259e1e
--- /dev/null
+++ b/StructureHelper/Windows/Forces/ForceTupleInterpolationViewModel.cs
@@ -0,0 +1,212 @@
+using StructureHelper.Infrastructure;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Models.Forces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace StructureHelper.Windows.Forces
+{
+ public class ForceTupleInterpolationViewModel : ViewModelBase
+ {
+ private RelayCommand invertForcesCommand;
+ private RelayCommand copyToStartCommand;
+ private RelayCommand copyToFinishCommand;
+ private int stepCount;
+ private IDesignForceTuple startDesignForce;
+ private IDesignForceTuple finishDesignForce;
+
+ public IDesignForceTuple StartDesignForce
+ {
+ get => startDesignForce; set
+ {
+ startDesignForce = value;
+ }
+ }
+ public IDesignForceTuple FinishDesignForce
+ {
+ get => finishDesignForce; set
+ {
+ finishDesignForce = value;
+ }
+ }
+
+ public double StartFactor { get; set; }
+ public double FinishFactor { get; set; }
+ public double StepCountFactor { get; set; }
+
+ public bool StepCountVisible { get; set; }
+ public double StartMx
+ {
+ get => StartDesignForce.ForceTuple.Mx;
+ set
+ {
+ StartDesignForce.ForceTuple.Mx = value;
+ OnPropertyChanged(nameof(StartMx));
+ }
+ }
+ public double StartMy
+ {
+ get => StartDesignForce.ForceTuple.My;
+ set
+ {
+ StartDesignForce.ForceTuple.My = value;
+ OnPropertyChanged(nameof(StartMy));
+ }
+ }
+ public double StartNz
+ {
+ get => StartDesignForce.ForceTuple.Nz;
+ set
+ {
+ StartDesignForce.ForceTuple.Nz = value;
+ OnPropertyChanged(nameof(StartNz));
+ }
+ }
+ public double FinishMx
+ {
+ get => FinishDesignForce.ForceTuple.Mx;
+ set
+ {
+ FinishDesignForce.ForceTuple.Mx = value;
+ OnPropertyChanged(nameof(FinishMx));
+ }
+ }
+ public double FinishMy
+ {
+ get => FinishDesignForce.ForceTuple.My;
+ set
+ {
+ FinishDesignForce.ForceTuple.My = value;
+ OnPropertyChanged(nameof(FinishMy));
+ }
+ }
+ public double FinishNz
+ {
+ get => FinishDesignForce.ForceTuple.Nz;
+ set
+ {
+ FinishDesignForce.ForceTuple.Nz = value;
+ OnPropertyChanged(nameof(FinishNz));
+ }
+ }
+ public int StepCount
+ {
+ get => stepCount; set
+ {
+ stepCount = value;
+ OnPropertyChanged(nameof(StepCount));
+ }
+ }
+
+ public ICommand InvertForcesCommand
+ {
+ get => invertForcesCommand ??= new RelayCommand(o => InvertForces());
+ }
+ public ICommand CopyToStartCommand
+ {
+ get => copyToStartCommand ??= new RelayCommand(o => CopyFinishToStart());
+ }
+ public ICommand CopyToFinishCommand
+ {
+ get => copyToFinishCommand ??= new RelayCommand(o => CopyStartToFinish());
+ }
+ public InterpolateTuplesResult Result
+ {
+ get => new()
+ {
+ StartTuple = StartDesignForce,
+ FinishTuple = FinishDesignForce,
+ StepCount = StepCount
+ };
+ }
+
+ private void InvertForces()
+ {
+ var tmpForce = StartDesignForce.Clone() as IDesignForceTuple;
+ StartDesignForce = FinishDesignForce;
+ FinishDesignForce = tmpForce;
+ StepCountVisible = true;
+ RefreshStartTuple();
+ RefreshFinishTuple();
+ }
+
+ private void CopyStartToFinish()
+ {
+ FinishDesignForce = StartDesignForce.Clone() as IDesignForceTuple;
+ RefreshFinishTuple();
+ }
+
+ private void CopyFinishToStart()
+ {
+ StartDesignForce = FinishDesignForce.Clone() as IDesignForceTuple;
+ RefreshStartTuple();
+ }
+
+ public void RefreshFinishTuple()
+ {
+ OnPropertyChanged(nameof(FinishDesignForce));
+ OnPropertyChanged(nameof(FinishMx));
+ OnPropertyChanged(nameof(FinishMy));
+ OnPropertyChanged(nameof(FinishNz));
+ }
+
+ public void RefreshStartTuple()
+ {
+ OnPropertyChanged(nameof(StartDesignForce));
+ OnPropertyChanged(nameof(StartMx));
+ OnPropertyChanged(nameof(StartMy));
+ OnPropertyChanged(nameof(StartNz));
+ }
+
+ public ForceTupleInterpolationViewModel(IDesignForceTuple finishDesignForce, IDesignForceTuple startDesignForce = null, int stepCount = 100)
+ {
+ if (startDesignForce != null)
+ {
+ CheckDesignForces(finishDesignForce, startDesignForce);
+ StartDesignForce = startDesignForce;
+ }
+ else
+ {
+ GetNewDesignForce(finishDesignForce);
+ }
+ FinishDesignForce = finishDesignForce;
+ StepCount = stepCount;
+ StepCountVisible = true;
+ }
+ public ForceTupleInterpolationViewModel()
+ {
+
+ }
+
+ private static void CheckDesignForces(IDesignForceTuple finishDesignForce, IDesignForceTuple startDesignForce)
+ {
+ if (startDesignForce.LimitState != finishDesignForce.LimitState)
+ {
+ throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid);
+ }
+ if (startDesignForce.CalcTerm != finishDesignForce.CalcTerm)
+ {
+ throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid);
+ }
+ }
+
+ private void GetNewDesignForce(IDesignForceTuple finishDesignForce)
+ {
+ StartDesignForce = new DesignForceTuple()
+ {
+ CalcTerm = finishDesignForce.CalcTerm,
+ LimitState = finishDesignForce.LimitState,
+ ForceTuple = new ForceTuple()
+ {
+ Mx = 0,
+ My = 0,
+ Nz = 0
+ },
+ };
+ }
+ }
+}
diff --git a/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml b/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml
index 5823dfc..911b889 100644
--- a/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml
+++ b/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml
@@ -8,7 +8,7 @@
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
d:DataContext="{d:DesignInstance local:InterpolateTuplesViewModel}"
mc:Ignorable="d"
- Title="Interpolate Combinations" Height="200" Width="460" MinHeight="180" MinWidth="460" WindowStartupLocation="CenterScreen">
+ Title="Interpolate Combinations" Height="250" Width="460" MinHeight="250" MinWidth="460" WindowStartupLocation="CenterScreen">