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;
77 wxString shareLocn = *GetpSharedDataLocation() + _T(
"plugins") +
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;
99int grib_pi::Init(
void) {
100 AddLocaleCatalog(_T(
"opencpn-grib_pi"));
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;
114 m_pconfig = GetOCPNConfigObject();
121 m_parent_window = GetOCPNCanvasWindow();
123 g_ContentScaleFactor = m_parent_window->GetContentScaleFactor();
128 wxString shareLocn = *GetpSharedDataLocation() + _T(
"plugins") +
129 wxFileName::GetPathSeparator() + _T(
"grib_pi") +
130 wxFileName::GetPathSeparator() + _T(
"data") +
131 wxFileName::GetPathSeparator();
133 wxString local_grib_catalog =
"sources.json";
134 wxString data_path = *GetpPrivateApplicationDataLocation() +
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");
151 if (GetActiveStyleName().Lower() != _T(
"traditional")) {
153 toggledIcon = _T(
"");
154 rolloverIcon = _T(
"");
157 wxLogMessage(normalIcon);
158 m_leftclick_tool_id = InsertPlugInToolSVG(
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);
174bool grib_pi::DeInit(
void) {
175 if (m_pGribCtrlBar) {
176 m_pGribCtrlBar->Close();
177 delete m_pGribCtrlBar;
178 m_pGribCtrlBar =
nullptr;
181 delete m_pGRIBOverlayFactory;
182 m_pGRIBOverlayFactory =
nullptr;
187int grib_pi::GetAPIVersionMajor() {
return MY_API_VERSION_MAJOR; }
189int grib_pi::GetAPIVersionMinor() {
return MY_API_VERSION_MINOR; }
191int grib_pi::GetPlugInVersionMajor() {
return PLUGIN_VERSION_MAJOR; }
193int grib_pi::GetPlugInVersionMinor() {
return PLUGIN_VERSION_MINOR; }
197wxString grib_pi::GetCommonName() {
return _T(
"GRIB"); }
199wxString grib_pi::GetShortDescription() {
return _(
"GRIB PlugIn for OpenCPN"); }
201wxString grib_pi::GetLongDescription() {
203 "GRIB PlugIn for OpenCPN\n\
204Provides basic GRIB file overlay capabilities for several GRIB file types\n\
205and a request function to get GRIB files by eMail.\n\n\
206Supported GRIB data include:\n\
207- wind direction and speed (at 10 m)\n\
212- significant wave height and direction\n\
213- air surface temperature (at 2 m)\n\
214- sea surface temperature\n\
215- surface current direction and speed\n\
216- Convective Available Potential Energy (CAPE)\n\
217- wind, altitude, temperature and relative humidity at 300, 500, 700, 850 hPa.");
220void grib_pi::SetDefaults(
void) {}
222int grib_pi::GetToolBarToolCount(
void) {
return 1; }
224bool grib_pi::MouseEventHook(wxMouseEvent &event) {
225 if ((m_pGribCtrlBar && m_pGribCtrlBar->pReq_Dialog))
226 return m_pGribCtrlBar->pReq_Dialog->MouseEventHook(event);
230void grib_pi::ShowPreferencesDialog(wxWindow *parent) {
236 Pref->m_cbUseHiDef->SetValue(m_bGRIBUseHiDef);
237 Pref->m_cbUseGradualColors->SetValue(m_bGRIBUseGradualColors);
238 Pref->m_cbDrawBarbedArrowHead->SetValue(m_bDrawBarbedArrowHead);
239 Pref->m_cZoomToCenterAtInit->SetValue(m_bZoomToCenterAtInit);
240 Pref->m_cbCopyFirstCumulativeRecord->SetValue(m_bCopyFirstCumRec);
241 Pref->m_cbCopyMissingWaveRecord->SetValue(m_bCopyMissWaveRec);
242 Pref->m_rbTimeFormat->SetSelection(m_bTimeZone);
243 Pref->m_rbLoadOptions->SetSelection(m_bLoadLastOpenFile);
244 Pref->m_rbStartOptions->SetSelection(m_bStartOptions);
246 wxFileConfig *pConf = GetOCPNConfigObject();
249 pConf->SetPath(_T (
"/Directories" ));
250 pConf->Read(_T (
"GRIBDirectory" ), &l_grib_dir);
251 Pref->m_grib_dir_sel = l_grib_dir;
255 int val = (m_GribIconsScaleFactor * 10.) - 10;
256 Pref->m_sIconSizeFactor->SetValue(val);
259#ifdef __OCPN__ANDROID__
260 if (m_parent_window) {
261 int xmax = m_parent_window->GetSize().GetWidth();
262 int ymax = m_parent_window->GetParent()
265 Pref->SetSize(xmax, ymax);
273 int display_width, display_height;
274 wxDisplaySize(&display_width, &display_height);
275 int char_width = GetOCPNCanvasWindow()->GetCharWidth();
276 int char_height = GetOCPNCanvasWindow()->GetCharHeight();
277 if (display_height < 600) {
278 wxSize canvas_size = GetOCPNCanvasWindow()->GetSize();
279 Pref->SetMaxSize(GetOCPNCanvasWindow()->GetSize());
280 Pref->SetSize(wxSize(60 * char_width, canvas_size.x * 8 / 10));
281 Pref->CentreOnScreen();
283 Pref->SetMaxSize(GetOCPNCanvasWindow()->GetSize());
284 Pref->SetSize(wxSize(60 * char_width, 32 * char_height));
292 m_bGRIBUseHiDef = Pref->m_cbUseHiDef->GetValue();
293 m_bGRIBUseGradualColors = Pref->m_cbUseGradualColors->GetValue();
294 m_bLoadLastOpenFile = Pref->m_rbLoadOptions->GetSelection();
295 m_bDrawBarbedArrowHead = Pref->m_cbDrawBarbedArrowHead->GetValue();
296 m_bZoomToCenterAtInit = Pref->m_cZoomToCenterAtInit->GetValue();
298 double val = Pref->m_sIconSizeFactor->GetValue();
299 m_GribIconsScaleFactor = 1. + (val / 10);
302 if (m_pGRIBOverlayFactory)
303 m_pGRIBOverlayFactory->SetSettings(m_bGRIBUseHiDef, m_bGRIBUseGradualColors,
304 m_bDrawBarbedArrowHead);
308 if (m_bStartOptions != Pref->m_rbStartOptions->GetSelection()) {
309 m_bStartOptions = Pref->m_rbStartOptions->GetSelection();
313 if (m_bTimeZone != Pref->m_rbTimeFormat->GetSelection()) {
314 m_bTimeZone = Pref->m_rbTimeFormat->GetSelection();
315 if (m_pGRIBOverlayFactory) m_pGRIBOverlayFactory->SetTimeZone(m_bTimeZone);
319 bool copyrec = Pref->m_cbCopyFirstCumulativeRecord->GetValue();
320 bool copywave = Pref->m_cbCopyMissingWaveRecord->GetValue();
321 if (m_bCopyFirstCumRec != copyrec || m_bCopyMissWaveRec != copywave) {
322 m_bCopyFirstCumRec = copyrec;
323 m_bCopyMissWaveRec = copywave;
327 if (m_pGribCtrlBar) {
328 switch (updatelevel) {
334 m_pGribCtrlBar->CreateActiveFileFromNames(
336 m_pGribCtrlBar->PopulateComboDataList();
337 m_pGribCtrlBar->TimelineChanged();
341 m_pGribCtrlBar->PopulateComboDataList();
342 m_pGribCtrlBar->TimelineChanged();
346 m_pGribCtrlBar->ComputeBestForecastForNow();
349 if (Pref->m_grib_dir_sel.Length()) {
350 m_pGribCtrlBar->
m_grib_dir = Pref->m_grib_dir_sel;
355 if (Pref->m_grib_dir_sel.Length()) {
356 wxFileConfig *pConf = GetOCPNConfigObject();
358 pConf->SetPath(_T (
"/Directories" ));
359 pConf->Write(_T (
"GRIBDirectory" ), Pref->m_grib_dir_sel);
360 pConf->DeleteGroup(_T (
"/Settings/GRIB/FileNames" ));
367bool grib_pi::QualifyCtrlBarPosition(
370 bool b_reset_pos =
false;
375 RECT frame_title_rect;
376 frame_title_rect.left = position.x;
377 frame_title_rect.top = position.y;
378 frame_title_rect.right = position.x + size.x;
379 frame_title_rect.bottom = m_DialogStyle == ATTACHED_HAS_CAPTION
381 : position.y + size.y;
383 if (
nullptr == MonitorFromRect(&frame_title_rect, MONITOR_DEFAULTTONULL))
386 wxRect window_title_rect;
387 window_title_rect.x = position.x;
388 window_title_rect.y = position.y;
389 window_title_rect.width = size.x;
390 window_title_rect.height =
391 m_DialogStyle == ATTACHED_HAS_CAPTION ? 30 : size.y;
393 wxRect ClientRect = wxGetClientDisplayRect();
394 if (!ClientRect.Intersects(window_title_rect)) b_reset_pos =
true;
400void grib_pi::MoveDialog(wxDialog *dialog, wxPoint position) {
402 wxApp *app = wxTheApp;
408 wxPoint p = frame->ScreenToClient(position);
411 if (p.x + dialog->GetSize().GetX() > frame->GetClientSize().GetX())
412 p.x = frame->GetClientSize().GetX() - dialog->GetSize().GetX();
413 if (p.y + dialog->GetSize().GetY() > frame->GetClientSize().GetY())
414 p.y = frame->GetClientSize().GetY() - dialog->GetSize().GetY();
419 dialog->Move(frame->ClientToScreen(p));
422void grib_pi::OnToolbarToolCallback(
int id) {
425 bool starting =
false;
427 double scale_factor =
428 GetOCPNGUIToolScaleFactor_PlugIn() * OCPN_GetWinDIPScaleFactor();
430 scale_factor *= m_GribIconsScaleFactor;
432 if (scale_factor != m_GUIScaleFactor) starting =
true;
434 if (!m_pGribCtrlBar) {
436 long style = m_DialogStyle == ATTACHED_HAS_CAPTION
437 ? wxCAPTION | wxCLOSE_BOX | wxSYSTEM_MENU
438 : wxBORDER_NONE | wxSYSTEM_MENU;
440 style |= wxSTAY_ON_TOP;
444 wxDefaultPosition, wxDefaultSize, style,
this);
445 m_pGribCtrlBar->SetScaledBitmap(scale_factor);
447 wxMenu *dummy =
new wxMenu(_T(
"Plugin"));
449 new wxMenuItem(dummy, wxID_ANY, wxString(_(
"Weather table")),
450 wxEmptyString, wxITEM_NORMAL);
457 m_MenuItem = AddCanvasContextMenuItem(table,
this);
458 SetCanvasContextMenuItemViz(m_MenuItem,
false);
462 m_pGRIBOverlayFactory->SetMessageFont();
463 m_pGRIBOverlayFactory->SetTimeZone(m_bTimeZone);
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 m_bShowGrib = !m_bShowGrib;
477 if (!starting && m_bLoadLastOpenFile == 0) {
478 m_pGribCtrlBar->OpenFile(
true);
482 if (m_pGribCtrlBar->GetFont() != *
OCPNGetFont(_(
"Dialog"), 0))
485 m_pGRIBOverlayFactory->SetMessageFont();
486 SetDialogFont(m_pGribCtrlBar);
487 m_GUIScaleFactor = scale_factor;
488 m_pGribCtrlBar->SetScaledBitmap(m_GUIScaleFactor);
489 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
490 m_pGribCtrlBar->Refresh();
492 MoveDialog(m_pGribCtrlBar, GetCtrlBarXY());
493 if (m_DialogStyle >> 1 == SEPARATED) {
494 MoveDialog(m_pGribCtrlBar->GetCDataDialog(), GetCursorDataXY());
495 m_pGribCtrlBar->GetCDataDialog()->Show(m_pGribCtrlBar->m_CDataIsShown);
497#ifdef __OCPN__ANDROID__
498 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
499 m_pGribCtrlBar->Refresh();
502 m_pGribCtrlBar->Show();
505 ArrayOfGribRecordSets *rsa =
507 if (rsa->GetCount() > 1) {
508 SetCanvasContextMenuItemViz(m_MenuItem,
true);
510 if (rsa->GetCount() >= 1) {
511 SendTimelineMessage(m_pGribCtrlBar->TimelineTime());
517 SetToolbarItemState(m_leftclick_tool_id, m_bShowGrib);
521 if (m_pGribCtrlBar && m_bZoomToCenterAtInit) {
522 m_pGribCtrlBar->DoZoomToCenter();
525 RequestRefresh(m_parent_window);
527 m_pGribCtrlBar->Close();
530void grib_pi::OnGribCtrlBarClose() {
532 SetToolbarItemState(m_leftclick_tool_id, m_bShowGrib);
534 m_pGribCtrlBar->Hide();
538 SetCanvasContextMenuItemViz(m_MenuItem,
false);
540 RequestRefresh(m_parent_window);
542 if (::wxIsBusy()) ::wxEndBusyCursor();
544#ifdef __OCPN__ANDROID__
545 m_DialogStyleChanged =
true;
548 if (m_DialogStyleChanged) {
549 m_pGribCtrlBar->Destroy();
550 m_pGribCtrlBar =
nullptr;
551 m_DialogStyleChanged =
false;
555bool grib_pi::RenderOverlay(wxDC &dc,
PlugIn_ViewPort *vp) {
return false; }
557bool grib_pi::DoRenderOverlay(wxDC &dc,
PlugIn_ViewPort *vp,
int canvasIndex) {
558 if (!m_pGribCtrlBar || !m_pGribCtrlBar->IsShown() || !m_pGRIBOverlayFactory)
561 m_pGRIBOverlayFactory->RenderGribOverlay(dc, vp);
563 if (GetCanvasByIndex(canvasIndex) == GetCanvasUnderMouse()) {
564 m_pGribCtrlBar->SetViewPort(vp);
565 if (m_pGribCtrlBar->pReq_Dialog)
566 m_pGribCtrlBar->pReq_Dialog->RenderZoneOverlay(dc);
568 if (::wxIsBusy()) ::wxEndBusyCursor();
572bool grib_pi::RenderGLOverlay(wxGLContext *pcontext,
PlugIn_ViewPort *vp) {
576bool grib_pi::DoRenderGLOverlay(wxGLContext *pcontext,
PlugIn_ViewPort *vp,
578 if (!m_pGribCtrlBar || !m_pGribCtrlBar->IsShown() || !m_pGRIBOverlayFactory)
581 m_pGRIBOverlayFactory->RenderGLGribOverlay(pcontext, vp);
583 if (GetCanvasByIndex(canvasIndex) == GetCanvasUnderMouse()) {
584 m_pGribCtrlBar->SetViewPort(vp);
585 if (m_pGribCtrlBar->pReq_Dialog)
586 m_pGribCtrlBar->pReq_Dialog->RenderGlZoneOverlay();
589 if (::wxIsBusy()) ::wxEndBusyCursor();
591#ifdef __OCPN__ANDROID__
592 m_pGribCtrlBar->Raise();
598bool grib_pi::RenderGLOverlayMultiCanvas(wxGLContext *pcontext,
600 return DoRenderGLOverlay(pcontext, vp, canvasIndex);
605 return DoRenderOverlay(dc, vp, canvasIndex);
608void grib_pi::SetCursorLatLon(
double lat,
double lon) {
609 if (m_pGribCtrlBar && m_pGribCtrlBar->IsShown())
610 m_pGribCtrlBar->SetCursorLatLon(lat, lon);
613void grib_pi::OnContextMenuItemCallback(
int id) {
615 m_pGribCtrlBar->ContextMenuItemCallback(
id);
618void grib_pi::SetDialogFont(wxWindow *dialog, wxFont *font) {
619 dialog->SetFont(*font);
620 wxWindowList list = dialog->GetChildren();
621 wxWindowListNode *node = list.GetFirst();
622 for (
size_t i = 0; i < list.GetCount(); i++) {
623 wxWindow *win = node->GetData();
625 node = node->GetNext();
631void grib_pi::SetPluginMessage(wxString &message_id, wxString &message_body) {
632 if (message_id == _T(
"GRIB_VALUES_REQUEST")) {
633 if (!m_pGribCtrlBar) OnToolbarToolCallback(0);
638 r.
Parse(message_body, &v);
641 SendPluginMessage(wxString(_T(
"GRIB_VALUES")), _T(
""));
644 wxDateTime time(v[_T(
"Day")].AsInt(),
645 (wxDateTime::Month)v[_T(
"Month")].AsInt(),
646 v[_T(
"Year")].AsInt(), v[_T(
"Hour")].AsInt(),
647 v[_T(
"Minute")].AsInt(), v[_T(
"Second")].AsInt());
648 double lat = v[_T(
"lat")].
AsDouble();
649 double lon = v[_T(
"lon")].
AsDouble();
651 if (m_pGribCtrlBar) {
654 if (m_pGribCtrlBar->getTimeInterpolatedValues(
656 vkn != GRIB_NOTDEF) {
657 v[_T(
"Type")] = wxT(
"Reply");
658 v[_T(
"WIND SPEED")] = vkn;
659 v[_T(
"WIND DIR")] = ang;
661 v.
Remove(_T(
"WIND SPEED"));
667 if (m_pGribCtrlBar->getTimeInterpolatedValues(
670 vkn != GRIB_NOTDEF) {
671 v[_T(
"Type")] = wxT(
"Reply");
672 v[_T(
"CURRENT SPEED")] = vkn;
673 v[_T(
"CURRENT DIR")] = ang;
675 v.
Remove(_T(
"CURRENT SPEED"));
676 v.
Remove(_T(
"CURRENT DIR"));
680 double vkn = m_pGribCtrlBar->getTimeInterpolatedValue(
Idx_WIND_GUST,
682 if (vkn != GRIB_NOTDEF) {
683 v[_T(
"Type")] = wxT(
"Reply");
689 double vkn = m_pGribCtrlBar->getTimeInterpolatedValue(
Idx_HTSIGW, lon,
691 if (vkn != GRIB_NOTDEF) {
692 v[_T(
"Type")] = wxT(
"Reply");
693 v[_T(
"SWELL")] = vkn;
701 SendPluginMessage(wxString(_T(
"GRIB_VALUES")), out);
703 }
else if (message_id == _T(
"GRIB_VERSION_REQUEST")) {
705 v[_T(
"GribVersionMinor")] = GetAPIVersionMinor();
706 v[_T(
"GribVersionMajor")] = GetAPIVersionMajor();
711 SendPluginMessage(wxString(_T(
"GRIB_VERSION")), out);
712 }
else if (message_id == _T(
"GRIB_TIMELINE_REQUEST")) {
714 SendTimelineMessage(m_pGribCtrlBar ? m_pGribCtrlBar->TimelineTime()
715 : wxDateTime::Now());
716 }
else if (message_id == _T(
"GRIB_TIMELINE_RECORD_REQUEST")) {
719 r.
Parse(message_body, &v);
720 wxDateTime time(v[_T(
"Day")].AsInt(),
721 (wxDateTime::Month)v[_T(
"Month")].AsInt(),
722 v[_T(
"Year")].AsInt(), v[_T(
"Hour")].AsInt(),
723 v[_T(
"Minute")].AsInt(), v[_T(
"Second")].AsInt());
725 if (!m_pGribCtrlBar) OnToolbarToolCallback(0);
731 snprintf(ptr,
sizeof ptr,
"%p", set);
733 v[_T(
"GribVersionMajor")] = PLUGIN_VERSION_MAJOR;
734 v[_T(
"GribVersionMinor")] = PLUGIN_VERSION_MINOR;
735 v[_T(
"TimelineSetPtr")] = wxString::From8BitData(ptr);
740 SendPluginMessage(wxString(_T(
"GRIB_TIMELINE_RECORD")), out);
741 delete m_pLastTimelineSet;
742 m_pLastTimelineSet = set;
745 else if (message_id == _T(
"GRIB_APPLY_JSON_CONFIG")) {
746 wxLogMessage(_T(
"Got GRIB_APPLY_JSON_CONFIG"));
748 if (m_pGribCtrlBar) {
749 m_pGribCtrlBar->OpenFileFromJSON(message_body);
753 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
758bool grib_pi::LoadConfig(
void) {
759 wxFileConfig *pConf = (wxFileConfig *)m_pconfig;
761 if (!pConf)
return false;
763 pConf->SetPath(_T(
"/PlugIns/GRIB" ));
764 pConf->Read(_T(
"LoadLastOpenFile" ), &m_bLoadLastOpenFile, 0);
765 pConf->Read(_T(
"OpenFileOption" ), &m_bStartOptions, 1);
766 pConf->Read(_T(
"GRIBUseHiDef" ), &m_bGRIBUseHiDef, 0);
767 pConf->Read(_T(
"GRIBUseGradualColors" ), &m_bGRIBUseGradualColors, 0);
768 pConf->Read(_T(
"DrawBarbedArrowHead" ), &m_bDrawBarbedArrowHead, 1);
769 pConf->Read(_T(
"ZoomToCenterAtInit"), &m_bZoomToCenterAtInit, 1);
770 pConf->Read(_T(
"ShowGRIBIcon" ), &m_bGRIBShowIcon, 1);
771 pConf->Read(_T(
"GRIBTimeZone" ), &m_bTimeZone, 1);
772 pConf->Read(_T(
"CopyFirstCumulativeRecord" ), &m_bCopyFirstCumRec, 1);
773 pConf->Read(_T(
"CopyMissingWaveRecord" ), &m_bCopyMissWaveRec, 1);
775 pConf->Read(_T(
"GribIconsScaleFactor"), &m_GribIconsScaleFactor, 1);
778 m_CtrlBar_Sizexy.x = pConf->Read(_T (
"GRIBCtrlBarSizeX" ), 1400L);
779 m_CtrlBar_Sizexy.y = pConf->Read(_T (
"GRIBCtrlBarSizeY" ), 800L);
780 m_CtrlBarxy.x = pConf->Read(_T (
"GRIBCtrlBarPosX" ), 20L);
781 m_CtrlBarxy.y = pConf->Read(_T (
"GRIBCtrlBarPosY" ), 60L);
782 m_CursorDataxy.x = pConf->Read(_T (
"GRIBCursorDataPosX" ), 20L);
783 m_CursorDataxy.y = pConf->Read(_T (
"GRIBCursorDataPosY" ), 170L);
785 pConf->Read(_T (
"GribCursorDataDisplayStyle" ), &m_DialogStyle, 0);
786 if (m_DialogStyle > 3)
792bool grib_pi::SaveConfig(
void) {
793 wxFileConfig *pConf = (wxFileConfig *)m_pconfig;
795 if (!pConf)
return false;
797 pConf->SetPath(_T(
"/PlugIns/GRIB" ));
799 pConf->Write(_T (
"LoadLastOpenFile" ), m_bLoadLastOpenFile);
800 pConf->Write(_T (
"OpenFileOption" ), m_bStartOptions);
801 pConf->Write(_T (
"ShowGRIBIcon" ), m_bGRIBShowIcon);
802 pConf->Write(_T (
"GRIBUseHiDef" ), m_bGRIBUseHiDef);
803 pConf->Write(_T (
"GRIBUseGradualColors" ), m_bGRIBUseGradualColors);
804 pConf->Write(_T (
"GRIBTimeZone" ), m_bTimeZone);
805 pConf->Write(_T (
"CopyFirstCumulativeRecord" ), m_bCopyFirstCumRec);
806 pConf->Write(_T (
"CopyMissingWaveRecord" ), m_bCopyMissWaveRec);
807 pConf->Write(_T (
"DrawBarbedArrowHead" ), m_bDrawBarbedArrowHead);
808 pConf->Write(_T (
"ZoomToCenterAtInit"), m_bZoomToCenterAtInit);
810 pConf->Write(_T(
"GribIconsScaleFactor"), m_GribIconsScaleFactor);
813 pConf->Write(_T (
"GRIBCtrlBarSizeX" ), m_CtrlBar_Sizexy.x);
814 pConf->Write(_T (
"GRIBCtrlBarSizeY" ), m_CtrlBar_Sizexy.y);
815 pConf->Write(_T (
"GRIBCtrlBarPosX" ), m_CtrlBarxy.x);
816 pConf->Write(_T (
"GRIBCtrlBarPosY" ), m_CtrlBarxy.y);
817 pConf->Write(_T (
"GRIBCursorDataPosX" ), m_CursorDataxy.x);
818 pConf->Write(_T (
"GRIBCursorDataPosY" ), m_CursorDataxy.y);
823void grib_pi::SetColorScheme(PI_ColorScheme cs) {
824 DimeWindow(m_pGribCtrlBar);
825 if (m_pGribCtrlBar) {
826 if (m_pGRIBOverlayFactory) m_pGRIBOverlayFactory->ClearCachedLabel();
827 if (m_pGribCtrlBar->pReq_Dialog) m_pGribCtrlBar->pReq_Dialog->Refresh();
828 m_pGribCtrlBar->Refresh();
833void grib_pi::SendTimelineMessage(wxDateTime time) {
834 if (!m_pGribCtrlBar)
return;
837 if (time.IsValid()) {
838 v[_T(
"Day")] = time.GetDay();
839 v[_T(
"Month")] = time.GetMonth();
840 v[_T(
"Year")] = time.GetYear();
841 v[_T(
"Hour")] = time.GetHour();
842 v[_T(
"Minute")] = time.GetMinute();
843 v[_T(
"Second")] = time.GetSecond();
849 v[_T(
"Minute")] = -1;
850 v[_T(
"Second")] = -1;
855 SendPluginMessage(wxString(_T(
"GRIB_TIMELINE")), out);
859 m_boat_cog = pfix.Cog;
860 m_boat_sog = pfix.Sog;
861 m_boat_lat = pfix.Lat;
862 m_boat_lon = pfix.Lon;
863 if (pfix.FixTime != 0) {
864 m_boat_time = pfix.FixTime;
866 m_boat_time = wxDateTime::Now().GetTicks();
873void GribPreferencesDialog::OnStartOptionChange(wxCommandEvent &event) {
874 if (m_rbStartOptions->GetSelection() == 2) {
875 OCPNMessageBox_PlugIn(
877 _(
"You have chosen to authorize interpolation.\nDon't forget that data "
878 "displayed at current time will not be real but Recomputed\nThis can "
879 "decrease accuracy!"),
884void GribPreferencesDialog::OnOKClick(wxCommandEvent &event) {
885 if (g_pi) g_pi->UpdatePrefs(
this);
@ Idx_WIND_GUST
Wind gust speed at surface.
@ Idx_WIND_VX
Surface wind velocity X component.
@ Idx_HTSIGW
Significant wave height.
@ Idx_SEACURRENT_VY
Sea current velocity Y component.
@ Idx_WIND_VY
Surface wind velocity Y component.
@ Idx_SEACURRENT_VX
Sea current velocity X component.
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.
GribOverlaySettings m_OverlaySettings
Settings that control how GRIB data is displayed and overlaid.
wxString m_grib_dir
Directory containing GRIB files.
GRIBFile * m_bGRIBActiveFile
Currently active GRIB file being displayed.
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.
A specialized GribRecordSet that represents temporally interpolated weather data with isobar renderin...
wxBitmap * GetPlugInBitmap()
FIXME static wxBitmap* LoadSVG(const wxString filename, unsigned int width, ...
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.
#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.
wxFont * OCPNGetFont(wxString TextElement, int default_size)
Gets a font for UI elements.
OpenGL Platform Abstraction Layer.