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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
36#ifndef _GRIBPI_H_
37#define _GRIBPI_H_
38
39#include "wx/wxprec.h"
40
41#ifndef WX_PRECOMP
42#include "wx/wx.h"
43#include <wx/glcanvas.h>
44#endif // precompiled headers
45
46#define PLUGIN_VERSION_MAJOR 5
47#define PLUGIN_VERSION_MINOR 0
48
49#define MY_API_VERSION_MAJOR 1
50#define MY_API_VERSION_MINOR 16
51
52#include "ocpn_plugin.h"
53
54#include "wx/jsonreader.h"
55#include "wx/jsonwriter.h"
56
57#include "GribSettingsDialog.h"
58#include "GribOverlayFactory.h"
59#include "GribUIDialog.h"
60
62
63//----------------------------------------------------------------------------------------------------------
64// The PlugIn Class Definition
65//----------------------------------------------------------------------------------------------------------
66
67#define GRIB_TOOL_POSITION -1 // Request default positioning of ToolBar tool
68#define STARTING_STATE_STYLE 9999 // style option undifined
69#define ATTACHED 0 // dialog are attached
70#define SEPARATED 1 // dialog are separated
71#define ATTACHED_HAS_CAPTION 0 // dialog attached has a caption
72#define ATTACHED_NO_CAPTION 1 // dialog attached don't have caption
73#define SEPARATED_HORIZONTAL 2 // dialog separated shown honrizontaly
74#define SEPARATED_VERTICAL 3 // dialog separated shown vaerticaly
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
89public:
90 grib_pi(void *ppimgr);
91 ~grib_pi(void);
92
93 // The required PlugIn Methods
94 int Init(void);
95 bool DeInit(void);
96
101 wxBitmap *GetPlugInBitmap();
102 wxString GetCommonName();
103 wxString GetShortDescription();
104 wxString GetLongDescription();
105
106 // The override PlugIn Methods
107 bool MouseEventHook(wxMouseEvent &event);
108 bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp);
109 bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex);
110 void SetCursorLatLon(double lat, double lon);
111 void OnContextMenuItemCallback(int id);
112 void SetPluginMessage(wxString &message_id, wxString &message_body);
113 bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp);
114 bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp,
115 int canvasIndex);
116 void SendTimelineMessage(wxDateTime time);
117 void SetDefaults(void);
118 int GetToolBarToolCount(void);
119 void ShowPreferencesDialog(wxWindow *parent);
120 void OnToolbarToolCallback(int id);
121 bool QualifyCtrlBarPosition(wxPoint position, wxSize size);
122 void MoveDialog(wxDialog *dialog, wxPoint position);
124
125 // Other public methods
126 void SetCtrlBarXY(wxPoint p) { m_CtrlBarxy = p; }
127 void SetCursorDataXY(wxPoint p) { m_CursorDataxy = p; }
128 void SetCtrlBarSizeXY(wxSize p) { m_CtrlBar_Sizexy = p; }
130 void SetDialogFont(wxWindow *window, wxFont *font = OCPNGetFont(_("Dialog")));
137 void SetCurrentViewPort(PlugIn_ViewPort &vp) { m_current_vp = vp; }
138 PlugIn_ViewPort &GetCurrentViewPort() { return m_current_vp; }
139
140 void OnGribCtrlBarClose();
141
142 wxPoint GetCtrlBarXY() { return m_CtrlBarxy; }
143 wxPoint GetCursorDataXY() { return m_CursorDataxy; }
144 int GetStartOptions() { return m_bStartOptions; }
151 bool GetCopyFirstCumRec() { return m_bCopyFirstCumRec; }
159 bool GetCopyMissWaveRec() { return m_bCopyMissWaveRec; }
160
161 GRIBOverlayFactory *m_pGRIBOverlayFactory;
162 GRIBOverlayFactory *GetGRIBOverlayFactory() { return m_pGRIBOverlayFactory; }
163
164 void UpdatePrefs(GribPreferencesDialog *Pref);
165
166 int m_MenuItem;
167 bool m_DialogStyleChanged;
168
169 wxSize m_coreToolbarSize;
170 wxPoint m_coreToolbarPosn;
171 bool m_bZoomToCenterAtInit;
172 wxString m_local_sources_catalog;
173 double m_boat_lat, m_boat_lon;
174 double m_boat_cog, m_boat_sog;
175 time_t m_boat_time;
176
177private:
178 bool LoadConfig(void);
179 bool SaveConfig(void);
180
181 bool DoRenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp,
182 int canvasIndex);
183 bool DoRenderOverlay(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex);
184
185 wxFileConfig *m_pconfig;
186 wxWindow *m_parent_window;
187
188 GRIBUICtrlBar *m_pGribCtrlBar;
189
190 int m_display_width, m_display_height;
191 int m_leftclick_tool_id;
192
193 wxPoint m_CtrlBarxy, m_CursorDataxy;
194 wxSize m_CtrlBar_Sizexy;
195
196 // Controls added to Preferences panel
197 wxCheckBox *m_pGRIBUseHiDef;
198 wxCheckBox *m_pGRIBUseGradualColors;
199
200 GribTimelineRecordSet *m_pLastTimelineSet;
201
202 // preference data
203 bool m_bGRIBUseHiDef;
204 bool m_bGRIBUseGradualColors;
205 bool m_bDrawBarbedArrowHead;
210 bool m_bCopyFirstCumRec;
215 bool m_bCopyMissWaveRec;
216 int m_bLoadLastOpenFile;
217 int m_bStartOptions;
218 wxString m_RequestConfig;
219 wxString m_bMailToAddresses;
220 wxString m_bMailFromAddress;
221 wxString m_ZyGribLogin;
222 wxString m_ZyGribCode;
223 double m_GUIScaleFactor;
224#ifdef __WXMSW__
225 double m_GribIconsScaleFactor;
226#endif
227 bool m_bGRIBShowIcon;
228
229 bool m_bShowGrib;
236 PlugIn_ViewPort m_current_vp;
237 wxBitmap m_panelBitmap;
238};
239
240//----------------------------------------------------------------------------------------
241// Preference dialog definition
242//----------------------------------------------------------------------------------------
243
245public:
246 GribPreferencesDialog(wxWindow *pparent)
247 : GribPreferencesDialogBase(pparent) {}
249
250 void OnOKClick(wxCommandEvent &event);
251
252private:
253 void OnStartOptionChange(wxCommandEvent &event);
254};
255#endif
GRIB Data Visualization and Rendering Factory.
GRIB Display Settings Configuration Interface.
GRIB Weather Data Control Interface.
Factory class for creating and managing GRIB data visualizations.
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.
void SetCursorLatLon(double lat, double lon)
Receives cursor lat/lon position updates.
Definition grib_pi.cpp:613
bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp)
Renders plugin overlay graphics in OpenGL mode.
Definition grib_pi.cpp:571
wxString GetCommonName()
Get the plugin's common (short) name.
Definition grib_pi.cpp:197
bool DeInit(void)
Clean up plugin resources.
Definition grib_pi.cpp:174
void OnContextMenuItemCallback(int id)
Handles context menu item selection.
Definition grib_pi.cpp:618
int Init(void)
Initialize the plugin and declare its capabilities.
Definition grib_pi.cpp:99
void SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix)
Updates plugin with extended position fix data.
Definition grib_pi.cpp:861
int GetAPIVersionMinor()
Returns the minor version number of the plugin API that this plugin supports.
Definition grib_pi.cpp:189
void SetCurrentViewPort(PlugIn_ViewPort &vp)
Callback invoked by OpenCPN core whenever the current ViewPort changes or through periodic updates.
Definition grib_pi.h:137
int GetPlugInVersionMinor()
Returns the minor version number of the plugin itself.
Definition grib_pi.cpp:193
void SetColorScheme(PI_ColorScheme cs)
Updates plugin color scheme.
Definition grib_pi.cpp:826
void OnToolbarToolCallback(int id)
Handles toolbar tool clicks.
Definition grib_pi.cpp:417
int GetPlugInVersionMajor()
Returns the major version number of the plugin itself.
Definition grib_pi.cpp:191
bool MouseEventHook(wxMouseEvent &event)
Handles mouse events from chart window.
Definition grib_pi.cpp:224
bool GetCopyFirstCumRec()
Returns true if cumulative parameters like precipitation and cloud cover should initialize their star...
Definition grib_pi.h:151
wxString GetShortDescription()
Get a brief description of the plugin.
Definition grib_pi.cpp:199
void ShowPreferencesDialog(wxWindow *parent)
Shows the plugin preferences dialog.
Definition grib_pi.cpp:230
void SetDefaults(void)
Sets plugin default options.
Definition grib_pi.cpp:220
wxBitmap * GetPlugInBitmap()
Get the plugin's icon bitmap.
Definition grib_pi.cpp:195
bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex)
Renders plugin overlay graphics with canvas selection.
Definition grib_pi.cpp:608
bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvasIndex)
Renders plugin overlay graphics in OpenGL mode with canvas selection.
Definition grib_pi.cpp:603
wxString GetLongDescription()
Get detailed plugin information.
Definition grib_pi.cpp:201
bool GetCopyMissWaveRec()
Returns true if wave data should be propagated across time periods where wave records are missing.
Definition grib_pi.h:159
int GetAPIVersionMajor()
Returns the major version number of the plugin API that this plugin supports.
Definition grib_pi.cpp:187
PlugIn Object Definition/API.
PI_ColorScheme
Enumeration of color schemes.
wxFont * OCPNGetFont(wxString TextElement, int default_size)
Gets a font for UI elements.