From fb8f977574d10785f855f5c10fa24341249a7627 Mon Sep 17 00:00:00 2001 From: Tatsuya Yamaguchi Date: Thu, 14 Mar 2024 13:13:44 +0900 Subject: [PATCH] FlightPlanner: Simultaneous display when not connected to vehicle --- GCSViews/FlightPlanner.cs | 43 ++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/GCSViews/FlightPlanner.cs b/GCSViews/FlightPlanner.cs index 23979cb9eb..5be89582d3 100644 --- a/GCSViews/FlightPlanner.cs +++ b/GCSViews/FlightPlanner.cs @@ -107,6 +107,9 @@ private void but_mincommands_Click(object sender, System.EventArgs e) private bool grid; private List groupmarkers = new List(); private List> history = new List>(); + private List wpCommandList = new List(); + private List fenceCommandList = new List(); + private List rallyCommandList = new List(); private bool isMouseClickOffMenu; private bool isMouseDown; private bool isMouseDraging; @@ -1417,15 +1420,26 @@ private void CreateAndDisplayOverlay(string overlayId, List (Locationwp)a).ToList(), wpRadius, loiterRadius, CurrentState.multiplieralt); + if (MainV2.comPort.BaseStream.IsOpen) commandlist = points.Select(a => (Locationwp)a).ToList(); + else + { + // Use the stored command list if not connected to vehicle + if (overlayId == "wp") commandlist = wpCommandList; + else if (overlayId == "fence") commandlist = fenceCommandList; + else if (overlayId == "rally") commandlist = rallyCommandList; + } } + overlay.CreateOverlay(home, commandlist, wpRadius, loiterRadius, CurrentState.multiplieralt); } catch (FormatException) { @@ -2101,16 +2115,22 @@ public void Cmb_missiontype_SelectedIndexChanged(object sender, EventArgs e) if (rally.Count() > 0) MainMap.Overlays.Remove(rally.First()); // update the displayed items + // if connected to a vehicle, display the vehicle's items; otherwise, display local items if ((MAVLink.MAV_MISSION_TYPE) cmb_missiontype.SelectedValue == MAVLink.MAV_MISSION_TYPE.RALLY) { BUT_Add.Visible = false; - processToScreen(MainV2.comPort.MAV.rallypoints.Select(a => (Locationwp) a.Value).ToList()); - + if (MainV2.comPort.BaseStream.IsOpen) + processToScreen(MainV2.comPort.MAV.rallypoints.Select(a => (Locationwp) a.Value).ToList()); + else + processToScreen(rallyCommandList); } else if ((MAVLink.MAV_MISSION_TYPE) cmb_missiontype.SelectedValue == MAVLink.MAV_MISSION_TYPE.FENCE) { BUT_Add.Visible = false; - processToScreen(MainV2.comPort.MAV.fencepoints.Select(a => (Locationwp) a.Value).ToList()); + if (MainV2.comPort.BaseStream.IsOpen) + processToScreen(MainV2.comPort.MAV.fencepoints.Select(a => (Locationwp) a.Value).ToList()); + else + processToScreen(fenceCommandList); Common.MessageShowAgain("FlightPlan Fence", "Please use the Polygon drawing tool to draw " + "Inclusion and Exclusion areas (round circle to the left)," + @@ -2120,7 +2140,16 @@ public void Cmb_missiontype_SelectedIndexChanged(object sender, EventArgs e) else { BUT_Add.Visible = true; - processToScreen(MainV2.comPort.MAV.wps.Select(a => (Locationwp) a.Value).ToList()); + if (MainV2.comPort.BaseStream.IsOpen) + processToScreen(MainV2.comPort.MAV.wps.Select(a => (Locationwp) a.Value).ToList()); + else + { + if (wpCommandList.Count > 0) + // insert a dummy home point + wpCommandList.Insert(0, new Locationwp().Set(0, 0, 0, 0)); + + processToScreen(wpCommandList); + } } writeKML();