Added reviewing of results in graphic mode

This commit is contained in:
Evgeny Redikultsev
2022-09-10 20:16:05 +05:00
parent c12e9f70f9
commit 78ec7bdc6f
26 changed files with 389 additions and 85 deletions

View File

@@ -12,17 +12,19 @@ namespace FieldVisualizer.Services.ColorServices
const byte Alpha = 0xff;
public static Color GetColorByValue(IValueRange range, IColorMap map, double val)
{
double minVal = range.BottomValue;
double maxVal = range.TopValue;
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%
double colorPerc = 1d / (map.Colors.Count - 1); // % of each block of color. the last is the "100% Color"
//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
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

View File

@@ -1,5 +1,7 @@
using FieldVisualizer.Entities.Values;
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,7 +13,7 @@ namespace FieldVisualizer.Services.PrimitiveServices
{
public static class PrimitiveOperations
{
public static IValueRange GetValuRange(IEnumerable<IValuePrimitive> valuePrimitives)
public static IValueRange GetValueRange(IEnumerable<IValuePrimitive> valuePrimitives)
{
double minVal =0d, maxVal = 0d;
foreach (var primitive in valuePrimitives)
@@ -57,6 +59,13 @@ namespace FieldVisualizer.Services.PrimitiveServices
coords.Add(rectanglePrimitive.CenterX + rectanglePrimitive.Width / 2);
coords.Add(rectanglePrimitive.CenterX - rectanglePrimitive.Width / 2);
}
else if (primitive is ICirclePrimitive)
{
ICirclePrimitive circlePrimitive = primitive as ICirclePrimitive;
coords.Add(circlePrimitive.CenterX + circlePrimitive.Diameter / 2);
coords.Add(circlePrimitive.CenterX - circlePrimitive.Diameter / 2);
}
else { throw new FieldVisulizerException(ErrorStrings.PrimitiveTypeIsUnknown);}
}
return coords;
}
@@ -72,6 +81,13 @@ namespace FieldVisualizer.Services.PrimitiveServices
coords.Add(rectanglePrimitive.CenterY + rectanglePrimitive.Height / 2);
coords.Add(rectanglePrimitive.CenterY - rectanglePrimitive.Height / 2);
}
else if (primitive is ICirclePrimitive)
{
ICirclePrimitive circlePrimitive = primitive as ICirclePrimitive;
coords.Add(circlePrimitive.CenterY + circlePrimitive.Diameter / 2);
coords.Add(circlePrimitive.CenterY - circlePrimitive.Diameter / 2);
}
else { throw new FieldVisulizerException(ErrorStrings.PrimitiveTypeIsUnknown); }
}
return coords;
}

View File

@@ -20,10 +20,11 @@ namespace FieldVisualizer.Services.ValueRanges
else
{
double dVal = (valueRange.TopValue - valueRange.BottomValue) / divisionNumber;
double currentBottom = valueRange.BottomValue;
double startBottom = valueRange.BottomValue;
for (int i = 0; i < divisionNumber; i++ )
{
currentBottom = i * dVal;
double currentBottom = startBottom + i * dVal;
var newRange = new ValueRange() { BottomValue = currentBottom, TopValue = currentBottom + dVal };
valueRanges.Add(newRange);
}