summaryrefslogtreecommitdiff
path: root/grapher/Models/Options
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-07-05 23:33:41 -0400
committera1xd <[email protected]>2021-07-05 23:33:41 -0400
commit31efc792f5895d7ef3533390875de3c480add996 (patch)
tree8db5b16a88f50448cb525ba8ae56801985294f63 /grapher/Models/Options
parentMerge pull request #87 from matthewstrasiotto/streamer_mode (diff)
parentHandle power\exponent correctly in GUI (diff)
downloadrawaccel-31efc792f5895d7ef3533390875de3c480add996.tar.xz
rawaccel-31efc792f5895d7ef3533390875de3c480add996.zip
merge lut2
Diffstat (limited to 'grapher/Models/Options')
-rw-r--r--grapher/Models/Options/AccelOptionSet.cs12
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs265
-rw-r--r--grapher/Models/Options/ApplyOptions.cs61
-rw-r--r--grapher/Models/Options/CapOptions.cs225
-rw-r--r--grapher/Models/Options/CheckBoxOption.cs109
-rw-r--r--grapher/Models/Options/LUT/LUTPanelOptions.cs217
-rw-r--r--grapher/Models/Options/LUT/LUTPointOption.cs39
-rw-r--r--grapher/Models/Options/LUT/LutApplyOptions.cs183
-rw-r--r--grapher/Models/Options/OffsetOptions.cs5
-rw-r--r--grapher/Models/Options/TextOption.cs129
10 files changed, 902 insertions, 343 deletions
diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs
index 11a7f10..75eb017 100644
--- a/grapher/Models/Options/AccelOptionSet.cs
+++ b/grapher/Models/Options/AccelOptionSet.cs
@@ -46,8 +46,8 @@ namespace grapher.Models.Options
{
IsTitleMode = false;
- HideTitle();
Options.ShowFull();
+ HideTitle();
}
}
@@ -61,6 +61,7 @@ namespace grapher.Models.Options
Options.ShowShortened();
DisplayTitle();
+ Options.HandleLUTOptionsOnResize();
}
}
@@ -103,16 +104,11 @@ namespace grapher.Models.Options
Options.SetArgs(ref args);
}
- public AccelArgs GenerateArgs()
- {
- return Options.GenerateArgs();
- }
-
- public void SetActiveValues(int mode, AccelArgs args)
+ public void SetActiveValues(ref AccelArgs args)
{
if (!Hidden)
{
- Options.SetActiveValues(mode, args);
+ Options.SetActiveValues(ref args);
}
}
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index 8d3fecb..f97df2d 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -1,5 +1,6 @@
using grapher.Layouts;
using grapher.Models.Options;
+using grapher.Models.Options.LUT;
using grapher.Models.Serialized;
using System;
using System.Collections.Generic;
@@ -12,16 +13,15 @@ namespace grapher
{
#region Fields
- public static readonly Dictionary<string, LayoutBase> AccelerationTypes = new List<LayoutBase>
- {
- new LinearLayout(),
- new ClassicLayout(),
- new NaturalLayout(),
- new NaturalGainLayout(),
- new PowerLayout(),
- new MotivityLayout(),
- new OffLayout()
- }.ToDictionary(k => k.Name);
+ public static readonly LayoutBase Linear = new LinearLayout();
+ public static readonly LayoutBase Classic = new ClassicLayout();
+ public static readonly LayoutBase Jump = new JumpLayout();
+ public static readonly LayoutBase Natural = new NaturalLayout();
+ public static readonly LayoutBase Motivity = new MotivityLayout();
+ public static readonly LayoutBase Power = new PowerLayout();
+ public static readonly LayoutBase LUT = new LUTLayout();
+ public static readonly LayoutBase Off = new OffLayout();
+ public static readonly LayoutBase Unsupported = new UnsupportedLayout();
#endregion Fields
@@ -29,22 +29,39 @@ namespace grapher
public AccelTypeOptions(
ComboBox accelDropdown,
+ CheckBoxOption gainSwitch,
Option acceleration,
Option scale,
- CapOptions cap,
+ Option cap,
Option weight,
- OffsetOptions offset,
+ Option offset,
Option limit,
Option exponent,
Option midpoint,
+ TextOption lutText,
+ LUTPanelOptions lutPanelOptions,
+ LutApplyOptions lutApplyOptions,
Button writeButton,
ActiveValueLabel accelTypeActiveValue)
{
AccelDropdown = accelDropdown;
AccelDropdown.Items.Clear();
- AccelDropdown.Items.AddRange(AccelerationTypes.Keys.ToArray());
+ AccelDropdown.Items.AddRange(
+ new LayoutBase[]
+ {
+ Linear,
+ Classic,
+ Jump,
+ Natural,
+ Motivity,
+ Power,
+ LUT,
+ Off
+ });
+
AccelDropdown.SelectedIndexChanged += new System.EventHandler(OnIndexChanged);
+ GainSwitch = gainSwitch;
Acceleration = acceleration;
Scale = scale;
Cap = cap;
@@ -55,11 +72,21 @@ namespace grapher
Midpoint = midpoint;
WriteButton = writeButton;
AccelTypeActiveValue = accelTypeActiveValue;
+ LutText = lutText;
+ LutPanel = lutPanelOptions;
+ LutApply = lutApplyOptions;
AccelTypeActiveValue.Left = AccelDropdown.Left + AccelDropdown.Width;
AccelTypeActiveValue.Height = AccelDropdown.Height;
+ GainSwitch.Left = Acceleration.Field.Left;
+
+ LutPanel.Left = AccelDropdown.Left;
+ LutPanel.Width = AccelDropdown.Width + AccelTypeActiveValue.Width;
- Layout("Off");
+ LutText.SetText(TextOption.LUTLayoutExpandedText, TextOption.LUTLayoutShortenedText);
+
+ AccelerationType = Off;
+ Layout();
ShowingDefault = true;
}
@@ -72,27 +99,17 @@ namespace grapher
public ComboBox AccelDropdown { get; }
- public int AccelerationIndex
- {
- get
- {
- return AccelerationType.Index;
- }
- }
-
- public LayoutBase AccelerationType { get; private set; }
-
public ActiveValueLabel AccelTypeActiveValue { get; }
public Option Acceleration { get; }
public Option Scale { get; }
- public CapOptions Cap { get; }
+ public Option Cap { get; }
public Option Weight { get; }
- public OffsetOptions Offset { get; }
+ public Option Offset { get; }
public Option Limit { get; }
@@ -100,6 +117,26 @@ namespace grapher
public Option Midpoint { get; }
+ public TextOption LutText { get; }
+
+ public CheckBoxOption GainSwitch { get; }
+
+ public LUTPanelOptions LutPanel { get; }
+
+ public LutApplyOptions LutApply { get; }
+
+ public LayoutBase AccelerationType
+ {
+ get
+ {
+ return AccelDropdown.SelectedItem as LayoutBase;
+ }
+ private set
+ {
+ AccelDropdown.SelectedItem = value;
+ }
+ }
+
public override int Top
{
get
@@ -131,6 +168,9 @@ namespace grapher
set
{
AccelDropdown.Left = value;
+ LutText.Left = value;
+ LutPanel.Left = value;
+ LutApply.Left = value;
}
}
@@ -143,6 +183,9 @@ namespace grapher
set
{
AccelDropdown.Width = value;
+ LutText.Width = value;
+ LutPanel.Width = AccelTypeActiveValue.CenteringLabel.Right - AccelDropdown.Left;
+ LutApply.Width = value;
}
}
@@ -165,6 +208,7 @@ namespace grapher
AccelDropdown.Hide();
AccelTypeActiveValue.Hide();
+ GainSwitch.Hide();
Acceleration.Hide();
Scale.Hide();
Cap.Hide();
@@ -173,13 +217,16 @@ namespace grapher
Limit.Hide();
Exponent.Hide();
Midpoint.Hide();
+ LutText.Hide();
+ LutPanel.Hide();
+ LutApply.Hide();
}
public void Show()
{
AccelDropdown.Show();
AccelTypeActiveValue.Show();
- Layout();
+ Layout(AccelDropdown.Bottom + Constants.OptionVerticalSeperation);
}
public override void Show(string name)
@@ -187,20 +234,21 @@ namespace grapher
Show();
}
- public void SetActiveValues(int index, AccelArgs args)
+ public void SetActiveValues(ref AccelArgs args)
{
- AccelerationType = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value;
- AccelTypeActiveValue.SetValue(AccelerationType.Name);
- AccelDropdown.SelectedIndex = AccelerationType.Index;
-
+ AccelerationType = AccelTypeFromSettings(ref args);
+ AccelTypeActiveValue.SetValue(AccelerationType.ActiveName);
+ GainSwitch.SetActiveValue(args.legacy);
Weight.SetActiveValue(args.weight);
- Cap.SetActiveValues(args.gainCap, args.scaleCap, args.gainCap > 0 || args.scaleCap <= 0);
- Offset.SetActiveValue(args.offset, args.legacyOffset);
- Acceleration.SetActiveValue(args.acceleration);
+ Cap.SetActiveValue(args.cap);
+ Offset.SetActiveValue(args.offset);
+ Acceleration.SetActiveValue(AccelerationParameterFromArgs(ref args));
Scale.SetActiveValue(args.scale);
Limit.SetActiveValue(args.limit);
- Exponent.SetActiveValue(args.exponent);
+ Exponent.SetActiveValue(ExponentParameterFromArgs(ref args));
Midpoint.SetActiveValue(args.midpoint);
+ LutPanel.SetActiveValues(args.tableData.points, args.tableData.length);
+ LutApply.SetActiveValue(args.tableData.velocity);
}
public void ShowFull()
@@ -212,6 +260,9 @@ namespace grapher
Left = Acceleration.Left + Constants.DropDownLeftSeparation;
Width = Acceleration.Width - Constants.DropDownLeftSeparation;
+
+ LutText.Expand();
+ HandleLUTOptionsOnResize();
}
public void ShowShortened()
@@ -223,33 +274,66 @@ namespace grapher
Left = Acceleration.Field.Left;
Width = Acceleration.Field.Width;
+
+ LutText.Shorten();
}
public void SetArgs(ref AccelArgs args)
{
- AccelArgs defaults = DriverInterop.DefaultSettings.args.x;
- args.acceleration = Acceleration.Visible ? Acceleration.Field.Data : defaults.acceleration;
- args.scale = Scale.Visible ? Scale.Field.Data : defaults.scale;
- args.gainCap = Cap.Visible ? Cap.VelocityGainCap : defaults.gainCap;
- args.scaleCap = Cap.Visible ? Cap.SensitivityCap : defaults.scaleCap;
- args.limit = Limit.Visible ? Limit.Field.Data : defaults.limit;
- args.exponent = Exponent.Visible ? Exponent.Field.Data : defaults.exponent;
- args.offset = Offset.Visible ? Offset.Offset : defaults.offset;
- args.legacyOffset = Offset.IsLegacy;
- args.midpoint = Midpoint.Visible ? Midpoint.Field.Data : defaults.midpoint;
- args.weight = Weight.Visible ? Weight.Field.Data : defaults.weight;
- }
+ if (AccelerationType == Unsupported) throw new NotImplementedException();
- public AccelArgs GenerateArgs()
- {
- AccelArgs args = new AccelArgs();
- SetArgs(ref args);
- return args;
+ args.mode = AccelerationType.Mode;
+
+ if (Acceleration.Visible)
+ {
+ if (args.mode == AccelMode.natural)
+ {
+ args.decayRate = Acceleration.Field.Data;
+ }
+ else if (args.mode == AccelMode.motivity)
+ {
+ args.growthRate = Acceleration.Field.Data;
+ }
+ else
+ {
+ args.accelClassic = Acceleration.Field.Data;
+ }
+
+ args.smooth = Acceleration.Field.Data;
+ }
+
+ args.legacy = !GainSwitch.CheckBox.Checked;
+
+ if (Scale.Visible) args.scale = Scale.Field.Data;
+ if (Cap.Visible) args.cap = Cap.Field.Data;
+ if (Limit.Visible) args.limit = Limit.Field.Data;
+ if (Exponent.Visible)
+ {
+ if (args.mode == AccelMode.classic)
+ {
+ args.power = Exponent.Field.Data;
+ }
+ else
+ {
+ args.exponent = Exponent.Field.Data;
+ }
+ }
+ if (Offset.Visible) args.offset = Offset.Field.Data;
+ if (Midpoint.Visible) args.midpoint = Midpoint.Field.Data;
+ if (Weight.Visible) args.weight = Weight.Field.Data;
+ if (LutPanel.Visible)
+ {
+ (var points, var length) = LutPanel.GetPoints();
+ args.tableData.points = points;
+ args.tableData.length = length;
+ }
+ if (LutApply.Visible) args.tableData.velocity = LutApply.ApplyType == LutApplyOptions.LutApplyType.Velocity;
}
public override void AlignActiveValues()
{
AccelTypeActiveValue.Align();
+ GainSwitch.AlignActiveValues();
Acceleration.AlignActiveValues();
Scale.AlignActiveValues();
Cap.AlignActiveValues();
@@ -258,29 +342,33 @@ namespace grapher
Limit.AlignActiveValues();
Exponent.AlignActiveValues();
Midpoint.AlignActiveValues();
+ LutApply.AlignActiveValues();
}
- private void OnIndexChanged(object sender, EventArgs e)
+ public void HandleLUTOptionsOnResize()
{
- var accelerationTypeString = AccelDropdown.SelectedItem.ToString();
- Layout(accelerationTypeString, Beneath);
- ShowingDefault = false;
+ LutText.Left = AccelDropdown.Left;
+ LutPanel.Left = GainSwitch.Left - 100;
+ LutPanel.Width = Acceleration.ActiveValueLabel.CenteringLabel.Right - LutPanel.Left;
+ LutApply.Left = LutPanel.Left;
+ LutApply.Width = AccelDropdown.Right - LutPanel.Left;
}
- private void Layout(string type, int top = -1)
+ private void OnIndexChanged(object sender, EventArgs e)
{
- AccelerationType = AccelerationTypes[type];
- Layout(top);
+ Layout(Beneath);
+ ShowingDefault = false;
}
private void Layout(int top = -1)
{
if (top < 0)
{
- top = Acceleration.Top;
+ top = GainSwitch.Top;
}
AccelerationType.Layout(
+ GainSwitch,
Acceleration,
Scale,
Cap,
@@ -289,9 +377,64 @@ namespace grapher
Limit,
Exponent,
Midpoint,
+ LutText,
+ LutPanel,
+ LutApply,
top);
}
+ private LayoutBase AccelTypeFromSettings(ref AccelArgs args)
+ {
+ if (args.spacedTableArgs.mode != SpacedTableMode.off)
+ {
+ if (!AccelDropdown.Items.Contains(Unsupported))
+ {
+ AccelDropdown.Items.Add(Unsupported);
+ }
+
+ return Unsupported;
+ }
+
+ switch (args.mode)
+ {
+ case AccelMode.classic: return (args.power == 2) ? Linear : Classic;
+ case AccelMode.jump: return Jump;
+ case AccelMode.natural: return Natural;
+ case AccelMode.motivity: return Motivity;
+ case AccelMode.power: return Power;
+ case AccelMode.lut: return LUT;
+ default: return Off;
+ }
+ }
+
+ private double AccelerationParameterFromArgs(ref AccelArgs args)
+ {
+ if (args.mode == AccelMode.motivity)
+ {
+ return args.growthRate;
+ }
+ else if (args.mode == AccelMode.natural)
+ {
+ return args.decayRate;
+ }
+ else
+ {
+ return args.accelClassic;
+ }
+ }
+
+ private double ExponentParameterFromArgs(ref AccelArgs args)
+ {
+ if (args.mode == AccelMode.classic)
+ {
+ return args.power;
+ }
+ else
+ {
+ return args.exponent;
+ }
+ }
+
#endregion Methods
}
}
diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs
index ffe430d..06854b8 100644
--- a/grapher/Models/Options/ApplyOptions.cs
+++ b/grapher/Models/Options/ApplyOptions.cs
@@ -81,59 +81,30 @@ namespace grapher.Models.Options
#region Methods
- public Vec2<AccelMode> GetModes()
+ public void SetArgs(ref Vec2<AccelArgs> args)
{
- var xMode = (AccelMode)OptionSetX.Options.AccelerationIndex;
+ OptionSetX.SetArgs(ref args.x);
- return new Vec2<AccelMode>
+ if (ByComponentVectorXYLock.Checked)
{
- x = xMode,
- y = ByComponentVectorXYLock.Checked ? xMode : (AccelMode)OptionSetY.Options.AccelerationIndex
- };
- }
-
- public Vec2<AccelArgs> GetArgs()
- {
- var xArgs = OptionSetX.GenerateArgs();
-
- return new Vec2<AccelArgs>
+ OptionSetX.SetArgs(ref args.y);
+ }
+ else
{
- x = xArgs,
- y = ByComponentVectorXYLock.Checked ? xArgs : OptionSetY.GenerateArgs()
- };
-
- }
-
- public void SetActiveValues(
- double xSens,
- double ySens,
- double rotation,
- int xMode,
- int yMode,
- AccelArgs xArgs,
- AccelArgs yArgs,
- bool isWhole)
- {
- Sensitivity.SetActiveValues(xSens, ySens);
- Rotation.SetActiveValue(rotation);
- OptionSetX.SetActiveValues(xMode, xArgs);
- WholeVectorCheckBox.Checked = isWhole;
- ByComponentVectorCheckBox.Checked = !isWhole;
- ByComponentVectorXYLock.Checked = xArgs.Equals(yArgs);
- OptionSetY.SetActiveValues(yMode, yArgs);
+ OptionSetY.SetArgs(ref args.y);
+ }
}
public void SetActiveValues(DriverSettings settings)
{
- SetActiveValues(
- settings.sensitivity.x,
- settings.sensitivity.y,
- settings.rotation,
- (int)settings.modes.x,
- (int)settings.modes.y,
- settings.args.x,
- settings.args.y,
- settings.combineMagnitudes);
+ Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y);
+ Rotation.SetActiveValue(settings.rotation);
+
+ WholeVectorCheckBox.Checked = settings.combineMagnitudes;
+ ByComponentVectorCheckBox.Checked = !settings.combineMagnitudes;
+ ByComponentVectorXYLock.Checked = settings.args.x.Equals(settings.args.y);
+ OptionSetX.SetActiveValues(ref settings.args.x);
+ OptionSetY.SetActiveValues(ref settings.args.y);
Directionality.SetActiveValues(settings);
diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs
deleted file mode 100644
index c459c50..0000000
--- a/grapher/Models/Options/CapOptions.cs
+++ /dev/null
@@ -1,225 +0,0 @@
-using grapher.Models.Options;
-using System;
-using System.Windows.Forms;
-
-namespace grapher
-{
- public class CapOptions : OptionBase
- {
- #region Constants
-
-
- #endregion Constants
-
- #region Constructors
-
- public CapOptions(
- ToolStripMenuItem velocityGainCapCheck,
- ToolStripMenuItem legacyCapCheck,
- Option capOption)
- {
-
- VelocityGainCapCheck = velocityGainCapCheck;
- LegacyCapCheck = legacyCapCheck;
- CapOption = capOption;
-
- LegacyCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick);
- VelocityGainCapCheck.Click += new System.EventHandler(OnVelocityGainCapCheckClick);
-
- LegacyCapCheck.CheckedChanged += new System.EventHandler(OnSensitivityCapCheckedChange);
- VelocityGainCapCheck.CheckedChanged += new System.EventHandler(OnVelocityGainCapCheckedChange);
-
- EnableVelocityGainCap();
- }
-
- #endregion Constructors
-
- #region Properties
-
- public ToolStripMenuItem LegacyCapCheck { get; }
-
- public ToolStripMenuItem VelocityGainCapCheck { get; }
-
- public Option CapOption { get; }
-
- public bool IsSensitivityGain { get; private set; }
-
- public double SensitivityCap {
- get
- {
- if (IsSensitivityGain)
- {
- return CapOption.Field.Data;
- }
- else
- {
- return 0;
- }
- }
- }
-
- public double VelocityGainCap {
- get
- {
- if (IsSensitivityGain)
- {
- return 0;
- }
- else
- {
- return CapOption.Field.Data;
- }
- }
- }
-
- public override int Top
- {
- get
- {
- return CapOption.Top;
- }
- set
- {
- CapOption.Top = value;
- }
- }
-
- public override int Height
- {
- get
- {
- return CapOption.Height;
- }
- }
-
- public override int Left
- {
- get
- {
- return CapOption.Left;
- }
- set
- {
- CapOption.Left = value;
- }
- }
-
- public override int Width
- {
- get
- {
- return CapOption.Width;
- }
- set
- {
- CapOption.Width = value;
- }
- }
-
- public override bool Visible
- {
- get
- {
- return CapOption.Visible;
- }
- }
-
- #endregion Properties
-
- #region Methods
-
- public override void Hide()
- {
- CapOption.Hide();
- }
-
- public void Show()
- {
- CapOption.Show();
- }
-
- public override void Show(string name)
- {
- CapOption.Show(name);
- }
-
- public void SnapTo(Option option)
- {
- Top = option.Top + option.Height + Constants.OptionVerticalSeperation;
- }
-
-
- public void SetActiveValues(double gainCap, double sensCap, bool capGainEnabled)
- {
- if (capGainEnabled)
- {
- CapOption.ActiveValueLabel.FormatString = Constants.GainCapFormatString;
- CapOption.ActiveValueLabel.Prefix = "Gain";
- CapOption.SetActiveValue(gainCap);
- LegacyCapCheck.Checked = false;
- VelocityGainCapCheck.Checked = true;
- }
- else
- {
- CapOption.ActiveValueLabel.FormatString = Constants.DefaultActiveValueFormatString;
- CapOption.ActiveValueLabel.Prefix = string.Empty;
- CapOption.SetActiveValue(sensCap);
- LegacyCapCheck.Checked = true;
- VelocityGainCapCheck.Checked = false;
- }
- }
-
- public override void AlignActiveValues()
- {
- CapOption.AlignActiveValues();
- }
-
- void OnSensitivityCapCheckClick(object sender, EventArgs e)
- {
- if (!LegacyCapCheck.Checked)
- {
- VelocityGainCapCheck.Checked = false;
- LegacyCapCheck.Checked = true;
- }
- }
-
- void OnVelocityGainCapCheckClick(object sender, EventArgs e)
- {
- if (!VelocityGainCapCheck.Checked)
- {
- VelocityGainCapCheck.Checked = true;
- LegacyCapCheck.Checked = false;
- }
- }
-
- void OnSensitivityCapCheckedChange(object sender, EventArgs e)
- {
- if (LegacyCapCheck.Checked)
- {
- EnableSensitivityCap();
- }
- }
-
- void OnVelocityGainCapCheckedChange(object sender, EventArgs e)
- {
- if (VelocityGainCapCheck.Checked)
- {
- EnableVelocityGainCap();
- }
- }
-
- void EnableSensitivityCap()
- {
- IsSensitivityGain = true;
- CapOption.SetName("Sensitivity Cap");
- }
-
- void EnableVelocityGainCap()
- {
- IsSensitivityGain = false;
- CapOption.SetName("Velocity Gain Cap");
- }
-
- #endregion Methods
- }
-}
diff --git a/grapher/Models/Options/CheckBoxOption.cs b/grapher/Models/Options/CheckBoxOption.cs
new file mode 100644
index 0000000..abf96d3
--- /dev/null
+++ b/grapher/Models/Options/CheckBoxOption.cs
@@ -0,0 +1,109 @@
+using System.Windows.Forms;
+
+namespace grapher.Models.Options
+{
+ public class CheckBoxOption : OptionBase
+ {
+ public CheckBoxOption(
+ CheckBox checkBox,
+ ActiveValueLabel activeValueLabel)
+ {
+ CheckBox = checkBox;
+ ActiveValueLabel = activeValueLabel;
+ Show(string.Empty);
+ }
+
+ public CheckBox CheckBox { get; }
+
+ public ActiveValueLabel ActiveValueLabel { get; }
+
+ public override bool Visible
+ {
+ get
+ {
+ return CheckBox.Visible || ShouldShow;
+ }
+ }
+
+ public override int Left
+ {
+ get
+ {
+ return CheckBox.Left;
+ }
+ set
+ {
+ CheckBox.Left = value;
+ }
+ }
+
+ public override int Height
+ {
+ get
+ {
+ return CheckBox.Height;
+ }
+ }
+
+ public override int Top
+ {
+ get
+ {
+ return CheckBox.Top;
+ }
+ set
+ {
+ CheckBox.Top = value;
+ ActiveValueLabel.Top = value;
+ }
+ }
+
+ public override int Width
+ {
+ get
+ {
+ return CheckBox.Width;
+ }
+ set
+ {
+ CheckBox.Width = value;
+ }
+ }
+
+ /// <summary>
+ /// For some reason, setting CheckBox.Show() does not result in visible not being true on GUI startup.
+ /// This is inconsistent with the other options, which do.
+ /// Keep this bool for allowing Visible to still be the signal for option snapping.
+ /// </summary>
+ private bool ShouldShow { get; set; }
+
+ public override void AlignActiveValues()
+ {
+ ActiveValueLabel.Align();
+ }
+
+ public override void Hide()
+ {
+ CheckBox.Hide();
+ ShouldShow = false;
+ CheckBox.Enabled = false;
+ ActiveValueLabel.Hide();
+ }
+
+ public override void Show(string Name)
+ {
+ CheckBox.Show();
+ ShouldShow = true;
+ CheckBox.Enabled = true;
+ CheckBox.Name = Name;
+ ActiveValueLabel.Show();
+ }
+
+ public void SetActiveValue(bool legacy)
+ {
+ CheckBox.Checked = !legacy;
+ var activeValueString = legacy ? "Legacy" : "Gain";
+ ActiveValueLabel.SetValue(activeValueString);
+ }
+ }
+}
diff --git a/grapher/Models/Options/LUT/LUTPanelOptions.cs b/grapher/Models/Options/LUT/LUTPanelOptions.cs
new file mode 100644
index 0000000..6b13cdc
--- /dev/null
+++ b/grapher/Models/Options/LUT/LUTPanelOptions.cs
@@ -0,0 +1,217 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options.LUT
+{
+ public class LUTPanelOptions : OptionBase
+ {
+ public const int PanelPadding = 5;
+ public const int PanelHeight = 100;
+
+ public LUTPanelOptions(RichTextBox pointsTextBox, RichTextBox activeValuesTextBox)
+ {
+ PointsTextBox = pointsTextBox;
+ PointsTextBox.Height = PanelHeight;
+
+ ActiveValuesTextBox = activeValuesTextBox;
+ ActiveValuesTextBox.Height = PanelHeight;
+ ActiveValuesTextBox.ReadOnly = true;
+ }
+
+ public RichTextBox PointsTextBox
+ {
+ get;
+ }
+
+ public RichTextBox ActiveValuesTextBox
+ {
+ get;
+ }
+
+ public override bool Visible
+ {
+ get
+ {
+ return PointsTextBox.Visible || ShouldShow;
+ }
+ }
+
+ public override int Top
+ {
+ get
+ {
+ return PointsTextBox.Top;
+ }
+ set
+ {
+ PointsTextBox.Top = value;
+ ActiveValuesTextBox.Top = value;
+ }
+ }
+
+ public override int Height
+ {
+ get
+ {
+ return PointsTextBox.Height;
+ }
+ }
+
+ public override int Left
+ {
+ get
+ {
+ return PointsTextBox.Left;
+ }
+ set
+ {
+ PointsTextBox.Left = value;
+ AlignActivePanelToPointsTextBox();
+ }
+ }
+
+ public override int Width
+ {
+ get
+ {
+ return PointsTextBox.Width;
+ }
+ set
+ {
+ var panelWidth = value / 2 - PanelPadding;
+ PointsTextBox.Width = panelWidth;
+ ActiveValuesTextBox.Width = panelWidth;
+ AlignActivePanelToPointsTextBox();
+ }
+ }
+
+ private bool ShouldShow { get; set; }
+
+ public override void Hide()
+ {
+ PointsTextBox.Hide();
+ ActiveValuesTextBox.Hide();
+ ShouldShow = false;
+ }
+
+ public override void Show(string name)
+ {
+ PointsTextBox.Show();
+ ActiveValuesTextBox.Show();
+ ShouldShow = true;
+ }
+
+ public override void AlignActiveValues()
+ {
+ // Nothing to do here.
+ }
+
+ public void SetActiveValues(IEnumerable<Vec2<float>> activePoints, int length)
+ {
+ if (length > 0 && activePoints.First().x != 0)
+ {
+ ActiveValuesTextBox.Text = PointsToActiveValuesText(activePoints, length);
+ }
+ else
+ {
+ ActiveValuesTextBox.Text = string.Empty;
+ }
+ }
+
+ public (Vec2<float>[], int length) GetPoints()
+ {
+ return UserTextToPoints(PointsTextBox.Text);
+ }
+
+ private static (Vec2<float>[], int length) UserTextToPoints(string userText)
+ {
+ if (string.IsNullOrWhiteSpace(userText))
+ {
+ throw new Exception("Text must be entered in text box to fill Look Up Table.");
+ }
+
+ Vec2<float>[] points = new Vec2<float>[256];
+
+ var userTextSplit = userText.Trim().Trim(';').Split(';');
+ int index = 0;
+ float lastX = 0;
+
+ foreach(var pointEntry in userTextSplit)
+ {
+ var pointSplit = pointEntry.Trim().Split(',');
+
+ if (pointSplit.Length != 2)
+ {
+ throw new Exception($"Point at index {index} is malformed. Expected format: x,y; Given: {pointEntry.Trim()}");
+ }
+
+ float x;
+ float y;
+
+ try
+ {
+ x = float.Parse(pointSplit[0]);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"X-value for point at index {index} is malformed. Expected: float. Given: {pointSplit[0]}", ex);
+ }
+
+ if (x <= 0)
+ {
+ throw new Exception($"X-value for point at index {index} is less than or equal to 0. Point (0,0) is implied and should not be specified in points text.");
+ }
+
+ if (x <= lastX)
+ {
+ throw new Exception($"X-value for point at index {index} is less than or equal to previous x-value. Value: {x} Previous: {lastX}");
+ }
+
+ lastX = x;
+
+ try
+ {
+ y = float.Parse(pointSplit[1]);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"Y-value for point at index {index} is malformed. Expected: float. Given: {pointSplit[1]}", ex);
+ }
+
+ if (y <= 0)
+ {
+ throw new Exception($"Y-value for point at index {index} is less than or equal to 0. Value: {y}");
+ }
+
+ points[index] = new Vec2<float> { x = x, y = y };
+
+ index++;
+ }
+
+ return (points, userTextSplit.Length);
+ }
+
+ private void AlignActivePanelToPointsTextBox()
+ {
+ ActiveValuesTextBox.Left = PointsTextBox.Right + PanelPadding;
+ }
+
+ private string PointsToActiveValuesText(IEnumerable<Vec2<float>> points, int length)
+ {
+ StringBuilder builder = new StringBuilder();
+
+ for(int i = 0; i < length; i++)
+ {
+ var point = points.ElementAt(i);
+ builder.AppendLine($"{point.x},{point.y};");
+ }
+
+ return builder.ToString();
+ }
+ }
+}
diff --git a/grapher/Models/Options/LUT/LUTPointOption.cs b/grapher/Models/Options/LUT/LUTPointOption.cs
new file mode 100644
index 0000000..6afee4f
--- /dev/null
+++ b/grapher/Models/Options/LUT/LUTPointOption.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options.LUT
+{
+ public class LUTPointOption
+ {
+ public LUTPointOption(Form form)
+ {
+ FieldX = new Field(new System.Windows.Forms.TextBox(), form, 0);
+ FieldY = new Field(new System.Windows.Forms.TextBox(), form, 0);
+ }
+
+ public double X { get => FieldX.Data; }
+
+ public double Y { get => FieldY.Data; }
+
+ public int Top
+ {
+ get
+ {
+ return FieldX.Top;
+ }
+ set
+ {
+ FieldX.Top = value;
+ FieldY.Top = value;
+ }
+ }
+
+ private Field FieldX { get; }
+
+ private Field FieldY { get; }
+ }
+}
diff --git a/grapher/Models/Options/LUT/LutApplyOptions.cs b/grapher/Models/Options/LUT/LutApplyOptions.cs
new file mode 100644
index 0000000..7d8c737
--- /dev/null
+++ b/grapher/Models/Options/LUT/LutApplyOptions.cs
@@ -0,0 +1,183 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options.LUT
+{
+ public class LutApplyOptions : OptionBase
+ {
+ public const string LUTApplyOptionsLabelText = "Apply as:";
+ public const int LUTApplyLabelDropdownSeparation = 4;
+
+ public enum LutApplyType
+ {
+ Sensitivity,
+ Velocity
+ }
+
+ public class LutApplyOption
+ {
+ public LutApplyType Type { get; set; }
+
+ public string Name => Type.ToString();
+
+ public override string ToString() => Name;
+ }
+
+ public static readonly LutApplyOption Sensitivity = new LutApplyOption
+ {
+ Type = LutApplyType.Sensitivity,
+ };
+
+ public static readonly LutApplyOption Velocity = new LutApplyOption
+ {
+ Type = LutApplyType.Velocity,
+ };
+
+ public LutApplyOptions(
+ Label label,
+ ComboBox applyOptionsDropdown,
+ ActiveValueLabel lutApplyActiveValue)
+ {
+ ApplyOptions = applyOptionsDropdown;
+ ApplyOptions.Items.Clear();
+ ApplyOptions.Items.AddRange(
+ new LutApplyOption[]
+ {
+ Sensitivity,
+ Velocity,
+ });
+
+ Label = label;
+ Label.Text = LUTApplyOptionsLabelText;
+ Label.AutoSize = false;
+ Label.Width = 50;
+
+ ActiveValueLabel = lutApplyActiveValue;
+ }
+
+ public LutApplyType ApplyType { get => ApplyOption.Type; }
+
+ public LutApplyOption ApplyOption {
+ get
+ {
+ return ApplyOptions.SelectedItem as LutApplyOption;
+ }
+ set
+ {
+ ApplyOptions.SelectedItem = value;
+ }
+ }
+
+ public Label Label { get; }
+
+ public ActiveValueLabel ActiveValueLabel { get; }
+
+ public ComboBox ApplyOptions { get; }
+
+ public override bool Visible
+ {
+ get
+ {
+ return Label.Visible || ShouldShow;
+ }
+ }
+
+ public override int Left
+ {
+ get
+ {
+ return Label.Left;
+ }
+ set
+ {
+ Label.Left = value;
+ ApplyOptions.Left = Label.Left + Label.Width + LUTApplyLabelDropdownSeparation;
+ }
+ }
+
+ public override int Height
+ {
+ get
+ {
+ return Label.Height;
+ }
+ }
+
+ public override int Top
+ {
+ get
+ {
+ return Label.Top;
+ }
+ set
+ {
+ ApplyOptions.Top = value;
+ Label.Top = (ApplyOptions.Height - Label.Height) / 2 + ApplyOptions.Top;
+ ActiveValueLabel.Top = value;
+ }
+ }
+
+ public override int Width
+ {
+ get
+ {
+ return Label.Width;
+ }
+ set
+ {
+ ApplyOptions.Width = value - Label.Width - Constants.OptionLabelBoxSeperation;
+ }
+ }
+
+ private bool ShouldShow { get; set; }
+
+ public override void Hide()
+ {
+ Label.Hide();
+ ApplyOptions.Hide();
+ ActiveValueLabel.Hide();
+ ShouldShow = false;
+ }
+
+ public override void Show(string labelText)
+ {
+ Label.Show();
+
+ if (!string.IsNullOrWhiteSpace(labelText))
+ {
+ Label.Text = labelText;
+ }
+
+ ApplyOptions.Show();
+ ActiveValueLabel.Show();
+ ShouldShow = true;
+ }
+
+ public override void AlignActiveValues()
+ {
+ ActiveValueLabel.Align();
+ }
+
+ public void SetActiveValue(bool applyAsVelocity)
+ {
+ ApplyOption = ApplyOptionFromSettings(applyAsVelocity);
+ ActiveValueLabel.SetValue(ApplyOption.Name);
+ }
+
+ public LutApplyOption ApplyOptionFromSettings(bool applyAsVelocity)
+ {
+ if (applyAsVelocity)
+ {
+ return Velocity;
+ }
+ else
+ {
+ return Sensitivity;
+ }
+ }
+ }
+}
diff --git a/grapher/Models/Options/OffsetOptions.cs b/grapher/Models/Options/OffsetOptions.cs
index 6638ed7..42d2d92 100644
--- a/grapher/Models/Options/OffsetOptions.cs
+++ b/grapher/Models/Options/OffsetOptions.cs
@@ -106,12 +106,9 @@ namespace grapher.Models.Options
OffsetOption.Show(name);
}
- public void SetActiveValue(double offset, bool legacy)
+ public void SetActiveValue(double offset)
{
OffsetOption.SetActiveValue(offset);
-
- VelocityGainOffsetCheck.Checked = !legacy;
- LegacyOffsetCheck.Checked = legacy;
}
public override void AlignActiveValues()
diff --git a/grapher/Models/Options/TextOption.cs b/grapher/Models/Options/TextOption.cs
new file mode 100644
index 0000000..1f8034d
--- /dev/null
+++ b/grapher/Models/Options/TextOption.cs
@@ -0,0 +1,129 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options
+{
+ public class TextOption : OptionBase
+ {
+ #region Constants
+
+ public const string LUTLayoutExpandedText = "This mode is for experts only. Format: x1,y1;x2,y2;...xn,yn;";
+ public const string LUTLayoutShortenedText = "Experts only.";
+
+ #endregion Constants
+
+ #region Constructors
+
+ public TextOption(Label label)
+ {
+ Label = label;
+ Label.AutoSize = true;
+ }
+
+ #endregion Constructors
+
+ #region Properties
+
+ private Label Label { get; }
+
+ private string ExpandedText { get; set; }
+
+ private string ShortenedText { get; set; }
+
+ public override bool Visible
+ {
+ get
+ {
+ return Label.Visible || ShouldShow;
+ }
+ }
+
+ public override int Top
+ {
+ get
+ {
+ return Label.Top;
+ }
+ set
+ {
+ Label.Top = value;
+ }
+ }
+
+ public override int Height
+ {
+ get
+ {
+ return Label.Height;
+ }
+ }
+
+ public override int Width
+ {
+ get
+ {
+ return Label.Width;
+ }
+ set
+ {
+ Label.MaximumSize = new System.Drawing.Size(value, 0);
+ }
+ }
+
+ public override int Left
+ {
+ get
+ {
+ return Label.Left;
+ }
+ set
+ {
+ Label.Left = value;
+ }
+ }
+
+ private bool ShouldShow
+ {
+ get; set;
+ }
+
+ public override void Hide()
+ {
+ Label.Hide();
+ ShouldShow = false;
+ }
+
+ public override void Show(string Name)
+ {
+ Label.Show();
+ ShouldShow = true;
+ }
+
+ public void Expand()
+ {
+ Label.Text = ExpandedText;
+ }
+
+ public void Shorten()
+ {
+ Label.Text = ShortenedText;
+ }
+
+ public void SetText(string expandedText, string shortenedText)
+ {
+ ExpandedText = expandedText;
+ ShortenedText = shortenedText;
+ }
+
+ public override void AlignActiveValues()
+ {
+ // Nothing to do here
+ }
+
+ #endregion Properties
+ }
+}