OpenCPN Partial API docs
Loading...
Searching...
No Matches
grib_pi.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
37#ifndef GRIBPI_H_
38#define GRIBPI_H_
39
40#include <wx/wxprec.h>
41
42#ifndef WX_PRECOMP
43#include <wx/wx.h>
44#include <wx/glcanvas.h>
45#endif
46
47#include "jsonreader.h"
48#include "jsonwriter.h"
49
50#include "grib_settings_dlg.h"
52#include "grib_ui_dlg.h"
53#include "ocpn_plugin.h"
54
55#define PLUGIN_VERSION_MAJOR 5
56#define PLUGIN_VERSION_MINOR 0
57
58#define MY_API_VERSION_MAJOR 1
59#define MY_API_VERSION_MINOR 16
60
61//------------------------------------------------------------------------------
62// The PlugIn Class Definition
63//------------------------------------------------------------------------------
64
65#define GRIB_TOOL_POSITION (-1) // Request Toolbar tool default positioning
66#define STARTING_STATE_STYLE 9999 // style option undefined
67#define ATTACHED 0 // dialog are attached
68#define SEPARATED 1 // dialog are separated
69#define ATTACHED_HAS_CAPTION 0 // dialog attached has a caption
70#define ATTACHED_NO_CAPTION 1 // dialog attached don't have caption
71#define SEPARATED_HORIZONTAL 2 // dialog separated shown horizontally
72#define SEPARATED_VERTICAL 3 // dialog separated shown vertically
73
75
76enum SettingsDisplay {
77 B_ARROWS,
78 ISO_LINE,
79 ISO_ABBR,
80 ISO_LINE_SHORT,
81 ISO_LINE_VISI,
82 D_ARROWS,
83 OVERLAY,
84 NUMBERS,
85 PARTICLES
86};
87
88class GribPi : public opencpn_plugin_116 {
89public:
90 GribPi(void *ppimgr);
91 ~GribPi() override;
92
93 // The required PlugIn Methods
94 int Init() override;
95 bool DeInit() override;
96
97 int GetAPIVersionMajor() override;
98 int GetAPIVersionMinor() override;
99 int GetPlugInVersionMajor() override;
100 int GetPlugInVersionMinor() override;
101 wxBitmap *GetPlugInBitmap() override;
102 wxString GetCommonName() override;
103 wxString GetShortDescription() override;
104 wxString GetLongDescription() override;
105
106 // The override PlugIn Methods
107 bool MouseEventHook(wxMouseEvent &event) override;
108 bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp) override;
109 bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp,
110 int canvasIndex) override;
111 void SetCursorLatLon(double lat, double lon) override;
112 void OnContextMenuItemCallback(int id) override;
113 void SetPluginMessage(wxString &message_id, wxString &message_body) override;
114 bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp) override;
115 bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp,
116 int canvasIndex) override;
117 void SendTimelineMessage(wxDateTime time);
118 void SetDefaults() override;
119 int GetToolBarToolCount();
120 void ShowPreferencesDialog(wxWindow *parent) override;
121 void OnToolbarToolCallback(int id) override;
122 bool QualifyCtrlBarPosition(wxPoint position, wxSize size);
123 void MoveDialog(wxDialog *dialog, wxPoint position);
124 void SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix) override;
125
126 // Other public methods
127 void SetCtrlBarXY(wxPoint p) { m_CtrlBarxy = p; }
128 void SetCursorDataXY(wxPoint p) { m_CursorDataxy = p; }
129 void SetCtrlBarSizeXY(wxSize p) { m_CtrlBar_Sizexy = p; }
130 void SetColorScheme(PI_ColorScheme cs) override;
131 void SetDialogFont(wxWindow *window, wxFont *font = OCPNGetFont(_("Dialog")));
138 void SetCurrentViewPort(PlugIn_ViewPort &vp) override { m_current_vp = vp; }
139 PlugIn_ViewPort &GetCurrentViewPort() { return m_current_vp; }
140
141 void OnGribCtrlBarClose();
142
143 wxPoint GetCtrlBarXY() { return m_CtrlBarxy; }
144 wxPoint GetCursorDataXY() { return m_CursorDataxy; }
145 [[nodiscard]] int GetStartOptions() const { return m_bStartOptions; }
152 [[nodiscard]] bool GetCopyFirstCumRec() const { return m_bCopyFirstCumRec; }
160 [[nodiscard]] bool GetCopyMissWaveRec() const { return m_bCopyMissWaveRec; }
161
162 GRIBOverlayFactory *m_pGRIBOverlayFactory;
163 [[nodiscard]] GRIBOverlayFactory *GetGRIBOverlayFactory() const {
164 return m_pGRIBOverlayFactory;
165 }
166
167 void UpdatePrefs(GribPreferencesDialog *Pref);
168
169 int m_MenuItem;
170 bool m_DialogStyleChanged;
171
172 wxSize m_coreToolbarSize;
173 wxPoint m_coreToolbarPosn;
174 bool m_bZoomToCenterAtInit;
175 wxString m_local_sources_catalog;
176 double m_boat_lat, m_boat_lon;
177 double m_boat_cog, m_boat_sog;
178 time_t m_boat_time;
179
180private:
181 bool LoadConfig();
182 bool SaveConfig();
183
184 bool DoRenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp,
185 int canvasIndex);
186 bool DoRenderOverlay(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex);
187
188 wxFileConfig *m_pconfig;
189 wxWindow *m_parent_window;
190
191 GRIBUICtrlBar *m_pGribCtrlBar;
192
193 int m_display_width, m_display_height;
194 int m_leftclick_tool_id;
195
196 wxPoint m_CtrlBarxy, m_CursorDataxy;
197 wxSize m_CtrlBar_Sizexy;
198
199 // Controls added to Preferences panel
200 wxCheckBox *m_pGRIBUseHiDef;
201 wxCheckBox *m_pGRIBUseGradualColors;
202
203 GribTimelineRecordSet *m_pLastTimelineSet;
204
205 // preference data
206 bool m_bGRIBUseHiDef;
207 bool m_bGRIBUseGradualColors;
208 bool m_bDrawBarbedArrowHead;
213 bool m_bCopyFirstCumRec;
218 bool m_bCopyMissWaveRec;
219 int m_bLoadLastOpenFile;
220 int m_bStartOptions;
221 wxString m_RequestConfig;
222 wxString m_bMailToAddresses;
223 wxString m_bMailFromAddress;
224 wxString m_ZyGribLogin;
225 wxString m_ZyGribCode;
226 double m_GUIScaleFactor;
227#ifdef __WXMSW__
228 double m_GribIconsScaleFactor;
229#endif
230 bool m_bGRIBShowIcon;
231
232 bool m_bShowGrib;
239 PlugIn_ViewPort m_current_vp;
240 wxBitmap m_panelBitmap;
241};
242
243//----------------------------------------------------------------------------------------
244// Preference dialog definition
245//----------------------------------------------------------------------------------------
246
248public:
249 GribPreferencesDialog(wxWindow *pparent)
250 : GribPreferencesDialogBase(pparent) {}
251 ~GribPreferencesDialog() override = default;
252
253protected:
254 void OnOKClick(wxCommandEvent &event) override;
255
256private:
257 void OnStartOptionChange(wxCommandEvent &event) override;
258};
259#endif // GRIBPI_H_
Factory class for creating and managing GRIB data visualizations.
bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex) override
Renders plugin overlay graphics in standard DC mode for multi-canvas support.
Definition grib_pi.cpp:616
void OnContextMenuItemCallback(int id) override
Handles context menu item selection.
Definition grib_pi.cpp:626
bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvasIndex) override
Renders plugin overlay graphics in OpenGL mode for multi-canvas support.
Definition grib_pi.cpp:611
void SetDefaults() override
Sets plugin default options.
Definition grib_pi.cpp:226
void ShowPreferencesDialog(wxWindow *parent) override
Shows the plugin preferences dialog.
Definition grib_pi.cpp:236
int GetPlugInVersionMajor() override
Returns the major version number of the plugin itself.
Definition grib_pi.cpp:197
bool GetCopyFirstCumRec() const
Returns true if cumulative parameters like precipitation and cloud cover should initialize their star...
Definition grib_pi.h:152
wxString GetShortDescription() override
Get a brief description of the plugin.
Definition grib_pi.cpp:205
wxString GetLongDescription() override
Get detailed plugin information.
Definition grib_pi.cpp:207
bool MouseEventHook(wxMouseEvent &event) override
Handles mouse events from chart window.
Definition grib_pi.cpp:230
void SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix) override
Updates plugin with extended position fix data at regular intervals.
Definition grib_pi.cpp:867
int GetAPIVersionMajor() override
Returns the major version number of the plugin API that this plugin supports.
Definition grib_pi.cpp:193
bool GetCopyMissWaveRec() const
Returns true if wave data should be propagated across time periods where wave records are missing.
Definition grib_pi.h:160
int GetAPIVersionMinor() override
Returns the minor version number of the plugin API that this plugin supports.
Definition grib_pi.cpp:195
bool DeInit() override
Clean up plugin resources.
Definition grib_pi.cpp:177
void SetColorScheme(PI_ColorScheme cs) override
Updates plugin color scheme.
Definition grib_pi.cpp:832
void OnToolbarToolCallback(int id) override
Handles toolbar tool clicks.
Definition grib_pi.cpp:426
wxBitmap * GetPlugInBitmap() override
Get the plugin's icon bitmap.
Definition grib_pi.cpp:201
void SetCursorLatLon(double lat, double lon) override
Receives cursor lat/lon position updates.
Definition grib_pi.cpp:621
int Init() override
Initialize the plugin and declare its capabilities.
Definition grib_pi.cpp:102
wxString GetCommonName() override
Get the plugin's common (short) name.
Definition grib_pi.cpp:203
bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp) override
Renders plugin overlay graphics in OpenGL mode for single canvas.
Definition grib_pi.cpp:579
int GetPlugInVersionMinor() override
Returns the minor version number of the plugin itself.
Definition grib_pi.cpp:199
void SetCurrentViewPort(PlugIn_ViewPort &vp) override
Callback invoked by OpenCPN core whenever the current ViewPort changes or through periodic updates.
Definition grib_pi.h:138
Class GribPreferencesDialogBase.
A specialized GribRecordSet that represents temporally interpolated weather data with isobar renderin...
Extended position fix information.
Contains view parameters and status information for a chart display viewport.
GRIB Data Visualization and Rendering Factory.
GRIB Display Settings Configuration Interface.
GRIB Weather Data Control Interface.
PlugIn Object Definition/API.
PI_ColorScheme
Color schemes for different lighting conditions.
wxFont * OCPNGetFont(wxString TextElement, int default_size)
Gets a font for UI elements.