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;
46 m_pGribTable->m_gParent =
this;
50 wxGridCellAttr *datarow =
new wxGridCellAttr();
52 datarow->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
56 l.Append(toSDMM_PlugIn(1, m_cursor_lat))
58 .Append(toSDMM_PlugIn(2, m_cursor_lon));
59 m_pCursorPosition->SetLabel(l);
60 m_pCursorPosition->SetFont(
65 m_pGribTable->AppendCols(rsa->GetCount());
68 wxDateTime time, day, ptime;
70 for (
unsigned i = 0; i < rsa->GetCount(); i++) {
72 time = rsa->Item(i).m_Reference_Time;
77 m_pGribTable->SetColLabelValue(
78 i, toUsrDateTimeFormat_Plugin(wxDateTime(time), opts));
81 if (pTimeset == 0)
continue;
95 AddDataRow(nrows, i, _(
"Wind,Dir"), datarow);
97 GetWind(RecordArray, 1, wdir);
98 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
99 m_pGribTable->SetNumericalRow(nrows, i, R_WIND, wdir);
101 AddDataRow(nrows, i, _(
"Wind,Speed"), datarow);
103 .m_Units != GribOverlaySettings::BFS)
104 m_pGribTable->SetCellValue(nrows, i, GetWind(RecordArray, 2, wdir));
106 m_pGribTable->SetCellValue(nrows, i, GetWind(RecordArray, 3, wdir));
107 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
111 AddDataRow(nrows, i, _(
"Wind,Gust"), datarow);
113 .m_Units != GribOverlaySettings::BFS)
114 m_pGribTable->SetCellValue(nrows, i, GetWindGust(RecordArray, 1));
116 m_pGribTable->SetCellValue(nrows, i, GetWindGust(RecordArray, 2));
117 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
125 AddDataRow(nrows, i, _(
"Pressure"), datarow);
126 m_pGribTable->SetCellValue(nrows, i, GetPressure(RecordArray));
140 AddDataRow(nrows, i, _(
"Waves,Dir"), datarow);
142 m_pGribTable->SetNumericalRow(nrows, i, R_WAVES, wdir);
145 AddDataRow(nrows, i, _(
"Waves,Hsig"), datarow);
146 m_pGribTable->SetCellValue(nrows, i,
148 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
152 AddDataRow(nrows, i, _(
"Waves,Per"), datarow);
153 m_pGribTable->SetCellValue(nrows, i,
162 AddDataRow(nrows, i, _(
"Rainfall"), datarow);
163 m_pGribTable->SetCellValue(nrows, i, GetRainfall(RecordArray));
164 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
171 AddDataRow(nrows, i, _(
"Cloud Cover"), datarow);
172 m_pGribTable->SetCellValue(nrows, i, GetCloudCover(RecordArray));
173 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
180 AddDataRow(nrows, i, _(
"Air Temp."), datarow);
181 m_pGribTable->SetCellValue(nrows, i, GetAirTemp(RecordArray));
182 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
189 AddDataRow(nrows, i, _(
"Sea Temp."), datarow);
190 m_pGribTable->SetCellValue(nrows, i, GetSeaTemp(RecordArray));
191 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
199 AddDataRow(nrows, i, _(
"CAPE"), datarow);
200 m_pGribTable->SetCellValue(nrows, i, GetCAPE(RecordArray));
201 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
208 AddDataRow(nrows, i, _(
"C. Reflect."), datarow);
209 m_pGribTable->SetCellValue(nrows, i, GetCompRefl(RecordArray));
210 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
222 AddDataRow(nrows, i, _(
"Current,Dir"), datarow);
223 GetCurrent(RecordArray, 1, wdir);
224 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
225 m_pGribTable->SetNumericalRow(nrows, i, R_CURRENT, wdir);
228 AddDataRow(nrows, i, _(
"Current,Speed"), datarow);
229 m_pGribTable->SetCellValue(nrows, i, GetCurrent(RecordArray, 2, wdir));
230 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
233 m_pGribTable->AutoSizeColumn(i,
false);
234 wcols = wxMax(m_pGribTable->GetColSize(i), wcols);
237 m_pGribTable->SetGridCursor(m_pGribTable->GetNumberRows() - 1, 0);
239 m_pGribTable->SetDefaultColSize(wcols,
true);
243 m_pGribTable->SetColLabelSize(wxGRID_AUTOSIZE);
245 m_pGribTable->SetScrollLineX(wcols);
249 m_tScrollToNowTimer.Connect(
250 wxEVT_TIMER, wxTimerEventHandler(GRIBTable::OnScrollToNowTimer),
nullptr,
256 int x = -1, y = -1, w = -1, h = -1;
259 pConf->SetPath(_T(
"/Settings/GRIB"));
260 pConf->Read(_T(
"GribDataTablePosition_x"), &x);
261 pConf->Read(_T(
"GribDataTablePosition_y"), &y);
262 pConf->Read(_T(
"GribDataTableWidth"), &w);
263 pConf->Read(_T(
"GribDataTableHeight"), &h);
271 if (!(wxRect(pcw, scw).Contains(wxRect(final_pos, wxSize(w, h)))))
273 if (w < (m_pGribTable->GetRowLabelSize() + (m_pGribTable->GetColSize(0))) ||
274 h < (m_pGribTable->GetColLabelSize() + (m_pGribTable->GetRowSize(0))))
281 w = (scw.GetWidth() / 10) * 9;
282 h = (scw.GetHeight() / 10) * 9;
283 x = (scw.GetWidth() / 20);
284 y = (scw.GetHeight() / 50);
287 y = m_pGDialog->GetSize().GetHeight() * 11 / 10;
288 h = scw.GetHeight() - m_pGDialog->GetSize().GetHeight();
293 int w1 = m_pGribTable->GetRowLabelSize() +
294 (m_pGribTable->GetColSize(0) * m_pGribTable->GetNumberCols());
296 int h1 = m_pGribTable->GetColLabelSize() +
297 (m_pGribTable->GetRowSize(0) * (m_pGribTable->GetNumberRows() + 4));
300 this->SetClientSize(w, h);
301 this->Move(final_pos);
304 m_pGribTable->MakeCellVisible(0, m_pGribTable->GetNumberCols() - 1);
306 m_tScrollToNowTimer.Start(200, wxTIMER_ONE_SHOT);
309void GRIBTable::OnScrollToNowTimer(wxTimerEvent &event) {
310 m_pGribTable->MakeCellVisible(0, m_pIndex);
313void GRIBTable::OnClose(wxCloseEvent &event) {
315 this->EndModal(wxID_OK);
318void GRIBTable::OnOKButton(wxCommandEvent &event) {
320 this->EndModal(wxID_OK);
323void GRIBTable::CloseDialog() {
324 wxSize s = this->GetClientSize();
329 pConf->SetPath(_T (
"/Settings/GRIB" ));
331 pConf->Write(_T (
"GribDataTablePosition_x" ), p.x);
332 pConf->Write(_T (
"GribDataTablePosition_y" ), p.y);
333 pConf->Write(_T (
"GribDataTableWidth" ), s.GetWidth());
334 pConf->Write(_T (
"GribDataTableHeight" ), s.GetHeight());
338void GRIBTable::AddDataRow(
int num_rows,
int num_cols, wxString label,
339 wxGridCellAttr *row_attr) {
340 if (m_pGribTable->GetNumberRows() == num_rows) {
341 m_pGribTable->AppendRows(1);
342 m_pGribTable->SetRowLabelValue(num_rows, label);
344 m_pGribTable->SetRowAttr(num_rows, row_attr);
346 m_pDataCellsColour = m_pGribTable->GetCellBackgroundColour(
350void GRIBTable::AutoSizeDataRows() {
352 for (
int i = 0; i < m_pGribTable->GetNumberRows(); i++) {
353 m_pGribTable->AutoSizeRow(i,
false);
354 hrows = wxMax(m_pGribTable->GetRowHeight(i) + 3, hrows);
356 m_pGribTable->SetDefaultRowSize(hrows,
true);
358 m_pGribTable->SetScrollLineY(hrows);
361wxString GRIBTable::GetWind(
GribRecord **recordarray,
int datatype,
363 wxString skn(wxEmptyString);
369 recordarray[
Idx_WIND_VY + altitude], m_cursor_lon, m_cursor_lat)) {
375 GribOverlaySettings::WIND, vkn);
377 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
378 GribOverlaySettings::WIND, cvkn);
379 skn.Printf(wxString::Format(
384 skn.Prepend(wxString::Format(
386 GribOverlaySettings::WIND),
387 (
int)wxRound(cvkn)) +
394wxString GRIBTable::GetWindGust(
GribRecord **recordarray,
int datatype) {
395 wxString skn(wxEmptyString);
398 m_cursor_lon, m_cursor_lat,
true);
399 if (vkn != GRIB_NOTDEF) {
401 GribOverlaySettings::WIND_GUST, vkn);
403 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
404 GribOverlaySettings::WIND_GUST, cvkn);
406 skn.Printf(wxString::Format(
414 GribOverlaySettings::WIND_GUST),
415 (
int)wxRound(cvkn)) +
423wxString GRIBTable::GetPressure(
GribRecord **recordarray) {
424 wxString skn(wxEmptyString);
427 m_cursor_lon, m_cursor_lat,
true);
429 if (press != GRIB_NOTDEF) {
431 GribOverlaySettings::PRESSURE, press);
437 skn.Printf(wxString::Format(
439 GribOverlaySettings::PRESSURE),
446wxString GRIBTable::GetWaves(
GribRecord **recordarray,
int datatype,
448 wxString skn(wxEmptyString);
454 m_cursor_lon, m_cursor_lat,
true);
455 if (height != GRIB_NOTDEF) {
457 GribOverlaySettings::WAVE, height);
458 skn.Printf(wxString::Format(
460 GribOverlaySettings::WAVE),
463 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
464 GribOverlaySettings::WAVE, cheight);
471 m_cursor_lon, m_cursor_lat,
true,
true);
479 m_cursor_lon, m_cursor_lat,
true);
480 if (period != GRIB_NOTDEF)
481 skn.Printf(wxString::Format(_T(
"%01ds"), (
int)(period + 0.5)));
487wxString GRIBTable::GetRainfall(
GribRecord **recordarray) {
488 wxString skn(wxEmptyString);
491 m_cursor_lon, m_cursor_lat,
true);
493 if (precip != GRIB_NOTDEF) {
495 GribOverlaySettings::PRECIPITATION, precip);
497 GribOverlaySettings::PRECIPITATION),
500 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
501 GribOverlaySettings::PRECIPITATION, precip);
507wxString GRIBTable::GetCloudCover(
GribRecord **recordarray) {
508 wxString skn(wxEmptyString);
511 m_cursor_lon, m_cursor_lat,
true);
513 if (cloud != GRIB_NOTDEF) {
515 GribOverlaySettings::CLOUD, cloud);
516 skn.Printf(_T(
"%5.1f "), cloud);
518 GribOverlaySettings::CLOUD));
520 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
521 GribOverlaySettings::CLOUD, cloud);
527wxString GRIBTable::GetAirTemp(
GribRecord **recordarray) {
528 wxString skn(wxEmptyString);
531 m_cursor_lon, m_cursor_lat,
true);
533 if (temp != GRIB_NOTDEF) {
535 GribOverlaySettings::AIR_TEMPERATURE, temp);
537 GribOverlaySettings::AIR_TEMPERATURE),
540 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
541 GribOverlaySettings::AIR_TEMPERATURE, temp);
547wxString GRIBTable::GetSeaTemp(
GribRecord **recordarray) {
548 wxString skn(wxEmptyString);
551 m_cursor_lon, m_cursor_lat,
true);
553 if (temp != GRIB_NOTDEF) {
555 GribOverlaySettings::SEA_TEMPERATURE, temp);
557 GribOverlaySettings::SEA_TEMPERATURE),
560 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
561 GribOverlaySettings::SEA_TEMPERATURE, temp);
567wxString GRIBTable::GetCAPE(
GribRecord **recordarray) {
568 wxString skn(wxEmptyString);
571 m_cursor_lon, m_cursor_lat,
true);
573 if (cape != GRIB_NOTDEF) {
575 GribOverlaySettings::CAPE, cape);
576 skn.Printf(wxString::Format(
578 GribOverlaySettings::CAPE),
581 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
582 GribOverlaySettings::CAPE, cape);
588wxString GRIBTable::GetCompRefl(
GribRecord **recordarray) {
589 wxString skn(wxEmptyString);
592 m_cursor_lon, m_cursor_lat,
true);
594 if (refl != GRIB_NOTDEF) {
596 GribOverlaySettings::COMP_REFL, refl);
597 skn.Printf(wxString::Format(
599 GribOverlaySettings::COMP_REFL),
602 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
603 GribOverlaySettings::COMP_REFL, refl);
609wxString GRIBTable::GetCurrent(
GribRecord **recordarray,
int datatype,
611 wxString skn(wxEmptyString);
622 GribOverlaySettings::CURRENT, vkn);
623 skn.Printf(wxString::Format(
625 GribOverlaySettings::CURRENT),
628 m_pGDialog->
pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
629 GribOverlaySettings::CURRENT, vkn);
Specialized Grid Control for GRIB Data Display.
@ Idx_COMP_REFL
Composite radar reflectivity.
@ Idx_PRECIP_TOT
Total precipitation.
@ Idx_AIR_TEMP
Air temperature at 2m.
@ Idx_PRESSURE
Surface pressure.
@ Idx_WVDIR
Wave direction.
@ Idx_CLOUD_TOT
Total cloud cover.
@ 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_SEA_TEMP
Sea surface temperature.
@ Idx_WIND_VY
Surface wind velocity Y component.
@ Idx_SEACURRENT_VX
Sea current velocity X component.
@ Idx_CAPE
Convective Available Potential Energy.
GRIB Data Table View and Export Interface.
void SetTableSizePosition(int vpWidth, int vpHeight)
Set the table size and position relative to viewport.
void InitGribTable(const wxString zone, 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.