31#include <wx/glcanvas.h>
35#include <wx/fileconf.h>
36#include <wx/stdpaths.h>
44double g_ContentScaleFactor;
52extern "C" DECL_EXP
void destroy_pi(
opencpn_plugin *p) {
delete p; }
54extern int m_DialogStyle;
78 wxFileName::GetPathSeparator() + _T(
"grib_pi") +
79 wxFileName::GetPathSeparator() + _T(
"data") +
80 wxFileName::GetPathSeparator();
81 wxImage panelIcon(shareLocn + _T(
"grib_panel_icon.png"));
83 m_panelBitmap = wxBitmap(panelIcon);
85 wxLogMessage(_T(
" GRIB panel icon NOT loaded"));
87 m_pLastTimelineSet =
nullptr;
89 m_GUIScaleFactor = -1.;
93grib_pi::~grib_pi(
void) {
96 delete m_pLastTimelineSet;
103 m_CtrlBarxy = wxPoint(0, 0);
104 m_CursorDataxy = wxPoint(0, 0);
106 m_pGribCtrlBar =
nullptr;
107 m_pGRIBOverlayFactory =
nullptr;
109 ::wxDisplaySize(&m_display_width, &m_display_height);
111 m_DialogStyleChanged =
false;
123 g_ContentScaleFactor = m_parent_window->GetContentScaleFactor();
129 wxFileName::GetPathSeparator() + _T(
"grib_pi") +
130 wxFileName::GetPathSeparator() + _T(
"data") +
131 wxFileName::GetPathSeparator();
133 wxString local_grib_catalog =
"sources.json";
135 wxFileName::GetPathSeparator() +
"grib_pi";
136 if (!wxDirExists(data_path)) {
139 m_local_sources_catalog =
140 data_path + wxFileName::GetPathSeparator() + local_grib_catalog;
141 if (!wxFileExists(m_local_sources_catalog)) {
142 wxCopyFile(shareLocn + local_grib_catalog, m_local_sources_catalog);
144 if (m_bGRIBShowIcon) {
145 wxString normalIcon = shareLocn + _T(
"grib.svg");
146 wxString toggledIcon = shareLocn + _T(
"grib_toggled.svg");
147 wxString rolloverIcon = shareLocn + _T(
"grib_rollover.svg");
153 toggledIcon = _T(
"");
154 rolloverIcon = _T(
"");
157 wxLogMessage(normalIcon);
159 _T(
""), normalIcon, rolloverIcon, toggledIcon, wxITEM_CHECK, _(
"Grib"),
160 _T(
""),
nullptr, GRIB_TOOL_POSITION, 0,
this);
163 if (!QualifyCtrlBarPosition(m_CtrlBarxy, m_CtrlBar_Sizexy)) {
164 m_CtrlBarxy = wxPoint(20, 60);
165 m_CursorDataxy = wxPoint(20, 170);
176 SendTimelineMessage(wxInvalidDateTime);
178 if (m_pGribCtrlBar) {
179 m_pGribCtrlBar->Close();
180 delete m_pGribCtrlBar;
181 m_pGribCtrlBar =
nullptr;
184 delete m_pGRIBOverlayFactory;
185 m_pGRIBOverlayFactory =
nullptr;
206 "GRIB PlugIn for OpenCPN\n\
207Provides basic GRIB file overlay capabilities for several GRIB file types\n\
208and a request function to get GRIB files by eMail.\n\n\
209Supported GRIB data include:\n\
210- wind direction and speed (at 10 m)\n\
215- significant wave height and direction\n\
216- air surface temperature (at 2 m)\n\
217- sea surface temperature\n\
218- surface current direction and speed\n\
219- Convective Available Potential Energy (CAPE)\n\
220- wind, altitude, temperature and relative humidity at 300, 500, 700, 850 hPa.");
225int grib_pi::GetToolBarToolCount(
void) {
return 1; }
228 if ((m_pGribCtrlBar && m_pGribCtrlBar->pReq_Dialog))
239 Pref->m_cbUseHiDef->SetValue(m_bGRIBUseHiDef);
240 Pref->m_cbUseGradualColors->SetValue(m_bGRIBUseGradualColors);
241 Pref->m_cbDrawBarbedArrowHead->SetValue(m_bDrawBarbedArrowHead);
242 Pref->m_cZoomToCenterAtInit->SetValue(m_bZoomToCenterAtInit);
243 Pref->m_cbCopyFirstCumulativeRecord->SetValue(m_bCopyFirstCumRec);
244 Pref->m_cbCopyMissingWaveRecord->SetValue(m_bCopyMissWaveRec);
245 Pref->m_rbLoadOptions->SetSelection(m_bLoadLastOpenFile);
246 Pref->m_rbStartOptions->SetSelection(m_bStartOptions);
248 if (Pref->m_textDirectory) {
252 pConf->SetPath(_T (
"/Directories" ));
253 pConf->Read(_T (
"GRIBDirectory" ), &l_grib_dir);
254 Pref->m_grib_dir_sel = l_grib_dir;
255 Pref->m_textDirectory->ChangeValue(l_grib_dir);
260 int val = (m_GribIconsScaleFactor * 10.) - 10;
261 Pref->m_sIconSizeFactor->SetValue(val);
264#ifdef __OCPN__ANDROID__
265 if (m_parent_window) {
266 int xmax = m_parent_window->GetSize().GetWidth();
267 int ymax = m_parent_window->GetParent()
270 Pref->SetSize(xmax, ymax);
278 int display_width, display_height;
279 wxDisplaySize(&display_width, &display_height);
282 if (display_height < 600) {
285 Pref->SetSize(wxSize(60 * char_width, canvas_size.x * 8 / 10));
286 Pref->CentreOnScreen();
289 Pref->SetSize(wxSize(60 * char_width, 32 * char_height));
297 m_bGRIBUseHiDef = Pref->m_cbUseHiDef->GetValue();
298 m_bGRIBUseGradualColors = Pref->m_cbUseGradualColors->GetValue();
299 m_bLoadLastOpenFile = Pref->m_rbLoadOptions->GetSelection();
300 m_bDrawBarbedArrowHead = Pref->m_cbDrawBarbedArrowHead->GetValue();
301 m_bZoomToCenterAtInit = Pref->m_cZoomToCenterAtInit->GetValue();
303 double val = Pref->m_sIconSizeFactor->GetValue();
304 m_GribIconsScaleFactor = 1. + (val / 10);
307 if (m_pGRIBOverlayFactory)
308 m_pGRIBOverlayFactory->SetSettings(m_bGRIBUseHiDef, m_bGRIBUseGradualColors,
309 m_bDrawBarbedArrowHead);
313 if (m_bStartOptions != Pref->m_rbStartOptions->GetSelection()) {
314 m_bStartOptions = Pref->m_rbStartOptions->GetSelection();
318 bool copyrec = Pref->m_cbCopyFirstCumulativeRecord->GetValue();
319 bool copywave = Pref->m_cbCopyMissingWaveRecord->GetValue();
320 if (m_bCopyFirstCumRec != copyrec || m_bCopyMissWaveRec != copywave) {
321 m_bCopyFirstCumRec = copyrec;
322 m_bCopyMissWaveRec = copywave;
326 if (m_pGribCtrlBar) {
327 switch (updatelevel) {
333 m_pGribCtrlBar->CreateActiveFileFromNames(
335 m_pGribCtrlBar->PopulateComboDataList();
336 m_pGribCtrlBar->TimelineChanged();
342 m_pGribCtrlBar->PopulateComboDataList();
343 m_pGribCtrlBar->TimelineChanged();
347 m_pGribCtrlBar->ComputeBestForecastForNow();
350 if (Pref->m_grib_dir_sel.Length()) {
351 m_pGribCtrlBar->
m_grib_dir = Pref->m_grib_dir_sel;
356 if (Pref->m_grib_dir_sel.Length()) {
359 pConf->SetPath(_T (
"/Directories" ));
360 pConf->Write(_T (
"GRIBDirectory" ), Pref->m_grib_dir_sel);
361 pConf->DeleteGroup(_T (
"/Settings/GRIB/FileNames" ));
368bool grib_pi::QualifyCtrlBarPosition(
371 bool b_reset_pos =
false;
376 RECT frame_title_rect;
377 frame_title_rect.left = position.x;
378 frame_title_rect.top = position.y;
379 frame_title_rect.right = position.x + size.x;
380 frame_title_rect.bottom = m_DialogStyle == ATTACHED_HAS_CAPTION
382 : position.y + size.y;
384 if (
nullptr == MonitorFromRect(&frame_title_rect, MONITOR_DEFAULTTONULL))
387 wxRect window_title_rect;
388 window_title_rect.x = position.x;
389 window_title_rect.y = position.y;
390 window_title_rect.width = size.x;
391 window_title_rect.height =
392 m_DialogStyle == ATTACHED_HAS_CAPTION ? 30 : size.y;
394 wxRect ClientRect = wxGetClientDisplayRect();
395 if (!ClientRect.Intersects(window_title_rect)) b_reset_pos =
true;
401void grib_pi::MoveDialog(wxDialog *dialog, wxPoint position) {
403 wxApp *app = wxTheApp;
409 wxPoint p = frame->ScreenToClient(position);
412 if (p.x + dialog->GetSize().GetX() > frame->GetClientSize().GetX())
413 p.x = frame->GetClientSize().GetX() - dialog->GetSize().GetX();
414 if (p.y + dialog->GetSize().GetY() > frame->GetClientSize().GetY())
415 p.y = frame->GetClientSize().GetY() - dialog->GetSize().GetY();
420 dialog->Move(frame->ClientToScreen(p));
426 bool starting =
false;
428 double scale_factor =
431 scale_factor *= m_GribIconsScaleFactor;
433 if (scale_factor != m_GUIScaleFactor) starting =
true;
435 if (!m_pGribCtrlBar) {
437 long style = m_DialogStyle == ATTACHED_HAS_CAPTION
439 : wxBORDER_NONE | wxSYSTEM_MENU;
441 style |= wxSTAY_ON_TOP;
443 m_pGribCtrlBar =
new GRIBUICtrlBar(m_parent_window, wxID_ANY, wxEmptyString,
444 wxDefaultPosition, wxDefaultSize, style,
446 m_pGribCtrlBar->SetScaledBitmap(scale_factor);
448 wxMenu *dummy =
new wxMenu(_T(
"Plugin"));
450 new wxMenuItem(dummy, wxID_ANY, wxString(_(
"Weather table")),
451 wxEmptyString, wxITEM_NORMAL);
463 m_pGRIBOverlayFactory->SetMessageFont();
464 m_pGRIBOverlayFactory->SetParentSize(m_display_width, m_display_height);
465 m_pGRIBOverlayFactory->SetSettings(m_bGRIBUseHiDef, m_bGRIBUseGradualColors,
466 m_bDrawBarbedArrowHead);
468 m_pGribCtrlBar->OpenFile(m_bLoadLastOpenFile == 0);
472 if (
id >= 0) m_bShowGrib = !m_bShowGrib;
475 if (m_bShowGrib ||
id < 0) {
477 if (!starting && m_bLoadLastOpenFile == 0) {
478 m_pGribCtrlBar->OpenFile(
true);
482 if (m_pGribCtrlBar->GetFont() != *
OCPNGetFont(_(
"Dialog"))) starting =
true;
484 m_pGRIBOverlayFactory->SetMessageFont();
485 SetDialogFont(m_pGribCtrlBar);
486 m_GUIScaleFactor = scale_factor;
487 m_pGribCtrlBar->SetScaledBitmap(m_GUIScaleFactor);
488 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
489 m_pGribCtrlBar->Refresh();
491 MoveDialog(m_pGribCtrlBar, GetCtrlBarXY());
492 if (m_DialogStyle >> 1 == SEPARATED) {
493 MoveDialog(m_pGribCtrlBar->GetCDataDialog(), GetCursorDataXY());
494 m_pGribCtrlBar->GetCDataDialog()->Show(m_pGribCtrlBar->m_CDataIsShown);
496#ifdef __OCPN__ANDROID__
497 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
498 m_pGribCtrlBar->Refresh();
501 if (
id >= 0) m_pGribCtrlBar->Show();
504 ArrayOfGribRecordSets *rsa =
506 if (rsa->GetCount() > 1) {
509 if (rsa->GetCount() >= 1) {
520 if (m_pGribCtrlBar && m_bZoomToCenterAtInit) {
521 m_pGribCtrlBar->DoZoomToCenter();
526 m_pGribCtrlBar->Close();
529void grib_pi::OnGribCtrlBarClose() {
533 m_pGribCtrlBar->Hide();
541 if (::wxIsBusy()) ::wxEndBusyCursor();
543#ifdef __OCPN__ANDROID__
544 m_DialogStyleChanged =
true;
547 if (m_DialogStyleChanged) {
548 m_pGribCtrlBar->Destroy();
549 m_pGribCtrlBar =
nullptr;
550 m_DialogStyleChanged =
false;
554bool grib_pi::RenderOverlay(wxDC &dc,
PlugIn_ViewPort *vp) {
return false; }
556bool grib_pi::DoRenderOverlay(wxDC &dc,
PlugIn_ViewPort *vp,
int canvasIndex) {
557 if (!m_pGribCtrlBar || !m_pGribCtrlBar->IsShown() || !m_pGRIBOverlayFactory)
560 m_pGRIBOverlayFactory->RenderGribOverlay(dc, vp);
567 if (m_pGribCtrlBar->pReq_Dialog &&
569 m_pGribCtrlBar->pReq_Dialog->GetBoundingBoxCanvasIndex()) {
573 if (::wxIsBusy()) ::wxEndBusyCursor();
581bool grib_pi::DoRenderGLOverlay(wxGLContext *pcontext,
PlugIn_ViewPort *vp,
583 if (!m_pGribCtrlBar || !m_pGribCtrlBar->IsShown() || !m_pGRIBOverlayFactory)
586 m_pGRIBOverlayFactory->RenderGLGribOverlay(pcontext, vp);
593 if (m_pGribCtrlBar->pReq_Dialog &&
595 m_pGribCtrlBar->pReq_Dialog->GetBoundingBoxCanvasIndex()) {
600 if (::wxIsBusy()) ::wxEndBusyCursor();
602#ifdef __OCPN__ANDROID__
603 m_pGribCtrlBar->Raise();
611 return DoRenderGLOverlay(pcontext, vp, canvasIndex);
616 return DoRenderOverlay(dc, vp, canvasIndex);
620 if (m_pGribCtrlBar && m_pGribCtrlBar->IsShown())
621 m_pGribCtrlBar->SetCursorLatLon(lat, lon);
626 m_pGribCtrlBar->ContextMenuItemCallback(
id);
629void grib_pi::SetDialogFont(wxWindow *dialog, wxFont *font) {
630 dialog->SetFont(*font);
631 wxWindowList list = dialog->GetChildren();
632 wxWindowListNode *node = list.GetFirst();
633 for (
size_t i = 0; i < list.GetCount(); i++) {
634 wxWindow *win = node->GetData();
636 node = node->GetNext();
642void grib_pi::SetPluginMessage(wxString &message_id, wxString &message_body) {
643 if (message_id == _T(
"GRIB_VALUES_REQUEST")) {
649 r.
Parse(message_body, &v);
655 wxDateTime time(v[_T(
"Day")].AsInt(),
656 (wxDateTime::Month)v[_T(
"Month")].AsInt(),
657 v[_T(
"Year")].AsInt(), v[_T(
"Hour")].AsInt(),
658 v[_T(
"Minute")].AsInt(), v[_T(
"Second")].AsInt());
659 double lat = v[_T(
"lat")].
AsDouble();
660 double lon = v[_T(
"lon")].
AsDouble();
662 if (m_pGribCtrlBar) {
665 if (m_pGribCtrlBar->getTimeInterpolatedValues(
667 vkn != GRIB_NOTDEF) {
668 v[_T(
"Type")] = wxT(
"Reply");
669 v[_T(
"WIND SPEED")] = vkn;
670 v[_T(
"WIND DIR")] = ang;
672 v.
Remove(_T(
"WIND SPEED"));
678 if (m_pGribCtrlBar->getTimeInterpolatedValues(
681 vkn != GRIB_NOTDEF) {
682 v[_T(
"Type")] = wxT(
"Reply");
683 v[_T(
"CURRENT SPEED")] = vkn;
684 v[_T(
"CURRENT DIR")] = ang;
686 v.
Remove(_T(
"CURRENT SPEED"));
687 v.
Remove(_T(
"CURRENT DIR"));
691 double vkn = m_pGribCtrlBar->getTimeInterpolatedValue(
Idx_WIND_GUST,
693 if (vkn != GRIB_NOTDEF) {
694 v[_T(
"Type")] = wxT(
"Reply");
700 double vkn = m_pGribCtrlBar->getTimeInterpolatedValue(
Idx_HTSIGW, lon,
702 if (vkn != GRIB_NOTDEF) {
703 v[_T(
"Type")] = wxT(
"Reply");
704 v[_T(
"SWELL")] = vkn;
714 }
else if (message_id == _T(
"GRIB_VERSION_REQUEST")) {
723 }
else if (message_id == _T(
"GRIB_TIMELINE_REQUEST")) {
725 SendTimelineMessage(m_pGribCtrlBar ? m_pGribCtrlBar->
TimelineTime()
726 : wxDateTime::Now());
727 }
else if (message_id == _T(
"GRIB_TIMELINE_RECORD_REQUEST")) {
730 r.
Parse(message_body, &v);
731 wxDateTime time(v[_T(
"Day")].AsInt(),
732 (wxDateTime::Month)v[_T(
"Month")].AsInt(),
733 v[_T(
"Year")].AsInt(), v[_T(
"Hour")].AsInt(),
734 v[_T(
"Minute")].AsInt(), v[_T(
"Second")].AsInt());
742 snprintf(ptr,
sizeof ptr,
"%p", set);
744 v[_T(
"GribVersionMajor")] = PLUGIN_VERSION_MAJOR;
745 v[_T(
"GribVersionMinor")] = PLUGIN_VERSION_MINOR;
746 v[_T(
"TimelineSetPtr")] = wxString::From8BitData(ptr);
752 delete m_pLastTimelineSet;
753 m_pLastTimelineSet = set;
756 else if (message_id == _T(
"GRIB_APPLY_JSON_CONFIG")) {
757 wxLogMessage(_T(
"Got GRIB_APPLY_JSON_CONFIG"));
759 if (m_pGribCtrlBar) {
760 m_pGribCtrlBar->OpenFileFromJSON(message_body);
764 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
769bool grib_pi::LoadConfig(
void) {
770 wxFileConfig *pConf = (wxFileConfig *)m_pconfig;
772 if (!pConf)
return false;
774 pConf->SetPath(_T(
"/PlugIns/GRIB" ));
775 pConf->Read(_T(
"LoadLastOpenFile" ), &m_bLoadLastOpenFile, 0);
776 pConf->Read(_T(
"OpenFileOption" ), &m_bStartOptions, 1);
777 pConf->Read(_T(
"GRIBUseHiDef" ), &m_bGRIBUseHiDef, 0);
778 pConf->Read(_T(
"GRIBUseGradualColors" ), &m_bGRIBUseGradualColors, 0);
779 pConf->Read(_T(
"DrawBarbedArrowHead" ), &m_bDrawBarbedArrowHead, 1);
780 pConf->Read(_T(
"ZoomToCenterAtInit"), &m_bZoomToCenterAtInit, 1);
781 pConf->Read(_T(
"ShowGRIBIcon" ), &m_bGRIBShowIcon, 1);
782 pConf->Read(_T(
"CopyFirstCumulativeRecord" ), &m_bCopyFirstCumRec, 1);
783 pConf->Read(_T(
"CopyMissingWaveRecord" ), &m_bCopyMissWaveRec, 1);
785 pConf->Read(_T(
"GribIconsScaleFactor"), &m_GribIconsScaleFactor, 1);
788 m_CtrlBar_Sizexy.x = pConf->Read(_T (
"GRIBCtrlBarSizeX" ), 1400L);
789 m_CtrlBar_Sizexy.y = pConf->Read(_T (
"GRIBCtrlBarSizeY" ), 800L);
790 m_CtrlBarxy.x = pConf->Read(_T (
"GRIBCtrlBarPosX" ), 20L);
791 m_CtrlBarxy.y = pConf->Read(_T (
"GRIBCtrlBarPosY" ), 60L);
792 m_CursorDataxy.x = pConf->Read(_T (
"GRIBCursorDataPosX" ), 20L);
793 m_CursorDataxy.y = pConf->Read(_T (
"GRIBCursorDataPosY" ), 170L);
795 pConf->Read(_T (
"GribCursorDataDisplayStyle" ), &m_DialogStyle, 0);
796 if (m_DialogStyle > 3)
802bool grib_pi::SaveConfig(
void) {
803 wxFileConfig *pConf = (wxFileConfig *)m_pconfig;
805 if (!pConf)
return false;
807 pConf->SetPath(_T(
"/PlugIns/GRIB" ));
809 pConf->Write(_T (
"LoadLastOpenFile" ), m_bLoadLastOpenFile);
810 pConf->Write(_T (
"OpenFileOption" ), m_bStartOptions);
811 pConf->Write(_T (
"ShowGRIBIcon" ), m_bGRIBShowIcon);
812 pConf->Write(_T (
"GRIBUseHiDef" ), m_bGRIBUseHiDef);
813 pConf->Write(_T (
"GRIBUseGradualColors" ), m_bGRIBUseGradualColors);
814 pConf->Write(_T (
"CopyFirstCumulativeRecord" ), m_bCopyFirstCumRec);
815 pConf->Write(_T (
"CopyMissingWaveRecord" ), m_bCopyMissWaveRec);
816 pConf->Write(_T (
"DrawBarbedArrowHead" ), m_bDrawBarbedArrowHead);
817 pConf->Write(_T (
"ZoomToCenterAtInit"), m_bZoomToCenterAtInit);
819 pConf->Write(_T(
"GribIconsScaleFactor"), m_GribIconsScaleFactor);
822 pConf->Write(_T (
"GRIBCtrlBarSizeX" ), m_CtrlBar_Sizexy.x);
823 pConf->Write(_T (
"GRIBCtrlBarSizeY" ), m_CtrlBar_Sizexy.y);
824 pConf->Write(_T (
"GRIBCtrlBarPosX" ), m_CtrlBarxy.x);
825 pConf->Write(_T (
"GRIBCtrlBarPosY" ), m_CtrlBarxy.y);
826 pConf->Write(_T (
"GRIBCursorDataPosX" ), m_CursorDataxy.x);
827 pConf->Write(_T (
"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 grib_pi::SendTimelineMessage(wxDateTime time) {
843 if (!m_pGribCtrlBar)
return;
846 if (time.IsValid()) {
847 v[_T(
"Day")] = time.GetDay();
848 v[_T(
"Month")] = time.GetMonth();
849 v[_T(
"Year")] = time.GetYear();
850 v[_T(
"Hour")] = time.GetHour();
851 v[_T(
"Minute")] = time.GetMinute();
852 v[_T(
"Second")] = time.GetSecond();
858 v[_T(
"Minute")] = -1;
859 v[_T(
"Second")] = -1;
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);
@ 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.
ArrayOfGribRecordSets * GetRecordSetArrayPtr(void)
Gets pointer to array of record sets organized by timestamp.
wxArrayString & GetFileNames(void)
Gets the list of source filenames being used.
bool IsOK(void)
Checks if file loading and parsing was successful.
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 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.
void SetCursorLatLon(double lat, double lon)
Receives cursor lat/lon position updates.
bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp)
Renders plugin overlay graphics in OpenGL mode for single canvas.
wxString GetCommonName()
Get the plugin's common (short) name.
bool DeInit(void)
Clean up plugin resources.
void OnContextMenuItemCallback(int id)
Handles context menu item selection.
int Init(void)
Initialize the plugin and declare its capabilities.
void SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix)
Updates plugin with extended position fix data at regular intervals.
int GetAPIVersionMinor()
Returns the minor version number of the plugin API that this plugin supports.
int GetPlugInVersionMinor()
Returns the minor version number of the plugin itself.
void SetColorScheme(PI_ColorScheme cs)
Updates plugin color scheme.
void OnToolbarToolCallback(int id)
Handles toolbar tool clicks.
int GetPlugInVersionMajor()
Returns the major version number of the plugin itself.
bool MouseEventHook(wxMouseEvent &event)
Handles mouse events from chart window.
wxString GetShortDescription()
Get a brief description of the plugin.
void ShowPreferencesDialog(wxWindow *parent)
Shows the plugin preferences dialog.
void SetDefaults(void)
Sets plugin default options.
wxBitmap * GetPlugInBitmap()
Get the plugin's icon bitmap.
bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex)
Renders plugin overlay graphics in standard DC mode for multi-canvas support.
bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvasIndex)
Renders plugin overlay graphics in OpenGL mode for multi-canvas support.
wxString GetLongDescription()
Get detailed plugin information.
int GetAPIVersionMajor()
Returns the major version number of the plugin API that this plugin supports.
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.
#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.