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