IReport is added
This commit is contained in:
@@ -12,16 +12,16 @@ namespace FieldVisualizer.Services.ColorServices
|
||||
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 (range.TopValue == minVal || map.Colors.Count == 0) { return map.Colors[0]; }
|
||||
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]; }
|
||||
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
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using FieldVisualizer.Entities.Values.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FieldVisualizer.Services.PrimitiveServices
|
||||
{
|
||||
public static class TestPrimitivesOperation
|
||||
{
|
||||
public static List<IPrimitiveSet> AddTestPrimitives()
|
||||
{
|
||||
List<IPrimitiveSet> primitiveSets = new List<IPrimitiveSet>();
|
||||
int imax = 100;
|
||||
int jmax = 100;
|
||||
PrimitiveSet primitiveSet = new PrimitiveSet();
|
||||
primitiveSets.Add(primitiveSet);
|
||||
List<IValuePrimitive> primitives = new List<IValuePrimitive>();
|
||||
primitiveSet.ValuePrimitives = primitives;
|
||||
IValuePrimitive primitive;
|
||||
for (int i = 0; i < imax; i++)
|
||||
{
|
||||
for (int j = 0; j < jmax; j++)
|
||||
{
|
||||
primitive = new RectanglePrimitive() { Height = 10, Width = 20, CenterX = 20 * i, CenterY = 10 * j, Value = -(i + j) };
|
||||
primitives.Add(primitive);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
primitive = new CirclePrimitive() { Diameter = 150, CenterX = -200 * i, CenterY = -100 * j, Value = i * 100 + j * 200 };
|
||||
primitives.Add(primitive);
|
||||
}
|
||||
}
|
||||
primitiveSet = new PrimitiveSet();
|
||||
primitives = new List<IValuePrimitive>();
|
||||
primitive = new RectanglePrimitive() { Height = 100, Width = 200, CenterX = 0, CenterY = 0, Value = 100 };
|
||||
primitives.Add(primitive);
|
||||
primitive = new CirclePrimitive() { Diameter = 50, CenterX = 0, CenterY = 0, Value = -100 };
|
||||
primitives.Add(primitive);
|
||||
primitiveSet.ValuePrimitives = primitives;
|
||||
primitiveSets.Add(primitiveSet);
|
||||
return primitiveSets;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="220"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -35,7 +35,12 @@
|
||||
</Viewbox>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<local:VerticalLegend x:Name="LegendViewer" Grid.Column="2"/>
|
||||
<StackPanel Grid.Column="2">
|
||||
<CheckBox x:Name="cbMinValueEnabled" Margin="3" Content="Minimum Value"/>
|
||||
<TextBox x:Name="tbMinValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMinValueEnabled}" Text="{Binding Path=UserValueRange.BottomValue}"/>
|
||||
<CheckBox x:Name="cbMaxValueEnabled" Margin="3" Content="Maximum Value"/>
|
||||
<TextBox x:Name="tbMaxValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMaxValueEnabled}" Text="{Binding Path=UserValueRange.TopValue}"/>
|
||||
<local:VerticalLegend x:Name="LegendViewer" Margin="3" Grid.Column="2"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -31,10 +31,12 @@ namespace FieldVisualizer.Windows.UserControls
|
||||
public ICommand ChangeColorMapCommand { get; }
|
||||
|
||||
public IPrimitiveSet PrimitiveSet { get; set; }
|
||||
public IValueRange UserValueRange { get; set; }
|
||||
|
||||
private double dX, dY;
|
||||
private ColorMapsTypes _ColorMapType;
|
||||
private IColorMap _ColorMap;
|
||||
private IValueRange _ValueRange;
|
||||
private IValueRange valueRange;
|
||||
private IEnumerable<IValueRange> _ValueRanges;
|
||||
private IEnumerable<IValueColorRange> _ValueColorRanges;
|
||||
const int RangeNumber = 16;
|
||||
@@ -48,14 +50,13 @@ namespace FieldVisualizer.Windows.UserControls
|
||||
ZoomInCommand = new RelayCommand(o => Zoom(1.2), o => PrimitiveValidation());
|
||||
ZoomOutCommand = new RelayCommand(o => Zoom(0.8), o => PrimitiveValidation());
|
||||
ChangeColorMapCommand = new RelayCommand(o => ChangeColorMap(), o => PrimitiveValidation());
|
||||
UserValueRange = new ValueRange() { BottomValue = 0, TopValue = 0 };
|
||||
}
|
||||
public void Refresh()
|
||||
{
|
||||
if (PrimitiveValidation() == false) { return; }
|
||||
_ValueRange = PrimitiveOperations.GetValueRange(PrimitiveSet.ValuePrimitives);
|
||||
_ValueRanges = ValueRangeOperations.DivideValueRange(_ValueRange, RangeNumber);
|
||||
_ColorMap = ColorMapFactory.GetColorMap(_ColorMapType);
|
||||
_ValueColorRanges = ColorOperations.GetValueColorRanges(_ValueRange, _ValueRanges, _ColorMap);
|
||||
SetColor();
|
||||
if ((PrimitiveSet is null) == false)
|
||||
{
|
||||
ProcessPrimitives();
|
||||
@@ -65,6 +66,7 @@ namespace FieldVisualizer.Windows.UserControls
|
||||
}
|
||||
private void ProcessPrimitives()
|
||||
{
|
||||
|
||||
WorkPlaneCanvas.Children.Clear();
|
||||
double sizeX = PrimitiveOperations.GetSizeX(PrimitiveSet.ValuePrimitives);
|
||||
double sizeY = PrimitiveOperations.GetSizeY(PrimitiveSet.ValuePrimitives);
|
||||
@@ -119,7 +121,7 @@ namespace FieldVisualizer.Windows.UserControls
|
||||
private void ProcessShape(Shape shape, IValuePrimitive valuePrimitive, double addX, double addY)
|
||||
{
|
||||
SolidColorBrush brush = new SolidColorBrush();
|
||||
brush.Color = ColorOperations.GetColorByValue(_ValueRange, _ColorMap, valuePrimitive.Value);
|
||||
brush.Color = ColorOperations.GetColorByValue(valueRange, _ColorMap, valuePrimitive.Value);
|
||||
foreach (var valueRange in _ValueColorRanges)
|
||||
{
|
||||
if (valuePrimitive.Value >= valueRange.BottomValue & valuePrimitive.Value <= valueRange.TopValue & (!valueRange.IsActive))
|
||||
@@ -131,7 +133,7 @@ namespace FieldVisualizer.Windows.UserControls
|
||||
shape.Tag = valuePrimitive;
|
||||
shape.Fill = brush;
|
||||
Canvas.SetLeft(shape, valuePrimitive.CenterX - addX - dX);
|
||||
Canvas.SetTop(shape, valuePrimitive.CenterY - addY - dY);
|
||||
Canvas.SetTop(shape, - valuePrimitive.CenterY - addY - dY);
|
||||
}
|
||||
private void Zoom(double coefficient)
|
||||
{
|
||||
@@ -154,5 +156,13 @@ namespace FieldVisualizer.Windows.UserControls
|
||||
if (PrimitiveSet == null || PrimitiveSet.ValuePrimitives.Count() == 0) { return false; }
|
||||
else return true;
|
||||
}
|
||||
private void SetColor()
|
||||
{
|
||||
valueRange = PrimitiveOperations.GetValueRange(PrimitiveSet.ValuePrimitives);
|
||||
if (cbMinValueEnabled.IsChecked == true) { valueRange.BottomValue = UserValueRange.BottomValue; } else { UserValueRange.BottomValue = valueRange.BottomValue; }
|
||||
if (cbMaxValueEnabled.IsChecked == true) { valueRange.TopValue = UserValueRange.TopValue; } else { UserValueRange.TopValue = valueRange.TopValue; }
|
||||
_ValueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber);
|
||||
_ValueColorRanges = ColorOperations.GetValueColorRanges(valueRange, _ValueRanges, _ColorMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<ListBox Name="LegendBox" ItemsSource="{Binding}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Height="30" Width="194" VerticalAlignment="Top" Background="{DynamicResource {x:Static SystemColors.MenuBarBrushKey}}">
|
||||
<Grid Height="30" Width="190" VerticalAlignment="Top" Background="{DynamicResource {x:Static SystemColors.MenuBarBrushKey}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
xmlns:FieldViewerControl="clr-namespace:FieldVisualizer.Windows.UserControls"
|
||||
xmlns:local="clr-namespace:FieldVisualizer.Windows"
|
||||
mc:Ignorable="d"
|
||||
Title="FieldViewer" Height="700" Width="1200" WindowStartupLocation="CenterOwner">
|
||||
Title="FieldViewer" Height="800" Width="1200" WindowStartupLocation="CenterOwner">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
|
||||
Reference in New Issue
Block a user