From de6b18db8226650cee9726c4694931bdc4b89fad Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sun, 10 Jan 2021 23:49:28 -0800 Subject: Implement direcitonality UI --- grapher/Constants/Constants.cs | 3 + grapher/Form1.Designer.cs | 296 ++++++++++++++++++--- grapher/Form1.cs | 25 +- grapher/Models/AccelGUI.cs | 4 +- grapher/Models/AccelGUIFactory.cs | 73 ++++- .../Models/Charts/ChartState/ChartStateManager.cs | 4 +- grapher/Models/Options/ApplyOptions.cs | 49 ++-- .../Directionality/DirectionalityOptions.cs | 172 ++++++++++++ grapher/Models/Options/Option.cs | 10 + grapher/Models/Options/OptionXY.cs | 12 + grapher/grapher.csproj | 1 + 11 files changed, 578 insertions(+), 71 deletions(-) create mode 100644 grapher/Models/Options/Directionality/DirectionalityOptions.cs (limited to 'grapher') diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index 5bee626..69b0bbb 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -61,6 +61,9 @@ namespace grapher /// Vertical placement of write button above bottom of sensitivity graph public const int ButtonVerticalOffset = 60; + /// Padding between directionality title and containing panel + public const int DirectionalityTitlePad = 2; + public const float SmallButtonSizeFactor = 0.666f; /// Format string for shortened x and y textboxes. diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 6fd9478..6e1bc3d 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -71,6 +71,20 @@ 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.DirectionalityPanel = new System.Windows.Forms.Panel(); + this.ByComponentCheckBox = new System.Windows.Forms.CheckBox(); + this.WholeCheckBox = new System.Windows.Forms.CheckBox(); + this.DirectionalityRangeLabel = new System.Windows.Forms.Label(); + this.DirectionalDomainLabel = new System.Windows.Forms.Label(); + this.LpNormBox = new System.Windows.Forms.TextBox(); + this.LPNormLabel = new System.Windows.Forms.Label(); + this.DirectionalityY = new System.Windows.Forms.Label(); + this.DirectionalityX = new System.Windows.Forms.Label(); + this.RangeBoxY = new System.Windows.Forms.TextBox(); + this.RangeBoxX = new System.Windows.Forms.TextBox(); + this.DomainBoxY = new System.Windows.Forms.TextBox(); + this.DomainBoxX = new System.Windows.Forms.TextBox(); + this.DirectionalityLabel = new System.Windows.Forms.Label(); this.toggleButton = new System.Windows.Forms.CheckBox(); this.scaleLabelY = new System.Windows.Forms.Label(); this.ScaleActiveYLabel = new System.Windows.Forms.Label(); @@ -158,9 +172,7 @@ namespace grapher this.offsetStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.gainOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.legacyOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.wholeVectorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.byVectorComponentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.chartsPanel = new System.Windows.Forms.Panel(); this.GainChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.VelocityChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); @@ -168,8 +180,15 @@ 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.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.DirectionalityActiveValueTitle = new System.Windows.Forms.Label(); + this.DomainActiveValueX = new System.Windows.Forms.Label(); + this.DomainActiveValueY = new System.Windows.Forms.Label(); + this.RangeActiveValueX = new System.Windows.Forms.Label(); + this.RangeActiveValueY = new System.Windows.Forms.Label(); + this.LpNormActiveValue = new System.Windows.Forms.Label(); + this.FakeBox = new System.Windows.Forms.CheckBox(); this.optionsPanel.SuspendLayout(); + this.DirectionalityPanel.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.chartsPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.GainChartY)).BeginInit(); @@ -183,6 +202,8 @@ namespace grapher // optionsPanel // this.optionsPanel.AutoSize = true; + this.optionsPanel.Controls.Add(this.FakeBox); + this.optionsPanel.Controls.Add(this.DirectionalityPanel); this.optionsPanel.Controls.Add(this.toggleButton); this.optionsPanel.Controls.Add(this.scaleLabelY); this.optionsPanel.Controls.Add(this.ScaleActiveYLabel); @@ -262,9 +283,145 @@ namespace grapher this.optionsPanel.TabIndex = 34; this.optionsPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.optionsPanel_Paint); // + // DirectionalityPanel + // + this.DirectionalityPanel.Controls.Add(this.LpNormActiveValue); + this.DirectionalityPanel.Controls.Add(this.RangeActiveValueY); + this.DirectionalityPanel.Controls.Add(this.RangeActiveValueX); + this.DirectionalityPanel.Controls.Add(this.DomainActiveValueY); + this.DirectionalityPanel.Controls.Add(this.DomainActiveValueX); + this.DirectionalityPanel.Controls.Add(this.DirectionalityActiveValueTitle); + this.DirectionalityPanel.Controls.Add(this.ByComponentCheckBox); + this.DirectionalityPanel.Controls.Add(this.WholeCheckBox); + this.DirectionalityPanel.Controls.Add(this.DirectionalityRangeLabel); + this.DirectionalityPanel.Controls.Add(this.DirectionalDomainLabel); + this.DirectionalityPanel.Controls.Add(this.LpNormBox); + this.DirectionalityPanel.Controls.Add(this.LPNormLabel); + this.DirectionalityPanel.Controls.Add(this.DirectionalityY); + this.DirectionalityPanel.Controls.Add(this.DirectionalityX); + this.DirectionalityPanel.Controls.Add(this.RangeBoxY); + this.DirectionalityPanel.Controls.Add(this.RangeBoxX); + this.DirectionalityPanel.Controls.Add(this.DomainBoxY); + this.DirectionalityPanel.Controls.Add(this.DomainBoxX); + this.DirectionalityPanel.Controls.Add(this.DirectionalityLabel); + this.DirectionalityPanel.Location = new System.Drawing.Point(28, 369); + this.DirectionalityPanel.Name = "DirectionalityPanel"; + this.DirectionalityPanel.Size = new System.Drawing.Size(301, 126); + this.DirectionalityPanel.TabIndex = 150; + // + // ByComponentCheckBox + // + this.ByComponentCheckBox.AutoSize = true; + this.ByComponentCheckBox.Location = new System.Drawing.Point(163, 104); + this.ByComponentCheckBox.Name = "ByComponentCheckBox"; + this.ByComponentCheckBox.Size = new System.Drawing.Size(95, 17); + this.ByComponentCheckBox.TabIndex = 12; + this.ByComponentCheckBox.Text = "By Component"; + this.ByComponentCheckBox.UseVisualStyleBackColor = true; + // + // WholeCheckBox + // + this.WholeCheckBox.AutoSize = true; + this.WholeCheckBox.Location = new System.Drawing.Point(43, 104); + this.WholeCheckBox.Name = "WholeCheckBox"; + this.WholeCheckBox.Size = new System.Drawing.Size(57, 17); + this.WholeCheckBox.TabIndex = 11; + this.WholeCheckBox.Text = "Whole"; + this.WholeCheckBox.UseVisualStyleBackColor = true; + // + // DirectionalityRangeLabel + // + this.DirectionalityRangeLabel.AutoSize = true; + this.DirectionalityRangeLabel.Location = new System.Drawing.Point(9, 55); + this.DirectionalityRangeLabel.Name = "DirectionalityRangeLabel"; + this.DirectionalityRangeLabel.Size = new System.Drawing.Size(39, 13); + this.DirectionalityRangeLabel.TabIndex = 10; + this.DirectionalityRangeLabel.Text = "Range"; + // + // DirectionalDomainLabel + // + this.DirectionalDomainLabel.AutoSize = true; + this.DirectionalDomainLabel.Location = new System.Drawing.Point(9, 28); + this.DirectionalDomainLabel.Name = "DirectionalDomainLabel"; + this.DirectionalDomainLabel.Size = new System.Drawing.Size(43, 13); + this.DirectionalDomainLabel.TabIndex = 9; + this.DirectionalDomainLabel.Text = "Domain"; + // + // LpNormBox + // + this.LpNormBox.Location = new System.Drawing.Point(78, 78); + this.LpNormBox.Name = "LpNormBox"; + this.LpNormBox.Size = new System.Drawing.Size(76, 20); + this.LpNormBox.TabIndex = 8; + // + // LPNormLabel + // + this.LPNormLabel.AutoSize = true; + this.LPNormLabel.Location = new System.Drawing.Point(9, 81); + this.LPNormLabel.Name = "LPNormLabel"; + this.LPNormLabel.Size = new System.Drawing.Size(47, 13); + this.LPNormLabel.TabIndex = 7; + this.LPNormLabel.Text = "Lp Norm"; + // + // DirectionalityY + // + this.DirectionalityY.AutoSize = true; + this.DirectionalityY.Location = new System.Drawing.Point(129, 9); + this.DirectionalityY.Name = "DirectionalityY"; + this.DirectionalityY.Size = new System.Drawing.Size(14, 13); + this.DirectionalityY.TabIndex = 6; + this.DirectionalityY.Text = "Y"; + // + // DirectionalityX + // + this.DirectionalityX.AutoSize = true; + this.DirectionalityX.Location = new System.Drawing.Point(86, 9); + this.DirectionalityX.Name = "DirectionalityX"; + this.DirectionalityX.Size = new System.Drawing.Size(14, 13); + this.DirectionalityX.TabIndex = 5; + this.DirectionalityX.Text = "X"; + // + // RangeBoxY + // + this.RangeBoxY.Location = new System.Drawing.Point(120, 52); + this.RangeBoxY.Name = "RangeBoxY"; + this.RangeBoxY.Size = new System.Drawing.Size(34, 20); + this.RangeBoxY.TabIndex = 4; + // + // RangeBoxX + // + this.RangeBoxX.Location = new System.Drawing.Point(78, 52); + this.RangeBoxX.Name = "RangeBoxX"; + this.RangeBoxX.Size = new System.Drawing.Size(34, 20); + this.RangeBoxX.TabIndex = 3; + // + // DomainBoxY + // + this.DomainBoxY.Location = new System.Drawing.Point(120, 25); + this.DomainBoxY.Name = "DomainBoxY"; + this.DomainBoxY.Size = new System.Drawing.Size(34, 20); + this.DomainBoxY.TabIndex = 2; + // + // DomainBoxX + // + this.DomainBoxX.Location = new System.Drawing.Point(78, 25); + this.DomainBoxX.Name = "DomainBoxX"; + this.DomainBoxX.Size = new System.Drawing.Size(34, 20); + this.DomainBoxX.TabIndex = 1; + // + // DirectionalityLabel + // + this.DirectionalityLabel.AutoSize = true; + this.DirectionalityLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.DirectionalityLabel.Location = new System.Drawing.Point(3, 9); + this.DirectionalityLabel.Name = "DirectionalityLabel"; + this.DirectionalityLabel.Size = new System.Drawing.Size(67, 13); + this.DirectionalityLabel.TabIndex = 0; + this.DirectionalityLabel.Text = "Directionality"; + // // toggleButton // - this.toggleButton.Location = new System.Drawing.Point(214, 387); + this.toggleButton.Location = new System.Drawing.Point(211, 534); this.toggleButton.Name = "toggleButton"; this.toggleButton.Size = new System.Drawing.Size(104, 24); this.toggleButton.TabIndex = 112; @@ -710,7 +867,7 @@ namespace grapher // writeButton // this.writeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.writeButton.Location = new System.Drawing.Point(94, 380); + this.writeButton.Location = new System.Drawing.Point(90, 527); this.writeButton.Name = "writeButton"; this.writeButton.Size = new System.Drawing.Size(92, 35); this.writeButton.TabIndex = 111; @@ -955,7 +1112,6 @@ namespace grapher this.advancedToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.capStyleToolStripMenuItem, this.offsetStyleToolStripMenuItem, - this.toolStripMenuItem1, this.AutoWriteMenuItem}); this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem"; this.advancedToolStripMenuItem.Size = new System.Drawing.Size(72, 20); @@ -1005,29 +1161,14 @@ namespace grapher this.legacyOffsetToolStripMenuItem.Size = new System.Drawing.Size(147, 22); this.legacyOffsetToolStripMenuItem.Text = "Legacy"; // - // toolStripMenuItem1 - // - this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.wholeVectorToolStripMenuItem, - this.byVectorComponentToolStripMenuItem}); - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(210, 22); - this.toolStripMenuItem1.Text = "Application Style"; - // - // wholeVectorToolStripMenuItem - // - this.wholeVectorToolStripMenuItem.Checked = true; - this.wholeVectorToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.wholeVectorToolStripMenuItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.wholeVectorToolStripMenuItem.Name = "wholeVectorToolStripMenuItem"; - this.wholeVectorToolStripMenuItem.Size = new System.Drawing.Size(154, 22); - this.wholeVectorToolStripMenuItem.Text = "Whole"; - // - // byVectorComponentToolStripMenuItem + // AutoWriteMenuItem // - this.byVectorComponentToolStripMenuItem.Name = "byVectorComponentToolStripMenuItem"; - this.byVectorComponentToolStripMenuItem.Size = new System.Drawing.Size(154, 22); - this.byVectorComponentToolStripMenuItem.Text = "By Component"; + this.AutoWriteMenuItem.Checked = true; + this.AutoWriteMenuItem.CheckOnClick = true; + this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.AutoWriteMenuItem.Name = "AutoWriteMenuItem"; + this.AutoWriteMenuItem.Size = new System.Drawing.Size(210, 22); + this.AutoWriteMenuItem.Text = "Apply Settings On Startup"; // // chartsPanel // @@ -1281,14 +1422,69 @@ namespace grapher title6.Text = "Sensitivity"; this.AccelerationChart.Titles.Add(title6); // - // AutoWriteMenuItem - // - this.AutoWriteMenuItem.Checked = true; - this.AutoWriteMenuItem.CheckOnClick = true; - this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.AutoWriteMenuItem.Name = "AutoWriteMenuItem"; - this.AutoWriteMenuItem.Size = new System.Drawing.Size(210, 22); - this.AutoWriteMenuItem.Text = "Apply Settings On Startup"; + // DirectionalityActiveValueTitle + // + this.DirectionalityActiveValueTitle.AutoSize = true; + this.DirectionalityActiveValueTitle.Location = new System.Drawing.Point(169, 9); + this.DirectionalityActiveValueTitle.Name = "DirectionalityActiveValueTitle"; + this.DirectionalityActiveValueTitle.Size = new System.Drawing.Size(41, 13); + this.DirectionalityActiveValueTitle.TabIndex = 13; + this.DirectionalityActiveValueTitle.Text = "Current"; + // + // DomainActiveValueX + // + this.DomainActiveValueX.AutoSize = true; + this.DomainActiveValueX.Location = new System.Drawing.Point(169, 28); + this.DomainActiveValueX.Name = "DomainActiveValueX"; + this.DomainActiveValueX.Size = new System.Drawing.Size(13, 13); + this.DomainActiveValueX.TabIndex = 14; + this.DomainActiveValueX.Text = "0"; + // + // DomainActiveValueY + // + this.DomainActiveValueY.AutoSize = true; + this.DomainActiveValueY.Location = new System.Drawing.Point(189, 28); + this.DomainActiveValueY.Name = "DomainActiveValueY"; + this.DomainActiveValueY.Size = new System.Drawing.Size(13, 13); + this.DomainActiveValueY.TabIndex = 15; + this.DomainActiveValueY.Text = "0"; + // + // RangeActiveValueX + // + this.RangeActiveValueX.AutoSize = true; + this.RangeActiveValueX.Location = new System.Drawing.Point(169, 55); + this.RangeActiveValueX.Name = "RangeActiveValueX"; + this.RangeActiveValueX.Size = new System.Drawing.Size(13, 13); + this.RangeActiveValueX.TabIndex = 16; + this.RangeActiveValueX.Text = "0"; + // + // RangeActiveValueY + // + this.RangeActiveValueY.AutoSize = true; + this.RangeActiveValueY.Location = new System.Drawing.Point(188, 55); + this.RangeActiveValueY.Name = "RangeActiveValueY"; + this.RangeActiveValueY.Size = new System.Drawing.Size(13, 13); + this.RangeActiveValueY.TabIndex = 17; + this.RangeActiveValueY.Text = "0"; + // + // LpNormActiveValue + // + this.LpNormActiveValue.AutoSize = true; + this.LpNormActiveValue.Location = new System.Drawing.Point(180, 78); + this.LpNormActiveValue.Name = "LpNormActiveValue"; + this.LpNormActiveValue.Size = new System.Drawing.Size(13, 13); + this.LpNormActiveValue.TabIndex = 18; + this.LpNormActiveValue.Text = "0"; + // + // FakeBox + // + this.FakeBox.AutoSize = true; + this.FakeBox.Location = new System.Drawing.Point(28, 502); + this.FakeBox.Name = "FakeBox"; + this.FakeBox.Size = new System.Drawing.Size(47, 17); + this.FakeBox.TabIndex = 151; + this.FakeBox.Text = "fake"; + this.FakeBox.UseVisualStyleBackColor = true; // // RawAcceleration // @@ -1304,6 +1500,8 @@ namespace grapher this.Paint += new System.Windows.Forms.PaintEventHandler(this.RawAcceleration_Paint); this.optionsPanel.ResumeLayout(false); this.optionsPanel.PerformLayout(); + this.DirectionalityPanel.ResumeLayout(false); + this.DirectionalityPanel.PerformLayout(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.chartsPanel.ResumeLayout(false); @@ -1407,9 +1605,6 @@ namespace grapher private System.Windows.Forms.ToolStripMenuItem offsetStyleToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem gainOffsetToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem legacyOffsetToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem wholeVectorToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem byVectorComponentToolStripMenuItem; private System.Windows.Forms.Panel chartsPanel; private System.Windows.Forms.DataVisualization.Charting.Chart GainChartY; private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChartY; @@ -1418,6 +1613,27 @@ namespace grapher private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChart; private System.Windows.Forms.DataVisualization.Charting.Chart AccelerationChart; private System.Windows.Forms.ToolStripMenuItem AutoWriteMenuItem; + private System.Windows.Forms.Panel DirectionalityPanel; + private System.Windows.Forms.Label DirectionalityRangeLabel; + private System.Windows.Forms.Label DirectionalDomainLabel; + private System.Windows.Forms.TextBox LpNormBox; + private System.Windows.Forms.Label LPNormLabel; + private System.Windows.Forms.Label DirectionalityY; + private System.Windows.Forms.Label DirectionalityX; + private System.Windows.Forms.TextBox RangeBoxY; + private System.Windows.Forms.TextBox RangeBoxX; + private System.Windows.Forms.TextBox DomainBoxY; + private System.Windows.Forms.TextBox DomainBoxX; + private System.Windows.Forms.Label DirectionalityLabel; + private System.Windows.Forms.CheckBox ByComponentCheckBox; + private System.Windows.Forms.CheckBox WholeCheckBox; + private System.Windows.Forms.Label DirectionalityActiveValueTitle; + private System.Windows.Forms.Label DomainActiveValueX; + private System.Windows.Forms.Label DomainActiveValueY; + private System.Windows.Forms.Label RangeActiveValueX; + private System.Windows.Forms.Label LpNormActiveValue; + private System.Windows.Forms.Label RangeActiveValueY; + private System.Windows.Forms.CheckBox FakeBox; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 0c12b86..06f76f1 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -64,8 +64,6 @@ namespace grapher toggleButton, showVelocityGainToolStripMenuItem, showLastMouseMoveToolStripMenuItem, - wholeVectorToolStripMenuItem, - byVectorComponentToolStripMenuItem, gainCapToolStripMenuItem, legacyCapToolStripMenuItem, gainOffsetToolStripMenuItem, @@ -74,6 +72,7 @@ namespace grapher ScaleMenuItem, DPITextBox, PollRateTextBox, + DirectionalityPanel, sensitivityBoxX, sensitivityBoxY, rotationBox, @@ -93,8 +92,16 @@ namespace grapher expBoxY, midpointBoxX, midpointBoxY, + DomainBoxX, + DomainBoxY, + RangeBoxX, + RangeBoxY, + LpNormBox, sensXYLock, ByComponentXYLock, + FakeBox, + WholeCheckBox, + ByComponentCheckBox, LockXYLabel, sensitivityLabel, rotationLabel, @@ -139,7 +146,19 @@ namespace grapher AccelTypeActiveLabelY, OptionSetXTitle, OptionSetYTitle, - MouseLabel); + MouseLabel, + DirectionalityLabel, + DirectionalityX, + DirectionalityY, + DirectionalityActiveValueTitle, + LPNormLabel, + LpNormActiveValue, + DirectionalDomainLabel, + DomainActiveValueX, + DomainActiveValueY, + DirectionalityRangeLabel, + RangeActiveValueX, + RangeActiveValueY); } #endregion Constructor diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index c6a2dcc..045cb23 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -141,7 +141,9 @@ namespace grapher modes = ApplyOptions.GetModes(), args = newArgs, minimumTime = driverSettings.minimumTime, - directionalMultipliers = driverSettings.directionalMultipliers + directionalMultipliers = driverSettings.directionalMultipliers, + domainArgs = ApplyOptions.Directionality.GetDomainArgs(), + rangeXY = ApplyOptions.Directionality.GetRangeXY(), }; ButtonDelay(WriteButton); diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index 901a1b5..1035cb7 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -1,6 +1,7 @@ using grapher.Models.Calculations; using grapher.Models.Mouse; using grapher.Models.Options; +using grapher.Models.Options.Directionality; using grapher.Models.Serialized; using System; using System.Windows.Forms; @@ -27,8 +28,6 @@ namespace grapher.Models ButtonBase toggleButton, ToolStripMenuItem showVelocityGainToolStripMenuItem, ToolStripMenuItem showLastMouseMoveMenuItem, - ToolStripMenuItem wholeVectorToolStripMenuItem, - ToolStripMenuItem byVectorComponentToolStripMenuItem, ToolStripMenuItem velocityGainCapToolStripMenuItem, ToolStripMenuItem legacyCapToolStripMenuItem, ToolStripMenuItem gainOffsetToolStripMenuItem, @@ -37,6 +36,7 @@ namespace grapher.Models ToolStripMenuItem scaleMenuItem, ToolStripTextBox dpiTextBox, ToolStripTextBox pollRateTextBox, + Panel directionalityPanel, TextBox sensitivityBoxX, TextBox sensitivityBoxY, TextBox rotationBox, @@ -56,8 +56,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, @@ -102,8 +110,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)); @@ -141,6 +164,8 @@ namespace grapher.Models var optionSetYLeft = rotation.Left + rotation.Width; + var directionalityLeft = directionalityPanel.Left; + var weightX = new Option( weightBoxX, form, @@ -265,6 +290,34 @@ 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))); + + var range = new OptionXY( + rangeBoxX, + rangeBoxY, + fakeBox, + form, + 1, + rangeLabel, + new ActiveValueLabelXY( + new ActiveValueLabel(rangeActiveValueX, direcionalityActiveValueTitle), + new ActiveValueLabel(rangeActiveValueY, direcionalityActiveValueTitle))); + var capOptionsX = new CapOptions( velocityGainCapToolStripMenuItem, legacyCapToolStripMenuItem, @@ -313,12 +366,22 @@ namespace grapher.Models rotationBox.Top + rotationBox.Height + Constants.OptionVerticalSeperation, accelerationOptionsY); + var directionalOptions = new DirectionalityOptions( + directionalityPanel, + directionalityLabel, + directionalityX, + directionalityY, + lpNorm, + domain, + range, + wholeCheckBox, + byComponentCheckBox); + var applyOptions = new ApplyOptions( - wholeVectorToolStripMenuItem, - byVectorComponentToolStripMenuItem, byComponentXYLock, optionsSetX, optionsSetY, + directionalOptions, sensitivity, rotation, lockXYLabel, diff --git a/grapher/Models/Charts/ChartState/ChartStateManager.cs b/grapher/Models/Charts/ChartState/ChartStateManager.cs index 54d2e81..ff4fe54 100644 --- a/grapher/Models/Charts/ChartState/ChartStateManager.cs +++ b/grapher/Models/Charts/ChartState/ChartStateManager.cs @@ -52,7 +52,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/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..3de93b4 --- /dev/null +++ b/grapher/Models/Options/Directionality/DirectionalityOptions.cs @@ -0,0 +1,172 @@ +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, + Option lpNorm, + OptionXY domain, + OptionXY range, + CheckBox wholeCheckBox, + CheckBox byComponentCheckBox) + { + ContainingPanel = containingPanel; + DirectionalityLabel = directionalityLabel; + DirectionalityX = directionalityX; + DirectionalityY = directionalityY; + LpNorm = lpNorm; + Domain = domain; + Range = range; + WholeCheckBox = wholeCheckBox; + ByComponentCheckBox = byComponentCheckBox; + + ContainingPanel.Paint += panel_Paint; + DirectionalityLabel.Left = ContainingPanel.Left + Constants.DirectionalityTitlePad; + DirectionalityLabel.Top = ContainingPanel.Top + Constants.DirectionalityTitlePad; + ToWhole(); + Hide(); + } + + public Panel ContainingPanel { get; } + + public Label DirectionalityLabel { get; } + + public Label DirectionalityX { get; } + + public Label DirectionalityY { get; } + + public Option LpNorm { get; } + + public OptionXY Domain { get; } + + public OptionXY Range { get; } + + public CheckBox WholeCheckBox { get; } + + public CheckBox ByComponentCheckBox { get; } + + public DomainArgs GetDomainArgs() + { + if (!ByComponentCheckBox.Checked) + { + return new DomainArgs + { + domainXY = new Vec2 + { + x = Domain.Fields.X, + y = Domain.Fields.Y, + }, + lpNorm = LpNorm.Field.Data, + }; + } + else + { + return new DomainArgs + { + domainXY = new Vec2 + { + x = 1, + y = 1, + }, + lpNorm = 2, + }; + + } + } + + public Vec2 GetRangeXY() + { + if (!ByComponentCheckBox.Checked) + { + return new Vec2 + { + x = Range.Fields.X, + y = Range.Fields.Y, + }; + } + else + { + return new Vec2 + { + 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() + { + DirectionalityX.Hide(); + DirectionalityY.Hide(); + LpNorm.Hide(); + Domain.Hide(); + Range.Hide(); + WholeCheckBox.Hide(); + ByComponentCheckBox.Hide(); + DrawHidden(); + } + + public void ToByComponent() + { + LpNorm.SetToUnavailable(); + Domain.SetToUnavailable(); + Range.SetToUnavailable(); + } + + public void ToWhole() + { + LpNorm.SetToAvailable(); + Domain.SetToAvailable(); + Range.SetToAvailable(); + } + + public void Show() + { + DirectionalityX.Hide(); + DirectionalityY.Hide(); + LpNorm.Hide(); + Domain.Hide(); + Range.Hide(); + WholeCheckBox.Hide(); + ByComponentCheckBox.Hide(); + DrawShown(); + } + + private void DrawHidden() + { + ContainingPanel.Height = DirectionalityLabel.Height + 2 * Constants.DirectionalityTitlePad; + } + + private void DrawShown() + { + ContainingPanel.Height = WholeCheckBox.Bottom - DirectionalityLabel.Top + 2 * Constants.DirectionalityTitlePad; + } + + 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); + } + } +} 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..3557a06 100644 --- a/grapher/Models/Options/OptionXY.cs +++ b/grapher/Models/Options/OptionXY.cs @@ -153,6 +153,18 @@ namespace grapher Show(); } + public void SetToUnavailable() + { + Fields.XField.SetToUnavailable(); + Fields.YField.SetToUnavailable(); + } + + public void SetToAvailable() + { + Fields.XField.SetToDefault(); + Fields.YField.SetToDefault(); + } + #endregion Methods } } diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index f6bdcb9..140d521 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -117,6 +117,7 @@ + -- cgit v1.2.3 From 6196cee980c7b8021b752b684cbe14bf7c41b657 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 11 Jan 2021 00:34:56 -0800 Subject: Some fixes --- grapher/Constants/Constants.cs | 2 +- .../Directionality/DirectionalityOptions.cs | 64 +++++++++++++++------- 2 files changed, 45 insertions(+), 21 deletions(-) (limited to 'grapher') diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index 69b0bbb..7ebb2cc 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -62,7 +62,7 @@ namespace grapher public const int ButtonVerticalOffset = 60; /// Padding between directionality title and containing panel - public const int DirectionalityTitlePad = 2; + public const int DirectionalityTitlePad = 4; public const float SmallButtonSizeFactor = 0.666f; diff --git a/grapher/Models/Options/Directionality/DirectionalityOptions.cs b/grapher/Models/Options/Directionality/DirectionalityOptions.cs index 3de93b4..df1b4de 100644 --- a/grapher/Models/Options/Directionality/DirectionalityOptions.cs +++ b/grapher/Models/Options/Directionality/DirectionalityOptions.cs @@ -32,8 +32,10 @@ namespace grapher.Models.Options.Directionality ByComponentCheckBox = byComponentCheckBox; ContainingPanel.Paint += panel_Paint; + directionalityLabel.Click += title_click; DirectionalityLabel.Left = ContainingPanel.Left + Constants.DirectionalityTitlePad; DirectionalityLabel.Top = ContainingPanel.Top + Constants.DirectionalityTitlePad; + IsHidden = false; ToWhole(); Hide(); } @@ -56,6 +58,8 @@ namespace grapher.Models.Options.Directionality public CheckBox ByComponentCheckBox { get; } + private bool IsHidden { get; set; } + public DomainArgs GetDomainArgs() { if (!ByComponentCheckBox.Checked) @@ -115,14 +119,34 @@ namespace grapher.Models.Options.Directionality public void Hide() { - DirectionalityX.Hide(); - DirectionalityY.Hide(); - LpNorm.Hide(); - Domain.Hide(); - Range.Hide(); - WholeCheckBox.Hide(); - ByComponentCheckBox.Hide(); - DrawHidden(); + if (!IsHidden) + { + DirectionalityX.Hide(); + DirectionalityY.Hide(); + LpNorm.Hide(); + Domain.Hide(); + Range.Hide(); + WholeCheckBox.Hide(); + ByComponentCheckBox.Hide(); + DrawHidden(); + IsHidden = true; + } + } + + public void Show() + { + if (IsHidden) + { + DirectionalityX.Hide(); + DirectionalityY.Hide(); + LpNorm.Hide(); + Domain.Hide(); + Range.Hide(); + WholeCheckBox.Hide(); + ByComponentCheckBox.Hide(); + DrawShown(); + IsHidden = false; + } } public void ToByComponent() @@ -139,18 +163,6 @@ namespace grapher.Models.Options.Directionality Range.SetToAvailable(); } - public void Show() - { - DirectionalityX.Hide(); - DirectionalityY.Hide(); - LpNorm.Hide(); - Domain.Hide(); - Range.Hide(); - WholeCheckBox.Hide(); - ByComponentCheckBox.Hide(); - DrawShown(); - } - private void DrawHidden() { ContainingPanel.Height = DirectionalityLabel.Height + 2 * Constants.DirectionalityTitlePad; @@ -168,5 +180,17 @@ namespace grapher.Models.Options.Directionality 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(); + } + } } } -- cgit v1.2.3 From 65e10856e41dd6c75303808d7de0c322bac38df6 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 11 Jan 2021 01:17:14 -0800 Subject: Driver works --- grapher/Models/Charts/ChartState/XYOneGraphState.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'grapher') diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs index 2b3cd9c..4a755b6 100644 --- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs @@ -45,6 +45,10 @@ namespace grapher.Models.Charts.ChartState public override void Calculate(ManagedAccel accel, DriverSettings settings) { Calculator.CalculateCombinedDiffSens(Data, accel, settings, Calculator.SimulatedInputCombined); + Data.X.Clear(); + Data.Y.Clear(); + Calculator.Calculate(Data.X, accel, settings.sensitivity.x, Calculator.SimulatedInputX); + Calculator.Calculate(Data.Y, accel, settings.sensitivity.y, Calculator.SimulatedInputY); } } } -- cgit v1.2.3 From 0776e8313bc2aa406da4603ca2d77e4140e35a5a Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 11 Jan 2021 14:50:37 -0800 Subject: Directionality menu progress --- grapher/Constants/Constants.cs | 8 +++++- grapher/Models/AccelGUIFactory.cs | 1 + .../Directionality/DirectionalityOptions.cs | 30 ++++++++++++++-------- 3 files changed, 28 insertions(+), 11 deletions(-) (limited to 'grapher') diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index 7ebb2cc..b86874f 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -62,7 +62,7 @@ namespace grapher public const int ButtonVerticalOffset = 60; /// Padding between directionality title and containing panel - public const int DirectionalityTitlePad = 4; + public const int DirectionalityTitlePad = 8; public const float SmallButtonSizeFactor = 0.666f; @@ -114,6 +114,12 @@ namespace grapher /// Default name of settings file. public const string DefaultSettingsFileName = @"settings.json"; + /// Text to direcitonality panel title when panel is closed. + public const string DirectionalityTitleClosed = "Directionality\u25BC"; + + /// Text to direcitonality panel title when panel is open. + public const string DirectionalityTitleOpen = "Directionality\u25B2"; + /// Style used by System.Double.Parse public const NumberStyles FloatStyle = NumberStyles.Float | NumberStyles.AllowThousands; diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index 1035cb7..e8def16 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -371,6 +371,7 @@ namespace grapher.Models directionalityLabel, directionalityX, directionalityY, + direcionalityActiveValueTitle, lpNorm, domain, range, diff --git a/grapher/Models/Options/Directionality/DirectionalityOptions.cs b/grapher/Models/Options/Directionality/DirectionalityOptions.cs index df1b4de..c83ea52 100644 --- a/grapher/Models/Options/Directionality/DirectionalityOptions.cs +++ b/grapher/Models/Options/Directionality/DirectionalityOptions.cs @@ -15,6 +15,7 @@ namespace grapher.Models.Options.Directionality Label directionalityLabel, Label directionalityX, Label directionalityY, + Label directionalityActiveValueTitle, Option lpNorm, OptionXY domain, OptionXY range, @@ -25,6 +26,7 @@ namespace grapher.Models.Options.Directionality DirectionalityLabel = directionalityLabel; DirectionalityX = directionalityX; DirectionalityY = directionalityY; + DirectionalityActiveValueTitle = directionalityActiveValueTitle; LpNorm = lpNorm; Domain = domain; Range = range; @@ -32,9 +34,9 @@ namespace grapher.Models.Options.Directionality ByComponentCheckBox = byComponentCheckBox; ContainingPanel.Paint += panel_Paint; - directionalityLabel.Click += title_click; - DirectionalityLabel.Left = ContainingPanel.Left + Constants.DirectionalityTitlePad; - DirectionalityLabel.Top = ContainingPanel.Top + Constants.DirectionalityTitlePad; + DirectionalityLabel.Click += title_click; + DirectionalityLabel.Left = Constants.DirectionalityTitlePad; + DirectionalityLabel.Top = Constants.DirectionalityTitlePad; IsHidden = false; ToWhole(); Hide(); @@ -48,6 +50,8 @@ namespace grapher.Models.Options.Directionality public Label DirectionalityY { get; } + public Label DirectionalityActiveValueTitle { get; } + public Option LpNorm { get; } public OptionXY Domain { get; } @@ -123,11 +127,13 @@ namespace grapher.Models.Options.Directionality { DirectionalityX.Hide(); DirectionalityY.Hide(); + DirectionalityActiveValueTitle.Hide(); LpNorm.Hide(); Domain.Hide(); Range.Hide(); WholeCheckBox.Hide(); ByComponentCheckBox.Hide(); + DirectionalityLabel.Text = Constants.DirectionalityTitleClosed; DrawHidden(); IsHidden = true; } @@ -137,13 +143,15 @@ namespace grapher.Models.Options.Directionality { if (IsHidden) { - DirectionalityX.Hide(); - DirectionalityY.Hide(); - LpNorm.Hide(); - Domain.Hide(); - Range.Hide(); - WholeCheckBox.Hide(); - ByComponentCheckBox.Hide(); + DirectionalityX.Show(); + DirectionalityY.Show(); + DirectionalityActiveValueTitle.Show(); + LpNorm.Show(); + Domain.Show(); + Range.Show(); + WholeCheckBox.Show(); + ByComponentCheckBox.Show(); + DirectionalityLabel.Text = Constants.DirectionalityTitleOpen; DrawShown(); IsHidden = false; } @@ -166,11 +174,13 @@ namespace grapher.Models.Options.Directionality private void DrawHidden() { ContainingPanel.Height = DirectionalityLabel.Height + 2 * Constants.DirectionalityTitlePad; + ContainingPanel.Invalidate(); } private void DrawShown() { ContainingPanel.Height = WholeCheckBox.Bottom - DirectionalityLabel.Top + 2 * Constants.DirectionalityTitlePad; + ContainingPanel.Invalidate(); } private void panel_Paint(object sender, PaintEventArgs e) -- cgit v1.2.3 From 784f7cab713640f4a13880ebc3c5abc10894d23c Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 12 Jan 2021 09:25:48 -0800 Subject: Many small tweaks --- grapher/Constants/Constants.cs | 10 +- grapher/Form1.Designer.cs | 170 +++++++++++---------- grapher/Layouts/LayoutBase.cs | 5 +- grapher/Models/AccelGUI.cs | 2 +- grapher/Models/AccelGUIFactory.cs | 3 +- grapher/Models/Charts/AccelCharts.cs | 8 - grapher/Models/Charts/ChartState/ChartState.cs | 2 + grapher/Models/Options/AccelTypeOptions.cs | 1 - grapher/Models/Options/ActiveValueLabelXY.cs | 12 ++ .../Directionality/DirectionalityOptions.cs | 23 ++- grapher/Models/Options/OptionXY.cs | 2 + 11 files changed, 134 insertions(+), 104 deletions(-) (limited to 'grapher') diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index b86874f..0fb9827 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -46,6 +46,12 @@ namespace grapher /// Horizontal separation between left side of single dropdown and left side of labels beneath dropdown public const int DropDownLeftSeparation = 10; + /// Height of sensitivity chart when displayed alone. + public const int SensitivityChartAloneHeight = 450; + + /// Height of sensitivity chart when displayed alongside Velocity and Gain charts. + public const int SensitivityChartTogetherHeight = 328; + /// Width of charts when widened public const int WideChartWidth = 723; @@ -115,10 +121,10 @@ namespace grapher public const string DefaultSettingsFileName = @"settings.json"; /// Text to direcitonality panel title when panel is closed. - public const string DirectionalityTitleClosed = "Directionality\u25BC"; + public const string DirectionalityTitleClosed = "Anisotropy\u25BC"; /// Text to direcitonality panel title when panel is open. - public const string DirectionalityTitleOpen = "Directionality\u25B2"; + public const string DirectionalityTitleOpen = "Anisotropy\u25B2"; /// Style used by System.Double.Parse public const NumberStyles FloatStyle = NumberStyles.Float | NumberStyles.AllowThousands; diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 6e1bc3d..d5dc37f 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -71,7 +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.FakeBox = new System.Windows.Forms.CheckBox(); this.DirectionalityPanel = new System.Windows.Forms.Panel(); + this.LpNormActiveValue = new System.Windows.Forms.Label(); + this.RangeActiveValueY = new System.Windows.Forms.Label(); + this.RangeActiveValueX = new System.Windows.Forms.Label(); + this.DomainActiveValueY = new System.Windows.Forms.Label(); + this.DomainActiveValueX = new System.Windows.Forms.Label(); + this.DirectionalityActiveValueTitle = new System.Windows.Forms.Label(); this.ByComponentCheckBox = new System.Windows.Forms.CheckBox(); this.WholeCheckBox = new System.Windows.Forms.CheckBox(); this.DirectionalityRangeLabel = new System.Windows.Forms.Label(); @@ -180,13 +187,6 @@ 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.DirectionalityActiveValueTitle = new System.Windows.Forms.Label(); - this.DomainActiveValueX = new System.Windows.Forms.Label(); - this.DomainActiveValueY = new System.Windows.Forms.Label(); - this.RangeActiveValueX = new System.Windows.Forms.Label(); - this.RangeActiveValueY = new System.Windows.Forms.Label(); - this.LpNormActiveValue = new System.Windows.Forms.Label(); - this.FakeBox = new System.Windows.Forms.CheckBox(); this.optionsPanel.SuspendLayout(); this.DirectionalityPanel.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -283,6 +283,16 @@ namespace grapher this.optionsPanel.TabIndex = 34; this.optionsPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.optionsPanel_Paint); // + // FakeBox + // + this.FakeBox.AutoSize = true; + this.FakeBox.Location = new System.Drawing.Point(31, 538); + this.FakeBox.Name = "FakeBox"; + this.FakeBox.Size = new System.Drawing.Size(47, 17); + this.FakeBox.TabIndex = 151; + this.FakeBox.Text = "fake"; + this.FakeBox.UseVisualStyleBackColor = true; + // // DirectionalityPanel // this.DirectionalityPanel.Controls.Add(this.LpNormActiveValue); @@ -304,15 +314,70 @@ namespace grapher this.DirectionalityPanel.Controls.Add(this.DomainBoxY); this.DirectionalityPanel.Controls.Add(this.DomainBoxX); this.DirectionalityPanel.Controls.Add(this.DirectionalityLabel); - this.DirectionalityPanel.Location = new System.Drawing.Point(28, 369); + this.DirectionalityPanel.Location = new System.Drawing.Point(12, 369); this.DirectionalityPanel.Name = "DirectionalityPanel"; - this.DirectionalityPanel.Size = new System.Drawing.Size(301, 126); + this.DirectionalityPanel.Size = new System.Drawing.Size(298, 135); this.DirectionalityPanel.TabIndex = 150; // + // LpNormActiveValue + // + this.LpNormActiveValue.AutoSize = true; + this.LpNormActiveValue.Location = new System.Drawing.Point(185, 81); + this.LpNormActiveValue.Name = "LpNormActiveValue"; + this.LpNormActiveValue.Size = new System.Drawing.Size(13, 13); + this.LpNormActiveValue.TabIndex = 18; + this.LpNormActiveValue.Text = "0"; + // + // RangeActiveValueY + // + this.RangeActiveValueY.AutoSize = true; + this.RangeActiveValueY.Location = new System.Drawing.Point(204, 55); + this.RangeActiveValueY.Name = "RangeActiveValueY"; + this.RangeActiveValueY.Size = new System.Drawing.Size(13, 13); + this.RangeActiveValueY.TabIndex = 17; + this.RangeActiveValueY.Text = "0"; + // + // RangeActiveValueX + // + this.RangeActiveValueX.AutoSize = true; + this.RangeActiveValueX.Location = new System.Drawing.Point(177, 55); + this.RangeActiveValueX.Name = "RangeActiveValueX"; + this.RangeActiveValueX.Size = new System.Drawing.Size(13, 13); + this.RangeActiveValueX.TabIndex = 16; + this.RangeActiveValueX.Text = "0"; + // + // DomainActiveValueY + // + this.DomainActiveValueY.AutoSize = true; + this.DomainActiveValueY.Location = new System.Drawing.Point(204, 28); + this.DomainActiveValueY.Name = "DomainActiveValueY"; + this.DomainActiveValueY.Size = new System.Drawing.Size(13, 13); + this.DomainActiveValueY.TabIndex = 15; + this.DomainActiveValueY.Text = "0"; + // + // DomainActiveValueX + // + this.DomainActiveValueX.AutoSize = true; + this.DomainActiveValueX.Location = new System.Drawing.Point(177, 28); + this.DomainActiveValueX.Name = "DomainActiveValueX"; + this.DomainActiveValueX.Size = new System.Drawing.Size(13, 13); + this.DomainActiveValueX.TabIndex = 14; + this.DomainActiveValueX.Text = "0"; + // + // DirectionalityActiveValueTitle + // + this.DirectionalityActiveValueTitle.AutoSize = true; + this.DirectionalityActiveValueTitle.Location = new System.Drawing.Point(176, 9); + this.DirectionalityActiveValueTitle.Name = "DirectionalityActiveValueTitle"; + this.DirectionalityActiveValueTitle.Size = new System.Drawing.Size(41, 13); + this.DirectionalityActiveValueTitle.TabIndex = 13; + this.DirectionalityActiveValueTitle.Text = "Current"; + // // ByComponentCheckBox // + this.ByComponentCheckBox.AutoCheck = false; this.ByComponentCheckBox.AutoSize = true; - this.ByComponentCheckBox.Location = new System.Drawing.Point(163, 104); + this.ByComponentCheckBox.Location = new System.Drawing.Point(180, 104); this.ByComponentCheckBox.Name = "ByComponentCheckBox"; this.ByComponentCheckBox.Size = new System.Drawing.Size(95, 17); this.ByComponentCheckBox.TabIndex = 12; @@ -321,6 +386,7 @@ namespace grapher // // WholeCheckBox // + this.WholeCheckBox.AutoCheck = false; this.WholeCheckBox.AutoSize = true; this.WholeCheckBox.Location = new System.Drawing.Point(43, 104); this.WholeCheckBox.Name = "WholeCheckBox"; @@ -332,7 +398,7 @@ namespace grapher // DirectionalityRangeLabel // this.DirectionalityRangeLabel.AutoSize = true; - this.DirectionalityRangeLabel.Location = new System.Drawing.Point(9, 55); + this.DirectionalityRangeLabel.Location = new System.Drawing.Point(24, 55); this.DirectionalityRangeLabel.Name = "DirectionalityRangeLabel"; this.DirectionalityRangeLabel.Size = new System.Drawing.Size(39, 13); this.DirectionalityRangeLabel.TabIndex = 10; @@ -341,7 +407,7 @@ namespace grapher // DirectionalDomainLabel // this.DirectionalDomainLabel.AutoSize = true; - this.DirectionalDomainLabel.Location = new System.Drawing.Point(9, 28); + this.DirectionalDomainLabel.Location = new System.Drawing.Point(23, 28); this.DirectionalDomainLabel.Name = "DirectionalDomainLabel"; this.DirectionalDomainLabel.Size = new System.Drawing.Size(43, 13); this.DirectionalDomainLabel.TabIndex = 9; @@ -349,7 +415,7 @@ namespace grapher // // LpNormBox // - this.LpNormBox.Location = new System.Drawing.Point(78, 78); + this.LpNormBox.Location = new System.Drawing.Point(94, 78); this.LpNormBox.Name = "LpNormBox"; this.LpNormBox.Size = new System.Drawing.Size(76, 20); this.LpNormBox.TabIndex = 8; @@ -357,7 +423,7 @@ namespace grapher // LPNormLabel // this.LPNormLabel.AutoSize = true; - this.LPNormLabel.Location = new System.Drawing.Point(9, 81); + this.LPNormLabel.Location = new System.Drawing.Point(23, 81); this.LPNormLabel.Name = "LPNormLabel"; this.LPNormLabel.Size = new System.Drawing.Size(47, 13); this.LPNormLabel.TabIndex = 7; @@ -366,7 +432,7 @@ namespace grapher // DirectionalityY // this.DirectionalityY.AutoSize = true; - this.DirectionalityY.Location = new System.Drawing.Point(129, 9); + this.DirectionalityY.Location = new System.Drawing.Point(147, 9); this.DirectionalityY.Name = "DirectionalityY"; this.DirectionalityY.Size = new System.Drawing.Size(14, 13); this.DirectionalityY.TabIndex = 6; @@ -375,7 +441,7 @@ namespace grapher // DirectionalityX // this.DirectionalityX.AutoSize = true; - this.DirectionalityX.Location = new System.Drawing.Point(86, 9); + this.DirectionalityX.Location = new System.Drawing.Point(103, 9); this.DirectionalityX.Name = "DirectionalityX"; this.DirectionalityX.Size = new System.Drawing.Size(14, 13); this.DirectionalityX.TabIndex = 5; @@ -383,28 +449,28 @@ namespace grapher // // RangeBoxY // - this.RangeBoxY.Location = new System.Drawing.Point(120, 52); + this.RangeBoxY.Location = new System.Drawing.Point(136, 52); this.RangeBoxY.Name = "RangeBoxY"; this.RangeBoxY.Size = new System.Drawing.Size(34, 20); this.RangeBoxY.TabIndex = 4; // // RangeBoxX // - this.RangeBoxX.Location = new System.Drawing.Point(78, 52); + this.RangeBoxX.Location = new System.Drawing.Point(94, 52); this.RangeBoxX.Name = "RangeBoxX"; this.RangeBoxX.Size = new System.Drawing.Size(34, 20); this.RangeBoxX.TabIndex = 3; // // DomainBoxY // - this.DomainBoxY.Location = new System.Drawing.Point(120, 25); + this.DomainBoxY.Location = new System.Drawing.Point(136, 25); this.DomainBoxY.Name = "DomainBoxY"; this.DomainBoxY.Size = new System.Drawing.Size(34, 20); this.DomainBoxY.TabIndex = 2; // // DomainBoxX // - this.DomainBoxX.Location = new System.Drawing.Point(78, 25); + this.DomainBoxX.Location = new System.Drawing.Point(94, 25); this.DomainBoxX.Name = "DomainBoxX"; this.DomainBoxX.Size = new System.Drawing.Size(34, 20); this.DomainBoxX.TabIndex = 1; @@ -1422,70 +1488,6 @@ namespace grapher title6.Text = "Sensitivity"; this.AccelerationChart.Titles.Add(title6); // - // DirectionalityActiveValueTitle - // - this.DirectionalityActiveValueTitle.AutoSize = true; - this.DirectionalityActiveValueTitle.Location = new System.Drawing.Point(169, 9); - this.DirectionalityActiveValueTitle.Name = "DirectionalityActiveValueTitle"; - this.DirectionalityActiveValueTitle.Size = new System.Drawing.Size(41, 13); - this.DirectionalityActiveValueTitle.TabIndex = 13; - this.DirectionalityActiveValueTitle.Text = "Current"; - // - // DomainActiveValueX - // - this.DomainActiveValueX.AutoSize = true; - this.DomainActiveValueX.Location = new System.Drawing.Point(169, 28); - this.DomainActiveValueX.Name = "DomainActiveValueX"; - this.DomainActiveValueX.Size = new System.Drawing.Size(13, 13); - this.DomainActiveValueX.TabIndex = 14; - this.DomainActiveValueX.Text = "0"; - // - // DomainActiveValueY - // - this.DomainActiveValueY.AutoSize = true; - this.DomainActiveValueY.Location = new System.Drawing.Point(189, 28); - this.DomainActiveValueY.Name = "DomainActiveValueY"; - this.DomainActiveValueY.Size = new System.Drawing.Size(13, 13); - this.DomainActiveValueY.TabIndex = 15; - this.DomainActiveValueY.Text = "0"; - // - // RangeActiveValueX - // - this.RangeActiveValueX.AutoSize = true; - this.RangeActiveValueX.Location = new System.Drawing.Point(169, 55); - this.RangeActiveValueX.Name = "RangeActiveValueX"; - this.RangeActiveValueX.Size = new System.Drawing.Size(13, 13); - this.RangeActiveValueX.TabIndex = 16; - this.RangeActiveValueX.Text = "0"; - // - // RangeActiveValueY - // - this.RangeActiveValueY.AutoSize = true; - this.RangeActiveValueY.Location = new System.Drawing.Point(188, 55); - this.RangeActiveValueY.Name = "RangeActiveValueY"; - this.RangeActiveValueY.Size = new System.Drawing.Size(13, 13); - this.RangeActiveValueY.TabIndex = 17; - this.RangeActiveValueY.Text = "0"; - // - // LpNormActiveValue - // - this.LpNormActiveValue.AutoSize = true; - this.LpNormActiveValue.Location = new System.Drawing.Point(180, 78); - this.LpNormActiveValue.Name = "LpNormActiveValue"; - this.LpNormActiveValue.Size = new System.Drawing.Size(13, 13); - this.LpNormActiveValue.TabIndex = 18; - this.LpNormActiveValue.Text = "0"; - // - // FakeBox - // - this.FakeBox.AutoSize = true; - this.FakeBox.Location = new System.Drawing.Point(28, 502); - this.FakeBox.Name = "FakeBox"; - this.FakeBox.Size = new System.Drawing.Size(47, 17); - this.FakeBox.TabIndex = 151; - this.FakeBox.Text = "fake"; - this.FakeBox.UseVisualStyleBackColor = true; - // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs index 7ed08ef..83af292 100644 --- a/grapher/Layouts/LayoutBase.cs +++ b/grapher/Layouts/LayoutBase.cs @@ -64,7 +64,6 @@ namespace grapher.Layouts IOption limitOption, IOption expOption, IOption midpointOption, - Button button, int top) { @@ -106,8 +105,7 @@ namespace grapher.Layouts IOption offsetOption, IOption limitOption, IOption expOption, - IOption midpointOption, - Button button) + IOption midpointOption) { Layout(accelOption, scaleOption, @@ -117,7 +115,6 @@ namespace grapher.Layouts limitOption, expOption, midpointOption, - button, accelOption.Top); } } diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 045cb23..e125310 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -192,7 +192,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 e8def16..de01468 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -376,7 +376,8 @@ namespace grapher.Models domain, range, wholeCheckBox, - byComponentCheckBox); + byComponentCheckBox, + 245); var applyOptions = new ApplyOptions( byComponentXYLock, diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index b7abb35..ea1345f 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -80,14 +80,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..269d269 100644 --- a/grapher/Models/Charts/ChartState/ChartState.cs +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -77,12 +77,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/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/Directionality/DirectionalityOptions.cs b/grapher/Models/Options/Directionality/DirectionalityOptions.cs index c83ea52..9485877 100644 --- a/grapher/Models/Options/Directionality/DirectionalityOptions.cs +++ b/grapher/Models/Options/Directionality/DirectionalityOptions.cs @@ -20,7 +20,8 @@ namespace grapher.Models.Options.Directionality OptionXY domain, OptionXY range, CheckBox wholeCheckBox, - CheckBox byComponentCheckBox) + CheckBox byComponentCheckBox, + int top) { ContainingPanel = containingPanel; DirectionalityLabel = directionalityLabel; @@ -33,8 +34,18 @@ namespace grapher.Models.Options.Directionality WholeCheckBox = wholeCheckBox; ByComponentCheckBox = byComponentCheckBox; + Domain.Fields.LockCheckBox.Checked = false; + Range.Fields.LockCheckBox.Checked = false; + Domain.Fields.LockCheckBox.Enabled = false; + Range.Fields.LockCheckBox.Enabled = false; + Domain.Fields.LockCheckBox.Hide(); + Range.Fields.LockCheckBox.Hide(); + Domain.Fields.SetSeparate(); + Range.Fields.SetSeparate(); + ContainingPanel.Paint += panel_Paint; DirectionalityLabel.Click += title_click; + ContainingPanel.Top = top; DirectionalityLabel.Left = Constants.DirectionalityTitlePad; DirectionalityLabel.Top = Constants.DirectionalityTitlePad; IsHidden = false; @@ -62,6 +73,10 @@ namespace grapher.Models.Options.Directionality 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() @@ -149,6 +164,8 @@ namespace grapher.Models.Options.Directionality LpNorm.Show(); Domain.Show(); Range.Show(); + Domain.Fields.LockCheckBox.Hide(); + Range.Fields.LockCheckBox.Hide(); WholeCheckBox.Show(); ByComponentCheckBox.Show(); DirectionalityLabel.Text = Constants.DirectionalityTitleOpen; @@ -173,13 +190,13 @@ namespace grapher.Models.Options.Directionality private void DrawHidden() { - ContainingPanel.Height = DirectionalityLabel.Height + 2 * Constants.DirectionalityTitlePad; + ContainingPanel.Height = ClosedHeight; ContainingPanel.Invalidate(); } private void DrawShown() { - ContainingPanel.Height = WholeCheckBox.Bottom - DirectionalityLabel.Top + 2 * Constants.DirectionalityTitlePad; + ContainingPanel.Height = OpenHeight; ContainingPanel.Invalidate(); } diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs index 3557a06..911d26b 100644 --- a/grapher/Models/Options/OptionXY.cs +++ b/grapher/Models/Options/OptionXY.cs @@ -137,6 +137,7 @@ namespace grapher Fields.Hide(); Fields.LockCheckBox.Hide(); Label.Hide(); + ActiveValueLabels.Hide(); } public void Show() @@ -144,6 +145,7 @@ namespace grapher Fields.Show(); Fields.LockCheckBox.Show(); Label.Show(); + ActiveValueLabels.Show(); } public override void Show(string name) -- cgit v1.2.3 From b6d7c7e67b487143276ad17c9ab85c0dba13180d Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 12 Jan 2021 09:43:25 -0800 Subject: Fix xy anisotropy combining in gui --- grapher/Models/AccelGUIFactory.cs | 6 ++-- grapher/Models/Fields/FieldXY.cs | 33 +++++++++++++++++----- .../Directionality/DirectionalityOptions.cs | 19 +++---------- grapher/Models/Options/OptionXY.cs | 11 +++++--- 4 files changed, 41 insertions(+), 28 deletions(-) (limited to 'grapher') diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index de01468..802ce4b 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -305,7 +305,8 @@ namespace grapher.Models domainLabel, new ActiveValueLabelXY( new ActiveValueLabel(domainActiveValueX, direcionalityActiveValueTitle), - new ActiveValueLabel(domainActiveValueY, direcionalityActiveValueTitle))); + new ActiveValueLabel(domainActiveValueY, direcionalityActiveValueTitle)), + false); var range = new OptionXY( rangeBoxX, @@ -316,7 +317,8 @@ namespace grapher.Models rangeLabel, new ActiveValueLabelXY( new ActiveValueLabel(rangeActiveValueX, direcionalityActiveValueTitle), - new ActiveValueLabel(rangeActiveValueY, direcionalityActiveValueTitle))); + new ActiveValueLabel(rangeActiveValueY, direcionalityActiveValueTitle)), + false); var capOptionsX = new CapOptions( velocityGainCapToolStripMenuItem, diff --git a/grapher/Models/Fields/FieldXY.cs b/grapher/Models/Fields/FieldXY.cs index a7db922..3396907 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 @@ -147,6 +149,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 +177,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/Options/Directionality/DirectionalityOptions.cs b/grapher/Models/Options/Directionality/DirectionalityOptions.cs index 9485877..d9a67cd 100644 --- a/grapher/Models/Options/Directionality/DirectionalityOptions.cs +++ b/grapher/Models/Options/Directionality/DirectionalityOptions.cs @@ -34,17 +34,8 @@ namespace grapher.Models.Options.Directionality WholeCheckBox = wholeCheckBox; ByComponentCheckBox = byComponentCheckBox; - Domain.Fields.LockCheckBox.Checked = false; - Range.Fields.LockCheckBox.Checked = false; - Domain.Fields.LockCheckBox.Enabled = false; - Range.Fields.LockCheckBox.Enabled = false; - Domain.Fields.LockCheckBox.Hide(); - Range.Fields.LockCheckBox.Hide(); - Domain.Fields.SetSeparate(); - Range.Fields.SetSeparate(); - - ContainingPanel.Paint += panel_Paint; - DirectionalityLabel.Click += title_click; + ContainingPanel.Paint += Panel_Paint; + DirectionalityLabel.Click += Title_click; ContainingPanel.Top = top; DirectionalityLabel.Left = Constants.DirectionalityTitlePad; DirectionalityLabel.Top = Constants.DirectionalityTitlePad; @@ -164,8 +155,6 @@ namespace grapher.Models.Options.Directionality LpNorm.Show(); Domain.Show(); Range.Show(); - Domain.Fields.LockCheckBox.Hide(); - Range.Fields.LockCheckBox.Hide(); WholeCheckBox.Show(); ByComponentCheckBox.Show(); DirectionalityLabel.Text = Constants.DirectionalityTitleOpen; @@ -200,7 +189,7 @@ namespace grapher.Models.Options.Directionality ContainingPanel.Invalidate(); } - private void panel_Paint(object sender, PaintEventArgs e) + private void Panel_Paint(object sender, PaintEventArgs e) { Color col = Color.DarkGray; ButtonBorderStyle bbs = ButtonBorderStyle.Dashed; @@ -208,7 +197,7 @@ namespace grapher.Models.Options.Directionality 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) + private void Title_click(object sender, EventArgs e) { if (IsHidden) { diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs index 911d26b..8efd5b7 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); } -- cgit v1.2.3 From 8c55ca08881b59943bc9dda193107cc8a117cf69 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 18 Jan 2021 17:39:10 -0800 Subject: Refactor for new graph calculation method --- grapher/Models/Calculations/AccelCalculator.cs | 73 ++++++++++++++++++++ .../Models/Calculations/Data/AccelDataCombined.cs | 49 ++++++++++++++ .../Calculations/Data/AccelDataXYComponential.cs | 64 ++++++++++++++++++ .../Calculations/Data/AccelDataXYDirectional.cs | 77 ++++++++++++++++++++++ grapher/Models/Calculations/Data/IAccelData.cs | 21 ++++++ grapher/Models/Charts/AccelCharts.cs | 4 +- grapher/Models/Charts/ChartState/ChartState.cs | 5 +- .../Models/Charts/ChartState/ChartStateManager.cs | 11 ++-- grapher/Models/Charts/ChartState/CombinedState.cs | 20 +++--- .../Models/Charts/ChartState/XYOneGraphState.cs | 8 ++- .../Models/Charts/ChartState/XYTwoGraphState.cs | 11 ++-- grapher/grapher.csproj | 4 ++ 12 files changed, 322 insertions(+), 25 deletions(-) create mode 100644 grapher/Models/Calculations/Data/AccelDataCombined.cs create mode 100644 grapher/Models/Calculations/Data/AccelDataXYComponential.cs create mode 100644 grapher/Models/Calculations/Data/AccelDataXYDirectional.cs create mode 100644 grapher/Models/Calculations/Data/IAccelData.cs (limited to 'grapher') diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 2c32753..f59a0fa 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,0, 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 Angles = GetAngles(); + + #endregion static + #region Constructors public AccelCalculator(Field dpi, Field pollRate) @@ -58,6 +70,14 @@ namespace grapher.Models.Calculations #region Methods + public static IEnumerable GetAngles() + { + for(int i=0; i<19; i++) + { + yield return (i / 18) * (Math.PI / 2); + } + } + public void Calculate(AccelChartData data, ManagedAccel accel, double starter, ICollection simulatedInputData) { double lastInputMagnitude = 0; @@ -316,6 +336,7 @@ namespace grapher.Models.Calculations mouseInputData.y = j; mouseInputData.time = MeasurementTime; mouseInputData.velocity = Velocity(i, j, mouseInputData.time); + mouseInputData.angle = Math.Atan2(j,i); magnitudes.Add(mouseInputData); } } @@ -336,6 +357,7 @@ namespace grapher.Models.Calculations mouseInputData.y = 0; mouseInputData.time = MeasurementTime; mouseInputData.velocity = Velocity(i, 0, mouseInputData.time); + mouseInputData.angle = 0; magnitudes.Add(mouseInputData); } @@ -353,12 +375,63 @@ namespace grapher.Models.Calculations mouseInputData.y = i; mouseInputData.time = MeasurementTime; mouseInputData.velocity = Velocity(0, i, mouseInputData.time); + mouseInputData.angle = Math.PI / 2; magnitudes.Add(mouseInputData); } return magnitudes.AsReadOnly(); } + public ReadOnlyCollection GetSimulatedInputXY() + { + var magnitudes = new List(); + + foreach (var slowMoveMagnitude in SlowMovements) + { + foreach (var slowAngle in Angles) + { + var slowMoveX = slowMoveMagnitude * Math.Cos(slowAngle); + var slowMoveY = slowMoveMagnitude * Math.Sin(slowAngle); + var ceilX = (int)Math.Ceiling(slowMoveX); + var ceilY = (int)Math.Ceiling(slowMoveY); + var magnitude = Magnitude(slowMoveX, slowMoveY); + 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, timeFactor); + mouseInputData.angle = slowAngle; + magnitudes.Add(mouseInputData); + } + } + + for (int magnitude = 5; magnitude < XYMaxVelocity; magnitude+=Increment) + { + foreach (var angle in Angles) + { + var slowMoveX = magnitude * Math.Cos(angle); + var slowMoveY = magnitude * Math.Sin(angle); + var ceilX = (int)Math.Ceiling(slowMoveX); + var ceilY = (int)Math.Ceiling(slowMoveY); + var ceilMagnitude = Magnitude(ceilX, ceilY); + var timeFactor = ceilMagnitude / magnitude; + + SimulatedMouseInput mouseInputData; + mouseInputData.x =ceilX; + mouseInputData.y = ceilY; + mouseInputData.time = MeasurementTime; + mouseInputData.velocity = Velocity(ceilX, ceilY, mouseInputData.time); + mouseInputData.angle = angle; + magnitudes.Add(mouseInputData); + } + } + + return magnitudes.AsReadOnly(); + } + public static double Magnitude(int x, int y) { return Math.Sqrt(x * x + y * y); 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..ffa353f --- /dev/null +++ b/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs @@ -0,0 +1,77 @@ +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) + { + 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 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)) + { + XPoints.Sensitivity.Set(points.Item1, points.Item2); + XPoints.Velocity.Set(points.Item1, points.Item3); + XPoints.Gain.Set(points.Item1, points.Item4); + YPoints.Sensitivity.Set(points.Item1, points.Item5); + YPoints.Velocity.Set(points.Item1, points.Item6); + YPoints.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); + } + + } + + public void Clear() + { + X.Clear(); + Y.Clear(); + } + + public void CreateGraphData(ManagedAccel accel, DriverSettings settings) + { + Clear(); + } + + } +} 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 ea1345f..b9f7a8b 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -1,4 +1,5 @@ using grapher.Models.Calculations; +using grapher.Models.Calculations.Data; using grapher.Models.Charts; using grapher.Models.Charts.ChartState; using grapher.Models.Serialized; @@ -26,7 +27,6 @@ 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); ContainingForm = form; @@ -56,7 +56,7 @@ namespace grapher private Button WriteButton { get; } - public AccelData AccelData + public IAccelData AccelData { get { diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs index 269d269..2a0325c 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; } diff --git a/grapher/Models/Charts/ChartState/ChartStateManager.cs b/grapher/Models/Charts/ChartState/ChartStateManager.cs index ff4fe54..9ed54e1 100644 --- a/grapher/Models/Charts/ChartState/ChartStateManager.cs +++ b/grapher/Models/Charts/ChartState/ChartStateManager.cs @@ -14,21 +14,24 @@ 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( diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs index 9eadb87..7275d16 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() { @@ -37,16 +39,16 @@ namespace grapher.Models.Charts.ChartState 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); + 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); } public override void Calculate(ManagedAccel accel, DriverSettings settings) { - Calculator.Calculate(Data.Combined, accel, settings.sensitivity.x, Calculator.SimulatedInputCombined); + Calculator.Calculate(Data.X, accel, settings.sensitivity.x, Calculator.SimulatedInputCombined); } } } diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs index 4a755b6..14d8850 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,15 +10,16 @@ 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 AccelDataXYDirectional(xPoints, yPoints, accelCalculator); TwoDotsPerGraph = true; } @@ -30,7 +32,7 @@ namespace grapher.Models.Charts.ChartState public override void MakeDots(double x, double y, double timeInMs) { - Data.CalculateDotsCombinedDiffSens(x, y, timeInMs, Settings); + Data.CalculateDots(x, y, timeInMs); } public override void Bind() diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs index 732ea3c..7dc2810 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; } @@ -35,7 +38,7 @@ namespace grapher.Models.Charts.ChartState public override void MakeDots(double x, double y, double timeInMs) { - Data.CalculateDotsXY(x, y, timeInMs); + Data.CalculateDots(x, y, timeInMs); } public override void Bind() diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 140d521..0216b8b 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -84,6 +84,10 @@ + + + + -- cgit v1.2.3 From 4faf0007c7c551fae8fd25fc7a98767070cb9244 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 18 Jan 2021 22:02:29 -0800 Subject: Directional works --- grapher/Constants/Constants.cs | 3 + grapher/Models/Calculations/AccelCalculator.cs | 300 +++++++++------------ grapher/Models/Calculations/AccelData.cs | 117 -------- .../Calculations/Data/AccelDataXYDirectional.cs | 73 ++--- grapher/Models/Charts/AccelCharts.cs | 11 +- grapher/Models/Charts/ChartState/ChartState.cs | 10 +- .../Models/Charts/ChartState/ChartStateManager.cs | 3 +- grapher/Models/Charts/ChartState/CombinedState.cs | 10 - .../Models/Charts/ChartState/XYOneGraphState.cs | 23 +- .../Models/Charts/ChartState/XYTwoGraphState.cs | 11 - grapher/grapher.csproj | 1 - 11 files changed, 201 insertions(+), 361 deletions(-) delete mode 100644 grapher/Models/Calculations/AccelData.cs (limited to 'grapher') diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index 0fb9827..c76ac59 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -72,6 +72,9 @@ namespace grapher public const float SmallButtonSizeFactor = 0.666f; + /// Number of divisions between 0 and 90 degrees for directional lookup. For 19: 0, 5, 10... 85, 90. + public const int AngleDivisions = 19; + /// Format string for shortened x and y textboxes. public const string ShortenedFormatString = "0.###"; diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index f59a0fa..260d137 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -25,7 +25,7 @@ namespace grapher.Models.Calculations public static double[] SlowMovements = { - 0,0, 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, + 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 Angles = GetAngles(); @@ -50,6 +50,8 @@ namespace grapher.Models.Calculations public ReadOnlyCollection SimulatedInputY { get; private set; } + public IReadOnlyCollection> SimulatedDirectionalInput { get; private set; } + public Field DPI { get; private set; } public Field PollRate { get; private set; } @@ -72,12 +74,18 @@ namespace grapher.Models.Calculations public static IEnumerable GetAngles() { - for(int i=0; i<19; i++) + for(double i=0; i < (Constants.AngleDivisions); i++) { - yield return (i / 18) * (Math.PI / 2); + 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 simulatedInputData) { double lastInputMagnitude = 0; @@ -174,12 +182,8 @@ namespace grapher.Models.Calculations data.MinGain = minSlope; } - public void CalculateCombinedDiffSens(AccelData data, ManagedAccel accel, DriverSettings settings, ICollection simulatedInputData) + public void CalculateCombinedDiffSens(AccelChartData[] dataByAngle, ManagedAccel accel, DriverSettings settings, IReadOnlyCollection> simulatedInputData) { - double lastInputMagnitude = 0; - double lastOutputMagnitudeX = 0; - double lastOutputMagnitudeY = 0; - double maxRatio = 0.0; double minRatio = Double.MaxValue; double maxSlope = 0.0; @@ -188,140 +192,101 @@ 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 ratio = magnitude / simulatedInputDatum.velocity; + + 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++; + } + + if (ratio > maxRatio) + { + maxRatio = ratio; + } + + if (ratio < minRatio) + { + minRatio = ratio; + } + + var inDiff = simulatedInputDatum.velocity - lastInputMagnitude; + var outDiff = magnitude - lastOutputMagnitude; + var slope = inDiff > 0 ? outDiff / inDiff : settings.sensitivity.x; + + if (slope > maxSlope) + { + maxSlope = slope; + } + + if (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 GetSimulatedInput() @@ -382,54 +347,56 @@ namespace grapher.Models.Calculations return magnitudes.AsReadOnly(); } - public ReadOnlyCollection GetSimulatedInputXY() + public IReadOnlyCollection> GetSimulatedDirectionalInput() { - var magnitudes = new List(); + var magnitudesByAngle = new List>(); - foreach (var slowMoveMagnitude in SlowMovements) + foreach (var angle in Angles) { - foreach (var slowAngle in Angles) - { - var slowMoveX = slowMoveMagnitude * Math.Cos(slowAngle); - var slowMoveY = slowMoveMagnitude * Math.Sin(slowAngle); - var ceilX = (int)Math.Ceiling(slowMoveX); - var ceilY = (int)Math.Ceiling(slowMoveY); - var magnitude = Magnitude(slowMoveX, slowMoveY); - var ceilMagnitude = Magnitude(ceilX, ceilY); - var timeFactor = ceilMagnitude / magnitude; + var magnitudes = new List(); - SimulatedMouseInput mouseInputData; - mouseInputData.x = ceilX; - mouseInputData.y = ceilY; - mouseInputData.time = timeFactor; - mouseInputData.velocity = Velocity(ceilX, ceilY, timeFactor); - mouseInputData.angle = slowAngle; - magnitudes.Add(mouseInputData); + foreach (var slowMoveMagnitude in SlowMovements) + { + var slowMoveX = Math.Round(slowMoveMagnitude * Math.Cos(angle), 4); + var slowMoveY = Math.Round(slowMoveMagnitude * 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 / 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 (int magnitude = 5; magnitude < XYMaxVelocity; magnitude+=Increment) - { - foreach (var angle in Angles) + for (int magnitude = 5; magnitude < XYMaxVelocity; magnitude+=Increment) { - var slowMoveX = magnitude * Math.Cos(angle); - var slowMoveY = magnitude * Math.Sin(angle); - var ceilX = (int)Math.Ceiling(slowMoveX); - var ceilY = (int)Math.Ceiling(slowMoveY); - var ceilMagnitude = Magnitude(ceilX, ceilY); - var timeFactor = ceilMagnitude / magnitude; - - SimulatedMouseInput mouseInputData; - mouseInputData.x =ceilX; - mouseInputData.y = ceilY; - mouseInputData.time = MeasurementTime; - mouseInputData.velocity = Velocity(ceilX, ceilY, mouseInputData.time); - mouseInputData.angle = angle; - magnitudes.Add(mouseInputData); + 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 magnitudes.AsReadOnly(); + return magnitudesByAngle.AsReadOnly(); } public static double Magnitude(int x, int y) @@ -487,6 +454,7 @@ namespace grapher.Models.Calculations 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(); - } - - #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 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/AccelDataXYDirectional.cs b/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs index ffa353f..ad54989 100644 --- a/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs +++ b/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs @@ -14,16 +14,26 @@ namespace grapher.Models.Calculations.Data EstimatedPoints yPoints, AccelCalculator calculator) { - X = new AccelChartData(); - Y = new AccelChartData(); XPoints = xPoints; YPoints = yPoints; Calculator = calculator; + AngleToData = new AccelChartData[Constants.AngleDivisions]; + FillAngleData(); } - public AccelChartData X { get; } + public AccelChartData X { get => AngleToData[0]; } - public AccelChartData Y { get; } + 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; } @@ -33,45 +43,42 @@ namespace grapher.Models.Calculations.Data public void CalculateDots(double x, double y, double timeInMs) { - (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)) - { - XPoints.Sensitivity.Set(points.Item1, points.Item2); - XPoints.Velocity.Set(points.Item1, points.Item3); - XPoints.Gain.Set(points.Item1, points.Item4); - YPoints.Sensitivity.Set(points.Item1, points.Item5); - YPoints.Velocity.Set(points.Item1, points.Item6); - YPoints.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); - } - + 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() { - X.Clear(); - Y.Clear(); + foreach (var data in AngleToData) + { + data.Clear(); + } } public void CreateGraphData(ManagedAccel accel, DriverSettings settings) { Clear(); + Calculator.CalculateCombinedDiffSens(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/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index b9f7a8b..2369432 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -2,9 +2,7 @@ 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 @@ -27,7 +25,14 @@ namespace grapher var estimatedX = new EstimatedPoints(); var estimatedY = new EstimatedPoints(); SetupCharts(sensitivityChart, velocityChart, gainChart, 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; diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs index 2a0325c..5a86713 100644 --- a/grapher/Models/Charts/ChartState/ChartState.cs +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -39,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() { diff --git a/grapher/Models/Charts/ChartState/ChartStateManager.cs b/grapher/Models/Charts/ChartState/ChartStateManager.cs index 9ed54e1..3d4bbec 100644 --- a/grapher/Models/Charts/ChartState/ChartStateManager.cs +++ b/grapher/Models/Charts/ChartState/ChartStateManager.cs @@ -38,7 +38,8 @@ namespace grapher.Models.Charts.ChartState sensitivityChart, velocityChart, gainChat, - accelData, + xPoints, + yPoints, accelCalculator); } diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs index 7275d16..3511cec 100644 --- a/grapher/Models/Charts/ChartState/CombinedState.cs +++ b/grapher/Models/Charts/ChartState/CombinedState.cs @@ -32,11 +32,6 @@ 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.X.AccelPoints); @@ -45,10 +40,5 @@ namespace grapher.Models.Charts.ChartState SensitivityChart.SetMinMax(Data.X.MinAccel, Data.X.MaxAccel); GainChart.SetMinMax(Data.X.MinGain, Data.X.MaxGain); } - - public override void Calculate(ManagedAccel accel, DriverSettings settings) - { - Calculator.Calculate(Data.X, accel, settings.sensitivity.x, Calculator.SimulatedInputCombined); - } } } diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs index 14d8850..34e9070 100644 --- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs @@ -19,10 +19,13 @@ namespace grapher.Models.Charts.ChartState gainChart, accelCalculator) { - Data = new AccelDataXYDirectional(xPoints, yPoints, accelCalculator); + DataDirectional = new AccelDataXYDirectional(xPoints, yPoints, accelCalculator); + Data = DataDirectional; TwoDotsPerGraph = true; } + private AccelDataXYDirectional DataDirectional { get; } + public override void Activate() { SensitivityChart.SetCombined(); @@ -30,27 +33,13 @@ namespace grapher.Models.Charts.ChartState GainChart.SetCombined(); } - public override void MakeDots(double x, double y, double timeInMs) - { - Data.CalculateDots(x, y, timeInMs); - } - 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); - Data.X.Clear(); - Data.Y.Clear(); - Calculator.Calculate(Data.X, accel, settings.sensitivity.x, Calculator.SimulatedInputX); - Calculator.Calculate(Data.Y, accel, settings.sensitivity.y, Calculator.SimulatedInputY); + 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 7dc2810..5b6c2b8 100644 --- a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs @@ -36,11 +36,6 @@ 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.BindXY(Data.X.AccelPoints, Data.Y.AccelPoints); @@ -50,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/grapher.csproj b/grapher/grapher.csproj index 0216b8b..88e7752 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -83,7 +83,6 @@ - -- cgit v1.2.3 From 8e5019e93688c318a31ed513938498e06aa2daf4 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 18 Jan 2021 22:13:54 -0800 Subject: Add timer to mousewatcher for better low-end fidelity --- grapher/Models/Mouse/MouseWatcher.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'grapher') diff --git a/grapher/Models/Mouse/MouseWatcher.cs b/grapher/Models/Mouse/MouseWatcher.cs index cbfc119..3cc8bd0 100644 --- a/grapher/Models/Mouse/MouseWatcher.cs +++ b/grapher/Models/Mouse/MouseWatcher.cs @@ -1,5 +1,6 @@ using grapher.Models.Serialized; using System; +using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -695,6 +696,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 @@ -711,6 +714,8 @@ namespace grapher.Models.Mouse private MouseData MouseData { get; } + private Stopwatch Stopwatch { get; } + private double PollTime { get => 1000 / SettingsManager.PollRateField.Data; @@ -738,6 +743,11 @@ namespace grapher.Models.Mouse if (relative && (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; @@ -757,7 +767,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); } } -- cgit v1.2.3 From 3bf6b041ee4b39def0200d238936322ce01a1afb Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 18 Jan 2021 22:21:04 -0800 Subject: Hide offset for power type --- grapher/Layouts/PowerLayout.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grapher') diff --git a/grapher/Layouts/PowerLayout.cs b/grapher/Layouts/PowerLayout.cs index 1911813..da7d5bb 100644 --- a/grapher/Layouts/PowerLayout.cs +++ b/grapher/Layouts/PowerLayout.cs @@ -15,7 +15,7 @@ namespace grapher.Layouts ScaleLayout = new OptionLayout(true, Scale); CapLayout = new OptionLayout(true, Cap); WeightLayout = new OptionLayout(true, Weight); - OffsetLayout = new OptionLayout(true, Offset); + OffsetLayout = new OptionLayout(false, string.Empty); LimitLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(true, Exponent); MidpointLayout = new OptionLayout(false, string.Empty); -- cgit v1.2.3 From 74de604f28a70b2ab444e6ba53979ea94e3b8d23 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 19 Jan 2021 00:30:53 -0800 Subject: Mostly working --- grapher/Models/Calculations/AccelCalculator.cs | 78 +++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 9 deletions(-) (limited to 'grapher') diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 260d137..a3b8e07 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -90,6 +90,8 @@ namespace grapher.Models.Calculations { double lastInputMagnitude = 0; double lastOutputMagnitude = 0; + SimulatedMouseInput lastInput; + double lastSlope = 0; double maxRatio = 0.0; double minRatio = Double.MaxValue; @@ -109,6 +111,14 @@ 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); + var slope = inDiff > 0 ? outDiff / inDiff : starter; + + if (inDiff <= 0) + { + continue; + } if (!data.VelocityPoints.ContainsKey(simulatedInputDatum.velocity)) { @@ -138,10 +148,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; @@ -165,6 +171,8 @@ namespace grapher.Models.Calculations lastInputMagnitude = simulatedInputDatum.velocity; lastOutputMagnitude = outMagnitude; index += 1; + lastInput = simulatedInputDatum; + lastSlope = slope; } index--; @@ -292,7 +300,34 @@ namespace grapher.Models.Calculations public ReadOnlyCollection GetSimulatedInput() { var magnitudes = new List(); - for (int i = 0; i < CombinedMaxVelocity; i+=Increment) + + foreach (var slowMoveX in SlowMovements) + { + foreach (var slowMoveY in SlowMovements) + { + if (slowMoveY >= slowMoveX) + { + continue; + } + + 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 (int i = 5; i < CombinedMaxVelocity; i+=Increment) { for (int j = 0; j <= i; j+=Increment) { @@ -315,7 +350,20 @@ namespace grapher.Models.Calculations { var magnitudes = new List(); - 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 = ceil; + mouseInputData.y = 0; + mouseInputData.time = MeasurementTime*timeFactor; + mouseInputData.velocity = Velocity(ceil, 0, mouseInputData.time); + mouseInputData.angle = 0; + magnitudes.Add(mouseInputData); + } + + for (int i = 5; i < XYMaxVelocity; i+=Increment) { SimulatedMouseInput mouseInputData; mouseInputData.x = i; @@ -333,7 +381,20 @@ namespace grapher.Models.Calculations { var magnitudes = new List(); - 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 (int i = 5; i < XYMaxVelocity; i+=Increment) { SimulatedMouseInput mouseInputData; mouseInputData.x = 0; @@ -359,9 +420,8 @@ namespace grapher.Models.Calculations { var slowMoveX = Math.Round(slowMoveMagnitude * Math.Cos(angle), 4); var slowMoveY = Math.Round(slowMoveMagnitude * 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 ceilY = (int)Math.Round(slowMoveY*90); var ceilMagnitude = Magnitude(ceilX, ceilY); var timeFactor = ceilMagnitude / slowMoveMagnitude; -- cgit v1.2.3 From 376e48c82ce992fd35aef927bbff9753f3547951 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 19 Jan 2021 00:31:11 -0800 Subject: further tweaks --- grapher/Models/Calculations/AccelCalculator.cs | 52 +++++++++------------- grapher/Models/Fields/FieldXY.cs | 3 +- .../Directionality/DirectionalityOptions.cs | 1 + grapher/Models/Options/OptionXY.cs | 1 - 4 files changed, 24 insertions(+), 33 deletions(-) (limited to 'grapher') diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index a3b8e07..ffe8444 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -113,7 +113,6 @@ namespace grapher.Models.Calculations var outMagnitude = Velocity(output.Item1, output.Item2, simulatedInputDatum.time); var inDiff = Math.Round(simulatedInputDatum.velocity - lastInputMagnitude, 5); var outDiff = Math.Round(outMagnitude - lastOutputMagnitude, 5); - var slope = inDiff > 0 ? outDiff / inDiff : starter; if (inDiff <= 0) { @@ -137,6 +136,7 @@ namespace grapher.Models.Calculations } var ratio = outMagnitude / simulatedInputDatum.velocity; + var slope = inDiff > 0 ? outDiff / inDiff : starter; if (ratio > maxRatio) { @@ -303,42 +303,32 @@ namespace grapher.Models.Calculations foreach (var slowMoveX in SlowMovements) { - foreach (var slowMoveY in SlowMovements) - { - if (slowMoveY >= slowMoveX) - { - continue; - } - - 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); + 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); + 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 (int i = 5; i < CombinedMaxVelocity; i+=Increment) { - 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); - mouseInputData.angle = Math.Atan2(j,i); - magnitudes.Add(mouseInputData); - } + SimulatedMouseInput mouseInputData; + mouseInputData.x = i; + mouseInputData.y = i; + mouseInputData.time = MeasurementTime; + mouseInputData.velocity = Velocity(i, i, mouseInputData.time); + mouseInputData.angle = Math.Atan2(i,i); + magnitudes.Add(mouseInputData); } magnitudes.Sort((m1, m2) => m1.velocity.CompareTo(m2.velocity)); diff --git a/grapher/Models/Fields/FieldXY.cs b/grapher/Models/Fields/FieldXY.cs index 3396907..72f14ea 100644 --- a/grapher/Models/Fields/FieldXY.cs +++ b/grapher/Models/Fields/FieldXY.cs @@ -129,9 +129,10 @@ namespace grapher YField.SetNewDefault(y); XField.SetToDefault(); - if (x != y) + if (x != y || !AllowCombined) { LockCheckBox.Checked = false; + YField.SetToDefault(); if (Combined) { diff --git a/grapher/Models/Options/Directionality/DirectionalityOptions.cs b/grapher/Models/Options/Directionality/DirectionalityOptions.cs index d9a67cd..c21b932 100644 --- a/grapher/Models/Options/Directionality/DirectionalityOptions.cs +++ b/grapher/Models/Options/Directionality/DirectionalityOptions.cs @@ -155,6 +155,7 @@ namespace grapher.Models.Options.Directionality LpNorm.Show(); Domain.Show(); Range.Show(); + Range.Fields.LockCheckBox.Hide(); WholeCheckBox.Show(); ByComponentCheckBox.Show(); DirectionalityLabel.Text = Constants.DirectionalityTitleOpen; diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs index 8efd5b7..102d05d 100644 --- a/grapher/Models/Options/OptionXY.cs +++ b/grapher/Models/Options/OptionXY.cs @@ -127,7 +127,6 @@ namespace grapher { ActiveValueLabels.SetValues(x, y); Fields.SetActive(x, y); - } public override void AlignActiveValues() -- cgit v1.2.3 From 9c2be5743fb44e8a68084ac0bd15c02f6cce637a Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 20 Jan 2021 00:30:50 -0800 Subject: Final graph fidelity tweaks and fixes --- grapher/Constants/Constants.cs | 5 +- grapher/Models/Calculations/AccelCalculator.cs | 53 ++++++++++++---------- .../Calculations/Data/AccelDataXYDirectional.cs | 2 +- grapher/Models/Charts/ChartXY.cs | 4 +- 4 files changed, 34 insertions(+), 30 deletions(-) (limited to 'grapher') diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index c76ac59..e31f62c 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -17,10 +17,7 @@ namespace grapher public const int Resolution = 100; /// Multiplied by DPI over poll rate to find rough max expected velocity. - public const double MaxMultiplier = 85; - - /// Ratio of max (X, Y) used in "by component" calulations to those used in "whole vector" calculations. - public const double XYToCombinedRatio = 1.4; + public const double MaxMultiplier = .05; /// Separation between X and Y active value labels, in pixels. public const int ActiveLabelXYSeparation = 2; diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index ffe8444..733a3c0 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -56,9 +56,7 @@ namespace grapher.Models.Calculations 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; } @@ -114,7 +112,7 @@ namespace grapher.Models.Calculations var inDiff = Math.Round(simulatedInputDatum.velocity - lastInputMagnitude, 5); var outDiff = Math.Round(outMagnitude - lastOutputMagnitude, 5); - if (inDiff <= 0) + if (inDiff == 0) { continue; } @@ -137,7 +135,7 @@ namespace grapher.Models.Calculations var ratio = outMagnitude / simulatedInputDatum.velocity; var slope = inDiff > 0 ? outDiff / inDiff : starter; - + if (ratio > maxRatio) { maxRatio = ratio; @@ -190,7 +188,7 @@ namespace grapher.Models.Calculations data.MinGain = minSlope; } - public void CalculateCombinedDiffSens(AccelChartData[] dataByAngle, ManagedAccel accel, DriverSettings settings, IReadOnlyCollection> simulatedInputData) + public void CalculateDirectional(AccelChartData[] dataByAngle, ManagedAccel accel, DriverSettings settings, IReadOnlyCollection> simulatedInputData) { double maxRatio = 0.0; double minRatio = Double.MaxValue; @@ -221,8 +219,18 @@ namespace grapher.Models.Calculations 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); - var ratio = magnitude / simulatedInputDatum.velocity; + if (inDiff == 0) + { + continue; + } + + if (inDiff < 0 || outDiff < 0) + { + Console.WriteLine(string.Empty); + } if (!data.VelocityPoints.ContainsKey(simulatedInputDatum.velocity)) { @@ -240,26 +248,27 @@ namespace grapher.Models.Calculations logIndex++; } - if (ratio > maxRatio) + 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 (ratio < minRatio) + if (indexToMeasureExtrema && (ratio < minRatio)) { minRatio = ratio; } - var inDiff = simulatedInputDatum.velocity - lastInputMagnitude; - var outDiff = magnitude - lastOutputMagnitude; - var slope = inDiff > 0 ? outDiff / inDiff : settings.sensitivity.x; - - if (slope > maxSlope) + if (indexToMeasureExtrema && (slope > maxSlope)) { maxSlope = slope; } - if (slope < minSlope) + if (indexToMeasureExtrema && (slope < minSlope)) { minSlope = slope; } @@ -320,7 +329,7 @@ namespace grapher.Models.Calculations } - for (int i = 5; i < CombinedMaxVelocity; i+=Increment) + for (int i = 5; i < MaxVelocity; i+=Increment) { SimulatedMouseInput mouseInputData; mouseInputData.x = i; @@ -353,7 +362,7 @@ namespace grapher.Models.Calculations magnitudes.Add(mouseInputData); } - for (int i = 5; i < XYMaxVelocity; i+=Increment) + for (int i = 5; i < MaxVelocity; i+=Increment) { SimulatedMouseInput mouseInputData; mouseInputData.x = i; @@ -384,7 +393,7 @@ namespace grapher.Models.Calculations magnitudes.Add(mouseInputData); } - for (int i = 5; i < XYMaxVelocity; i+=Increment) + for (int i = 5; i < MaxVelocity; i+=Increment) { SimulatedMouseInput mouseInputData; mouseInputData.x = 0; @@ -424,7 +433,7 @@ namespace grapher.Models.Calculations magnitudes.Add(mouseInputData); } - for (int magnitude = 5; magnitude < XYMaxVelocity; magnitude+=Increment) + for (int magnitude = 5; magnitude < MaxVelocity; magnitude+=Increment) { var slowMoveX = Math.Round(magnitude * Math.Cos(angle), 4); var slowMoveY = Math.Round(magnitude * Math.Sin(angle), 4); @@ -495,12 +504,10 @@ namespace grapher.Models.Calculations public void ScaleByMouseSettings() { - var dpiPollFactor = DPI.Data / PollRate.Data; - CombinedMaxVelocity = dpiPollFactor * Constants.MaxMultiplier; - var ratio = CombinedMaxVelocity / Constants.Resolution; + MaxVelocity = DPI.Data * Constants.MaxMultiplier; + var ratio = MaxVelocity / Constants.Resolution; Increment = ratio > 1 ? (int) Math.Floor(ratio) : 1; MeasurementTime = Increment == 1 ? 1 / ratio : 1; - XYMaxVelocity = CombinedMaxVelocity * Constants.XYToCombinedRatio; SimulatedInputCombined = GetSimulatedInput(); SimulatedInputX = GetSimulatInputX(); SimulatedInputY = GetSimulatedInputY(); diff --git a/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs b/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs index ad54989..8bd889d 100644 --- a/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs +++ b/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs @@ -70,7 +70,7 @@ namespace grapher.Models.Calculations.Data public void CreateGraphData(ManagedAccel accel, DriverSettings settings) { Clear(); - Calculator.CalculateCombinedDiffSens(AngleToData, accel, settings, Calculator.SimulatedDirectionalInput); + Calculator.CalculateDirectional(AngleToData, accel, settings, Calculator.SimulatedDirectionalInput); } private void FillAngleData() 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() -- cgit v1.2.3 From 3bab172f863390a3930ada35173b5c943db9489a Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 20 Jan 2021 00:32:51 -0800 Subject: Remove debug statement --- grapher/Models/Calculations/AccelCalculator.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'grapher') diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 733a3c0..3787291 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -227,11 +227,6 @@ namespace grapher.Models.Calculations continue; } - if (inDiff < 0 || outDiff < 0) - { - Console.WriteLine(string.Empty); - } - if (!data.VelocityPoints.ContainsKey(simulatedInputDatum.velocity)) { data.VelocityPoints.Add(simulatedInputDatum.velocity, magnitude); -- cgit v1.2.3 From 6046120f67327411eafa9c6a9fa0601c2ea5c554 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 20 Jan 2021 18:25:31 -0800 Subject: Tweaks --- grapher/Constants/Constants.cs | 2 +- grapher/Form1.Designer.cs | 9 ------ grapher/Models/AccelGUIFactory.cs | 1 - grapher/Models/Calculations/AccelCalculator.cs | 38 +++++++++++++++----------- 4 files changed, 23 insertions(+), 27 deletions(-) (limited to 'grapher') diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index e31f62c..f05be34 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -14,7 +14,7 @@ namespace grapher public const int DefaultPollRate = 1000; /// Resolution of chart calulation. - public const int Resolution = 100; + public const int Resolution = 500; /// Multiplied by DPI over poll rate to find rough max expected velocity. public const double MaxMultiplier = .05; diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 13aefb7..20af913 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -1237,15 +1237,6 @@ namespace grapher this.AutoWriteMenuItem.Size = new System.Drawing.Size(210, 22); this.AutoWriteMenuItem.Text = "Apply Settings On Startup"; // - // AutoWriteMenuItem - // - this.AutoWriteMenuItem.Checked = true; - this.AutoWriteMenuItem.CheckOnClick = true; - this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.AutoWriteMenuItem.Name = "AutoWriteMenuItem"; - this.AutoWriteMenuItem.Size = new System.Drawing.Size(210, 22); - this.AutoWriteMenuItem.Text = "Apply Settings On Startup"; - // // UseSpecificDeviceMenuItem // this.UseSpecificDeviceMenuItem.Name = "UseSpecificDeviceMenuItem"; diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index 9ca1578..6a4c46f 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -406,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 3787291..42b7347 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -58,7 +58,7 @@ namespace grapher.Models.Calculations private double MaxVelocity { get; set; } - private int Increment { get; set; } + private double Increment { get; set; } private double MeasurementTime { get; set; } @@ -324,14 +324,16 @@ namespace grapher.Models.Calculations } - for (int i = 5; i < MaxVelocity; i+=Increment) + for (double i = 5; i < MaxVelocity; i+=Increment) { SimulatedMouseInput mouseInputData; - mouseInputData.x = i; - mouseInputData.y = i; - mouseInputData.time = MeasurementTime; - mouseInputData.velocity = Velocity(i, i, mouseInputData.time); - mouseInputData.angle = Math.Atan2(i,i); + 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); } @@ -357,13 +359,15 @@ namespace grapher.Models.Calculations magnitudes.Add(mouseInputData); } - for (int i = 5; i < MaxVelocity; i+=Increment) + for (double i = 5; i < MaxVelocity; i+=Increment) { SimulatedMouseInput mouseInputData; - mouseInputData.x = i; + var ceil = (int)Math.Ceiling(i); + var timeFactor = ceil / 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); } @@ -388,11 +392,13 @@ namespace grapher.Models.Calculations magnitudes.Add(mouseInputData); } - for (int i = 5; i < MaxVelocity; i+=Increment) + 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; @@ -428,7 +434,7 @@ namespace grapher.Models.Calculations magnitudes.Add(mouseInputData); } - for (int magnitude = 5; magnitude < MaxVelocity; magnitude+=Increment) + 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); @@ -501,8 +507,8 @@ namespace grapher.Models.Calculations { MaxVelocity = DPI.Data * Constants.MaxMultiplier; var ratio = MaxVelocity / Constants.Resolution; - Increment = ratio > 1 ? (int) Math.Floor(ratio) : 1; - MeasurementTime = Increment == 1 ? 1 / ratio : 1; + Increment = ratio; + MeasurementTime = 1; SimulatedInputCombined = GetSimulatedInput(); SimulatedInputX = GetSimulatInputX(); SimulatedInputY = GetSimulatedInputY(); -- cgit v1.2.3 From e785ba5b4b4f2a991fef3c5b548b09208bee0293 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 20 Jan 2021 18:46:47 -0800 Subject: Final GUI tweaks --- grapher/Constants/Constants.cs | 4 ++-- grapher/Models/AccelGUI.cs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'grapher') diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index f05be34..d58c5cf 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -121,10 +121,10 @@ namespace grapher public const string DefaultSettingsFileName = @"settings.json"; /// Text to direcitonality panel title when panel is closed. - public const string DirectionalityTitleClosed = "Anisotropy\u25BC"; + public const string DirectionalityTitleClosed = "Anisotropy \u25BC"; /// Text to direcitonality panel title when panel is open. - public const string DirectionalityTitleOpen = "Anisotropy\u25B2"; + public const string DirectionalityTitleOpen = "Anisotropy \u25B2"; /// Style used by System.Double.Parse public const NumberStyles FloatStyle = NumberStyles.Float | NumberStyles.AllowThousands; diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 5f05798..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 -- cgit v1.2.3