From 196958a389518b28fa9939ed71df111a9328f622 Mon Sep 17 00:00:00 2001 From: Andras Schaffer Date: Fri, 12 Jan 2024 05:03:04 +0100 Subject: [PATCH] Fix rotated map not displaying vehicle (#3266) --- .../GMap.NET.WindowsForms/GMapControl.cs | 4 ++-- ExtLibs/Maps/GMapMarkerQuad.cs | 2 +- GCSViews/ConfigurationView/ConfigPlanner.cs | 8 ++++++++ GCSViews/FlightData.cs | 10 +++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ExtLibs/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs b/ExtLibs/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs index d774c40dde..0a59227923 100644 --- a/ExtLibs/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs +++ b/ExtLibs/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs @@ -1439,7 +1439,6 @@ public void doPaint(IGraphics e) { { e.Clear(EmptyMapBackground); - #if !PocketPC if (MapRenderTransform.HasValue) { @@ -1507,8 +1506,9 @@ public void doPaint(IGraphics e) } #endif DrawMap(e); - OnPaintOverlays(e); } + OnPaintOverlays(e); + } } diff --git a/ExtLibs/Maps/GMapMarkerQuad.cs b/ExtLibs/Maps/GMapMarkerQuad.cs index 537960898a..4f7eb4a9b3 100644 --- a/ExtLibs/Maps/GMapMarkerQuad.cs +++ b/ExtLibs/Maps/GMapMarkerQuad.cs @@ -47,8 +47,8 @@ public override void OnRender(IGraphics g) { var temp = g.Transform; g.TranslateTransform(LocalPosition.X, LocalPosition.Y); - // set centerpoint as 0,0 g.TranslateTransform(-Offset.X, -Offset.Y); + g.RotateTransform(-Overlay.Control.Bearing); // anti NaN try diff --git a/GCSViews/ConfigurationView/ConfigPlanner.cs b/GCSViews/ConfigurationView/ConfigPlanner.cs index 5e7fd49b75..4c11bd9ed2 100644 --- a/GCSViews/ConfigurationView/ConfigPlanner.cs +++ b/GCSViews/ConfigurationView/ConfigPlanner.cs @@ -720,6 +720,10 @@ private void CHK_maprotation_CheckedChanged(object sender, EventArgs e) if (startup) return; Settings.Instance["CHK_maprotation"] = CHK_maprotation.Checked.ToString(); + if (CHK_maprotation.Checked) + { + chk_shownofly.Checked = false; + } FlightData.instance.gMapControl1.Bearing = 0; } @@ -987,6 +991,10 @@ private void CHK_AutoParamCommit_CheckedChanged(object sender, EventArgs e) private void chk_shownofly_CheckedChanged(object sender, EventArgs e) { Settings.Instance["ShowNoFly"] = chk_shownofly.Checked.ToString(); + if (chk_shownofly.Checked) + { + CHK_maprotation.Checked = false; + } } private void CMB_altunits_SelectedIndexChanged(object sender, EventArgs e) diff --git a/GCSViews/FlightData.cs b/GCSViews/FlightData.cs index 74909e1ba7..95e6842d26 100644 --- a/GCSViews/FlightData.cs +++ b/GCSViews/FlightData.cs @@ -3593,8 +3593,16 @@ private void mainloop() if (Settings.Instance.GetBoolean("CHK_maprotation")) { - // dont holdinvalidation here + ////Check if we have more than one vehicle connected and disable CHK_maprotation if so + if (MainV2.comPort.MAVlist.Count > 1) + { + Settings.Instance["CHK_maprotation"] = "false"; + //And set maprotation to zero + BeginInvoke((Action)delegate { gMapControl1.Bearing = 0; }); + } + //gMapControl1.HoldInvalidation = true; setMapBearing(); + } if (route == null)