diff options
| author | a1xd <[email protected]> | 2020-09-04 00:17:55 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-04 00:17:55 -0400 |
| commit | 159abe32fa9e903e1ac0a2c758d64c4b8e152c3d (patch) | |
| tree | 2230e353985551a21a25b09bfacb89467b52d165 /grapher | |
| parent | Merge pull request #18 from a1xd/write-delay (diff) | |
| parent | Add offset options to GUI, make gain options default (diff) | |
| download | rawaccel-159abe32fa9e903e1ac0a2c758d64c4b8e152c3d.tar.xz rawaccel-159abe32fa9e903e1ac0a2c758d64c4b8e152c3d.zip | |
Merge pull request #19 from JacobPalecki/gainOffset
Add gain offset & make gain options default
Diffstat (limited to 'grapher')
| -rw-r--r-- | grapher/Form1.Designer.cs | 66 | ||||
| -rw-r--r-- | grapher/Form1.cs | 11 | ||||
| -rw-r--r-- | grapher/Layouts/LayoutBase.cs | 2 | ||||
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 10 | ||||
| -rw-r--r-- | grapher/Models/Fields/Field.cs | 2 | ||||
| -rw-r--r-- | grapher/Models/Options/CapOptions.cs | 22 | ||||
| -rw-r--r-- | grapher/Models/Options/OffsetOptions.cs | 124 | ||||
| -rw-r--r-- | grapher/Models/Options/Option.cs | 3 | ||||
| -rw-r--r-- | grapher/Models/Options/OptionXY.cs | 3 | ||||
| -rw-r--r-- | grapher/Models/Serialized/DriverSettings.cs | 1 | ||||
| -rw-r--r-- | grapher/grapher.csproj | 1 |
11 files changed, 204 insertions, 41 deletions
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index ac438a1..a7a3e16 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -93,8 +93,8 @@ namespace grapher this.ScaleMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.capStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sensitivityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.velocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.gainCapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.legacyCapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.startupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AccelerationChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); @@ -114,6 +114,9 @@ namespace grapher this.OffsetActiveLabel = new System.Windows.Forms.Label(); this.LimitExpActiveLabel = new System.Windows.Forms.Label(); this.MidpointActiveLabel = new System.Windows.Forms.Label(); + this.offsetStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.gainOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.legacyOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit(); @@ -191,7 +194,7 @@ namespace grapher // // accelerationBox // - this.accelerationBox.Location = new System.Drawing.Point(106, 125); + this.accelerationBox.Location = new System.Drawing.Point(105, 125); this.accelerationBox.Name = "accelerationBox"; this.accelerationBox.Size = new System.Drawing.Size(69, 20); this.accelerationBox.TabIndex = 7; @@ -491,7 +494,8 @@ namespace grapher // advancedToolStripMenuItem // this.advancedToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.capStyleToolStripMenuItem}); + this.capStyleToolStripMenuItem, + this.offsetStyleToolStripMenuItem}); this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem"; this.advancedToolStripMenuItem.Size = new System.Drawing.Size(72, 20); this.advancedToolStripMenuItem.Text = "Advanced"; @@ -499,25 +503,25 @@ namespace grapher // capStyleToolStripMenuItem // this.capStyleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.sensitivityToolStripMenuItem, - this.velocityGainToolStripMenuItem}); + this.gainCapToolStripMenuItem, + this.legacyCapToolStripMenuItem}); this.capStyleToolStripMenuItem.Name = "capStyleToolStripMenuItem"; - this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.capStyleToolStripMenuItem.Text = "Cap Style"; // - // sensitivityToolStripMenuItem + // gainCapToolStripMenuItem // - this.sensitivityToolStripMenuItem.Checked = true; - this.sensitivityToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.sensitivityToolStripMenuItem.Name = "sensitivityToolStripMenuItem"; - this.sensitivityToolStripMenuItem.Size = new System.Drawing.Size(142, 22); - this.sensitivityToolStripMenuItem.Text = "Sensitivity"; + this.gainCapToolStripMenuItem.Checked = true; + this.gainCapToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.gainCapToolStripMenuItem.Name = "gainCapToolStripMenuItem"; + this.gainCapToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.gainCapToolStripMenuItem.Text = "Gain (Default)"; // - // velocityGainToolStripMenuItem + // legacyCapToolStripMenuItem // - this.velocityGainToolStripMenuItem.Name = "velocityGainToolStripMenuItem"; - this.velocityGainToolStripMenuItem.Size = new System.Drawing.Size(142, 22); - this.velocityGainToolStripMenuItem.Text = "Velocity Gain"; + this.legacyCapToolStripMenuItem.Name = "legacyCapToolStripMenuItem"; + this.legacyCapToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.legacyCapToolStripMenuItem.Text = "Legacy"; // // startupToolStripMenuItem // @@ -737,6 +741,27 @@ namespace grapher this.MidpointActiveLabel.TabIndex = 47; this.MidpointActiveLabel.Text = "0"; // + // offsetStyleToolStripMenuItem + // + this.offsetStyleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.gainOffsetToolStripMenuItem, + this.legacyOffsetToolStripMenuItem}); + this.offsetStyleToolStripMenuItem.Name = "offsetStyleToolStripMenuItem"; + this.offsetStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.offsetStyleToolStripMenuItem.Text = "Offset Style"; + // + // gainOffsetToolStripMenuItem + // + this.gainOffsetToolStripMenuItem.Name = "gainOffsetToolStripMenuItem"; + this.gainOffsetToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.gainOffsetToolStripMenuItem.Text = "Gain (Default)"; + // + // legacyOffsetToolStripMenuItem + // + this.legacyOffsetToolStripMenuItem.Name = "legacyOffsetToolStripMenuItem"; + this.legacyOffsetToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.legacyOffsetToolStripMenuItem.Text = "Legacy"; + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -840,8 +865,8 @@ namespace grapher private System.Windows.Forms.ToolStripMenuItem showVelocityGainToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem advancedToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem capStyleToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem sensitivityToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem velocityGainToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem gainCapToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem legacyCapToolStripMenuItem; private System.Windows.Forms.DataVisualization.Charting.Chart AccelerationChartY; private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChartY; private System.Windows.Forms.DataVisualization.Charting.Chart GainChartY; @@ -867,6 +892,9 @@ namespace grapher private System.Windows.Forms.Label MidpointActiveLabel; private System.Windows.Forms.ToolStripMenuItem startupToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem AutoWriteMenuItem; + private System.Windows.Forms.ToolStripMenuItem offsetStyleToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem gainOffsetToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem legacyOffsetToolStripMenuItem; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 37f67f8..ba0730c 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -104,6 +104,11 @@ namespace grapher new ActiveValueLabel(OffsetActiveLabel, ActiveValueTitle), "Offset"); + var offsetOptions = new OffsetOptions( + gainOffsetToolStripMenuItem, + legacyOffsetToolStripMenuItem, + offset); + // The name and layout of these options is handled by AccelerationOptions object. var acceleration = new Option( new Field(accelerationBox, this, 0), @@ -138,8 +143,8 @@ namespace grapher new ActiveValueLabel(AccelTypeActiveLabel, ActiveValueTitle)); var capOptions = new CapOptions( - sensitivityToolStripMenuItem, - velocityGainToolStripMenuItem, + gainCapToolStripMenuItem, + legacyCapToolStripMenuItem, cap, weight); @@ -163,7 +168,7 @@ namespace grapher rotation, weight, capOptions, - offset, + offsetOptions, acceleration, limitOrExponent, midpoint, diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs index 3ae2e90..eed1716 100644 --- a/grapher/Layouts/LayoutBase.cs +++ b/grapher/Layouts/LayoutBase.cs @@ -43,7 +43,7 @@ namespace grapher.Layouts public void Layout(Option[] options, OptionXY[] optionsXY, Button button) { // Relies on AccelOptions to keep lengths correct. - for (int i = 0; i< options.Length; i++) + for (int i = 0; i < options.Length; i++) { if (ShowOptions[i]) { diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 7a32b4e..a7d5d49 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -1,5 +1,6 @@ using grapher.Models.Calculations; using grapher.Models.Mouse; +using grapher.Models.Options; using grapher.Models.Serialized; using System; using System.CodeDom; @@ -28,7 +29,7 @@ namespace grapher Option rotation, OptionXY weight, CapOptions cap, - Option offset, + OffsetOptions offset, Option acceleration, Option limtOrExp, Option midpoint, @@ -82,7 +83,7 @@ namespace grapher public CapOptions Cap { get; } - public Option Offset { get; } + public OffsetOptions Offset { get; } public Option Acceleration { get; } @@ -119,7 +120,8 @@ namespace grapher { x = new AccelArgs { - offset = Offset.Field.Data, + offset = Offset.Offset, + legacy_offset = Offset.LegacyOffset, weight = Weight.Fields.X, gainCap = Cap.VelocityGainCap, scaleCap = Cap.SensitivityCapX, @@ -162,7 +164,7 @@ namespace grapher Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y); Rotation.SetActiveValue(settings.rotation); AccelerationOptions.SetActiveValue((int)settings.modes.x); - Offset.SetActiveValue(settings.args.x.offset); + Offset.SetActiveValue(settings.args.x.offset, settings.args.y.offset); Weight.SetActiveValues(settings.args.x.weight, settings.args.x.weight); Acceleration.SetActiveValue(settings.args.x.accel); // rate, powerscale LimitOrExponent.SetActiveValue(settings.args.x.limit); //exp, powerexp diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs index 8d75172..1810081 100644 --- a/grapher/Models/Fields/Field.cs +++ b/grapher/Models/Fields/Field.cs @@ -97,7 +97,7 @@ namespace grapher State = FieldState.Typing; } - Box.Text = string.Empty; + Box.Text = Data.ToString(); } public void SetToEntered() diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index 493561a..87bac88 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -14,27 +14,27 @@ namespace grapher public const string GainCapFormatString = "0.##"; public CapOptions( - ToolStripMenuItem sensitivityCapCheck, ToolStripMenuItem velocityGainCapCheck, + ToolStripMenuItem legacyCapCheck, OptionXY capOption, OptionXY weightOption) { - SensitivityCapCheck = sensitivityCapCheck; VelocityGainCapCheck = velocityGainCapCheck; + LegacyCapCheck = legacyCapCheck; CapOption = capOption; WeightOption = weightOption; - SensitivityCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick); + LegacyCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick); VelocityGainCapCheck.Click += new System.EventHandler(OnVelocityGainCapCheckClick); - SensitivityCapCheck.CheckedChanged += new System.EventHandler(OnSensitivityCapCheckedChange); + LegacyCapCheck.CheckedChanged += new System.EventHandler(OnSensitivityCapCheckedChange); VelocityGainCapCheck.CheckedChanged += new System.EventHandler(OnVelocityGainCapCheckedChange); - EnableSensitivityCap(); + EnableVelocityGainCap(); } - public ToolStripMenuItem SensitivityCapCheck { get; } + public ToolStripMenuItem LegacyCapCheck { get; } public ToolStripMenuItem VelocityGainCapCheck { get; } @@ -104,10 +104,10 @@ namespace grapher void OnSensitivityCapCheckClick(object sender, EventArgs e) { - if (!SensitivityCapCheck.Checked) + if (!LegacyCapCheck.Checked) { VelocityGainCapCheck.Checked = false; - SensitivityCapCheck.Checked = true; + LegacyCapCheck.Checked = true; } } @@ -116,13 +116,13 @@ namespace grapher if (!VelocityGainCapCheck.Checked) { VelocityGainCapCheck.Checked = true; - SensitivityCapCheck.Checked = false; + LegacyCapCheck.Checked = false; } } void OnSensitivityCapCheckedChange(object sender, EventArgs e) { - if (SensitivityCapCheck.Checked == true) + if (LegacyCapCheck.Checked == true) { EnableSensitivityCap(); } @@ -130,7 +130,7 @@ namespace grapher void OnVelocityGainCapCheckedChange(object sender, EventArgs e) { - if (SensitivityCapCheck.Checked == true) + if (LegacyCapCheck.Checked == true) { EnableVelocityGainCap(); } diff --git a/grapher/Models/Options/OffsetOptions.cs b/grapher/Models/Options/OffsetOptions.cs new file mode 100644 index 0000000..0b01ab9 --- /dev/null +++ b/grapher/Models/Options/OffsetOptions.cs @@ -0,0 +1,124 @@ +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 OffsetOptions + { + public OffsetOptions( + ToolStripMenuItem velocityGainOffsetCheck, + ToolStripMenuItem legacyOffsetCheck, + Option offsetOption) + { + VelocityGainOffsetCheck = velocityGainOffsetCheck; + LegacyOffsetCheck = legacyOffsetCheck; + OffsetOption = offsetOption; + + VelocityGainOffsetCheck.Click += new System.EventHandler(OnVelocityGainOffsetClick); + LegacyOffsetCheck.Click += new System.EventHandler(OnLegacyOffsetClick); + + VelocityGainOffsetCheck.CheckedChanged += new System.EventHandler(OnVelocityGainOffsetCheckedChange); + LegacyOffsetCheck.CheckedChanged += new System.EventHandler(OnLegacyOffsetCheckedChange); + + VelocityGainOffsetCheck.Checked = true; + } + + public ToolStripMenuItem VelocityGainOffsetCheck { get; } + + public ToolStripMenuItem LegacyOffsetCheck { get; } + + public Option OffsetOption { get; } + + public bool IsLegacy { get; private set; } + + public double LegacyOffset + { + get + { + if (IsLegacy) + { + return OffsetOption.Field.Data; + } + else + { + return 0; + } + } + } + + public double Offset + { + get + { + if (IsLegacy) + { + return 0; + } + else + { + return OffsetOption.Field.Data; + } + } + } + + public void SetActiveValue(double offset, double legacyOffset) + { + if (offset > 0) + { + OffsetOption.SetActiveValue(offset); + } + else + { + OffsetOption.SetActiveValue(legacyOffset); + } + } + + public void OnVelocityGainOffsetClick(object sender, EventArgs e) + { + if (!VelocityGainOffsetCheck.Checked) + { + VelocityGainOffsetCheck.Checked = true; + LegacyOffsetCheck.Checked = false; + } + } + + public void OnLegacyOffsetClick(object sender, EventArgs e) + { + if (!LegacyOffsetCheck.Checked) + { + LegacyOffsetCheck.Checked = true; + VelocityGainOffsetCheck.Checked = false; + } + } + + public void OnVelocityGainOffsetCheckedChange(object sender, EventArgs e) + { + if (VelocityGainOffsetCheck.Checked) + { + EnableVelocityGainOffset(); + } + } + + public void OnLegacyOffsetCheckedChange(object sender, EventArgs e) + { + if (LegacyOffsetCheck.Checked) + { + EnableLegacyOffset(); + } + } + + public void EnableVelocityGainOffset() + { + IsLegacy = false; + } + + public void EnableLegacyOffset() + { + IsLegacy = true; + } + } +} diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs index bacd760..b0ef374 100644 --- a/grapher/Models/Options/Option.cs +++ b/grapher/Models/Options/Option.cs @@ -59,7 +59,8 @@ namespace grapher public void SetName(string name) { Label.Text = name; - Label.Left = Convert.ToInt32((Field.Box.Left / 2.0) - (Label.Width / 2.0)); + //Label.Left = Convert.ToInt32((Field.Box.Left / 2.0) - (Label.Width / 2.0)); //Centered + Label.Left = Convert.ToInt32(Field.Box.Left - Label.Width - 10); //Right-aligned } public void SetActiveValue(double value) diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs index b22bb78..8e22617 100644 --- a/grapher/Models/Options/OptionXY.cs +++ b/grapher/Models/Options/OptionXY.cs @@ -62,7 +62,8 @@ namespace grapher public void SetName(string name) { Label.Text = name; - Label.Left = Convert.ToInt32((Fields.XField.Box.Left / 2.0) - (Label.Width / 2.0)); + //Label.Left = Convert.ToInt32((Fields.XField.Box.Left / 2.0) - (Label.Width / 2.0)); //Centered + Label.Left = Convert.ToInt32(Fields.XField.Box.Left - Label.Width - 10); //Right-aligned } public void SetActiveValues(double x, double y) diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs index 4595bf2..cdccf88 100644 --- a/grapher/Models/Serialized/DriverSettings.cs +++ b/grapher/Models/Serialized/DriverSettings.cs @@ -13,6 +13,7 @@ namespace grapher.Models.Serialized public struct AccelArgs { public double offset; + public double legacy_offset; public double accel; public double limit; public double exponent; diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index d34e678..28322bb 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -85,6 +85,7 @@ <Compile Include="Layouts\OffLayout.cs" /> <Compile Include="Layouts\PowerLayout.cs" /> <Compile Include="Layouts\SigmoidLayout.cs" /> + <Compile Include="Models\Options\OffsetOptions.cs" /> <Compile Include="Models\Options\Option.cs" /> <Compile Include="Models\Options\OptionXY.cs" /> <Compile Include="Models\Serialized\GUISettings.cs" /> |