Add field 2d viewer

This commit is contained in:
Evgeny Redikultsev
2025-12-27 21:59:20 +05:00
parent d81b72d420
commit 3b95fab0b2
28 changed files with 726 additions and 29 deletions

View File

@@ -2,12 +2,49 @@
using System.Collections.Generic;
using System.Windows.Media;
using System.Text;
using System.Windows;
namespace FieldVisualizer.Entities.ColorMaps
{
public class ColorMap : IColorMap
{
private LinearGradientBrush _gradientBrush;
public string Name { get; set; }
public List<Color> Colors { get; set; }
public LinearGradientBrush GradientBrush
{
get
{
if (_gradientBrush == null)
{
_gradientBrush = CreateGradientBrush();
_gradientBrush.Freeze(); // very important for performance
}
return _gradientBrush;
}
}
protected virtual LinearGradientBrush CreateGradientBrush()
{
var brush = new LinearGradientBrush
{
StartPoint = new Point(0, 0),
EndPoint = new Point(1, 0) // horizontal
};
int count = Colors.Count;
for (int i = 0; i < count; i++)
{
brush.GradientStops.Add(
new GradientStop(
Colors[i],
(double)i / (count - 1)));
}
return brush;
}
}
}

View File

@@ -32,7 +32,7 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
{
ColorMap colorMap = new()
{
Name = "LiraSpectrumColorMap"
Name = "Lira Style Spectrum"
};
List<Color> colors = new();
byte Alpha = 0xff;
@@ -55,7 +55,7 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
{
ColorMap colorMap = new()
{
Name = "FullSpectrumColorMap"
Name = "Full Spectrum"
};
List<Color> colors = new List<Color>();
byte Alpha = 0xff;
@@ -78,7 +78,7 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
private static IColorMap GetRedToWhite()
{
ColorMap colorMap = new ColorMap();
colorMap.Name = "FullSpectrumColorMap";
colorMap.Name = "Red To White Spectrum";
List<Color> colors = new List<Color>();
byte Alpha = 0xff;
colors.AddRange(new Color[]{
@@ -91,7 +91,7 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
private static IColorMap GetRedToBlue()
{
ColorMap colorMap = new ColorMap();
colorMap.Name = "FullSpectrumColorMap";
colorMap.Name = "Red To Blue Spectrum";
List<Color> colors = new List<Color>();
byte Alpha = 0xff;
colors.AddRange(new Color[]{
@@ -104,7 +104,7 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
private static IColorMap GetBlueToWhite()
{
ColorMap colorMap = new ColorMap();
colorMap.Name = "FullSpectrumColorMap";
colorMap.Name = "Blue To White Spectrum";
List<Color> colors = new List<Color>();
byte Alpha = 0xff;
colors.AddRange(new Color[]{

View File

@@ -9,5 +9,6 @@ namespace FieldVisualizer.Entities.ColorMaps
{
string Name { get;}
List<Color> Colors { get; }
LinearGradientBrush GradientBrush { get; }
}
}

View File

@@ -9,7 +9,6 @@ using FieldVisualizer.Services.ValueRanges;
using FieldVisualizer.Windows.UserControls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows.Controls;
@@ -249,7 +248,10 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
}
private bool PrimitiveValidation()
{
if (PrimitiveSet == null || PrimitiveSet.ValuePrimitives.Count() == 0) { return false; }
if (PrimitiveSet == null || PrimitiveSet.ValuePrimitives.Count() == 0)
{
return false;
}
else return true;
}
private void SetColor()

View File

@@ -32,9 +32,8 @@
<ScrollViewer Name="WorkPlaneViewer" HorizontalScrollBarVisibility="Visible" SizeChanged="WorkPlaneViewer_SizeChanged">
<ScrollViewer.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black"/>
<GradientStop Color="White" Offset="1"/>
<GradientStop Color="#FF00EDFF" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</ScrollViewer.Background>
<Viewbox Name="WorkPlaneBox" Margin="10">
@@ -102,7 +101,6 @@
</StackPanel>
</Expander>
</StackPanel>
</ScrollViewer>

View File

@@ -23,7 +23,14 @@ namespace FieldVisualizer.Windows.UserControls
viewModel.Legend = LegendViewer;
}
public IPrimitiveSet PrimitiveSet { get => viewModel.PrimitiveSet; set { viewModel.PrimitiveSet = value; } }
public IPrimitiveSet PrimitiveSet
{
get => viewModel.PrimitiveSet;
set
{
viewModel.PrimitiveSet = value;
}
}
internal void Refresh()
{

View File

@@ -9,7 +9,7 @@
<Grid x:Name="grid">
<StackPanel>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#FF868686"></TextBlock>
<ListBox Name="LegendBox" ItemsSource="{Binding}">
<ListBox Name="LegendBox" ItemsSource="{Binding ColorRanges, RelativeSource={RelativeSource AncestorType=UserControl}}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="30" Width="190" VerticalAlignment="Top" Background="{DynamicResource {x:Static SystemColors.MenuBarBrushKey}}">
@@ -44,6 +44,5 @@
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
</UserControl>

View File

@@ -1,4 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>

View File

@@ -0,0 +1,21 @@
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.States;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class SelectedPrimitiveSet
{
public List<INdmPrimitive>? AllPrimitives { get; set; }
public List<INdmPrimitive>? SelectedPrimitives { get; set; }
public List<INdm> Ndms { get; internal set; }
public IStateCalcTermPair? StateCalcTermPair { get; set; }
public IStrainMatrix StrainMatrix { get; set; }
}
}

View File

@@ -879,4 +879,32 @@
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="Zoom">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Ellipse Canvas.Top="5" Canvas.Left="5" Width="16" Height="16" Stroke="Black"/>
<Line X1="18" Y1="18" X2="28" Y2="28" Stroke="Black" StrokeThickness="2"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="ZoomIn">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<ContentControl ContentTemplate="{StaticResource Zoom}"/>
<Line X1="13" Y1="8" X2="13" Y2="18" Stroke="Black" StrokeThickness="2"/>
<Line X1="8" Y1="13" X2="18" Y2="13" Stroke="Black" StrokeThickness="2"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="ZoomOut">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<ContentControl ContentTemplate="{StaticResource Zoom}"/>
<Line X1="8" Y1="13" X2="18" Y2="13" Stroke="Black" StrokeThickness="2"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
</ResourceDictionary>

View File

@@ -0,0 +1,34 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
namespace StructureHelper.Services.Reports.CalculationReports
{
public class IsoField2DReport : IIsoFieldReport
{
private SelectedPrimitiveSet primitiveSet;
private IsoField2DViewerViewModel viewModel;
private IsoField2DViewerView view;
public IsoField2DReport(SelectedPrimitiveSet primitiveSet)
{
this.primitiveSet = primitiveSet;
}
public void Prepare()
{
viewModel = new(primitiveSet);
view = new(viewModel);
}
public void Show()
{
Prepare();
ShowPrepared();
}
public void ShowPrepared()
{
view.ShowDialog();
}
}
}

View File

@@ -72,6 +72,9 @@
<Compile Update="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\ForceResultLogic\LimitCurveDataView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\IsoField2DViewerView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\IsoField3DViewerView.xaml.cs">
<SubType>Code</SubType>
</Compile>
@@ -162,6 +165,12 @@
<Compile Update="Windows\UserControls\Forces\FactoredCombination.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\UserControls\IsoFieldContours.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\UserControls\IsoFieldVerticalLegend.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\UserControls\ListOfFileControl.xaml.cs">
<SubType>Code</SubType>
</Compile>

View File

@@ -0,0 +1,43 @@
using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.ColorMaps.Factories;
using StructureHelper.Infrastructure;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Text;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
public class ColorMapViewModel : ViewModelBase
{
private IsoField2DViewerViewModel isoField2DViewerViewModel;
private IColorMap selectedColorMap;
public List<IColorMap> ColorMaps { get; set; }
public IColorMap SelectedColorMap
{
get => selectedColorMap;
set
{
selectedColorMap = value;
Refresh();
}
}
public ColorMapViewModel(IsoField2DViewerViewModel isoField2DViewerViewModel)
{
this.isoField2DViewerViewModel = isoField2DViewerViewModel;
ColorMaps = [];
ColorMaps.Add(ColorMapFactory.GetColorMap(ColorMapsTypes.LiraSpectrum));
ColorMaps.Add(ColorMapFactory.GetColorMap(ColorMapsTypes.FullSpectrum));
ColorMaps.Add(ColorMapFactory.GetColorMap(ColorMapsTypes.RedToWhite));
ColorMaps.Add(ColorMapFactory.GetColorMap(ColorMapsTypes.RedToBlue));
ColorMaps.Add(ColorMapFactory.GetColorMap(ColorMapsTypes.BlueToWhite));
SelectedColorMap = ColorMaps[0];
}
private void Refresh()
{
isoField2DViewerViewModel.Refresh();
}
}
}

View File

@@ -0,0 +1,14 @@
using FieldVisualizer.Entities.ColorMaps;
using StructureHelper.Infrastructure;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
public class ContourLegendViewModel : ViewModelBase
{
public ObservableCollection<IValueColorRange>? ValueColorRanges { get; set; } = new();
}
}

View File

@@ -0,0 +1,61 @@
using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.Values;
using FieldVisualizer.Services.ColorServices;
using FieldVisualizer.Services.ValueRanges;
using StructureHelper.Infrastructure;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Text;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
public class ContoursRangeViewModel : ViewModelBase
{
const int RangeNumber = 16;
private double userMinValue;
private double userMaxValue;
public IColorMap? ColorMap { get; set; }
public IValueRange? ValueRange { get; set; } = new ValueRange();
public bool SetMinValue { get; set; } = false;
public double UserMinValue
{
get => userMinValue;
set
{
userMinValue = value;
Refresh();
}
}
public bool SetMaxValue { get; set; } = false;
public double UserMaxValue
{
get => userMaxValue;
set
{
userMaxValue = value;
Refresh();
}
}
public ContourLegendViewModel ContourLegend { get; set; } = new();
public ContoursRangeViewModel()
{
//Refresh();
}
public void Refresh()
{
var valueRanges = ValueRangeOperations.DivideValueRange(ValueRange, RangeNumber);
var valueColorRanges = ColorOperations.GetValueColorRanges(ValueRange, valueRanges, ColorMap);
ContourLegend.ValueColorRanges.Clear();
foreach (var valueRange in valueColorRanges)
{
ContourLegend.ValueColorRanges.Add(valueRange);
}
OnPropertyChanged(nameof(UserMinValue));
OnPropertyChanged(nameof(UserMaxValue));
}
}
}

View File

@@ -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;
@@ -461,10 +462,20 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
try
{
IStrainMatrix strainMatrix = SelectedResult.ForcesTupleResult.LoaderResults.ForceStrainPair.StrainMatrix;
var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ForceResultFuncFactory.GetResultFuncs());
isoFieldReport = new IsoFieldReport(primitiveSets);
isoFieldReport.Show();
SelectedPrimitiveSet selectedPrimitiveSet = new()
{
AllPrimitives = ndmPrimitives.ToList(),
SelectedPrimitives = selectedNdmPrimitives.ToList(),
StateCalcTermPair = SelectedResult.StateCalcTermPair,
Ndms = [.. ndms],
StrainMatrix = SelectedResult.ForcesTupleResult.LoaderResults.StrainMatrix
};
IsoField2DReport report = new(selectedPrimitiveSet);
report.Show();
//IStrainMatrix strainMatrix = SelectedResult.ForcesTupleResult.LoaderResults.ForceStrainPair.StrainMatrix;
//var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ForceResultFuncFactory.GetResultFuncs());
//isoFieldReport = new IsoFieldReport(primitiveSets);
//isoFieldReport.Show();
}
catch (Exception ex)
{

View File

@@ -0,0 +1,134 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.IsoField2DViewerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
d:DataContext="{d:DesignInstance local:IsoField2DViewerViewModel}"
mc:Ignorable="d"
Title="Iso Field Viewer" Height="800" Width="1200" MinHeight="450" MinWidth="800" WindowStartupLocation="CenterScreen">
<DockPanel>
<ToolBarTray DockPanel.Dock="Top">
<ToolBar>
<Button Style="{StaticResource ToolButton}"
Command="{Binding RebuildCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Rebuild image"
IconContent="{StaticResource Renew}"
DescriptionText="Rebuild current image"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{StaticResource Renew}"/>
</Viewbox>
</Button>
<Button Style="{StaticResource ToolButton}"
Command="{Binding RebuildCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Zoom In"
IconContent="{StaticResource ZoomIn}"
DescriptionText="Zooms work plane in"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{StaticResource ZoomIn}"/>
</Viewbox>
</Button>
<Button Style="{StaticResource ToolButton}"
Command="{Binding RebuildCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Zoom Out"
IconContent="{StaticResource ZoomOut}"
DescriptionText="Zooms work plane out"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{StaticResource ZoomOut}"/>
</Viewbox>
</Button>
<ComboBox DataContext="{Binding ColorMapViewModel}" Width="200" ItemsSource="{Binding ColorMaps}" SelectedItem="{Binding SelectedColorMap}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid Height="32">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Rectangle Margin="2" Stroke="DarkGray" Fill="{Binding GradientBrush}"/>
<TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="2" Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</ToolBar>
<ToolBar DataContext="{Binding SaveCopyViewModel}">
<Button Style="{DynamicResource ToolButton}" Command="{Binding CopyToClipboardCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Copy to clipboard"
IconContent="{StaticResource CopyToClipboard}"
DescriptionText="Copy chart to clipboard as image"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource CopyToClipboard}"/>
</Viewbox>
</Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding SaveAsImageCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Export to *.png"
IconContent="{StaticResource PngImage}"
DescriptionText="Export chart to *.png file"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource PngImage}"/>
</Viewbox>
</Button>
</ToolBar>
</ToolBarTray>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250"/>
<ColumnDefinition/>
<ColumnDefinition Width="auto" MinWidth="200"/>
</Grid.ColumnDefinitions>
<ListBox Name="SetsList" ItemsSource="{Binding PrimitiveSets}" SelectedValue="{Binding SelectedPrimitiveSet}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="{Binding Path=Name}" Width="270"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid Grid.Column="1">
<StackPanel Panel.ZIndex="1" DataContext="{Binding Title}">
<TextBlock Text="{Binding Title}" FontWeight="Bold"/>
<TextBlock Text="{Binding SubTitle}"/>
</StackPanel>
<ScrollViewer Name="WorkPlaneViewer" HorizontalScrollBarVisibility="Visible">
<ScrollViewer.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="LightGray" Offset="1"/>
</LinearGradientBrush>
</ScrollViewer.Background>
<Viewbox Name="WorkPlaneBox" Margin="10">
<Grid>
<Canvas x:Name="WorkPlaneCanvas">
</Canvas>
</Grid>
</Viewbox>
</ScrollViewer>
</Grid>
<TabControl Grid.Column="2">
<TabItem Header="Contours">
<local:IsoFieldContours ContourRange="{Binding ContourRange}"/>
</TabItem>
<TabItem Header="Summary">
</TabItem>
</TabControl>
</Grid>
</DockPanel>
</Window>

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
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.CalculatorsViews.ForceCalculatorViews
{
/// <summary>
/// Interaction logic for IsoField2DViewerView.xaml
/// </summary>
public partial class IsoField2DViewerView : Window
{
private IsoField2DViewerViewModel viewModel;
public IsoField2DViewerView(IsoField2DViewerViewModel viewModel)
{
InitializeComponent();
this.viewModel = viewModel;
this.DataContext = viewModel;
this.viewModel.Window = this;
}
}
}

View File

@@ -0,0 +1,52 @@
using FieldVisualizer.Entities.Values.Primitives;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Services.ResultViewers;
using System.Collections.Generic;
using System.Linq;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
public class IsoField2DViewerViewModel : ViewModelBase
{
private SelectedPrimitiveSet ndmPrimitiveSet;
public IsoField2DViewerView Window { get; internal set; }
public IsoFieldTitle Title { get; set; }
public IsoFieldSummary Summary { get; }
public List<IPrimitiveSet> PrimitiveSets { get; set; }
public IPrimitiveSet SelectedPrimitiveSet { get; set; }
public ColorMapViewModel ColorMapViewModel { get; set; }
public ContoursRangeViewModel ContourRange { get; set; } = new();
public IsoField2DViewerViewModel(SelectedPrimitiveSet ndmPrimitiveSet)
{
this.ndmPrimitiveSet = ndmPrimitiveSet;
SetValues(ndmPrimitiveSet);
ColorMapViewModel = new ColorMapViewModel(this);
SelectedPrimitiveSet = PrimitiveSets[0];
Refresh();
}
private void SetValues(SelectedPrimitiveSet ndmPrimitiveSet)
{
PrimitiveSets = ShowIsoFieldResult.GetPrimitiveSets(ndmPrimitiveSet.StrainMatrix, ndmPrimitiveSet.Ndms, ForceResultFuncFactory.GetResultFuncs());
}
public void Refresh()
{
if (SelectedPrimitiveSet is null) { return; }
Title = new(SelectedPrimitiveSet);
Title.Refresh();
OnPropertyChanged(nameof(Title));
if (ColorMapViewModel is null) { return; }
ContourRange.ColorMap = ColorMapViewModel.SelectedColorMap;
double minValue = SelectedPrimitiveSet.ValuePrimitives.Min(x => x.Value);
ContourRange.ValueRange.BottomValue = ContourRange.UserMinValue = minValue;
double maxValue = SelectedPrimitiveSet.ValuePrimitives.Max(x => x.Value);
ContourRange.ValueRange.TopValue = ContourRange.UserMinValue = maxValue;
ContourRange.Refresh();
OnPropertyChanged(nameof(ContourRange));
}
}
}

View File

@@ -0,0 +1,47 @@
using FieldVisualizer.Entities.Values.Primitives;
using StructureHelper.Infrastructure;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
public class IsoFieldSummary : ViewModelBase
{
private IPrimitiveSet primitiveSet;
public double AreaTotal { get; private set; }
public double AreaNeg { get; private set; }
public double AreaZero { get; private set; }
public double AreaPos { get; private set; }
public double SumTotal { get; private set; }
public double SumNeg { get; private set; }
public double SumPos { get; private set; }
public IsoFieldSummary(IPrimitiveSet primitiveSet)
{
this.primitiveSet = primitiveSet;
Refresh();
}
private void Refresh()
{
AreaTotal = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Sum(x => x.Area);
AreaNeg = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value < 0d).Sum(x => x.Area);
AreaZero = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value == 0d).Sum(x => x.Area);
AreaPos = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value > 0d).Sum(x => x.Area);
SumTotal = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Sum(x => x.Value);
SumNeg = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value < 0d).Sum(x => x.Value);
SumPos = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value > 0d).Sum(x => x.Value);
OnPropertyChanged(nameof(PrimitiveSet));
OnPropertyChanged(nameof(AreaTotal));
OnPropertyChanged(nameof(AreaNeg));
OnPropertyChanged(nameof(AreaZero));
OnPropertyChanged(nameof(AreaPos));
OnPropertyChanged(nameof(SumTotal));
OnPropertyChanged(nameof(SumNeg));
OnPropertyChanged(nameof(SumPos));
}
}
}

