OpenCPN Partial API docs
Loading...
Searching...
No Matches
ocpn_frame.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: OpenCPN Main wxWidgets Program
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2010 by David S. Register *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 **************************************************************************/
25
26#ifndef _OFRAME_H
27#define _OFRAME_H
28
29#include <wx/print.h>
30#include <wx/power.h>
31
32#include <memory>
33#ifdef __WXMSW__
34#include <wx/msw/private.h>
35#endif
36
37#include "model/ocpn_types.h"
38#include "model/comm_appmsg_bus.h"
39#include "bbox.h"
40#include "comm_overflow_dlg.h"
41#include "connections_dlg.h"
42#include "color_handler.h"
43#include "data_monitor.h"
44#include "gui_lib.h"
45#include "load_errors_dlg.h"
46#include "observable_evtvar.h"
47#include "s52s57.h"
48#include "s57registrar_mgr.h"
49#include "SencManager.h"
50#include "displays.h"
51
52wxColour GetGlobalColor(wxString colorName);
53wxColour GetDialogColor(DialogColor color);
54
55// Helper to create menu label + hotkey string when registering menus
56wxString _menuText(wxString name, wxString shortcut);
57
58// The point for anchor watch should really be a class...
59double AnchorDistFix(double const d, double const AnchorPointMinDist,
60 double const AnchorPointMaxDist); // pjotrc 2010.02.22
61
62bool TestGLCanvas(wxString prog_dir);
63bool ReloadLocale();
64void ApplyLocale(void);
65
66void LoadS57();
67
68// Fwd definitions
69class ChartCanvas;
71class OCPN_MsgEvent;
72class options;
73class Track;
74class wxHtmlWindow;
75class ArrayOfCDI;
76
77//----------------------------------------------------------------------------
78// constants
79//----------------------------------------------------------------------------
80
81#define TIMER_GFRAME_1 999
82
83#define ID_CM93ZOOMG 102
84
85// Command identifiers for wxCommandEvents coming from the outside world.
86// Removed from enum to facilitate constant definition
87//
88// NOLINTBEGIN
89#define ID_CMD_APPLY_SETTINGS 300
90#define ID_CMD_NULL_REFRESH 301
91#define ID_CMD_TRIGGER_RESIZE 302
92#define ID_CMD_SETVP 303
93#define ID_CMD_POST_JSON_TO_PLUGINS 304
94#define ID_CMD_SOUND_FINISHED 306
95// NOLINTEND
96
97#ifdef __ANDROID__
98#define STAT_FIELD_COUNT 2
99#define STAT_FIELD_TICK -1
100#define STAT_FIELD_SOGCOG 0
101#define STAT_FIELD_CURSOR_LL -1
102#define STAT_FIELD_CURSOR_BRGRNG -1
103#define STAT_FIELD_SCALE 1
104#else
105#define STAT_FIELD_COUNT 5
106#define STAT_FIELD_TICK 0
107#define STAT_FIELD_SOGCOG 1
108#define STAT_FIELD_CURSOR_LL 2
109#define STAT_FIELD_CURSOR_BRGRNG 3
110#define STAT_FIELD_SCALE 4
111#endif
112
113// Define a constant GPS signal watchdog timeout value
114#define GPS_TIMEOUT_SECONDS 10
115
116#define MAX_COG_AVERAGE_SECONDS 60
117#define MAX_COGSOG_FILTER_SECONDS 60
118//----------------------------------------------------------------------------
119// fwd class declarations
120//----------------------------------------------------------------------------
121class ChartBase;
122class wxSocketEvent;
124class OCPN_DataStreamEvent;
125class AisTargetData;
126
127bool ShowNavWarning();
128
129bool isSingleChart(ChartBase* chart);
130
136class MyFrame : public wxFrame {
137public:
138 MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos,
139 const wxSize& size, long style);
140
141 ~MyFrame();
142
143 int GetApplicationMemoryUse(void);
144
145 void OnEraseBackground(wxEraseEvent& event);
146 void OnMaximize(wxMaximizeEvent& event);
147 void OnCloseWindow(wxCloseEvent& event);
148 void OnExit(wxCommandEvent& event);
149 void OnSize(wxSizeEvent& event);
150 void OnMove(wxMoveEvent& event);
151 void OnInitTimer(wxTimerEvent& event);
152
161 void OnFrameTimer1(wxTimerEvent& event);
162
163 bool DoChartUpdate(void);
164 void OnEvtPlugInMessage(OCPN_MsgEvent& event);
165 void OnMemFootTimer(wxTimerEvent& event);
166 void OnRecaptureTimer(wxTimerEvent& event);
167 void OnSENCEvtThread(OCPN_BUILDSENC_ThreadEvent& event);
168 void OnIconize(wxIconizeEvent& event);
169 void OnBellsFinished(wxCommandEvent& event);
170
182 void OnFrameTenHzTimer(wxTimerEvent& event);
183
184#ifdef wxHAS_POWER_EVENTS
185 void OnSuspending(wxPowerEvent& event);
186 void OnSuspended(wxPowerEvent& event);
187 void OnSuspendCancel(wxPowerEvent& event);
188 void OnResume(wxPowerEvent& event);
189#endif // wxHAS_POWER_EVENTS
190
191 void RefreshCanvasOther(ChartCanvas* ccThis);
192 void UpdateAllFonts(void);
193 void PositionConsole(void);
194 void OnToolLeftClick(wxCommandEvent& event);
195 void DoStackUp(ChartCanvas* cc);
196 void DoStackDown(ChartCanvas* cc);
197 void selectChartDisplay(int type, int family);
198 void applySettingsString(wxString settings);
199 void setStringVP(wxString VPS);
200 void InvalidateAllGL();
201 void RefreshAllCanvas(bool bErase = true);
202 void CancelAllMouseRoute();
203 void InvalidateAllQuilts();
204
205 void SetUpMode(ChartCanvas* cc, int mode);
206
207 ChartCanvas* GetPrimaryCanvas();
208 ChartCanvas* GetFocusCanvas();
209
210 void DoStackDelta(ChartCanvas* cc, int direction);
211 void DoSettings(void);
212 void DoSettingsNew(void);
213 void SwitchKBFocus(ChartCanvas* pCanvas);
214 ChartCanvas* GetCanvasUnderMouse();
215 int GetCanvasIndexUnderMouse();
216
217 bool DropMarker(bool atOwnShip = true);
218
219 void TriggerRecaptureTimer();
220 bool SetGlobalToolbarViz(bool viz);
221
222 void MouseEvent(wxMouseEvent& event);
223 void CenterView(ChartCanvas* cc, const LLBBox& bbox);
224
225 void JumpToPosition(ChartCanvas* cc, double lat, double lon, double scale);
226
227 void ProcessCanvasResize(void);
228
229 void BuildMenuBar(void);
230 void ApplyGlobalSettings(bool bnewtoolbar);
231 void RegisterGlobalMenuItems();
232 void UpdateGlobalMenuItems();
233 void UpdateGlobalMenuItems(ChartCanvas* cc);
234 void DoOptionsDialog();
235 void ProcessOptionsDialog(int resultFlags, ArrayOfCDI* pNewDirArray);
236 void PrepareOptionsClose(options* settings, int settings_return_value);
237
238 void DoPrint(void);
239 void ToggleDataQuality(ChartCanvas* cc);
240 void TogglebFollow(ChartCanvas* cc);
241 void ToggleFullScreen();
242 void ToggleChartBar(ChartCanvas* cc);
243 void SetbFollow(ChartCanvas* cc);
244 void ClearbFollow(ChartCanvas* cc);
245 void ToggleChartOutlines(ChartCanvas* cc);
246 void ToggleENCText(ChartCanvas* cc);
247 void ToggleSoundings(ChartCanvas* cc);
248#if 0
249 void ToggleRocks(void);
250#endif
251 bool ToggleLights(ChartCanvas* cc);
252 void ToggleAnchor(ChartCanvas* cc);
253 void ToggleAISDisplay(ChartCanvas* cc);
254 void ToggleAISMinimizeTargets(ChartCanvas* cc);
255
256 void ToggleTestPause(void);
257 void TrackOn(void);
258 void SetENCDisplayCategory(ChartCanvas* cc, enum _DisCat nset);
259 void ToggleNavobjects(ChartCanvas* cc);
260
261 Track* TrackOff(bool do_add_point = false);
262 void TrackDailyRestart(void);
263 bool ShouldRestartTrack();
264 void ToggleColorScheme();
265 void SetMenubarItemState(int item_id, bool state);
266 void SetMasterToolbarItemState(int tool_id, bool state);
267
268 void SetToolbarItemBitmaps(int tool_id, wxBitmap* bitmap,
269 wxBitmap* bmpDisabled);
270 void SetToolbarItemSVG(int tool_id, wxString normalSVGfile,
271 wxString rolloverSVGfile, wxString toggledSVGfile);
272 void ToggleQuiltMode(ChartCanvas* cc);
273 void UpdateControlBar(ChartCanvas* cc);
274
275 void SubmergeAllCanvasToolbars(void);
276 void SurfaceAllCanvasToolbars(void);
277 void SetAllToolbarScale(void);
278 void SetGPSCompassScale(void);
279 void InvalidateAllCanvasUndo();
280
281 void RefreshGroupIndices(void);
282
283 double GetBestVPScale(ChartBase* pchart);
284
285 DataMonitor* GetDataMonitor() const { return m_data_monitor; }
286
287 ColorScheme GetColorScheme();
288 void SetAndApplyColorScheme(ColorScheme cs);
289
290 void OnFrameTCTimer(wxTimerEvent& event);
291 void OnFrameCOGTimer(wxTimerEvent& event);
292
293 void HandleBasicNavMsg(std::shared_ptr<const BasicNavDataMsg> msg);
294 void HandleGPSWatchdogMsg(std::shared_ptr<const GPSWatchdogMsg> msg);
295
296 void ChartsRefresh();
297
298 bool CheckGroup(int igroup);
299 double GetMag(double a, double lat, double lon);
300 bool SendJSON_WMM_Var_Request(double lat, double lon, wxDateTime date);
301
302 void DestroyPersistentDialogs();
303 void TouchAISActive(void);
304 void UpdateAISTool(void);
305
306 void ActivateAISMOBRoute(const AisTargetData* ptarget);
307 void UpdateAISMOBRoute(const AisTargetData* ptarget);
308
309 wxStatusBar* m_pStatusBar;
310 wxMenuBar* m_pMenuBar;
311 int nBlinkerTick;
312 bool m_bTimeIsSet;
313
314 wxTimer InitTimer;
315 int m_iInitCount;
316 bool m_initializing;
317
318 wxTimer FrameTCTimer;
319 wxTimer FrameTimer1;
320 wxTimer FrameCOGTimer;
321 wxTimer MemFootTimer;
322 wxTimer m_resizeTimer;
323 wxTimer FrameTenHzTimer;
324
325 int m_BellsToPlay;
326 wxTimer BellsTimer;
327
328 // PlugIn support
329 int GetNextToolbarToolId() { return m_next_available_plugin_tool_id; }
330 void RequestNewToolbarArgEvent(wxCommandEvent& WXUNUSED(event)) {
331 return RequestNewMasterToolbar();
332 }
333 void RequestNewToolbars(bool bforcenew = false);
334
335 void ActivateMOB(void);
336 void UpdateGPSCompassStatusBoxes(bool b_force_new = false);
337 void UpdateRotationState(double rotation);
338
339 bool UpdateChartDatabaseInplace(ArrayOfCDI& DirArray, bool b_force,
340 bool b_prog,
341 const wxString& ChartListFileName);
342
343 bool m_bdefer_resize;
344 wxSize m_defer_size;
345 double COGTable[MAX_COG_AVERAGE_SECONDS];
346
347 void FastClose();
348 void SetChartUpdatePeriod();
349 void CreateCanvasLayout(bool b_useStoredSize = false);
350 void LoadHarmonics();
351 void ReloadAllVP();
352 void SetCanvasSizes(wxSize frameSize);
353
354 ocpnToolBarSimple* CreateMasterToolbar();
355 void RequestNewMasterToolbar(bool bforcenew = true);
356 bool CheckAndAddPlugInTool();
357 bool AddDefaultPositionPlugInTools();
358
359 void NotifyChildrenResize(void);
360 void UpdateCanvasConfigDescriptors();
361 void ScheduleSettingsDialog();
362 void ScheduleSettingsDialogNew();
363 void ScheduleDeleteSettingsDialog();
364 void ScheduleReconfigAndSettingsReload(bool reload, bool new_dialog);
365 static void RebuildChartDatabase();
366 void PositionIENCToolbar();
367
368 void InitAppMsgBusListener();
369 void InitApiListeners();
370 void ReleaseApiListeners();
371 void UpdateStatusBar(void);
372 void ConfigureStatusBar();
373
374private:
375 void ProcessUnitTest();
376 void ProcessQuitFlag();
377 void ProcessDeferredTrackOn();
378 void SendFixToPlugins();
379 void ProcessAnchorWatch();
380 void ProcessLogAndBells();
381 void CalculateCOGAverage();
382 void CheckToolbarPosition();
383
384 void ODoSetSize(void);
385 void DoCOGSet(void);
386
387 void UpdateAllToolbars(ColorScheme cs);
388
389 void FilterCogSog(void);
390
391 void ApplyGlobalColorSchemetoStatusBar(void);
392
393 bool ScrubGroupArray();
394
395 void OnToolbarAnimateTimer(wxTimerEvent& event);
396 bool CollapseGlobalToolbar();
397
398 int m_StatusBarFieldCount;
399
400 wxDateTime m_MMEAeventTime;
401 unsigned long m_ulLastNMEATicktime;
402 int m_tick_idx;
403 wxDateTime m_fix_start_time;
404
405 wxString m_last_reported_chart_name;
406 wxString m_last_reported_chart_pubdate;
407
408 wxString m_lastAISiconName;
409
410 // Plugin Support
411 int m_next_available_plugin_tool_id;
412
413 double COGFilterTable[MAX_COGSOG_FILTER_SECONDS];
414 double SOGFilterTable[MAX_COGSOG_FILTER_SECONDS];
415
416 int m_ChartUpdatePeriod;
417 bool m_last_bGPSValid;
418 bool m_last_bVelocityValid;
419 double m_last_hdt;
420
421 wxString prev_locale;
422
430 time_t m_fixtime;
431 bool b_autofind;
432
433 time_t m_last_track_rotation_ts;
434 wxTimer ToolbarAnimateTimer;
435 int m_nMasterToolCountShown;
436 wxTimer m_recaptureTimer;
437
438 std::unique_ptr<LoadErrorsDlgCtrl> m_load_errors_dlg_ctrl;
439
440 ObservableListener listener_basic_navdata;
441 ObservableListener listener_gps_watchdog;
442 ObsListener m_on_raise_listener;
443 ObsListener m_on_quit_listener;
444 ObsListener m_routes_update_listener;
445 ObsListener m_evt_drv_msg_listener;
446
447 CommOverflowDlg comm_overflow_dlg;
448 ConnectionsDlg* m_connections_dlg;
449 bool m_need_new_options;
450 wxArrayString pathArray;
451 double restoreScale[4];
452 unsigned int last_canvasConfig;
453 DataMonitor* m_data_monitor;
454
455 DECLARE_EVENT_TABLE()
456};
457
458#endif // _OFRAME_H
Base class for all chart types.
Definition chartbase.h:119
ChartCanvas - Main chart display and interaction component.
Definition chcanv.h:151
A dialog for handling communication overflow notifications.
Options | Connections tab implementaion, basically a UI for maintaining the list of connections.
Overall logging handler, outputs to screen and log file.
Main application frame.
Definition ocpn_frame.h:136
void OnFrameTimer1(wxTimerEvent &event)
Main application timer handler called approximately once per second.
void InitApiListeners()
Setup handling of events from the local ipc/dbus API.
void OnFrameTenHzTimer(wxTimerEvent &event)
High-frequency timer handler running at 10Hz for smooth navigation updates.
Define an action to be performed when a KeyProvider is notified.
Definition observable.h:228
Keeps listening over it's lifespan, removes itself on destruction.
Definition observable.h:131
Represents a track, which is a series of connected track points.
Definition track.h:111
Floating toolbar dialog for OpenCPN.
Definition toolbar.h:386
Generic toolbar implementation in pure wxWidgets adapted from wxToolBarSimple (deprecated).
Definition toolbar.h:103
Popup dialog on communication overflows.
The ConnectionsDlg class.
New NMEA Debugger successor main window.
General purpose GUI support.