Skip to content

Commit

Permalink
Merge pull request #105 from mariuszhermansdorfer/feature/SandWorm2-0
Browse files Browse the repository at this point in the history
Merge the 2.0 branch to master
  • Loading branch information
mariuszhermansdorfer authored Mar 24, 2022
2 parents c88c38d + fbbdbb5 commit 1afd9ca
Show file tree
Hide file tree
Showing 83 changed files with 16,910 additions and 1,651 deletions.
14 changes: 2 additions & 12 deletions SandWorm.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.489
# Visual Studio Version 16
VisualStudioVersion = 16.0.30621.155
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SandWorm", "SandWorm\SandWorm.csproj", "{23B848FB-52C2-4E58-B86F-F69B076045DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SandwormBenchmarks", "SandwormBenchmarks\SandwormBenchmarks.csproj", "{8637E765-912C-4964-9BC5-6BB972AF86D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -23,14 +21,6 @@ Global
{23B848FB-52C2-4E58-B86F-F69B076045DE}.Release|Any CPU.Build.0 = Release|Any CPU
{23B848FB-52C2-4E58-B86F-F69B076045DE}.Release|x64.ActiveCfg = Release|x64
{23B848FB-52C2-4E58-B86F-F69B076045DE}.Release|x64.Build.0 = Release|x64
{8637E765-912C-4964-9BC5-6BB972AF86D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8637E765-912C-4964-9BC5-6BB972AF86D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8637E765-912C-4964-9BC5-6BB972AF86D6}.Debug|x64.ActiveCfg = Debug|Any CPU
{8637E765-912C-4964-9BC5-6BB972AF86D6}.Debug|x64.Build.0 = Debug|Any CPU
{8637E765-912C-4964-9BC5-6BB972AF86D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8637E765-912C-4964-9BC5-6BB972AF86D6}.Release|Any CPU.Build.0 = Release|Any CPU
{8637E765-912C-4964-9BC5-6BB972AF86D6}.Release|x64.ActiveCfg = Release|Any CPU
{8637E765-912C-4964-9BC5-6BB972AF86D6}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
60 changes: 4 additions & 56 deletions SandWorm/Analysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,6 @@ namespace SandWorm
{
public static class Analysis
{
/// <summary>Abstractions for managing analysis state.</summary>
public static class AnalysisManager
{
/// <summary>Stories copies of each analysis option and interfaces their use with components.</summary>
public static List<MeshAnalysis> options;

static AnalysisManager() // Note that the order of items here determines their menu order
{
options = new List<MeshAnalysis>
{
new Analytics.WaterLevel(), new Analytics.Contours(),
new Analytics.None(),
new Analytics.Elevation(), new Analytics.Slope(), new Analytics.Aspect()
};
// Default to showing elevation analysis
options[3].isEnabled = true;
}

public static List<MeshAnalysis> GetEnabledAnalyses()
{
return options.FindAll(x => x.isEnabled);
}

public static MeshColorAnalysis GetEnabledMeshColoring()
{
foreach (var enabledOption in GetEnabledAnalyses())
if (enabledOption.GetType().IsSubclassOf(typeof(MeshColorAnalysis)))
return enabledOption as MeshColorAnalysis;
return null; // Shouldn't happen; a mesh coloring option (even no color) is always set
}

public static List<MeshGeometryAnalysis> GetEnabledMeshAnalytics()
{
var enabledGeometryAnalysis = new List<MeshGeometryAnalysis>();
foreach (var enabledOption in GetEnabledAnalyses())
{
// Testing inheritance with generics is not going to work; so just check if the option is not a color one
if (enabledOption.GetType().IsSubclassOf(typeof(MeshGeometryAnalysis)))
enabledGeometryAnalysis.Add(enabledOption as MeshGeometryAnalysis);
}
return enabledGeometryAnalysis;
}

public static void SetEnabledOptions(ToolStripMenuItem selectedMenuItem)
{
var selectedOption = options.Find(x => x.MenuItem == selectedMenuItem);
if (selectedOption.IsExclusive)
foreach (var exclusiveOption in options.FindAll(x => x.IsExclusive))
exclusiveOption.isEnabled =
selectedOption == exclusiveOption; // Toggle selected item; untoggle other exclusive items
else
selectedOption.isEnabled = !selectedOption.isEnabled; // Simple toggle for independent items
}
}

public class VisualisationRangeWithColor
{
Expand Down Expand Up @@ -118,8 +64,10 @@ public abstract class MeshColorAnalysis : MeshAnalysis
public MeshColorAnalysis(string menuName) : base(menuName, true)
{
} // Note: is mutually exclusive

public abstract void ComputeLookupTableForAnalysis(double sensorElevation);

// Provide two methods for overloading; one for custom-gradient-using options and one for the others
public virtual void ComputeLookupTableForAnalysis(double sensorElevation, double gradientRange) { return; }
public virtual void ComputeLookupTableForAnalysis(double sensorElevation, double gradientRange, int paletteOptions = 0) { return; }

public void ComputeLinearRanges(params VisualisationRangeWithColor[] lookUpRanges)
{
Expand Down
6 changes: 3 additions & 3 deletions SandWorm/Analytics/Aspect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ private Color GetColorForAspect(short aspectValue)
return lookupTable[aspectValue];
}

public Color[] GetColorCloudForAnalysis(double[] pixelArray, int width, int height)
public Color[] GetColorCloudForAnalysis(double[] pixelArray, int width, int height, double gradientRange)
{
if (lookupTable == null)
{
ComputeLookupTableForAnalysis(0.0);
ComputeLookupTableForAnalysis(0.0, gradientRange);
}
var vertexColors = new Color[pixelArray.Length];

Expand Down Expand Up @@ -165,7 +165,7 @@ public Color[] GetColorCloudForAnalysis(double[] pixelArray, int width, int heig
return vertexColors;
}

public override void ComputeLookupTableForAnalysis(double sensorElevation)
public override void ComputeLookupTableForAnalysis(double sensorElevation, double gradientRange)
{
var north = new ColorHSL(0.7, 1, 0.90); // North = Blue
var east = new ColorHSL(0.9, 1, 0.5); // East = Pink
Expand Down
124 changes: 124 additions & 0 deletions SandWorm/Analytics/ColorPalettes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using System.Collections.Generic;
using System.Drawing;

namespace SandWorm
{
public static class ColorPalettes
{
public static List<Color> GenerateColorPalettes(Structs.ColorPalettes palette, List<Color> customColors)
{
List<Color> paletteSwatches = new List<Color>();

switch (palette)
{
case Structs.ColorPalettes.Custom:
if (customColors.Count == 0) // No inputs provided; use placeholder
{
paletteSwatches.Add(Color.FromArgb(122, 122, 122));
paletteSwatches.Add(Color.FromArgb(122, 122, 122));
}

for (int i = 0; i < customColors.Count; i++)
paletteSwatches.Add(customColors[i]);
break;

case Structs.ColorPalettes.Chile:
paletteSwatches.Add(Color.FromArgb(38, 115, 0));
paletteSwatches.Add(Color.FromArgb(124, 191, 48));
paletteSwatches.Add(Color.FromArgb(255, 247, 52));
paletteSwatches.Add(Color.FromArgb(196, 65, 0));
paletteSwatches.Add(Color.FromArgb(230, 188, 167));
break;

case Structs.ColorPalettes.CutFill:
paletteSwatches.Add(Color.FromArgb(235, 100, 75));
paletteSwatches.Add(Color.FromArgb(40, 40, 40));
paletteSwatches.Add(Color.FromArgb(164, 206, 101));
break;

case Structs.ColorPalettes.Desert:
paletteSwatches.Add(Color.FromArgb(55, 101, 84));
paletteSwatches.Add(Color.FromArgb(73, 117, 100));
paletteSwatches.Add(Color.FromArgb(172, 196, 160));
paletteSwatches.Add(Color.FromArgb(148, 131, 85));
paletteSwatches.Add(Color.FromArgb(217, 209, 190));
break;

case Structs.ColorPalettes.Europe:
paletteSwatches.Add(Color.FromArgb(36, 121, 36));
paletteSwatches.Add(Color.FromArgb(89, 148, 54));
paletteSwatches.Add(Color.FromArgb(181, 195, 80));
paletteSwatches.Add(Color.FromArgb(208, 191, 94));
paletteSwatches.Add(Color.FromArgb(115, 24, 19));
break;

case Structs.ColorPalettes.Greyscale:
paletteSwatches.Add(Color.FromArgb(40, 40, 40));
paletteSwatches.Add(Color.FromArgb(80, 80, 80));
paletteSwatches.Add(Color.FromArgb(120, 120, 120));
paletteSwatches.Add(Color.FromArgb(160, 160, 160));
paletteSwatches.Add(Color.FromArgb(200, 200, 200));
break;

case Structs.ColorPalettes.Dune:
paletteSwatches.Add(Color.FromArgb(80, 80, 80));
paletteSwatches.Add(Color.FromArgb(122, 91, 76));
paletteSwatches.Add(Color.FromArgb(191, 118, 40));
paletteSwatches.Add(Color.FromArgb(240, 173, 50));
paletteSwatches.Add(Color.FromArgb(255, 210, 128));
break;

case Structs.ColorPalettes.Ocean:
paletteSwatches.Add(Color.FromArgb(47, 34, 58));
paletteSwatches.Add(Color.FromArgb(62, 90, 146));
paletteSwatches.Add(Color.FromArgb(80, 162, 162));
paletteSwatches.Add(Color.FromArgb(152, 218, 164));
paletteSwatches.Add(Color.FromArgb(250, 250, 200));
break;

case Structs.ColorPalettes.Turbo:
paletteSwatches.Add(Color.FromArgb(48, 18, 59));
paletteSwatches.Add(Color.FromArgb(65, 69, 171));
paletteSwatches.Add(Color.FromArgb(70,117,237));
paletteSwatches.Add(Color.FromArgb(57, 162, 252));
paletteSwatches.Add(Color.FromArgb(27, 207, 212));
paletteSwatches.Add(Color.FromArgb(36, 236, 166));
paletteSwatches.Add(Color.FromArgb(97, 252, 108));
paletteSwatches.Add(Color.FromArgb(164, 252, 59));
paletteSwatches.Add(Color.FromArgb(209, 232, 52));
paletteSwatches.Add(Color.FromArgb(243, 198, 58));
paletteSwatches.Add(Color.FromArgb(254, 155, 45));
paletteSwatches.Add(Color.FromArgb(243, 99, 21));
paletteSwatches.Add(Color.FromArgb(217, 56, 6));
paletteSwatches.Add(Color.FromArgb(177, 25, 1));
paletteSwatches.Add(Color.FromArgb(122, 4, 2));
break;

case Structs.ColorPalettes.Viridis:
paletteSwatches.Add(Color.FromArgb(52, 0, 66));
paletteSwatches.Add(Color.FromArgb(55, 8, 85));
paletteSwatches.Add(Color.FromArgb(55, 23, 100));
paletteSwatches.Add(Color.FromArgb(53, 37, 110));
paletteSwatches.Add(Color.FromArgb(48, 52, 117));
paletteSwatches.Add(Color.FromArgb(44, 65, 121));
paletteSwatches.Add(Color.FromArgb(39, 80, 123));
paletteSwatches.Add(Color.FromArgb(36, 93, 123));
paletteSwatches.Add(Color.FromArgb(33, 106, 123));
paletteSwatches.Add(Color.FromArgb(31, 120, 122));
paletteSwatches.Add(Color.FromArgb(30, 134, 120));
paletteSwatches.Add(Color.FromArgb(32, 148, 115));
paletteSwatches.Add(Color.FromArgb(38, 162, 108));
paletteSwatches.Add(Color.FromArgb(52, 178, 98));
paletteSwatches.Add(Color.FromArgb(73, 190, 84));
paletteSwatches.Add(Color.FromArgb(101, 202, 68));
paletteSwatches.Add(Color.FromArgb(132, 212, 50));
paletteSwatches.Add(Color.FromArgb(171, 219, 32));
paletteSwatches.Add(Color.FromArgb(212, 225, 21));
paletteSwatches.Add(Color.FromArgb(252, 229, 30));
break;
}

return paletteSwatches;
}
}
}
21 changes: 0 additions & 21 deletions SandWorm/Analytics/Contours.cs

This file was deleted.

Loading

0 comments on commit 1afd9ca

Please sign in to comment.