OpenCPN Partial API docs
Loading...
Searching...
No Matches
wmm_pi.h
1/******************************************************************************
2 * $Id: wmm_pi.h,v 1.0 2011/02/26 01:54:37 nohal Exp $
3 *
4 * Project: OpenCPN
5 * Purpose: WMM Plugin
6 * Author: Pavel Kalian
7 *
8 ***************************************************************************
9 * Copyright (C) 2011 by Pavel Kalian *
10 * $EMAIL$ *
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 * This program is distributed in the hope that it will be useful, *
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20 * GNU General Public License for more details. *
21 * *
22 * You should have received a copy of the GNU General Public License *
23 * along with this program; if not, write to the *
24 * Free Software Foundation, Inc., *
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
26 ***************************************************************************
27 */
28
29#ifndef _WMMPI_H_
30#define _WMMPI_H_
31
32#include "wx/wxprec.h"
33
34#ifndef WX_PRECOMP
35#include "wx/wx.h"
36#endif // precompiled headers
37
38#include <wx/fileconf.h>
39
40#include "version.h"
41#include "wxWTranslateCatalog.h"
42
43#define MY_API_VERSION_MAJOR 1
44#define MY_API_VERSION_MINOR 8
45
46#include "ocpn_plugin.h"
47#include "pi_ocpndc.h"
48
49#include "GeomagnetismHeader.h"
50#include "EGM9615.h"
51#include "WmmUIDialog.h"
52#include "MagneticPlotMap.h"
53
54#include "jsonreader.h"
55#include "jsonwriter.h"
56
57//----------------------------------------------------------------------------------------------------------
58// The PlugIn Class Definition
59//----------------------------------------------------------------------------------------------------------
60
61#define WMM_TOOL_POSITION -1 // Request default positioning of toolbar tool
62class wmm_pi;
63class WmmPrefsDialog;
64
66public:
67 WmmUIDialog(wmm_pi &_wmm_pi, wxWindow *parent, wxWindowID id = wxID_ANY,
68 const wxString &title = _T("WMM"),
69 const wxPoint &pos = wxDefaultPosition,
70 const wxSize &size = wxSize(250, 495),
71 long style = wxCAPTION | wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL |
72 wxFRAME_FLOAT_ON_PARENT | wxFRAME_NO_TASKBAR)
73 : WmmUIDialogBase(parent, id, title, pos, size, style),
74 m_wmm_pi(_wmm_pi) {}
75
76 void EnablePlotChanged(wxCommandEvent &event);
77 void PlotSettings(wxCommandEvent &event);
78
79protected:
80 wmm_pi &m_wmm_pi;
81};
82
84public:
85 WmmPlotSettingsDialog(wxWindow *parent, wxWindowID id = wxID_ANY,
86 const wxString &title = _("Magnetic Plot Settings"),
87 const wxPoint &pos = wxDefaultPosition,
88 const wxSize &size = wxSize(375, 180),
89 long style = wxDEFAULT_DIALOG_STYLE)
90 : WmmPlotSettingsDialogBase(parent, id, title, pos, size, style) {}
91
92 void About(wxCommandEvent &event);
93 void Save(wxCommandEvent &event) { EndDialog(wxID_OK); }
94 void Cancel(wxCommandEvent &event) { EndDialog(wxID_CANCEL); }
95};
96
97class wmm_pi : public opencpn_plugin_18 {
98public:
99 wmm_pi(void *ppimgr);
100
101 // The required PlugIn Methods
102 int Init(void);
103 bool DeInit(void);
104
105 int GetAPIVersionMajor();
106 int GetAPIVersionMinor();
107 int GetPlugInVersionMajor();
108 int GetPlugInVersionMinor();
109 wxBitmap *GetPlugInBitmap();
110 wxString GetCommonName();
111 wxString GetShortDescription();
112 wxString GetLongDescription();
113
114 // The required override PlugIn Methods
115 void SetCursorLatLon(double lat, double lon);
116 void SetPositionFix(PlugIn_Position_Fix &pfix);
117
118 void RenderOverlayBoth(pi_ocpnDC *dc, PlugIn_ViewPort *vp);
119 bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp);
120 bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp);
121 void RecomputePlot();
122
123 int GetToolbarToolCount(void);
124 void ShowPreferencesDialog(wxWindow *parent);
125 void ShowPlotSettingsDialog(wxCommandEvent &event);
126
127 void OnToolbarToolCallback(int id);
128
129 // Optional plugin overrides
130 void SetColorScheme(PI_ColorScheme cs);
131 void SetPluginMessage(wxString &message_id, wxString &message_body);
132
133 void SetShowPlot(bool showplot) { m_bShowPlot = showplot; }
134
135 // Other public methods
136 void SetWmmDialogX(int x) { m_wmm_dialog_x = x; };
137 void SetWmmDialogY(int x) { m_wmm_dialog_y = x; }
138
139 void OnWmmDialogClose();
140 void ShowPlotSettings();
141
142 // WMM Declarations
143 MAGtype_MagneticModel *MagneticModels[1];
144 MAGtype_MagneticModel *MagneticModel, *TimedMagneticModel;
145 MAGtype_Ellipsoid Ellip;
146 MAGtype_CoordSpherical CoordSpherical;
147 MAGtype_CoordGeodetic CoordGeodetic;
148 MAGtype_Date UserDate;
149 MAGtype_GeoMagneticElements GeoMagneticElements;
150 MAGtype_Geoid Geoid;
151 wxString filename;
152
153 wxWindow *m_parent_window;
154 WmmUIDialog *m_pWmmDialog;
155
156 pi_ocpnDC *m_oDC;
157
158private:
159 wxFileConfig *m_pconfig;
160 bool LoadConfig(void);
161 bool SaveConfig(void);
162
163 int m_wmm_dialog_x, m_wmm_dialog_y;
164 int m_display_width, m_display_height;
165 int m_iViewType;
166 bool m_bShowPlotOptions;
167 bool m_bShowAtCursor;
168 bool m_bShowLiveIcon;
169 bool m_bShowIcon;
170 int m_iOpacity;
171
172 wxString m_LastVal;
173
174 int m_leftclick_tool_id;
175
176 wxString AngleToText(double angle);
177
178 bool m_bCachedPlotOk, m_bShowPlot;
179 MagneticPlotMap m_DeclinationMap, m_InclinationMap, m_FieldStrengthMap;
180 wxDateTime m_MapDate;
181 int m_MapStep;
182 int m_MapPoleAccuracy;
183
184 void RearrangeWindow();
185 void SetIconType();
186 wxString m_wmm_dir;
187 bool m_buseable, m_busegeoid;
188
189 void SendVariationAt(double lat, double lon, int year, int month, int day);
190 void SendBoatVariation();
191 void SendCursorVariation();
192
193 MAGtype_GeoMagneticElements m_cursorVariation;
194 MAGtype_GeoMagneticElements m_boatVariation;
195
196 bool m_bComputingPlot;
197 wxFont *pFontSmall;
198 double m_scale;
199 wxString m_shareLocn;
200};
201
202int WMM_setupMagneticModel(char *data, MAGtype_MagneticModel *MagneticModel);
203
204#endif
Class WmmPlotSettingsDialogBase.
Class WmmPrefsDialog.
Class WmmUIDialogBase.
Definition WmmUIDialog.h:38
void ShowPlotSettings()
Definition wmm_pi.cpp:907
wxBitmap * GetPlugInBitmap()
FIXME static wxBitmap* LoadSVG(const wxString filename, unsigned int width, ...
Definition wmm_pi.cpp:277
PlugIn Object Definition/API.