summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-08-12 19:04:23 -0700
committerJacob Palecki <[email protected]>2020-08-12 19:04:23 -0700
commita6a9f6785eb416ac48d34bb320265c812efc600b (patch)
tree871ca3005e21f1c172f955a457610ebd91cdc788
parentFixed some edge cases around not using enter (diff)
downloadrawaccel-a6a9f6785eb416ac48d34bb320265c812efc600b.tar.xz
rawaccel-a6a9f6785eb416ac48d34bb320265c812efc600b.zip
Add ability to have x\y graphs
-rw-r--r--grapher/AccelCharts.cs50
-rw-r--r--grapher/AccelGUI.cs6
-rw-r--r--grapher/ChartXY.cs142
-rw-r--r--grapher/Form1.Designer.cs85
-rw-r--r--grapher/Form1.cs65
-rw-r--r--grapher/grapher.csproj1
6 files changed, 268 insertions, 81 deletions
diff --git a/grapher/AccelCharts.cs b/grapher/AccelCharts.cs
index 62c60e5..9952016 100644
--- a/grapher/AccelCharts.cs
+++ b/grapher/AccelCharts.cs
@@ -11,16 +11,16 @@ namespace grapher
{
public class AccelCharts
{
- public const int ChartSeparation = 10;
+ public const int ChartSeparationVertical = 10;
/// <summary> Needed to show full contents in form. Unsure why. </summary>
public const int FormHeightPadding = 35;
public AccelCharts(
Form form,
- Chart sensitivityChart,
- Chart velocityChart,
- Chart gainChart,
+ ChartXY sensitivityChart,
+ ChartXY velocityChart,
+ ChartXY gainChart,
ToolStripMenuItem enableVelocityAndGain)
{
ContaingForm = form;
@@ -29,11 +29,11 @@ namespace grapher
GainChart = gainChart;
EnableVelocityAndGain = enableVelocityAndGain;
- SensitivityChart.Top = 0;
- VelocityChart.Height = SensitivityChart.Height;
- VelocityChart.Top = SensitivityChart.Height + ChartSeparation;
- GainChart.Height = SensitivityChart.Height;
- GainChart.Top = VelocityChart.Top + VelocityChart.Height + ChartSeparation;
+ SensitivityChart.SetTop(0);
+ VelocityChart.SetHeight(SensitivityChart.Height);
+ VelocityChart.SetTop(SensitivityChart.Height + ChartSeparationVertical);
+ GainChart.SetHeight(SensitivityChart.Height);
+ GainChart.SetTop(VelocityChart.Top + VelocityChart.Height + ChartSeparationVertical);
Rectangle screenRectangle = ContaingForm.RectangleToScreen(ContaingForm.ClientRectangle);
FormBorderHeight = screenRectangle.Top - ContaingForm.Top;
@@ -42,15 +42,16 @@ namespace grapher
EnableVelocityAndGain.CheckedChanged += new System.EventHandler(OnEnableCheckStateChange);
HideVelocityAndGain();
+ ShowCombined();
}
public Form ContaingForm { get; }
- public Chart SensitivityChart { get; }
+ public ChartXY SensitivityChart { get; }
- public Chart VelocityChart { get; }
+ public ChartXY VelocityChart { get; }
- public Chart GainChart { get; }
+ public ChartXY GainChart { get; }
public ToolStripMenuItem EnableVelocityAndGain { get; }
@@ -78,9 +79,9 @@ namespace grapher
VelocityChart.Show();
GainChart.Show();
ContaingForm.Height = SensitivityChart.Height +
- ChartSeparation +
+ ChartSeparationVertical +
VelocityChart.Height +
- ChartSeparation +
+ ChartSeparationVertical +
GainChart.Height +
FormBorderHeight;
}
@@ -91,5 +92,26 @@ namespace grapher
GainChart.Hide();
ContaingForm.Height = SensitivityChart.Height + FormBorderHeight;
}
+
+ private void ShowXandYSeparate()
+ {
+ SensitivityChart.SetSeparate();
+ VelocityChart.SetSeparate();
+ GainChart.SetSeparate();
+ UpdateFormWidth();
+ }
+
+ private void ShowCombined()
+ {
+ SensitivityChart.SetCombined();
+ VelocityChart.SetCombined();
+ GainChart.SetCombined();
+ UpdateFormWidth();
+ }
+
+ private void UpdateFormWidth()
+ {
+ ContaingForm.Width = SensitivityChart.Left + SensitivityChart.Width;
+ }
}
}
diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs
index ae05359..54564b3 100644
--- a/grapher/AccelGUI.cs
+++ b/grapher/AccelGUI.cs
@@ -169,9 +169,9 @@ namespace grapher
lastOutputMagnitude = outMagnitude;
}
- AccelCharts.SensitivityChart.Series[0].Points.DataBindXY(OrderedAccelPoints.Keys, OrderedAccelPoints.Values);
- AccelCharts.VelocityChart.Series[0].Points.DataBindXY(OrderedVelocityPoints.Keys, OrderedVelocityPoints.Values);
- AccelCharts.GainChart.Series[0].Points.DataBindXY(OrderedGainPoints.Keys, OrderedGainPoints.Values);
+ AccelCharts.SensitivityChart.ChartX.Series[0].Points.DataBindXY(OrderedAccelPoints.Keys, OrderedAccelPoints.Values);
+ AccelCharts.VelocityChart.ChartX.Series[0].Points.DataBindXY(OrderedVelocityPoints.Keys, OrderedVelocityPoints.Values);
+ AccelCharts.GainChart.ChartX.Series[0].Points.DataBindXY(OrderedGainPoints.Keys, OrderedGainPoints.Values);
}
#endregion methods
diff --git a/grapher/ChartXY.cs b/grapher/ChartXY.cs
new file mode 100644
index 0000000..4bb1bd5
--- /dev/null
+++ b/grapher/ChartXY.cs
@@ -0,0 +1,142 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Windows.Forms.DataVisualization.Charting;
+
+namespace grapher
+{
+ public class ChartXY
+ {
+ public const int ChartSeparationHorizontal = 10;
+
+ public ChartXY(Chart chartX, Chart chartY)
+ {
+ ChartX = chartX;
+ ChartY = chartY;
+
+ ChartY.Top = ChartX.Top;
+ ChartY.Height = ChartX.Height;
+ ChartY.Width = ChartX.Width;
+ ChartY.Left = ChartX.Left + ChartX.Width + ChartSeparationHorizontal;
+
+ SetupChart(ChartX);
+ SetupChart(ChartY);
+ }
+
+ public Chart ChartX { get; }
+
+ public Chart ChartY { get; }
+
+ public static void SetupChart(Chart chart)
+ {
+ chart.ChartAreas[0].AxisX.RoundAxisValues();
+
+ chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
+ chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
+
+ chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01;
+ chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001;
+
+ chart.ChartAreas[0].CursorY.Interval = 0.001;
+
+ chart.ChartAreas[0].CursorX.AutoScroll = true;
+ chart.ChartAreas[0].CursorY.AutoScroll = true;
+
+ chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
+ chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
+
+ chart.ChartAreas[0].CursorX.IsUserEnabled = true;
+ chart.ChartAreas[0].CursorY.IsUserEnabled = true;
+ }
+
+ public int Height {
+ get
+ {
+ return ChartX.Height;
+ }
+ }
+
+ public int Width {
+ get
+ {
+ if (Combined)
+ {
+ return ChartX.Width;
+ }
+ else
+ {
+ return ChartY.Left + ChartY.Width - ChartX.Left;
+ }
+ }
+ }
+
+ public int Top {
+ get
+ {
+ return ChartX.Height;
+ }
+ }
+
+ public int Left {
+ get
+ {
+ return ChartX.Left;
+ }
+ }
+
+ public bool Combined { get; private set; }
+
+ public void SetCombined()
+ {
+ if (!Combined)
+ {
+ ChartY.Hide();
+ Combined = true;
+ }
+ }
+
+ public void SetSeparate()
+ {
+ if (Combined)
+ {
+ if (ChartX.Visible)
+ {
+ ChartY.Show();
+ }
+
+ Combined = false;
+ }
+ }
+
+ public void Hide()
+ {
+ ChartX.Hide();
+ ChartY.Hide();
+ }
+
+ public void Show()
+ {
+ ChartX.Show();
+
+ if (!Combined)
+ {
+ ChartY.Show();
+ }
+ }
+
+ public void SetTop(int top)
+ {
+ ChartX.Top = top;
+ ChartY.Top = top;
+ }
+
+ public void SetHeight(int height)
+ {
+ ChartX.Height = height;
+ ChartY.Height = height;
+ }
+ }
+}
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index bcfb9b5..ab9c6b2 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -39,6 +39,15 @@ namespace grapher
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend5 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend6 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.accelTypeDrop = new System.Windows.Forms.ComboBox();
this.sensitivityBoxX = new System.Windows.Forms.TextBox();
@@ -74,10 +83,16 @@ namespace grapher
this.capStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sensitivityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.velocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.AccelerationChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
+ this.VelocityChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
+ this.GainChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit();
this.menuStrip1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.AccelerationChartY)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.VelocityChartY)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.GainChartY)).BeginInit();
this.SuspendLayout();
//
// AccelerationChart
@@ -361,7 +376,7 @@ namespace grapher
this.advancedToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(963, 24);
+ this.menuStrip1.Size = new System.Drawing.Size(1693, 24);
this.menuStrip1.TabIndex = 30;
this.menuStrip1.Text = "menuStrip1";
//
@@ -412,11 +427,71 @@ namespace grapher
this.velocityGainToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
this.velocityGainToolStripMenuItem.Text = "Velocity Gain";
//
+ // AccelerationChartY
+ //
+ chartArea4.AxisX.Title = "Speed (counts/ms)";
+ chartArea4.AxisY.Title = "Sensitivity (magnitude ratio)";
+ chartArea4.Name = "ChartArea1";
+ this.AccelerationChartY.ChartAreas.Add(chartArea4);
+ legend4.Name = "Legend1";
+ this.AccelerationChartY.Legends.Add(legend4);
+ this.AccelerationChartY.Location = new System.Drawing.Point(969, 0);
+ this.AccelerationChartY.Name = "AccelerationChartY";
+ series4.ChartArea = "ChartArea1";
+ series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series4.Legend = "Legend1";
+ series4.Name = "Accelerated Sensitivity";
+ this.AccelerationChartY.Series.Add(series4);
+ this.AccelerationChartY.Size = new System.Drawing.Size(723, 328);
+ this.AccelerationChartY.TabIndex = 31;
+ this.AccelerationChartY.Text = "chart1";
+ //
+ // VelocityChartY
+ //
+ chartArea5.AxisX.Title = "Speed (count/ms)";
+ chartArea5.AxisY.Title = "Output Speed (counts/ms)";
+ chartArea5.Name = "ChartArea1";
+ this.VelocityChartY.ChartAreas.Add(chartArea5);
+ legend5.Name = "Legend1";
+ this.VelocityChartY.Legends.Add(legend5);
+ this.VelocityChartY.Location = new System.Drawing.Point(970, 334);
+ this.VelocityChartY.Name = "VelocityChartY";
+ series5.ChartArea = "ChartArea1";
+ series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series5.Legend = "Legend1";
+ series5.Name = "Mouse Velocity";
+ this.VelocityChartY.Series.Add(series5);
+ this.VelocityChartY.Size = new System.Drawing.Size(723, 307);
+ this.VelocityChartY.TabIndex = 32;
+ this.VelocityChartY.Text = "chart1";
+ //
+ // GainChartY
+ //
+ chartArea6.AxisX.Title = "Speed (counts/ms)";
+ chartArea6.AxisY.Title = "Slope of Velocity Chart";
+ chartArea6.Name = "ChartArea1";
+ this.GainChartY.ChartAreas.Add(chartArea6);
+ legend6.Name = "Legend1";
+ this.GainChartY.Legends.Add(legend6);
+ this.GainChartY.Location = new System.Drawing.Point(970, 647);
+ this.GainChartY.Name = "GainChartY";
+ series6.ChartArea = "ChartArea1";
+ series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series6.Legend = "Legend1";
+ series6.Name = "Velocity Gain";
+ this.GainChartY.Series.Add(series6);
+ this.GainChartY.Size = new System.Drawing.Size(723, 309);
+ this.GainChartY.TabIndex = 33;
+ this.GainChartY.Text = "chart1";
+ //
// RawAcceleration
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(963, 958);
+ this.ClientSize = new System.Drawing.Size(1693, 958);
+ this.Controls.Add(this.GainChartY);
+ this.Controls.Add(this.VelocityChartY);
+ this.Controls.Add(this.AccelerationChartY);
this.Controls.Add(this.GainChart);
this.Controls.Add(this.VelocityChart);
this.Controls.Add(this.LockXYLabel);
@@ -454,6 +529,9 @@ namespace grapher
((System.ComponentModel.ISupportInitialize)(this.GainChart)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.AccelerationChartY)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.VelocityChartY)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.GainChartY)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -496,6 +574,9 @@ namespace grapher
private System.Windows.Forms.ToolStripMenuItem capStyleToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem sensitivityToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem velocityGainToolStripMenuItem;
+ private System.Windows.Forms.DataVisualization.Charting.Chart AccelerationChartY;
+ private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChartY;
+ private System.Windows.Forms.DataVisualization.Charting.Chart GainChartY;
}
}
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index 518ffc3..da9bd5f 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -126,9 +126,9 @@ namespace grapher
this,
new AccelCharts(
this,
- AccelerationChart,
- VelocityChart,
- GainChart,
+ new ChartXY(AccelerationChart, AccelerationChartY),
+ new ChartXY(VelocityChart, VelocityChartY),
+ new ChartXY(GainChart, GainChartY),
showVelocityGainToolStripMenuItem),
managedAcceleration,
accelerationOptions,
@@ -141,65 +141,6 @@ namespace grapher
limitOrExponent,
midpoint,
writeButton);
-
- this.AccelerationChart.ChartAreas[0].AxisX.RoundAxisValues();
-
- this.AccelerationChart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
- this.AccelerationChart.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
-
- this.AccelerationChart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01;
- this.AccelerationChart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001;
-
- this.AccelerationChart.ChartAreas[0].CursorY.Interval = 0.001;
-
- this.AccelerationChart.ChartAreas[0].CursorX.AutoScroll = true;
- this.AccelerationChart.ChartAreas[0].CursorY.AutoScroll = true;
-
- this.AccelerationChart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
- this.AccelerationChart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
-
- this.AccelerationChart.ChartAreas[0].CursorX.IsUserEnabled = true;
- this.AccelerationChart.ChartAreas[0].CursorY.IsUserEnabled = true;
-
-
- this.VelocityChart.ChartAreas[0].AxisX.RoundAxisValues();
-
- this.VelocityChart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
- this.VelocityChart.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
-
- this.VelocityChart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01;
- this.VelocityChart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001;
-
- this.VelocityChart.ChartAreas[0].CursorY.Interval = 0.001;
-
- this.VelocityChart.ChartAreas[0].CursorX.AutoScroll = true;
- this.VelocityChart.ChartAreas[0].CursorY.AutoScroll = true;
-
- this.VelocityChart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
- this.VelocityChart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
-
- this.VelocityChart.ChartAreas[0].CursorX.IsUserEnabled = true;
- this.VelocityChart.ChartAreas[0].CursorY.IsUserEnabled = true;
-
-
- this.GainChart.ChartAreas[0].AxisX.RoundAxisValues();
-
- this.GainChart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
- this.GainChart.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
-
- this.GainChart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01;
- this.GainChart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001;
-
- this.GainChart.ChartAreas[0].CursorY.Interval = 0.001;
-
- this.GainChart.ChartAreas[0].CursorX.AutoScroll = true;
- this.GainChart.ChartAreas[0].CursorY.AutoScroll = true;
-
- this.GainChart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
- this.GainChart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
-
- this.GainChart.ChartAreas[0].CursorX.IsUserEnabled = true;
- this.GainChart.ChartAreas[0].CursorY.IsUserEnabled = true;
}
#endregion Constructor
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index da70b46..2cce072 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -51,6 +51,7 @@
<Compile Include="AccelGUI.cs" />
<Compile Include="AccelOptions.cs" />
<Compile Include="CapOptions.cs" />
+ <Compile Include="ChartXY.cs" />
<Compile Include="Field.cs" />
<Compile Include="FieldXY.cs" />
<Compile Include="Form1.cs">