summaryrefslogtreecommitdiff
path: root/grapher/Models/Options
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2021-01-10 23:49:28 -0800
committerJacob Palecki <[email protected]>2021-01-10 23:49:28 -0800
commitde6b18db8226650cee9726c4694931bdc4b89fad (patch)
treec5bffd4d1eaad53842394c92d4907acb65c6ff84 /grapher/Models/Options
parentAdd to stigma, directional to settings (diff)
downloadrawaccel-de6b18db8226650cee9726c4694931bdc4b89fad.tar.xz
rawaccel-de6b18db8226650cee9726c4694931bdc4b89fad.zip
Implement direcitonality UI
Diffstat (limited to 'grapher/Models/Options')
-rw-r--r--grapher/Models/Options/ApplyOptions.cs49
-rw-r--r--grapher/Models/Options/Directionality/DirectionalityOptions.cs172
-rw-r--r--grapher/Models/Options/Option.cs10
-rw-r--r--grapher/Models/Options/OptionXY.cs12
4 files changed, 222 insertions, 21 deletions
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
}
}