summaryrefslogtreecommitdiff
path: root/grapher/Models/Charts
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-08-13 13:39:40 -0700
committerJacob Palecki <[email protected]>2020-08-13 13:39:40 -0700
commit6602649bd7f9a9849b25fe55a5e5e8a617f40b70 (patch)
tree01360e218547270421b7ef91a7239b2702d1297e /grapher/Models/Charts
parentDot to show mouse move (diff)
downloadrawaccel-6602649bd7f9a9849b25fe55a5e5e8a617f40b70.tar.xz
rawaccel-6602649bd7f9a9849b25fe55a5e5e8a617f40b70.zip
All works smoothly
Diffstat (limited to 'grapher/Models/Charts')
-rw-r--r--grapher/Models/Charts/AccelCharts.cs70
-rw-r--r--grapher/Models/Charts/ChartXY.cs41
-rw-r--r--grapher/Models/Charts/EstimatedPoints.cs25
3 files changed, 82 insertions, 54 deletions
diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs
index e593bb9..42377c4 100644
--- a/grapher/Models/Charts/AccelCharts.cs
+++ b/grapher/Models/Charts/AccelCharts.cs
@@ -1,4 +1,5 @@
using grapher.Models.Calculations;
+using grapher.Models.Charts;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -13,27 +14,6 @@ namespace grapher
{
public class AccelCharts
{
- public struct ChartPoint
- {
- public double X;
- public double Y;
- }
-
- public struct EstimatedPoints
- {
- public ChartPoint CombinedVelocity;
- public ChartPoint CombinedSensitivity;
- public ChartPoint CombinedGain;
-
- public ChartPoint XVelocity;
- public ChartPoint XSensitivity;
- public ChartPoint XGain;
-
- public ChartPoint YVelocity;
- public ChartPoint YSensitivity;
- public ChartPoint YGain;
- }
-
public const int ChartSeparationVertical = 10;
/// <summary> Needed to show full contents in form. Unsure why. </summary>
@@ -47,28 +27,21 @@ namespace grapher
ToolStripMenuItem enableVelocityAndGain,
ICollection<CheckBox> checkBoxesXY)
{
+ Estimated = new EstimatedPoints();
+ EstimatedX = new EstimatedPoints();
+ EstimatedY = new EstimatedPoints();
+ AccelData = new AccelData(Estimated, EstimatedX, EstimatedY);
+
ContaingForm = form;
SensitivityChart = sensitivityChart;
VelocityChart = velocityChart;
GainChart = gainChart;
EnableVelocityAndGain = enableVelocityAndGain;
CheckBoxesXY = checkBoxesXY;
- AccelData = new AccelData();
-
- Estimated = new EstimatedPoints
- {
- CombinedVelocity = new ChartPoint { X = 0, Y = 0 },
- CombinedSensitivity = new ChartPoint { X = 0, Y = 0 },
- CombinedGain = new ChartPoint { X = 0, Y = 0 },
-
- XVelocity = new ChartPoint { X = 0, Y = 0 },
- XSensitivity = new ChartPoint { X = 0, Y = 0 },
- XGain = new ChartPoint { X = 0, Y = 0 },
- YVelocity = new ChartPoint { X = 0, Y = 0 },
- YSensitivity = new ChartPoint { X = 0, Y = 0 },
- YGain = new ChartPoint { X = 0, Y = 0 },
- };
+ SensitivityChart.SetPointBinds(Estimated.Sensitivity, EstimatedX.Sensitivity, EstimatedY.Sensitivity);
+ VelocityChart.SetPointBinds(Estimated.Velocity, EstimatedX.Velocity, EstimatedY.Velocity);
+ GainChart.SetPointBinds(Estimated.Gain, EstimatedX.Gain, EstimatedY.Gain);
SensitivityChart.SetTop(0);
VelocityChart.SetHeight(SensitivityChart.Height);
@@ -99,7 +72,11 @@ namespace grapher
public AccelData AccelData { get; }
- private EstimatedPoints Estimated;
+ private EstimatedPoints Estimated { get; }
+
+ private EstimatedPoints EstimatedX { get; }
+
+ private EstimatedPoints EstimatedY { get; }
private ICollection<CheckBox> CheckBoxesXY { get; }
@@ -109,10 +86,21 @@ namespace grapher
public void MakeDots(int x, int y)
{
- AccelData.CalculateDots(x, y, ref Estimated);
- SensitivityChart.DrawPoints(Estimated.CombinedSensitivity, Estimated.XSensitivity, Estimated.YSensitivity);
- VelocityChart.DrawPoints(Estimated.CombinedVelocity, Estimated.XVelocity, Estimated.YVelocity);
- GainChart.DrawPoints(Estimated.CombinedGain, Estimated.XGain, Estimated.YGain);
+ if (Combined)
+ {
+ AccelData.CalculateDots(x, y);
+ }
+ else
+ {
+ AccelData.CalculateDotsXY(x, y);
+ }
+ }
+
+ public void DrawPoints()
+ {
+ SensitivityChart.DrawPoints();
+ VelocityChart.DrawPoints();
+ GainChart.DrawPoints();
}
public void Bind()
diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs
index 2c0ce2c..c0c8713 100644
--- a/grapher/Models/Charts/ChartXY.cs
+++ b/grapher/Models/Charts/ChartXY.cs
@@ -1,4 +1,6 @@
-using System;
+using grapher.Models.Charts;
+using grapher.Models.Mouse;
+using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
@@ -80,6 +82,12 @@ namespace grapher
public bool Combined { get; private set; }
+ private PointData CombinedPointData { get; set; }
+
+ private PointData XPointData { get; set; }
+
+ private PointData YPointData { get; set; }
+
#endregion Properties
#region Methods
@@ -109,26 +117,33 @@ namespace grapher
chart.Series[1].Points.AddXY(0, 0);
}
- public static void DrawPoint(Chart chart, ChartPoint point)
+ public static void DrawPoint(Chart chart, PointData point)
{
- chart.Series[1].Points[0].XValue = point.X;
- chart.Series[1].Points[0].YValues[0] = point.Y;
+ if (chart.Visible)
+ {
+ (var x, var y) = point.Get();
+ chart.Series[1].Points.DataBindXY(x, y);
+ chart.Update();
+ }
}
- public void DrawPoints(ChartPoint CombinedPoint, ChartPoint XPoint, ChartPoint YPoint)
+ public void SetPointBinds(PointData combined, PointData x, PointData y)
{
- if (Combined)
+ CombinedPointData = combined;
+ XPointData = x;
+ YPointData = y;
+ }
+
+ public void DrawPoints()
+ {
+ if(Combined)
{
- DrawPoint(ChartX, CombinedPoint);
+ DrawPoint(ChartX, CombinedPointData);
}
else
{
- DrawPoint(ChartX, XPoint);
- }
-
- if (ChartY.Visible)
- {
- DrawPoint(ChartY, YPoint);
+ DrawPoint(ChartX, XPointData);
+ DrawPoint(ChartY, YPointData);
}
}
diff --git a/grapher/Models/Charts/EstimatedPoints.cs b/grapher/Models/Charts/EstimatedPoints.cs
new file mode 100644
index 0000000..fa0718b
--- /dev/null
+++ b/grapher/Models/Charts/EstimatedPoints.cs
@@ -0,0 +1,25 @@
+using grapher.Models.Mouse;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Models.Charts
+{
+ public class EstimatedPoints
+ {
+ public EstimatedPoints()
+ {
+ Sensitivity = new PointData();
+ Velocity = new PointData();
+ Gain = new PointData();
+ }
+
+ public PointData Sensitivity { get; }
+
+ public PointData Velocity { get; }
+
+ public PointData Gain { get; }
+ }
+}