31 #include <wx/bitmap.h>
33 #include <wx/dynarray.h>
34 #include <wx/imaglist.h>
36 #include <wx/string.h>
38 #include "model/MarkIcon.h"
39 #include "model/nav_object_database.h"
40 #include "model/nmea_log.h"
41 #include "model/ocpn_types.h"
42 #include "model/route.h"
43 #include "model/route_point.h"
44 #include "model/select.h"
46 #include "color_types.h"
48 #include "observable_evtvar.h"
54 #define PI 3.1415926535897931160E0
60 extern bool g_bPluginHandleAutopilotRoute;
62 extern Route *pAISMOBRoute;
64 extern RouteList *pRouteList;
69 extern float g_ChartScaleFactorExp;
75 class markicon_bitmap_list_type;
76 class markicon_key_list_type;
77 class markicon_description_list_type;
79 WX_DEFINE_SORTED_ARRAY(
MarkIcon *, SortedArrayOfMarkIcon);
80 WX_DEFINE_ARRAY(
MarkIcon *, ArrayOfMarkIcon);
84 std::function<void(
Route*)> set_route_and_update;
86 std::function<void(
Route*)> hide;
88 set_route_and_update([&](
Route* r) {}),
90 hide([&](
Route* r) {})
97 std::function<bool()> confirm_delete_ais_mob;
98 std::function<wxColour(wxString)> get_global_colour;
99 std::function<void()> show_with_fresh_fonts;
100 std::function<void()> clear_console_background;
101 std::function<void()> route_mgr_dlg_update_list_ctrl;
104 : confirm_delete_ais_mob([]() {
return true; }),
105 get_global_colour([](wxString c) {
return *wxBLACK; }),
106 show_with_fresh_fonts([]() { }),
107 clear_console_background([]() { }),
108 route_mgr_dlg_update_list_ctrl([]() { })
127 bool DeleteTrack(
Track *pTrack);
132 bool IsRouteValid(
Route *pRoute);
134 Route *FindRouteByGUID(
const wxString &guid);
135 Track *FindTrackByGUID(
const wxString &guid);
138 wxArrayPtrVoid *GetRouteArrayContaining(
RoutePoint *pWP);
139 bool DoesRouteContainSharedPoints(
Route *pRoute);
140 void RemovePointFromRoute(
RoutePoint *point,
Route *route,
int route_state);
142 bool ActivateRoute(
Route *pRouteToActivate,
RoutePoint *pStartPoint = NULL);
146 double cog,
double sog);
148 bool UpdateAutopilot();
149 bool DeactivateRoute(
bool b_arrival =
false);
150 bool IsAnyRouteActive(
void) {
return (pActiveRoute != NULL); }
152 Route *GetpActiveRoute() {
return pActiveRoute; }
153 RoutePoint *GetpActivePoint() {
return pActivePoint; }
154 double GetCurrentRngToActivePoint() {
return CurrentRngToActivePoint; }
155 double GetCurrentBrgToActivePoint() {
return CurrentBrgToActivePoint; }
156 double GetCurrentRngToActiveNormalArrival() {
157 return CurrentRangeToActiveNormalCrossing;
159 double GetCurrentXTEToActivePoint() {
return CurrentXTEToActivePoint; }
160 void ZeroCurrentXTEToActivePoint();
161 double GetCurrentSegmentCourse() {
return CurrentSegmentCourse; }
162 int GetXTEDir() {
return XTEDir; }
164 void SetColorScheme(ColorScheme cs,
double displayDPmm);
165 wxPen *GetRoutePen(
void) {
return m_pRoutePen; }
166 wxPen *GetTrackPen(
void) {
return m_pTrackPen; }
167 wxPen *GetSelectedRoutePen(
void) {
return m_pSelectedRoutePen; }
168 wxPen *GetActiveRoutePen(
void) {
return m_pActiveRoutePen; }
169 wxPen *GetActiveRoutePointPen(
void) {
return m_pActiveRoutePointPen; }
170 wxPen *GetRoutePointPen(
void) {
return m_pRoutePointPen; }
171 wxBrush *GetRouteBrush(
void) {
return m_pRouteBrush; }
172 wxBrush *GetSelectedRouteBrush(
void) {
return m_pSelectedRouteBrush; }
173 wxBrush *GetActiveRouteBrush(
void) {
return m_pActiveRouteBrush; }
174 wxBrush *GetActiveRoutePointBrush(
void) {
return m_pActiveRoutePointBrush; }
175 wxBrush *GetRoutePointBrush(
void) {
return m_pRoutePointBrush; }
177 wxString GetRouteReverseMessage(
void);
178 wxString GetRouteResequenceMessage(
void);
201 double RouteBrgToActivePoint;
202 double CurrentSegmentBeginLat;
203 double CurrentSegmentBeginLon;
204 double CurrentRngToActivePoint;
205 double CurrentBrgToActivePoint;
206 double CurrentXTEToActivePoint;
207 double CourseToRouteSegment;
208 double CurrentRangeToActiveNormalCrossing;
211 double CurrentSegmentCourse;
216 wxPen *m_pSelectedRoutePen;
217 wxPen *m_pActiveRoutePen;
218 wxPen *m_pActiveRoutePointPen;
219 wxPen *m_pRoutePointPen;
220 wxBrush *m_pRouteBrush;
221 wxBrush *m_pSelectedRouteBrush;
222 wxBrush *m_pActiveRouteBrush;
223 wxBrush *m_pActiveRoutePointBrush;
224 wxBrush *m_pRoutePointBrush;
228 double m_arrival_min;
242 typedef std::function<wxColour(wxString)> GlobalColourFunc;
251 wxBitmap *GetIconBitmap(
const wxString &icon_key);
252 bool GetIconPrescaled(
const wxString &icon_key);
253 int GetIconIndex(
const wxBitmap *pbm);
254 int GetIconImageListIndex(
const wxBitmap *pbm);
255 int GetXIconImageListIndex(
const wxBitmap *pbm);
256 int GetFIconImageListIndex(
const wxBitmap *pbm);
257 int GetNumIcons(
void) {
return m_pIconArray->Count(); }
259 RoutePoint* FindWaypointByGuid(
const std::string& guid);
260 RoutePoint *GetNearbyWaypoint(
double lat,
double lon,
double radius_meters);
261 RoutePoint *GetOtherNearbyWaypoint(
double lat,
double lon,
262 double radius_meters,
263 const wxString &guid);
265 bool SharedWptsExist();
266 void DeleteAllWaypoints(
bool b_delete_used);
267 RoutePoint *FindRoutePointByGUID(
const wxString &guid);
268 void DestroyWaypoint(
RoutePoint *pRp,
bool b_update_changeset =
true);
269 void ClearRoutePointFonts(
void);
271 bool DoesIconExist(
const wxString &icon_key)
const;
272 wxBitmap GetIconBitmapForList(
int index,
int height);
273 wxString *GetIconDescription(
int index);
274 wxString *GetIconKey(
int index);
275 wxString GetIconDescription(wxString icon_key);
277 wxImageList *Getpmarkicon_image_list(
int nominal_height);
281 RoutePointList *GetWaypointList(
void) {
return m_pWayPointList; }
285 wxImage CreateDimImage(wxImage &image,
double factor);
287 RoutePointList *m_pWayPointList;
288 wxBitmap *CreateDimBitmap(wxBitmap *pBitmap,
double factor);
290 wxImageList *pmarkicon_image_list;
292 int m_markicon_image_list_base_count;
293 ArrayOfMarkIcon *m_pIconArray;
296 double m_iconListScale;
298 SortedArrayOfMarkIcon *m_pLegacyIconArray;
299 SortedArrayOfMarkIcon *m_pExtendedIconArray;
301 int m_bitmapSizeForList;
302 int m_iconListHeight;
304 GlobalColourFunc m_get_global_colour;
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
Define an action to be performed when a KeyProvider is notified.
bool ActivateRoutePoint(Route *pA, RoutePoint *pRP)
bool ActivateNextPoint(Route *pr, bool skipped)
EventVar on_routes_update
Notified when list of routes is updated (no data in event)
bool DeleteRoute(Route *pRoute, NavObjectChanges *nav_obj_changes)
EventVar json_msg
Notified with message targeting all plugins.
EventVar json_leg_info
Notified with a shared_ptr<ActiveLegDat>, leg info to all plugins.
EventVar on_message_sent
Notified when a message available as GetString() is sent to garmin.
Callbacks for RoutePropDlg.