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