View File

@@ -0,0 +1,27 @@
using FieldVisualizer.Entities.Values.Primitives;
using StructureHelper.Infrastructure;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
public class IsoFieldTitle : ViewModelBase
{
private IPrimitiveSet primitiveSet;
public string Title { get; set; }
public string SubTitle { get; set; }
public IsoFieldTitle(IPrimitiveSet primitiveSet)
{
this.primitiveSet = primitiveSet;
Title = primitiveSet.Name;
SubTitle = primitiveSet.SubTitle;
}
public void Refresh()
{
OnPropertyChanged(nameof(Title));
OnPropertyChanged(nameof(SubTitle));
}
}
}

View File

@@ -0,0 +1,21 @@
<UserControl x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.IsoFieldContours"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="220">
<Grid DataContext="{Binding ContourRange, RelativeSource={RelativeSource AncestorType=UserControl}}">
<ScrollViewer Grid.Column="2">
<StackPanel>
<CheckBox x:Name="cbMinValueEnabled" Margin="3" Content="Minimum Value" IsChecked="{Binding SetMinValue}"/>
<TextBox x:Name="tbMinValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMinValueEnabled}" Text="{Binding Path=UserMinValue, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
<CheckBox x:Name="cbMaxValueEnabled" Margin="3" Content="Maximum Value" IsChecked="{Binding Path=SetMaxValue}"/>
<TextBox x:Name="tbMaxValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMaxValueEnabled}" Text="{Binding Path=UserMaxValue, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
<Button Margin="3" Content="Set custom colors" Command="{Binding SetUserColorsCommand}"/>
<local:IsoFieldVerticalLegend />
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>

