diff options
| author | Jacob Palecki <[email protected]> | 2021-09-16 18:33:30 -0700 |
|---|---|---|
| committer | a1xd <[email protected]> | 2021-09-23 22:35:45 -0400 |
| commit | 1fd8881608e4ce6ab21fd78d3ebb42a941cd0e93 (patch) | |
| tree | 27ee298593168cf2d330abf4a7a3ee9fbe8f3d68 | |
| parent | Fix error in LUT gui (diff) | |
| download | rawaccel-1fd8881608e4ce6ab21fd78d3ebb42a941cd0e93.tar.xz rawaccel-1fd8881608e4ce6ab21fd78d3ebb42a941cd0e93.zip | |
Add power start from one
| -rw-r--r-- | common/accel-power.hpp | 77 | ||||
| -rw-r--r-- | common/rawaccel-base.hpp | 1 | ||||
| -rw-r--r-- | grapher/Form1.Designer.cs | 94 | ||||
| -rw-r--r-- | grapher/Form1.cs | 8 | ||||
| -rw-r--r-- | grapher/Layouts/ClassicLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Layouts/DefaultLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Layouts/JumpLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Layouts/LUTLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Layouts/LayoutBase.cs | 8 | ||||
| -rw-r--r-- | grapher/Layouts/LinearLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Layouts/MotivityLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Layouts/NaturalLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Layouts/OffLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Layouts/PowerLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Layouts/UnsupportedLayout.cs | 1 | ||||
| -rw-r--r-- | grapher/Models/AccelGUIFactory.cs | 24 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 9 | ||||
| -rw-r--r-- | grapher/Models/Options/SwitchOption.cs | 162 | ||||
| -rw-r--r-- | grapher/grapher.csproj | 1 | ||||
| -rw-r--r-- | wrapper/wrapper.cpp | 1 |
20 files changed, 381 insertions, 14 deletions
diff --git a/common/accel-power.hpp b/common/accel-power.hpp index 3baeda0..014acae 100644 --- a/common/accel-power.hpp +++ b/common/accel-power.hpp @@ -23,7 +23,7 @@ namespace rawaccel { power(const accel_args& args) { - // Note that cap types may overwrite this below. + // Note that cap types may overwrite scale below. scale = args.scale; switch (args.cap_mode){ @@ -65,7 +65,12 @@ namespace rawaccel { double operator()(double speed, const accel_args& args) const { - return minsd(base_fn(speed, scale, args), cap); + if (args.powerStartFromOne) { + return minsd(maxsd(base_fn(speed, scale, args), 1), cap); + } + else { + return minsd(base_fn(speed, scale, args), cap); + } } double static scale_from_sens_point(double sens, double input, double power) @@ -79,6 +84,7 @@ namespace rawaccel { vec2d cap = { DBL_MAX, DBL_MAX }; double constant = 0; double scale = 0; + vec2d startFromOne{ 0, 0 }; power(const accel_args& args) { @@ -102,12 +108,8 @@ namespace rawaccel { args.cap.x, args.exponent_power, scale); - - constant = integration_constant( - cap.x, - cap.y, - base_fn(cap.x, scale, args)); } + break; case classic_cap_mode::io: if (args.cap.x > 0 && args.cap.y > 1) { @@ -117,12 +119,8 @@ namespace rawaccel { args.cap.x, args.cap.y, args.exponent_power); - - constant = integration_constant( - cap.x, - cap.y, - base_fn(cap.x, scale, args)); } + break; case classic_cap_mode::out: default: if (args.cap.y > 1) { @@ -131,26 +129,77 @@ namespace rawaccel { args.cap.y, args.exponent_power, scale); + } + break; + } + + if (args.powerStartFromOne) + { + startFromOne.x = gain_inverse( + 1, + args.exponent_power, + scale); + startFromOne.y = -1 * integration_constant(startFromOne.x, + 1, + base_fn(startFromOne.x, scale, args)); + } + if (cap.x < DBL_MAX && cap.y < DBL_MAX) + { + if (args.powerStartFromOne) { + constant = integration_constant( + cap.x, + cap.y, + startFromOneOutput( + startFromOne, + cap.x, + scale, + args)); + } + else { constant = integration_constant( cap.x, cap.y, base_fn(cap.x, scale, args)); } - break; } + } double operator()(double speed, const accel_args& args) const { if (speed < cap.x) { - return base_fn(speed, scale, args); + if (args.powerStartFromOne) { + return startFromOneOutput( + startFromOne, + speed, + scale, + args); + } + else { + return base_fn(speed, scale, args); + } } else { return cap.y + constant / speed; } } + double static startFromOneOutput( + const vec2d& startFromOne, + double speed, + double scale, + const accel_args& args) + { + if (speed > startFromOne.x) { + return base_fn(speed, scale, args) + startFromOne.y / speed; + } + else + { + return 1; + } + } + double static gain_inverse(double gain, double power, double scale) { return pow(gain / (power + 1), 1 / power) / scale; diff --git a/common/rawaccel-base.hpp b/common/rawaccel-base.hpp index d8a089c..08d42c6 100644 --- a/common/rawaccel-base.hpp +++ b/common/rawaccel-base.hpp @@ -53,6 +53,7 @@ namespace rawaccel { double limit = 1.5; double midpoint = 5; double smooth = 0.5; + bool powerStartFromOne = true; vec2d cap = { 15, 1.5 }; classic_cap_mode cap_mode = classic_cap_mode::out; diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index a0b102e..6905de1 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -71,6 +71,12 @@ 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.powerStartsFromOneBoxY = new System.Windows.Forms.CheckBox(); + this.powerStartsFromZeroBoxY = new System.Windows.Forms.CheckBox(); + this.powerStartsFromOneBoxX = new System.Windows.Forms.CheckBox(); + this.powerStartsFromZeroBoxX = new System.Windows.Forms.CheckBox(); + this.powerStartFromLabelY = new System.Windows.Forms.Label(); + this.powerStartFromLabelX = new System.Windows.Forms.Label(); this.OutCapActiveYLabelPower = new System.Windows.Forms.Label(); this.InCapActiveYLabelPower = new System.Windows.Forms.Label(); this.OutCapActiveXLabelPower = new System.Windows.Forms.Label(); @@ -248,6 +254,8 @@ 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.powerStartFromActiveLabelX = new System.Windows.Forms.Label(); + this.powerStartFromActiveLabelY = new System.Windows.Forms.Label(); this.optionsPanel.SuspendLayout(); this.DirectionalityPanel.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -263,6 +271,14 @@ namespace grapher // optionsPanel // this.optionsPanel.AutoSize = true; + this.optionsPanel.Controls.Add(this.powerStartFromActiveLabelY); + this.optionsPanel.Controls.Add(this.powerStartFromActiveLabelX); + this.optionsPanel.Controls.Add(this.powerStartsFromOneBoxY); + this.optionsPanel.Controls.Add(this.powerStartsFromZeroBoxY); + this.optionsPanel.Controls.Add(this.powerStartsFromOneBoxX); + this.optionsPanel.Controls.Add(this.powerStartsFromZeroBoxX); + this.optionsPanel.Controls.Add(this.powerStartFromLabelY); + this.optionsPanel.Controls.Add(this.powerStartFromLabelX); this.optionsPanel.Controls.Add(this.OutCapActiveYLabelPower); this.optionsPanel.Controls.Add(this.InCapActiveYLabelPower); this.optionsPanel.Controls.Add(this.OutCapActiveXLabelPower); @@ -408,6 +424,58 @@ namespace grapher this.optionsPanel.Size = new System.Drawing.Size(483, 956); this.optionsPanel.TabIndex = 34; // + // powerStartsFromOneBoxY + // + this.powerStartsFromOneBoxY.Location = new System.Drawing.Point(363, 220); + this.powerStartsFromOneBoxY.Name = "powerStartsFromOneBoxY"; + this.powerStartsFromOneBoxY.Size = new System.Drawing.Size(32, 17); + this.powerStartsFromOneBoxY.TabIndex = 0; + this.powerStartsFromOneBoxY.Text = "1"; + this.powerStartsFromOneBoxY.UseVisualStyleBackColor = true; + // + // powerStartsFromZeroBoxY + // + this.powerStartsFromZeroBoxY.Location = new System.Drawing.Point(332, 220); + this.powerStartsFromZeroBoxY.Name = "powerStartsFromZeroBoxY"; + this.powerStartsFromZeroBoxY.Size = new System.Drawing.Size(32, 17); + this.powerStartsFromZeroBoxY.TabIndex = 0; + this.powerStartsFromZeroBoxY.Text = "0"; + this.powerStartsFromZeroBoxY.UseVisualStyleBackColor = true; + // + // powerStartsFromOneBoxX + // + this.powerStartsFromOneBoxX.Location = new System.Drawing.Point(136, 220); + this.powerStartsFromOneBoxX.Name = "powerStartsFromOneBoxX"; + this.powerStartsFromOneBoxX.Size = new System.Drawing.Size(32, 17); + this.powerStartsFromOneBoxX.TabIndex = 0; + this.powerStartsFromOneBoxX.Text = "1"; + this.powerStartsFromOneBoxX.UseVisualStyleBackColor = true; + // + // powerStartsFromZeroBoxX + // + this.powerStartsFromZeroBoxX.Location = new System.Drawing.Point(106, 220); + this.powerStartsFromZeroBoxX.Name = "powerStartsFromZeroBoxX"; + this.powerStartsFromZeroBoxX.Size = new System.Drawing.Size(32, 17); + this.powerStartsFromZeroBoxX.TabIndex = 0; + this.powerStartsFromZeroBoxX.Text = "0"; + this.powerStartsFromZeroBoxX.UseVisualStyleBackColor = true; + // + // powerStartFromLabelY + // + this.powerStartFromLabelY.Location = new System.Drawing.Point(266, 220); + this.powerStartFromLabelY.Name = "powerStartFromLabelY"; + this.powerStartFromLabelY.Size = new System.Drawing.Size(52, 13); + this.powerStartFromLabelY.TabIndex = 0; + this.powerStartFromLabelY.Text = "Start from"; + // + // powerStartFromLabelX + // + this.powerStartFromLabelX.Location = new System.Drawing.Point(38, 220); + this.powerStartFromLabelX.Name = "powerStartFromLabelX"; + this.powerStartFromLabelX.Size = new System.Drawing.Size(55, 13); + this.powerStartFromLabelX.TabIndex = 0; + this.powerStartFromLabelX.Text = "Start from"; + // // OutCapActiveYLabelPower // this.OutCapActiveYLabelPower.AutoSize = true; @@ -2138,6 +2206,24 @@ namespace grapher title6.Text = "Sensitivity"; this.AccelerationChart.Titles.Add(title6); // + // powerStartFromActiveLabelX + // + this.powerStartFromActiveLabelX.AutoSize = true; + this.powerStartFromActiveLabelX.Location = new System.Drawing.Point(197, 220); + this.powerStartFromActiveLabelX.Name = "powerStartFromActiveLabelX"; + this.powerStartFromActiveLabelX.Size = new System.Drawing.Size(13, 13); + this.powerStartFromActiveLabelX.TabIndex = 225; + this.powerStartFromActiveLabelX.Text = "0"; + // + // powerStartFromActiveLabelY + // + this.powerStartFromActiveLabelY.AutoSize = true; + this.powerStartFromActiveLabelY.Location = new System.Drawing.Point(414, 221); + this.powerStartFromActiveLabelY.Name = "powerStartFromActiveLabelY"; + this.powerStartFromActiveLabelY.Size = new System.Drawing.Size(13, 13); + this.powerStartFromActiveLabelY.TabIndex = 226; + this.powerStartFromActiveLabelY.Text = "0"; + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -2345,6 +2431,14 @@ namespace grapher private System.Windows.Forms.TextBox outCapBoxXPower; private System.Windows.Forms.TextBox inCapBoxYPower; private System.Windows.Forms.TextBox inCapBoxXPower; + private System.Windows.Forms.CheckBox powerStartsFromOneBoxY; + private System.Windows.Forms.CheckBox powerStartsFromZeroBoxY; + private System.Windows.Forms.CheckBox powerStartsFromOneBoxX; + private System.Windows.Forms.CheckBox powerStartsFromZeroBoxX; + private System.Windows.Forms.Label powerStartFromLabelY; + private System.Windows.Forms.Label powerStartFromLabelX; + private System.Windows.Forms.Label powerStartFromActiveLabelX; + private System.Windows.Forms.Label powerStartFromActiveLabelY; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 4d1e57d..9e88912 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -114,6 +114,10 @@ namespace grapher ByComponentCheckBox, gainSwitchX, gainSwitchY, + powerStartsFromZeroBoxX, + powerStartsFromOneBoxX, + powerStartsFromZeroBoxY, + powerStartsFromOneBoxY, XLutActiveValuesBox, YLutActiveValuesBox, XLutPointsBox, @@ -152,6 +156,8 @@ namespace grapher powerLabelY, expLabelX, expLabelY, + powerStartFromLabelX, + powerStartFromLabelY, LUTTextLabelX, LUTTextLabelY, constantThreeLabelX, @@ -191,6 +197,8 @@ namespace grapher PowerClassicActiveYLabel, ExpActiveXLabel, ExpActiveYLabel, + powerStartFromActiveLabelX, + powerStartFromActiveLabelY, MidpointActiveXLabel, MidpointActiveYLabel, AccelTypeActiveLabelX, diff --git a/grapher/Layouts/ClassicLayout.cs b/grapher/Layouts/ClassicLayout.cs index 1248a9c..05c590f 100644 --- a/grapher/Layouts/ClassicLayout.cs +++ b/grapher/Layouts/ClassicLayout.cs @@ -20,6 +20,7 @@ namespace grapher.Layouts LimitLayout = new OptionLayout(false, string.Empty); PowerClassicLayout = new OptionLayout(true, PowerClassic); ExponentLayout = new OptionLayout(false, string.Empty); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); MidpointLayout = new OptionLayout(false, string.Empty); LutTextLayout = new OptionLayout(false, string.Empty); LutPanelLayout = new OptionLayout(false, string.Empty); diff --git a/grapher/Layouts/DefaultLayout.cs b/grapher/Layouts/DefaultLayout.cs index 9ae10b2..1b45307 100644 --- a/grapher/Layouts/DefaultLayout.cs +++ b/grapher/Layouts/DefaultLayout.cs @@ -21,6 +21,7 @@ namespace grapher.Layouts LimitLayout = new OptionLayout(true, Limit); PowerClassicLayout = new OptionLayout(true, PowerClassic); ExponentLayout = new OptionLayout(true, Exponent); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); MidpointLayout = new OptionLayout(true, Midpoint); LutTextLayout = new OptionLayout(false, string.Empty); LutPanelLayout = new OptionLayout(false, string.Empty); diff --git a/grapher/Layouts/JumpLayout.cs b/grapher/Layouts/JumpLayout.cs index ab2bc17..40e7629 100644 --- a/grapher/Layouts/JumpLayout.cs +++ b/grapher/Layouts/JumpLayout.cs @@ -21,6 +21,7 @@ namespace grapher.Layouts LimitLayout = new OptionLayout(false, Limit); PowerClassicLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(false, string.Empty); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); MidpointLayout = new OptionLayout(false, string.Empty); LutTextLayout = new OptionLayout(false, string.Empty); LutPanelLayout = new OptionLayout(false, string.Empty); diff --git a/grapher/Layouts/LUTLayout.cs b/grapher/Layouts/LUTLayout.cs index 86287b1..5412294 100644 --- a/grapher/Layouts/LUTLayout.cs +++ b/grapher/Layouts/LUTLayout.cs @@ -28,6 +28,7 @@ namespace grapher.Layouts OffsetLayout = new OptionLayout(false, Offset); LimitLayout = new OptionLayout(false, string.Empty); PowerClassicLayout = new OptionLayout(false, string.Empty); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(false, Exponent); MidpointLayout = new OptionLayout(false, string.Empty); LutTextLayout = new OptionLayout(true, string.Empty); diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs index e7b654f..a283008 100644 --- a/grapher/Layouts/LayoutBase.cs +++ b/grapher/Layouts/LayoutBase.cs @@ -9,6 +9,7 @@ namespace grapher.Layouts public const string DecayRate = "Decay Rate"; public const string Scale = "Scale"; public const string Exponent = "Exponent"; + public const string StartsFrom = "Start from"; public const string PowerClassic = "Power"; public const string Limit = "Limit"; public const string Midpoint = "Midpoint"; @@ -30,6 +31,7 @@ namespace grapher.Layouts LimitLayout = new OptionLayout(false, string.Empty); PowerClassicLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(false, string.Empty); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); MidpointLayout = new OptionLayout(false, string.Empty); LutTextLayout = new OptionLayout(false, string.Empty); LutPanelLayout = new OptionLayout(false, string.Empty); @@ -65,6 +67,8 @@ namespace grapher.Layouts protected OptionLayout ExponentLayout { get; set; } + protected OptionLayout PowerStartsFromLayout { get; set; } + protected OptionLayout MidpointLayout { get; set; } protected OptionLayout LutTextLayout { get; set; } @@ -91,6 +95,7 @@ namespace grapher.Layouts IOption limitOption, IOption powerClassicOption, IOption expOption, + IOption startsFromOption, IOption midpointOption, IOption lutTextOption, IOption lutPanelOption, @@ -111,6 +116,7 @@ namespace grapher.Layouts (LimitLayout, limitOption), (PowerClassicLayout, powerClassicOption), (ExponentLayout, expOption), + (PowerStartsFromLayout, startsFromOption), (MidpointLayout, midpointOption), (LutTextLayout, lutTextOption), (LutPanelLayout, lutPanelOption), @@ -145,6 +151,7 @@ namespace grapher.Layouts IOption limitOption, IOption powerClassicOption, IOption expOption, + IOption startsFromOption, IOption midpointOption, IOption lutTextOption, IOption lutPanelOption, @@ -160,6 +167,7 @@ namespace grapher.Layouts limitOption, powerClassicOption, expOption, + startsFromOption, midpointOption, lutTextOption, lutPanelOption, diff --git a/grapher/Layouts/LinearLayout.cs b/grapher/Layouts/LinearLayout.cs index 7aa0965..f6b3cc0 100644 --- a/grapher/Layouts/LinearLayout.cs +++ b/grapher/Layouts/LinearLayout.cs @@ -21,6 +21,7 @@ namespace grapher.Layouts OffsetLayout = new OptionLayout(true, Offset); LimitLayout = new OptionLayout(false, string.Empty); PowerClassicLayout = new OptionLayout(false, string.Empty); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(false, string.Empty); MidpointLayout = new OptionLayout(false, string.Empty); LutTextLayout = new OptionLayout(false, string.Empty); diff --git a/grapher/Layouts/MotivityLayout.cs b/grapher/Layouts/MotivityLayout.cs index 77c20ab..ebce103 100644 --- a/grapher/Layouts/MotivityLayout.cs +++ b/grapher/Layouts/MotivityLayout.cs @@ -26,6 +26,7 @@ namespace grapher.Layouts LimitLayout = new OptionLayout(true, Motivity); PowerClassicLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(false, string.Empty); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); MidpointLayout = new OptionLayout(true, Midpoint); LutTextLayout = new OptionLayout(false, string.Empty); LutPanelLayout = new OptionLayout(false, string.Empty); diff --git a/grapher/Layouts/NaturalLayout.cs b/grapher/Layouts/NaturalLayout.cs index 452c6aa..ed5ade9 100644 --- a/grapher/Layouts/NaturalLayout.cs +++ b/grapher/Layouts/NaturalLayout.cs @@ -21,6 +21,7 @@ namespace grapher.Layouts LimitLayout = new OptionLayout(true, Limit); PowerClassicLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(false, string.Empty); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); MidpointLayout = new OptionLayout(false, string.Empty); LutTextLayout = new OptionLayout(false, string.Empty); LutPanelLayout = new OptionLayout(false, string.Empty); diff --git a/grapher/Layouts/OffLayout.cs b/grapher/Layouts/OffLayout.cs index 64902a5..92333d9 100644 --- a/grapher/Layouts/OffLayout.cs +++ b/grapher/Layouts/OffLayout.cs @@ -21,6 +21,7 @@ namespace grapher.Layouts LimitLayout = new OptionLayout(false, string.Empty); PowerClassicLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(false, string.Empty); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); MidpointLayout = new OptionLayout(false, string.Empty); LutTextLayout = new OptionLayout(false, string.Empty); LutPanelLayout = new OptionLayout(false, string.Empty); diff --git a/grapher/Layouts/PowerLayout.cs b/grapher/Layouts/PowerLayout.cs index cdc9b98..c25bbbb 100644 --- a/grapher/Layouts/PowerLayout.cs +++ b/grapher/Layouts/PowerLayout.cs @@ -19,6 +19,7 @@ LimitLayout = new OptionLayout(false, string.Empty); PowerClassicLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(true, Exponent); + PowerStartsFromLayout = new OptionLayout(true, StartsFrom); MidpointLayout = new OptionLayout(false, string.Empty); LutTextLayout = new OptionLayout(false, string.Empty); LutPanelLayout = new OptionLayout(false, string.Empty); diff --git a/grapher/Layouts/UnsupportedLayout.cs b/grapher/Layouts/UnsupportedLayout.cs index 87bf5f8..3faf721 100644 --- a/grapher/Layouts/UnsupportedLayout.cs +++ b/grapher/Layouts/UnsupportedLayout.cs @@ -26,6 +26,7 @@ namespace grapher.Layouts LimitLayout = new OptionLayout(false, string.Empty); PowerClassicLayout = new OptionLayout(false, string.Empty); ExponentLayout = new OptionLayout(false, Exponent); + PowerStartsFromLayout = new OptionLayout(false, string.Empty); MidpointLayout = new OptionLayout(false, string.Empty); LutTextLayout = new OptionLayout(true, LUTLayoutText); LutPanelLayout = new OptionLayout(false, string.Empty); diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index d95489b..89318e2 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -86,6 +86,10 @@ namespace grapher.Models CheckBox byComponentCheckBox, CheckBox gainSwitchX, CheckBox gainSwitchY, + CheckBox powerStartsFromZeroBoxX, + CheckBox powerStartsFromOneBoxX, + CheckBox powerStartsFromZeroBoxY, + CheckBox powerStartsFromOneBoxY, RichTextBox xLutActiveValuesBox, RichTextBox yLutActiveValuesBox, RichTextBox xLutPointsBox, @@ -124,6 +128,8 @@ namespace grapher.Models Label powerClassicLabelY, Label expLabelX, Label expLabelY, + Label powerStartsFromLabelX, + Label powerStartsFromLabelY, Label lutTextLabelX, Label lutTextLabelY, Label constantThreeLabelX, @@ -163,6 +169,8 @@ namespace grapher.Models Label powerClassicActiveLabelY, Label expActiveLabelX, Label expActiveLabelY, + Label powerStartsFromActiveLabelX, + Label powerStartsFromActiveLabelY, Label midpointActiveLabelX, Label midpointActiveLabelY, Label accelTypeActiveLabelX, @@ -487,6 +495,20 @@ namespace grapher.Models outCapYPower, scaleY); + var powerStartsFromX = new SwitchOption( + powerStartsFromLabelX, + powerStartsFromZeroBoxX, + powerStartsFromOneBoxX, + new ActiveValueLabel(powerStartsFromActiveLabelX, activeValueTitleX), + 0); + + var powerStartsFromY = new SwitchOption( + powerStartsFromLabelY, + powerStartsFromZeroBoxY, + powerStartsFromOneBoxY, + new ActiveValueLabel(powerStartsFromActiveLabelY, activeValueTitleY), + optionSetYLeft); + var lpNorm = new Option( new Field(lpNormBox, form, 2), lpNormLabel, @@ -532,6 +554,7 @@ namespace grapher.Models gainSwitchOptionX, classicCapOptionsX, powerCapOptionsX, + powerStartsFromX, decayRateX, growthRateX, smoothX, @@ -554,6 +577,7 @@ namespace grapher.Models gainSwitchOptionY, classicCapOptionsY, powerCapOptionsY, + powerStartsFromY, decayRateY, growthRateY, smoothY, diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index 029a93e..b3153ed 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -29,6 +29,7 @@ namespace grapher CheckBoxOption gainSwitch, CapOptions classicCap, CapOptions powerCap, + SwitchOption powerStartsFrom, Option decayRate, Option growthRate, Option smooth, @@ -70,6 +71,7 @@ namespace grapher Limit = limit; PowerClassic = powerClassic; Exponent = exponent; + PowerStartsFrom = powerStartsFrom; Midpoint = midpoint; WriteButton = writeButton; AccelTypeActiveValue = accelTypeActiveValue; @@ -112,6 +114,8 @@ namespace grapher public CapOptions PowerCap { get; } + public SwitchOption PowerStartsFrom { get; } + public Option Offset { get; } public Option Limit { get; } @@ -223,6 +227,7 @@ namespace grapher Smooth.Hide(); ClassicCap.Hide(); PowerCap.Hide(); + PowerStartsFrom.Hide(); Offset.Hide(); Limit.Hide(); PowerClassic.Hide(); @@ -260,6 +265,7 @@ namespace grapher args.cap.x, args.cap.y, args.capMode); + PowerStartsFrom.SetActiveValue(!args.powerStartFromOne); Offset.SetActiveValue(args.offset); DecayRate.SetActiveValue(args.decayRate); GrowthRate.SetActiveValue(args.growthRate); @@ -322,6 +328,7 @@ namespace grapher args.cap.y = PowerCap.Out.Field.Data; args.capMode = PowerCap.CapTypeOptions.GetSelectedCapMode(); } + if (PowerStartsFrom.Visible) args.powerStartFromOne = PowerStartsFrom.Second.Checked; if (Limit.Visible) { if (args.mode == AccelMode.motivity) @@ -362,6 +369,7 @@ namespace grapher Smooth.AlignActiveValues(); ClassicCap.AlignActiveValues(); PowerCap.AlignActiveValues(); + PowerStartsFrom.AlignActiveValues(); Offset.AlignActiveValues(); Limit.AlignActiveValues(); PowerClassic.AlignActiveValues(); @@ -403,6 +411,7 @@ namespace grapher Limit, PowerClassic, Exponent, + PowerStartsFrom, Midpoint, LutText, LutPanel, diff --git a/grapher/Models/Options/SwitchOption.cs b/grapher/Models/Options/SwitchOption.cs new file mode 100644 index 0000000..79991c1 --- /dev/null +++ b/grapher/Models/Options/SwitchOption.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Options +{ + public class SwitchOption : OptionBase + { + + #region Constructors + + public SwitchOption( + Label label, + CheckBox firstCheckBox, + CheckBox secondCheckBox, + ActiveValueLabel activeValueLabel, + int left) + { + Label = label; + First = firstCheckBox; + Second = secondCheckBox; + ActiveValueLabel = activeValueLabel; + Left = left; + + label.AutoSize = false; + label.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + label.Width = First.Left - left - Constants.OptionLabelBoxSeperation; + label.Height = First.Height; + + ActiveValueLabel.Height = First.Height; + + First.CheckedChanged += OnFirstCheckedChange; + Second.CheckedChanged += OnSecondCheckedChange; + + First.Checked = true; + Second.Left = First.Left + First.Width + Constants.OptionLabelBoxSeperation; + Show(string.Empty); + } + + #endregion Constructors + + #region Properties + + public Label Label { get; } + + public CheckBox First { get; } + + public CheckBox Second { get; } + + public ActiveValueLabel ActiveValueLabel { get; } + + public override int Height + { + get => Label.Height; + } + + public override int Left + { + get => Label.Left; + set + { + Label.Left = value; + } + } + + public override bool Visible + { + get => ShouldShow; + } + + public override int Width + { + get => Second.Left + Second.Width - Label.Left; + set + { + } + } + + public override int Top + { + get => Label.Top; + set + { + Label.Top = value; + First.Top = value; + Second.Top = value; + ActiveValueLabel.Top = value; + } + } + + private bool ShouldShow { get; set; } + + #endregion Properties + + #region Methods + + public override void AlignActiveValues() + { + ActiveValueLabel.Align(); + } + + public override void Hide() + { + ShouldShow = false; + + Label.Hide(); + First.Hide(); + Second.Hide(); + ActiveValueLabel.Hide(); + } + + public override void Show(string name) + { + ShouldShow = true; + + if (!string.IsNullOrWhiteSpace(name)) + { + Label.Text = name; + } + + Label.Show(); + First.Show(); + Second.Show(); + ActiveValueLabel.Show(); + } + + public void SetActiveValue(bool shouldFirstBeChecked) + { + if (shouldFirstBeChecked) + { + First.Checked = true; + ActiveValueLabel.SetValue(First.Text); + } + else + { + Second.Checked = true; + ActiveValueLabel.SetValue(Second.Text); + } + } + + private void OnFirstCheckedChange(object sender, EventArgs e) + { + if (First.Checked) + { + Second.Checked = false; + } + } + + private void OnSecondCheckedChange(object sender, EventArgs e) + { + if (Second.Checked) + { + First.Checked = false; + } + } + + #endregion Methods + } +} diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 702d89e..51c7fb6 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -145,6 +145,7 @@ <Compile Include="Layouts\OptionLayout.cs" /> <Compile Include="Models\Options\OptionBase.cs" /> <Compile Include="Models\Options\OptionXY.cs" /> + <Compile Include="Models\Options\SwitchOption.cs" /> <Compile Include="Models\Options\TextOption.cs" /> <Compile Include="Models\Serialized\GUISettings.cs" /> <Compile Include="Models\Serialized\SettingsManager.cs" /> diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index 2eefb1b..9930454 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -75,6 +75,7 @@ public value struct AccelArgs double limit; double midpoint; double smooth; + bool powerStartFromOne; [JsonProperty("Cap / Jump")] Vec2<double> cap; |