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 "ocpn_types.h"
38#include "ocpn_print.h"
39#include "color_handler.h"
40#include "gui_lib.h"
41#include "s52s57.h"
42#include "SencManager.h"
43#include "comm_appmsg_bus.h"
44#include "bbox.h"
45
46wxColour GetGlobalColor(wxString colorName);
47wxColour GetDialogColor(DialogColor color);
48
49int GetApplicationMemoryUse(void);
50
51// Helper to create menu label + hotkey string when registering menus
52wxString _menuText(wxString name, wxString shortcut);
53
54// The point for anchor watch should really be a class...
55double AnchorDistFix(double const d, double const AnchorPointMinDist,
56 double const AnchorPointMaxDist); // pjotrc 2010.02.22
57
58bool TestGLCanvas(wxString prog_dir);
59bool ReloadLocale();
60void ApplyLocale(void);
61
62void LoadS57();
63
64
65// Fwd definitions
66class ChartCanvas;
68class OCPN_MsgEvent;
69class options;
70class Track;
71//class OCPN_ThreadMessageEvent;
72class wxHtmlWindow;
73class ArrayOfCDI;
74
75//----------------------------------------------------------------------------
76// constants
77//----------------------------------------------------------------------------
78
79#define TIMER_GFRAME_1 999
80
81#define ID_QUIT 101
82#define ID_CM93ZOOMG 102
83
84
85
86// Command identifiers for wxCommandEvents coming from the outside world.
87// Removed from enum to facilitate constant definition
88#define ID_CMD_APPLY_SETTINGS 300
89#define ID_CMD_NULL_REFRESH 301
90#define ID_CMD_TRIGGER_RESIZE 302
91#define ID_CMD_SETVP 303
92#define ID_CMD_POST_JSON_TO_PLUGINS 304
93#define ID_CMD_SET_LOCALE 305
94#define ID_CMD_SOUND_FINISHED 306
95
96#define N_STATUS_BAR_FIELDS_MAX 20
97
98#ifdef __OCPN__ANDROID__
99#define STAT_FIELD_COUNT 2
100#define STAT_FIELD_TICK -1
101#define STAT_FIELD_SOGCOG 0
102#define STAT_FIELD_CURSOR_LL -1
103#define STAT_FIELD_CURSOR_BRGRNG -1
104#define STAT_FIELD_SCALE 1
105#else
106#define STAT_FIELD_COUNT 5
107#define STAT_FIELD_TICK 0
108#define STAT_FIELD_SOGCOG 1
109#define STAT_FIELD_CURSOR_LL 2
110#define STAT_FIELD_CURSOR_BRGRNG 3
111#define STAT_FIELD_SCALE 4
112#endif
113
114// Define a constant GPS signal watchdog timeout value
115#define GPS_TIMEOUT_SECONDS 10
116
117// Define a timer value for Tide/Current updates
118// Note that the underlying data algorithms produce fresh data only every 15
119// minutes So maybe 5 minute updates should provide sufficient oversampling
120#define TIMER_TC_VALUE_SECONDS 300
121
122#define MAX_COG_AVERAGE_SECONDS 60
123#define MAX_COGSOG_FILTER_SECONDS 60
124//----------------------------------------------------------------------------
125// fwd class declarations
126//----------------------------------------------------------------------------
127class ChartBase;
128class wxSocketEvent;
130class OCPN_DataStreamEvent;
131class OCPN_SignalKEvent;
132class DataStream;
133class AisTargetData;
134
135bool isSingleChart(ChartBase *chart);
136
137class OCPN_ThreadMessageEvent : public wxEvent {
138public:
139 OCPN_ThreadMessageEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
141
142 // accessors
143 void SetSString(std::string string) { m_string = string; }
144 std::string GetSString() { return m_string; }
145
146 // required for sending with wxPostEvent()
147 wxEvent *Clone() const;
148
149private:
150 std::string m_string;
151};
152
153class MyFrame : public wxFrame {
154 friend class SignalKEventHandler;
155
156public:
157 MyFrame(wxFrame *frame, const wxString &title, const wxPoint &pos,
158 const wxSize &size, long style);
159
160 ~MyFrame();
161
162 int GetApplicationMemoryUse(void);
163
164 void OnEraseBackground(wxEraseEvent &event);
165 void OnMaximize(wxMaximizeEvent &event);
166 void OnCloseWindow(wxCloseEvent &event);
167 void OnExit(wxCommandEvent &event);
168 void OnSize(wxSizeEvent &event);
169 void OnMove(wxMoveEvent &event);
170 void OnInitTimer(wxTimerEvent &event);
171 void OnFrameTimer1(wxTimerEvent &event);
172 bool DoChartUpdate(void);
173 void OnEvtTHREADMSG(OCPN_ThreadMessageEvent &event);
174 void OnEvtOCPN_NMEA(OCPN_DataStreamEvent &event);
175 void OnEvtOCPN_SignalK(OCPN_SignalKEvent &event);
176 void OnEvtOCPN_SIGNALK_Test(OCPN_SignalKEvent &event);
177 void OnEvtPlugInMessage(OCPN_MsgEvent &event);
178 void OnMemFootTimer(wxTimerEvent &event);
179 void OnRecaptureTimer(wxTimerEvent &event);
180 void OnSENCEvtThread(OCPN_BUILDSENC_ThreadEvent &event);
181 void OnIconize(wxIconizeEvent &event);
182 void OnBellsFinished(wxCommandEvent &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 ClearRouteTool();
196 void DoStackUp(ChartCanvas *cc);
197 void DoStackDown(ChartCanvas *cc);
198 void selectChartDisplay(int type, int family);
199 void applySettingsString(wxString settings);
200 void setStringVP(wxString VPS);
201 void InvalidateAllGL();
202 void RefreshAllCanvas(bool bErase = true);
203 void CancelAllMouseRoute();
204 void InvalidateAllQuilts();
205
206 void SetUpMode(ChartCanvas *cc, int mode);
207
208 wxMenuBar *GetMainMenuBar() { return m_pMenuBar; }
209
210 ChartCanvas *GetPrimaryCanvas();
211 ChartCanvas *GetFocusCanvas();
212
213 void DoStackDelta(ChartCanvas *cc, int direction);
214 void DoSettings(void);
215 void SwitchKBFocus(ChartCanvas *pCanvas);
216 ChartCanvas *GetCanvasUnderMouse();
217 int GetCanvasIndexUnderMouse();
218
219 bool DropMarker(bool atOwnShip = true);
220
221 void TriggerResize(wxSize sz);
222 void OnResizeTimer(wxTimerEvent &event);
223
224 void TriggerRecaptureTimer();
225 bool SetGlobalToolbarViz(bool viz);
226
227 void MouseEvent(wxMouseEvent &event);
228 void CenterView(ChartCanvas *cc, const LLBBox &bbox);
229
230 void JumpToPosition(ChartCanvas *cc, double lat, double lon, double scale);
231
232 void ProcessCanvasResize(void);
233
234 void BuildMenuBar(void);
235 void ApplyGlobalSettings(bool bnewtoolbar);
236 void RegisterGlobalMenuItems();
237 void UpdateGlobalMenuItems();
238 void UpdateGlobalMenuItems(ChartCanvas *cc);
239 int DoOptionsDialog();
240 bool ProcessOptionsDialog(int resultFlags, ArrayOfCDI *pNewDirArray);
241 void DoPrint(void);
242 void StopSockets(void);
243 void ResumeSockets(void);
244 void ToggleDataQuality(ChartCanvas *cc);
245 void TogglebFollow(ChartCanvas *cc);
246 void ToggleFullScreen();
247 void ToggleChartBar(ChartCanvas *cc);
248 void SetbFollow(ChartCanvas *cc);
249 void ClearbFollow(ChartCanvas *cc);
250 void ToggleChartOutlines(ChartCanvas *cc);
251 void ToggleENCText(ChartCanvas *cc);
252 void ToggleSoundings(ChartCanvas *cc);
253 void ToggleRocks(void);
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 ShowTides(bool bShow);
279 void ShowCurrents(bool bShow);
280
281 void SubmergeAllCanvasToolbars(void);
282 void SurfaceAllCanvasToolbars(void);
283 void ToggleAllToolbars(bool b_smooth = false);
284 void SetAllToolbarScale(void);
285 void SetGPSCompassScale(void);
286 void InvalidateAllCanvasUndo();
287
288 void RefreshGroupIndices(void);
289
290 double GetBestVPScale(ChartBase *pchart);
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);
305 double GetMag(double a, double lat, double lon);
306 bool SendJSON_WMM_Var_Request(double lat, double lon, wxDateTime date);
307
308 void DestroyPersistentDialogs();
309 void TouchAISActive(void);
310 void UpdateAISTool(void);
311
312 void ActivateAISMOBRoute(const AisTargetData *ptarget);
313 void UpdateAISMOBRoute(const AisTargetData *ptarget);
314
315 wxStatusBar *m_pStatusBar;
316 wxMenuBar *m_pMenuBar;
317 int nBlinkerTick;
318 bool m_bTimeIsSet;
319 bool m_bDateIsSet;
320
321 wxTimer InitTimer;
322 int m_iInitCount;
323 bool m_initializing;
324
325 wxTimer FrameTCTimer;
326 wxTimer FrameTimer1;
327 wxTimer FrameCOGTimer;
328 wxTimer MemFootTimer;
329 wxTimer m_resizeTimer;
330
331 int m_BellsToPlay;
332 wxTimer BellsTimer;
333
334 // PlugIn support
335 int GetNextToolbarToolId() { return m_next_available_plugin_tool_id; }
336 void RequestNewToolbarArgEvent(wxCommandEvent &WXUNUSED(event)) {
337 return RequestNewMasterToolbar();
338 }
339 void RequestNewToolbars(bool bforcenew = false);
340
341 void ActivateMOB(void);
342 void UpdateGPSCompassStatusBoxes(bool b_force_new = false);
343 void UpdateRotationState(double rotation);
344
345 bool UpdateChartDatabaseInplace(ArrayOfCDI &DirArray, bool b_force,
346 bool b_prog,
347 const wxString &ChartListFileName);
348
349 bool m_bdefer_resize;
350 wxSize m_defer_size;
351 wxSize m_newsize;
352 double COGTable[MAX_COG_AVERAGE_SECONDS];
353
354 void FastClose();
355 void SetChartUpdatePeriod();
356 void CreateCanvasLayout(bool b_useStoredSize = false);
357 void LoadHarmonics();
358 void ReloadAllVP();
359 void SetCanvasSizes(wxSize frameSize);
360
361 ocpnToolBarSimple *CreateMasterToolbar();
362 void RequestNewMasterToolbar(bool bforcenew = true);
363 bool CheckAndAddPlugInTool();
364 bool AddDefaultPositionPlugInTools();
365
366 void NotifyChildrenResize(void);
367 void UpdateCanvasConfigDescriptors();
368 void ScheduleSettingsDialog();
369 static void RebuildChartDatabase();
370 void PositionIENCToolbar();
371
372 void InitAppMsgBusListener();
373 void UpdateStatusBar(void);
374
375private:
376 void CheckToolbarPosition();
377 void ODoSetSize(void);
378 void DoCOGSet(void);
379
380 void UpdateAllToolbars(ColorScheme cs);
381
382 void FilterCogSog(void);
383
384 void ApplyGlobalColorSchemetoStatusBar(void);
385
386 bool ScrubGroupArray();
387 wxString GetGroupName(int igroup);
388
389 bool EvalPriority(const wxString &message, DataStream *pDS);
390 void SetAISDisplayStyle(ChartCanvas *cc, int StyleIndx);
391
392 bool GetMasterToolItemShow(int toolid);
393 void OnToolbarAnimateTimer(wxTimerEvent &event);
394 bool CollapseGlobalToolbar();
395
396 int m_StatusBarFieldCount;
397
398 wxDateTime m_MMEAeventTime;
399 unsigned long m_ulLastNMEATicktime;
400 int m_tick_idx;
401
402 wxString m_last_reported_chart_name;
403 wxString m_last_reported_chart_pubdate;
404
405 wxString m_lastAISiconName;
406
407 // Plugin Support
408 int m_next_available_plugin_tool_id;
409
410 double COGFilterTable[MAX_COGSOG_FILTER_SECONDS];
411 double SOGFilterTable[MAX_COGSOG_FILTER_SECONDS];
412
413 bool m_bpersistent_quilt;
414 int m_ChartUpdatePeriod;
415 bool m_last_bGPSValid;
416 bool m_last_bVelocityValid;
417
418 wxString prev_locale;
419 bool bPrevQuilt;
420 bool bPrevFullScreenQuilt;
421 bool bPrevOGL;
422
423 time_t m_fixtime;
424 wxMenu *piano_ctx_menu;
425 bool b_autofind;
426
427 time_t m_last_track_rotation_ts;
428 wxRect m_mainlast_tb_rect;
429 wxTimer ToolbarAnimateTimer;
430 int m_nMasterToolCountShown;
431 wxTimer m_recaptureTimer;
432 bool m_b_new_data;
433
434 ObservableListener listener_basic_navdata;
435 ObservableListener listener_gps_watchdog;
436
437 DECLARE_EVENT_TABLE()
438};
439
440
441#endif // _OFRAME_H
void OnFrameTimer1(wxTimerEvent &event)
void SurfaceAllCanvasToolbars(void)
Keeps listening over it's lifespan, removes itself on destruction.
Definition: observable.h:143
Definition: track.h:79
Definition: Quilt.cpp:864