View File

@@ -0,0 +1,30 @@
using System.Windows;
using System.Windows.Controls;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
/// <summary>
/// Interaction logic for IsoFieldContours.xaml
/// </summary>
public partial class IsoFieldContours : UserControl
{
public bool IsSelected { get; set; }
public ContoursRangeViewModel ContourRange
{
get { return (ContoursRangeViewModel)GetValue(ContourRangeProperty); }
set { SetValue(ContourRangeProperty, value); }
}
// Using a DependencyProperty as the backing store for ContourRange. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ContourRangeProperty =
DependencyProperty.Register(nameof(ContourRange), typeof(ContoursRangeViewModel), typeof(IsoFieldContours), new PropertyMetadata(null));
public IsoFieldContours()
{
InitializeComponent();
DataContext = this;
}
}
}

View File

@@ -0,0 +1,47 @@
<UserControl x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.IsoFieldVerticalLegend"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StructureHelper.Windows.UserControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel>
<ListBox Name="LegendBox" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="30" Width="190" VerticalAlignment="Top" Background="{DynamicResource {x:Static SystemColors.MenuBarBrushKey}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<CheckBox Name="ActiveCheckBox" Grid.Column="0" IsChecked="{Binding Path=IsActive}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Rectangle Grid.Column="1" Margin="0,2,0,2" ToolTip="{Binding Path=RoundedValues.BottomValue}">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=ExactValues.BottomColor}"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Column="2" Margin="0,2,0,2">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="{Binding Path=ExactValues.BottomColor}"/>
<GradientStop Color="{Binding Path=ExactValues.TopColor}" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#FF868686" Text="{Binding RoundedValues.AverageValue}"/>
<Rectangle Grid.Column="3" Margin="0,2,0,2" ToolTip="{Binding Path=RoundedValues.TopValue}">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=ExactValues.TopColor}"/>
</Rectangle.Fill>
</Rectangle>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
</UserControl>

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
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.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
/// <summary>
/// Interaction logic for IsoFieldVerticalLegend.xaml
/// </summary>
public partial class IsoFieldVerticalLegend : UserControl
{
public ContourLegendViewModel ColorRanges
{
get { return (ContourLegendViewModel)GetValue(ColorRangesProperty); }
set { SetValue(ColorRangesProperty, value); }
}
// Using a DependencyProperty as the backing store for ColorRanges. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ColorRangesProperty =
DependencyProperty.Register(nameof(ColorRanges), typeof(ContourLegendViewModel), typeof(IsoFieldVerticalLegend), new PropertyMetadata(null));
public IsoFieldVerticalLegend()
{
InitializeComponent();
}
}
}

