summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2021-07-01 19:13:12 -0700
committerJacob Palecki <[email protected]>2021-07-01 19:13:12 -0700
commitac0a6eb86c8d783c21cb246d688a221913b15789 (patch)
tree9b4021b1ab0401191a228dd6539612b2f72ae936
parentBetter-written LUT panels (diff)
downloadrawaccel-ac0a6eb86c8d783c21cb246d688a221913b15789.tar.xz
rawaccel-ac0a6eb86c8d783c21cb246d688a221913b15789.zip
Mostly working
-rw-r--r--grapher/Form1.Designer.cs152
-rw-r--r--grapher/Form1.cs4
-rw-r--r--grapher/Models/AccelGUIFactory.cs8
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs14
-rw-r--r--grapher/Models/Options/LUT/LUTPanelOptions.cs53
-rw-r--r--grapher/Models/Options/LUT/LutApplyOptions.cs3
-rw-r--r--grapher/Models/Options/TextOption.cs6
7 files changed, 119 insertions, 121 deletions
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index 415b5e0..2cd13d5 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -71,10 +71,14 @@ namespace grapher
System.Windows.Forms.DataVisualization.Charting.Title title6 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RawAcceleration));
this.optionsPanel = new System.Windows.Forms.Panel();
+ this.LutApplyActiveYLabel = new System.Windows.Forms.Label();
+ this.YLutApplyDropdown = new System.Windows.Forms.ComboBox();
+ this.XLutApplyDropdown = new System.Windows.Forms.ComboBox();
+ this.LutApplyActiveXLabel = new System.Windows.Forms.Label();
+ this.YLutApplyLabel = new System.Windows.Forms.Label();
+ this.XLutApplyLabel = new System.Windows.Forms.Label();
this.YLutPointsBox = new System.Windows.Forms.RichTextBox();
this.XLutPointsBox = new System.Windows.Forms.RichTextBox();
- this.LUTPanelY = new System.Windows.Forms.Panel();
- this.LUTPanelX = new System.Windows.Forms.Panel();
this.gainSwitchActiveLabelY = new System.Windows.Forms.Label();
this.gainSwitchActiveLabelX = new System.Windows.Forms.Label();
this.gainSwitchY = new System.Windows.Forms.CheckBox();
@@ -192,12 +196,8 @@ namespace grapher
this.GainChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.VelocityChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
- this.XLutApplyLabel = new System.Windows.Forms.Label();
- this.YLutApplyLabel = new System.Windows.Forms.Label();
- this.LutApplyActiveXLabel = new System.Windows.Forms.Label();
- this.XLutApplyDropdown = new System.Windows.Forms.ComboBox();
- this.YLutApplyDropdown = new System.Windows.Forms.ComboBox();
- this.LutApplyActiveYLabel = new System.Windows.Forms.Label();
+ this.XLutActiveValuesBox = new System.Windows.Forms.RichTextBox();
+ this.YLutActiveValuesBox = new System.Windows.Forms.RichTextBox();
this.optionsPanel.SuspendLayout();
this.DirectionalityPanel.SuspendLayout();
this.menuStrip1.SuspendLayout();
@@ -213,6 +213,8 @@ namespace grapher
// optionsPanel
//
this.optionsPanel.AutoSize = true;
+ this.optionsPanel.Controls.Add(this.YLutActiveValuesBox);
+ this.optionsPanel.Controls.Add(this.XLutActiveValuesBox);
this.optionsPanel.Controls.Add(this.LutApplyActiveYLabel);
this.optionsPanel.Controls.Add(this.YLutApplyDropdown);
this.optionsPanel.Controls.Add(this.XLutApplyDropdown);
@@ -221,8 +223,6 @@ namespace grapher
this.optionsPanel.Controls.Add(this.XLutApplyLabel);
this.optionsPanel.Controls.Add(this.YLutPointsBox);
this.optionsPanel.Controls.Add(this.XLutPointsBox);
- this.optionsPanel.Controls.Add(this.LUTPanelY);
- this.optionsPanel.Controls.Add(this.LUTPanelX);
this.optionsPanel.Controls.Add(this.gainSwitchActiveLabelY);
this.optionsPanel.Controls.Add(this.gainSwitchActiveLabelX);
this.optionsPanel.Controls.Add(this.gainSwitchY);
@@ -309,6 +309,58 @@ namespace grapher
this.optionsPanel.Size = new System.Drawing.Size(483, 956);
this.optionsPanel.TabIndex = 34;
//
+ // LutApplyActiveYLabel
+ //
+ this.LutApplyActiveYLabel.AutoSize = true;
+ this.LutApplyActiveYLabel.Location = new System.Drawing.Point(417, 565);
+ this.LutApplyActiveYLabel.Name = "LutApplyActiveYLabel";
+ this.LutApplyActiveYLabel.Size = new System.Drawing.Size(35, 13);
+ this.LutApplyActiveYLabel.TabIndex = 167;
+ this.LutApplyActiveYLabel.Text = "label1";
+ //
+ // YLutApplyDropdown
+ //
+ this.YLutApplyDropdown.FormattingEnabled = true;
+ this.YLutApplyDropdown.Location = new System.Drawing.Point(397, 527);
+ this.YLutApplyDropdown.Name = "YLutApplyDropdown";
+ this.YLutApplyDropdown.Size = new System.Drawing.Size(73, 21);
+ this.YLutApplyDropdown.TabIndex = 166;
+ //
+ // XLutApplyDropdown
+ //
+ this.XLutApplyDropdown.FormattingEnabled = true;
+ this.XLutApplyDropdown.Location = new System.Drawing.Point(320, 527);
+ this.XLutApplyDropdown.Name = "XLutApplyDropdown";
+ this.XLutApplyDropdown.Size = new System.Drawing.Size(65, 21);
+ this.XLutApplyDropdown.TabIndex = 165;
+ //
+ // LutApplyActiveXLabel
+ //
+ this.LutApplyActiveXLabel.AutoSize = true;
+ this.LutApplyActiveXLabel.Location = new System.Drawing.Point(200, 565);
+ this.LutApplyActiveXLabel.Name = "LutApplyActiveXLabel";
+ this.LutApplyActiveXLabel.Size = new System.Drawing.Size(35, 13);
+ this.LutApplyActiveXLabel.TabIndex = 164;
+ this.LutApplyActiveXLabel.Text = "label1";
+ //
+ // YLutApplyLabel
+ //
+ this.YLutApplyLabel.AutoSize = true;
+ this.YLutApplyLabel.Location = new System.Drawing.Point(397, 510);
+ this.YLutApplyLabel.Name = "YLutApplyLabel";
+ this.YLutApplyLabel.Size = new System.Drawing.Size(47, 13);
+ this.YLutApplyLabel.TabIndex = 163;
+ this.YLutApplyLabel.Text = "Apply as";
+ //
+ // XLutApplyLabel
+ //
+ this.XLutApplyLabel.AutoSize = true;
+ this.XLutApplyLabel.Location = new System.Drawing.Point(317, 511);
+ this.XLutApplyLabel.Name = "XLutApplyLabel";
+ this.XLutApplyLabel.Size = new System.Drawing.Size(47, 13);
+ this.XLutApplyLabel.TabIndex = 162;
+ this.XLutApplyLabel.Text = "Apply as";
+ //
// YLutPointsBox
//
this.YLutPointsBox.Location = new System.Drawing.Point(397, 447);
@@ -325,22 +377,6 @@ namespace grapher
this.XLutPointsBox.TabIndex = 160;
this.XLutPointsBox.Text = "";
//
- // LUTPanelY
- //
- this.LUTPanelY.AutoScroll = true;
- this.LUTPanelY.Location = new System.Drawing.Point(397, 369);
- this.LUTPanelY.Name = "LUTPanelY";
- this.LUTPanelY.Size = new System.Drawing.Size(73, 72);
- this.LUTPanelY.TabIndex = 159;
- //
- // LUTPanelX
- //
- this.LUTPanelX.AutoScroll = true;
- this.LUTPanelX.Location = new System.Drawing.Point(317, 369);
- this.LUTPanelX.Name = "LUTPanelX";
- this.LUTPanelX.Size = new System.Drawing.Size(68, 72);
- this.LUTPanelX.TabIndex = 158;
- //
// gainSwitchActiveLabelY
//
this.gainSwitchActiveLabelY.AutoSize = true;
@@ -1567,57 +1603,21 @@ namespace grapher
title6.Text = "Sensitivity";
this.AccelerationChart.Titles.Add(title6);
//
- // XLutApplyLabel
- //
- this.XLutApplyLabel.AutoSize = true;
- this.XLutApplyLabel.Location = new System.Drawing.Point(317, 511);
- this.XLutApplyLabel.Name = "XLutApplyLabel";
- this.XLutApplyLabel.Size = new System.Drawing.Size(47, 13);
- this.XLutApplyLabel.TabIndex = 162;
- this.XLutApplyLabel.Text = "Apply as";
- //
- // YLutApplyLabel
- //
- this.YLutApplyLabel.AutoSize = true;
- this.YLutApplyLabel.Location = new System.Drawing.Point(397, 510);
- this.YLutApplyLabel.Name = "YLutApplyLabel";
- this.YLutApplyLabel.Size = new System.Drawing.Size(47, 13);
- this.YLutApplyLabel.TabIndex = 163;
- this.YLutApplyLabel.Text = "Apply as";
- //
- // LutApplyActiveXLabel
- //
- this.LutApplyActiveXLabel.AutoSize = true;
- this.LutApplyActiveXLabel.Location = new System.Drawing.Point(200, 565);
- this.LutApplyActiveXLabel.Name = "LutApplyActiveXLabel";
- this.LutApplyActiveXLabel.Size = new System.Drawing.Size(35, 13);
- this.LutApplyActiveXLabel.TabIndex = 164;
- this.LutApplyActiveXLabel.Text = "label1";
+ // XLutActiveValuesBox
//
- // XLutApplyDropdown
+ this.XLutActiveValuesBox.Location = new System.Drawing.Point(317, 369);
+ this.XLutActiveValuesBox.Name = "XLutActiveValuesBox";
+ this.XLutActiveValuesBox.Size = new System.Drawing.Size(68, 72);
+ this.XLutActiveValuesBox.TabIndex = 168;
+ this.XLutActiveValuesBox.Text = "";
//
- this.XLutApplyDropdown.FormattingEnabled = true;
- this.XLutApplyDropdown.Location = new System.Drawing.Point(320, 527);
- this.XLutApplyDropdown.Name = "XLutApplyDropdown";
- this.XLutApplyDropdown.Size = new System.Drawing.Size(65, 21);
- this.XLutApplyDropdown.TabIndex = 165;
- //
- // YLutApplyDropdown
+ // YLutActiveValuesBox
//
- this.YLutApplyDropdown.FormattingEnabled = true;
- this.YLutApplyDropdown.Location = new System.Drawing.Point(397, 527);
- this.YLutApplyDropdown.Name = "YLutApplyDropdown";
- this.YLutApplyDropdown.Size = new System.Drawing.Size(73, 21);
- this.YLutApplyDropdown.TabIndex = 166;
- //
- // LutApplyActiveYLabel
- //
- this.LutApplyActiveYLabel.AutoSize = true;
- this.LutApplyActiveYLabel.Location = new System.Drawing.Point(417, 565);
- this.LutApplyActiveYLabel.Name = "LutApplyActiveYLabel";
- this.LutApplyActiveYLabel.Size = new System.Drawing.Size(35, 13);
- this.LutApplyActiveYLabel.TabIndex = 167;
- this.LutApplyActiveYLabel.Text = "label1";
+ this.YLutActiveValuesBox.Location = new System.Drawing.Point(397, 369);
+ this.YLutActiveValuesBox.Name = "YLutActiveValuesBox";
+ this.YLutActiveValuesBox.Size = new System.Drawing.Size(73, 72);
+ this.YLutActiveValuesBox.TabIndex = 169;
+ this.YLutActiveValuesBox.Text = "";
//
// RawAcceleration
//
@@ -1766,8 +1766,6 @@ namespace grapher
private System.Windows.Forms.CheckBox gainSwitchY;
private System.Windows.Forms.Label gainSwitchActiveLabelY;
private System.Windows.Forms.Label gainSwitchActiveLabelX;
- private System.Windows.Forms.Panel LUTPanelY;
- private System.Windows.Forms.Panel LUTPanelX;
private System.Windows.Forms.RichTextBox YLutPointsBox;
private System.Windows.Forms.RichTextBox XLutPointsBox;
private System.Windows.Forms.Label LutApplyActiveYLabel;
@@ -1776,6 +1774,8 @@ namespace grapher
private System.Windows.Forms.Label LutApplyActiveXLabel;
private System.Windows.Forms.Label YLutApplyLabel;
private System.Windows.Forms.Label XLutApplyLabel;
+ private System.Windows.Forms.RichTextBox YLutActiveValuesBox;
+ private System.Windows.Forms.RichTextBox XLutActiveValuesBox;
}
}
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index 113fc4d..a7a878b 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -102,8 +102,8 @@ namespace grapher
ByComponentCheckBox,
gainSwitchX,
gainSwitchY,
- LUTPanelX,
- LUTPanelY,
+ XLutActiveValuesBox,
+ YLutActiveValuesBox,
XLutPointsBox,
YLutPointsBox,
LockXYLabel,
diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs
index b82cf59..3bb5a49 100644
--- a/grapher/Models/AccelGUIFactory.cs
+++ b/grapher/Models/AccelGUIFactory.cs
@@ -69,8 +69,8 @@ namespace grapher.Models
CheckBox byComponentCheckBox,
CheckBox gainSwitchX,
CheckBox gainSwitchY,
- Panel lutPanelX,
- Panel lutPanelY,
+ RichTextBox xLutActiveValuesBox,
+ RichTextBox yLutActiveValuesBox,
RichTextBox xLutPointsBox,
RichTextBox yLutPointsBox,
Label lockXYLabel,
@@ -347,7 +347,7 @@ namespace grapher.Models
exponentX,
midpointX,
lutTextX,
- new LUTPanelOptions(lutPanelX, xLutPointsBox),
+ new LUTPanelOptions(xLutPointsBox, xLutActiveValuesBox),
new LutApplyOptions(
lutApplyLabelX,
lutApplyDropdownX,
@@ -367,7 +367,7 @@ namespace grapher.Models
exponentY,
midpointY,
lutTextY,
- new LUTPanelOptions(lutPanelY, yLutPointsBox),
+ new LUTPanelOptions(yLutPointsBox, yLutActiveValuesBox),
new LutApplyOptions(
lutApplyLabelY,
lutApplyDropdownY,
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index 08ab111..f43d955 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -166,6 +166,9 @@ namespace grapher
set
{
AccelDropdown.Left = value;
+ LutText.Left = value;
+ LutPanel.Left = value;
+ LutApply.Left = value;
}
}
@@ -178,6 +181,9 @@ namespace grapher
set
{
AccelDropdown.Width = value;
+ LutText.Width = value;
+ LutPanel.Width = value;
+ LutApply.Width = value;
}
}
@@ -239,7 +245,7 @@ namespace grapher
Limit.SetActiveValue(args.limit);
Exponent.SetActiveValue(args.exponent);
Midpoint.SetActiveValue(args.midpoint);
- LutPanel.SetActiveValues(args.tableData.points);
+ LutPanel.SetActiveValues(args.tableData.points, args.tableData.length);
LutApply.SetActiveValue(args.tableData.velocity);
}
@@ -298,6 +304,12 @@ namespace grapher
if (Offset.Visible) args.offset = Offset.Field.Data;
if (Midpoint.Visible) args.midpoint = Midpoint.Field.Data;
if (Weight.Visible) args.weight = Weight.Field.Data;
+ if (LutPanel.Visible)
+ {
+ (var points, var length) = LutPanel.GetPoints();
+ args.tableData.points = points;
+ args.tableData.length = length;
+ }
if (LutApply.Visible) args.tableData.velocity = LutApply.ApplyType == LutApplyOptions.LutApplyType.Velocity;
}
diff --git a/grapher/Models/Options/LUT/LUTPanelOptions.cs b/grapher/Models/Options/LUT/LUTPanelOptions.cs
index 6425d91..6b13cdc 100644
--- a/grapher/Models/Options/LUT/LUTPanelOptions.cs
+++ b/grapher/Models/Options/LUT/LUTPanelOptions.cs
@@ -13,17 +13,14 @@ namespace grapher.Models.Options.LUT
public const int PanelPadding = 5;
public const int PanelHeight = 100;
- public LUTPanelOptions(Panel activePanel, RichTextBox pointsTextBox)
+ public LUTPanelOptions(RichTextBox pointsTextBox, RichTextBox activeValuesTextBox)
{
PointsTextBox = pointsTextBox;
+ PointsTextBox.Height = PanelHeight;
- ActivePanel = activePanel;
- ActivePanel.Height = PanelHeight;
- ActivePanel.Paint += Panel_Paint;
-
- ActiveValuesTextBox = new RichTextBox();
+ ActiveValuesTextBox = activeValuesTextBox;
+ ActiveValuesTextBox.Height = PanelHeight;
ActiveValuesTextBox.ReadOnly = true;
- ActivePanel.Controls.Add(ActiveValuesTextBox);
}
public RichTextBox PointsTextBox
@@ -36,11 +33,6 @@ namespace grapher.Models.Options.LUT
get;
}
- public Panel ActivePanel
- {
- get;
- }
-
public override bool Visible
{
get
@@ -58,7 +50,7 @@ namespace grapher.Models.Options.LUT
set
{
PointsTextBox.Top = value;
- ActivePanel.Top = value;
+ ActiveValuesTextBox.Top = value;
}
}
@@ -93,7 +85,7 @@ namespace grapher.Models.Options.LUT
{
var panelWidth = value / 2 - PanelPadding;
PointsTextBox.Width = panelWidth;
- ActivePanel.Width = panelWidth;
+ ActiveValuesTextBox.Width = panelWidth;
AlignActivePanelToPointsTextBox();
}
}
@@ -103,14 +95,14 @@ namespace grapher.Models.Options.LUT
public override void Hide()
{
PointsTextBox.Hide();
- ActivePanel.Hide();
+ ActiveValuesTextBox.Hide();
ShouldShow = false;
}
public override void Show(string name)
{
PointsTextBox.Show();
- ActivePanel.Show();
+ ActiveValuesTextBox.Show();
ShouldShow = true;
}
@@ -119,11 +111,11 @@ namespace grapher.Models.Options.LUT
// Nothing to do here.
}
- public void SetActiveValues(IEnumerable<Vec2<float>> activePoints)
+ public void SetActiveValues(IEnumerable<Vec2<float>> activePoints, int length)
{
- if (activePoints.Any() && activePoints.First().x != 0)
+ if (length > 0 && activePoints.First().x != 0)
{
- ActiveValuesTextBox.Text = PointsToActiveValuesText(activePoints);
+ ActiveValuesTextBox.Text = PointsToActiveValuesText(activePoints, length);
}
else
{
@@ -131,12 +123,12 @@ namespace grapher.Models.Options.LUT
}
}
- public Vec2<float>[] GetPoints()
+ public (Vec2<float>[], int length) GetPoints()
{
return UserTextToPoints(PointsTextBox.Text);
}
- private static Vec2<float>[] UserTextToPoints(string userText)
+ private static (Vec2<float>[], int length) UserTextToPoints(string userText)
{
if (string.IsNullOrWhiteSpace(userText))
{
@@ -145,7 +137,7 @@ namespace grapher.Models.Options.LUT
Vec2<float>[] points = new Vec2<float>[256];
- var userTextSplit = userText.Split(';');
+ var userTextSplit = userText.Trim().Trim(';').Split(';');
int index = 0;
float lastX = 0;
@@ -201,32 +193,25 @@ namespace grapher.Models.Options.LUT
index++;
}
- return points;
+ return (points, userTextSplit.Length);
}
private void AlignActivePanelToPointsTextBox()
{
- ActivePanel.Left = PointsTextBox.Right + PanelPadding;
+ ActiveValuesTextBox.Left = PointsTextBox.Right + PanelPadding;
}
- private string PointsToActiveValuesText(IEnumerable<Vec2<float>> points)
+ private string PointsToActiveValuesText(IEnumerable<Vec2<float>> points, int length)
{
StringBuilder builder = new StringBuilder();
- foreach(var point in points)
+ for(int i = 0; i < length; i++)
{
+ var point = points.ElementAt(i);
builder.AppendLine($"{point.x},{point.y};");
}
return builder.ToString();
}
-
- private void Panel_Paint(object sender, PaintEventArgs e)
- {
- Color col = Color.DarkGray;
- ButtonBorderStyle bbs = ButtonBorderStyle.Dashed;
- int thickness = 2;
- ControlPaint.DrawBorder(e.Graphics, ActivePanel.ClientRectangle, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs);
- }
}
}
diff --git a/grapher/Models/Options/LUT/LutApplyOptions.cs b/grapher/Models/Options/LUT/LutApplyOptions.cs
index 6ea7412..f71c1e2 100644
--- a/grapher/Models/Options/LUT/LutApplyOptions.cs
+++ b/grapher/Models/Options/LUT/LutApplyOptions.cs
@@ -22,6 +22,8 @@ namespace grapher.Models.Options.LUT
public LutApplyType Type { get; set; }
public string Name => Type.ToString();
+
+ public override string ToString() => Name;
}
public static readonly LutApplyOption Sensitivity = new LutApplyOption
@@ -50,6 +52,7 @@ namespace grapher.Models.Options.LUT
Label = label;
Label.Text = LUTApplyOptionsLabelText;
+ Label.Width = 45;
ActiveValueLabel = lutApplyActiveValue;
}
diff --git a/grapher/Models/Options/TextOption.cs b/grapher/Models/Options/TextOption.cs
index 3c6f378..83a72df 100644
--- a/grapher/Models/Options/TextOption.cs
+++ b/grapher/Models/Options/TextOption.cs
@@ -14,9 +14,7 @@ namespace grapher.Models.Options
public TextOption(Label label)
{
Label = label;
- Label.AutoSize = false;
- Label.Width = 150;
- Label.Height = 100;
+ Label.AutoSize = true;
}
#endregion Constructors
@@ -61,7 +59,7 @@ namespace grapher.Models.Options
}
set
{
- Label.Width = value;
+ Label.MaximumSize = new System.Drawing.Size(value, 0);
}
}