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 m_world_models_catalog =
148 data_path + wxFileName::GetPathSeparator() +
"models.json";
149 if (!wxFileExists(m_world_models_catalog)) {
150 wxCopyFile(shareLocn +
"models.json", m_world_models_catalog);
152 if (m_bGRIBShowIcon) {
153 wxString normalIcon = shareLocn +
"grib.svg";
154 wxString toggledIcon = shareLocn +
"grib_toggled.svg";
155 wxString rolloverIcon = shareLocn +
"grib_rollover.svg";
165 wxLogMessage(normalIcon);
167 "", normalIcon, rolloverIcon, toggledIcon, wxITEM_CHECK, _(
"Grib"),
"",
168 nullptr, GRIB_TOOL_POSITION, 0,
this);
171 if (!QualifyCtrlBarPosition(m_CtrlBarxy, m_CtrlBar_Sizexy)) {
172 m_CtrlBarxy = wxPoint(20, 60);
173 m_CursorDataxy = wxPoint(20, 170);
184 SendTimelineMessage(wxInvalidDateTime);
186 if (m_pGribCtrlBar) {
187 m_pGribCtrlBar->Close();
188 delete m_pGribCtrlBar;
189 m_pGribCtrlBar =
nullptr;
192 delete m_pGRIBOverlayFactory;
193 m_pGRIBOverlayFactory =
nullptr;
214 "GRIB PlugIn for OpenCPN\n\
215Provides basic GRIB file overlay capabilities for several GRIB file types\n\
216and a request function to get GRIB files by eMail.\n\n\
217Supported GRIB data include:\n\
218- wind direction and speed (at 10 m)\n\
223- significant wave height and direction\n\
224- air surface temperature (at 2 m)\n\
225- sea surface temperature\n\
226- surface current direction and speed\n\
227- Convective Available Potential Energy (CAPE)\n\
228- wind, altitude, temperature and relative humidity at 300, 500, 700, 850 hPa.");
233int GribPi::GetToolBarToolCount() {
return 1; }
236 if ((m_pGribCtrlBar && m_pGribCtrlBar->pReq_Dialog))
247 Pref->m_cbUseHiDef->SetValue(m_bGRIBUseHiDef);
248 Pref->m_cbUseGradualColors->SetValue(m_bGRIBUseGradualColors);
249 Pref->m_cbDrawBarbedArrowHead->SetValue(m_bDrawBarbedArrowHead);
250 Pref->m_cZoomToCenterAtInit->SetValue(m_bZoomToCenterAtInit);
251 Pref->m_cbCopyFirstCumulativeRecord->SetValue(m_bCopyFirstCumRec);
252 Pref->m_cbCopyMissingWaveRecord->SetValue(m_bCopyMissWaveRec);
253 Pref->m_rbLoadOptions->SetSelection(m_bLoadLastOpenFile);
254 Pref->m_rbStartOptions->SetSelection(m_bStartOptions);
256 if (Pref->m_textDirectory) {
260 pConf->SetPath(
"/Directories");
261 pConf->Read(
"GRIBDirectory", &l_grib_dir);
262 Pref->m_grib_dir_sel = l_grib_dir;
263 Pref->m_textDirectory->ChangeValue(l_grib_dir);
268 int val = (m_GribIconsScaleFactor * 10.) - 10;
269 Pref->m_sIconSizeFactor->SetValue(val);
273 if (m_parent_window) {
274 int xmax = m_parent_window->GetSize().GetWidth();
275 int ymax = m_parent_window->GetParent()
278 Pref->SetSize(xmax, ymax);
286 int display_width, display_height;
287 wxDisplaySize(&display_width, &display_height);
290 if (display_height < 600) {
293 Pref->SetSize(wxSize(60 * char_width, canvas_size.x * 8 / 10));
294 Pref->CentreOnScreen();
297 Pref->SetSize(wxSize(60 * char_width, 32 * char_height));
305 m_bGRIBUseHiDef = Pref->m_cbUseHiDef->GetValue();
306 m_bGRIBUseGradualColors = Pref->m_cbUseGradualColors->GetValue();
307 m_bLoadLastOpenFile = Pref->m_rbLoadOptions->GetSelection();
308 m_bDrawBarbedArrowHead = Pref->m_cbDrawBarbedArrowHead->GetValue();
309 m_bZoomToCenterAtInit = Pref->m_cZoomToCenterAtInit->GetValue();
311 double val = Pref->m_sIconSizeFactor->GetValue();
312 m_GribIconsScaleFactor = 1. + (val / 10);
315 if (m_pGRIBOverlayFactory)
316 m_pGRIBOverlayFactory->SetSettings(m_bGRIBUseHiDef, m_bGRIBUseGradualColors,
317 m_bDrawBarbedArrowHead);
321 if (m_bStartOptions != Pref->m_rbStartOptions->GetSelection()) {
322 m_bStartOptions = Pref->m_rbStartOptions->GetSelection();
326 bool copyrec = Pref->m_cbCopyFirstCumulativeRecord->GetValue();
327 bool copywave = Pref->m_cbCopyMissingWaveRecord->GetValue();
328 if (m_bCopyFirstCumRec != copyrec || m_bCopyMissWaveRec != copywave) {
329 m_bCopyFirstCumRec = copyrec;
330 m_bCopyMissWaveRec = copywave;
334 if (m_pGribCtrlBar) {
335 switch (updatelevel) {
341 m_pGribCtrlBar->CreateActiveFileFromNames(
343 m_pGribCtrlBar->PopulateComboDataList();
344 m_pGribCtrlBar->TimelineChanged();
350 m_pGribCtrlBar->PopulateComboDataList();
351 m_pGribCtrlBar->TimelineChanged();
355 m_pGribCtrlBar->ComputeBestForecastForNow();
358 if (Pref->m_grib_dir_sel.Length()) {
359 m_pGribCtrlBar->
m_grib_dir = Pref->m_grib_dir_sel;
364 if (Pref->m_grib_dir_sel.Length()) {
367 pConf->SetPath(
"/Directories");
368 pConf->Write(
"GRIBDirectory", Pref->m_grib_dir_sel);
369 pConf->DeleteGroup(
"/Settings/GRIB/FileNames");
376bool GribPi::QualifyCtrlBarPosition(
379 bool b_reset_pos =
false;
384 RECT frame_title_rect;
385 frame_title_rect.left = position.x;
386 frame_title_rect.top = position.y;
387 frame_title_rect.right = position.x + size.x;
388 frame_title_rect.bottom = m_DialogStyle == ATTACHED_HAS_CAPTION
390 : position.y + size.y;
392 if (
nullptr == MonitorFromRect(&frame_title_rect, MONITOR_DEFAULTTONULL))
395 wxRect window_title_rect;
396 window_title_rect.x = position.x;
397 window_title_rect.y = position.y;
398 window_title_rect.width = size.x;
399 window_title_rect.height =
400 m_DialogStyle == ATTACHED_HAS_CAPTION ? 30 : size.y;
402 wxRect ClientRect = wxGetClientDisplayRect();
403 if (!ClientRect.Intersects(window_title_rect)) b_reset_pos =
true;
409void GribPi::MoveDialog(wxDialog *dialog, wxPoint position) {
411 wxApp *app = wxTheApp;
417 wxPoint p = frame->ScreenToClient(position);
420 if (p.x + dialog->GetSize().GetX() > frame->GetClientSize().GetX())
421 p.x = frame->GetClientSize().GetX() - dialog->GetSize().GetX();
422 if (p.y + dialog->GetSize().GetY() > frame->GetClientSize().GetY())
423 p.y = frame->GetClientSize().GetY() - dialog->GetSize().GetY();
428 dialog->Move(frame->ClientToScreen(p));
434 bool starting =
false;
436 double scale_factor =
439 scale_factor *= m_GribIconsScaleFactor;
441 if (scale_factor != m_GUIScaleFactor) starting =
true;
443 if (!m_pGribCtrlBar) {
445 long style = m_DialogStyle == ATTACHED_HAS_CAPTION
447 : wxBORDER_NONE | wxSYSTEM_MENU;
449 style |= wxSTAY_ON_TOP;
451 m_pGribCtrlBar =
new GRIBUICtrlBar(m_parent_window, wxID_ANY, wxEmptyString,
452 wxDefaultPosition, wxDefaultSize, style,
454 m_pGribCtrlBar->SetScaledBitmap(scale_factor);
456 auto *dummy =
new wxMenu(
"Plugin");
457 auto *table =
new wxMenuItem(dummy, wxID_ANY, wxString(_(
"Weather table")),
458 wxEmptyString, wxITEM_NORMAL);
470 m_pGRIBOverlayFactory->SetMessageFont();
471 m_pGRIBOverlayFactory->SetParentSize(m_display_width, m_display_height);
472 m_pGRIBOverlayFactory->SetSettings(m_bGRIBUseHiDef, m_bGRIBUseGradualColors,
473 m_bDrawBarbedArrowHead);
475 m_pGribCtrlBar->OpenFile(m_bLoadLastOpenFile == 0);
479 if (
id >= 0) m_bShowGrib = !m_bShowGrib;
482 if (m_bShowGrib ||
id < 0) {
484 if (!starting && m_bLoadLastOpenFile == 0) {
485 m_pGribCtrlBar->OpenFile(
true);
489 if (m_pGribCtrlBar->GetFont() != *
OCPNGetFont(_(
"Dialog"))) starting =
true;
491 m_pGRIBOverlayFactory->SetMessageFont();
492 SetDialogFont(m_pGribCtrlBar);
493 m_GUIScaleFactor = scale_factor;
494 m_pGribCtrlBar->SetScaledBitmap(m_GUIScaleFactor);
495 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
496 m_pGribCtrlBar->Refresh();
498 MoveDialog(m_pGribCtrlBar, GetCtrlBarXY());
499 if (m_DialogStyle >> 1 == SEPARATED) {
500 MoveDialog(m_pGribCtrlBar->GetCDataDialog(), GetCursorDataXY());
501 m_pGribCtrlBar->GetCDataDialog()->Show(m_pGribCtrlBar->m_CDataIsShown);
504 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
505 m_pGribCtrlBar->Refresh();
508 if (
id >= 0) m_pGribCtrlBar->Show();
511 ArrayOfGribRecordSets *rsa =
513 if (rsa->GetCount() > 1) {
516 if (rsa->GetCount() >= 1) {
527 if (m_pGribCtrlBar && m_bZoomToCenterAtInit) {
528 m_pGribCtrlBar->DoZoomToCenter();
533 m_pGribCtrlBar->Close();
536void GribPi::OnGribCtrlBarClose() {
540 m_pGribCtrlBar->Hide();
548 if (::wxIsBusy()) ::wxEndBusyCursor();
551 m_DialogStyleChanged =
true;
554 if (m_DialogStyleChanged) {
555 m_pGribCtrlBar->Destroy();
556 m_pGribCtrlBar =
nullptr;
557 m_DialogStyleChanged =
false;
561bool GribPi::RenderOverlay(wxDC &dc,
PlugIn_ViewPort *vp) {
return false; }
563bool GribPi::DoRenderOverlay(wxDC &dc,
PlugIn_ViewPort *vp,
int canvasIndex) {
564 if (!m_pGribCtrlBar || !m_pGribCtrlBar->IsShown() || !m_pGRIBOverlayFactory)
567 m_pGRIBOverlayFactory->RenderGribOverlay(dc, vp);
574 if (m_pGribCtrlBar->pReq_Dialog &&
576 m_pGribCtrlBar->pReq_Dialog->GetBoundingBoxCanvasIndex()) {
580 if (::wxIsBusy()) ::wxEndBusyCursor();
588bool GribPi::DoRenderGLOverlay(wxGLContext *pcontext,
PlugIn_ViewPort *vp,
590 if (!m_pGribCtrlBar || !m_pGribCtrlBar->IsShown() || !m_pGRIBOverlayFactory)
593 m_pGRIBOverlayFactory->RenderGLGribOverlay(pcontext, vp);
600 if (m_pGribCtrlBar->pReq_Dialog &&
602 m_pGribCtrlBar->pReq_Dialog->GetBoundingBoxCanvasIndex()) {
607 if (::wxIsBusy()) ::wxEndBusyCursor();
610 m_pGribCtrlBar->Raise();
618 return DoRenderGLOverlay(pcontext, vp, canvasIndex);
623 return DoRenderOverlay(dc, vp, canvasIndex);
627 if (m_pGribCtrlBar && m_pGribCtrlBar->IsShown())
628 m_pGribCtrlBar->SetCursorLatLon(lat, lon);
633 m_pGribCtrlBar->ContextMenuItemCallback(
id);
636void GribPi::SetDialogFont(wxWindow *dialog, wxFont *font) {
637 dialog->SetFont(*font);
638 wxWindowList list = dialog->GetChildren();
639 wxWindowList::compatibility_iterator node = list.GetFirst();
640 for (
size_t i = 0; i < list.GetCount(); i++) {
641 wxWindow *win = node->GetData();
643 node = node->GetNext();
649void GribPi::SetPluginMessage(wxString &message_id, wxString &message_body) {
650 if (message_id ==
"GRIB_VALUES_REQUEST") {
656 r.
Parse(message_body, &v);
662 wxDateTime time(v[
"Day"].AsInt(), (wxDateTime::Month)v[
"Month"].AsInt(),
663 v[
"Year"].AsInt(), v[
"Hour"].AsInt(), v[
"Minute"].AsInt(),
664 v[
"Second"].AsInt());
668 if (m_pGribCtrlBar) {
671 if (m_pGribCtrlBar->getTimeInterpolatedValues(
673 vkn != GRIB_NOTDEF) {
674 v[
"Type"] = wxString(
"Reply");
675 v[
"WIND SPEED"] = vkn;
684 if (m_pGribCtrlBar->getTimeInterpolatedValues(
687 vkn != GRIB_NOTDEF) {
688 v[
"Type"] = wxString(
"Reply");
689 v[
"CURRENT SPEED"] = vkn;
690 v[
"CURRENT DIR"] = ang;
692 v.
Remove(
"CURRENT SPEED");
697 double vkn = m_pGribCtrlBar->getTimeInterpolatedValue(
Idx_WIND_GUST,
699 if (vkn != GRIB_NOTDEF) {
700 v[
"Type"] = wxString(
"Reply");
706 double vkn = m_pGribCtrlBar->getTimeInterpolatedValue(
Idx_HTSIGW, lon,
708 if (vkn != GRIB_NOTDEF) {
709 v[
"Type"] = wxString(
"Reply");
720 }
else if (message_id ==
"GRIB_VERSION_REQUEST") {
729 }
else if (message_id ==
"GRIB_TIMELINE_REQUEST") {
731 SendTimelineMessage(m_pGribCtrlBar ? m_pGribCtrlBar->
TimelineTime()
732 : wxDateTime::Now());
733 }
else if (message_id ==
"GRIB_TIMELINE_RECORD_REQUEST") {
736 r.
Parse(message_body, &v);
737 wxDateTime time(v[
"Day"].AsInt(), (wxDateTime::Month)v[
"Month"].AsInt(),
738 v[
"Year"].AsInt(), v[
"Hour"].AsInt(), v[
"Minute"].AsInt(),
739 v[
"Second"].AsInt());
747 snprintf(ptr,
sizeof ptr,
"%p", set);
749 v[
"GribVersionMajor"] = PLUGIN_VERSION_MAJOR;
750 v[
"GribVersionMinor"] = PLUGIN_VERSION_MINOR;
751 v[
"TimelineSetPtr"] = wxString::From8BitData(ptr);
757 delete m_pLastTimelineSet;
758 m_pLastTimelineSet = set;
761 else if (message_id ==
"GRIB_APPLY_JSON_CONFIG") {
762 wxLogMessage(
"Got GRIB_APPLY_JSON_CONFIG");
764 if (m_pGribCtrlBar) {
765 m_pGribCtrlBar->OpenFileFromJSON(message_body);
769 m_pGribCtrlBar->SetDialogsStyleSizePosition(
true);
774bool GribPi::LoadConfig() {
775 auto *pConf = (wxFileConfig *)m_pconfig;
777 if (!pConf)
return false;
779 pConf->SetPath(
"/PlugIns/GRIB");
780 pConf->Read(
"LoadLastOpenFile", &m_bLoadLastOpenFile, 0);
781 pConf->Read(
"OpenFileOption", &m_bStartOptions, 1);
782 pConf->Read(
"GRIBUseHiDef", &m_bGRIBUseHiDef,
false);
783 pConf->Read(
"GRIBUseGradualColors", &m_bGRIBUseGradualColors,
false);
784 pConf->Read(
"DrawBarbedArrowHead", &m_bDrawBarbedArrowHead,
true);
785 pConf->Read(
"ZoomToCenterAtInit", &m_bZoomToCenterAtInit,
true);
786 pConf->Read(
"ShowGRIBIcon", &m_bGRIBShowIcon,
true);
787 pConf->Read(
"CopyFirstCumulativeRecord", &m_bCopyFirstCumRec,
true);
788 pConf->Read(
"CopyMissingWaveRecord", &m_bCopyMissWaveRec,
true);
790 pConf->Read(
"GribIconsScaleFactor", &m_GribIconsScaleFactor, 1);
793 m_CtrlBar_Sizexy.x = pConf->Read(
"GRIBCtrlBarSizeX", 1400L);
794 m_CtrlBar_Sizexy.y = pConf->Read(
"GRIBCtrlBarSizeY", 800L);
795 m_CtrlBarxy.x = pConf->Read(
"GRIBCtrlBarPosX", 20L);
796 m_CtrlBarxy.y = pConf->Read(
"GRIBCtrlBarPosY", 60L);
797 m_CursorDataxy.x = pConf->Read(
"GRIBCursorDataPosX", 20L);
798 m_CursorDataxy.y = pConf->Read(
"GRIBCursorDataPosY", 170L);
800 pConf->Read(
"GribCursorDataDisplayStyle", &m_DialogStyle, 0);
801 if (m_DialogStyle > 3)
807bool GribPi::SaveConfig(
void) {
808 wxFileConfig *pConf = (wxFileConfig *)m_pconfig;
810 if (!pConf)
return false;
812 pConf->SetPath(
"/PlugIns/GRIB");
814 pConf->Write(
"LoadLastOpenFile", m_bLoadLastOpenFile);
815 pConf->Write(
"OpenFileOption", m_bStartOptions);
816 pConf->Write(
"ShowGRIBIcon", m_bGRIBShowIcon);
817 pConf->Write(
"GRIBUseHiDef", m_bGRIBUseHiDef);
818 pConf->Write(
"GRIBUseGradualColors", m_bGRIBUseGradualColors);
819 pConf->Write(
"CopyFirstCumulativeRecord", m_bCopyFirstCumRec);
820 pConf->Write(
"CopyMissingWaveRecord", m_bCopyMissWaveRec);
821 pConf->Write(
"DrawBarbedArrowHead", m_bDrawBarbedArrowHead);
822 pConf->Write(
"ZoomToCenterAtInit", m_bZoomToCenterAtInit);
824 pConf->Write(
"GribIconsScaleFactor", m_GribIconsScaleFactor);
827 pConf->Write(
"GRIBCtrlBarSizeX", m_CtrlBar_Sizexy.x);
828 pConf->Write(
"GRIBCtrlBarSizeY", m_CtrlBar_Sizexy.y);
829 pConf->Write(
"GRIBCtrlBarPosX", m_CtrlBarxy.x);
830 pConf->Write(
"GRIBCtrlBarPosY", m_CtrlBarxy.y);
831 pConf->Write(
"GRIBCursorDataPosX", m_CursorDataxy.x);
832 pConf->Write(
"GRIBCursorDataPosY", m_CursorDataxy.y);
839 if (m_pGribCtrlBar) {
840 if (m_pGRIBOverlayFactory) m_pGRIBOverlayFactory->ClearCachedLabel();
841 if (m_pGribCtrlBar->pReq_Dialog) m_pGribCtrlBar->pReq_Dialog->Refresh();
842 m_pGribCtrlBar->Refresh();
847void GribPi::SendTimelineMessage(wxDateTime time) {
848 if (!m_pGribCtrlBar)
return;
851 if (time.IsValid()) {
852 v[
"Day"] = time.GetDay();
853 v[
"Month"] = time.GetMonth();
854 v[
"Year"] = time.GetYear();
855 v[
"Hour"] = time.GetHour();
856 v[
"Minute"] = time.GetMinute();
857 v[
"Second"] = time.GetSecond();
873 m_boat_cog = pfix.
Cog;
874 m_boat_sog = pfix.
Sog;
875 m_boat_lat = pfix.
Lat;
876 m_boat_lon = pfix.
Lon;
880 m_boat_time = wxDateTime::Now().GetTicks();
887void GribPreferencesDialog::OnStartOptionChange(wxCommandEvent &event) {
888 if (m_rbStartOptions->GetSelection() == 2) {
891 _(
"You have chosen to authorize interpolation.\nDon't forget that data "
892 "displayed at current time will not be real but Recomputed\nThis can "
893 "decrease accuracy!"),
898void GribPreferencesDialog::OnOKClick(wxCommandEvent &event) {
899 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.