summaryrefslogtreecommitdiff
path: root/grapher/Models
diff options
context:
space:
mode:
authorJacobPalecki <[email protected]>2021-01-20 20:13:33 -0800
committerGitHub <[email protected]>2021-01-20 20:13:33 -0800
commit5b6479013c8f35df933dd57c680063f4db1e4028 (patch)
tree60dd7c67a0f163457da2519b42553382a39a591b /grapher/Models
parentshow custom dialog on bad input (#63) (diff)
parentGuard against bad anisotropy args (diff)
downloadrawaccel-5b6479013c8f35df933dd57c680063f4db1e4028.tar.xz
rawaccel-5b6479013c8f35df933dd57c680063f4db1e4028.zip
Merge pull request #65 from JacobPalecki/Directional
Directionality Features + Graph Fidelity
Diffstat (limited to 'grapher/Models')
-rw-r--r--grapher/Models/AccelGUI.cs9
-rw-r--r--grapher/Models/AccelGUIFactory.cs78
-rw-r--r--grapher/Models/Calculations/AccelCalculator.cs411
-rw-r--r--grapher/Models/Calculations/AccelData.cs117
-rw-r--r--grapher/Models/Calculations/Data/AccelDataCombined.cs49
-rw-r--r--grapher/Models/Calculations/Data/AccelDataXYComponential.cs64
-rw-r--r--grapher/Models/Calculations/Data/AccelDataXYDirectional.cs84
-rw-r--r--grapher/Models/Calculations/Data/IAccelData.cs21
-rw-r--r--grapher/Models/Charts/AccelCharts.cs23
-rw-r--r--grapher/Models/Charts/ChartState/ChartState.cs17
-rw-r--r--grapher/Models/Charts/ChartState/ChartStateManager.cs18
-rw-r--r--grapher/Models/Charts/ChartState/CombinedState.cs28
-rw-r--r--grapher/Models/Charts/ChartState/XYOneGraphState.cs23
-rw-r--r--grapher/Models/Charts/ChartState/XYTwoGraphState.cs20
-rw-r--r--grapher/Models/Charts/ChartXY.cs4
-rw-r--r--grapher/Models/Fields/FieldXY.cs36
-rw-r--r--grapher/Models/Mouse/MouseWatcher.cs12
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs1
-rw-r--r--grapher/Models/Options/ActiveValueLabelXY.cs12
-rw-r--r--grapher/Models/Options/ApplyOptions.cs49
-rw-r--r--grapher/Models/Options/Directionality/DirectionalityOptions.cs213
-rw-r--r--grapher/Models/Options/Option.cs10
-rw-r--r--grapher/Models/Options/OptionXY.cs26
23 files changed, 937 insertions, 388 deletions
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index bb634ff..5cd7012 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -72,6 +72,11 @@ namespace grapher
SetupButtons();
AccelForm.DoResize();
+
+ // TODO: The below removes an overlapping form from the anisotropy panel.
+ // Figure out why and remove the overlap and below.
+ ApplyOptions.Directionality.Show();
+ ApplyOptions.Directionality.Hide();
}
#endregion Constructors
@@ -149,6 +154,8 @@ namespace grapher
args = newArgs,
minimumTime = driverSettings.minimumTime,
directionalMultipliers = driverSettings.directionalMultipliers,
+ domainArgs = ApplyOptions.Directionality.GetDomainArgs(),
+ rangeXY = ApplyOptions.Directionality.GetRangeXY(),
deviceID = DeviceIDManager.ID,
};
@@ -206,7 +213,7 @@ namespace grapher
private void SetupButtons()
{
- WriteButton.Top = AccelCharts.Top + AccelCharts.TopChartHeight - Constants.ButtonVerticalOffset;
+ WriteButton.Top = Constants.SensitivityChartAloneHeight - Constants.ButtonVerticalOffset;
ToggleButton.Appearance = Appearance.Button;
ToggleButton.FlatStyle = FlatStyle.System;
diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs
index 0669bf5..6a4c46f 100644
--- a/grapher/Models/AccelGUIFactory.cs
+++ b/grapher/Models/AccelGUIFactory.cs
@@ -2,6 +2,7 @@
using grapher.Models.Devices;
using grapher.Models.Mouse;
using grapher.Models.Options;
+using grapher.Models.Options.Directionality;
using grapher.Models.Serialized;
using System;
using System.Windows.Forms;
@@ -28,8 +29,6 @@ namespace grapher.Models
ButtonBase toggleButton,
ToolStripMenuItem showVelocityGainToolStripMenuItem,
ToolStripMenuItem showLastMouseMoveMenuItem,
- ToolStripMenuItem wholeVectorToolStripMenuItem,
- ToolStripMenuItem byVectorComponentToolStripMenuItem,
ToolStripMenuItem velocityGainCapToolStripMenuItem,
ToolStripMenuItem legacyCapToolStripMenuItem,
ToolStripMenuItem gainOffsetToolStripMenuItem,
@@ -39,6 +38,7 @@ namespace grapher.Models
ToolStripMenuItem scaleMenuItem,
ToolStripTextBox dpiTextBox,
ToolStripTextBox pollRateTextBox,
+ Panel directionalityPanel,
TextBox sensitivityBoxX,
TextBox sensitivityBoxY,
TextBox rotationBox,
@@ -58,8 +58,16 @@ namespace grapher.Models
TextBox expBoxY,
TextBox midpointBoxX,
TextBox midpointBoxY,
+ TextBox domainBoxX,
+ TextBox domainBoxY,
+ TextBox rangeBoxX,
+ TextBox rangeBoxY,
+ TextBox lpNormBox,
CheckBox sensXYLock,
CheckBox byComponentXYLock,
+ CheckBox fakeBox,
+ CheckBox wholeCheckBox,
+ CheckBox byComponentCheckBox,
Label lockXYLabel,
Label sensitivityLabel,
Label rotationLabel,
@@ -104,8 +112,23 @@ namespace grapher.Models
Label accelTypeActiveLabelY,
Label optionSetXTitle,
Label optionSetYTitle,
- Label mouseLabel)
+ Label mouseLabel,
+ Label directionalityLabel,
+ Label directionalityX,
+ Label directionalityY,
+ Label direcionalityActiveValueTitle,
+ Label lpNormLabel,
+ Label lpNormActiveLabel,
+ Label domainLabel,
+ Label domainActiveValueX,
+ Label domainActiveValueY,
+ Label rangeLabel,
+ Label rangeActiveValueX,
+ Label rangeActiveValueY)
{
+ fakeBox.Checked = false;
+ fakeBox.Hide();
+
var accelCalculator = new AccelCalculator(
new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI, 1),
new Field(pollRateTextBox.TextBox, form, Constants.DefaultPollRate, 1));
@@ -143,6 +166,8 @@ namespace grapher.Models
var optionSetYLeft = rotation.Left + rotation.Width;
+ var directionalityLeft = directionalityPanel.Left;
+
var weightX = new Option(
weightBoxX,
form,
@@ -267,6 +292,36 @@ namespace grapher.Models
new ActiveValueLabel(midpointActiveLabelY, activeValueTitleY),
optionSetYLeft);
+ var lpNorm = new Option(
+ new Field(lpNormBox, form, 2),
+ lpNormLabel,
+ new ActiveValueLabel(lpNormActiveLabel, direcionalityActiveValueTitle),
+ directionalityLeft);
+
+ var domain = new OptionXY(
+ domainBoxX,
+ domainBoxY,
+ fakeBox,
+ form,
+ 1,
+ domainLabel,
+ new ActiveValueLabelXY(
+ new ActiveValueLabel(domainActiveValueX, direcionalityActiveValueTitle),
+ new ActiveValueLabel(domainActiveValueY, direcionalityActiveValueTitle)),
+ false);
+
+ var range = new OptionXY(
+ rangeBoxX,
+ rangeBoxY,
+ fakeBox,
+ form,
+ 1,
+ rangeLabel,
+ new ActiveValueLabelXY(
+ new ActiveValueLabel(rangeActiveValueX, direcionalityActiveValueTitle),
+ new ActiveValueLabel(rangeActiveValueY, direcionalityActiveValueTitle)),
+ false);
+
var capOptionsX = new CapOptions(
velocityGainCapToolStripMenuItem,
legacyCapToolStripMenuItem,
@@ -315,12 +370,24 @@ namespace grapher.Models
rotationBox.Top + rotationBox.Height + Constants.OptionVerticalSeperation,
accelerationOptionsY);
+ var directionalOptions = new DirectionalityOptions(
+ directionalityPanel,
+ directionalityLabel,
+ directionalityX,
+ directionalityY,
+ direcionalityActiveValueTitle,
+ lpNorm,
+ domain,
+ range,
+ wholeCheckBox,
+ byComponentCheckBox,
+ 245);
+
var applyOptions = new ApplyOptions(
- wholeVectorToolStripMenuItem,
- byVectorComponentToolStripMenuItem,
byComponentXYLock,
optionsSetX,
optionsSetY,
+ directionalOptions,
sensitivity,
rotation,
lockXYLabel,
@@ -339,7 +406,6 @@ namespace grapher.Models
var mouseWatcher = new MouseWatcher(form, mouseLabel, accelCharts, settings);
-
return new AccelGUI(
form,
accelCalculator,
diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs
index 2c32753..42b7347 100644
--- a/grapher/Models/Calculations/AccelCalculator.cs
+++ b/grapher/Models/Calculations/AccelCalculator.cs
@@ -14,12 +14,24 @@ namespace grapher.Models.Calculations
{
public double velocity;
public double time;
+ public double angle;
public int x;
public int y;
}
#endregion Structs
+ #region Static
+
+ public static double[] SlowMovements =
+ {
+ 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.333, 3.666, 4.0, 4.333, 4.666,
+ };
+
+ public IEnumerable<double> Angles = GetAngles();
+
+ #endregion static
+
#region Constructors
public AccelCalculator(Field dpi, Field pollRate)
@@ -38,15 +50,15 @@ namespace grapher.Models.Calculations
public ReadOnlyCollection<SimulatedMouseInput> SimulatedInputY { get; private set; }
+ public IReadOnlyCollection<IReadOnlyCollection<SimulatedMouseInput>> SimulatedDirectionalInput { get; private set; }
+
public Field DPI { get; private set; }
public Field PollRate { get; private set; }
- private double CombinedMaxVelocity { get; set; }
-
- private double XYMaxVelocity { get; set; }
+ private double MaxVelocity { get; set; }
- private int Increment { get; set; }
+ private double Increment { get; set; }
private double MeasurementTime { get; set; }
@@ -58,10 +70,26 @@ namespace grapher.Models.Calculations
#region Methods
+ public static IEnumerable<double> GetAngles()
+ {
+ for(double i=0; i < (Constants.AngleDivisions); i++)
+ {
+ yield return (i / (Constants.AngleDivisions-1.0)) * (Math.PI / 2);
+ }
+ }
+
+ public static int NearestAngleDivision(double angle)
+ {
+ var angleTransformed = angle * 2 / Math.PI * (Constants.AngleDivisions-1);
+ return (int)Math.Round(angleTransformed);
+ }
+
public void Calculate(AccelChartData data, ManagedAccel accel, double starter, ICollection<SimulatedMouseInput> simulatedInputData)
{
double lastInputMagnitude = 0;
double lastOutputMagnitude = 0;
+ SimulatedMouseInput lastInput;
+ double lastSlope = 0;
double maxRatio = 0.0;
double minRatio = Double.MaxValue;
@@ -81,6 +109,13 @@ namespace grapher.Models.Calculations
var output = accel.Accelerate(simulatedInputDatum.x, simulatedInputDatum.y, simulatedInputDatum.time);
var outMagnitude = Velocity(output.Item1, output.Item2, simulatedInputDatum.time);
+ var inDiff = Math.Round(simulatedInputDatum.velocity - lastInputMagnitude, 5);
+ var outDiff = Math.Round(outMagnitude - lastOutputMagnitude, 5);
+
+ if (inDiff == 0)
+ {
+ continue;
+ }
if (!data.VelocityPoints.ContainsKey(simulatedInputDatum.velocity))
{
@@ -99,7 +134,8 @@ namespace grapher.Models.Calculations
}
var ratio = outMagnitude / simulatedInputDatum.velocity;
-
+ var slope = inDiff > 0 ? outDiff / inDiff : starter;
+
if (ratio > maxRatio)
{
maxRatio = ratio;
@@ -110,10 +146,6 @@ namespace grapher.Models.Calculations
minRatio = ratio;
}
- var inDiff = simulatedInputDatum.velocity - lastInputMagnitude;
- var outDiff = outMagnitude - lastOutputMagnitude;
- var slope = inDiff > 0 ? outDiff / inDiff : starter;
-
if (slope > maxSlope)
{
maxSlope = slope;
@@ -137,6 +169,8 @@ namespace grapher.Models.Calculations
lastInputMagnitude = simulatedInputDatum.velocity;
lastOutputMagnitude = outMagnitude;
index += 1;
+ lastInput = simulatedInputDatum;
+ lastSlope = slope;
}
index--;
@@ -154,12 +188,8 @@ namespace grapher.Models.Calculations
data.MinGain = minSlope;
}
- public void CalculateCombinedDiffSens(AccelData data, ManagedAccel accel, DriverSettings settings, ICollection<SimulatedMouseInput> simulatedInputData)
+ public void CalculateDirectional(AccelChartData[] dataByAngle, ManagedAccel accel, DriverSettings settings, IReadOnlyCollection<IReadOnlyCollection<SimulatedMouseInput>> simulatedInputData)
{
- double lastInputMagnitude = 0;
- double lastOutputMagnitudeX = 0;
- double lastOutputMagnitudeY = 0;
-
double maxRatio = 0.0;
double minRatio = Double.MaxValue;
double maxSlope = 0.0;
@@ -168,156 +198,143 @@ namespace grapher.Models.Calculations
Sensitivity = GetSens(ref settings);
- double log = -2;
- int index = 0;
- int logIndex = 0;
+ int angleIndex = 0;
- foreach (var simulatedInputDatum in simulatedInputData)
+ foreach (var simulatedInputDataAngle in simulatedInputData)
{
- if (simulatedInputDatum.velocity <= 0)
- {
- continue;
- }
-
- var output = accel.Accelerate(simulatedInputDatum.x, simulatedInputDatum.y, simulatedInputDatum.time);
- var outputWithoutSens = StripThisSens(output.Item1, output.Item2);
- var magnitudeWithoutSens = Velocity(outputWithoutSens.Item1, outputWithoutSens.Item2, simulatedInputDatum.time);
+ double log = -2;
+ int index = 0;
+ int logIndex = 0;
+ double lastInputMagnitude = 0;
+ double lastOutputMagnitude = 0;
- var ratio = magnitudeWithoutSens / simulatedInputDatum.velocity;
+ var data = dataByAngle[angleIndex];
- if (!data.Combined.VelocityPoints.ContainsKey(simulatedInputDatum.velocity))
+ foreach (var simulatedInputDatum in simulatedInputDataAngle)
{
- data.Combined.VelocityPoints.Add(simulatedInputDatum.velocity, magnitudeWithoutSens);
- }
- else
- {
- continue;
+ if (simulatedInputDatum.velocity <= 0)
+ {
+ continue;
+ }
+
+ var output = accel.Accelerate(simulatedInputDatum.x, simulatedInputDatum.y, simulatedInputDatum.time);
+ var magnitude = Velocity(output.Item1, output.Item2, simulatedInputDatum.time);
+ var inDiff = Math.Round(simulatedInputDatum.velocity - lastInputMagnitude, 5);
+ var outDiff = Math.Round(magnitude - lastOutputMagnitude, 5);
+
+ if (inDiff == 0)
+ {
+ continue;
+ }
+
+ if (!data.VelocityPoints.ContainsKey(simulatedInputDatum.velocity))
+ {
+ data.VelocityPoints.Add(simulatedInputDatum.velocity, magnitude);
+ }
+ else
+ {
+ continue;
+ }
+
+ while (Math.Pow(10, log) < magnitude && logIndex < data.LogToIndex.Length)
+ {
+ data.LogToIndex[logIndex] = index;
+ log += 0.01;
+ logIndex++;
+ }
+
+ var ratio = magnitude / simulatedInputDatum.velocity;
+ var slope = inDiff > 0 ? outDiff / inDiff : settings.sensitivity.x;
+
+ bool indexToMeasureExtrema = (angleIndex == 0) || (angleIndex == (Constants.AngleDivisions - 1));
+
+ if (indexToMeasureExtrema && (ratio > maxRatio))
+ {
+ maxRatio = ratio;
+ }
+
+ if (indexToMeasureExtrema && (ratio < minRatio))
+ {
+ minRatio = ratio;
+ }
+
+ if (indexToMeasureExtrema && (slope > maxSlope))
+ {
+ maxSlope = slope;
+ }
+
+ if (indexToMeasureExtrema && (slope < minSlope))
+ {
+ minSlope = slope;
+ }
+
+ if (!data.AccelPoints.ContainsKey(simulatedInputDatum.velocity))
+ {
+ data.AccelPoints.Add(simulatedInputDatum.velocity, ratio);
+ }
+
+ if (!data.GainPoints.ContainsKey(simulatedInputDatum.velocity))
+ {
+ data.GainPoints.Add(simulatedInputDatum.velocity, slope);
+ }
+
+ lastInputMagnitude = simulatedInputDatum.velocity;
+ lastOutputMagnitude = magnitude;
+ index += 1;
}
- while (Math.Pow(10,log) < magnitudeWithoutSens && logIndex < data.Combined.LogToIndex.Length)
+ index--;
+
+ while (log <= 5.0)
{
- data.Combined.LogToIndex[logIndex] = index;
+ data.LogToIndex[logIndex] = index;
log += 0.01;
logIndex++;
}
- var xRatio = settings.sensitivity.x * ratio;
- var yRatio = settings.sensitivity.y * ratio;
-
- if (xRatio > maxRatio)
- {
- maxRatio = xRatio;
- }
-
- if (xRatio < minRatio)
- {
- minRatio = xRatio;
- }
-
- if (yRatio > maxRatio)
- {
- maxRatio = yRatio;
- }
-
- if (yRatio < minRatio)
- {
- minRatio = yRatio;
- }
-
- if (!data.X.AccelPoints.ContainsKey(simulatedInputDatum.velocity))
- {
- data.X.AccelPoints.Add(simulatedInputDatum.velocity, xRatio);
- }
-
- if (!data.Y.AccelPoints.ContainsKey(simulatedInputDatum.velocity))
- {
- data.Y.AccelPoints.Add(simulatedInputDatum.velocity, yRatio);
- }
-
- var xOut = xRatio * simulatedInputDatum.velocity;
- var yOut = yRatio * simulatedInputDatum.velocity;
-
- var inDiff = simulatedInputDatum.velocity - lastInputMagnitude;
- var xOutDiff = xOut - lastOutputMagnitudeX;
- var yOutDiff = yOut - lastOutputMagnitudeY;
- var xSlope = inDiff > 0 ? xOutDiff / inDiff : settings.sensitivity.x;
- var ySlope = inDiff > 0 ? yOutDiff / inDiff : settings.sensitivity.y;
-
- if (xSlope > maxSlope)
- {
- maxSlope = xSlope;
- }
-
- if (xSlope < minSlope)
- {
- minSlope = xSlope;
- }
-
- if (ySlope > maxSlope)
- {
- maxSlope = ySlope;
- }
-
- if (ySlope < minSlope)
- {
- minSlope = ySlope;
- }
-
- if (!data.X.VelocityPoints.ContainsKey(simulatedInputDatum.velocity))
- {
- data.X.VelocityPoints.Add(simulatedInputDatum.velocity, xOut);
- }
-
- if (!data.Y.VelocityPoints.ContainsKey(simulatedInputDatum.velocity))
- {
- data.Y.VelocityPoints.Add(simulatedInputDatum.velocity, yOut);
- }
-
- if (!data.X.GainPoints.ContainsKey(simulatedInputDatum.velocity))
- {
- data.X.GainPoints.Add(simulatedInputDatum.velocity, xSlope);
- }
-
- if (!data.Y.GainPoints.ContainsKey(simulatedInputDatum.velocity))
- {
- data.Y.GainPoints.Add(simulatedInputDatum.velocity, ySlope);
- }
-
- lastInputMagnitude = simulatedInputDatum.velocity;
- lastOutputMagnitudeX = xOut;
- lastOutputMagnitudeY = yOut;
- index += 1;
+ angleIndex++;
}
- index--;
-
- while (log <= 5.0)
- {
- data.Combined.LogToIndex[logIndex] = index;
- log += 0.01;
- logIndex++;
- }
-
- data.Combined.MaxAccel = maxRatio;
- data.Combined.MinAccel = minRatio;
- data.Combined.MaxGain = maxSlope;
- data.Combined.MinGain = minSlope;
+ dataByAngle[0].MaxAccel = maxRatio;
+ dataByAngle[0].MinAccel = minRatio;
+ dataByAngle[0].MaxGain = maxSlope;
+ dataByAngle[0].MinGain = minSlope;
}
public ReadOnlyCollection<SimulatedMouseInput> GetSimulatedInput()
{
var magnitudes = new List<SimulatedMouseInput>();
- for (int i = 0; i < CombinedMaxVelocity; i+=Increment)
+
+ foreach (var slowMoveX in SlowMovements)
{
- for (int j = 0; j <= i; j+=Increment)
- {
- SimulatedMouseInput mouseInputData;
- mouseInputData.x = i;
- mouseInputData.y = j;
- mouseInputData.time = MeasurementTime;
- mouseInputData.velocity = Velocity(i, j, mouseInputData.time);
- magnitudes.Add(mouseInputData);
- }
+ var slowMoveY = slowMoveX;
+ var ratio = slowMoveX > 0.0 ? slowMoveY / slowMoveX : 1;
+ var ceilX = (int)Math.Round(slowMoveX*50);
+ var ceilY = (int)Math.Round(slowMoveY*50);
+ var ceilMagnitude = Magnitude(ceilX, ceilY);
+ var timeFactor = ceilMagnitude / Magnitude(slowMoveX, slowMoveY);
+
+ SimulatedMouseInput mouseInputData;
+ mouseInputData.x = ceilX;
+ mouseInputData.y = ceilY;
+ mouseInputData.time = MeasurementTime*timeFactor;
+ mouseInputData.velocity = Velocity(ceilX, ceilY, mouseInputData.time);
+ mouseInputData.angle = Math.Atan2(ceilY, ceilX);
+ magnitudes.Add(mouseInputData);
+
+ }
+
+ for (double i = 5; i < MaxVelocity; i+=Increment)
+ {
+ SimulatedMouseInput mouseInputData;
+ var ceil = (int)Math.Ceiling(i);
+ var timeFactor = ceil / i;
+ mouseInputData.x = ceil;
+ mouseInputData.y = 0;
+ mouseInputData.time = MeasurementTime * timeFactor;
+ mouseInputData.velocity = Velocity(ceil, 0, mouseInputData.time);
+ mouseInputData.angle = Math.Atan2(ceil, 0);
+ magnitudes.Add(mouseInputData);
}
magnitudes.Sort((m1, m2) => m1.velocity.CompareTo(m2.velocity));
@@ -329,13 +346,29 @@ namespace grapher.Models.Calculations
{
var magnitudes = new List<SimulatedMouseInput>();
- for (int i = 0; i < XYMaxVelocity; i+=Increment)
+ foreach (var slowMovement in SlowMovements)
{
+ var ceil = (int)Math.Ceiling(slowMovement);
+ var timeFactor = ceil / slowMovement;
SimulatedMouseInput mouseInputData;
- mouseInputData.x = i;
+ mouseInputData.x = ceil;
mouseInputData.y = 0;
- mouseInputData.time = MeasurementTime;
- mouseInputData.velocity = Velocity(i, 0, mouseInputData.time);
+ mouseInputData.time = MeasurementTime*timeFactor;
+ mouseInputData.velocity = Velocity(ceil, 0, mouseInputData.time);
+ mouseInputData.angle = 0;
+ magnitudes.Add(mouseInputData);
+ }
+
+ for (double i = 5; i < MaxVelocity; i+=Increment)
+ {
+ SimulatedMouseInput mouseInputData;
+ var ceil = (int)Math.Ceiling(i);
+ var timeFactor = ceil / i;
+ mouseInputData.x = ceil;
+ mouseInputData.y = 0;
+ mouseInputData.time = MeasurementTime*timeFactor;
+ mouseInputData.velocity = Velocity(ceil, 0, mouseInputData.time);
+ mouseInputData.angle = 0;
magnitudes.Add(mouseInputData);
}
@@ -346,19 +379,86 @@ namespace grapher.Models.Calculations
{
var magnitudes = new List<SimulatedMouseInput>();
- for (int i = 0; i < XYMaxVelocity; i+=Increment)
+ foreach (var slowMovement in SlowMovements)
+ {
+ var ceil = (int)Math.Ceiling(slowMovement);
+ var timeFactor = ceil / slowMovement;
+ SimulatedMouseInput mouseInputData;
+ mouseInputData.x = 0;
+ mouseInputData.y = ceil;
+ mouseInputData.time = MeasurementTime*timeFactor;
+ mouseInputData.velocity = Velocity(0, ceil, mouseInputData.time);
+ mouseInputData.angle = 0;
+ magnitudes.Add(mouseInputData);
+ }
+
+ for (double i = 5; i < MaxVelocity; i+=Increment)
{
SimulatedMouseInput mouseInputData;
+ var ceil = (int)Math.Ceiling(i);
+ var timeFactor = ceil / i;
mouseInputData.x = 0;
- mouseInputData.y = i;
+ mouseInputData.y = ceil;
mouseInputData.time = MeasurementTime;
mouseInputData.velocity = Velocity(0, i, mouseInputData.time);
+ mouseInputData.angle = Math.PI / 2;
magnitudes.Add(mouseInputData);
}
return magnitudes.AsReadOnly();
}
+ public IReadOnlyCollection<IReadOnlyCollection<SimulatedMouseInput>> GetSimulatedDirectionalInput()
+ {
+ var magnitudesByAngle = new List<IReadOnlyCollection<SimulatedMouseInput>>();
+
+ foreach (var angle in Angles)
+ {
+ var magnitudes = new List<SimulatedMouseInput>();
+
+ foreach (var slowMoveMagnitude in SlowMovements)
+ {
+ var slowMoveX = Math.Round(slowMoveMagnitude * Math.Cos(angle), 4);
+ var slowMoveY = Math.Round(slowMoveMagnitude * Math.Sin(angle), 4);
+ var ceilX = (int)Math.Round(slowMoveX*90);
+ var ceilY = (int)Math.Round(slowMoveY*90);
+ var ceilMagnitude = Magnitude(ceilX, ceilY);
+ var timeFactor = ceilMagnitude / slowMoveMagnitude;
+
+ SimulatedMouseInput mouseInputData;
+ mouseInputData.x = ceilX;
+ mouseInputData.y = ceilY;
+ mouseInputData.time = timeFactor;
+ mouseInputData.velocity = Velocity(ceilX, ceilY, timeFactor);
+ mouseInputData.angle = angle;
+ magnitudes.Add(mouseInputData);
+ }
+
+ for (double magnitude = 5; magnitude < MaxVelocity; magnitude+=Increment)
+ {
+ var slowMoveX = Math.Round(magnitude * Math.Cos(angle), 4);
+ var slowMoveY = Math.Round(magnitude * Math.Sin(angle), 4);
+ var ratio = slowMoveX > 0.0 ? slowMoveY / slowMoveX : 90;
+ var ceilX = (int)Math.Round(slowMoveX*90);
+ var ceilY = (int)Math.Round(slowMoveY*ratio);
+ var ceilMagnitude = Magnitude(ceilX, ceilY);
+ var timeFactor = ceilMagnitude / magnitude;
+
+ SimulatedMouseInput mouseInputData;
+ mouseInputData.x = ceilX;
+ mouseInputData.y = ceilY;
+ mouseInputData.time = timeFactor;
+ mouseInputData.velocity = Velocity(ceilX, ceilY, mouseInputData.time);
+ mouseInputData.angle = angle;
+ magnitudes.Add(mouseInputData);
+ }
+
+ magnitudesByAngle.Add(magnitudes.AsReadOnly());
+ }
+
+ return magnitudesByAngle.AsReadOnly();
+ }
+
public static double Magnitude(int x, int y)
{
return Math.Sqrt(x * x + y * y);
@@ -405,15 +505,14 @@ namespace grapher.Models.Calculations
public void ScaleByMouseSettings()
{
- var dpiPollFactor = DPI.Data / PollRate.Data;
- CombinedMaxVelocity = dpiPollFactor * Constants.MaxMultiplier;
- var ratio = CombinedMaxVelocity / Constants.Resolution;
- Increment = ratio > 1 ? (int) Math.Floor(ratio) : 1;
- MeasurementTime = Increment == 1 ? 1 / ratio : 1;
- XYMaxVelocity = CombinedMaxVelocity * Constants.XYToCombinedRatio;
+ MaxVelocity = DPI.Data * Constants.MaxMultiplier;
+ var ratio = MaxVelocity / Constants.Resolution;
+ Increment = ratio;
+ MeasurementTime = 1;
SimulatedInputCombined = GetSimulatedInput();
SimulatedInputX = GetSimulatInputX();
SimulatedInputY = GetSimulatedInputY();
+ SimulatedDirectionalInput = GetSimulatedDirectionalInput();
}
#endregion Methods
diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs
deleted file mode 100644
index d35217f..0000000
--- a/grapher/Models/Calculations/AccelData.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using grapher.Models.Charts;
-using grapher.Models.Serialized;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace grapher.Models.Calculations
-{
- public class AccelData
- {
- #region Constructors
-
- public AccelData(
- EstimatedPoints combined,
- EstimatedPoints x,
- EstimatedPoints y)
- {
- Combined = new AccelChartData();
- X = new AccelChartData();
- Y = new AccelChartData();
-
- Estimated = combined;
- EstimatedX = x;
- EstimatedY = y;
-
- OutVelocityToPoints = new Dictionary<double, (double, double, double, double, double, double, double)>();
- }
-
- #endregion Constructors
-
- #region Properties
-
- public AccelChartData Combined { get; }
-
- public AccelChartData X { get; }
-
- public AccelChartData Y { get; }
-
- private EstimatedPoints Estimated { get; }
-
- private EstimatedPoints EstimatedX { get; }
-
- private EstimatedPoints EstimatedY { get; }
-
- private Dictionary<double, (double, double, double, double, double, double, double)> OutVelocityToPoints { get; }
-
- #endregion Properties
-
- #region Methods
-
- public void Clear()
- {
- Combined.Clear();
- X.Clear();
- Y.Clear();
- OutVelocityToPoints.Clear();
- }
-
- public void CalculateDots(double x, double y, double timeInMs)
- {
- var outVelocity = AccelCalculator.Velocity(x, y, timeInMs);
-
- (var inCombVel, var combSens, var combGain) = Combined.FindPointValuesFromOut(outVelocity);
- Estimated.Velocity.Set(inCombVel, outVelocity);
- Estimated.Sensitivity.Set(inCombVel, combSens);
- Estimated.Gain.Set(inCombVel, combGain);
- }
-
- public void CalculateDotsXY(double x, double y, double timeInMs)
- {
- var outX = Math.Abs(x) / timeInMs;
- var outY = Math.Abs(y) / timeInMs;
-
- (var inXVelocity, var xSensitivity, var xGain) = X.FindPointValuesFromOut(outX);
- EstimatedX.Velocity.Set(inXVelocity, outX);
- EstimatedX.Sensitivity.Set(inXVelocity, xSensitivity);
- EstimatedX.Gain.Set(inXVelocity, xGain);
-
- (var inYVelocity, var ySensitivity, var yGain) = Y.FindPointValuesFromOut(outY);
- EstimatedY.Velocity.Set(inYVelocity, outY);
- EstimatedY.Sensitivity.Set(inYVelocity, ySensitivity);
- EstimatedY.Gain.Set(inYVelocity, yGain);
- }
-
- public void CalculateDotsCombinedDiffSens(double x, double y, double timeInMs, DriverSettings settings)
- {
- (var xStripped, var yStripped) = AccelCalculator.StripSens(x, y, settings.sensitivity.x, settings.sensitivity.y);
- var outVelocity = AccelCalculator.Velocity(xStripped, yStripped, timeInMs);
-
- if (OutVelocityToPoints.TryGetValue(outVelocity, out var points))
- {
- EstimatedX.Sensitivity.Set(points.Item1, points.Item2);
- EstimatedX.Velocity.Set(points.Item1, points.Item3);
- EstimatedX.Gain.Set(points.Item1, points.Item4);
- EstimatedY.Sensitivity.Set(points.Item1, points.Item5);
- EstimatedY.Velocity.Set(points.Item1, points.Item6);
- EstimatedY.Gain.Set(points.Item1, points.Item7);
- }
- else
- {
- var index = Combined.GetVelocityIndex(outVelocity);
- var inVelocity = Combined.VelocityPoints.ElementAt(index).Key;
- var xPoints = X.ValuesAtIndex(index);
- var yPoints = Y.ValuesAtIndex(index);
- OutVelocityToPoints.Add(outVelocity, (inVelocity, xPoints.Item1, xPoints.Item2, xPoints.Item3, yPoints.Item1, yPoints.Item2, yPoints.Item3));
- EstimatedX.Sensitivity.Set(inVelocity, xPoints.Item1);
- EstimatedX.Velocity.Set(inVelocity, xPoints.Item2);
- EstimatedX.Gain.Set(inVelocity, xPoints.Item3);
- EstimatedY.Sensitivity.Set(inVelocity, yPoints.Item1);
- EstimatedY.Velocity.Set(inVelocity, yPoints.Item2);
- EstimatedY.Gain.Set(inVelocity, yPoints.Item3);
- }
- }
-
- #endregion Methods
- }
-}
diff --git a/grapher/Models/Calculations/Data/AccelDataCombined.cs b/grapher/Models/Calculations/Data/AccelDataCombined.cs
new file mode 100644
index 0000000..8efb9ac
--- /dev/null
+++ b/grapher/Models/Calculations/Data/AccelDataCombined.cs
@@ -0,0 +1,49 @@
+using grapher.Models.Charts;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Models.Calculations.Data
+{
+ public class AccelDataCombined : IAccelData
+ {
+ public AccelDataCombined(EstimatedPoints points, AccelCalculator calculator)
+ {
+ X = new AccelChartData();
+ Points = points;
+ Calculator = calculator;
+ }
+
+ public AccelChartData X { get; }
+
+ public AccelChartData Y { get => X; }
+
+ private EstimatedPoints Points { get; }
+
+ private AccelCalculator Calculator { get; }
+
+ public void CalculateDots(double x, double y, double timeInMs)
+ {
+ var outVelocity = AccelCalculator.Velocity(x, y, timeInMs);
+
+ (var inCombVel, var combSens, var combGain) = X.FindPointValuesFromOut(outVelocity);
+ Points.Velocity.Set(inCombVel, outVelocity);
+ Points.Sensitivity.Set(inCombVel, combSens);
+ Points.Gain.Set(inCombVel, combGain);
+
+ }
+
+ public void Clear()
+ {
+ X.Clear();
+ }
+
+ public void CreateGraphData(ManagedAccel accel, DriverSettings settings)
+ {
+ Clear();
+ Calculator.Calculate(X, accel, settings.sensitivity.x, Calculator.SimulatedInputCombined);
+ }
+ }
+}
diff --git a/grapher/Models/Calculations/Data/AccelDataXYComponential.cs b/grapher/Models/Calculations/Data/AccelDataXYComponential.cs
new file mode 100644
index 0000000..6231eb3
--- /dev/null
+++ b/grapher/Models/Calculations/Data/AccelDataXYComponential.cs
@@ -0,0 +1,64 @@
+using grapher.Models.Charts;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Models.Calculations.Data
+{
+ public class AccelDataXYComponential : IAccelData
+ {
+ public AccelDataXYComponential(
+ EstimatedPoints xPoints,
+ EstimatedPoints yPoints,
+ AccelCalculator calculator)
+ {
+ X = new AccelChartData();
+ Y = new AccelChartData();
+ XPoints = xPoints;
+ YPoints = yPoints;
+ Calculator = calculator;
+ }
+
+ public AccelChartData X { get; }
+
+ public AccelChartData Y { get; }
+
+ private EstimatedPoints XPoints { get; }
+
+ private EstimatedPoints YPoints { get; }
+
+ private AccelCalculator Calculator { get; }
+
+ public void CalculateDots(double x, double y, double timeInMs)
+ {
+ var outX = Math.Abs(x) / timeInMs;
+ var outY = Math.Abs(y) / timeInMs;
+
+ (var inXVelocity, var xSensitivity, var xGain) = X.FindPointValuesFromOut(outX);
+ XPoints.Velocity.Set(inXVelocity, outX);
+ XPoints.Sensitivity.Set(inXVelocity, xSensitivity);
+ XPoints.Gain.Set(inXVelocity, xGain);
+
+ (var inYVelocity, var ySensitivity, var yGain) = Y.FindPointValuesFromOut(outY);
+ YPoints.Velocity.Set(inYVelocity, outY);
+ YPoints.Sensitivity.Set(inYVelocity, ySensitivity);
+ YPoints.Gain.Set(inYVelocity, yGain);
+
+ }
+
+ public void Clear()
+ {
+ X.Clear();
+ Y.Clear();
+ }
+
+ public void CreateGraphData(ManagedAccel accel, DriverSettings settings)
+ {
+ Clear();
+ Calculator.Calculate(X, accel, settings.sensitivity.x, Calculator.SimulatedInputX);
+ Calculator.Calculate(Y, accel, settings.sensitivity.y, Calculator.SimulatedInputY);
+ }
+ }
+}
diff --git a/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs b/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs
new file mode 100644
index 0000000..8bd889d
--- /dev/null
+++ b/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs
@@ -0,0 +1,84 @@
+using grapher.Models.Charts;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Models.Calculations.Data
+{
+ public class AccelDataXYDirectional : IAccelData
+ {
+ public AccelDataXYDirectional(
+ EstimatedPoints xPoints,
+ EstimatedPoints yPoints,
+ AccelCalculator calculator)
+ {
+ XPoints = xPoints;
+ YPoints = yPoints;
+ Calculator = calculator;
+ AngleToData = new AccelChartData[Constants.AngleDivisions];
+ FillAngleData();
+ }
+
+ public AccelChartData X { get => AngleToData[0]; }
+
+ public AccelChartData Y { get => AngleToData[Constants.AngleDivisions-1]; }
+
+ public double SensitivityMax { get => X.MaxAccel; }
+
+ public double SensitivityMin { get => X.MinAccel; }
+
+ public double GainMax { get => X.MaxGain; }
+
+ public double GainMin { get => X.MinGain; }
+
+ private AccelChartData[] AngleToData { get; }
+
+ private EstimatedPoints XPoints { get; }
+
+ private EstimatedPoints YPoints { get; }
+
+ private AccelCalculator Calculator { get; }
+
+ public void CalculateDots(double x, double y, double timeInMs)
+ {
+ var outVelocity = AccelCalculator.Velocity(x, y, timeInMs);
+ var outAngle = Math.Atan2(Math.Abs(y),Math.Abs(x));
+ var nearestAngleDivision = AccelCalculator.NearestAngleDivision(outAngle);
+ var data = AngleToData[nearestAngleDivision];
+ var index = data.GetVelocityIndex(outVelocity);
+ var inVelocity = data.VelocityPoints.ElementAt(index).Key;
+ var xPoints = X.ValuesAtIndex(index);
+ var yPoints = Y.ValuesAtIndex(index);
+ XPoints.Sensitivity.Set(inVelocity, xPoints.Item1);
+ XPoints.Velocity.Set(inVelocity, xPoints.Item2);
+ XPoints.Gain.Set(inVelocity, xPoints.Item3);
+ YPoints.Sensitivity.Set(inVelocity, yPoints.Item1);
+ YPoints.Velocity.Set(inVelocity, yPoints.Item2);
+ YPoints.Gain.Set(inVelocity, yPoints.Item3);
+ }
+
+ public void Clear()
+ {
+ foreach (var data in AngleToData)
+ {
+ data.Clear();
+ }
+ }
+
+ public void CreateGraphData(ManagedAccel accel, DriverSettings settings)
+ {
+ Clear();
+ Calculator.CalculateDirectional(AngleToData, accel, settings, Calculator.SimulatedDirectionalInput);
+ }
+
+ private void FillAngleData()
+ {
+ for(int i=0; i < Constants.AngleDivisions; i++)
+ {
+ AngleToData[i] = new AccelChartData();
+ }
+ }
+ }
+}
diff --git a/grapher/Models/Calculations/Data/IAccelData.cs b/grapher/Models/Calculations/Data/IAccelData.cs
new file mode 100644
index 0000000..576e6df
--- /dev/null
+++ b/grapher/Models/Calculations/Data/IAccelData.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Models.Calculations.Data
+{
+ public interface IAccelData
+ {
+ void CalculateDots(double x, double y, double timeInMs);
+
+ void CreateGraphData(ManagedAccel accel, DriverSettings settings);
+
+ void Clear();
+
+ AccelChartData X { get; }
+
+ AccelChartData Y { get; }
+ }
+}
diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs
index b7abb35..2369432 100644
--- a/grapher/Models/Charts/AccelCharts.cs
+++ b/grapher/Models/Charts/AccelCharts.cs
@@ -1,9 +1,8 @@
using grapher.Models.Calculations;
+using grapher.Models.Calculations.Data;
using grapher.Models.Charts;
using grapher.Models.Charts.ChartState;
-using grapher.Models.Serialized;
using System;
-using System.Drawing;
using System.Windows.Forms;
namespace grapher
@@ -26,8 +25,14 @@ namespace grapher
var estimatedX = new EstimatedPoints();
var estimatedY = new EstimatedPoints();
SetupCharts(sensitivityChart, velocityChart, gainChart, estimated, estimatedX, estimatedY);
- var accelData = new AccelData(estimated, estimatedX, estimatedY);
- ChartStateManager = new ChartStateManager(sensitivityChart, velocityChart, gainChart, accelData, accelCalculator);
+ ChartStateManager = new ChartStateManager(
+ sensitivityChart,
+ velocityChart,
+ gainChart,
+ accelCalculator,
+ estimated,
+ estimatedY,
+ estimatedX);
ContainingForm = form;
EnableVelocityAndGain = enableVelocityAndGain;
@@ -56,7 +61,7 @@ namespace grapher
private Button WriteButton { get; }
- public AccelData AccelData
+ public IAccelData AccelData
{
get
{
@@ -80,14 +85,6 @@ namespace grapher
}
}
- public int TopChartHeight
- {
- get
- {
- return ChartState.SensitivityChart.Height;
- }
- }
-
private int FormBorderHeight { get; }
private ChartState ChartState { get; set; }
diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs
index 0bb141e..5a86713 100644
--- a/grapher/Models/Charts/ChartState/ChartState.cs
+++ b/grapher/Models/Charts/ChartState/ChartState.cs
@@ -1,4 +1,5 @@
using grapher.Models.Calculations;
+using grapher.Models.Calculations.Data;
using grapher.Models.Serialized;
using System;
using System.Collections.Generic;
@@ -15,13 +16,11 @@ namespace grapher.Models.Charts.ChartState
ChartXY sensitivityChart,
ChartXY velocityChart,
ChartXY gainChart,
- AccelData accelData,
AccelCalculator calculator)
{
SensitivityChart = sensitivityChart;
VelocityChart = velocityChart;
GainChart = gainChart;
- Data = accelData;
Calculator = calculator;
TwoDotsPerGraph = false;
}
@@ -32,7 +31,7 @@ namespace grapher.Models.Charts.ChartState
public ChartXY GainChart { get; }
- public AccelData Data { get; }
+ public IAccelData Data { get; protected set; }
public AccelCalculator Calculator { get; }
@@ -40,13 +39,19 @@ namespace grapher.Models.Charts.ChartState
internal bool TwoDotsPerGraph { get; set; }
- public abstract void MakeDots(double x, double y, double timeInMs);
+ public virtual void MakeDots(double x, double y, double timeInMs)
+ {
+ Data.CalculateDots(x, y, timeInMs);
+ }
public abstract void Bind();
public abstract void Activate();
- public abstract void Calculate(ManagedAccel accel, DriverSettings settings);
+ public virtual void Calculate(ManagedAccel accel, DriverSettings settings)
+ {
+ Data.CreateGraphData(accel, settings);
+ }
public void Redraw()
{
@@ -77,12 +82,14 @@ namespace grapher.Models.Charts.ChartState
public void ShowVelocityAndGain()
{
+ SensitivityChart.SetHeight(Constants.SensitivityChartTogetherHeight);
VelocityChart.Show();
GainChart.Show();
}
public void HideVelocityAndGain()
{
+ SensitivityChart.SetHeight(Constants.SensitivityChartAloneHeight);
VelocityChart.Hide();
GainChart.Hide();
}
diff --git a/grapher/Models/Charts/ChartState/ChartStateManager.cs b/grapher/Models/Charts/ChartState/ChartStateManager.cs
index 54d2e81..3d4bbec 100644
--- a/grapher/Models/Charts/ChartState/ChartStateManager.cs
+++ b/grapher/Models/Charts/ChartState/ChartStateManager.cs
@@ -14,28 +14,32 @@ namespace grapher.Models.Charts.ChartState
ChartXY sensitivityChart,
ChartXY velocityChart,
ChartXY gainChat,
- AccelData accelData,
- AccelCalculator accelCalculator)
+ AccelCalculator accelCalculator,
+ EstimatedPoints combined,
+ EstimatedPoints xPoints,
+ EstimatedPoints yPoints)
{
CombinedState = new CombinedState(
sensitivityChart,
velocityChart,
gainChat,
- accelData,
+ combined,
accelCalculator);
XYOneGraphState = new XYOneGraphState(
sensitivityChart,
velocityChart,
gainChat,
- accelData,
+ xPoints,
+ yPoints,
accelCalculator);
XYTwoGraphState = new XYTwoGraphState(
sensitivityChart,
velocityChart,
gainChat,
- accelData,
+ xPoints,
+ yPoints,
accelCalculator);
}
@@ -52,7 +56,9 @@ namespace grapher.Models.Charts.ChartState
if (settings.combineMagnitudes)
{
- if (settings.sensitivity.x != settings.sensitivity.y)
+ if (settings.sensitivity.x != settings.sensitivity.y ||
+ settings.domainArgs.domainXY.x != settings.domainArgs.domainXY.y ||
+ settings.rangeXY.x != settings.rangeXY.y)
{
chartState = XYOneGraphState;
}
diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs
index 9eadb87..3511cec 100644
--- a/grapher/Models/Charts/ChartState/CombinedState.cs
+++ b/grapher/Models/Charts/ChartState/CombinedState.cs
@@ -1,4 +1,5 @@
using grapher.Models.Calculations;
+using grapher.Models.Calculations.Data;
using grapher.Models.Serialized;
namespace grapher.Models.Charts.ChartState
@@ -9,15 +10,16 @@ namespace grapher.Models.Charts.ChartState
ChartXY sensitivityChart,
ChartXY velocityChart,
ChartXY gainChart,
- AccelData accelData,
+ EstimatedPoints points,
AccelCalculator accelCalculator)
: base(
sensitivityChart,
velocityChart,
gainChart,
- accelData,
accelCalculator)
- { }
+ {
+ Data = new AccelDataCombined(points, accelCalculator);
+ }
public override void Activate()
{
@@ -30,23 +32,13 @@ namespace grapher.Models.Charts.ChartState
GainChart.ClearSecondDots();
}
- public override void MakeDots(double x, double y, double timeInMs)
- {
- Data.CalculateDots(x, y, timeInMs);
- }
-
public override void Bind()
{
- SensitivityChart.Bind(Data.Combined.AccelPoints);
- VelocityChart.Bind(Data.Combined.VelocityPoints);
- GainChart.Bind(Data.Combined.GainPoints);
- SensitivityChart.SetMinMax(Data.Combined.MinAccel, Data.Combined.MaxAccel);
- GainChart.SetMinMax(Data.Combined.MinGain, Data.Combined.MaxGain);
- }
-
- public override void Calculate(ManagedAccel accel, DriverSettings settings)
- {
- Calculator.Calculate(Data.Combined, accel, settings.sensitivity.x, Calculator.SimulatedInputCombined);
+ SensitivityChart.Bind(Data.X.AccelPoints);
+ VelocityChart.Bind(Data.X.VelocityPoints);
+ GainChart.Bind(Data.X.GainPoints);
+ SensitivityChart.SetMinMax(Data.X.MinAccel, Data.X.MaxAccel);
+ GainChart.SetMinMax(Data.X.MinGain, Data.X.MaxGain);
}
}
}
diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
index 2b3cd9c..34e9070 100644
--- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs
+++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
@@ -1,4 +1,5 @@
using grapher.Models.Calculations;
+using grapher.Models.Calculations.Data;
using grapher.Models.Serialized;
namespace grapher.Models.Charts.ChartState
@@ -9,18 +10,22 @@ namespace grapher.Models.Charts.ChartState
ChartXY sensitivityChart,
ChartXY velocityChart,
ChartXY gainChart,
- AccelData accelData,
+ EstimatedPoints xPoints,
+ EstimatedPoints yPoints,
AccelCalculator accelCalculator)
: base(
sensitivityChart,
velocityChart,
gainChart,
- accelData,
accelCalculator)
{
+ DataDirectional = new AccelDataXYDirectional(xPoints, yPoints, accelCalculator);
+ Data = DataDirectional;
TwoDotsPerGraph = true;
}
+ private AccelDataXYDirectional DataDirectional { get; }
+
public override void Activate()
{
SensitivityChart.SetCombined();
@@ -28,23 +33,13 @@ namespace grapher.Models.Charts.ChartState
GainChart.SetCombined();
}
- public override void MakeDots(double x, double y, double timeInMs)
- {
- Data.CalculateDotsCombinedDiffSens(x, y, timeInMs, Settings);
- }
-
public override void Bind()
{
SensitivityChart.BindXYCombined(Data.X.AccelPoints, Data.Y.AccelPoints);
VelocityChart.BindXYCombined(Data.X.VelocityPoints, Data.Y.VelocityPoints);
GainChart.BindXYCombined(Data.X.GainPoints, Data.Y.GainPoints);
- SensitivityChart.SetMinMax(Data.Combined.MinAccel, Data.Combined.MaxAccel);
- GainChart.SetMinMax(Data.Combined.MinGain, Data.Combined.MaxGain);
- }
-
- public override void Calculate(ManagedAccel accel, DriverSettings settings)
- {
- Calculator.CalculateCombinedDiffSens(Data, accel, settings, Calculator.SimulatedInputCombined);
+ SensitivityChart.SetMinMax(DataDirectional.SensitivityMin, DataDirectional.SensitivityMax);
+ GainChart.SetMinMax(DataDirectional.GainMin, DataDirectional.GainMax);
}
}
}
diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
index 732ea3c..5b6c2b8 100644
--- a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
+++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
@@ -1,4 +1,5 @@
using grapher.Models.Calculations;
+using grapher.Models.Calculations.Data;
using grapher.Models.Serialized;
using System;
@@ -10,15 +11,17 @@ namespace grapher.Models.Charts.ChartState
ChartXY sensitivityChart,
ChartXY velocityChart,
ChartXY gainChart,
- AccelData accelData,
+ EstimatedPoints xPoints,
+ EstimatedPoints yPoints,
AccelCalculator accelCalculator)
: base(
sensitivityChart,
velocityChart,
gainChart,
- accelData,
accelCalculator)
- { }
+ {
+ Data = new AccelDataXYComponential(xPoints, yPoints, accelCalculator);
+ }
public override DriverSettings Settings { get; set; }
@@ -33,11 +36,6 @@ namespace grapher.Models.Charts.ChartState
GainChart.ClearSecondDots();
}
- public override void MakeDots(double x, double y, double timeInMs)
- {
- Data.CalculateDotsXY(x, y, timeInMs);
- }
-
public override void Bind()
{
SensitivityChart.BindXY(Data.X.AccelPoints, Data.Y.AccelPoints);
@@ -47,11 +45,5 @@ namespace grapher.Models.Charts.ChartState
SensitivityChart.SetMinMaxXY(Data.X.MinAccel, Data.X.MaxAccel, Data.Y.MinAccel, Data.Y.MaxAccel);
GainChart.SetMinMaxXY(Data.X.MinGain, Data.X.MaxGain, Data.Y.MinGain, Data.Y.MaxGain);
}
-
- public override void Calculate(ManagedAccel accel, DriverSettings settings)
- {
- Calculator.Calculate(Data.X, accel, settings.sensitivity.x, Calculator.SimulatedInputX);
- Calculator.Calculate(Data.Y, accel, settings.sensitivity.y, Calculator.SimulatedInputY);
- }
}
}
diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs
index 553ab3e..bd80ea2 100644
--- a/grapher/Models/Charts/ChartXY.cs
+++ b/grapher/Models/Charts/ChartXY.cs
@@ -244,8 +244,8 @@ namespace grapher
ChartX.ChartAreas[0].AxisY.Maximum = maxX * (1 + VerticalMargin);
VerifyRange(minY, maxY);
- ChartX.ChartAreas[0].AxisY.Minimum = minY * (1 - VerticalMargin);
- ChartX.ChartAreas[0].AxisY.Maximum = maxY * (1 + VerticalMargin);
+ ChartY.ChartAreas[0].AxisY.Minimum = minY * (1 - VerticalMargin);
+ ChartY.ChartAreas[0].AxisY.Maximum = maxY * (1 + VerticalMargin);
}
public void SetCombined()
diff --git a/grapher/Models/Fields/FieldXY.cs b/grapher/Models/Fields/FieldXY.cs
index a7db922..72f14ea 100644
--- a/grapher/Models/Fields/FieldXY.cs
+++ b/grapher/Models/Fields/FieldXY.cs
@@ -7,13 +7,14 @@ namespace grapher
{
#region Constructors
- public FieldXY(TextBox xBox, TextBox yBox, CheckBox lockCheckBox, Form containingForm, double defaultData)
+ public FieldXY(TextBox xBox, TextBox yBox, CheckBox lockCheckBox, Form containingForm, double defaultData, bool allowCombined = true)
{
XField = new Field(xBox, containingForm, defaultData);
YField = new Field(yBox, containingForm, defaultData);
YField.FormatString = Constants.ShortenedFormatString;
LockCheckBox = lockCheckBox;
LockCheckBox.CheckedChanged += new System.EventHandler(CheckChanged);
+ AllowCombined = allowCombined;
XField.Box.Width = (YField.Box.Left + YField.Box.Width - XField.Box.Left - Constants.DefaultFieldSeparation) / 2;
YField.Box.Width = XField.Box.Width;
@@ -24,7 +25,7 @@ namespace grapher
YField.Box.Left = XField.Box.Left + XField.Box.Width + Constants.DefaultFieldSeparation;
CombinedWidth = DefaultWidthX + DefaultWidthY + YField.Box.Left - (XField.Box.Left + DefaultWidthX);
- SetCombined();
+ Startup();
}
#endregion Constructors
@@ -116,6 +117,7 @@ namespace grapher
private int DefaultWidthY { get; }
+ private bool AllowCombined { get; }
#endregion Properties
@@ -127,9 +129,10 @@ namespace grapher
YField.SetNewDefault(y);
XField.SetToDefault();
- if (x != y)
+ if (x != y || !AllowCombined)
{
LockCheckBox.Checked = false;
+ YField.SetToDefault();
if (Combined)
{
@@ -147,6 +150,20 @@ namespace grapher
}
}
+ private void Startup()
+ {
+ if (AllowCombined)
+ {
+ SetCombined();
+ }
+ else
+ {
+ SetSeparate();
+ LockCheckBox.Hide();
+ LockCheckBox.Enabled = false;
+ }
+ }
+
private void CheckChanged(object sender, EventArgs e)
{
if (LockCheckBox.CheckState == CheckState.Checked)
@@ -161,11 +178,14 @@ namespace grapher
public void SetCombined()
{
- Combined = true;
- YField.SetToUnavailable();
- YField.Hide();
- XField.Box.Width = CombinedWidth;
- XField.FormatString = Constants.DefaultFieldFormatString;
+ if (AllowCombined)
+ {
+ Combined = true;
+ YField.SetToUnavailable();
+ YField.Hide();
+ XField.Box.Width = CombinedWidth;
+ XField.FormatString = Constants.DefaultFieldFormatString;
+ }
}
public void SetSeparate()
diff --git a/grapher/Models/Mouse/MouseWatcher.cs b/grapher/Models/Mouse/MouseWatcher.cs
index 151a2a2..163829f 100644
--- a/grapher/Models/Mouse/MouseWatcher.cs
+++ b/grapher/Models/Mouse/MouseWatcher.cs
@@ -1,6 +1,7 @@
using grapher.Models.Serialized;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
@@ -701,6 +702,8 @@ namespace grapher.Models.Mouse
RAWINPUTDEVICE[] devices = new RAWINPUTDEVICE[1];
devices[0] = device;
RegisterRawInputDevices(devices, 1, Marshal.SizeOf(typeof(RAWINPUTDEVICE)));
+ Stopwatch = new Stopwatch();
+ Stopwatch.Start();
}
#endregion Constructors
@@ -717,6 +720,8 @@ namespace grapher.Models.Mouse
private MouseData MouseData { get; }
+ private Stopwatch Stopwatch { get; }
+
private List<IntPtr> DeviceHandles { get; }
private bool AnyDevice { get; set; }
@@ -757,6 +762,11 @@ namespace grapher.Models.Mouse
if (relative && deviceMatch && (rawInput.Data.Mouse.LastX != 0 || rawInput.Data.Mouse.LastY != 0))
{
+ var time = Stopwatch.Elapsed.TotalMilliseconds;
+ Stopwatch.Restart();
+ time = time > 100 ? 100 : time;
+ time = time > (PollTime * 0.8) ? time : (PollTime * 0.8);
+
double x = rawInput.Data.Mouse.LastX;
double y = rawInput.Data.Mouse.LastY;
@@ -776,7 +786,7 @@ namespace grapher.Models.Mouse
}
MouseData.Set(rawInput.Data.Mouse.LastX, rawInput.Data.Mouse.LastY);
- AccelCharts.MakeDots(x, y, PollTime);
+ AccelCharts.MakeDots(x, y, time);
}
}
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index 4410a12..8d3fecb 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -289,7 +289,6 @@ namespace grapher
Limit,
Exponent,
Midpoint,
- WriteButton,
top);
}
diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs
index 381779c..f5b593e 100644
--- a/grapher/Models/Options/ActiveValueLabelXY.cs
+++ b/grapher/Models/Options/ActiveValueLabelXY.cs
@@ -140,6 +140,18 @@ namespace grapher.Models.Options
}
}
+ public void Hide()
+ {
+ X.Hide();
+ Y.Hide();
+ }
+
+ public void Show()
+ {
+ X.Show();
+ Y.Show();
+ }
+
private void Align (int width)
{
FullWidth = width;
diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs
index b8cc9bf..ffe430d 100644
--- a/grapher/Models/Options/ApplyOptions.cs
+++ b/grapher/Models/Options/ApplyOptions.cs
@@ -1,4 +1,5 @@
-using grapher.Models.Serialized;
+using grapher.Models.Options.Directionality;
+using grapher.Models.Serialized;
using System;
using System.Drawing;
using System.Windows.Forms;
@@ -10,24 +11,24 @@ namespace grapher.Models.Options
#region Constructors
public ApplyOptions(
- ToolStripMenuItem wholeVectorMenuItem,
- ToolStripMenuItem byComponentMenuItem,
CheckBox byComponentVectorXYLock,
AccelOptionSet optionSetX,
AccelOptionSet optionSetY,
+ DirectionalityOptions directionalityOptions,
OptionXY sensitivity,
Option rotation,
Label lockXYLabel,
AccelCharts accelCharts)
{
- WholeVectorMenuItem = wholeVectorMenuItem;
- ByComponentVectorMenuItem = byComponentMenuItem;
+ Directionality = directionalityOptions;
+ WholeVectorCheckBox = Directionality.WholeCheckBox;
+ ByComponentVectorCheckBox = Directionality.ByComponentCheckBox;
- WholeVectorMenuItem.Click += new System.EventHandler(OnWholeClicked);
- ByComponentVectorMenuItem.Click += new System.EventHandler(OnByComponentClicked);
+ WholeVectorCheckBox.Click += new System.EventHandler(OnWholeClicked);
+ ByComponentVectorCheckBox.Click += new System.EventHandler(OnByComponentClicked);
- WholeVectorMenuItem.CheckedChanged += new System.EventHandler(OnWholeCheckedChange);
- ByComponentVectorMenuItem.CheckedChanged += new System.EventHandler(OnByComponentCheckedChange);
+ WholeVectorCheckBox.CheckedChanged += new System.EventHandler(OnWholeCheckedChange);
+ ByComponentVectorCheckBox.CheckedChanged += new System.EventHandler(OnByComponentCheckedChange);
ByComponentVectorXYLock = byComponentVectorXYLock;
OptionSetX = optionSetX;
@@ -52,9 +53,9 @@ namespace grapher.Models.Options
#region Properties
- public ToolStripMenuItem WholeVectorMenuItem { get; }
+ public CheckBox WholeVectorCheckBox { get; }
- public ToolStripMenuItem ByComponentVectorMenuItem { get; }
+ public CheckBox ByComponentVectorCheckBox { get; }
public CheckBox ByComponentVectorXYLock { get; }
@@ -62,6 +63,8 @@ namespace grapher.Models.Options
public AccelOptionSet OptionSetY { get; }
+ public DirectionalityOptions Directionality { get; }
+
public OptionXY Sensitivity { get; }
public Option Rotation { get; }
@@ -114,8 +117,8 @@ namespace grapher.Models.Options
Sensitivity.SetActiveValues(xSens, ySens);
Rotation.SetActiveValue(rotation);
OptionSetX.SetActiveValues(xMode, xArgs);
- WholeVectorMenuItem.Checked = isWhole;
- ByComponentVectorMenuItem.Checked = !isWhole;
+ WholeVectorCheckBox.Checked = isWhole;
+ ByComponentVectorCheckBox.Checked = !isWhole;
ByComponentVectorXYLock.Checked = xArgs.Equals(yArgs);
OptionSetY.SetActiveValues(yMode, yArgs);
}
@@ -132,6 +135,8 @@ namespace grapher.Models.Options
settings.args.y,
settings.combineMagnitudes);
+ Directionality.SetActiveValues(settings);
+
AccelCharts.SetLogarithmic(
OptionSetX.Options.AccelerationType.LogarithmicCharts,
OptionSetY.Options.AccelerationType.LogarithmicCharts);
@@ -139,25 +144,27 @@ namespace grapher.Models.Options
public void OnWholeClicked(object sender, EventArgs e)
{
- if (!WholeVectorMenuItem.Checked)
+ if (!WholeVectorCheckBox.Checked)
{
- WholeVectorMenuItem.Checked = true;
- ByComponentVectorMenuItem.Checked = false;
+ WholeVectorCheckBox.Checked = true;
+ ByComponentVectorCheckBox.Checked = false;
+ Directionality.ToWhole();
}
}
public void OnByComponentClicked(object sender, EventArgs e)
{
- if (!ByComponentVectorMenuItem.Checked)
+ if (!ByComponentVectorCheckBox.Checked)
{
- WholeVectorMenuItem.Checked = false;
- ByComponentVectorMenuItem.Checked = true;
+ WholeVectorCheckBox.Checked = false;
+ ByComponentVectorCheckBox.Checked = true;
+ Directionality.ToByComponent();
}
}
public void OnWholeCheckedChange(object sender, EventArgs e)
{
- if (WholeVectorMenuItem.Checked)
+ if (WholeVectorCheckBox.Checked)
{
EnableWholeApplication();
}
@@ -165,7 +172,7 @@ namespace grapher.Models.Options
public void OnByComponentCheckedChange(object sender, EventArgs e)
{
- if (ByComponentVectorMenuItem.Checked)
+ if (ByComponentVectorCheckBox.Checked)
{
EnableByComponentApplication();
}
diff --git a/grapher/Models/Options/Directionality/DirectionalityOptions.cs b/grapher/Models/Options/Directionality/DirectionalityOptions.cs
new file mode 100644
index 0000000..c21b932
--- /dev/null
+++ b/grapher/Models/Options/Directionality/DirectionalityOptions.cs
@@ -0,0 +1,213 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options.Directionality
+{
+ public class DirectionalityOptions
+ {
+ public DirectionalityOptions(
+ Panel containingPanel,
+ Label directionalityLabel,
+ Label directionalityX,
+ Label directionalityY,
+ Label directionalityActiveValueTitle,
+ Option lpNorm,
+ OptionXY domain,
+ OptionXY range,
+ CheckBox wholeCheckBox,
+ CheckBox byComponentCheckBox,
+ int top)
+ {
+ ContainingPanel = containingPanel;
+ DirectionalityLabel = directionalityLabel;
+ DirectionalityX = directionalityX;
+ DirectionalityY = directionalityY;
+ DirectionalityActiveValueTitle = directionalityActiveValueTitle;
+ LpNorm = lpNorm;
+ Domain = domain;
+ Range = range;
+ WholeCheckBox = wholeCheckBox;
+ ByComponentCheckBox = byComponentCheckBox;
+
+ ContainingPanel.Paint += Panel_Paint;
+ DirectionalityLabel.Click += Title_click;
+ ContainingPanel.Top = top;
+ DirectionalityLabel.Left = Constants.DirectionalityTitlePad;
+ DirectionalityLabel.Top = Constants.DirectionalityTitlePad;
+ IsHidden = false;
+ ToWhole();
+ Hide();
+ }
+
+ public Panel ContainingPanel { get; }
+
+ public Label DirectionalityLabel { get; }
+
+ public Label DirectionalityX { get; }
+
+ public Label DirectionalityY { get; }
+
+ public Label DirectionalityActiveValueTitle { get; }
+
+ public Option LpNorm { get; }
+
+ public OptionXY Domain { get; }
+
+ public OptionXY Range { get; }
+
+ public CheckBox WholeCheckBox { get; }
+
+ public CheckBox ByComponentCheckBox { get; }
+
+ public int OpenHeight { get => WholeCheckBox.Bottom - DirectionalityLabel.Top + 2 * Constants.DirectionalityTitlePad; }
+
+ public int ClosedHeight { get => DirectionalityLabel.Height + 2 * Constants.DirectionalityTitlePad; }
+
+ private bool IsHidden { get; set; }
+
+ public DomainArgs GetDomainArgs()
+ {
+ if (!ByComponentCheckBox.Checked)
+ {
+ return new DomainArgs
+ {
+ domainXY = new Vec2<double>
+ {
+ x = Domain.Fields.X,
+ y = Domain.Fields.Y,
+ },
+ lpNorm = LpNorm.Field.Data,
+ };
+ }
+ else
+ {
+ return new DomainArgs
+ {
+ domainXY = new Vec2<double>
+ {
+ x = 1,
+ y = 1,
+ },
+ lpNorm = 2,
+ };
+
+ }
+ }
+
+ public Vec2<double> GetRangeXY()
+ {
+ if (!ByComponentCheckBox.Checked)
+ {
+ return new Vec2<double>
+ {
+ x = Range.Fields.X,
+ y = Range.Fields.Y,
+ };
+ }
+ else
+ {
+ return new Vec2<double>
+ {
+ x = 1,
+ y = 1,
+ };
+ }
+
+ }
+
+ public void SetActiveValues(DriverSettings settings)
+ {
+ Domain.SetActiveValues(settings.domainArgs.domainXY.x, settings.domainArgs.domainXY.y);
+ LpNorm.SetActiveValue(settings.domainArgs.lpNorm);
+ Range.SetActiveValues(settings.rangeXY.x, settings.rangeXY.y);
+ }
+
+ public void Hide()
+ {
+ if (!IsHidden)
+ {
+ DirectionalityX.Hide();
+ DirectionalityY.Hide();
+ DirectionalityActiveValueTitle.Hide();
+ LpNorm.Hide();
+ Domain.Hide();
+ Range.Hide();
+ WholeCheckBox.Hide();
+ ByComponentCheckBox.Hide();
+ DirectionalityLabel.Text = Constants.DirectionalityTitleClosed;
+ DrawHidden();
+ IsHidden = true;
+ }
+ }
+
+ public void Show()
+ {
+ if (IsHidden)
+ {
+ DirectionalityX.Show();
+ DirectionalityY.Show();
+ DirectionalityActiveValueTitle.Show();
+ LpNorm.Show();
+ Domain.Show();
+ Range.Show();
+ Range.Fields.LockCheckBox.Hide();
+ WholeCheckBox.Show();
+ ByComponentCheckBox.Show();
+ DirectionalityLabel.Text = Constants.DirectionalityTitleOpen;
+ DrawShown();
+ IsHidden = false;
+ }
+ }
+
+ public void ToByComponent()
+ {
+ LpNorm.SetToUnavailable();
+ Domain.SetToUnavailable();
+ Range.SetToUnavailable();
+ }
+
+ public void ToWhole()
+ {
+ LpNorm.SetToAvailable();
+ Domain.SetToAvailable();
+ Range.SetToAvailable();
+ }
+
+ private void DrawHidden()
+ {
+ ContainingPanel.Height = ClosedHeight;
+ ContainingPanel.Invalidate();
+ }
+
+ private void DrawShown()
+ {
+ ContainingPanel.Height = OpenHeight;
+ ContainingPanel.Invalidate();
+ }
+
+ private void Panel_Paint(object sender, PaintEventArgs e)
+ {
+ Color col = Color.DarkGray;
+ ButtonBorderStyle bbs = ButtonBorderStyle.Dashed;
+ int thickness = 2;
+ ControlPaint.DrawBorder(e.Graphics, this.ContainingPanel.ClientRectangle, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs);
+ }
+
+ private void Title_click(object sender, EventArgs e)
+ {
+ if (IsHidden)
+ {
+ Show();
+ }
+ else
+ {
+ Hide();
+ }
+ }
+ }
+}
diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs
index d5129d5..c6b68ba 100644
--- a/grapher/Models/Options/Option.cs
+++ b/grapher/Models/Options/Option.cs
@@ -171,6 +171,16 @@ namespace grapher
ActiveValueLabel.Align();
}
+ public void SetToUnavailable()
+ {
+ Field.SetToUnavailable();
+ }
+
+ public void SetToAvailable()
+ {
+ Field.SetToDefault();
+ }
+
#endregion Methods
}
}
diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs
index b4a2b27..102d05d 100644
--- a/grapher/Models/Options/OptionXY.cs
+++ b/grapher/Models/Options/OptionXY.cs
@@ -22,8 +22,9 @@ namespace grapher
Form containingForm,
double defaultData,
Label label,
- ActiveValueLabelXY activeValueLabels)
- : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData), label, activeValueLabels)
+ ActiveValueLabelXY activeValueLabels,
+ bool allowCombined = true)
+ : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, allowCombined), label, activeValueLabels)
{
}
@@ -35,7 +36,8 @@ namespace grapher
double defaultData,
Label label,
ActiveValueLabelXY activeValueLabels,
- string startingName):
+ string startingName,
+ bool allowCombined = true):
this(
xBox,
yBox,
@@ -43,7 +45,8 @@ namespace grapher
containingForm,
defaultData,
label,
- activeValueLabels)
+ activeValueLabels,
+ allowCombined)
{
SetName(startingName);
}
@@ -124,7 +127,6 @@ namespace grapher
{
ActiveValueLabels.SetValues(x, y);
Fields.SetActive(x, y);
-
}
public override void AlignActiveValues()
@@ -137,6 +139,7 @@ namespace grapher
Fields.Hide();
Fields.LockCheckBox.Hide();
Label.Hide();
+ ActiveValueLabels.Hide();
}
public void Show()
@@ -144,6 +147,7 @@ namespace grapher
Fields.Show();
Fields.LockCheckBox.Show();
Label.Show();
+ ActiveValueLabels.Show();
}
public override void Show(string name)
@@ -153,6 +157,18 @@ namespace grapher
Show();
}
+ public void SetToUnavailable()
+ {
+ Fields.XField.SetToUnavailable();
+ Fields.YField.SetToUnavailable();
+ }
+
+ public void SetToAvailable()
+ {
+ Fields.XField.SetToDefault();
+ Fields.YField.SetToDefault();
+ }
+
#endregion Methods
}
}