From a919b3a8bc981b714adfa95ce60ee58cc3881f0f Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 23 Sep 2020 11:51:59 -0700 Subject: Add to Guide, fix motility name --- grapher/Layouts/LayoutBase.cs | 2 +- grapher/Layouts/MotivityLayout.cs | 2 +- grapher/Models/Serialized/DriverSettings.cs | 3 +++ grapher/ReadMe/Guide.md | 9 ++++++--- 4 files changed, 11 insertions(+), 5 deletions(-) (limited to 'grapher') diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs index b89e2f7..04f5189 100644 --- a/grapher/Layouts/LayoutBase.cs +++ b/grapher/Layouts/LayoutBase.cs @@ -10,7 +10,7 @@ namespace grapher.Layouts public const string Exponent = "Exponent"; public const string Limit = "Limit"; public const string Midpoint = "Midpoint"; - public const string Motility = "Motility"; + public const string Motivity = "Motivity"; public const string Offset = "Offset"; public const string Cap = "Cap"; public const string Weight = "Weight"; diff --git a/grapher/Layouts/MotivityLayout.cs b/grapher/Layouts/MotivityLayout.cs index dfef2de..c555ef0 100644 --- a/grapher/Layouts/MotivityLayout.cs +++ b/grapher/Layouts/MotivityLayout.cs @@ -20,7 +20,7 @@ namespace grapher.Layouts CapLayout = new OptionLayout(false, string.Empty); WeightLayout = new OptionLayout(true, Weight); OffsetLayout = new OptionLayout(false, string.Empty); - LimExpLayout = new OptionLayout(true, Motility); + LimExpLayout = new OptionLayout(true, Motivity); MidpointLayout = new OptionLayout(true, Midpoint); } } diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs index 5f9307c..e841b68 100644 --- a/grapher/Models/Serialized/DriverSettings.cs +++ b/grapher/Models/Serialized/DriverSettings.cs @@ -70,6 +70,7 @@ namespace grapher.Models.Serialized public static void SetActive(DriverSettings settings, Action unmanagedActionBefore = null) { + ManualResetEvent sync = new ManualResetEvent(false); new Thread(() => { lock (UnmanagedSettingsLock) @@ -78,8 +79,10 @@ namespace grapher.Models.Serialized unmanagedActionBefore?.Invoke(UnmanagedSettingsHandle); DriverInterop.SetActiveSettings(UnmanagedSettingsHandle); } + sync.Set(); }).Start(); + sync.WaitOne(); } public void SendToDriver(Action unmanagedActionBefore = null) diff --git a/grapher/ReadMe/Guide.md b/grapher/ReadMe/Guide.md index 3680c0a..1eae47e 100644 --- a/grapher/ReadMe/Guide.md +++ b/grapher/ReadMe/Guide.md @@ -1,7 +1,7 @@ # Raw Accel Guide ## Philosophy -The Raw Accel driver and GUI's workings and exposed parameters are based on our understanding of mouse acceleration. Our understanding includes the concepts of "gain", "whole vs by component", and "anisotropy." For clarity, we will outline this understanding here. +The Raw Accel driver and GUI's workings and exposed parameters are based on our understanding of mouse acceleration. Our understanding includes the concepts of "gain", "whole vs by component", and "anisotropy." For clarity, we will outline this understanding here. Those uninterested can skip to Features below. ### Measurements from Input Speed Raw Accel, like any mouse modification program, works by acting on a passed in (x,y) input and passing back out an (x,y) output. The GUI program creates charts by feeding a set of (x,y) inputs to the driver code to receive a set of (x,y) outputs. The following measurements, available as charts in Raw Accel, are then found from the outputs: @@ -57,6 +57,9 @@ See "Horizontal and Vertical" in the philosophy section to understand what these ### Last Mouse Move The Raw Accel GUI reads the output of the raw input stream, and thus the output of the Raw Accel Driver, and displays on the graphs red points corresponding to the last mouse movements. These calculations are slightly slow but build up a cache, so shaking your mouse around on GUI start should make the points display fast and smoothly. This feature can be turned off in the "Charts" menu. +### Scale by DPI and Poll Rate +This option does not scale your acceleration curve in any way. Rather, it scales the set of points used to graph your curve, and shows you a window of input speed relevant for your chosen DPI and Poll Rate. + ## Acceleration Styles [To be added: pictures of the styles, typical settings] @@ -72,8 +75,8 @@ This is the style found in CS:GO and Source Engine games. The user can set a rat ### Natural & NaturalGain Natural is a style found in the game Diabotical. It features a concave curve which starts at 1 and approaches some maximum sensitivity. This style is unique and useful but causes an ugly dip in the gain graph. For this reason we have created the NaturalGain style, which recreates the Natural style shape in the gain graph without any dips. We recommend users use the NaturalGain style instead of the Natural style; on switch some small tweaks may be needed since for any particular settings the NaturalGain is slightly slower to ramp up than the Natural style. NaturalGain is another excellent choice for new users. -### SigmoidGain -A sigmoid curve is an s-shaped curve. SigmoidGain creates an s-shaped curve from 1 to some maximum gain in the gain graph, allowing a user to set the maximum gain, the midpoint of the s, and how fast the s ramps up (similarly to the Natural styles.) At one point there was a Sigmoid style but we removed it because it caused an awful dip in the gain graph. +### Motivity +This curve looks like an "S" with the top half bigger than the bottom. Mathematically it's a "Sigmoid function on a log-log plot". A user can set the "midpoint" of the S, the "acceleration" (i.e. slantedness) of the S, and the "motivity". "Motivity" sets min and max sensitivity, where the maximum is just "motility", and the minimum is "1/motility." (Sensitivity is 1 at the midpoint.) This curve is calculated and stored in a lookup table before applying acceleration, which makes the gain graph look a little funny. This is one author's favorite curve, and an excellent choice for power users and new users who don't mind playing with the settings a little. ### Logarithm [Sidiouth needs to write this] -- cgit v1.2.3 From 625728e32cbf9d6dc9b5180c5dd5799160e0d781 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 24 Sep 2020 01:08:44 -0700 Subject: Remove waithandle: --- grapher/Models/Serialized/DriverSettings.cs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'grapher') diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs index e841b68..cc37ad7 100644 --- a/grapher/Models/Serialized/DriverSettings.cs +++ b/grapher/Models/Serialized/DriverSettings.cs @@ -70,7 +70,6 @@ namespace grapher.Models.Serialized public static void SetActive(DriverSettings settings, Action unmanagedActionBefore = null) { - ManualResetEvent sync = new ManualResetEvent(false); new Thread(() => { lock (UnmanagedSettingsLock) @@ -79,10 +78,7 @@ namespace grapher.Models.Serialized unmanagedActionBefore?.Invoke(UnmanagedSettingsHandle); DriverInterop.SetActiveSettings(UnmanagedSettingsHandle); } - sync.Set(); }).Start(); - - sync.WaitOne(); } public void SendToDriver(Action unmanagedActionBefore = null) -- cgit v1.2.3 From a4fcd872bd694f77897fd6cc91cd9068f11d0acd Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Fri, 25 Sep 2020 13:25:11 -0700 Subject: Use log LUT rather than binary search for last mouse move point --- grapher/Models/Calculations/AccelCalculator.cs | 62 +++++++++++++++++++++++--- grapher/Models/Calculations/AccelChartData.cs | 24 ++++++---- 2 files changed, 70 insertions(+), 16 deletions(-) (limited to 'grapher') diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index f2a6c7c..5d3582c 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -67,6 +67,10 @@ namespace grapher.Models.Calculations double maxSlope = 0.0; double minSlope = Double.MaxValue; + double log = -2; + int index = 0; + int logIndex = 0; + foreach (var magnitudeDatum in magnitudeData) { if (magnitudeDatum.magnitude <=0) @@ -77,6 +81,22 @@ namespace grapher.Models.Calculations var output = accel.Accelerate(magnitudeDatum.x, magnitudeDatum.y, MeasurementTime); var outMagnitude = Magnitude(output.Item1, output.Item2); + if (!data.VelocityPoints.ContainsKey(magnitudeDatum.magnitude)) + { + data.VelocityPoints.Add(magnitudeDatum.magnitude, outMagnitude); + } + else + { + continue; + } + + while (Math.Pow(10,log) < outMagnitude) + { + data.LogToIndex[logIndex] = index; + log += 0.01; + logIndex++; + } + var ratio = magnitudeDatum.magnitude > 0 ? outMagnitude / magnitudeDatum.magnitude : starter; if (ratio > maxRatio) @@ -108,11 +128,6 @@ namespace grapher.Models.Calculations data.AccelPoints.Add(magnitudeDatum.magnitude, ratio); } - if (!data.VelocityPoints.ContainsKey(magnitudeDatum.magnitude)) - { - data.VelocityPoints.Add(magnitudeDatum.magnitude, outMagnitude); - } - if (!data.GainPoints.ContainsKey(magnitudeDatum.magnitude)) { data.GainPoints.Add(magnitudeDatum.magnitude, slope); @@ -120,9 +135,18 @@ namespace grapher.Models.Calculations lastInputMagnitude = magnitudeDatum.magnitude; lastOutputMagnitude = outMagnitude; + index += 1; + } + + index--; + + while (log <= 4.0) + { + data.LogToIndex[logIndex] = index; + log += 0.01; + logIndex++; } - data.OrderedVelocityPointsList.AddRange(data.VelocityPoints.Values.ToList()); data.MaxAccel = maxRatio; data.MinAccel = minRatio; data.MaxGain = maxSlope; @@ -143,6 +167,10 @@ namespace grapher.Models.Calculations Sensitivity = GetSens(ref settings); + double log = -2; + int index = 0; + int logIndex = 0; + foreach (var magnitudeDatum in magnitudeData) { var output = accel.Accelerate(magnitudeDatum.x, magnitudeDatum.y, MeasurementTime); @@ -155,6 +183,17 @@ namespace grapher.Models.Calculations { data.Combined.VelocityPoints.Add(magnitudeDatum.magnitude, magnitudeWithoutSens); } + else + { + continue; + } + + while (Math.Pow(10,log) < magnitudeWithoutSens) + { + data.Combined.LogToIndex[logIndex] = index; + log += 0.01; + logIndex++; + } var xRatio = settings.sensitivity.x * ratio; var yRatio = settings.sensitivity.y * ratio; @@ -241,9 +280,18 @@ namespace grapher.Models.Calculations lastInputMagnitude = magnitudeDatum.magnitude; lastOutputMagnitudeX = xOut; lastOutputMagnitudeY = yOut; + index += 1; + } + + index--; + + while (log <= 4.0) + { + data.Combined.LogToIndex[logIndex] = index; + log += 0.01; + logIndex++; } - data.Combined.OrderedVelocityPointsList.AddRange(data.Combined.VelocityPoints.Values.ToList()); data.Combined.MaxAccel = maxRatio; data.Combined.MinAccel = minRatio; data.Combined.MaxGain = maxSlope; diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 54685a2..98d501b 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -13,8 +13,8 @@ namespace grapher.Models.Calculations AccelPoints = new SortedDictionary(); VelocityPoints = new SortedDictionary(); GainPoints = new SortedDictionary(); - OrderedVelocityPointsList = new List(); OutVelocityToPoints = new Dictionary(); + LogToIndex = new int[601]; } #endregion Constructors @@ -35,7 +35,7 @@ namespace grapher.Models.Calculations public SortedDictionary GainPoints { get; } - public List OrderedVelocityPointsList { get; } + public int[] LogToIndex { get; } public Dictionary OutVelocityToPoints { get; } @@ -48,8 +48,8 @@ namespace grapher.Models.Calculations AccelPoints.Clear(); VelocityPoints.Clear(); GainPoints.Clear(); - OrderedVelocityPointsList.Clear(); OutVelocityToPoints.Clear(); + Array.Clear(LogToIndex, 0, LogToIndex.Length); } public (double, double, double) FindPointValuesFromOut(double outVelocityValue) @@ -80,15 +80,21 @@ namespace grapher.Models.Calculations public int GetVelocityIndex(double outVelocityValue) { - var velIdx = OrderedVelocityPointsList.BinarySearch(outVelocityValue); - - if (velIdx < 0) + var log = Math.Log10(outVelocityValue); + if (log < -2) + { + log = -2; + } + else if (log > 4) + { + log = 4; + } + else { - velIdx = ~velIdx; + log = log * 100 + 200; } - velIdx = Math.Min(velIdx, VelocityPoints.Count - 1); - velIdx = Math.Max(velIdx, 0); + var velIdx = LogToIndex[(int)log]; return velIdx; } -- cgit v1.2.3 From fd184b6ffeaf5b1d1dceb7de58a8ebb7c3d8c760 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Fri, 25 Sep 2020 18:46:04 -0400 Subject: add initial writer move managed settings into wrapper move gui build into driver build dir --- grapher/Models/AccelGUI.cs | 10 +-- grapher/Models/Serialized/DriverSettings.cs | 117 --------------------------- grapher/Models/Serialized/SettingsManager.cs | 41 +++++----- grapher/grapher.csproj | 5 +- 4 files changed, 27 insertions(+), 146 deletions(-) delete mode 100644 grapher/Models/Serialized/DriverSettings.cs (limited to 'grapher') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 95d0c25..dd394c5 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -83,14 +83,8 @@ namespace grapher minimumTime = .4 }; - Settings.UpdateActiveSettings(settings, () => - { - AccelForm.Invoke((MethodInvoker)delegate - { - WriteButtonDelay(); - UpdateGraph(); - }); - }); + WriteButtonDelay(); + Settings.UpdateActiveSettings(settings); RefreshOnRead(); } diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs deleted file mode 100644 index 5f9307c..0000000 --- a/grapher/Models/Serialized/DriverSettings.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Threading; - -namespace grapher.Models.Serialized -{ - #region Enumerations - - public enum AccelMode - { - linear, classic, natural, naturalgain, power, logarithm, motivity, noaccel - } - - #endregion Enumerations - - #region Structs - - [StructLayout(LayoutKind.Sequential)] - public struct AccelArgs - { - public double offset; - public double legacy_offset; - public double accel; - public double limit; - public double exponent; - public double midpoint; - public double powerScale; - public double powerExponent; - public double weight; - public double rate; - public double scaleCap; - public double gainCap; - }; - - [StructLayout(LayoutKind.Sequential)] - public struct Vec2 - { - public T x; - public T y; - } - - #endregion Structs - - [StructLayout(LayoutKind.Sequential)] - [Serializable] - public class DriverSettings - { - #region Fields - - private static readonly IntPtr UnmanagedSettingsHandle = - Marshal.AllocHGlobal(Marshal.SizeOf()); - private static object UnmanagedSettingsLock = new object(); - - public double rotation; - public bool combineMagnitudes; - public Vec2 modes; - public Vec2 args; - public Vec2 sensitivity; - public double minimumTime; - - #endregion Fields - - #region Methods - - public static DriverSettings GetActive() - { - DriverInterop.GetActiveSettings(UnmanagedSettingsHandle); - return Marshal.PtrToStructure(UnmanagedSettingsHandle); - } - - public static void SetActive(DriverSettings settings, Action unmanagedActionBefore = null) - { - new Thread(() => - { - lock (UnmanagedSettingsLock) - { - Marshal.StructureToPtr(settings, UnmanagedSettingsHandle, false); - unmanagedActionBefore?.Invoke(UnmanagedSettingsHandle); - DriverInterop.SetActiveSettings(UnmanagedSettingsHandle); - } - }).Start(); - - } - - public void SendToDriver(Action unmanagedActionBefore = null) - { - SetActive(this, unmanagedActionBefore); - } - - public void SendToDriverAndUpdate(ManagedAccel accel, Action betweenAccelAndWrite = null) - { - SendToDriver(settingsHandle => - { - accel.UpdateFromSettings(settingsHandle); - betweenAccelAndWrite?.Invoke(); - }); - } - - public bool verify() - { - /* - if (args.accel < 0 || args.rate < 0) - bad_arg("accel can not be negative, use a negative weight to compensate"); - if (args.rate > 1) bad_arg("rate can not be greater than 1"); - if (args.exponent <= 1) bad_arg("exponent must be greater than 1"); - if (args.limit <= 1) bad_arg("limit must be greater than 1"); - if (args.power_scale <= 0) bad_arg("scale must be positive"); - if (args.power_exp <= 0) bad_arg("exponent must be positive"); - if (args.midpoint < 0) bad_arg("midpoint must not be negative"); - if (args.time_min <= 0) bad_arg("min time must be positive"); - */ - return true; - } - - #endregion Methods - } -} diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs index cac2bd0..26160f5 100644 --- a/grapher/Models/Serialized/SettingsManager.cs +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -1,6 +1,7 @@ using Newtonsoft.Json; using System; using System.Windows.Forms; +using System.Threading; namespace grapher.Models.Serialized { @@ -46,29 +47,28 @@ namespace grapher.Models.Serialized #region Methods - public void UpdateActiveSettings(DriverSettings settings, Action afterAccelSettingsUpdate = null) + public void UpdateActiveSettings(DriverSettings settings) { - settings.SendToDriverAndUpdate(ActiveAccel, () => - { - RawAccelSettings.AccelerationSettings = settings; - RawAccelSettings.GUISettings = new GUISettings - { - AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, - DPI = (int)DpiField.Data, - PollRate = (int)PollRateField.Data, - ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked, - ShowVelocityAndGain = ShowVelocityAndGainMoveMenuItem.Checked, - }; + ActiveAccel.UpdateFromSettings(settings); + SendToDriver(settings); - RawAccelSettings.Save(); + RawAccelSettings.AccelerationSettings = settings; + RawAccelSettings.GUISettings = new GUISettings + { + AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, + DPI = (int)DpiField.Data, + PollRate = (int)PollRateField.Data, + ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked, + ShowVelocityAndGain = ShowVelocityAndGainMoveMenuItem.Checked, + }; - afterAccelSettingsUpdate?.Invoke(); - }); + RawAccelSettings.Save(); } public void UpdateActiveAccelFromFileSettings(DriverSettings settings) - { - settings.SendToDriverAndUpdate(ActiveAccel); + { + ActiveAccel.UpdateFromSettings(settings); + SendToDriver(settings); DpiField.SetToEntered(RawAccelSettings.GUISettings.DPI); PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate); @@ -77,6 +77,11 @@ namespace grapher.Models.Serialized ShowVelocityAndGainMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowVelocityAndGain; } + public static void SendToDriver(DriverSettings settings) + { + new Thread(() => DriverInterop.SetActiveSettings(settings)).Start(); + } + public void Startup() { if (RawAccelSettings.Exists()) @@ -97,7 +102,7 @@ namespace grapher.Models.Serialized } RawAccelSettings = new RawAccelSettings( - DriverSettings.GetActive(), + DriverInterop.GetActiveSettings(), new GUISettings { AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index bc9fcf2..29b5cff 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -15,7 +15,7 @@ true - bin\x64\Debug\ + $(SolutionDir)$(Platform)\$(Configuration)\ DEBUG;TRACE full x64 @@ -25,7 +25,7 @@ true - bin\x64\Release\ + $(SolutionDir)$(Platform)\$(Configuration)\ TRACE true pdbonly @@ -101,7 +101,6 @@ - -- cgit v1.2.3 From aa9dbd9320938ac2541e5055d0041c9fd4fe5697 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Fri, 25 Sep 2020 21:56:29 -0700 Subject: Fix 0 point for separate x y sens --- grapher/Models/Calculations/AccelCalculator.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'grapher') diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 5d3582c..0838154 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -73,7 +73,7 @@ namespace grapher.Models.Calculations foreach (var magnitudeDatum in magnitudeData) { - if (magnitudeDatum.magnitude <=0) + if (magnitudeDatum.magnitude <= 0) { continue; } @@ -97,7 +97,7 @@ namespace grapher.Models.Calculations logIndex++; } - var ratio = magnitudeDatum.magnitude > 0 ? outMagnitude / magnitudeDatum.magnitude : starter; + var ratio = outMagnitude / magnitudeDatum.magnitude; if (ratio > maxRatio) { @@ -173,11 +173,16 @@ namespace grapher.Models.Calculations foreach (var magnitudeDatum in magnitudeData) { + if (magnitudeDatum.magnitude <= 0) + { + continue; + } + var output = accel.Accelerate(magnitudeDatum.x, magnitudeDatum.y, MeasurementTime); var outputWithoutSens = StripThisSens(output.Item1, output.Item2); var magnitudeWithoutSens = Magnitude(outputWithoutSens.Item1, outputWithoutSens.Item2); - var ratio = magnitudeDatum.magnitude > 0 ? magnitudeWithoutSens / magnitudeDatum.magnitude : 1; + var ratio = magnitudeWithoutSens / magnitudeDatum.magnitude; if (!data.Combined.VelocityPoints.ContainsKey(magnitudeDatum.magnitude)) { -- cgit v1.2.3 From 70360dd3c19909737d29c0b2b9fb1a7ba3f12bba Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Fri, 25 Sep 2020 22:21:26 -0700 Subject: Last mouse move perfetly responsive at 100 FPS --- grapher/Form1.cs | 2 +- grapher/Models/AccelGUI.cs | 19 +++++++++++++++++++ grapher/Models/Charts/AccelCharts.cs | 5 +++++ grapher/Models/Charts/ChartState/ChartState.cs | 7 +++++++ grapher/Models/Charts/ChartXY.cs | 9 +++++++++ grapher/Models/Mouse/MouseWatcher.cs | 8 +++++++- 6 files changed, 48 insertions(+), 2 deletions(-) (limited to 'grapher') diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 3f2ca2a..aa3d2ef 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -144,7 +144,7 @@ namespace grapher private void RawAcceleration_Paint(object sender, PaintEventArgs e) { - AccelGUI.AccelCharts.DrawLastMovement(); + //AccelGUI.AccelCharts.DrawLastMovement(); } #endregion Method diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index dd394c5..131df9c 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -38,6 +38,7 @@ namespace grapher WriteButton.Click += new System.EventHandler(OnWriteButtonClick); ButtonTimer = SetupButtonTimer(); + ChartRefresh = SetupChartTimer(); SetupWriteButton(); } @@ -63,6 +64,8 @@ namespace grapher public ToolStripMenuItem ScaleMenuItem { get; } + private Timer ChartRefresh { get; } + #endregion Properties #region Methods @@ -110,6 +113,15 @@ namespace grapher ApplyOptions.SetActiveValues(settings); } + private Timer SetupChartTimer() + { + Timer chartTimer = new Timer(); + chartTimer.Enabled = true; + chartTimer.Interval = 10; + chartTimer.Tick += new System.EventHandler(OnChartTimerTick); + return chartTimer; + } + private Timer SetupButtonTimer() { Timer buttonTimer = new Timer(); @@ -159,6 +171,13 @@ namespace grapher ButtonTimer.Start(); } + private void OnChartTimerTick(object sender, EventArgs e) + { + AccelCharts.DrawLastMovement(); + MouseWatcher.UpdateLastMove(); + AccelCharts.Redraw(); + } + #endregion Methods } diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index a0e99c8..7484a3a 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -143,6 +143,11 @@ namespace grapher AlignWriteButton(); } + public void Redraw() + { + ChartState.Redraw(); + } + public void Calculate(ManagedAccel accel, DriverSettings settings) { ChartState.SetUpCalculate(settings); diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs index e1c7d01..1898e12 100644 --- a/grapher/Models/Charts/ChartState/ChartState.cs +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -48,6 +48,13 @@ namespace grapher.Models.Charts.ChartState public abstract void Calculate(ManagedAccel accel, DriverSettings settings); + public void Redraw() + { + SensitivityChart.Update(); + VelocityChart.Update(); + GainChart.Update(); + } + public virtual void SetUpCalculate(DriverSettings settings) { Data.Clear(); diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index c30c993..3bd7601 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -154,6 +154,15 @@ namespace grapher */ } + public void Update() + { + ChartX.Update(); + if (ChartY.Visible) + { + ChartY.Update(); + } + } + public void SetPointBinds(PointData combined, PointData x, PointData y) { CombinedPointData = combined; diff --git a/grapher/Models/Mouse/MouseWatcher.cs b/grapher/Models/Mouse/MouseWatcher.cs index 86b1c2e..c6e85c1 100644 --- a/grapher/Models/Mouse/MouseWatcher.cs +++ b/grapher/Models/Mouse/MouseWatcher.cs @@ -716,10 +716,16 @@ namespace grapher.Models.Mouse public void OnMouseMove(int x, int y, double timeInMs) { - Display.Text = $"Last (x, y): ({x}, {y})"; + MouseData.Set(x,y); AccelCharts.MakeDots(x, y, timeInMs); } + public void UpdateLastMove() + { + MouseData.Get(out var x, out var y); + Display.Text = $"Last (x, y): ({x}, {y})"; + } + public void ReadMouseMove(Message message) { RawInput rawInput = new RawInput(); -- cgit v1.2.3 From 206cdc1712d02d15b85393a57ca744fbc014a55c Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Fri, 25 Sep 2020 23:03:00 -0700 Subject: SetActive changes field default, bugs fixed --- grapher/Models/AccelGUI.cs | 1 - grapher/Models/Calculations/AccelCalculator.cs | 8 ++++---- grapher/Models/Calculations/AccelChartData.cs | 12 +++++------- grapher/Models/Charts/ChartXY.cs | 12 ++++++------ grapher/Models/Fields/Field.cs | 10 ++++++++-- grapher/Models/Options/Option.cs | 2 ++ 6 files changed, 25 insertions(+), 20 deletions(-) (limited to 'grapher') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 131df9c..cc86ff7 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -175,7 +175,6 @@ namespace grapher { AccelCharts.DrawLastMovement(); MouseWatcher.UpdateLastMove(); - AccelCharts.Redraw(); } #endregion Methods diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 0838154..e2f7bcc 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -90,7 +90,7 @@ namespace grapher.Models.Calculations continue; } - while (Math.Pow(10,log) < outMagnitude) + while (Math.Pow(10,log) < outMagnitude && logIndex < data.LogToIndex.Length) { data.LogToIndex[logIndex] = index; log += 0.01; @@ -140,7 +140,7 @@ namespace grapher.Models.Calculations index--; - while (log <= 4.0) + while (log <= 5.0) { data.LogToIndex[logIndex] = index; log += 0.01; @@ -193,7 +193,7 @@ namespace grapher.Models.Calculations continue; } - while (Math.Pow(10,log) < magnitudeWithoutSens) + while (Math.Pow(10,log) < magnitudeWithoutSens && logIndex < data.Combined.LogToIndex.Length) { data.Combined.LogToIndex[logIndex] = index; log += 0.01; @@ -290,7 +290,7 @@ namespace grapher.Models.Calculations index--; - while (log <= 4.0) + while (log <= 5.0) { data.Combined.LogToIndex[logIndex] = index; log += 0.01; diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 98d501b..60d4c89 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -14,7 +14,7 @@ namespace grapher.Models.Calculations VelocityPoints = new SortedDictionary(); GainPoints = new SortedDictionary(); OutVelocityToPoints = new Dictionary(); - LogToIndex = new int[601]; + LogToIndex = new int[701]; } #endregion Constructors @@ -85,15 +85,13 @@ namespace grapher.Models.Calculations { log = -2; } - else if (log > 4) + else if (log > 5) { - log = 4; - } - else - { - log = log * 100 + 200; + log = 5; } + log = log * 100 + 200; + var velIdx = LogToIndex[(int)log]; return velIdx; diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 3bd7601..d95c7ac 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -222,8 +222,8 @@ namespace grapher { if (min < max) { - ChartX.ChartAreas[0].AxisY.Minimum = min; - ChartX.ChartAreas[0].AxisY.Maximum = max; + ChartX.ChartAreas[0].AxisY.Minimum = min * 0.95; + ChartX.ChartAreas[0].AxisY.Maximum = max * 1.05; } } @@ -231,14 +231,14 @@ namespace grapher { if (minX < maxX) { - ChartX.ChartAreas[0].AxisY.Minimum = minX; - ChartX.ChartAreas[0].AxisY.Maximum = maxX; + ChartX.ChartAreas[0].AxisY.Minimum = minX * 0.95; + ChartX.ChartAreas[0].AxisY.Maximum = maxX * 1.05; } if (minY < maxY) { - ChartY.ChartAreas[0].AxisY.Minimum = minY; - ChartY.ChartAreas[0].AxisY.Maximum = maxY; + ChartY.ChartAreas[0].AxisY.Minimum = minY * 0.95; + ChartY.ChartAreas[0].AxisY.Maximum = maxY * 1.05; } } diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs index df73dd7..541bbe2 100644 --- a/grapher/Models/Fields/Field.cs +++ b/grapher/Models/Fields/Field.cs @@ -52,7 +52,7 @@ namespace grapher public string FormatString { get; set; } - public string DefaultText { get; } + public string DefaultText { get; set; } public FieldState State { get; private set; } @@ -120,7 +120,7 @@ namespace grapher } } - private double DefaultData { get; } + private double DefaultData { get; set; } #endregion Properties @@ -138,6 +138,12 @@ namespace grapher Box.Enabled = true; } + public void SetNewDefault(double newDefault) + { + DefaultData = newDefault; + DefaultText = DecimalString(newDefault); + } + public void SetToDefault() { if (State != FieldState.Default) diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs index c0d339e..d5129d5 100644 --- a/grapher/Models/Options/Option.cs +++ b/grapher/Models/Options/Option.cs @@ -136,6 +136,8 @@ namespace grapher public void SetActiveValue(double value) { ActiveValueLabel.SetValue(value); + Field.SetNewDefault(value); + Field.SetToDefault(); } public override void Hide() -- cgit v1.2.3