diff --git a/ExtLibs/Utilities/Grid.cs b/ExtLibs/Utilities/Grid.cs index 0f73299df3..8f71bcf441 100644 --- a/ExtLibs/Utilities/Grid.cs +++ b/ExtLibs/Utilities/Grid.cs @@ -187,13 +187,13 @@ private static List GenerateOffsetPath(List utmpositions, double return ans; } - public static async Task> CreateRotaryAsync(List 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> CreateRotaryAsync(List 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 CreateRotary(List 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 CreateRotary(List 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; @@ -215,7 +215,7 @@ public static List CreateRotary(List 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(); diff --git a/Grid/GridData.cs b/Grid/GridData.cs index 0e8d71656b..01a10b2b45 100644 --- a/Grid/GridData.cs +++ b/Grid/GridData.cs @@ -44,6 +44,7 @@ public struct GridData public decimal minlaneseparation; // spiral settings public decimal clockwiseLaps; + public decimal laps; public bool matchPerimeter; // camera config diff --git a/Grid/GridUI.Designer.cs b/Grid/GridUI.Designer.cs index 9eec7468f5..9f0d76483c 100644 --- a/Grid/GridUI.Designer.cs +++ b/Grid/GridUI.Designer.cs @@ -97,6 +97,8 @@ private void InitializeComponent() this.BUT_save = new MissionPlanner.Controls.MyButton(); this.tabGrid = new System.Windows.Forms.TabPage(); this.groupBoxSpiral = new System.Windows.Forms.GroupBox(); + this.LBL_laps = new System.Windows.Forms.Label(); + this.NUM_laps = new System.Windows.Forms.NumericUpDown(); this.CHK_match_spiral_perimeter = new System.Windows.Forms.CheckBox(); this.LBL_clockwise_laps = new System.Windows.Forms.Label(); this.LBL_clockwise_laps1 = new System.Windows.Forms.Label(); @@ -180,6 +182,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.NUM_focallength)).BeginInit(); this.tabGrid.SuspendLayout(); this.groupBoxSpiral.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUM_laps)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUM_clockwise_laps)).BeginInit(); this.groupBox7.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.NUM_Lane_Dist)).BeginInit(); @@ -737,6 +740,8 @@ private void InitializeComponent() // groupBoxSpiral // resources.ApplyResources(this.groupBoxSpiral, "groupBoxSpiral"); + this.groupBoxSpiral.Controls.Add(this.LBL_laps); + this.groupBoxSpiral.Controls.Add(this.NUM_laps); this.groupBoxSpiral.Controls.Add(this.CHK_match_spiral_perimeter); this.groupBoxSpiral.Controls.Add(this.LBL_clockwise_laps); this.groupBoxSpiral.Controls.Add(this.LBL_clockwise_laps1); @@ -745,6 +750,32 @@ private void InitializeComponent() this.groupBoxSpiral.Name = "groupBoxSpiral"; this.groupBoxSpiral.TabStop = false; // + // LBL_laps + // + resources.ApplyResources(this.LBL_laps, "LBL_laps"); + this.LBL_laps.Name = "LBL_laps"; + // + // NUM_laps + // + resources.ApplyResources(this.NUM_laps, "NUM_laps"); + this.NUM_laps.Maximum = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUM_laps.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.NUM_laps.Name = "NUM_laps"; + this.NUM_laps.Value = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.NUM_laps.ValueChanged += new System.EventHandler(this.domainUpDown1_ValueChanged); + // // CHK_match_spiral_perimeter // resources.ApplyResources(this.CHK_match_spiral_perimeter, "CHK_match_spiral_perimeter"); @@ -1454,6 +1485,7 @@ private void InitializeComponent() this.tabGrid.PerformLayout(); this.groupBoxSpiral.ResumeLayout(false); this.groupBoxSpiral.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUM_laps)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUM_clockwise_laps)).EndInit(); this.groupBox7.ResumeLayout(false); this.groupBox7.PerformLayout(); @@ -1629,5 +1661,7 @@ private void InitializeComponent() private System.Windows.Forms.NumericUpDown NUM_clockwise_laps; private System.Windows.Forms.Label label46; private System.Windows.Forms.CheckBox CHK_match_spiral_perimeter; + private System.Windows.Forms.NumericUpDown NUM_laps; + private System.Windows.Forms.Label LBL_laps; } } \ No newline at end of file diff --git a/Grid/GridUI.cs b/Grid/GridUI.cs index 9a50167247..a860141eae 100644 --- a/Grid/GridUI.cs +++ b/Grid/GridUI.cs @@ -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 @@ -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; @@ -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); @@ -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(); } @@ -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 { diff --git a/Grid/GridUI.resx b/Grid/GridUI.resx index 6e37910594..1dcb2aee34 100644 --- a/Grid/GridUI.resx +++ b/Grid/GridUI.resx @@ -1971,6 +1971,57 @@ Top, Bottom, Right + + True + + + NoControl + + + 7, 25 + + + 82, 13 + + + 13 + + + Number of Laps + + + LBL_laps + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxSpiral + + + 0 + + + 143, 23 + + + 51, 20 + + + 12 + + + NUM_laps + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxSpiral + + + 1 + True @@ -1978,7 +2029,7 @@ NoControl - 10, 72 + 10, 94 156, 17 @@ -1999,7 +2050,7 @@ groupBoxSpiral - 0 + 2 True @@ -2008,7 +2059,7 @@ NoControl - 7, 25 + 7, 47 133, 13 @@ -2029,7 +2080,7 @@ groupBoxSpiral - 1 + 3 True @@ -2038,7 +2089,7 @@ NoControl - 18, 49 + 18, 71 117, 13 @@ -2059,10 +2110,10 @@ groupBoxSpiral - 2 + 4 - 143, 47 + 143, 69 51, 20 @@ -2080,7 +2131,7 @@ groupBoxSpiral - 3 + 5 True @@ -2089,7 +2140,7 @@ NoControl - 6, 23 + 6, 45 0, 13 @@ -2107,13 +2158,13 @@ groupBoxSpiral - 4 + 6 - 6, 474 + 6, 457 - 233, 105 + 233, 122 64 @@ -2143,7 +2194,7 @@ NoControl - 10, 72 + 10, 63 126, 17 @@ -2173,7 +2224,7 @@ NoControl - 7, 25 + 7, 19 81, 13 @@ -2203,7 +2254,7 @@ NoControl - 26, 49 + 26, 40 103, 13 @@ -2227,7 +2278,7 @@ 2 - 143, 47 + 143, 38 51, 20 @@ -2278,7 +2329,7 @@ 6, 363 - 233, 105 + 233, 88 63