Skip to content

Commit

Permalink
GMapMarkers: seperate and move
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Dec 5, 2017
1 parent 2b29310 commit 3814bb7
Show file tree
Hide file tree
Showing 28 changed files with 809 additions and 759 deletions.
711 changes: 1 addition & 710 deletions Common.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Controls/SITL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using MissionPlanner.Maps;
using MissionPlanner.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down
1 change: 0 additions & 1 deletion ExtLibs/Utilities/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ public static bool inverse(float[] x, float[] y, ushort dim)
return true;
}
}
return false;
}


Expand Down
4 changes: 0 additions & 4 deletions ExtLibs/Utilities/ubx_m8p.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,6 @@ public enum modeflags

public PointLatLngAlt getPointLatLngAlt()
{
double lat = 0;
double lng = 0;
double alt = 0;

if (flags == 2)
{
var X = ecefXorLat / 100.0 + ecefXOrLatHP * 0.0001;
Expand Down
37 changes: 0 additions & 37 deletions GCSViews/ConfigurationView/ConfigArdurover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,43 +149,6 @@ private static string AddNewLinesForTooltip(string text)
return sb.ToString();
}

private void ComboBox_Validated(object sender, EventArgs e)
{
EEPROM_View_float_TextChanged(sender, e);
}

private void Configuration_Validating(object sender, CancelEventArgs e)
{
EEPROM_View_float_TextChanged(sender, e);
}

internal void EEPROM_View_float_TextChanged(object sender, EventArgs e)
{
float value = 0;
var name = ((Control) sender).Name;

// do domainupdown state check
try
{
if (sender.GetType() == typeof (NumericUpDown))
{
value = (float) ((NumericUpDown) sender).Value;
MAVLinkInterface.modifyParamForDisplay(false, ((Control) sender).Name, ref value);
changes[name] = value;
}
else if (sender.GetType() == typeof (ComboBox))
{
value = ((ComboBox) sender).SelectedIndex;
changes[name] = value;
}
((Control) sender).BackColor = Color.Green;
}
catch (Exception)
{
((Control) sender).BackColor = Color.Red;
}
}

private void BUT_writePIDS_Click(object sender, EventArgs e)
{
var temp = (Hashtable) changes.Clone();
Expand Down
1 change: 1 addition & 0 deletions GCSViews/FlightData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using WebCamService;
using ZedGraph;
using LogAnalyzer = MissionPlanner.Utilities.LogAnalyzer;
using MissionPlanner.Maps;

// written by michael oborne

Expand Down
1 change: 1 addition & 0 deletions Grid/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using MissionPlanner.Utilities;
using MissionPlanner.Controls;
using Timer = System.Windows.Forms.Timer;
using MissionPlanner.Maps;

namespace MissionPlanner
{
Expand Down
1 change: 1 addition & 0 deletions Grid/GridUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using GMap.NET.WindowsForms.Markers;
using log4net;
using MissionPlanner.GCSViews;
using MissionPlanner.Maps;
using MissionPlanner.Properties;
using MissionPlanner.Utilities;
using ProjNet.CoordinateSystems;
Expand Down
2 changes: 0 additions & 2 deletions MagCalib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ public static void test()

mine.logreadmode = true;

int a = 0;

var sub = mine.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.RAW_IMU, message =>
{
var imu = message.ToStructure<MAVLink.mavlink_raw_imu_t>();
Expand Down
64 changes: 64 additions & 0 deletions Maps/GMapMarkerADSBPlane.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Drawing;
using GMap.NET;
using GMap.NET.WindowsForms;

namespace MissionPlanner.Maps
{
[Serializable]
public class GMapMarkerADSBPlane : GMapMarker
{
private static readonly Bitmap icong = new Bitmap(global::MissionPlanner.Properties.Resources.FW_icons_2013_logos_01, new Size(40, 40));
private static readonly Bitmap iconr = new Bitmap(global::MissionPlanner.Properties.Resources.FW_icons_2013_logos_011, new Size(40, 40));
private static readonly Bitmap icono = new Bitmap(global::MissionPlanner.Properties.Resources.FW_icons_2013_logos_012, new Size(40, 40));

public float heading = 0;
public AlertLevelOptions AlertLevel = AlertLevelOptions.Green;

public enum AlertLevelOptions
{
Green,
Orange,
Red
}

public GMapMarkerADSBPlane(PointLatLng p, float heading, AlertLevelOptions alert = AlertLevelOptions.Green)
: base(p)
{
this.AlertLevel = alert;
this.heading = heading;
Size = icong.Size;
}

public override void OnRender(Graphics g)
{
var temp = g.Transform;
g.TranslateTransform(LocalPosition.X, LocalPosition.Y);

g.RotateTransform(-Overlay.Control.Bearing);

try
{
g.RotateTransform(heading);
}
catch
{
}

switch (AlertLevel)
{
case AlertLevelOptions.Green:
g.DrawImageUnscaled(icong, icong.Width/-2, icong.Height/-2);
break;
case AlertLevelOptions.Orange:
g.DrawImageUnscaled(icono, icono.Width/-2, icono.Height/-2);
break;
case AlertLevelOptions.Red:
g.DrawImageUnscaled(iconr, iconr.Width/-2, iconr.Height/-2);
break;
}

g.Transform = temp;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Linq;
using System.Text;

namespace MissionPlanner.Utilities
namespace MissionPlanner.Maps
{
[Serializable]
public class GMapMarkerAirport : GMapMarker
Expand Down
51 changes: 51 additions & 0 deletions Maps/GMapMarkerAntennaTracker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Drawing;
using GMap.NET;
using GMap.NET.WindowsForms;
using MissionPlanner.Utilities;

namespace MissionPlanner.Maps
{
[Serializable]
public class GMapMarkerAntennaTracker : GMapMarker
{
private readonly Bitmap icon = global::MissionPlanner.Properties.Resources.Antenna_Tracker_01;

float heading = 0;
private float target = 0;

public GMapMarkerAntennaTracker(PointLatLng p, float heading, float target)
: base(p)
{
Size = icon.Size;
this.heading = heading;
this.target = target;
}

public override void OnRender(Graphics g)
{
var temp = g.Transform;
g.TranslateTransform(LocalPosition.X, LocalPosition.Y);

int length = 500;

try
{
// heading
g.DrawLine(new Pen(Color.Red, 2), 0.0f, 0.0f, (float) Math.Cos((heading - 90)*MathHelper.deg2rad)*length,
(float) Math.Sin((heading - 90)*MathHelper.deg2rad)*length);

// target
g.DrawLine(new Pen(Color.Orange, 2), 0.0f, 0.0f, (float) Math.Cos((target - 90)*MathHelper.deg2rad)*length,
(float) Math.Sin((target - 90)*MathHelper.deg2rad)*length);
}
catch
{
}

g.DrawImage(icon, -20, -20, 40, 40);

g.Transform = temp;
}
}
}
70 changes: 70 additions & 0 deletions Maps/GMapMarkerBoat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Drawing;
using GMap.NET;
using GMap.NET.WindowsForms;
using MissionPlanner.Utilities;

namespace MissionPlanner.Maps
{
[Serializable]
public class GMapMarkerBoat : GMapMarker
{
static readonly System.Drawing.Size SizeSt =
new System.Drawing.Size(global::MissionPlanner.Properties.Resources.boat.Width,
global::MissionPlanner.Properties.Resources.boat.Height);

float heading = 0;
float cog = -1;
float target = -1;
float nav_bearing = -1;

public GMapMarkerBoat(PointLatLng p, float heading, float cog, float nav_bearing, float target)
: base(p)
{
this.heading = heading;
this.cog = cog;
this.target = target;
this.nav_bearing = nav_bearing;
Size = SizeSt;
}

public override void OnRender(Graphics g)
{
var temp = g.Transform;
g.TranslateTransform(LocalPosition.X, LocalPosition.Y);

g.RotateTransform(-Overlay.Control.Bearing);

int length = 500;
// anti NaN
try
{
g.DrawLine(new Pen(Color.Red, 2), 0.0f, 0.0f, (float)Math.Cos((heading - 90) * MathHelper.deg2rad) * length,
(float)Math.Sin((heading - 90) * MathHelper.deg2rad) * length);
}
catch
{
}
g.DrawLine(new Pen(Color.Green, 2), 0.0f, 0.0f, (float)Math.Cos((nav_bearing - 90) * MathHelper.deg2rad) * length,
(float)Math.Sin((nav_bearing - 90) * MathHelper.deg2rad) * length);
g.DrawLine(new Pen(Color.Black, 2), 0.0f, 0.0f, (float)Math.Cos((cog - 90) * MathHelper.deg2rad) * length,
(float)Math.Sin((cog - 90) * MathHelper.deg2rad) * length);
g.DrawLine(new Pen(Color.Orange, 2), 0.0f, 0.0f, (float)Math.Cos((target - 90) * MathHelper.deg2rad) * length,
(float)Math.Sin((target - 90) * MathHelper.deg2rad) * length);
// anti NaN

try
{
g.RotateTransform(heading);
}
catch
{
}
g.DrawImageUnscaled(global::MissionPlanner.Properties.Resources.boat,
global::MissionPlanner.Properties.Resources.boat.Width / -2,
global::MissionPlanner.Properties.Resources.boat.Height / -2);

g.Transform = temp;
}
}
}
60 changes: 60 additions & 0 deletions Maps/GMapMarkerHeli.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Drawing;
using GMap.NET;
using GMap.NET.WindowsForms;
using MissionPlanner.Utilities;

namespace MissionPlanner.Maps
{
[Serializable]
public class GMapMarkerHeli : GMapMarker
{
private readonly Bitmap icon = global::MissionPlanner.Properties.Resources.heli;

float heading = 0;
float cog = -1;
float target = -1;

public GMapMarkerHeli(PointLatLng p, float heading, float cog, float target)
: base(p)
{
this.heading = heading;
this.cog = cog;
this.target = target;
Size = icon.Size;
}

public override void OnRender(Graphics g)
{
var temp = g.Transform;
g.TranslateTransform(LocalPosition.X, LocalPosition.Y);

int length = 500;
// anti NaN
try
{
g.DrawLine(new Pen(Color.Red, 2), 0.0f, 0.0f, (float) Math.Cos((heading - 90)*MathHelper.deg2rad)*length,
(float) Math.Sin((heading - 90)*MathHelper.deg2rad)*length);
}
catch
{
}
//g.DrawLine(new Pen(Color.Green, 2), 0.0f, 0.0f, (float)Math.Cos((nav_bearing - 90) * MathHelper.deg2rad) * length, (float)Math.Sin((nav_bearing - 90) * MathHelper.deg2rad) * length);
g.DrawLine(new Pen(Color.Black, 2), 0.0f, 0.0f, (float) Math.Cos((cog - 90)*MathHelper.deg2rad)*length,
(float) Math.Sin((cog - 90)*MathHelper.deg2rad)*length);
g.DrawLine(new Pen(Color.Orange, 2), 0.0f, 0.0f, (float) Math.Cos((target - 90)*MathHelper.deg2rad)*length,
(float) Math.Sin((target - 90)*MathHelper.deg2rad)*length);
// anti NaN
try
{
g.RotateTransform(heading);
}
catch
{
}
g.DrawImageUnscaled(icon, icon.Width/-2 + 2, icon.Height/-2);

g.Transform = temp;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
using GMap.NET;
using GMap.NET.WindowsForms;
using MissionPlanner.Properties;
using MissionPlanner.Utilities;

namespace MissionPlanner.Utilities
namespace MissionPlanner.Maps
{
[Serializable]
public class GMapMarkerOverlapCount : GMapMarker
Expand Down
2 changes: 1 addition & 1 deletion Utilities/GMapMarkerPOI.cs → Maps/GMapMarkerPOI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using GMap.NET.WindowsForms.Markers;
using MissionPlanner.Properties;

namespace MissionPlanner.Utilities
namespace MissionPlanner.Maps
{
[Serializable]
public class GMapMarkerPOI : GMarkerGoogle
Expand Down
3 changes: 2 additions & 1 deletion Utilities/GMapMarkerPhoto.cs → Maps/GMapMarkerPhoto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
using GMap.NET;
using GMap.NET.WindowsForms;
using MissionPlanner.Properties;
using MissionPlanner.Utilities;

namespace MissionPlanner.Utilities
namespace MissionPlanner.Maps
{
[Serializable]
public class GMapMarkerPhoto : GMapMarker
Expand Down
Loading

0 comments on commit 3814bb7

Please sign in to comment.