diff options
| -rw-r--r-- | common/math-vec2.hpp | 10 | ||||
| -rw-r--r-- | grapher/Constants/Constants.cs | 4 | ||||
| -rw-r--r-- | grapher/Form1.Designer.cs | 24 | ||||
| -rw-r--r-- | grapher/Form1.cs | 1 | ||||
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 2 | ||||
| -rw-r--r-- | grapher/Models/AccelGUIFactory.cs | 27 | ||||
| -rw-r--r-- | grapher/Models/Options/ApplyOptions.cs | 13 | ||||
| -rw-r--r-- | grapher/Models/Options/LockableOption.cs | 48 |
8 files changed, 96 insertions, 33 deletions
diff --git a/common/math-vec2.hpp b/common/math-vec2.hpp index ac6fd9b..a7656ed 100644 --- a/common/math-vec2.hpp +++ b/common/math-vec2.hpp @@ -30,6 +30,11 @@ inline double magnitude(const vec2d& v) return sqrt(v.x * v.x + v.y * v.y); } +inline double lp_infinite_distance(const vec2d& v) +{ + return abs(v.x) > abs(v.y) ? abs(v.x) : abs(v.y); +} + inline double lp_distance(const vec2d& v, double p) { if (p > 64) { @@ -38,8 +43,3 @@ inline double lp_distance(const vec2d& v, double p) return pow(pow(v.x, p) + pow(v.y, p), 1 / p); } - -inline double lp_infinite_distance(const vec2d& v) -{ - return abs(v.x) > abs(v.y) ? abs(v.x) : abs(v.y); -} diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index 383d7f4..179c45e 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -44,7 +44,7 @@ namespace grapher public const int DropDownLeftSeparation = 10; /// <summary> Height of sensitivity chart when displayed alone. </summary> - public const int SensitivityChartAloneHeight = 480; + public const int SensitivityChartAloneHeight = 510; /// <summary> Height of sensitivity chart when displayed alongside Velocity and Gain charts. </summary> public const int SensitivityChartTogetherHeight = 328; @@ -65,7 +65,7 @@ namespace grapher public const int ButtonVerticalOffset = 60; /// <summary> Vertical placement of directionality panel below top of containing form </summary> - public const int DirectionalityVerticalOffset = 285; + public const int DirectionalityVerticalOffset = 315; /// <summary> Padding between directionality title and containing panel </summary> public const int DirectionalityTitlePad = 8; diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 376809f..0356683 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -71,6 +71,7 @@ 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.VertHorzRatioLabel = new System.Windows.Forms.Label(); this.SmoothActiveYLabel = new System.Windows.Forms.Label(); this.smoothLabelY = new System.Windows.Forms.Label(); this.SmoothActiveXLabel = new System.Windows.Forms.Label(); @@ -223,7 +224,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.VertHorzRatioLabel = new System.Windows.Forms.Label(); this.optionsPanel.SuspendLayout(); this.DirectionalityPanel.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -360,6 +360,15 @@ namespace grapher this.optionsPanel.Size = new System.Drawing.Size(483, 956); this.optionsPanel.TabIndex = 34; // + // VertHorzRatioLabel + // + this.VertHorzRatioLabel.AutoSize = true; + this.VertHorzRatioLabel.Location = new System.Drawing.Point(28, 79); + this.VertHorzRatioLabel.Name = "VertHorzRatioLabel"; + this.VertHorzRatioLabel.Size = new System.Drawing.Size(59, 13); + this.VertHorzRatioLabel.TabIndex = 194; + this.VertHorzRatioLabel.Text = "Y to X ratio"; + // // SmoothActiveYLabel // this.SmoothActiveYLabel.AutoSize = true; @@ -1157,7 +1166,7 @@ namespace grapher // accelTypeDropY // this.accelTypeDropY.FormattingEnabled = true; - this.accelTypeDropY.Location = new System.Drawing.Point(332, 140); + this.accelTypeDropY.Location = new System.Drawing.Point(332, 138); this.accelTypeDropY.Name = "accelTypeDropY"; this.accelTypeDropY.Size = new System.Drawing.Size(76, 21); this.accelTypeDropY.TabIndex = 99; @@ -1505,7 +1514,7 @@ namespace grapher // accelTypeDropX // this.accelTypeDropX.FormattingEnabled = true; - this.accelTypeDropX.Location = new System.Drawing.Point(106, 140); + this.accelTypeDropX.Location = new System.Drawing.Point(106, 138); this.accelTypeDropX.Name = "accelTypeDropX"; this.accelTypeDropX.Size = new System.Drawing.Size(76, 21); this.accelTypeDropX.TabIndex = 84; @@ -1878,15 +1887,6 @@ namespace grapher title6.Text = "Sensitivity"; this.AccelerationChart.Titles.Add(title6); // - // VertHorzRatioLabel - // - this.VertHorzRatioLabel.AutoSize = true; - this.VertHorzRatioLabel.Location = new System.Drawing.Point(28, 79); - this.VertHorzRatioLabel.Name = "VertHorzRatioLabel"; - this.VertHorzRatioLabel.Size = new System.Drawing.Size(59, 13); - this.VertHorzRatioLabel.TabIndex = 194; - this.VertHorzRatioLabel.Text = "Y to X ratio"; - // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 91bc980..5f2c90e 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -106,6 +106,7 @@ namespace grapher YLutPointsBox, LockXYLabel, sensitivityLabel, + VertHorzRatioLabel, rotationLabel, weightLabelX, weightLabelY, diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 801fd8d..e15aba9 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -116,7 +116,7 @@ namespace grapher settings.sensitivity = ApplyOptions.Sensitivity.Field.Data; // TODO - separate sensitivity fields, add new label for ratio - settings.yxSensRatio = ApplyOptions.Sensitivity.Fields.Y; + settings.yxSensRatio = ApplyOptions.YToXRatio.Value; settings.combineMagnitudes = ApplyOptions.IsWhole; ApplyOptions.SetArgsFromActiveValues(ref settings.argsX, ref settings.argsY); diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index cc43aeb..20040fb 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -83,6 +83,7 @@ namespace grapher.Models RichTextBox yLutPointsBox, Label lockXYLabel, Label sensitivityLabel, + Label yxRatioLabel, Label rotationLabel, Label weightLabelX, Label weightLabelY, @@ -112,8 +113,8 @@ namespace grapher.Models Label constantThreeLabelY, Label activeValueTitleX, Label activeValueTitleY, - Label sensitivityActiveXLabel, - Label sensitivityActiveYLabel, + Label sensitivityActiveLabel, + Label yxRatioActiveLabel, Label rotationActiveLabel, Label weightActiveXLabel, Label weightActiveYLabel, @@ -181,18 +182,27 @@ namespace grapher.Models writeButton, accelCalculator); - var sensitivity = new OptionXY( + var sensitivity = new Option( sensitivityBoxX, - sensitivityBoxY, - sensXYLock, form, 1, sensitivityLabel, - new ActiveValueLabelXY( - new ActiveValueLabel(sensitivityActiveXLabel, activeValueTitleX), - new ActiveValueLabel(sensitivityActiveYLabel, activeValueTitleX)), + 0, + new ActiveValueLabel(sensitivityActiveLabel, activeValueTitleX), "Sens Multiplier"); + var yxRatio = new LockableOption( + new Option( + sensitivityBoxY, + form, + 1, + yxRatioLabel, + 0, + new ActiveValueLabel(yxRatioActiveLabel, activeValueTitleX), + "Y/X Ratio"), + sensXYLock, + 1); + var rotation = new Option( rotationBox, form, @@ -487,6 +497,7 @@ namespace grapher.Models optionsSetY, directionalOptions, sensitivity, + yxRatio, rotation, lockXYLabel, accelCharts); diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs index 5c3494c..4946414 100644 --- a/grapher/Models/Options/ApplyOptions.cs +++ b/grapher/Models/Options/ApplyOptions.cs @@ -15,7 +15,8 @@ namespace grapher.Models.Options AccelOptionSet optionSetX, AccelOptionSet optionSetY, DirectionalityOptions directionalityOptions, - OptionXY sensitivity, + Option sensitivity, + LockableOption yxRatio, Option rotation, Label lockXYLabel, AccelCharts accelCharts) @@ -34,6 +35,7 @@ namespace grapher.Models.Options OptionSetX = optionSetX; OptionSetY = optionSetY; Sensitivity = sensitivity; + YToXRatio = yxRatio; Rotation = rotation; LockXYLabel = lockXYLabel; AccelCharts = accelCharts; @@ -44,7 +46,8 @@ namespace grapher.Models.Options ByComponentVectorXYLock.CheckedChanged += new System.EventHandler(OnByComponentXYLockChecked); ByComponentVectorXYLock.Checked = true; - Rotation.SnapTo(Sensitivity); + YToXRatio.SnapTo(Sensitivity); + Rotation.SnapTo(YToXRatio); EnableWholeApplication(); } @@ -67,7 +70,7 @@ namespace grapher.Models.Options public Option Sensitivity { get; } - public Option YToXRatio { get; } + public LockableOption YToXRatio { get; } public Option Rotation { get; } @@ -213,8 +216,8 @@ namespace grapher.Models.Options LockXYLabel.Width = (AccelCharts.Left - OptionSetX.ActiveValuesTitle.Left) / 2; OptionSetX.ActiveValuesTitle.Width = LockXYLabel.Width; LockXYLabel.Left = OptionSetX.ActiveValuesTitle.Left + OptionSetX.ActiveValuesTitle.Width; - Sensitivity.Fields.LockCheckBox.Left = LockXYLabel.Left + LockXYLabel.Width / 2 - Sensitivity.Fields.LockCheckBox.Width / 2; - ByComponentVectorXYLock.Left = Sensitivity.Fields.LockCheckBox.Left; + YToXRatio.LockBox.Left = LockXYLabel.Left + LockXYLabel.Width / 2 - YToXRatio.LockBox.Width / 2; + ByComponentVectorXYLock.Left = YToXRatio.LockBox.Left; AlignActiveValues(); } diff --git a/grapher/Models/Options/LockableOption.cs b/grapher/Models/Options/LockableOption.cs index bf77520..6e78783 100644 --- a/grapher/Models/Options/LockableOption.cs +++ b/grapher/Models/Options/LockableOption.cs @@ -20,6 +20,12 @@ namespace grapher.Models.Options Option = option; LockBox = checkBox; LockedValue = lockedvalue; + + LockBox.Click += OnLockedBoxClicked; + LockBox.AutoCheck = false; + + Option.Field.SetNewDefault(LockedValue); + SetLocked(); } public Option Option { get; } @@ -69,6 +75,25 @@ namespace grapher.Models.Options get => Option.Visible; } + public double Value + { + get => LockBox.Checked ? LockedValue : Option.Field.Data; + } + + public void SetActiveValue(double activeValue) + { + Option.SetActiveValue(activeValue); + + if (activeValue == LockedValue) + { + SetLocked(); + } + else + { + SetUnlocked(); + } + } + public override void AlignActiveValues() { Option.AlignActiveValues(); @@ -85,5 +110,28 @@ namespace grapher.Models.Options Option.Show(Name); LockBox.Show(); } + private void SetLocked() + { + LockBox.Checked = true; + Option.Field.SetToUnavailable(); + } + + private void SetUnlocked() + { + LockBox.Checked = false; + Option.Field.SetToDefault(); + } + + private void OnLockedBoxClicked(object sender, EventArgs e) + { + if (LockBox.Checked) + { + SetUnlocked(); + } + else + { + SetLocked(); + } + } } } |