Skip to content

Commit

Permalink
Grid circular pattern exposed number of laps to UI
Browse files Browse the repository at this point in the history
Added UI elements to set the number of laps on the Grid circular pattern
  • Loading branch information
aunrela authored and meee1 committed Feb 7, 2022
1 parent a0666c1 commit 640102e
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 22 deletions.
8 changes: 4 additions & 4 deletions ExtLibs/Utilities/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ private static List<utmpos> GenerateOffsetPath(List<utmpos> utmpositions, double
return ans;
}

public static async Task<List<PointLatLngAlt>> CreateRotaryAsync(List<PointLatLngAlt> polygon, double altitude, double distance, double spacing, double angle, double overshoot1, double overshoot2, StartPosition startpos, bool shutter, float minLaneSeparation, float leadin, PointLatLngAlt HomeLocation, int clockwise_laps, bool match_spiral_perimeter)
public static async Task<List<PointLatLngAlt>> CreateRotaryAsync(List<PointLatLngAlt> polygon, double altitude, double distance, double spacing, double angle, double overshoot1, double overshoot2, StartPosition startpos, bool shutter, float minLaneSeparation, float leadin, PointLatLngAlt HomeLocation, int clockwise_laps, bool match_spiral_perimeter, int laps)
{
return await Task.Run((() => CreateRotary(polygon, altitude, distance, spacing, angle, overshoot1, overshoot2,
startpos, shutter, minLaneSeparation, leadin, HomeLocation, clockwise_laps, match_spiral_perimeter))).ConfigureAwait(false);
startpos, shutter, minLaneSeparation, leadin, HomeLocation, clockwise_laps, match_spiral_perimeter, laps))).ConfigureAwait(false);
}

