From f315e8160e984df93be6667929db34749aa25cfa Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 30 Jul 2020 02:00:20 -0700 Subject: Use class heirarchy for layout types --- grapher/Layouts/LayoutBase.cs | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 grapher/Layouts/LayoutBase.cs (limited to 'grapher/Layouts/LayoutBase.cs') diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs new file mode 100644 index 0000000..9c60008 --- /dev/null +++ b/grapher/Layouts/LayoutBase.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Layouts +{ + public abstract class LayoutBase + { + public const string Acceleration = "Acceleration"; + public const string Scale = "Scale"; + public const string Exponent = "Exponent"; + public const string Limit = "Limit"; + public const string Midpoint = "Midpoint"; + + public LayoutBase() + { + Show = new bool[] { false, false, false }; + OptionNames = new string[] { string.Empty, string.Empty, string.Empty }; + } + + /// + /// Gets or sets mapping from acceleration type to identifying integer. + /// Must match order in tagged_union in rawaccel.hpp (which is 1-indexed, meaning 0 is off.) + /// + public int Index { get; internal set; } + + public string Name { get; internal set; } + + internal bool[] Show { get; set; } + + internal string[] OptionNames { get; set; } + + public void Layout(Option[] options) + { + // Relies on AccelOptions to keep lengths correct. + for (int i = 0; i< options.Length; i++) + { + if (Show[i]) + { + options[i].Show(OptionNames[i]); + } + else + { + options[i].Hide(); + } + } + + } + } +} -- cgit v1.2.3