Add field 2d viewer
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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[]{
|
||||
|
||||
@@ -9,5 +9,6 @@ namespace FieldVisualizer.Entities.ColorMaps
|
||||
{
|
||||
string Name { get;}
|
||||
List<Color> Colors { get; }
|
||||
LinearGradientBrush GradientBrush { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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">
|
||||
@@ -46,7 +45,7 @@
|
||||
</Viewbox>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Column="2">
|
||||
<StackPanel>
|
||||
@@ -102,7 +101,6 @@
|
||||
</StackPanel>
|
||||
</Expander>
|
||||
</StackPanel>
|
||||
|
||||
</ScrollViewer>
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user