diff options
| author | Jacob Palecki <[email protected]> | 2020-09-22 15:26:08 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-22 15:26:08 -0700 |
| commit | f4ff6334df8a3fd66d13082606b69a78fa592237 (patch) | |
| tree | 6db3b486a4c19ed02d5c4368fd18d29b2abec78d | |
| parent | Save option to show velocity and gain on gui startup (diff) | |
| download | rawaccel-f4ff6334df8a3fd66d13082606b69a78fa592237.tar.xz rawaccel-f4ff6334df8a3fd66d13082606b69a78fa592237.zip | |
Remove sigmoidgain, only allow one instance of grapher to run at a time
| -rw-r--r-- | common/accel-sigmoidgain.hpp | 34 | ||||
| -rw-r--r-- | common/common.vcxitems | 1 | ||||
| -rw-r--r-- | common/rawaccel-settings.h | 2 | ||||
| -rw-r--r-- | common/rawaccel.hpp | 5 | ||||
| -rw-r--r-- | grapher/Constants/Constants.cs | 4 | ||||
| -rw-r--r-- | grapher/Form1.Designer.cs | 20 | ||||
| -rw-r--r-- | grapher/Layouts/SigmoidGainLayout.cs | 22 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartXY.cs | 22 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 3 | ||||
| -rw-r--r-- | grapher/Models/Serialized/DriverSettings.cs | 2 | ||||
| -rw-r--r-- | grapher/Program.cs | 10 | ||||
| -rw-r--r-- | grapher/grapher.csproj | 1 |
12 files changed, 41 insertions, 85 deletions
diff --git a/common/accel-sigmoidgain.hpp b/common/accel-sigmoidgain.hpp deleted file mode 100644 index bed2f16..0000000 --- a/common/accel-sigmoidgain.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include <math.h> - -#include "accel-base.hpp" - -namespace rawaccel { - - /// <summary> Struct to hold sigmoid (s-shaped) gain implementation. </summary> - struct sigmoidgain_impl { - double rate; - double limit; - double additive_constant; - double integration_constant; - - sigmoidgain_impl(const accel_args& args) : - rate(args.rate), limit(args.limit - 1) - { - additive_constant = exp(rate * args.midpoint); - integration_constant = log(1 + additive_constant); - } - - inline double operator()(double speed) const { - //f(x) = k/(1+e^(-m(c-x))) - double scaled_speed = rate * speed; - return limit * ((log(additive_constant+exp(scaled_speed)) - integration_constant)/scaled_speed); - } - - inline double legacy_offset(double speed) const { return operator()(speed); } - }; - - using accel_sigmoidgain = additive_accel<sigmoidgain_impl>; - -} diff --git a/common/common.vcxitems b/common/common.vcxitems index fdf5cf4..3407cf2 100644 --- a/common/common.vcxitems +++ b/common/common.vcxitems @@ -24,7 +24,6 @@ <ClInclude Include="$(MSBuildThisFileDirectory)accel-naturalgain.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)accel-noaccel.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)accel-power.hpp" /> - <ClInclude Include="$(MSBuildThisFileDirectory)accel-sigmoidgain.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-error.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-io.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-settings.h" /> diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h index 00289b6..2ba6a98 100644 --- a/common/rawaccel-settings.h +++ b/common/rawaccel-settings.h @@ -6,7 +6,7 @@ namespace rawaccel { enum class accel_mode { - linear, classic, natural, naturalgain, sigmoidgain, power, logarithm, motivity, noaccel + linear, classic, natural, naturalgain, power, logarithm, motivity, noaccel }; struct settings { diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp index 3eb9181..2e627c9 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -12,7 +12,6 @@ #include "accel-natural.hpp" #include "accel-naturalgain.hpp" #include "accel-power.hpp" -#include "accel-sigmoidgain.hpp" #include "accel-motivity.hpp" #include "accel-noaccel.hpp" @@ -84,10 +83,9 @@ namespace rawaccel { case accel_mode::classic: return vis(var.u.classic); case accel_mode::natural: return vis(var.u.natural); case accel_mode::naturalgain: return vis(var.u.naturalgain); - case accel_mode::sigmoidgain: return vis(var.u.sigmoidgain); case accel_mode::power: return vis(var.u.power); case accel_mode::logarithm: return vis(var.u.logarithm); - case accel_mode::motivity: return vis(var.u.motivity); + case accel_mode::motivity: return vis(var.u.motivity); default: return vis(var.u.noaccel); } } @@ -102,7 +100,6 @@ namespace rawaccel { accel_classic classic; accel_natural natural; accel_naturalgain naturalgain; - accel_sigmoidgain sigmoidgain; accel_power power; accel_logarithm logarithm; accel_motivity motivity; diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index 2ce6763..b41ffa2 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -21,9 +21,6 @@ namespace grapher /// <summary> Ratio of max (X, Y) used in "by component" calulations to those used in "whole vector" calculations. </summary> public const double XYToCombinedRatio = 1.4; - /// <summary> Possible options to display in a layout. </summary> - public const int PossibleOptionsCount = 6; - /// <summary> Separation between X and Y active value labels, in pixels. </summary> public const int ActiveLabelXYSeparation = 2; @@ -60,6 +57,7 @@ namespace grapher /// <summary> Left placement of charts when narrowed </summary> public const int NarrowChartLeft = 482; + /// <summary> Vertical placement of write button above bottom of sensitivity graph </summary> public const int WriteButtonVerticalOffset = 80; /// <summary> Format string for shortened x and y textboxes. </summary> diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index e108720..c6a895d 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -98,13 +98,13 @@ namespace grapher this.GainChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.graphsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.showVelocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.scaleByDPIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dPIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.DPITextBox = new System.Windows.Forms.ToolStripTextBox(); this.pollRateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.PollRateTextBox = new System.Windows.Forms.ToolStripTextBox(); this.ScaleMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showVelocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showLastMouseMoveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.capStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -505,12 +505,6 @@ namespace grapher this.graphsToolStripMenuItem.Size = new System.Drawing.Size(53, 20); this.graphsToolStripMenuItem.Text = "Charts"; // - // showVelocityGainToolStripMenuItem - // - this.showVelocityGainToolStripMenuItem.Name = "showVelocityGainToolStripMenuItem"; - this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(199, 22); - this.showVelocityGainToolStripMenuItem.Text = "Show Velocity && Gain"; - // // scaleByDPIToolStripMenuItem // this.scaleByDPIToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -526,7 +520,7 @@ namespace grapher this.dPIToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.DPITextBox}); this.dPIToolStripMenuItem.Name = "dPIToolStripMenuItem"; - this.dPIToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.dPIToolStripMenuItem.Size = new System.Drawing.Size(169, 22); this.dPIToolStripMenuItem.Text = "DPI"; // // DPITextBox @@ -540,7 +534,7 @@ namespace grapher this.pollRateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.PollRateTextBox}); this.pollRateToolStripMenuItem.Name = "pollRateToolStripMenuItem"; - this.pollRateToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.pollRateToolStripMenuItem.Size = new System.Drawing.Size(169, 22); this.pollRateToolStripMenuItem.Text = "Poll Rate"; // // PollRateTextBox @@ -552,9 +546,15 @@ namespace grapher // ScaleMenuItem // this.ScaleMenuItem.Name = "ScaleMenuItem"; - this.ScaleMenuItem.Size = new System.Drawing.Size(180, 22); + this.ScaleMenuItem.Size = new System.Drawing.Size(169, 22); this.ScaleMenuItem.Text = "Re-scale by above"; // + // showVelocityGainToolStripMenuItem + // + this.showVelocityGainToolStripMenuItem.Name = "showVelocityGainToolStripMenuItem"; + this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(199, 22); + this.showVelocityGainToolStripMenuItem.Text = "Show Velocity && Gain"; + // // showLastMouseMoveToolStripMenuItem // this.showLastMouseMoveToolStripMenuItem.Checked = true; diff --git a/grapher/Layouts/SigmoidGainLayout.cs b/grapher/Layouts/SigmoidGainLayout.cs deleted file mode 100644 index 684de83..0000000 --- a/grapher/Layouts/SigmoidGainLayout.cs +++ /dev/null @@ -1,22 +0,0 @@ -using grapher.Models.Serialized; - -namespace grapher.Layouts -{ - public class SigmoidGainLayout : LayoutBase - { - public SigmoidGainLayout() - : base() - { - Name = "SigmoidGain"; - Index = (int)AccelMode.sigmoidgain; - LogarithmicCharts = false; - - AccelLayout = new OptionLayout(true, Acceleration); - CapLayout = new OptionLayout(false, string.Empty); - WeightLayout = new OptionLayout(true, Weight); - OffsetLayout = new OptionLayout(false, string.Empty); - LimExpLayout = new OptionLayout(true, Limit); - MidpointLayout = new OptionLayout(true, Midpoint); - } - } -} diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 253804e..c30c993 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -211,16 +211,26 @@ namespace grapher public void SetMinMax(double min, double max) { - ChartX.ChartAreas[0].AxisY.Minimum = min; - ChartX.ChartAreas[0].AxisY.Maximum = max; + if (min < max) + { + ChartX.ChartAreas[0].AxisY.Minimum = min; + ChartX.ChartAreas[0].AxisY.Maximum = max; + } } public void SetMinMaxXY(double minX, double maxX, double minY, double maxY) { - ChartX.ChartAreas[0].AxisY.Minimum = minX; - ChartX.ChartAreas[0].AxisY.Maximum = maxX; - ChartY.ChartAreas[0].AxisY.Minimum = minY; - ChartY.ChartAreas[0].AxisY.Maximum = maxY; + if (minX < maxX) + { + ChartX.ChartAreas[0].AxisY.Minimum = minX; + ChartX.ChartAreas[0].AxisY.Maximum = maxX; + } + + if (minY < maxY) + { + ChartY.ChartAreas[0].AxisY.Minimum = minY; + ChartY.ChartAreas[0].AxisY.Maximum = maxY; + } } public void SetCombined() diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index 16029ce..9bd42f5 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -17,10 +17,9 @@ namespace grapher new LinearLayout(), new ClassicLayout(), new NaturalLayout(), + new NaturalGainLayout(), new PowerLayout(), new LogarithmLayout(), - new NaturalGainLayout(), - new SigmoidGainLayout(), new MotivityLayout(), new OffLayout() }.ToDictionary(k => k.Name); diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs index 119b684..5f9307c 100644 --- a/grapher/Models/Serialized/DriverSettings.cs +++ b/grapher/Models/Serialized/DriverSettings.cs @@ -8,7 +8,7 @@ namespace grapher.Models.Serialized public enum AccelMode { - linear, classic, natural, naturalgain, sigmoidgain, power, logarithm, motivity, noaccel + linear, classic, natural, naturalgain, power, logarithm, motivity, noaccel } #endregion Enumerations diff --git a/grapher/Program.cs b/grapher/Program.cs index 85fd040..485e074 100644 --- a/grapher/Program.cs +++ b/grapher/Program.cs @@ -11,9 +11,19 @@ namespace grapher [STAThread] static void Main() { + var mutex = new System.Threading.Mutex(true, "RawAccelGrapher", out bool result); + + if (!result) + { + MessageBox.Show("Another instance of the Raw Accel Grapher is already running."); + return; + } + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new RawAcceleration()); + + GC.KeepAlive(mutex); } } } diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index b283e37..bc9fcf2 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -57,7 +57,6 @@ <Compile Include="Layouts\MotivityLayout.cs" /> <Compile Include="Layouts\LogarithmLayout.cs" /> <Compile Include="Layouts\NaturalGainLayout.cs" /> - <Compile Include="Layouts\SigmoidGainLayout.cs" /> <Compile Include="Models\AccelGUIFactory.cs" /> <Compile Include="Models\Calculations\AccelCalculator.cs" /> <Compile Include="Models\Calculations\AccelChartData.cs" /> |