diff options
| author | Jacob Palecki <[email protected]> | 2021-01-10 23:49:28 -0800 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2021-01-10 23:49:28 -0800 |
| commit | de6b18db8226650cee9726c4694931bdc4b89fad (patch) | |
| tree | c5bffd4d1eaad53842394c92d4907acb65c6ff84 /grapher/Models | |
| parent | Add to stigma, directional to settings (diff) | |
| download | rawaccel-de6b18db8226650cee9726c4694931bdc4b89fad.tar.xz rawaccel-de6b18db8226650cee9726c4694931bdc4b89fad.zip | |
Implement direcitonality UI
Diffstat (limited to 'grapher/Models')
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 4 | ||||
| -rw-r--r-- | grapher/Models/AccelGUIFactory.cs | 73 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartState/ChartStateManager.cs | 4 | ||||
| -rw-r--r-- | grapher/Models/Options/ApplyOptions.cs | 49 | ||||
| -rw-r--r-- | grapher/Models/Options/Directionality/DirectionalityOptions.cs | 172 | ||||
| -rw-r--r-- | grapher/Models/Options/Option.cs | 10 | ||||
| -rw-r--r-- | grapher/Models/Options/OptionXY.cs | 12 |
7 files changed, 296 insertions, 28 deletions
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<double> + { + x = Domain.Fields.X, + y = Domain.Fields.Y, + }, + lpNorm = LpNorm.Field.Data, + }; + } + else + { + return new DomainArgs + { + domainXY = new Vec2<double> + { + x = 1, + y = 1, + }, + lpNorm = 2, + }; + + } + } + + public Vec2<double> GetRangeXY() + { + if (!ByComponentCheckBox.Checked) + { + return new Vec2<double> + { + x = Range.Fields.X, + y = Range.Fields.Y, + }; + } + else + { + return new Vec2<double> + { + 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 } } |