summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2021-06-30 00:01:26 -0700
committerJacob Palecki <[email protected]>2021-06-30 00:01:26 -0700
commitabbe20f63aded56c4714766ca1b93183eafa062a (patch)
tree4b1a6e91b7c8c4fa3f017e4fc6880b932fb93dca
parentFix high DPI issue (diff)
downloadrawaccel-abbe20f63aded56c4714766ca1b93183eafa062a.tar.xz
rawaccel-abbe20f63aded56c4714766ca1b93183eafa062a.zip
Add class for LUT apply type
-rw-r--r--grapher/Form1.Designer.cs36
-rw-r--r--grapher/Layouts/LUTLayout.cs3
-rw-r--r--grapher/Layouts/LayoutBase.cs11
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs7
-rw-r--r--grapher/Models/Options/CapOptions.cs221
-rw-r--r--grapher/Models/Options/LUT/LutApplyOptions.cs176
-rw-r--r--grapher/grapher.csproj2
7 files changed, 213 insertions, 243 deletions
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index f63d9a7..fc742ac 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -71,6 +71,8 @@ namespace grapher
System.Windows.Forms.DataVisualization.Charting.Title title6 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RawAcceleration));
this.optionsPanel = new System.Windows.Forms.Panel();
+ this.richTextBox2 = new System.Windows.Forms.RichTextBox();
+ this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.LUTPanelY = new System.Windows.Forms.Panel();
this.LUTPanelX = new System.Windows.Forms.Panel();
this.gainSwitchActiveLabelY = new System.Windows.Forms.Label();
@@ -190,8 +192,6 @@ namespace grapher
this.GainChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.VelocityChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
- this.richTextBox1 = new System.Windows.Forms.RichTextBox();
- this.richTextBox2 = new System.Windows.Forms.RichTextBox();
this.optionsPanel.SuspendLayout();
this.DirectionalityPanel.SuspendLayout();
this.menuStrip1.SuspendLayout();
@@ -297,6 +297,22 @@ namespace grapher
this.optionsPanel.Size = new System.Drawing.Size(483, 956);
this.optionsPanel.TabIndex = 34;
//
+ // richTextBox2
+ //
+ this.richTextBox2.Location = new System.Drawing.Point(397, 447);
+ this.richTextBox2.Name = "richTextBox2";
+ this.richTextBox2.Size = new System.Drawing.Size(73, 57);
+ this.richTextBox2.TabIndex = 161;
+ this.richTextBox2.Text = "";
+ //
+ // richTextBox1
+ //
+ this.richTextBox1.Location = new System.Drawing.Point(317, 447);
+ this.richTextBox1.Name = "richTextBox1";
+ this.richTextBox1.Size = new System.Drawing.Size(68, 57);
+ this.richTextBox1.TabIndex = 160;
+ this.richTextBox1.Text = "";
+ //
// LUTPanelY
//
this.LUTPanelY.AutoScroll = true;
@@ -1539,22 +1555,6 @@ namespace grapher
title6.Text = "Sensitivity";
this.AccelerationChart.Titles.Add(title6);
//
- // richTextBox1
- //
- this.richTextBox1.Location = new System.Drawing.Point(317, 447);
- this.richTextBox1.Name = "richTextBox1";
- this.richTextBox1.Size = new System.Drawing.Size(68, 57);
- this.richTextBox1.TabIndex = 160;
- this.richTextBox1.Text = "";
- //
- // richTextBox2
- //
- this.richTextBox2.Location = new System.Drawing.Point(397, 447);
- this.richTextBox2.Name = "richTextBox2";
- this.richTextBox2.Size = new System.Drawing.Size(73, 57);
- this.richTextBox2.TabIndex = 161;
- this.richTextBox2.Text = "";
- //
// RawAcceleration
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
diff --git a/grapher/Layouts/LUTLayout.cs b/grapher/Layouts/LUTLayout.cs
index 37c336e..e570f6a 100644
--- a/grapher/Layouts/LUTLayout.cs
+++ b/grapher/Layouts/LUTLayout.cs
@@ -8,7 +8,7 @@ namespace grapher.Layouts
{
public class LUTLayout : LayoutBase
{
- public const string LUTLayoutText = "This mode is for advanced users only. We recommend setting points in the settings file with a script.";
+ public const string LUTLayoutText = "This mode is for advanced users only. Format: x1,y1;x2,y2;...xn,yn;";
/// <summary>
/// String small enough to fit in active value label
@@ -32,6 +32,7 @@ namespace grapher.Layouts
MidpointLayout = new OptionLayout(false, string.Empty);
LutTextLayout = new OptionLayout(true, LUTLayoutText);
LutPanelLayout = new OptionLayout(true, string.Empty);
+ LutApplyOptionsLayout = new OptionLayout(true, string.Empty);
}
public override string ActiveName => LUTActiveName;
diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs
index bc207d3..db914dc 100644
--- a/grapher/Layouts/LayoutBase.cs
+++ b/grapher/Layouts/LayoutBase.cs
@@ -30,6 +30,7 @@ namespace grapher.Layouts
MidpointLayout = new OptionLayout(false, string.Empty);
LutTextLayout = new OptionLayout(false, string.Empty);
LutPanelLayout = new OptionLayout(false, string.Empty);
+ LutApplyOptionsLayout = new OptionLayout(false, string.Empty);
GainSwitchOptionLayout = new OptionLayout(false, string.Empty);
LogarithmicCharts = false;
@@ -63,6 +64,8 @@ namespace grapher.Layouts
protected OptionLayout LutPanelLayout { get; set; }
+ protected OptionLayout LutApplyOptionsLayout { get; set; }
+
protected OptionLayout GainSwitchOptionLayout { get; set; }
public override string ToString()
@@ -82,6 +85,7 @@ namespace grapher.Layouts
IOption midpointOption,
IOption lutTextOption,
IOption lutPanelOption,
+ IOption lutApplyOption,
int top)
{
@@ -98,7 +102,8 @@ namespace grapher.Layouts
(ExponentLayout, expOption),
(MidpointLayout, midpointOption),
(LutTextLayout, lutTextOption),
- (LutPanelLayout, lutPanelOption)})
+ (LutPanelLayout, lutPanelOption),
+ (LutApplyOptionsLayout, lutApplyOption)})
{
option.Item1.Layout(option.Item2);
@@ -129,7 +134,8 @@ namespace grapher.Layouts
IOption expOption,
IOption midpointOption,
IOption lutTextOption,
- IOption lutPanelOption)
+ IOption lutPanelOption,
+ IOption lutApplyOption)
{
Layout(gainSwitchOption,
accelOption,
@@ -142,6 +148,7 @@ namespace grapher.Layouts
midpointOption,
lutTextOption,
lutPanelOption,
+ lutApplyOption,
accelOption.Top);
}
}
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index 74e748a..cc2480c 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -119,6 +119,8 @@ namespace grapher
public LUTPanelOptions LutPanel { get; }
+ public LutApplyOptions LutApply { get; }
+
public LayoutBase AccelerationType
{
get
@@ -207,6 +209,7 @@ namespace grapher
Midpoint.Hide();
LutText.Hide();
LutPanel.Hide();
+ LutApply.Hide();
}
public void Show()
@@ -234,6 +237,7 @@ namespace grapher
Limit.SetActiveValue(args.limit);
Exponent.SetActiveValue(args.exponent);
Midpoint.SetActiveValue(args.midpoint);
+ LutApply.SetActiveValue(args.tableData.velocity);
}
public void ShowFull()
@@ -291,6 +295,7 @@ namespace grapher
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 (LutApply.Visible) args.tableData.velocity = LutApply.ApplyType == LutApplyOptions.LutApplyType.Velocity;
}
public override void AlignActiveValues()
@@ -305,6 +310,7 @@ namespace grapher
Limit.AlignActiveValues();
Exponent.AlignActiveValues();
Midpoint.AlignActiveValues();
+ LutApply.AlignActiveValues();
}
private void OnIndexChanged(object sender, EventArgs e)
@@ -332,6 +338,7 @@ namespace grapher
Midpoint,
LutText,
LutPanel,
+ LutApply,
top);
}
diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs
deleted file mode 100644
index b4afa5c..0000000
--- a/grapher/Models/Options/CapOptions.cs
+++ /dev/null
@@ -1,221 +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 cap, bool legacyCap)
- {
- if (!legacyCap)
- {
- CapOption.ActiveValueLabel.FormatString = Constants.GainCapFormatString;
- CapOption.ActiveValueLabel.Prefix = "Gain";
- }
- else
- {
- CapOption.ActiveValueLabel.FormatString = Constants.DefaultActiveValueFormatString;
- CapOption.ActiveValueLabel.Prefix = string.Empty;
- }
-
- CapOption.SetActiveValue(cap);
- }
-
- 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/LUT/LutApplyOptions.cs b/grapher/Models/Options/LUT/LutApplyOptions.cs
new file mode 100644
index 0000000..6ea7412
--- /dev/null
+++ b/grapher/Models/Options/LUT/LutApplyOptions.cs
@@ -0,0 +1,176 @@
+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 enum LutApplyType
+ {
+ Sensitivity,
+ Velocity
+ }
+
+ public class LutApplyOption
+ {
+ public LutApplyType Type { get; set; }
+
+ public string Name => Type.ToString();
+ }
+
+ 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;
+
+ 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 + Constants.OptionLabelBoxSeperation;
+ }
+ }
+
+ public override int Height
+ {
+ get
+ {
+ return Label.Height;
+ }
+ }
+
+ public override int Top
+ {
+ get
+ {
+ return Label.Top;
+ }
+ set
+ {
+ Label.Top = value;
+ ApplyOptions.Top = value;
+ 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();
+ ShouldShow = false;
+ }
+
+ public override void Show(string labelText)
+ {
+ Label.Show();
+
+ if (!string.IsNullOrWhiteSpace(labelText))
+ {
+ Label.Text = labelText;
+ }
+
+ ApplyOptions.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/grapher.csproj b/grapher/grapher.csproj
index 029029b..7b0ab02 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -113,7 +113,6 @@
<Compile Include="Models\Options\ActiveValueLabel.cs" />
<Compile Include="Models\Options\ActiveValueLabelXY.cs" />
<Compile Include="Models\Options\ApplyOptions.cs" />
- <Compile Include="Models\Options\CapOptions.cs" />
<Compile Include="Models\Charts\ChartXY.cs" />
<Compile Include="Models\Fields\Field.cs" />
<Compile Include="Models\Fields\FieldXY.cs" />
@@ -132,6 +131,7 @@
<Compile Include="Layouts\PowerLayout.cs" />
<Compile Include="Models\Options\CheckBoxOption.cs" />
<Compile Include="Models\Options\Directionality\DirectionalityOptions.cs" />
+ <Compile Include="Models\Options\LUT\LutApplyOptions.cs" />
<Compile Include="Models\Options\IOption.cs" />
<Compile Include="Models\Options\LUT\LUTPanelOptions.cs" />
<Compile Include="Models\Options\OffsetOptions.cs" />