summaryrefslogtreecommitdiff
path: root/grapher/Models/Options
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-09-24 02:04:43 -0400
committerGitHub <[email protected]>2021-09-24 02:04:43 -0400
commit2896b8a09ce42e965705c58593b8738adc454f7f (patch)
tree71e4d0cff60b5a1ad11427d78e1f8c7b775e5690 /grapher/Models/Options
parentMerge pull request #107 from a1xd/1.5.0-fix (diff)
parentmake note clearer (diff)
downloadrawaccel-dark-mode.tar.xz
rawaccel-dark-mode.zip
Merge pull request #108 from a1xd/1.6r2HEADv1.6.0masterdark-mode
v1.6
Diffstat (limited to 'grapher/Models/Options')
-rw-r--r--grapher/Models/Options/AccelOptionSet.cs2
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs176
-rw-r--r--grapher/Models/Options/ApplyOptions.cs34
-rw-r--r--grapher/Models/Options/Cap/CapOptions.cs249
-rw-r--r--grapher/Models/Options/Cap/CapTypeOptions.cs160
-rw-r--r--grapher/Models/Options/CheckBoxOption.cs9
-rw-r--r--grapher/Models/Options/ComboBoxOptionsBase.cs124
-rw-r--r--grapher/Models/Options/Directionality/DirectionalityOptions.cs21
-rw-r--r--grapher/Models/Options/LUT/LUTPanelOptions.cs27
-rw-r--r--grapher/Models/Options/LUT/LutApplyOptions.cs138
-rw-r--r--grapher/Models/Options/LockableOption.cs137
-rw-r--r--grapher/Models/Options/SwitchOption.cs162
12 files changed, 1019 insertions, 220 deletions
diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs
index 75eb017..3451402 100644
--- a/grapher/Models/Options/AccelOptionSet.cs
+++ b/grapher/Models/Options/AccelOptionSet.cs
@@ -99,7 +99,7 @@ namespace grapher.Models.Options
Options.Top = TopAnchor;
}
- public void SetArgs(ref AccelArgs args)
+ public void SetArgsFromActiveValues(ref AccelArgs args)
{
Options.SetArgs(ref args);
}
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index 44c9ea8..359b6b8 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -1,10 +1,8 @@
using grapher.Layouts;
using grapher.Models.Options;
+using grapher.Models.Options.Cap;
using grapher.Models.Options.LUT;
-using grapher.Models.Serialized;
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Windows.Forms;
namespace grapher
@@ -21,7 +19,6 @@ namespace grapher
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
@@ -30,14 +27,15 @@ namespace grapher
public AccelTypeOptions(
ComboBox accelDropdown,
CheckBoxOption gainSwitch,
- Option acceleration,
+ CapOptions classicCap,
+ CapOptions powerCap,
+ Option outputJump,
+ Option outputOffset,
Option decayRate,
Option growthRate,
Option smooth,
- Option scale,
- Option cap,
- Option weight,
- Option offset,
+ Option inputJump,
+ Option inputOffset,
Option limit,
Option powerClassic,
Option exponent,
@@ -66,17 +64,18 @@ namespace grapher
AccelDropdown.SelectedIndexChanged += new System.EventHandler(OnIndexChanged);
GainSwitch = gainSwitch;
- Acceleration = acceleration;
DecayRate = decayRate;
GrowthRate = growthRate;
Smooth = smooth;
- Scale = scale;
- Cap = cap;
- Weight = weight;
- Offset = offset;
+ ClassicCap = classicCap;
+ PowerCap = powerCap;
+ InputJump = inputJump;
+ InputOffset = inputOffset;
Limit = limit;
PowerClassic = powerClassic;
Exponent = exponent;
+ OutputJump = outputJump;
+ OutputOffset = outputOffset;
Midpoint = midpoint;
WriteButton = writeButton;
AccelTypeActiveValue = accelTypeActiveValue;
@@ -86,7 +85,7 @@ namespace grapher
AccelTypeActiveValue.Left = AccelDropdown.Left + AccelDropdown.Width;
AccelTypeActiveValue.Height = AccelDropdown.Height;
- GainSwitch.Left = Acceleration.Field.Left;
+ GainSwitch.Left = DecayRate.Field.Left;
LutPanel.Left = AccelDropdown.Left;
LutPanel.Width = AccelDropdown.Width + AccelTypeActiveValue.Width;
@@ -109,21 +108,23 @@ namespace grapher
public ActiveValueLabel AccelTypeActiveValue { get; }
- public Option Acceleration { get; }
-
public Option DecayRate { get; }
public Option GrowthRate { get; }
public Option Smooth { get; }
- public Option Scale { get; }
+ public CapOptions ClassicCap { get; }
+
+ public CapOptions PowerCap { get; }
+
+ public Option InputJump { get; }
- public Option Cap { get; }
+ public Option OutputJump { get; }
- public Option Weight { get; }
+ public Option InputOffset { get; }
- public Option Offset { get; }
+ public Option OutputOffset { get; }
public Option Limit { get; }
@@ -229,14 +230,15 @@ namespace grapher
AccelTypeActiveValue.Hide();
GainSwitch.Hide();
- Acceleration.Hide();
DecayRate.Hide();
GrowthRate.Hide();
Smooth.Hide();
- Scale.Hide();
- Cap.Hide();
- Weight.Hide();
- Offset.Hide();
+ ClassicCap.Hide();
+ PowerCap.Hide();
+ OutputOffset.Hide();
+ InputOffset.Hide();
+ InputJump.Hide();
+ OutputJump.Hide();
Limit.Hide();
PowerClassic.Hide();
Exponent.Hide();
@@ -262,21 +264,30 @@ namespace grapher
{
AccelerationType = AccelTypeFromSettings(ref args);
AccelTypeActiveValue.SetValue(AccelerationType.ActiveName);
- GainSwitch.SetActiveValue(args.legacy);
- Weight.SetActiveValue(args.weight);
- Cap.SetActiveValue(args.cap);
- Offset.SetActiveValue(args.offset);
- Acceleration.SetActiveValue(args.accelClassic);
+ GainSwitch.SetActiveValue(args.gain);
+ ClassicCap.SetActiveValues(
+ args.acceleration,
+ args.cap.x,
+ args.cap.y,
+ args.capMode);
+ PowerCap.SetActiveValues(
+ args.scale,
+ args.cap.x,
+ args.cap.y,
+ args.capMode);
+ InputJump.SetActiveValue(args.cap.x);
+ OutputJump.SetActiveValue(args.cap.y);
+ OutputOffset.SetActiveValue(args.outputOffset);
+ InputOffset.SetActiveValue(args.inputOffset);
DecayRate.SetActiveValue(args.decayRate);
GrowthRate.SetActiveValue(args.growthRate);
Smooth.SetActiveValue(args.smooth);
- Scale.SetActiveValue(args.scale);
Limit.SetActiveValue((args.mode == AccelMode.motivity) ? args.motivity : args.limit);
- PowerClassic.SetActiveValue(args.power);
- Exponent.SetActiveValue(args.exponent);
+ PowerClassic.SetActiveValue(args.exponentClassic);
+ Exponent.SetActiveValue(args.exponentPower);
Midpoint.SetActiveValue(args.midpoint);
- LutPanel.SetActiveValues(args.tableData.points, args.tableData.length);
- LutApply.SetActiveValue(args.tableData.velocity);
+ LutPanel.SetActiveValues(args.data, args.length, args.mode);
+ LutApply.SetActiveValue(args.gain);
}
public void ShowFull()
@@ -286,8 +297,8 @@ namespace grapher
AccelDropdown.Text = Constants.AccelDropDownDefaultFullText;
}
- Left = Acceleration.Left + Constants.DropDownLeftSeparation;
- Width = Acceleration.Width - Constants.DropDownLeftSeparation;
+ Left = DecayRate.Left + Constants.DropDownLeftSeparation;
+ Width = DecayRate.Width - Constants.DropDownLeftSeparation;
LutText.Expand();
HandleLUTOptionsOnResize();
@@ -300,25 +311,38 @@ namespace grapher
AccelDropdown.Text = Constants.AccelDropDownDefaultShortText;
}
- Left = Acceleration.Field.Left;
- Width = Acceleration.Field.Width;
+ Left = DecayRate.Field.Left;
+ Width = DecayRate.Field.Width;
LutText.Shorten();
}
public void SetArgs(ref AccelArgs args)
{
- if (AccelerationType == Unsupported) throw new NotImplementedException();
-
args.mode = AccelerationType.Mode;
- args.legacy = !GainSwitch.CheckBox.Checked;
+ args.gain = LutPanel.Visible ?
+ LutApply.ApplyType == LutApplyOptions.LutApplyType.Velocity :
+ GainSwitch.CheckBox.Checked;
- if (Acceleration.Visible) args.accelClassic = Acceleration.Field.Data;
if (DecayRate.Visible) args.decayRate = DecayRate.Field.Data;
if (GrowthRate.Visible) args.growthRate = GrowthRate.Field.Data;
if (Smooth.Visible) args.smooth = Smooth.Field.Data;
- if (Scale.Visible) args.scale = Scale.Field.Data;
- if (Cap.Visible) args.cap = Cap.Field.Data;
+ if (ClassicCap.Visible)
+ {
+ args.acceleration = ClassicCap.Slope.Field.Data;
+ args.cap.x = ClassicCap.In.Field.Data;
+ args.cap.y = ClassicCap.Out.Field.Data;
+ args.capMode = ClassicCap.CapTypeOptions.GetSelectedCapMode();
+ }
+ if (PowerCap.Visible)
+ {
+ args.scale = PowerCap.Slope.Field.Data;
+ args.cap.x = PowerCap.In.Field.Data;
+ args.cap.y = PowerCap.Out.Field.Data;
+ args.capMode = PowerCap.CapTypeOptions.GetSelectedCapMode();
+ }
+ if (InputJump.Visible) args.cap.x = InputJump.Field.Data;
+ if (OutputJump.Visible) args.cap.y = OutputJump.Field.Data;
if (Limit.Visible)
{
if (args.mode == AccelMode.motivity)
@@ -328,34 +352,43 @@ namespace grapher
else
{
args.limit = Limit.Field.Data;
- }
+ }
}
- if (PowerClassic.Visible) args.power = PowerClassic.Field.Data;
- if (Exponent.Visible)args.exponent = Exponent.Field.Data;
- if (Offset.Visible) args.offset = Offset.Field.Data;
+ if (PowerClassic.Visible) args.exponentClassic = PowerClassic.Field.Data;
+ if (Exponent.Visible) args.exponentPower = Exponent.Field.Data;
+ if (InputOffset.Visible) args.inputOffset = InputOffset.Field.Data;
+ if (OutputOffset.Visible) args.outputOffset = OutputOffset.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;
+ args.length = length * 2;
+
+ for (int i = 0; i < length; i++)
+ {
+ ref var p = ref points[i];
+ var data_idx = i * 2;
+ args.data[data_idx] = p.x;
+ args.data[data_idx + 1] = p.y;
+ }
}
- if (LutApply.Visible) args.tableData.velocity = LutApply.ApplyType == LutApplyOptions.LutApplyType.Velocity;
+
}
public override void AlignActiveValues()
{
AccelTypeActiveValue.Align();
GainSwitch.AlignActiveValues();
- Acceleration.AlignActiveValues();
DecayRate.AlignActiveValues();
GrowthRate.AlignActiveValues();
Smooth.AlignActiveValues();
- Scale.AlignActiveValues();
- Cap.AlignActiveValues();
- Offset.AlignActiveValues();
- Weight.AlignActiveValues();
+ ClassicCap.AlignActiveValues();
+ PowerCap.AlignActiveValues();
+ OutputOffset.AlignActiveValues();
+ InputOffset.AlignActiveValues();
+ OutputJump.AlignActiveValues();
+ InputJump.AlignActiveValues();
Limit.AlignActiveValues();
PowerClassic.AlignActiveValues();
Exponent.AlignActiveValues();
@@ -367,7 +400,7 @@ namespace grapher
{
LutText.Left = AccelDropdown.Left;
LutPanel.Left = GainSwitch.Left - 100;
- LutPanel.Width = Acceleration.ActiveValueLabel.CenteringLabel.Right - LutPanel.Left;
+ LutPanel.Width = DecayRate.ActiveValueLabel.CenteringLabel.Right - LutPanel.Left;
LutApply.Left = LutPanel.Left;
LutApply.Width = AccelDropdown.Right - LutPanel.Left;
}
@@ -387,17 +420,18 @@ namespace grapher
AccelerationType.Layout(
GainSwitch,
- Acceleration,
+ ClassicCap,
+ PowerCap,
DecayRate,
GrowthRate,
Smooth,
- Scale,
- Cap,
- Weight,
- Offset,
+ InputJump,
+ InputOffset,
Limit,
PowerClassic,
Exponent,
+ OutputJump,
+ OutputOffset,
Midpoint,
LutText,
LutPanel,
@@ -407,19 +441,9 @@ namespace grapher
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.classic: return (args.exponentClassic == 2) ? Linear : Classic;
case AccelMode.jump: return Jump;
case AccelMode.natural: return Natural;
case AccelMode.motivity: return Motivity;
diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs
index 06854b8..4946414 100644
--- a/grapher/Models/Options/ApplyOptions.cs
+++ b/grapher/Models/Options/ApplyOptions.cs
@@ -15,7 +15,8 @@ namespace grapher.Models.Options
AccelOptionSet optionSetX,
AccelOptionSet optionSetY,
DirectionalityOptions directionalityOptions,
- OptionXY sensitivity,
+ Option sensitivity,
+ LockableOption yxRatio,
Option rotation,
Label lockXYLabel,
AccelCharts accelCharts)
@@ -34,6 +35,7 @@ namespace grapher.Models.Options
OptionSetX = optionSetX;
OptionSetY = optionSetY;
Sensitivity = sensitivity;
+ YToXRatio = yxRatio;
Rotation = rotation;
LockXYLabel = lockXYLabel;
AccelCharts = accelCharts;
@@ -44,7 +46,8 @@ namespace grapher.Models.Options
ByComponentVectorXYLock.CheckedChanged += new System.EventHandler(OnByComponentXYLockChecked);
ByComponentVectorXYLock.Checked = true;
- Rotation.SnapTo(Sensitivity);
+ YToXRatio.SnapTo(Sensitivity);
+ Rotation.SnapTo(YToXRatio);
EnableWholeApplication();
}
@@ -65,7 +68,9 @@ namespace grapher.Models.Options
public DirectionalityOptions Directionality { get; }
- public OptionXY Sensitivity { get; }
+ public Option Sensitivity { get; }
+
+ public LockableOption YToXRatio { get; }
public Option Rotation { get; }
@@ -81,30 +86,31 @@ namespace grapher.Models.Options
#region Methods
- public void SetArgs(ref Vec2<AccelArgs> args)
+ public void SetArgsFromActiveValues(ref AccelArgs argsX, ref AccelArgs argsY)
{
- OptionSetX.SetArgs(ref args.x);
+ OptionSetX.SetArgsFromActiveValues(ref argsX);
if (ByComponentVectorXYLock.Checked)
{
- OptionSetX.SetArgs(ref args.y);
+ OptionSetX.SetArgsFromActiveValues(ref argsY);
}
else
{
- OptionSetY.SetArgs(ref args.y);
+ OptionSetY.SetArgsFromActiveValues(ref argsY);
}
}
- public void SetActiveValues(DriverSettings settings)
+ public void SetActiveValues(Profile settings)
{
- Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y);
+ Sensitivity.SetActiveValue(settings.sensitivity);
+ YToXRatio.SetActiveValue(settings.yxSensRatio);
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);
+ ByComponentVectorXYLock.Checked = settings.argsX.Equals(settings.argsY);
+ OptionSetX.SetActiveValues(ref settings.argsX);
+ OptionSetY.SetActiveValues(ref settings.argsY);
Directionality.SetActiveValues(settings);
@@ -210,8 +216,8 @@ namespace grapher.Models.Options
LockXYLabel.Width = (AccelCharts.Left - OptionSetX.ActiveValuesTitle.Left) / 2;
OptionSetX.ActiveValuesTitle.Width = LockXYLabel.Width;
LockXYLabel.Left = OptionSetX.ActiveValuesTitle.Left + OptionSetX.ActiveValuesTitle.Width;
- Sensitivity.Fields.LockCheckBox.Left = LockXYLabel.Left + LockXYLabel.Width / 2 - Sensitivity.Fields.LockCheckBox.Width / 2;
- ByComponentVectorXYLock.Left = Sensitivity.Fields.LockCheckBox.Left;
+ YToXRatio.LockBox.Left = LockXYLabel.Left + LockXYLabel.Width / 2 - YToXRatio.LockBox.Width / 2;
+ ByComponentVectorXYLock.Left = YToXRatio.LockBox.Left;
AlignActiveValues();
}
diff --git a/grapher/Models/Options/Cap/CapOptions.cs b/grapher/Models/Options/Cap/CapOptions.cs
new file mode 100644
index 0000000..68326e5
--- /dev/null
+++ b/grapher/Models/Options/Cap/CapOptions.cs
@@ -0,0 +1,249 @@
+using System;
+using System.Windows.Forms;
+using static grapher.Models.Options.Cap.CapTypeOptions;
+
+namespace grapher.Models.Options.Cap
+{
+ public class CapOptions : OptionBase
+ {
+ #region Constants
+
+ public const string InCapLabel = "Cap: Input";
+ public const string OutCapLabel = "Cap: Output";
+
+ #endregion Constants
+
+ #region Fields
+
+ private int _top;
+
+ #endregion Fields
+
+ #region Constructors
+
+ public CapOptions(
+ CapTypeOptions capTypeOptions,
+ Option capIn,
+ Option capOut,
+ Option slope,
+ Option disableOptionInBoth = null,
+ CheckBoxOption disableInBoth = null)
+ {
+ CapTypeOptions = capTypeOptions;
+ In = capIn;
+ Out = capOut;
+ Slope = slope;
+ DisableOptionInBoth = disableOptionInBoth;
+ DisableInBoth = disableInBoth;
+
+ ShouldShow = true;
+ _top = Slope.Top;
+ BottomElement = In;
+ CapTypeOptions.OptionsDropdown.SelectedIndexChanged += OnCapTypeDropdownSelectedItemChanged;
+ CapTypeOptions.SelectedCapOption = InCap;
+
+ if (DisableInBoth != null)
+ {
+ DisableInBoth.CheckBox.CheckedChanged += OnDisableInBothCheckedChange;
+ }
+ }
+
+ #endregion Constructors
+
+ #region Properties
+
+ public CapTypeOptions CapTypeOptions { get; }
+
+ public Option In { get; }
+
+ public Option Out { get; }
+
+ public Option Slope { get; }
+
+ private Option DisableOptionInBoth { get; }
+
+ private CheckBoxOption DisableInBoth { get; }
+
+ public override int Left
+ {
+ get => In.Left;
+
+ set
+ {
+ In.Left = value;
+ Out.Left = value;
+ Slope.Left = value;
+ }
+ }
+
+ public override int Top
+ {
+ get => _top;
+ set
+ {
+ _top = value;
+ Layout(value);
+ }
+ }
+
+ public override int Height
+ {
+ get => BottomElement.Top + BottomElement.Height - Top;
+ }
+
+ public override int Width
+ {
+ get => CapTypeOptions.Width;
+
+ set
+ {
+ CapTypeOptions.Width = value;
+ In.Width = value;
+ Out.Width = value;
+ Slope.Width = value;
+ }
+ }
+
+ public override bool Visible
+ {
+ get => ShouldShow;
+ }
+
+ private bool ShouldShow { get; set; }
+
+ private IOption BottomElement { get; set; }
+
+ #endregion Properties
+
+ #region Methods
+
+ public override void AlignActiveValues()
+ {
+ Slope.AlignActiveValues();
+ CapTypeOptions.AlignActiveValues();
+ In.AlignActiveValues();
+ Out.AlignActiveValues();
+ }
+
+ public override void Show(string name)
+ {
+ ShouldShow = true;
+ Layout(Top, name);
+ }
+
+ public override void Hide()
+ {
+ ShouldShow = false;
+ CapTypeOptions.Hide();
+ Slope.Hide();
+ In.Hide();
+ Out.Hide();
+ }
+
+ public void SetActiveValues(
+ double scale,
+ double inCap,
+ double outCap,
+ CapMode capMode)
+ {
+ Slope.SetActiveValue(scale);
+ In.SetActiveValue(inCap);
+ Out.SetActiveValue(outCap);
+ CapTypeOptions.SetActiveValue(capMode);
+ }
+
+ private void Layout(int top, string name = null)
+ {
+ switch (CapTypeOptions.SelectedCapType)
+ {
+ case CapType.Input:
+ if (ShouldShow)
+ {
+ Slope.Show();
+ CapTypeOptions.Show(name);
+ ShowInCap();
+ Out.Hide();
+ }
+
+ Slope.Top = top;
+ CapTypeOptions.SnapTo(Slope);
+ In.SnapTo(CapTypeOptions);
+
+ BottomElement = In;
+ break;
+ case CapType.Output:
+ if (ShouldShow)
+ {
+ Slope.Show();
+ CapTypeOptions.Show(name);
+ In.Hide();
+ ShowOutCap();
+ }
+
+ Slope.Top = top;
+ CapTypeOptions.SnapTo(Slope);
+ Out.SnapTo(CapTypeOptions);
+
+ BottomElement = Out;
+ break;
+ case CapType.Both:
+ if (ShouldShow)
+ {
+ CapTypeOptions.Show(name);
+ Slope.Hide();
+ ShowInCap();
+ ShowOutCap();
+ }
+
+ CapTypeOptions.Top = top;
+ In.SnapTo(CapTypeOptions);
+ Out.SnapTo(In);
+
+ BottomElement = Out;
+ break;
+ }
+
+ DisableBuggedOptionIfApplicable();
+ }
+
+ private void DisableBuggedOptionIfApplicable()
+ {
+ if (DisableOptionInBoth != null)
+ {
+ if (CapTypeOptions.SelectedCapType == CapType.Both &&
+ DisableInBoth != null &&
+ !DisableInBoth.CheckBox.Checked)
+ {
+ DisableOptionInBoth.Field.SetToUnavailable();
+ }
+ else
+ {
+ DisableOptionInBoth.Field.SetToDefault();
+ }
+ }
+ }
+
+ private void ShowInCap()
+ {
+ In.Show(InCapLabel);
+ }
+
+ private void ShowOutCap()
+ {
+ Out.Show(OutCapLabel);
+ }
+
+ private void OnCapTypeDropdownSelectedItemChanged(object sender, EventArgs e)
+ {
+ Layout(Top);
+ CapTypeOptions.CheckIfDefault();
+ }
+
+ private void OnDisableInBothCheckedChange(object sender, EventArgs e)
+ {
+ DisableBuggedOptionIfApplicable();
+ }
+
+ #endregion Methods
+ }
+}
diff --git a/grapher/Models/Options/Cap/CapTypeOptions.cs b/grapher/Models/Options/Cap/CapTypeOptions.cs
new file mode 100644
index 0000000..6447feb
--- /dev/null
+++ b/grapher/Models/Options/Cap/CapTypeOptions.cs
@@ -0,0 +1,160 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options.Cap
+{
+ public class CapTypeOptions : ComboBoxOptionsBase
+ {
+ #region Enum
+
+ public enum CapType
+ {
+ Input,
+ Output,
+ Both,
+ }
+
+ #endregion Enum
+
+ #region Classes
+
+ public class CapTypeOption
+ {
+ public CapType Type { get; set; }
+
+ public string Name => Type.ToString();
+
+ public override string ToString() => Name;
+ }
+
+ #endregion Classes
+
+ #region Static
+
+ public static readonly CapTypeOption InCap = new CapTypeOption
+ {
+ Type = CapType.Input,
+ };
+
+ public static readonly CapTypeOption OutCap = new CapTypeOption
+ {
+ Type = CapType.Output,
+ };
+
+ public static readonly CapTypeOption BothCap = new CapTypeOption
+ {
+ Type = CapType.Both,
+ };
+
+ public static readonly CapTypeOption[] AllCapTypeOptions = new CapTypeOption[]
+ {
+ InCap,
+ OutCap,
+ BothCap
+ };
+
+ #endregion Static
+
+ #region Constructors
+
+ public CapTypeOptions(
+ Label label,
+ ComboBox dropdown,
+ ActiveValueLabel activeValueLabel,
+ int left)
+ : base(
+ label,
+ dropdown,
+ activeValueLabel)
+ {
+ OptionsDropdown.Items.AddRange(
+ new CapTypeOption[]
+ {
+ InCap,
+ OutCap,
+ BothCap
+ });
+
+ Default = OutCap;
+
+ label.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ label.Left = left;
+ label.Width = OptionsDropdown.Left - left - Constants.OptionLabelBoxSeperation;
+ label.Height = OptionsDropdown.Height;
+ }
+
+ #endregion Constructors
+
+ #region Properties
+
+ public CapType SelectedCapType => SelectedCapOption.Type;
+
+ public CapTypeOption SelectedCapOption
+ {
+ get
+ {
+ return OptionsDropdown.SelectedItem as CapTypeOption;
+ }
+ set
+ {
+ OptionsDropdown.SelectedItem = value;
+ }
+ }
+
+ private CapTypeOption Default { get; set; }
+
+ public CapMode GetSelectedCapMode()
+ {
+ switch(SelectedCapType)
+ {
+ case CapType.Output: return CapMode.output;
+ case CapType.Both: return CapMode.in_out;
+ case CapType.Input:
+ default: return CapMode.input;
+ }
+ }
+
+ #endregion Properties
+
+ #region Methods
+
+ public static CapTypeOption CapTypeOptionFromSettings(CapMode capMode)
+ {
+ switch (capMode)
+ {
+ case CapMode.output:
+ return OutCap;
+ case CapMode.in_out:
+ return BothCap;
+ case CapMode.input:
+ default:
+ return InCap;
+ }
+ }
+
+ public void SetActiveValue(CapMode capMode)
+ {
+ Default = CapTypeOptionFromSettings(capMode);
+ SelectedCapOption = Default;
+ ActiveValueLabel.SetValue(SelectedCapOption.Name);
+ }
+
+ public void CheckIfDefault()
+ {
+ if (SelectedCapOption.Equals(Default))
+ {
+ OptionsDropdown.ForeColor = System.Drawing.Color.Gray;
+ }
+ else
+ {
+ OptionsDropdown.ForeColor = System.Drawing.Color.Black;
+ }
+ }
+
+ #endregion Methods
+ }
+}
diff --git a/grapher/Models/Options/CheckBoxOption.cs b/grapher/Models/Options/CheckBoxOption.cs
index abf96d3..8c125ec 100644
--- a/grapher/Models/Options/CheckBoxOption.cs
+++ b/grapher/Models/Options/CheckBoxOption.cs
@@ -2,6 +2,9 @@
namespace grapher.Models.Options
{
+ /// <summary>
+ /// This is an option type that is just a checkbox.
+ /// </summary>
public class CheckBoxOption : OptionBase
{
public CheckBoxOption(
@@ -99,10 +102,10 @@ namespace grapher.Models.Options
ActiveValueLabel.Show();
}
- public void SetActiveValue(bool legacy)
+ public void SetActiveValue(bool gain)
{
- CheckBox.Checked = !legacy;
- var activeValueString = legacy ? "Legacy" : "Gain";
+ CheckBox.Checked = gain;
+ var activeValueString = gain ? "Gain" : "Legacy";
ActiveValueLabel.SetValue(activeValueString);
}
}
diff --git a/grapher/Models/Options/ComboBoxOptionsBase.cs b/grapher/Models/Options/ComboBoxOptionsBase.cs
new file mode 100644
index 0000000..6999e99
--- /dev/null
+++ b/grapher/Models/Options/ComboBoxOptionsBase.cs
@@ -0,0 +1,124 @@
+using System.Windows.Forms;
+
+namespace grapher.Models.Options
+{
+ public abstract class ComboBoxOptionsBase : OptionBase
+ {
+ #region Constructors
+
+ public ComboBoxOptionsBase(
+ Label label,
+ ComboBox dropdown,
+ ActiveValueLabel activeValueLabel)
+ {
+ OptionsDropdown = dropdown;
+ OptionsDropdown.Items.Clear();
+
+ Label = label;
+ Label.AutoSize = false;
+ Label.Width = 50;
+
+ ActiveValueLabel = activeValueLabel;
+ }
+
+ #endregion Constructors
+
+ #region Properties
+
+ public Label Label { get; }
+
+ public ActiveValueLabel ActiveValueLabel { get; }
+
+ public ComboBox OptionsDropdown { get; }
+
+ public override bool Visible
+ {
+ get
+ {
+ return Label.Visible || ShouldShow;
+ }
+ }
+
+ public override int Left
+ {
+ get
+ {
+ return Label.Left;
+ }
+ set
+ {
+ Label.Left = value;
+ OptionsDropdown.Left = Label.Left + Label.Width + Constants.OptionVerticalSeperation;
+ }
+ }
+
+ public override int Height
+ {
+ get
+ {
+ return OptionsDropdown.Height;
+ }
+ }
+
+ public override int Top
+ {
+ get
+ {
+ return OptionsDropdown.Top;
+ }
+ set
+ {
+ OptionsDropdown.Top = value;
+ Label.Top = (OptionsDropdown.Height - Label.Height) / 2 + OptionsDropdown.Top;
+ ActiveValueLabel.Top = value;
+ }
+ }
+
+ public override int Width
+ {
+ get
+ {
+ return Label.Width;
+ }
+ set
+ {
+ OptionsDropdown.Width = value - Label.Width - Constants.OptionLabelBoxSeperation;
+ }
+ }
+
+ protected bool ShouldShow { get; set; }
+
+ #endregion Properties
+
+ #region Methods
+
+ public override void Hide()
+ {
+ Label.Hide();
+ OptionsDropdown.Hide();
+ ActiveValueLabel.Hide();
+ ShouldShow = false;
+ }
+
+ public override void Show(string labelText)
+ {
+ Label.Show();
+
+ if (!string.IsNullOrWhiteSpace(labelText))
+ {
+ Label.Text = labelText;
+ }
+
+ OptionsDropdown.Show();
+ ActiveValueLabel.Show();
+ ShouldShow = true;
+ }
+
+ public override void AlignActiveValues()
+ {
+ ActiveValueLabel.Align();
+ }
+
+ #endregion Methods
+ }
+}
diff --git a/grapher/Models/Options/Directionality/DirectionalityOptions.cs b/grapher/Models/Options/Directionality/DirectionalityOptions.cs
index 9288132..35d2575 100644
--- a/grapher/Models/Options/Directionality/DirectionalityOptions.cs
+++ b/grapher/Models/Options/Directionality/DirectionalityOptions.cs
@@ -70,17 +70,16 @@ namespace grapher.Models.Options.Directionality
private bool IsHidden { get; set; }
- public DomainArgs GetDomainArgs()
+ public Tuple<Vec2<double>, double> GetDomainArgs()
{
- return new DomainArgs
+ var weights = new Vec2<double>
{
- domainXY = new Vec2<double>
- {
- x = Domain.Fields.X,
- y = Domain.Fields.Y,
- },
- lpNorm = ByComponentCheckBox.Checked ? 2 : LpNorm.Field.Data
+ x = Domain.Fields.X,
+ y = Domain.Fields.Y
};
+ double p = ByComponentCheckBox.Checked ? 2 : LpNorm.Field.Data;
+
+ return new Tuple<Vec2<double>, double>(weights, p);
}
public Vec2<double> GetRangeXY()
@@ -92,14 +91,14 @@ namespace grapher.Models.Options.Directionality
};
}
- public void SetActiveValues(DriverSettings settings)
+ public void SetActiveValues(Profile settings)
{
- Domain.SetActiveValues(settings.domainArgs.domainXY.x, settings.domainArgs.domainXY.y);
+ Domain.SetActiveValues(settings.domainXY.x, settings.domainXY.y);
Range.SetActiveValues(settings.rangeXY.x, settings.rangeXY.y);
if (settings.combineMagnitudes)
{
- LpNorm.SetActiveValue(settings.domainArgs.lpNorm);
+ LpNorm.SetActiveValue(settings.lpNorm);
}
else
{
diff --git a/grapher/Models/Options/LUT/LUTPanelOptions.cs b/grapher/Models/Options/LUT/LUTPanelOptions.cs
index 3690c76..eedcfa8 100644
--- a/grapher/Models/Options/LUT/LUTPanelOptions.cs
+++ b/grapher/Models/Options/LUT/LUTPanelOptions.cs
@@ -111,15 +111,26 @@ namespace grapher.Models.Options.LUT
// Nothing to do here.
}
- public void SetActiveValues(IEnumerable<Vec2<float>> activePoints, int length)
+ public void SetActiveValues(IEnumerable<float> rawData, int length, AccelMode mode)
{
- if (length > 0 && activePoints.First().x != 0)
+ if (mode == AccelMode.lut && length > 1 && rawData.First() != 0)
{
- ActiveValuesTextBox.Text = PointsToActiveValuesText(activePoints, length);
+ var pointsLen = length / 2;
+ var points = new Vec2<float>[pointsLen];
+ for (int i = 0; i < pointsLen; i++)
+ {
+ var data_idx = i * 2;
+ points[i] = new Vec2<float>
+ {
+ x = rawData.ElementAt(data_idx),
+ y = rawData.ElementAt(data_idx + 1)
+ };
+ }
+ ActiveValuesTextBox.Text = PointsToActiveValuesText(points, pointsLen);
if (string.IsNullOrWhiteSpace(PointsTextBox.Text))
{
- PointsTextBox.Text = PointsToEntryTextBoxText(activePoints, length);
+ PointsTextBox.Text = PointsToEntryTextBoxText(points, pointsLen);
}
}
else
@@ -135,14 +146,12 @@ namespace grapher.Models.Options.LUT
private static (Vec2<float>[], int length) UserTextToPoints(string userText)
{
- const int MaxPoints = 256;
-
if (string.IsNullOrWhiteSpace(userText))
{
throw new ApplicationException("Text must be entered in text box to fill Look Up Table.");
}
- Vec2<float>[] points = new Vec2<float>[MaxPoints];
+ Vec2<float>[] points = new Vec2<float>[AccelArgs.MaxLutPoints];
var userTextSplit = userText.Trim().Trim(';').Split(';');
int index = 0;
@@ -155,9 +164,9 @@ namespace grapher.Models.Options.LUT
throw new ApplicationException("At least 2 points required");
}
- if (pointsCount > MaxPoints)
+ if (pointsCount > AccelArgs.MaxLutPoints)
{
- throw new ApplicationException($"Number of points exceeds max ({MaxPoints})");
+ throw new ApplicationException($"Number of points exceeds max ({AccelArgs.MaxLutPoints})");
}
foreach(var pointEntry in userTextSplit)
diff --git a/grapher/Models/Options/LUT/LutApplyOptions.cs b/grapher/Models/Options/LUT/LutApplyOptions.cs
index 7d8c737..61cae61 100644
--- a/grapher/Models/Options/LUT/LutApplyOptions.cs
+++ b/grapher/Models/Options/LUT/LutApplyOptions.cs
@@ -7,10 +7,9 @@ using System.Windows.Forms;
namespace grapher.Models.Options.LUT
{
- public class LutApplyOptions : OptionBase
+ public class LutApplyOptions : ComboBoxOptionsBase
{
- public const string LUTApplyOptionsLabelText = "Apply as:";
- public const int LUTApplyLabelDropdownSeparation = 4;
+ #region Enum
public enum LutApplyType
{
@@ -18,6 +17,10 @@ namespace grapher.Models.Options.LUT
Velocity
}
+ #endregion Enum
+
+ #region Classes
+
public class LutApplyOption
{
public LutApplyType Type { get; set; }
@@ -27,6 +30,10 @@ namespace grapher.Models.Options.LUT
public override string ToString() => Name;
}
+ #endregion Classes
+
+ #region Static
+
public static readonly LutApplyOption Sensitivity = new LutApplyOption
{
Type = LutApplyType.Sensitivity,
@@ -37,129 +44,58 @@ namespace grapher.Models.Options.LUT
Type = LutApplyType.Velocity,
};
+ #endregion Static
+
+ #region Constructors
+
public LutApplyOptions(
Label label,
ComboBox applyOptionsDropdown,
ActiveValueLabel lutApplyActiveValue)
+ : base(
+ label,
+ applyOptionsDropdown,
+ lutApplyActiveValue)
{
- ApplyOptions = applyOptionsDropdown;
- ApplyOptions.Items.Clear();
- ApplyOptions.Items.AddRange(
+ OptionsDropdown.Items.AddRange(
new LutApplyOption[]
{
Sensitivity,
Velocity,
});
+ }
- Label = label;
- Label.Text = LUTApplyOptionsLabelText;
- Label.AutoSize = false;
- Label.Width = 50;
+ #endregion Constructors
- ActiveValueLabel = lutApplyActiveValue;
- }
+ #region Properties
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;
+ return OptionsDropdown.SelectedItem as LutApplyOption;
}
set
{
- Label.Left = value;
- ApplyOptions.Left = Label.Left + Label.Width + LUTApplyLabelDropdownSeparation;
+ OptionsDropdown.SelectedItem = value;
}
}
- public override int Height
- {
- get
- {
- return Label.Height;
- }
- }
+ #endregion Properties
- public override int Top
- {
- get
- {
- return Label.Top;
- }
- set
- {
- ApplyOptions.Top = value;
- Label.Top = (ApplyOptions.Height - Label.Height) / 2 + ApplyOptions.Top;
- ActiveValueLabel.Top = value;
- }
- }
+ #region Methods
- public override int Width
+ public static LutApplyOption ApplyOptionFromSettings(bool applyAsVelocity)
{
- get
- {
- return Label.Width;
- }
- set
+ if (applyAsVelocity)
{
- ApplyOptions.Width = value - Label.Width - Constants.OptionLabelBoxSeperation;
+ return Velocity;
}
- }
-
- 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))
+ else
{
- Label.Text = labelText;
+ return Sensitivity;
}
-
- ApplyOptions.Show();
- ActiveValueLabel.Show();
- ShouldShow = true;
- }
-
- public override void AlignActiveValues()
- {
- ActiveValueLabel.Align();
}
public void SetActiveValue(bool applyAsVelocity)
@@ -168,16 +104,6 @@ namespace grapher.Models.Options.LUT
ActiveValueLabel.SetValue(ApplyOption.Name);
}
- public LutApplyOption ApplyOptionFromSettings(bool applyAsVelocity)
- {
- if (applyAsVelocity)
- {
- return Velocity;
- }
- else
- {
- return Sensitivity;
- }
- }
+ #endregion Methods
}
}
diff --git a/grapher/Models/Options/LockableOption.cs b/grapher/Models/Options/LockableOption.cs
new file mode 100644
index 0000000..6e78783
--- /dev/null
+++ b/grapher/Models/Options/LockableOption.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options
+{
+ /// <summary>
+ /// This is an option type that is a regular option with a checkbox that disables it.
+ /// </summary>
+ public class LockableOption : OptionBase
+ {
+ public LockableOption(
+ Option option,
+ CheckBox checkBox,
+ int lockedvalue)
+ {
+ Option = option;
+ LockBox = checkBox;
+ LockedValue = lockedvalue;
+
+ LockBox.Click += OnLockedBoxClicked;
+ LockBox.AutoCheck = false;
+
+ Option.Field.SetNewDefault(LockedValue);
+ SetLocked();
+ }
+
+ public Option Option { get; }
+
+ public CheckBox LockBox { get; }
+
+ public int LockedValue { get; }
+
+ public override int Left
+ {
+ get => Option.Left;
+
+ set
+ {
+ Option.Left = value;
+ }
+ }
+
+ public override int Top
+ {
+ get => Option.Top;
+
+ set
+ {
+ Option.Top = value;
+ LockBox.Top = value;
+ }
+ }
+
+ public override int Width
+ {
+ get => Option.Width;
+
+ set
+ {
+ Option.Width = value;
+ }
+ }
+
+ public override int Height
+ {
+ get => Option.Height;
+ }
+
+ public override bool Visible
+ {
+ get => Option.Visible;
+ }
+
+ public double Value
+ {
+ get => LockBox.Checked ? LockedValue : Option.Field.Data;
+ }
+
+ public void SetActiveValue(double activeValue)
+ {
+ Option.SetActiveValue(activeValue);
+
+ if (activeValue == LockedValue)
+ {
+ SetLocked();
+ }
+ else
+ {
+ SetUnlocked();
+ }
+ }
+
+ public override void AlignActiveValues()
+ {
+ Option.AlignActiveValues();
+ }
+
+ public override void Hide()
+ {
+ Option.Hide();
+ LockBox.Hide();
+ }
+
+ public override void Show(string Name)
+ {
+ Option.Show(Name);
+ LockBox.Show();
+ }
+ private void SetLocked()
+ {
+ LockBox.Checked = true;
+ Option.Field.SetToUnavailable();
+ }
+
+ private void SetUnlocked()
+ {
+ LockBox.Checked = false;
+ Option.Field.SetToDefault();
+ }
+
+ private void OnLockedBoxClicked(object sender, EventArgs e)
+ {
+ if (LockBox.Checked)
+ {
+ SetUnlocked();
+ }
+ else
+ {
+ SetLocked();
+ }
+ }
+ }
+}
diff --git a/grapher/Models/Options/SwitchOption.cs b/grapher/Models/Options/SwitchOption.cs
new file mode 100644
index 0000000..79991c1
--- /dev/null
+++ b/grapher/Models/Options/SwitchOption.cs
@@ -0,0 +1,162 @@
+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 SwitchOption : OptionBase
+ {
+
+ #region Constructors
+
+ public SwitchOption(
+ Label label,
+ CheckBox firstCheckBox,
+ CheckBox secondCheckBox,
+ ActiveValueLabel activeValueLabel,
+ int left)
+ {
+ Label = label;
+ First = firstCheckBox;
+ Second = secondCheckBox;
+ ActiveValueLabel = activeValueLabel;
+ Left = left;
+
+ label.AutoSize = false;
+ label.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ label.Width = First.Left - left - Constants.OptionLabelBoxSeperation;
+ label.Height = First.Height;
+
+ ActiveValueLabel.Height = First.Height;
+
+ First.CheckedChanged += OnFirstCheckedChange;
+ Second.CheckedChanged += OnSecondCheckedChange;
+
+ First.Checked = true;
+ Second.Left = First.Left + First.Width + Constants.OptionLabelBoxSeperation;
+ Show(string.Empty);
+ }
+
+ #endregion Constructors
+
+ #region Properties
+
+ public Label Label { get; }
+
+ public CheckBox First { get; }
+
+ public CheckBox Second { get; }
+
+ public ActiveValueLabel ActiveValueLabel { get; }
+
+ public override int Height
+ {
+ get => Label.Height;
+ }
+
+ public override int Left
+ {
+ get => Label.Left;
+ set
+ {
+ Label.Left = value;
+ }
+ }
+
+ public override bool Visible
+ {
+ get => ShouldShow;
+ }
+
+ public override int Width
+ {
+ get => Second.Left + Second.Width - Label.Left;
+ set
+ {
+ }
+ }
+
+ public override int Top
+ {
+ get => Label.Top;
+ set
+ {
+ Label.Top = value;
+ First.Top = value;
+ Second.Top = value;
+ ActiveValueLabel.Top = value;
+ }
+ }
+
+ private bool ShouldShow { get; set; }
+
+ #endregion Properties
+
+ #region Methods
+
+ public override void AlignActiveValues()
+ {
+ ActiveValueLabel.Align();
+ }
+
+ public override void Hide()
+ {
+ ShouldShow = false;
+
+ Label.Hide();
+ First.Hide();
+ Second.Hide();
+ ActiveValueLabel.Hide();
+ }
+
+ public override void Show(string name)
+ {
+ ShouldShow = true;
+
+ if (!string.IsNullOrWhiteSpace(name))
+ {
+ Label.Text = name;
+ }
+
+ Label.Show();
+ First.Show();
+ Second.Show();
+ ActiveValueLabel.Show();
+ }
+
+ public void SetActiveValue(bool shouldFirstBeChecked)
+ {
+ if (shouldFirstBeChecked)
+ {
+ First.Checked = true;
+ ActiveValueLabel.SetValue(First.Text);
+ }
+ else
+ {
+ Second.Checked = true;
+ ActiveValueLabel.SetValue(Second.Text);
+ }
+ }
+
+ private void OnFirstCheckedChange(object sender, EventArgs e)
+ {
+ if (First.Checked)
+ {
+ Second.Checked = false;
+ }
+ }
+
+ private void OnSecondCheckedChange(object sender, EventArgs e)
+ {
+ if (Second.Checked)
+ {
+ First.Checked = false;
+ }
+ }
+
+ #endregion Methods
+ }
+}