33#include <wx/glcanvas.h>
36#include <wx/fileconf.h>
37#include <wx/stdpaths.h>
41#include "jsonwriter.h"
47double g_ContentScaleFactor;
55extern "C" DECL_EXP
void destroy_pi(
opencpn_plugin *p) {
delete p; }
57extern int m_DialogStyle;
81 wxFileName::GetPathSeparator() +
"grib_pi" +
82 wxFileName::GetPathSeparator() +
"data" +
83 wxFileName::GetPathSeparator();
84 wxImage panelIcon(shareLocn +
"grib_panel_icon.png");
86 m_panelBitmap = wxBitmap(panelIcon);
88 wxLogMessage(
" GRIB panel icon NOT loaded");
90 m_pLastTimelineSet =
nullptr;
92 m_GUIScaleFactor = -1.;
99 delete m_pLastTimelineSet;
106 m_CtrlBarxy = wxPoint(0, 0);
107 m_CursorDataxy = wxPoint(0, 0);
109 m_pGribCtrlBar =
nullptr;
110 m_pGRIBOverlayFactory =
nullptr;
112 ::wxDisplaySize(&m_display_width, &m_display_height);
114 m_DialogStyleChanged =
false;
126 g_ContentScaleFactor = m_parent_window->GetContentScaleFactor();
132 wxFileName::GetPathSeparator() +
"grib_pi" +
133 wxFileName::GetPathSeparator() +
"data" +
134 wxFileName::GetPathSeparator();
136 wxString local_grib_catalog =
"sources.json";
138 wxFileName::GetPathSeparator() +
"grib_pi";
139 if (!wxDirExists(data_path)) {
142 m_local_sources_catalog =
143 data_path + wxFileName::GetPathSeparator() + local_grib_catalog;
144 if (!wxFileExists(m_local_sources_catalog)) {
145 wxCopyFile(shareLocn + local_grib_catalog, m_local_sources_catalog);
147 if (m_bGRIBShowIcon) {
148 wxString normalIcon = shareLocn +
"grib.svg";
149 wxString toggledIcon = shareLocn +
"grib_toggled.svg";
150 wxString rolloverIcon = shareLocn +
"grib_rollover.svg";
160 wxLogMessage(normalIcon);
162 "", normalIcon, rolloverIcon, toggledIcon, wxITEM_CHECK, _(
"Grib"),
"",
163 nullptr, GRIB_TOOL_POSITION, 0,
this);
166 if (!QualifyCtrlBarPosition(m_CtrlBarxy, m_CtrlBar_Sizexy)) {
167 m_CtrlBarxy = wxPoint(20, 60);
168 m_CursorDataxy = wxPoint(20, 170);
179 SendTimelineMessage(wxInvalidDateTime);
181 if (m_pGribCtrlBar) {
182 m_pGribCtrlBar->Close();
183 delete m_pGribCtrlBar;
184 m_pGribCtrlBar =
nullptr;
187 delete m_pGRIBOverlayFactory;
188 m_pGRIBOverlayFactory =
nullptr;
209 "GRIB PlugIn for OpenCPN\n\
210Provides basic GRIB file overlay capabilities for several GRIB file types\n\
211and a request function to get GRIB files by eMail.\n\n\
212Supported GRIB data include:\n\
213- wind direction and speed (at 10 m)\n\
218- significant wave height and direction\n\
219- air surface temperature (at 2 m)\n\
220- sea surface temperature\n\
221- surface current direction and speed\n\
222- Convective Available Potential Energy (CAPE)\n\
223- wind, altitude, temperature and relative humidity at 300, 500, 700, 850 hPa.");
228int GribPi::GetToolBarToolCount() {
return 1; }
231 if ((m_pGribCtrlBar && m_pGribCtrlBar->pReq_Dialog))
242 Pref->m_cbUseHiDef->SetValue(m_bGRIBUseHiDef);
243 Pref->m_cbUseGradualColors->SetValue(m_bGRIBUseGradualColors);
244 Pref->m_cbDrawBarbedArrowHead->SetValue(m_bDrawBarbedArrowHead);
245 Pref->m_cZoomToCenterAtInit->SetValue(m_bZoomToCenterAtInit);
246 Pref->m_cbCopyFirstCumulativeRecord->SetValue(m_bCopyFirstCumRec);
247 Pref->m_cbCopyMissingWaveRecord->SetValue(m_bCopyMissWaveRec);
248 Pref->m_rbLoadOptions->SetSelection(m_bLoadLastOpenFile);
249 Pref->m_rbStartOptions->SetSelection(m_bStartOptions);
251 if (Pref->m_textDirectory) {
255 pConf->SetPath(
"/Directories");
256 pConf->Read(
"GRIBDirectory", &l_grib_dir);
257 Pref->m_grib_dir_sel = l_grib_dir;
258 Pref->m_textDirectory->ChangeValue(l_grib_dir);
263 int val = (m_GribIconsScaleFactor * 10.) - 10;
264 Pref->m_sIconSizeFactor->SetValue(val);
268 if (m_parent_window) {
269 int xmax = m_parent_window->GetSize().GetWidth();
270 int ymax = m_parent_window->GetParent()
273 Pref->SetSize(xmax, ymax);
281 int display_width, display_height;
282 wxDisplaySize(&display_width, &display_height);
285 if (display_height < 600) {
288 Pref->SetSize(wxSize(60 * char_width, canvas_size.x * 8 / 10));
289 Pref->CentreOnScreen();
292 Pref->SetSize(wxSize(60 * char_width, 32 * char_height));
300 m_bGRIBUseHiDef = Pref->m_cbUseHiDef->GetValue();
301 m_bGRIBUseGradualColors = Pref->m_cbUseGradualColors->GetValue();
302 m_bLoadLastOpenFile = Pref->m_rbLoadOptions->GetSelection();
303 m_bDrawBarbedArrowHead = Pref->m_cbDrawBarbedArrowHead->GetValue();
304 m_bZoomToCenterAtInit = Pref->m_cZoomToCenterAtInit->GetValue();
306 double val = Pref->m_sIconSizeFactor->GetValue();
307 m_GribIconsScaleFactor = 1. + (val / 10);
310 if (m_pGRIBOverlayFactory)
311 m_pGRIBOverlayFactory->SetSettings(m_bGRIBUseHiDef, m_bGRIBUseGradualColors,
312 m_bDrawBarbedArrowHead);
316 if (m_bStartOptions != Pref->m_rbStartOptions->GetSelection()) {
317 m_bStartOptions = Pref->m_rbStartOptions->GetSelection();
321 bool copyrec = Pref->m_cbCopyFirstCumulativeRecord->GetValue();
322 bool copywave = Pref->m_cbCopyMissingWaveRecord->GetValue();
323 if (m_bCopyFirstCumRec != copyrec || m_bCopyMissWaveRec != copywave) {
324 m_bCopyFirstCumRec = copyrec;
325 m_bCopyMissWaveRec = copywave;
329 if (m_pGribCtrlBar) {
330 switch (updatelevel) {
336 m_pGribCtrlBar->CreateActiveFileFromNames(
338 m_pGribCtrlBar->PopulateComboDataList();
339 m_pGribCtrlBar->TimelineChanged();
345 m_pGribCtrlBar->PopulateComboDataList();
346 m_pGribCtrlBar->TimelineChanged();
350 m_pGribCtrlBar->ComputeBestForecastForNow();
353 if (Pref->m_grib_dir_sel.Length()) {
354 m_pGribCtrlBar->
m_grib_dir = Pref->m_grib_dir_sel;
359 if (Pref->m_grib_dir_sel.Length()) {
362 pConf->SetPath(
"/Directories");
363 pConf->Write(
"GRIBDirectory", Pref->m_grib_dir_sel);
364 pConf->DeleteGroup(
"/Settings/GRIB/FileNames");
371bool GribPi::QualifyCtrlBarPosition(
374 bool b_reset_pos =
false;
379 RECT frame_title_rect;
380 frame_title_rect.left = position.x;
381 frame_title_rect.top = position.y;
382 frame_title_rect.right = position.x + size.x;
383 frame_title_rect.bottom = m_DialogStyle == ATTACHED_HAS_CAPTION
385 : position.y + size.y;
387 if (
nullptr == MonitorFromRect(&frame_title_rect, MONITOR_DEFAULTTONULL))
390 wxRect window_title_rect;
391 window_title_rect.x = position.x;
392 window_title_rect.y = position.y;
393 window_title_rect.width = size.x;
394 window_title_rect.height =
395 m_DialogStyle == ATTACHED_HAS_CAPTION ? 30 : size.y;
397 wxRect ClientRect = wxGetClientDisplayRect();
398 if (!ClientRect.Intersects(window_title_rect)) b_reset_pos =
true;
404void GribPi::MoveDialog(wxDialog *dialog, wxPoint position) {
406 wxApp *app = wxTheApp;
412 wxPoint p = frame->ScreenToClient(position);
415 if (p.x + dialog->GetSize().GetX() > frame->GetClientSize().GetX())
416 p.x = frame->GetClientSize().GetX() - dialog->GetSize().GetX();
417 if (p.y + dialog->GetSize().GetY() > frame->GetClientSize().GetY())
418 p.y = frame->GetClientSize().GetY() - dialog->GetSize().GetY();
423 dialog->Move(frame->ClientToScreen(p));
429 bool starting =
false;
431 double scale_factor =
434 scale_factor *= m_GribIconsScaleFactor;
436 if (scale_factor != m_GUIScaleFactor) starting =
true;
438 if (!m_pGribCtrlBar) {
440 long style = m_DialogStyle == ATTACHED_HAS_CAPTION
442 : wxBORDER_NONE | wxSYSTEM_MENU;
444 style |= wxSTAY_ON_TOP;
446 m_pGribCtrlBar =
new GRIBUICtrlBar(m_parent_window, wxID_ANY, wxEmptyString,
447 wxDefaultPosition, wxDefaultSize, style,
449 m_pGribCtrlBar->SetScaledBitmap(scale_factor);
451 auto *dummy =
new wxMenu(
"Plugin");
452 auto *table =
new wxMenuItem(dummy, wxID_ANY, wxString(_(
"Weather table")),
453 wxEmptyString, wxITEM_NORMAL);
465 m_pGRIBOverlayFactory->SetMessageFont();
466 m_pGRIBOverlayFactory->SetParentSize(m_display_width, m_display_height);
467 m_pGRIBOverlayFactory->SetSettings(m_bGRIBUseHiDef, m_bGRIBUseGradualColors,
468 m_bDrawBarbedArrowHead);
470 m_pGribCtrlBar->OpenFile(m_bLoadLastOpenFile == 0);
474 if (
id >= 0) m_bShowGrib = !m_bShowGrib;
477 if (m_bShowGrib ||
id < 0) {
479 if (!starting && m_bLoadLastOpenFile == 0) {
480 m_pGribCtrlBar->OpenFile(
true);
484 if (m_pGribCtrlBar->GetFont() != *
OCPNGetFont(_(
"Dialog"))) starting =
true;
486 m_pGRIBOverlayFactory->SetMessageFont();
487 SetDialogFont(m_pGribCtrlBar);
488 m_GUIScaleFactor = scale_factor;
489 m_pGribCtrlBar->SetScaledBitmap(m_GUIScaleFactor);
490 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
491 m_pGribCtrlBar->Refresh();
493 MoveDialog(m_pGribCtrlBar, GetCtrlBarXY());
494 if (m_DialogStyle >> 1 == SEPARATED) {
495 MoveDialog(m_pGribCtrlBar->GetCDataDialog(), GetCursorDataXY());
496 m_pGribCtrlBar->GetCDataDialog()->Show(m_pGribCtrlBar->m_CDataIsShown);
499 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
500 m_pGribCtrlBar->Refresh();
503 if (
id >= 0) m_pGribCtrlBar->Show();
506 ArrayOfGribRecordSets *rsa =
508 if (rsa->GetCount() > 1) {
511 if (rsa->GetCount() >= 1) {
522 if (m_pGribCtrlBar && m_bZoomToCenterAtInit) {
523 m_pGribCtrlBar->DoZoomToCenter();
528 m_pGribCtrlBar->Close();
531void GribPi::OnGribCtrlBarClose() {
535 m_pGribCtrlBar->Hide();
543 if (::wxIsBusy()) ::wxEndBusyCursor();
546 m_DialogStyleChanged =
true;
549 if (m_DialogStyleChanged) {
550 m_pGribCtrlBar->Destroy();
551 m_pGribCtrlBar =
nullptr;
552 m_DialogStyleChanged =
false;
556bool GribPi::RenderOverlay(wxDC &dc,
PlugIn_ViewPort *vp) {
return false; }
558bool GribPi::DoRenderOverlay(wxDC &dc,
PlugIn_ViewPort *vp,
int canvasIndex) {
559 if (!m_pGribCtrlBar || !m_pGribCtrlBar->IsShown() || !m_pGRIBOverlayFactory)
562 m_pGRIBOverlayFactory->RenderGribOverlay(dc, vp);
569 if (m_pGribCtrlBar->pReq_Dialog &&
571 m_pGribCtrlBar->pReq_Dialog->GetBoundingBoxCanvasIndex()) {
575 if (::wxIsBusy()) ::wxEndBusyCursor();
583bool GribPi::DoRenderGLOverlay(wxGLContext *pcontext,
PlugIn_ViewPort *vp,
585 if (!m_pGribCtrlBar || !m_pGribCtrlBar->IsShown() || !m_pGRIBOverlayFactory)
588 m_pGRIBOverlayFactory->RenderGLGribOverlay(pcontext, vp);
595 if (m_pGribCtrlBar->pReq_Dialog &&
597 m_pGribCtrlBar->pReq_Dialog->GetBoundingBoxCanvasIndex()) {
602 if (::wxIsBusy()) ::wxEndBusyCursor();
605 m_pGribCtrlBar->Raise();
613 return DoRenderGLOverlay(pcontext, vp, canvasIndex);
618 return DoRenderOverlay(dc, vp, canvasIndex);
622 if (m_pGribCtrlBar && m_pGribCtrlBar->IsShown())
623 m_pGribCtrlBar->SetCursorLatLon(lat, lon);
628 m_pGribCtrlBar->ContextMenuItemCallback(
id);
631void GribPi::SetDialogFont(wxWindow *dialog, wxFont *font) {
632 dialog->SetFont(*font);
633 wxWindowList list = dialog->GetChildren();
634 wxWindowListNode *node = list.GetFirst();
635 for (
size_t i = 0; i < list.GetCount(); i++) {
636 wxWindow *win = node->GetData();
638 node = node->GetNext();
644void GribPi::SetPluginMessage(wxString &message_id, wxString &message_body) {
645 if (message_id ==
"GRIB_VALUES_REQUEST") {
651 r.
Parse(message_body, &v);
657 wxDateTime time(v[
"Day"].AsInt(), (wxDateTime::Month)v[
"Month"].AsInt(),
658 v[
"Year"].AsInt(), v[
"Hour"].AsInt(), v[
"Minute"].AsInt(),
659 v[
"Second"].AsInt());
663 if (m_pGribCtrlBar) {
666 if (m_pGribCtrlBar->getTimeInterpolatedValues(
668 vkn != GRIB_NOTDEF) {
669 v[
"Type"] = wxString(
"Reply");
670 v[
"WIND SPEED"] = vkn;
679 if (m_pGribCtrlBar->getTimeInterpolatedValues(
682 vkn != GRIB_NOTDEF) {
683 v[
"Type"] = wxString(
"Reply");
684 v[
"CURRENT SPEED"] = vkn;
685 v[
"CURRENT DIR"] = ang;
687 v.
Remove(
"CURRENT SPEED");
692 double vkn = m_pGribCtrlBar->getTimeInterpolatedValue(
Idx_WIND_GUST,
694 if (vkn != GRIB_NOTDEF) {
695 v[
"Type"] = wxString(
"Reply");
701 double vkn = m_pGribCtrlBar->getTimeInterpolatedValue(
Idx_HTSIGW, lon,
703 if (vkn != GRIB_NOTDEF) {
704 v[
"Type"] = wxString(
"Reply");
715 }
else if (message_id ==
"GRIB_VERSION_REQUEST") {
724 }
else if (message_id ==
"GRIB_TIMELINE_REQUEST") {
726 SendTimelineMessage(m_pGribCtrlBar ? m_pGribCtrlBar->
TimelineTime()
727 : wxDateTime::Now());
728 }
else if (message_id ==
"GRIB_TIMELINE_RECORD_REQUEST") {
731 r.
Parse(message_body, &v);
732 wxDateTime time(v[
"Day"].AsInt(), (wxDateTime::Month)v[
"Month"].AsInt(),
733 v[
"Year"].AsInt(), v[
"Hour"].AsInt(), v[
"Minute"].AsInt(),
734 v[
"Second"].AsInt());
742 snprintf(ptr,
sizeof ptr,
"%p", set);
744 v[
"GribVersionMajor"] = PLUGIN_VERSION_MAJOR;
745 v[
"GribVersionMinor"] = PLUGIN_VERSION_MINOR;
746 v[
"TimelineSetPtr"] = wxString::From8BitData(ptr);
752 delete m_pLastTimelineSet;
753 m_pLastTimelineSet = set;
756 else if (message_id ==
"GRIB_APPLY_JSON_CONFIG") {
757 wxLogMessage(
"Got GRIB_APPLY_JSON_CONFIG");
759 if (m_pGribCtrlBar) {
760 m_pGribCtrlBar->OpenFileFromJSON(message_body);
764 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
769bool GribPi::LoadConfig() {
770 auto *pConf = (wxFileConfig *)m_pconfig;
772 if (!pConf)
return false;
774 pConf->SetPath(
"/PlugIns/GRIB");
775 pConf->Read(
"LoadLastOpenFile", &m_bLoadLastOpenFile, 0);
776 pConf->Read(
"OpenFileOption", &m_bStartOptions, 1);
777 pConf->Read(
"GRIBUseHiDef", &m_bGRIBUseHiDef,
false);
778 pConf->Read(
"GRIBUseGradualColors", &m_bGRIBUseGradualColors,
false);
779 pConf->Read(
"DrawBarbedArrowHead", &m_bDrawBarbedArrowHead,
true);
780 pConf->Read(
"ZoomToCenterAtInit", &m_bZoomToCenterAtInit,
true);
781 pConf->Read(
"ShowGRIBIcon", &m_bGRIBShowIcon,
true);
782 pConf->Read(
"CopyFirstCumulativeRecord", &m_bCopyFirstCumRec,
true);
783 pConf->Read(
"CopyMissingWaveRecord", &m_bCopyMissWaveRec,
true);
785 pConf->Read(
"GribIconsScaleFactor", &m_GribIconsScaleFactor, 1);
788 m_CtrlBar_Sizexy.x = pConf->Read(
"GRIBCtrlBarSizeX", 1400L);
789 m_CtrlBar_Sizexy.y = pConf->Read(
"GRIBCtrlBarSizeY", 800L);
790 m_CtrlBarxy.x = pConf->Read(
"GRIBCtrlBarPosX", 20L);
791 m_CtrlBarxy.y = pConf->Read(
"GRIBCtrlBarPosY", 60L);
792 m_CursorDataxy.x = pConf->Read(
"GRIBCursorDataPosX", 20L);
793 m_CursorDataxy.y = pConf->Read(
"GRIBCursorDataPosY", 170L);
795 pConf->Read(
"GribCursorDataDisplayStyle", &m_DialogStyle, 0);
796 if (m_DialogStyle > 3)
802bool GribPi::SaveConfig(
void) {
803 wxFileConfig *pConf = (wxFileConfig *)m_pconfig;
805 if (!pConf)
return false;
807 pConf->SetPath(
"/PlugIns/GRIB");
809 pConf->Write(
"LoadLastOpenFile", m_bLoadLastOpenFile);
810 pConf->Write(
"OpenFileOption", m_bStartOptions);
811 pConf->Write(
"ShowGRIBIcon", m_bGRIBShowIcon);
812 pConf->Write(
"GRIBUseHiDef", m_bGRIBUseHiDef);
813 pConf->Write(
"GRIBUseGradualColors", m_bGRIBUseGradualColors);
814 pConf->Write(
"CopyFirstCumulativeRecord", m_bCopyFirstCumRec);
815 pConf->Write(
"CopyMissingWaveRecord", m_bCopyMissWaveRec);
816 pConf->Write(
"DrawBarbedArrowHead", m_bDrawBarbedArrowHead);
817 pConf->Write(
"ZoomToCenterAtInit", m_bZoomToCenterAtInit);
819 pConf->Write(
"GribIconsScaleFactor", m_GribIconsScaleFactor);
822 pConf->Write(
"GRIBCtrlBarSizeX", m_CtrlBar_Sizexy.x);
823 pConf->Write(
"GRIBCtrlBarSizeY", m_CtrlBar_Sizexy.y);
824 pConf->Write(
"GRIBCtrlBarPosX", m_CtrlBarxy.x);
825 pConf->Write(
"GRIBCtrlBarPosY", m_CtrlBarxy.y);
826 pConf->Write(
"GRIBCursorDataPosX", m_CursorDataxy.x);
827 pConf->Write(
"GRIBCursorDataPosY", m_CursorDataxy.y);
834 if (m_pGribCtrlBar) {
835 if (m_pGRIBOverlayFactory) m_pGRIBOverlayFactory->ClearCachedLabel();
836 if (m_pGribCtrlBar->pReq_Dialog) m_pGribCtrlBar->pReq_Dialog->Refresh();
837 m_pGribCtrlBar->Refresh();
842void GribPi::SendTimelineMessage(wxDateTime time) {
843 if (!m_pGribCtrlBar)
return;
846 if (time.IsValid()) {
847 v[
"Day"] = time.GetDay();
848 v[
"Month"] = time.GetMonth();
849 v[
"Year"] = time.GetYear();
850 v[
"Hour"] = time.GetHour();
851 v[
"Minute"] = time.GetMinute();
852 v[
"Second"] = time.GetSecond();
868 m_boat_cog = pfix.
Cog;
869 m_boat_sog = pfix.
Sog;
870 m_boat_lat = pfix.
Lat;
871 m_boat_lon = pfix.
Lon;
875 m_boat_time = wxDateTime::Now().GetTicks();
882void GribPreferencesDialog::OnStartOptionChange(wxCommandEvent &event) {
883 if (m_rbStartOptions->GetSelection() == 2) {
886 _(
"You have chosen to authorize interpolation.\nDon't forget that data "
887 "displayed at current time will not be real but Recomputed\nThis can "
888 "decrease accuracy!"),
893void GribPreferencesDialog::OnOKClick(wxCommandEvent &event) {
894 if (g_pi) g_pi->UpdatePrefs(
this);
bool IsOK() const
Checks if file loading and parsing was successful.
wxArrayString & GetFileNames()
Gets the list of source filenames being used.
ArrayOfGribRecordSets * GetRecordSetArrayPtr()
Gets pointer to array of record sets organized by timestamp.
Factory class for creating and managing GRIB data visualizations.
void SetViewPortWithFocus(PlugIn_ViewPort *vp)
Set the ViewPort that has the focus.
GribOverlaySettings m_OverlaySettings
Settings that control how GRIB data is displayed and overlaid.
void SetViewPortUnderMouse(PlugIn_ViewPort *vp)
Set the ViewPort under the mouse.
wxString m_grib_dir
Directory containing GRIB files.
GRIBFile * m_bGRIBActiveFile
Currently active GRIB file being displayed.
wxDateTime TimelineTime()
Returns the selected time in the GRIB timeline widget.
wxArrayString m_file_names
List of GRIB filenames being displayed.
GribTimelineRecordSet * GetTimeLineRecordSet(wxDateTime time)
Retrieves or creates a temporally interpolated GRIB record set for a specific timestamp.
bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex) override
Renders plugin overlay graphics in standard DC mode for multi-canvas support.
void OnContextMenuItemCallback(int id) override
Handles context menu item selection.
bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvasIndex) override
Renders plugin overlay graphics in OpenGL mode for multi-canvas support.
void SetDefaults() override
Sets plugin default options.
void ShowPreferencesDialog(wxWindow *parent) override
Shows the plugin preferences dialog.
int GetPlugInVersionMajor() override
Returns the major version number of the plugin itself.
wxString GetShortDescription() override
Get a brief description of the plugin.
wxString GetLongDescription() override
Get detailed plugin information.
bool MouseEventHook(wxMouseEvent &event) override
Handles mouse events from chart window.
void SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix) override
Updates plugin with extended position fix data at regular intervals.
int GetAPIVersionMajor() override
Returns the major version number of the plugin API that this plugin supports.
int GetAPIVersionMinor() override
Returns the minor version number of the plugin API that this plugin supports.
bool DeInit() override
Clean up plugin resources.
void SetColorScheme(PI_ColorScheme cs) override
Updates plugin color scheme.
void OnToolbarToolCallback(int id) override
Handles toolbar tool clicks.
wxBitmap * GetPlugInBitmap() override
Get the plugin's icon bitmap.
void SetCursorLatLon(double lat, double lon) override
Receives cursor lat/lon position updates.
int Init() override
Initialize the plugin and declare its capabilities.
wxString GetCommonName() override
Get the plugin's common (short) name.
bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp) override
Renders plugin overlay graphics in OpenGL mode for single canvas.
int GetPlugInVersionMinor() override
Returns the minor version number of the plugin itself.
bool RenderGlZoneOverlay()
Renders the GRIB area selection overlay using OpenGL.
bool RenderZoneOverlay(wxDC &dc)
Renders the GRIB area selection overlay using standard device context.
bool MouseEventHook(wxMouseEvent &event)
Intercepts mouse events to handle GRIB area selection.
A specialized GribRecordSet that represents temporally interpolated weather data with isobar renderin...
Extended position fix information.
double Cog
Course over ground in degrees [0-360).
double Lat
Latitude in decimal degrees.
time_t FixTime
UTC time of fix.
double Lon
Longitude in decimal degrees.
double Sog
Speed over ground in knots.
Contains view parameters and status information for a chart display viewport.
Base class for OpenCPN plugins.
int Parse(const wxString &doc, wxJSONValue *val)
Parse the JSON document.
The JSON value class implementation.
bool Remove(int index)
Remove the item at the specified index or key.
bool HasMember(unsigned index) const
Return TRUE if the object contains an element at the specified index.
double AsDouble() const
Return the stored value as a double.
The JSON document writer.
void Write(const wxJSONValue &value, wxString &str)
Write the JSONvalue object to a JSON text.
GRIB Weather Data Plugin for OpenCPN.
@ Idx_WIND_GUST
Wind gust speed at surface in m/s.
@ Idx_WIND_VX
Surface wind velocity X component in m/s.
@ Idx_HTSIGW
Significant wave height in meters.
@ Idx_SEACURRENT_VY
Sea current velocity Y component in m/s.
@ Idx_WIND_VY
Surface wind velocity Y component in m/s.
@ Idx_SEACURRENT_VX
Sea current velocity X component in m/s.
#define WANTS_NMEA_EVENTS
Receive decoded NMEA events with parsed data.
PI_ColorScheme
Color schemes for different lighting conditions.
#define WANTS_ONPAINT_VIEWPORT
Receive callbacks during chart viewport painting.
#define WANTS_MOUSE_EVENTS
Receive mouse events (clicks, movement, etc).
#define WANTS_PREFERENCES
Plugin will add page(s) to global preferences dialog.
#define WANTS_CONFIG
Plugin requires persistent configuration storage.
#define WANTS_PLUGIN_MESSAGING
Enable message passing between plugins.
#define INSTALLS_TOOLBAR_TOOL
Plugin will add one or more toolbar buttons.
#define WANTS_CURSOR_LATLON
Receive updates when cursor moves over chart.
#define WANTS_TOOLBAR_CALLBACK
Receive notification when user left-clicks plugin's toolbar buttons.
#define WANTS_OVERLAY_CALLBACK
Receive callbacks to render custom overlay graphics on the chart.
wxWindow * PluginGetFocusCanvas()
Gets the currently focused chart canvas.
wxWindow * GetOCPNCanvasWindow()
Gets OpenCPN's main canvas window.
void SetCanvasContextMenuItemViz(int item, bool viz)
Temporarily changes context menu item visibility.
wxFont * OCPNGetFont(wxString TextElement, int default_size)
Gets a font for UI elements.
wxFileConfig * GetOCPNConfigObject()
Gets OpenCPN's configuration object.
int InsertPlugInToolSVG(wxString label, wxString SVGfile, wxString SVGfileRollover, wxString SVGfileToggled, wxItemKind kind, wxString shortHelp, wxString longHelp, wxObject *clientData, int position, int tool_sel, opencpn_plugin *pplugin)
Adds a tool using SVG graphics.
wxString * GetpSharedDataLocation()
Gets shared application data location.
void DimeWindow(wxWindow *win)
Applies system color scheme to window.
wxWindow * GetCanvasUnderMouse()
Gets canvas window under mouse cursor.
double GetOCPNGUIToolScaleFactor_PlugIn()
Gets current global GUI scaling factor.
int AddCanvasContextMenuItem(wxMenuItem *pitem, opencpn_plugin *pplugin)
Adds item to chart canvas context menu.
wxString GetActiveStyleName()
Gets name of currently active style sheet.
int GetCanvasIndexUnderMouse()
Gets index of chart canvas under mouse cursor.
void SetToolbarItemState(int item, bool toggle)
Sets toolbar item toggle state.
wxWindow * GetCanvasByIndex(int canvasIndex)
Gets chart canvas window by index.
double OCPN_GetWinDIPScaleFactor()
Gets Windows-specific DPI scaling factor.
void SendPluginMessage(wxString message_id, wxString message_body)
Sends message to other plugins.
void RequestRefresh(wxWindow *win)
Requests window refresh.
bool AddLocaleCatalog(wxString catalog)
Adds a locale catalog for translations.
OpenGL Platform Abstraction Layer.
wxString * GetpPrivateApplicationDataLocation()
Gets private application data directory.
int OCPNMessageBox_PlugIn(wxWindow *parent, const wxString &message, const wxString &caption, int style, int x, int y)
Shows a message box dialog.