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 ToggleColorScheme();
268 void SetMenubarItemState(int item_id, bool state);
269 void SetMasterToolbarItemState(int tool_id, bool state);
270
271 void SetToolbarItemBitmaps(int tool_id, wxBitmap* bitmap,
272 wxBitmap* bmpDisabled);
273 void SetToolbarItemSVG(int tool_id, wxString normalSVGfile,
274 wxString rolloverSVGfile, wxString toggledSVGfile);
275 void ToggleQuiltMode(ChartCanvas* cc);
276 void UpdateControlBar(ChartCanvas* cc);
277
278 void SubmergeAllCanvasToolbars(void);
279 void SurfaceAllCanvasToolbars(void);
280 void SetAllToolbarScale(void);
281 void SetGPSCompassScale(void);
282 void InvalidateAllCanvasUndo();
283
284 void RefreshGroupIndices(void);
285
286 double GetBestVPScale(ChartBase* pchart);
287
288 DataMonitor* GetDataMonitor() const { return m_data_monitor; }
289
290 ColorScheme GetColorScheme();
291 void SetAndApplyColorScheme(ColorScheme cs);
292
293 void OnFrameTCTimer(wxTimerEvent& event);
294 void OnFrameCOGTimer(wxTimerEvent& event);
295
296 void HandleBasicNavMsg(std::shared_ptr<const BasicNavDataMsg> msg);
297 void HandleGPSWatchdogMsg(std::shared_ptr<const GPSWatchdogMsg> msg);
298
299 void ChartsRefresh();
300
301 bool CheckGroup(int igroup);
302 double GetMag(double a, double lat, double lon);
303 bool SendJSON_WMM_Var_Request(double lat, double lon, wxDateTime date);
304
305 void DestroyPersistentDialogs();
306 void TouchAISActive(void);
307 void UpdateAISTool(void);
308
309 void ActivateAISMOBRoute(const AisTargetData* ptarget);
310 void UpdateAISMOBRoute(const AisTargetData* ptarget);
311
312 wxStatusBar* m_pStatusBar;
313 wxMenuBar* m_pMenuBar;
314 int nBlinkerTick;
315 bool m_bTimeIsSet;
316
317 wxTimer InitTimer;
318 int m_iInitCount;
319 bool m_initializing;
320
321 wxTimer FrameTCTimer;
322 wxTimer FrameTimer1;
323 wxTimer FrameCOGTimer;
324 wxTimer MemFootTimer;
325 wxTimer m_resizeTimer;
326 wxTimer FrameTenHzTimer;
327
328 int m_BellsToPlay;
329 wxTimer BellsTimer;
330
331 // PlugIn support
332 int GetNextToolbarToolId() { return m_next_available_plugin_tool_id; }
333 void RequestNewToolbarArgEvent(wxCommandEvent& WXUNUSED(event)) {
334 return RequestNewMasterToolbar();
335 }
336 void RequestNewToolbars(bool bforcenew = false);
337
338 void ActivateMOB(void);
339 void UpdateGPSCompassStatusBoxes(bool b_force_new = false);
340 void UpdateRotationState(double rotation);
341
342 bool UpdateChartDatabaseInplace(ArrayOfCDI& DirArray, bool b_force,
343 bool b_prog,
344 const wxString& ChartListFileName);
345
346 bool m_bdefer_resize;
347 wxSize m_defer_size;
348 double COGTable[MAX_COG_AVERAGE_SECONDS];
349
350 void FastClose();
351 void SetChartUpdatePeriod();
352 void CreateCanvasLayout(bool b_useStoredSize = false);
353 void LoadHarmonics();
354 void ReloadAllVP();
355 void SetCanvasSizes(wxSize frameSize);
356
357 ocpnToolBarSimple* CreateMasterToolbar();
358 void RequestNewMasterToolbar(bool bforcenew = true);
359 bool CheckAndAddPlugInTool();
360 bool AddDefaultPositionPlugInTools();
361
362 void NotifyChildrenResize(void);
363 void UpdateCanvasConfigDescriptors();
364 void ScheduleSettingsDialog();
365 void ScheduleSettingsDialogNew();
366 void ScheduleDeleteSettingsDialog();
367 void ScheduleReconfigAndSettingsReload(bool reload, bool new_dialog);
368 void ScheduleReloadCharts();
369 static void RebuildChartDatabase();
370 void PositionIENCToolbar();
371
372 void InitAppMsgBusListener();
373 void InitApiListeners();
374 void ReleaseApiListeners();
375 void UpdateStatusBar(void);
376 void ConfigureStatusBar();
377 void FreezeCharts();
378 void ThawCharts();
379
380private:
381 void ProcessUnitTest();
382 void ProcessQuitFlag();
383 void ProcessDeferredTrackOn();
384 void SendFixToPlugins();
385 void ProcessAnchorWatch();
386 void ProcessLogAndBells();
387 void CalculateCOGAverage();
388 void CheckToolbarPosition();
389
390 void ODoSetSize(void);
391 void DoCOGSet(void);
392
393 void UpdateAllToolbars(ColorScheme cs);
394
395 void FilterCogSog(void);
396
397 void ApplyGlobalColorSchemetoStatusBar(void);
398
399 bool ScrubGroupArray();
400
401 void OnToolbarAnimateTimer(wxTimerEvent& event);
402 bool CollapseGlobalToolbar();
403
404 int m_StatusBarFieldCount;
405
406 wxDateTime m_MMEAeventTime;
407 unsigned long m_ulLastNMEATicktime;
408 int m_tick_idx;
409 wxDateTime m_fix_start_time;
410
411 wxString m_last_reported_chart_name;
412 wxString m_last_reported_chart_pubdate;
413
414 wxString m_lastAISiconName;
415
416 // Plugin Support
417 int m_next_available_plugin_tool_id;
418
419 double COGFilterTable[MAX_COGSOG_FILTER_SECONDS];
420 double SOGFilterTable[MAX_COGSOG_FILTER_SECONDS];
421
422 int m_ChartUpdatePeriod;
423 bool m_last_bGPSValid;
424 bool m_last_bVelocityValid;
425 double m_last_hdt;
426
427 wxString prev_locale;
428
436 time_t m_fixtime;
437 bool b_autofind;
438
439 time_t m_last_track_rotation_ts;
440 wxTimer ToolbarAnimateTimer;
441 int m_nMasterToolCountShown;
442 wxTimer m_recaptureTimer;
443
444 std::unique_ptr<LoadErrorsDlgCtrl> m_load_errors_dlg_ctrl;
445
446private:
447 ObservableListener listener_basic_navdata;
448 ObservableListener listener_gps_watchdog;
449 ObsListener m_on_raise_listener;
450 ObsListener m_on_quit_listener;
451 ObsListener m_routes_update_listener;
452 ObsListener m_evt_drv_msg_listener;
453
454 ConnectionsDlg* m_connections_dlg;
455 bool m_need_new_options;
456 wxArrayString pathArray;
457 double restoreScale[4];
458 unsigned int last_canvasConfig;
459 DataMonitor* m_data_monitor;
460 wxAuiDefaultDockArt* m_pauidockart;
461
462 DECLARE_EVENT_TABLE()
463};
464
465#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.