diff options
Diffstat (limited to 'grapher/Models/Options/LUT')
| -rw-r--r-- | grapher/Models/Options/LUT/LUTPanelOptions.cs | 27 | ||||
| -rw-r--r-- | grapher/Models/Options/LUT/LutApplyOptions.cs | 138 |
2 files changed, 50 insertions, 115 deletions
diff --git a/grapher/Models/Options/LUT/LUTPanelOptions.cs b/grapher/Models/Options/LUT/LUTPanelOptions.cs index 3690c76..eedcfa8 100644 --- a/grapher/Models/Options/LUT/LUTPanelOptions.cs +++ b/grapher/Models/Options/LUT/LUTPanelOptions.cs @@ -111,15 +111,26 @@ namespace grapher.Models.Options.LUT // Nothing to do here. } - public void SetActiveValues(IEnumerable<Vec2<float>> activePoints, int length) + public void SetActiveValues(IEnumerable<float> rawData, int length, AccelMode mode) { - if (length > 0 && activePoints.First().x != 0) + if (mode == AccelMode.lut && length > 1 && rawData.First() != 0) { - ActiveValuesTextBox.Text = PointsToActiveValuesText(activePoints, length); + var pointsLen = length / 2; + var points = new Vec2<float>[pointsLen]; + for (int i = 0; i < pointsLen; i++) + { + var data_idx = i * 2; + points[i] = new Vec2<float> + { + x = rawData.ElementAt(data_idx), + y = rawData.ElementAt(data_idx + 1) + }; + } + ActiveValuesTextBox.Text = PointsToActiveValuesText(points, pointsLen); if (string.IsNullOrWhiteSpace(PointsTextBox.Text)) { - PointsTextBox.Text = PointsToEntryTextBoxText(activePoints, length); + PointsTextBox.Text = PointsToEntryTextBoxText(points, pointsLen); } } else @@ -135,14 +146,12 @@ namespace grapher.Models.Options.LUT private static (Vec2<float>[], int length) UserTextToPoints(string userText) { - const int MaxPoints = 256; - if (string.IsNullOrWhiteSpace(userText)) { throw new ApplicationException("Text must be entered in text box to fill Look Up Table."); } - Vec2<float>[] points = new Vec2<float>[MaxPoints]; + Vec2<float>[] points = new Vec2<float>[AccelArgs.MaxLutPoints]; var userTextSplit = userText.Trim().Trim(';').Split(';'); int index = 0; @@ -155,9 +164,9 @@ namespace grapher.Models.Options.LUT throw new ApplicationException("At least 2 points required"); } - if (pointsCount > MaxPoints) + if (pointsCount > AccelArgs.MaxLutPoints) { - throw new ApplicationException($"Number of points exceeds max ({MaxPoints})"); + throw new ApplicationException($"Number of points exceeds max ({AccelArgs.MaxLutPoints})"); } foreach(var pointEntry in userTextSplit) diff --git a/grapher/Models/Options/LUT/LutApplyOptions.cs b/grapher/Models/Options/LUT/LutApplyOptions.cs index 7d8c737..61cae61 100644 --- a/grapher/Models/Options/LUT/LutApplyOptions.cs +++ b/grapher/Models/Options/LUT/LutApplyOptions.cs @@ -7,10 +7,9 @@ using System.Windows.Forms; namespace grapher.Models.Options.LUT { - public class LutApplyOptions : OptionBase + public class LutApplyOptions : ComboBoxOptionsBase { - public const string LUTApplyOptionsLabelText = "Apply as:"; - public const int LUTApplyLabelDropdownSeparation = 4; + #region Enum public enum LutApplyType { @@ -18,6 +17,10 @@ namespace grapher.Models.Options.LUT Velocity } + #endregion Enum + + #region Classes + public class LutApplyOption { public LutApplyType Type { get; set; } @@ -27,6 +30,10 @@ namespace grapher.Models.Options.LUT public override string ToString() => Name; } + #endregion Classes + + #region Static + public static readonly LutApplyOption Sensitivity = new LutApplyOption { Type = LutApplyType.Sensitivity, @@ -37,129 +44,58 @@ namespace grapher.Models.Options.LUT Type = LutApplyType.Velocity, }; + #endregion Static + + #region Constructors + public LutApplyOptions( Label label, ComboBox applyOptionsDropdown, ActiveValueLabel lutApplyActiveValue) + : base( + label, + applyOptionsDropdown, + lutApplyActiveValue) { - ApplyOptions = applyOptionsDropdown; - ApplyOptions.Items.Clear(); - ApplyOptions.Items.AddRange( + OptionsDropdown.Items.AddRange( new LutApplyOption[] { Sensitivity, Velocity, }); + } - Label = label; - Label.Text = LUTApplyOptionsLabelText; - Label.AutoSize = false; - Label.Width = 50; + #endregion Constructors - ActiveValueLabel = lutApplyActiveValue; - } + #region Properties public LutApplyType ApplyType { get => ApplyOption.Type; } public LutApplyOption ApplyOption { get { - return ApplyOptions.SelectedItem as LutApplyOption; - } - set - { - ApplyOptions.SelectedItem = value; - } - } - - public Label Label { get; } - - public ActiveValueLabel ActiveValueLabel { get; } - - public ComboBox ApplyOptions { get; } - - public override bool Visible - { - get - { - return Label.Visible || ShouldShow; - } - } - - public override int Left - { - get - { - return Label.Left; + return OptionsDropdown.SelectedItem as LutApplyOption; } set { - Label.Left = value; - ApplyOptions.Left = Label.Left + Label.Width + LUTApplyLabelDropdownSeparation; + OptionsDropdown.SelectedItem = value; } } - public override int Height - { - get - { - return Label.Height; - } - } + #endregion Properties - public override int Top - { - get - { - return Label.Top; - } - set - { - ApplyOptions.Top = value; - Label.Top = (ApplyOptions.Height - Label.Height) / 2 + ApplyOptions.Top; - ActiveValueLabel.Top = value; - } - } + #region Methods - public override int Width + public static LutApplyOption ApplyOptionFromSettings(bool applyAsVelocity) { - get - { - return Label.Width; - } - set + if (applyAsVelocity) { - ApplyOptions.Width = value - Label.Width - Constants.OptionLabelBoxSeperation; + return Velocity; } - } - - private bool ShouldShow { get; set; } - - public override void Hide() - { - Label.Hide(); - ApplyOptions.Hide(); - ActiveValueLabel.Hide(); - ShouldShow = false; - } - - public override void Show(string labelText) - { - Label.Show(); - - if (!string.IsNullOrWhiteSpace(labelText)) + else { - Label.Text = labelText; + return Sensitivity; } - - ApplyOptions.Show(); - ActiveValueLabel.Show(); - ShouldShow = true; - } - - public override void AlignActiveValues() - { - ActiveValueLabel.Align(); } public void SetActiveValue(bool applyAsVelocity) @@ -168,16 +104,6 @@ namespace grapher.Models.Options.LUT ActiveValueLabel.SetValue(ApplyOption.Name); } - public LutApplyOption ApplyOptionFromSettings(bool applyAsVelocity) - { - if (applyAsVelocity) - { - return Velocity; - } - else - { - return Sensitivity; - } - } + #endregion Methods } } |