OpenCPN Partial API docs
Loading...
Searching...
No Matches
wmm_pi.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2011 by Pavel Kalian *
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 WMMPI_H_
25#define WMMPI_H_
26
27#include <wx/wxprec.h>
28
29#ifndef WX_PRECOMP
30#include <wx/wx.h>
31#endif
32
33#include <wx/fileconf.h>
34
35#include "version.h"
36#include "ocpn_plugin.h"
37
38#include "EGM9615.h"
39#include "GeomagnetismHeader.h"
40#include "jsonreader.h"
41#include "jsonwriter.h"
42#include "magnetic_plot_map.h"
43#include "pi_ocpndc.h"
44#include "wmm_ui_dialog.h"
45#include "wxWTranslateCatalog.h"
46
47#define MY_API_VERSION_MAJOR 1
48#define MY_API_VERSION_MINOR 9
49
50#define WMM_TOOL_POSITION -1 // Request default positioning of toolbar tool
51
52//-----------------------------------------------------------------------------------
53// The PlugIn Class Definition
54//-----------------------------------------------------------------------------------
55
56class WmmPi;
57class WmmPrefsDialog;
58
60public:
61 WmmUIDialog(WmmPi &_wmm_pi, wxWindow *parent, wxWindowID id = wxID_ANY,
62 const wxString &title = "WMM",
63 const wxPoint &pos = wxDefaultPosition,
64 const wxSize &size = wxSize(250, 495),
65 long style = wxCAPTION | wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL |
66 wxFRAME_FLOAT_ON_PARENT | wxFRAME_NO_TASKBAR)
67 : WmmUIDialogBase(parent, id, title, pos, size, style),
68 m_wmm_pi(_wmm_pi) {}
69
70protected:
71 WmmPi &m_wmm_pi;
72 void EnablePlotChanged(wxCommandEvent &event) override;
73 void PlotSettings(wxCommandEvent &event) override;
74};
75
77public:
78 WmmPlotSettingsDialog(wxWindow *parent, wxWindowID id = wxID_ANY,
79 const wxString &title = _("Magnetic Plot Settings"),
80 const wxPoint &pos = wxDefaultPosition,
81 const wxSize &size = wxSize(375, 180),
82 long style = wxDEFAULT_DIALOG_STYLE)
83 : WmmPlotSettingsDialogBase(parent, id, title, pos, size, style) {}
84
85protected:
86 void About(wxCommandEvent &event) override;
87 void Save(wxCommandEvent &event) override { EndDialog(wxID_OK); }
88 void Cancel(wxCommandEvent &event) override { EndDialog(wxID_CANCEL); }
89};
90
91class WmmPi : public wxEvtHandler, public opencpn_plugin_118 {
92public:
93 WmmPi(void *ppimgr);
94
95 // The required PlugIn Methods
96 int Init() override;
97 bool DeInit() override;
98
99 int GetAPIVersionMajor() override;
100 int GetAPIVersionMinor() override;
101 int GetPlugInVersionMajor() override;
102 int GetPlugInVersionMinor() override;
103 wxBitmap *GetPlugInBitmap() override;
104 wxString GetCommonName() override;
105 wxString GetShortDescription() override;
106 wxString GetLongDescription() override;
107
108 // The required override PlugIn Methods
109 void SetCursorLatLon(double lat, double lon) override;
110 void SetPositionFix(PlugIn_Position_Fix &pfix) override;
111
112 void RenderOverlayBoth(pi_ocpnDC *dc, PlugIn_ViewPort *vp);
113 bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp) override;
114 bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp) override;
115 void RecomputePlot();
116
117 int GetToolbarToolCount() override;
118 void ShowPreferencesDialog(wxWindow *parent) override;
119
120 void OnToolbarToolCallback(int id) override;
121
122 // Optional plugin overrides
123 void SetColorScheme(PI_ColorScheme cs) override;
124 void SetPluginMessage(wxString &message_id, wxString &message_body) override;
125
126 void SetShowPlot(bool showplot) { m_bShowPlot = showplot; }
127
128 // Other public methods
129 void SetWmmDialogX(int x) { m_wmm_dialog_x = x; };
130 void SetWmmDialogY(int x) { m_wmm_dialog_y = x; }
131
132 void ShowPlotSettings();
133
134 // WMM Declarations
135 MAGtype_MagneticModel *MagneticModels[1];
136 MAGtype_MagneticModel *MagneticModel, *TimedMagneticModel;
137 MAGtype_Ellipsoid Ellip;
138 MAGtype_CoordSpherical CoordSpherical;
139 MAGtype_CoordGeodetic CoordGeodetic;
140 MAGtype_Date UserDate;
141 MAGtype_GeoMagneticElements GeoMagneticElements;
142 MAGtype_Geoid Geoid;
143 wxString filename;
144
145 wxWindow *m_parent_window;
146 WmmUIDialog *m_pWmmDialog;
147
148 pi_ocpnDC *m_oDC;
149
150private:
151 wxFileConfig *m_pconfig;
152 bool LoadConfig();
153 bool SaveConfig();
154
155 int m_wmm_dialog_x, m_wmm_dialog_y;
156 int m_display_width, m_display_height;
157 int m_iViewType;
158 bool m_bShowPlotOptions;
159 bool m_bShowAtCursor;
160 bool m_bShowLiveIcon;
161 bool m_bShowIcon;
162 int m_iOpacity;
163
164 wxString m_LastVal;
165
166 int m_leftclick_tool_id;
167
168 wxString AngleToText(double angle);
169
170 bool m_bCachedPlotOk, m_bShowPlot;
171 MagneticPlotMap m_DeclinationMap, m_InclinationMap, m_FieldStrengthMap;
172 wxDateTime m_MapDate;
173 int m_MapStep;
174 int m_MapPoleAccuracy;
175
176 void RearrangeWindow();
177 void SetIconType();
178 wxString m_wmm_dir;
179 bool m_buseable, m_busegeoid;
180
181 void SendVariationAt(double lat, double lon, int year, int month, int day);
182 void SendBoatVariation();
183 void SendCursorVariation();
184 void SendBoatVarHVD(double d_var); // send variation to NMEA handler
185 void SendPGN127258(double d_var); // send variation via N2k
186 [[nodiscard]] unsigned char ComputeChecksum(wxString sentence) const;
187
188 MAGtype_GeoMagneticElements m_cursorVariation;
189 MAGtype_GeoMagneticElements m_boatVariation;
190
191 bool m_bComputingPlot;
192 wxFont *pFontSmall;
193 double m_scale;
194 wxString m_shareLocn;
195
196 DriverHandle m_handleN2k;
197};
198
199int WMM_setupMagneticModel(char *data, MAGtype_MagneticModel *MagneticModel);
200
201#endif // WMMPI_H_
Geomagnetism Library subroutines.
The OpenCPN About dialog displaying information including version, authors, license,...
Definition about.h:61
Basic position fix information.
Contains view parameters and status information for a chart display viewport.
Definition wmm_pi.h:91
int GetAPIVersionMinor() override
Returns the minor version number of the plugin API that this plugin supports.
Definition wmm_pi.cpp:287
wxString GetShortDescription() override
Get a brief description of the plugin.
Definition wmm_pi.cpp:297
int GetPlugInVersionMajor() override
Returns the major version number of the plugin itself.
Definition wmm_pi.cpp:289
void ShowPlotSettings()
Definition wmm_pi.cpp:924
wxString GetLongDescription() override
Get detailed plugin information.
Definition wmm_pi.cpp:301
bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp) override
Renders plugin overlay graphics in OpenGL mode for single canvas.
Definition wmm_pi.cpp:430
int Init() override
Initialize the plugin and declare its capabilities.
Definition wmm_pi.cpp:128
void ShowPreferencesDialog(wxWindow *parent) override
Shows the plugin preferences dialog.
Definition wmm_pi.cpp:894
void SetCursorLatLon(double lat, double lon) override
Receives cursor lat/lon position updates.
Definition wmm_pi.cpp:486
int GetAPIVersionMajor() override
Returns the major version number of the plugin API that this plugin supports.
Definition wmm_pi.cpp:285
bool DeInit() override
Clean up plugin resources.
Definition wmm_pi.cpp:251
void OnToolbarToolCallback(int id) override
Handles toolbar tool clicks.
Definition wmm_pi.cpp:378
void SetColorScheme(PI_ColorScheme cs) override
Updates plugin color scheme.
Definition wmm_pi.cpp:315
wxBitmap * GetPlugInBitmap() override
Get the plugin's icon bitmap.
Definition wmm_pi.cpp:293
int GetPlugInVersionMinor() override
Returns the minor version number of the plugin itself.
Definition wmm_pi.cpp:291
wxString GetCommonName() override
Get the plugin's common (short) name.
Definition wmm_pi.cpp:295
void SetPositionFix(PlugIn_Position_Fix &pfix) override
Updates plugin with current position fix data at regular intervals.
Definition wmm_pi.cpp:543
int GetToolbarToolCount() override
Returns the number of toolbar tools this plugin provides.
Definition wmm_pi.cpp:313
Class WmmPlotSettingsDialogBase.
Class WmmPrefsDialog.
Class WmmUIDialogBase.
WMM plugin magnetic plotmap utility.
PlugIn Object Definition/API.
PI_ColorScheme
Color schemes for different lighting conditions.
std::string DriverHandle
Plugin API supporting direct access to comm drivers for output purposes.
Graphics abstraction layer on top of wxDC or OpenGL.