31#include <wx/glcanvas.h>
32#include <wx/graphics.h>
33#include <wx/progdlg.h>
37#include <wx/tokenzr.h>
39extern double m_cursor_lat, m_cursor_lon;
45 m_pGribTable->m_gParent =
this;
49 wxGridCellAttr *datarow =
new wxGridCellAttr();
51 datarow->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
55 l.Append(toSDMM_PlugIn(1, m_cursor_lat))
57 .Append(toSDMM_PlugIn(2, m_cursor_lon));
58 m_pCursorPosition->SetLabel(l);
59 m_pCursorPosition->SetFont(
64 m_pGribTable->AppendCols(rsa->GetCount());
67 wxDateTime time, day, ptime;
69 for (
unsigned i = 0; i < rsa->GetCount(); i++) {
71 time = rsa->Item(i).m_Reference_Time;
74 m_pGribTable->SetColLabelValue(
75 i, toUsrDateTimeFormat_Plugin(wxDateTime(time), opts));
78 if (pTimeset == 0)
continue;
92 AddDataRow(nrows, i, _(
"Wind,Dir"), datarow);
94 GetWind(RecordArray, 1, wdir);
95 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
96 m_pGribTable->SetNumericalRow(nrows, i, R_WIND, wdir);
98 AddDataRow(nrows, i, _(
"Wind,Speed"), datarow);
100 .m_Units != GribOverlaySettings::BFS)
101 m_pGribTable->SetCellValue(nrows, i, GetWind(RecordArray, 2, wdir));
103 m_pGribTable->SetCellValue(nrows, i, GetWind(RecordArray, 3, wdir));
104 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
108 AddDataRow(nrows, i, _(
"Wind,Gust"), datarow);
110 .m_Units != GribOverlaySettings::BFS)
111 m_pGribTable->SetCellValue(nrows, i, GetWindGust(RecordArray, 1));
113 m_pGribTable->SetCellValue(nrows, i, GetWindGust(RecordArray, 2));
114 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
122 AddDataRow(nrows, i, _(
"Pressure"), datarow);
123 m_pGribTable->SetCellValue(nrows, i, GetPressure(RecordArray));
137 AddDataRow(nrows, i, _(
"Waves,Dir"), datarow);
139 m_pGribTable->SetNumericalRow(nrows, i, R_WAVES, wdir);
142 AddDataRow(nrows, i, _(
"Waves,Hsig"), datarow);
143 m_pGribTable->SetCellValue(nrows, i,
145 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
149 AddDataRow(nrows, i, _(
"Waves,Per"), datarow);
150 m_pGribTable->SetCellValue(nrows, i,
159 AddDataRow(nrows, i, _(
"Rainfall"), datarow);
160 m_pGribTable->SetCellValue(nrows, i, GetRainfall(RecordArray));
161 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
168 AddDataRow(nrows, i, _(
"Cloud Cover"), datarow);
169 m_pGribTable->SetCellValue(nrows, i, GetCloudCover(RecordArray));
170 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
177 AddDataRow(nrows, i, _(
"Air Temp."), datarow);
178 m_pGribTable->SetCellValue(nrows, i, GetAirTemp(RecordArray));
179 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
186 AddDataRow(nrows, i, _(
"Sea Temp."), datarow);
187 m_pGribTable->SetCellValue(nrows, i, GetSeaTemp(RecordArray));
188 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
196 AddDataRow(nrows, i, _(
"CAPE"), datarow);
197 m_pGribTable->SetCellValue(nrows, i, GetCAPE(RecordArray));
198 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
205 AddDataRow(nrows, i, _(
"C. Reflect."), datarow);
206 m_pGribTable->SetCellValue(nrows, i, GetCompRefl(RecordArray));
207 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
219 AddDataRow(nrows, i, _(
"Current,Dir"), datarow);
220 GetCurrent(RecordArray, 1, wdir);
221 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
222 m_pGribTable->SetNumericalRow(nrows, i, R_CURRENT, wdir);
225 AddDataRow(nrows, i, _(
"Current,Speed"), datarow);
226 m_pGribTable->SetCellValue(nrows, i, GetCurrent(RecordArray, 2, wdir));
227 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
230 m_pGribTable->AutoSizeColumn(i,
false);
231 wcols = wxMax(m_pGribTable->GetColSize(i), wcols);
234 m_pGribTable->SetGridCursor(m_pGribTable->GetNumberRows() - 1, 0);
236 m_pGribTable->SetDefaultColSize(wcols,
true);
240 m_pGribTable->SetColLabelSize(wxGRID_AUTOSIZE);
242 m_pGribTable->SetScrollLineX(wcols);
246 m_tScrollToNowTimer.Connect(
247 wxEVT_TIMER, wxTimerEventHandler(GRIBTable::OnScrollToNowTimer),
nullptr,
253 int x = -1, y = -1, w = -1, h = -1;
256 pConf->SetPath(_T(
"/Settings/GRIB"));
257 pConf->Read(_T(
"GribDataTablePosition_x"), &x);
258 pConf->Read(_T(
"GribDataTablePosition_y"), &y);
259 pConf->Read(_T(
"GribDataTableWidth"), &w);
260 pConf->Read(_T(
"GribDataTableHeight"), &h);
268 if (!(wxRect(pcw, scw).Contains(wxRect(final_pos, wxSize(w, h)))))
270 if (w < (m_pGribTable->GetRowLabelSize() + (m_pGribTable->GetColSize(0))) ||
271 h < (m_pGribTable->GetColLabelSize() + (m_pGribTable->GetRowSize(0))))
278 w = (scw.GetWidth() / 10) * 9;
279 h = (scw.GetHeight() / 10) * 9;
280 x = (scw.GetWidth() / 20);
281 y = (scw.GetHeight() / 50);
284 y = m_pGDialog->GetSize().GetHeight() * 11 / 10;
285 h = scw.GetHeight() - m_pGDialog->GetSize().GetHeight();
290 int w1 = m_pGribTable->GetRowLabelSize() +
291 (m_pGribTable->GetColSize(0) * m_pGribTable->GetNumberCols());
293 int h1 = m_pGribTable->GetColLabelSize() +
294 (m_pGribTable->GetRowSize(0) * (m_pGribTable->GetNumberRows() + 4));
297 this->SetClientSize(w, h);
298 this->Move(final_pos);
301 m_pGribTable->MakeCellVisible(0, m_pGribTable->GetNumberCols() - 1);
303 m_tScrollToNowTimer.Start(200, wxTIMER_ONE_SHOT);
306void GRIBTable::OnScrollToNowTimer(wxTimerEvent &event) {
307 m_pGribTable->MakeCellVisible(0, m_pIndex);
310void GRIBTable::OnClose(wxCloseEvent &event) {
312 this->EndModal(wxID_OK);
315void GRIBTable::OnOKButton(wxCommandEvent &event) {
317 this->EndModal(wxID_OK);
320void GRIBTable::CloseDialog() {
321 wxSize s = this->GetClientSize();
326 pConf->SetPath(_T (
"/Settings/GRIB" ));
328 pConf->Write(_T (
"GribDataTablePosition_x" ), p.x);
329 pConf->Write(_T (
"GribDataTablePosition_y" ), p.y);
330 pConf->Write(_T (
"GribDataTableWidth" ), s.GetWidth());
331 pConf->Write(_T (
"GribDataTableHeight" ), s.GetHeight());
335void GRIBTable::AddDataRow(
int num_rows,
int num_cols, wxString label,
336 wxGridCellAttr *row_attr) {
337 if (m_pGribTable->GetNumberRows() == num_rows) {
338 m_pGribTable->AppendRows(1);
339 m_pGribTable->SetRowLabelValue(num_rows, label);
341 m_pGribTable->SetRowAttr(num_rows, row_attr);
343 m_pDataCellsColour = m_pGribTable->GetCellBackgroundColour(
347void GRIBTable::AutoSizeDataRows() {
349 for (
int i = 0; i < m_pGribTable->GetNumberRows(); i++) {
350 m_pGribTable->AutoSizeRow(i,
false);
351 hrows = wxMax(m_pGribTable->GetRowHeight(i) + 3, hrows);
353 m_pGribTable->SetDefaultRowSize(hrows,
true);
355 m_pGribTable->SetScrollLineY(hrows);
358wxString GRIBTable::GetWind(
GribRecord **recordarray,
int datatype,
360 wxString skn(wxEmptyString);
366 recordarray[
Idx_WIND_VY + altitude], m_cursor_lon, m_cursor_lat)) {
372 GribOverlaySettings::WIND, vkn);
374 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
375 GribOverlaySettings::WIND, cvkn);
376 skn.Printf(wxString::Format(
381 skn.Prepend(wxString::Format(
383 GribOverlaySettings::WIND),
384 (
int)wxRound(cvkn)) +
391wxString GRIBTable::GetWindGust(
GribRecord **recordarray,
int datatype) {
392 wxString skn(wxEmptyString);
395 m_cursor_lon, m_cursor_lat,
true);
396 if (vkn != GRIB_NOTDEF) {
398 GribOverlaySettings::WIND_GUST, vkn);
400 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
401 GribOverlaySettings::WIND_GUST, cvkn);
403 skn.Printf(wxString::Format(
411 GribOverlaySettings::WIND_GUST),
412 (
int)wxRound(cvkn)) +
420wxString GRIBTable::GetPressure(
GribRecord **recordarray) {
421 wxString skn(wxEmptyString);
424 m_cursor_lon, m_cursor_lat,
true);
426 if (press != GRIB_NOTDEF) {
428 GribOverlaySettings::PRESSURE, press);
434 skn.Printf(wxString::Format(
436 GribOverlaySettings::PRESSURE),
443wxString GRIBTable::GetWaves(
GribRecord **recordarray,
int datatype,
445 wxString skn(wxEmptyString);
451 m_cursor_lon, m_cursor_lat,
true);
452 if (height != GRIB_NOTDEF) {
454 GribOverlaySettings::WAVE, height);
455 skn.Printf(wxString::Format(
457 GribOverlaySettings::WAVE),
460 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
461 GribOverlaySettings::WAVE, cheight);
468 m_cursor_lon, m_cursor_lat,
true,
true);
476 m_cursor_lon, m_cursor_lat,
true);
477 if (period != GRIB_NOTDEF)
478 skn.Printf(wxString::Format(_T(
"%01ds"), (
int)(period + 0.5)));
484wxString GRIBTable::GetRainfall(
GribRecord **recordarray) {
485 wxString skn(wxEmptyString);
488 m_cursor_lon, m_cursor_lat,
true);
490 if (precip != GRIB_NOTDEF) {
492 GribOverlaySettings::PRECIPITATION, precip);
494 GribOverlaySettings::PRECIPITATION),
497 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
498 GribOverlaySettings::PRECIPITATION, precip);
504wxString GRIBTable::GetCloudCover(
GribRecord **recordarray) {
505 wxString skn(wxEmptyString);
508 m_cursor_lon, m_cursor_lat,
true);
510 if (cloud != GRIB_NOTDEF) {
512 GribOverlaySettings::CLOUD, cloud);
513 skn.Printf(_T(
"%5.1f "), cloud);
515 GribOverlaySettings::CLOUD));
517 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
518 GribOverlaySettings::CLOUD, cloud);
524wxString GRIBTable::GetAirTemp(
GribRecord **recordarray) {
525 wxString skn(wxEmptyString);
528 m_cursor_lon, m_cursor_lat,
true);
530 if (temp != GRIB_NOTDEF) {
532 GribOverlaySettings::AIR_TEMPERATURE, temp);
534 GribOverlaySettings::AIR_TEMPERATURE),
537 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
538 GribOverlaySettings::AIR_TEMPERATURE, temp);
544wxString GRIBTable::GetSeaTemp(
GribRecord **recordarray) {
545 wxString skn(wxEmptyString);
548 m_cursor_lon, m_cursor_lat,
true);
550 if (temp != GRIB_NOTDEF) {
552 GribOverlaySettings::SEA_TEMPERATURE, temp);
554 GribOverlaySettings::SEA_TEMPERATURE),
557 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
558 GribOverlaySettings::SEA_TEMPERATURE, temp);
564wxString GRIBTable::GetCAPE(
GribRecord **recordarray) {
565 wxString skn(wxEmptyString);
568 m_cursor_lon, m_cursor_lat,
true);
570 if (cape != GRIB_NOTDEF) {
572 GribOverlaySettings::CAPE, cape);
573 skn.Printf(wxString::Format(
575 GribOverlaySettings::CAPE),
578 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
579 GribOverlaySettings::CAPE, cape);
585wxString GRIBTable::GetCompRefl(
GribRecord **recordarray) {
586 wxString skn(wxEmptyString);
589 m_cursor_lon, m_cursor_lat,
true);
591 if (refl != GRIB_NOTDEF) {
593 GribOverlaySettings::COMP_REFL, refl);
594 skn.Printf(wxString::Format(
596 GribOverlaySettings::COMP_REFL),
599 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
600 GribOverlaySettings::COMP_REFL, refl);
606wxString GRIBTable::GetCurrent(
GribRecord **recordarray,
int datatype,
608 wxString skn(wxEmptyString);
619 GribOverlaySettings::CURRENT, vkn);
620 skn.Printf(wxString::Format(
622 GribOverlaySettings::CURRENT),
625 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
626 GribOverlaySettings::CURRENT, vkn);
Specialized Grid Control for GRIB Data Display.
@ Idx_COMP_REFL
Composite radar reflectivity in dBZ (decibel relative to Z)
@ Idx_PRECIP_TOT
Precipitation data in millimeters per hour.
@ Idx_AIR_TEMP
Air temperature at 2m in Kelvin (K)
@ Idx_PRESSURE
Surface pressure in Pascal (Pa)
@ Idx_WVDIR
Wave direction.
@ Idx_CLOUD_TOT
Total cloud cover in % (percent, range 0-100%)
@ 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_SEA_TEMP
Sea surface temperature in Kelvin (K)
@ Idx_WIND_VY
Surface wind velocity Y component in m/s.
@ Idx_SEACURRENT_VX
Sea current velocity X component in m/s.
@ Idx_CAPE
Convective Available Potential Energy in J/kg (Joules per kilogram)
GRIB Data Table View and Export Interface.
void SetTableSizePosition(int vpWidth, int vpHeight)
Set the table size and position relative to viewport.
void InitGribTable(ArrayOfGribRecordSets *rsa)
Initialize the GRIB data table.
GribOverlaySettings m_OverlaySettings
Settings that control how GRIB data is displayed and overlaid.
grib_pi * pPlugIn
Plugin instance that owns this control bar.
GRIBFile * m_bGRIBActiveFile
Currently active GRIB file being displayed.
GribTimelineRecordSet * GetTimeLineRecordSet(wxDateTime time)
Retrieves or creates a temporally interpolated GRIB record set for a specific timestamp.
GribRecord * m_GribRecordPtrArray[Idx_COUNT]
Array of pointers to GRIB records representing different meteorological parameters.
Represents a meteorological data grid from a GRIB (Gridded Binary) file.
double getInterpolatedValue(double px, double py, bool numericalInterpolation=true, bool dir=false) const
Get spatially interpolated value at exact lat/lon position.
static bool getInterpolatedValues(double &M, double &A, const GribRecord *GRX, const GribRecord *GRY, double px, double py, bool numericalInterpolation=true)
Gets spatially interpolated wind or current vector values at a specific latitude/longitude point.
A specialized GribRecordSet that represents temporally interpolated weather data with isobar renderin...
int GetChartbarHeight(void)
Gets height of chart bar in pixels.
wxWindow * GetOCPNCanvasWindow()
Gets OpenCPN's main canvas window.
wxFont GetOCPNGUIScaledFont_PlugIn(wxString item)
Gets a uniquely scaled font copy for responsive UI elements.
wxFileConfig * GetOCPNConfigObject(void)
Gets OpenCPN's configuration object.
OpenGL Platform Abstraction Layer.