public static List<PointLatLngAlt> CreateRotary(List<PointLatLngAlt> polygon, double altitude, double distance, double spacing, double angle, double overshoot1, double overshoot2, StartPosition startpos, bool shutter, float minLaneSeparation, float leadin, PointLatLngAlt HomeLocation, int clockwise_laps, bool match_spiral_perimeter)
public static List<PointLatLngAlt> CreateRotary(List<PointLatLngAlt> polygon, double altitude, double distance, double spacing, double angle, double overshoot1, double overshoot2, StartPosition startpos, bool shutter, float minLaneSeparation, float leadin, PointLatLngAlt HomeLocation, int clockwise_laps, bool match_spiral_perimeter, int laps)
{
spacing = 0;

Expand All @@ -215,7 +215,7 @@ public static List<PointLatLngAlt> CreateRotary(List<PointLatLngAlt> polygon, do
if (utmpositions[0] != utmpositions[utmpositions.Count - 1])
utmpositions.Add(utmpositions[0]); // make a full loop

var maxlane = 200;// (Centroid(utmpositions).GetDistance(utmpositions[0]) / distance);
var maxlane = laps;// (Centroid(utmpositions).GetDistance(utmpositions[0]) / distance);

ClipperLib.ClipperOffset clipperOffset = new ClipperLib.ClipperOffset();

Expand Down
1 change: 1 addition & 0 deletions Grid/GridData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public struct GridData
public decimal minlaneseparation;
// spiral settings
public decimal clockwiseLaps;
public decimal laps;
public bool matchPerimeter;

// camera config
Expand Down
34 changes: 34 additions & 0 deletions Grid/GridUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Grid/GridUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ void loadgriddata(GridData griddata)

// Spiral Settings
NUM_clockwise_laps.Value = griddata.clockwiseLaps;
NUM_laps.Value = griddata.laps;
CHK_match_spiral_perimeter.Checked = griddata.matchPerimeter;

// update display options last
Expand Down Expand Up @@ -298,6 +299,7 @@ GridData savegriddata()

//Spiral Settings
griddata.clockwiseLaps = NUM_clockwise_laps.Value;
griddata.laps = NUM_laps.Value;
griddata.matchPerimeter = CHK_match_spiral_perimeter.Checked;

griddata.trigdist = rad_trigdist.Checked;
Expand Down Expand Up @@ -362,6 +364,7 @@ void loadsettings()

// Spiral Settings
loadsetting("grid_clockwise_laps", NUM_clockwise_laps);
loadsetting("grid_laps", NUM_laps);
loadsetting("grid_match_spiral_perimeter", CHK_match_spiral_perimeter);

loadsetting("grid_internals", CHK_internals);
Expand Down Expand Up @@ -441,6 +444,7 @@ void savesettings()

// Spiral Settings
plugin.Host.config["grid_clockwise_laps"] = NUM_clockwise_laps.Value.ToString();
plugin.Host.config["grid_laps"] = NUM_laps.Value.ToString();
plugin.Host.config["grid_match_spiral_perimeter"] = CHK_match_spiral_perimeter.Checked.ToString();
}

Expand Down Expand Up @@ -591,7 +595,7 @@ private async void domainUpDown1_ValueChanged(object sender, EventArgs e)
(double)NUM_overshoot.Value, (double)NUM_overshoot2.Value,
(Utilities.Grid.StartPosition)Enum.Parse(typeof(Utilities.Grid.StartPosition), CMB_startfrom.Text), false,
(float)NUM_Lane_Dist.Value, (float)NUM_leadin.Value, MainV2.comPort.MAV.cs.PlannedHomeLocation,
(int)NUM_clockwise_laps.Value, CHK_match_spiral_perimeter.Checked).ConfigureAwait(true);
(int)NUM_clockwise_laps.Value, CHK_match_spiral_perimeter.Checked, (int)NUM_laps.Value).ConfigureAwait(true);
}
else
{
Expand Down
85 changes: 68 additions & 17 deletions Grid/GridUI.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1971,14 +1971,65 @@
<data name="groupBoxSpiral.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Right</value>
</data>
<data name="LBL_laps.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="LBL_laps.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="LBL_laps.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 25</value>
</data>
<data name="LBL_laps.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 13</value>
</data>
<data name="LBL_laps.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
</data>
<data name="LBL_laps.Text" xml:space="preserve">
<value>Number of Laps</value>
</data>
<data name="&gt;&gt;LBL_laps.Name" xml:space="preserve">
<value>LBL_laps</value>
</data>
<data name="&gt;&gt;LBL_laps.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;LBL_laps.Parent" xml:space="preserve">
<value>groupBoxSpiral</value>
</data>
<data name="&gt;&gt;LBL_laps.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="NUM_laps.Location" type="System.Drawing.Point, System.Drawing">
<value>143, 23</value>
</data>
<data name="NUM_laps.Size" type="System.Drawing.Size, System.Drawing">
<value>51, 20</value>
</data>
<data name="NUM_laps.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
</data>
<data name="&gt;&gt;NUM_laps.Name" xml:space="preserve">
<value>NUM_laps</value>
</data>
<data name="&gt;&gt;NUM_laps.Type" xml:space="preserve">
<value>System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;NUM_laps.Parent" xml:space="preserve">
<value>groupBoxSpiral</value>
</data>
<data name="&gt;&gt;NUM_laps.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="CHK_match_spiral_perimeter.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="CHK_match_spiral_perimeter.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="CHK_match_spiral_perimeter.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 72</value>
<value>10, 94</value>
</data>
<data name="CHK_match_spiral_perimeter.Size" type="System.Drawing.Size, System.Drawing">
<value>156, 17</value>
Expand All @@ -1999,7 +2050,7 @@
<value>groupBoxSpiral</value>
</data>
<data name="&gt;&gt;CHK_match_spiral_perimeter.ZOrder" xml:space="preserve">
<value>0</value>
<value>2</value>
</data>
<data name="LBL_clockwise_laps.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -2008,7 +2059,7 @@
<value>NoControl</value>
</data>
<data name="LBL_clockwise_laps.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 25</value>
<value>7, 47</value>
</data>
<data name="LBL_clockwise_laps.Size" type="System.Drawing.Size, System.Drawing">
<value>133, 13</value>
Expand All @@ -2029,7 +2080,7 @@
<value>groupBoxSpiral</value>
</data>
<data name="&gt;&gt;LBL_clockwise_laps.ZOrder" xml:space="preserve">
<value>1</value>
<value>3</value>
</data>
<data name="LBL_clockwise_laps1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -2038,7 +2089,7 @@
<value>NoControl</value>
</data>
<data name="LBL_clockwise_laps1.Location" type="System.Drawing.Point, System.Drawing">
<value>18, 49</value>
<value>18, 71</value>
</data>
<data name="LBL_clockwise_laps1.Size" type="System.Drawing.Size, System.Drawing">
<value>117, 13</value>
Expand All @@ -2059,10 +2110,10 @@
<value>groupBoxSpiral</value>
</data>
<data name="&gt;&gt;LBL_clockwise_laps1.ZOrder" xml:space="preserve">
<value>2</value>
<value>4</value>
</data>
<data name="NUM_clockwise_laps.Location" type="System.Drawing.Point, System.Drawing">
<value>143, 47</value>
<value>143, 69</value>
</data>
<data name="NUM_clockwise_laps.Size" type="System.Drawing.Size, System.Drawing">
<value>51, 20</value>
Expand All @@ -2080,7 +2131,7 @@
<value>groupBoxSpiral</value>
</data>
<data name="&gt;&gt;NUM_clockwise_laps.ZOrder" xml:space="preserve">
<value>3</value>
<value>5</value>
</data>
<data name="label46.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -2089,7 +2140,7 @@
<value>NoControl</value>
</data>
<data name="label46.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 23</value>
<value>6, 45</value>
</data>
<data name="label46.Size" type="System.Drawing.Size, System.Drawing">
<value>0, 13</value>
Expand All @@ -2107,13 +2158,13 @@
<value>groupBoxSpiral</value>
</data>
<data name="&gt;&gt;label46.ZOrder" xml:space="preserve">
<value>4</value>
<value>6</value>
</data>
<data name="groupBoxSpiral.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 474</value>
<value>6, 457</value>
</data>
<data name="groupBoxSpiral.Size" type="System.Drawing.Size, System.Drawing">
<value>233, 105</value>
<value>233, 122</value>
</data>
<data name="groupBoxSpiral.TabIndex" type="System.Int32, mscorlib">
<value>64</value>
Expand Down Expand Up @@ -2143,7 +2194,7 @@
<value>NoControl</value>
</data>
<data name="chk_optimize_for_distance.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 72</value>
<value>10, 63</value>
</data>
<data name="chk_optimize_for_distance.Size" type="System.Drawing.Size, System.Drawing">
<value>126, 17</value>
Expand Down Expand Up @@ -2173,7 +2224,7 @@
<value>NoControl</value>
</data>
<data name="LBL_Alternating_lanes.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 25</value>
<value>7, 19</value>
</data>
<data name="LBL_Alternating_lanes.Size" type="System.Drawing.Size, System.Drawing">
<value>81, 13</value>
Expand Down Expand Up @@ -2203,7 +2254,7 @@
<value>NoControl</value>
</data>
<data name="LBL_Lane_Dist.Location" type="System.Drawing.Point, System.Drawing">
<value>26, 49</value>
<value>26, 40</value>
</data>
<data name="LBL_Lane_Dist.Size" type="System.Drawing.Size, System.Drawing">
<value>103, 13</value>
Expand All @@ -2227,7 +2278,7 @@
<value>2</value>
</data>
<data name="NUM_Lane_Dist.Location" type="System.Drawing.Point, System.Drawing">
<value>143, 47</value>
<value>143, 38</value>
</data>
<data name="NUM_Lane_Dist.Size" type="System.Drawing.Size, System.Drawing">
<value>51, 20</value>
Expand Down Expand Up @@ -2278,7 +2329,7 @@
<value>6, 363</value>
</data>
<data name="groupBox7.Size" type="System.Drawing.Size, System.Drawing">
<value>233, 105</value>
<value>233, 88</value>
</data>
<data name="groupBox7.TabIndex" type="System.Int32, mscorlib">
<value>63</value>
Expand Down

0 comments on commit 640102e

Please sign in to comment.