34 #include <wx/msw/private.h>
37 #include "model/ocpn_types.h"
38 #include "model/comm_appmsg_bus.h"
40 #include "comm_overflow_dlg.h"
41 #include "color_handler.h"
44 #include "observable_evtvar.h"
45 #include "ocpn_print.h"
47 #include "SencManager.h"
50 wxColour GetGlobalColor(wxString colorName);
51 wxColour GetDialogColor(DialogColor color);
54 wxString _menuText(wxString name, wxString shortcut);
57 double AnchorDistFix(
double const d,
double const AnchorPointMinDist,
58 double const AnchorPointMaxDist);
60 bool TestGLCanvas(wxString prog_dir);
62 void ApplyLocale(
void);
81 #define TIMER_GFRAME_1 999
83 #define ID_CM93ZOOMG 102
91 #define ID_CMD_APPLY_SETTINGS 300
92 #define ID_CMD_NULL_REFRESH 301
93 #define ID_CMD_TRIGGER_RESIZE 302
94 #define ID_CMD_SETVP 303
95 #define ID_CMD_POST_JSON_TO_PLUGINS 304
96 #define ID_CMD_SOUND_FINISHED 306
101 #define STAT_FIELD_COUNT 2
102 #define STAT_FIELD_TICK -1
103 #define STAT_FIELD_SOGCOG 0
104 #define STAT_FIELD_CURSOR_LL -1
105 #define STAT_FIELD_CURSOR_BRGRNG -1
106 #define STAT_FIELD_SCALE 1
108 #define STAT_FIELD_COUNT 5
109 #define STAT_FIELD_TICK 0
110 #define STAT_FIELD_SOGCOG 1
111 #define STAT_FIELD_CURSOR_LL 2
112 #define STAT_FIELD_CURSOR_BRGRNG 3
113 #define STAT_FIELD_SCALE 4
117 #define GPS_TIMEOUT_SECONDS 10
120 #define MAX_COG_AVERAGE_SECONDS 60
121 #define MAX_COGSOG_FILTER_SECONDS 60
128 class OCPN_DataStreamEvent;
139 [[maybe_unused]]
void SetSString(std::string
string) { m_string = string; }
140 std::string GetSString() {
return m_string; }
143 wxEvent *Clone()
const;
146 std::string m_string;
152 MyFrame(wxFrame *frame,
const wxString &title,
const wxPoint &pos,
153 const wxSize &size,
long style);
157 int GetApplicationMemoryUse(
void);
159 void OnEraseBackground(wxEraseEvent &event);
160 void OnMaximize(wxMaximizeEvent &event);
161 void OnCloseWindow(wxCloseEvent &event);
162 void OnExit(wxCommandEvent &event);
163 void OnSize(wxSizeEvent &event);
164 void OnMove(wxMoveEvent &event);
165 void OnInitTimer(wxTimerEvent &event);
167 bool DoChartUpdate(
void);
169 void OnMemFootTimer(wxTimerEvent &event);
170 void OnRecaptureTimer(wxTimerEvent &event);
172 void OnIconize(wxIconizeEvent &event);
173 void OnBellsFinished(wxCommandEvent &event);
175 #ifdef wxHAS_POWER_EVENTS
176 void OnSuspending(wxPowerEvent &event);
177 void OnSuspended(wxPowerEvent &event);
178 void OnSuspendCancel(wxPowerEvent &event);
179 void OnResume(wxPowerEvent &event);
183 void UpdateAllFonts(
void);
184 void PositionConsole(
void);
185 void OnToolLeftClick(wxCommandEvent &event);
188 void selectChartDisplay(
int type,
int family);
189 void applySettingsString(wxString settings);
190 void setStringVP(wxString VPS);
191 void InvalidateAllGL();
192 void RefreshAllCanvas(
bool bErase =
true);
193 void CancelAllMouseRoute();
194 void InvalidateAllQuilts();
202 void DoSettings(
void);
205 int GetCanvasIndexUnderMouse();
207 bool DropMarker(
bool atOwnShip =
true);
209 void TriggerRecaptureTimer();
210 bool SetGlobalToolbarViz(
bool viz);
212 void MouseEvent(wxMouseEvent &event);
213 void CenterView(
ChartCanvas *cc,
const LLBBox &bbox);
217 void ProcessCanvasResize(
void);
219 void BuildMenuBar(
void);
220 void ApplyGlobalSettings(
bool bnewtoolbar);
221 void RegisterGlobalMenuItems();
222 void UpdateGlobalMenuItems();
224 int DoOptionsDialog();
225 bool ProcessOptionsDialog(
int resultFlags, ArrayOfCDI *pNewDirArray);
229 void ToggleFullScreen();
237 void ToggleRocks(
void);
244 void ToggleTestPause(
void);
246 void SetENCDisplayCategory(
ChartCanvas *cc,
enum _DisCat nset);
249 Track *TrackOff(
bool do_add_point =
false);
250 void TrackDailyRestart(
void);
251 bool ShouldRestartTrack();
252 void ToggleColorScheme();
253 void SetMenubarItemState(
int item_id,
bool state);
254 void SetMasterToolbarItemState(
int tool_id,
bool state);
256 void SetToolbarItemBitmaps(
int tool_id, wxBitmap *bitmap,
257 wxBitmap *bmpDisabled);
258 void SetToolbarItemSVG(
int tool_id, wxString normalSVGfile,
259 wxString rolloverSVGfile, wxString toggledSVGfile);
263 void SubmergeAllCanvasToolbars(
void);
264 void SurfaceAllCanvasToolbars(
void);
265 void SetAllToolbarScale(
void);
266 void SetGPSCompassScale(
void);
267 void InvalidateAllCanvasUndo();
269 void RefreshGroupIndices(
void);
271 double GetBestVPScale(
ChartBase *pchart);
273 ColorScheme GetColorScheme();
274 void SetAndApplyColorScheme(ColorScheme cs);
276 void OnFrameTCTimer(wxTimerEvent &event);
277 void OnFrameCOGTimer(wxTimerEvent &event);
279 void HandleBasicNavMsg(std::shared_ptr<const BasicNavDataMsg> msg);
280 void HandleGPSWatchdogMsg(std::shared_ptr<const GPSWatchdogMsg> msg);
282 void ChartsRefresh();
284 bool CheckGroup(
int igroup);
285 double GetMag(
double a,
double lat,
double lon);
286 bool SendJSON_WMM_Var_Request(
double lat,
double lon, wxDateTime date);
288 void DestroyPersistentDialogs();
289 void TouchAISActive(
void);
290 void UpdateAISTool(
void);
295 wxStatusBar *m_pStatusBar;
296 wxMenuBar *m_pMenuBar;
304 wxTimer FrameTCTimer;
306 wxTimer FrameCOGTimer;
307 wxTimer MemFootTimer;
308 wxTimer m_resizeTimer;
314 int GetNextToolbarToolId() {
return m_next_available_plugin_tool_id; }
315 void RequestNewToolbarArgEvent(wxCommandEvent &WXUNUSED(event)) {
316 return RequestNewMasterToolbar();
318 void RequestNewToolbars(
bool bforcenew =
false);
320 void ActivateMOB(
void);
321 void UpdateGPSCompassStatusBoxes(
bool b_force_new =
false);
322 void UpdateRotationState(
double rotation);
324 bool UpdateChartDatabaseInplace(ArrayOfCDI &DirArray,
bool b_force,
326 const wxString &ChartListFileName);
328 bool m_bdefer_resize;
330 double COGTable[MAX_COG_AVERAGE_SECONDS];
333 void SetChartUpdatePeriod();
334 void CreateCanvasLayout(
bool b_useStoredSize =
false);
335 void LoadHarmonics();
337 void SetCanvasSizes(wxSize frameSize);
340 void RequestNewMasterToolbar(
bool bforcenew =
true);
341 bool CheckAndAddPlugInTool();
342 bool AddDefaultPositionPlugInTools();
344 void NotifyChildrenResize(
void);
345 void UpdateCanvasConfigDescriptors();
346 void ScheduleSettingsDialog();
347 static void RebuildChartDatabase();
348 void PositionIENCToolbar();
350 void InitAppMsgBusListener();
352 void ReleaseApiListeners();
353 void UpdateStatusBar(
void);
356 void CheckToolbarPosition();
357 void ODoSetSize(
void);
360 void UpdateAllToolbars(ColorScheme cs);
362 void FilterCogSog(
void);
364 void ApplyGlobalColorSchemetoStatusBar(
void);
366 bool ScrubGroupArray();
368 void OnToolbarAnimateTimer(wxTimerEvent &event);
369 bool CollapseGlobalToolbar();
371 int m_StatusBarFieldCount;
373 wxDateTime m_MMEAeventTime;
374 unsigned long m_ulLastNMEATicktime;
377 wxString m_last_reported_chart_name;
378 wxString m_last_reported_chart_pubdate;
380 wxString m_lastAISiconName;
383 int m_next_available_plugin_tool_id;
385 double COGFilterTable[MAX_COGSOG_FILTER_SECONDS];
386 double SOGFilterTable[MAX_COGSOG_FILTER_SECONDS];
388 int m_ChartUpdatePeriod;
389 bool m_last_bGPSValid;
390 bool m_last_bVelocityValid;
392 wxString prev_locale;
397 time_t m_last_track_rotation_ts;
398 wxTimer ToolbarAnimateTimer;
399 int m_nMasterToolCountShown;
400 wxTimer m_recaptureTimer;
402 std::unique_ptr<LoadErrorsDlgCtrl> m_load_errors_dlg_ctrl;
412 DECLARE_EVENT_TABLE()
void OnFrameTimer1(wxTimerEvent &event)
void InitApiListeners()
Setup handling of events from the local ipc/dbus API.
Define an action to be performed when a KeyProvider is notified.
Keeps listening over it's lifespan, removes itself on destruction.
General purpose GUI support.
Handle dialog reporting plugin load errors.