View File

@@ -1,11 +1,7 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Windows.ViewModels;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace StructureHelper.Windows.PrimitivePropertiesWindow
@@ -20,5 +16,11 @@ namespace StructureHelper.Windows.PrimitivePropertiesWindow
Items = new SelectItemsVM<PrimitiveBase>(primitiveViews) { ShowButtons = true };
Items.ItemDataTemplate = Application.Current.Resources["ColoredItemTemplate"] as DataTemplate;
}
public SelectPrimitivesViewModel(IEnumerable<PrimitiveBase> primitives)
{
Items = new SelectItemsVM<PrimitiveBase>(primitives) { ShowButtons = true };
Items.ItemDataTemplate = Application.Current.Resources["ColoredItemTemplate"] as DataTemplate;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace StructureHelperCommon.Models.Forces
{
public interface IStrainTuple : IForceTuple
{
}
}

View File

@@ -5,7 +5,7 @@ using System;
namespace StructureHelperCommon.Models.Forces
{
/// <inheritdoc/>
public class StrainTuple : IForceTuple
public class StrainTuple : IStrainTuple
{
private readonly IUpdateStrategy<IForceTuple> updateStrategy = new ForceTupleUpdateStrategy();
private static IForceTupleServiceLogic forceTupleServiceLogic;