OpenCPN Partial API docs
Loading...
Searching...
No Matches
GribTable.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2010 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
23#include "wx/wxprec.h"
24
25#ifndef WX_PRECOMP
26#include "wx/wx.h"
27#endif // precompiled headers
28
29#include "pi_gl.h"
30
31#include <wx/glcanvas.h>
32#include <wx/graphics.h>
33#include <wx/progdlg.h>
34#include <wx/grid.h>
35#include "GribTable.h"
36#include "CustomGrid.h"
37#include <wx/tokenzr.h>
38
39extern double m_cursor_lat, m_cursor_lon;
40
41GRIBTable::GRIBTable(GRIBUICtrlBar &parent)
42 : GRIBTableBase(&parent), m_pGDialog(&parent) {}
43
44void GRIBTable::InitGribTable(ArrayOfGribRecordSets *rsa, int NowIndex) {
45 m_pGribTable->m_gParent = this;
46 m_pIndex = NowIndex;
47
48 // init row attr
49 wxGridCellAttr *datarow = new wxGridCellAttr();
50 datarow->SetFont(GetOCPNGUIScaledFont_PlugIn(_("Dialog")));
51 datarow->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
52
53 // populate "cursor position" display
54 wxString l;
55 l.Append(toSDMM_PlugIn(1, m_cursor_lat))
56 .Append(_T(" "))
57 .Append(toSDMM_PlugIn(2, m_cursor_lon));
58 m_pCursorPosition->SetLabel(l);
59 m_pCursorPosition->SetFont(
60 GetOCPNGUIScaledFont_PlugIn(_("Dialog")).MakeBold());
61 m_pPositionText->SetFont(GetOCPNGUIScaledFont_PlugIn(_("Dialog")).MakeBold());
62
63 // create as columns as necessary
64 m_pGribTable->AppendCols(rsa->GetCount());
65
66 // populate grid
67 wxDateTime time, day, ptime;
68 int nrows, wcols = 0;
69 for (unsigned i = 0; i < rsa->GetCount(); i++) {
70 // populate time labels
71 time = rsa->Item(i).m_Reference_Time;
73 DateTimeFormatOptions().SetFormatString("$short_date\n$hour_minutes");
74 m_pGribTable->SetColLabelValue(
75 i, toUsrDateTimeFormat_Plugin(wxDateTime(time), opts));
76 nrows = -1;
77 GribTimelineRecordSet *pTimeset = m_pGDialog->GetTimeLineRecordSet(time);
78 if (pTimeset == 0) continue;
79
80 GribRecord **RecordArray = pTimeset->m_GribRecordPtrArray;
81
82 /*create and populate wind data row
83 wind is a special case:
84 1) if current unit is not bf ==> double speed display (current unit +
85 bf) 2) create two lines for direction and speed and a third for gust if
86 exists 3) these two or three lines will be part of the same block*/
87 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_VX) !=
88 wxNOT_FOUND &&
89 m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_VY) !=
90 wxNOT_FOUND) {
91 nrows++;
92 AddDataRow(nrows, i, _("Wind,Dir"), datarow);
93 double wdir;
94 GetWind(RecordArray, 1, wdir); // this is a numerical row
95 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
96 m_pGribTable->SetNumericalRow(nrows, i, R_WIND, wdir);
97 nrows++;
98 AddDataRow(nrows, i, _("Wind,Speed"), datarow);
99 if (m_pGDialog->m_OverlaySettings.Settings[GribOverlaySettings::WIND]
100 .m_Units != GribOverlaySettings::BFS)
101 m_pGribTable->SetCellValue(nrows, i, GetWind(RecordArray, 2, wdir));
102 else
103 m_pGribTable->SetCellValue(nrows, i, GetWind(RecordArray, 3, wdir));
104 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
105 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_GUST) !=
106 wxNOT_FOUND) {
107 nrows++;
108 AddDataRow(nrows, i, _("Wind,Gust"), datarow);
109 if (m_pGDialog->m_OverlaySettings.Settings[GribOverlaySettings::WIND]
110 .m_Units != GribOverlaySettings::BFS)
111 m_pGribTable->SetCellValue(nrows, i, GetWindGust(RecordArray, 1));
112 else
113 m_pGribTable->SetCellValue(nrows, i, GetWindGust(RecordArray, 2));
114 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
115 }
116 } // wind
117
118 // create and populate Pressure data rown
119 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_PRESSURE) !=
120 wxNOT_FOUND) {
121 nrows++;
122 AddDataRow(nrows, i, _("Pressure"), datarow);
123 m_pGribTable->SetCellValue(nrows, i, GetPressure(RecordArray));
124 } // pressure
125
126 /*create and populate Waves data rows
127 waves is another special case:
128 1) if significant height data exists then create a line for direction
129 and height then a third for periode if data exists
130 2) these two or three lines will be part of the same block*/
131 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_HTSIGW) !=
132 wxNOT_FOUND) {
133 double wdir;
134 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WVDIR) !=
135 wxNOT_FOUND) {
136 nrows++;
137 AddDataRow(nrows, i, _("Waves,Dir"), datarow);
138 GetWaves(RecordArray, Idx_WVDIR, wdir); // this is a numerical row
139 m_pGribTable->SetNumericalRow(nrows, i, R_WAVES, wdir);
140 }
141 nrows++;
142 AddDataRow(nrows, i, _("Waves,Hsig"), datarow);
143 m_pGribTable->SetCellValue(nrows, i,
144 GetWaves(RecordArray, Idx_HTSIGW, wdir));
145 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
146 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WVPER) !=
147 wxNOT_FOUND) {
148 nrows++;
149 AddDataRow(nrows, i, _("Waves,Per"), datarow);
150 m_pGribTable->SetCellValue(nrows, i,
151 GetWaves(RecordArray, Idx_WVPER, wdir));
152 }
153 } // waves
154
155 // create and populate total rainfall data row
156 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_PRECIP_TOT) !=
157 wxNOT_FOUND) {
158 nrows++;
159 AddDataRow(nrows, i, _("Rainfall"), datarow);
160 m_pGribTable->SetCellValue(nrows, i, GetRainfall(RecordArray));
161 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
162 } // rainfall
163
164 // create and populate total cloud control
165 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_CLOUD_TOT) !=
166 wxNOT_FOUND) {
167 nrows++;
168 AddDataRow(nrows, i, _("Cloud Cover"), datarow);
169 m_pGribTable->SetCellValue(nrows, i, GetCloudCover(RecordArray));
170 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
171 } // cloud
172
173 // create and populate the Air Temperature data row
174 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_AIR_TEMP) !=
175 wxNOT_FOUND) {
176 nrows++;
177 AddDataRow(nrows, i, _("Air Temp."), datarow);
178 m_pGribTable->SetCellValue(nrows, i, GetAirTemp(RecordArray));
179 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
180 } // air temp
181
182 // create and populate the Sea Surface Temperature data row
183 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEA_TEMP) !=
184 wxNOT_FOUND) {
185 nrows++;
186 AddDataRow(nrows, i, _("Sea Temp."), datarow);
187 m_pGribTable->SetCellValue(nrows, i, GetSeaTemp(RecordArray));
188 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
189 } // sea temp
190
191 // create and populate the Convective Available Potential Energy (CAPE) data
192 // row
193 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_CAPE) !=
194 wxNOT_FOUND) {
195 nrows++;
196 AddDataRow(nrows, i, _("CAPE"), datarow);
197 m_pGribTable->SetCellValue(nrows, i, GetCAPE(RecordArray));
198 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
199 } // cape
200
201 // create and populate the Composite Reflectivity data row
202 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_COMP_REFL) !=
203 wxNOT_FOUND) {
204 nrows++;
205 AddDataRow(nrows, i, _("C. Reflect."), datarow);
206 m_pGribTable->SetCellValue(nrows, i, GetCompRefl(RecordArray));
207 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
208 } // composite Reflectivity
209
210 /*create and populate the current data rows
211 1)create two lines for direction and speed
212 2) these two or three lines will be part of the same block*/
213 if (m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(
214 Idx_SEACURRENT_VX) != wxNOT_FOUND &&
215 m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(
216 Idx_SEACURRENT_VY) != wxNOT_FOUND) {
217 double wdir;
218 nrows++;
219 AddDataRow(nrows, i, _("Current,Dir"), datarow);
220 GetCurrent(RecordArray, 1, wdir); // this is a numerical row
221 m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
222 m_pGribTable->SetNumericalRow(nrows, i, R_CURRENT, wdir);
223
224 nrows++;
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);
228 } // current // populate grid
229 delete pTimeset;
230 m_pGribTable->AutoSizeColumn(i, false);
231 wcols = wxMax(m_pGribTable->GetColSize(i), wcols);
232 } // populate grid
233 // put cursor outside the grid
234 m_pGribTable->SetGridCursor(m_pGribTable->GetNumberRows() - 1, 0);
235 // set col size
236 m_pGribTable->SetDefaultColSize(wcols, true);
237 // set row size
238 AutoSizeDataRows();
239 // set label size
240 m_pGribTable->SetColLabelSize(wxGRID_AUTOSIZE);
241 // set scroll steps
242 m_pGribTable->SetScrollLineX(wcols);
243
244 datarow->DecRef(); // Give up pointer contrl to Grid
245
246 m_tScrollToNowTimer.Connect(
247 wxEVT_TIMER, wxTimerEventHandler(GRIBTable::OnScrollToNowTimer), nullptr,
248 this);
249}
250
251void GRIBTable::SetTableSizePosition(int vpWidth, int vpHeight) {
252 // Get size & position previously saved
253 int x = -1, y = -1, w = -1, h = -1;
254 wxFileConfig *pConf = GetOCPNConfigObject();
255 if (pConf) {
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);
261 }
262 wxPoint final_pos = GetOCPNCanvasWindow()->ClientToScreen(wxPoint(x, y));
263 // set a default size & position if saved values are outside of limits
264 bool refit = false;
265 wxSize scw = wxSize(vpWidth, (vpHeight - GetChartbarHeight()));
266 wxPoint pcw = GetOCPNCanvasWindow()->ClientToScreen(
267 GetOCPNCanvasWindow()->GetPosition());
268 if (!(wxRect(pcw, scw).Contains(wxRect(final_pos, wxSize(w, h)))))
269 refit = true;
270 if (w < (m_pGribTable->GetRowLabelSize() + (m_pGribTable->GetColSize(0))) ||
271 h < (m_pGribTable->GetColLabelSize() + (m_pGribTable->GetRowSize(0))))
272 refit = true;
273
274#ifdef __ANDROID__
275 refit = true;
276#endif
277 if (refit) {
278 w = (scw.GetWidth() / 10) * 9; // 10% less than canvas
279 h = (scw.GetHeight() / 10) * 9;
280 x = (scw.GetWidth() / 20); // centered horizontally
281 y = (scw.GetHeight() / 50); // a bit out-centered toward the top
282#ifdef __ANDROID__
283 // Position directly below GRIB control dialog
284 y = m_pGDialog->GetSize().GetHeight() * 11 / 10;
285 h = scw.GetHeight() - m_pGDialog->GetSize().GetHeight();
286#endif
287 final_pos = GetOCPNCanvasWindow()->ClientToScreen(wxPoint(x, y));
288 } //
289 // in case client size too large for the grib
290 int w1 = m_pGribTable->GetRowLabelSize() +
291 (m_pGribTable->GetColSize(0) * m_pGribTable->GetNumberCols());
292 w = wxMin(w, w1);
293 int h1 = m_pGribTable->GetColLabelSize() +
294 (m_pGribTable->GetRowSize(0) * (m_pGribTable->GetNumberRows() + 4));
295 h = wxMin(h, h1);
296
297 this->SetClientSize(w, h);
298 this->Move(final_pos);
299
300 // scroll to the end of time steps to prepare the next scroll to 'now'
301 m_pGribTable->MakeCellVisible(0, m_pGribTable->GetNumberCols() - 1);
302 // trigger scroll to 'now'(must be postpone after the dialog is shown)
303 m_tScrollToNowTimer.Start(200, wxTIMER_ONE_SHOT);
304}
305
306void GRIBTable::OnScrollToNowTimer(wxTimerEvent &event) {
307 m_pGribTable->MakeCellVisible(0, m_pIndex);
308}
309
310void GRIBTable::OnClose(wxCloseEvent &event) {
311 CloseDialog();
312 this->EndModal(wxID_OK);
313}
314
315void GRIBTable::OnOKButton(wxCommandEvent &event) {
316 CloseDialog();
317 this->EndModal(wxID_OK);
318}
319
320void GRIBTable::CloseDialog() {
321 wxSize s = this->GetClientSize();
322 wxPoint p = GetOCPNCanvasWindow()->ScreenToClient(this->GetPosition());
323
324 wxFileConfig *pConf = GetOCPNConfigObject();
325 if (pConf) {
326 pConf->SetPath(_T ( "/Settings/GRIB" ));
327
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());
332 } //
333}
334
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);
340 row_attr->IncRef();
341 m_pGribTable->SetRowAttr(num_rows, row_attr);
342 }
343 m_pDataCellsColour = m_pGribTable->GetCellBackgroundColour(
344 num_rows, num_cols); // set default colour
345}
346
347void GRIBTable::AutoSizeDataRows() {
348 int hrows = 0;
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);
352 }
353 m_pGribTable->SetDefaultRowSize(hrows, true);
354 // set scroll steps
355 m_pGribTable->SetScrollLineY(hrows);
356}
357
358wxString GRIBTable::GetWind(GribRecord **recordarray, int datatype,
359 double &wdir) {
360 wxString skn(wxEmptyString);
361 int altitude = 0;
362 double vkn, ang;
363 wdir = GRIB_NOTDEF;
365 vkn, ang, recordarray[Idx_WIND_VX + altitude],
366 recordarray[Idx_WIND_VY + altitude], m_cursor_lon, m_cursor_lat)) {
367 if (datatype == 1) {
368 wdir = ang;
369 return skn;
370 }
371 double cvkn = m_pGDialog->m_OverlaySettings.CalibrateValue(
372 GribOverlaySettings::WIND, vkn);
373 m_pDataCellsColour =
374 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
375 GribOverlaySettings::WIND, cvkn);
376 skn.Printf(wxString::Format(
377 _T("%2d bf"),
378 (int)wxRound(m_pGDialog->m_OverlaySettings.GetmstobfFactor(vkn) *
379 vkn)));
380 if (datatype == 2) { // wind speed unit other than bf
381 skn.Prepend(wxString::Format(
382 _T("%2d ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
383 GribOverlaySettings::WIND),
384 (int)wxRound(cvkn)) +
385 _T(" - "));
386 }
387 }
388 return skn;
389}
390
391wxString GRIBTable::GetWindGust(GribRecord **recordarray, int datatype) {
392 wxString skn(wxEmptyString);
393 if (recordarray[Idx_WIND_GUST]) {
394 double vkn = recordarray[Idx_WIND_GUST]->getInterpolatedValue(
395 m_cursor_lon, m_cursor_lat, true);
396 if (vkn != GRIB_NOTDEF) {
397 double cvkn = m_pGDialog->m_OverlaySettings.CalibrateValue(
398 GribOverlaySettings::WIND_GUST, vkn);
399 m_pDataCellsColour =
400 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
401 GribOverlaySettings::WIND_GUST, cvkn);
402
403 skn.Printf(wxString::Format(
404 _T("%2d bf"),
405 (int)wxRound(m_pGDialog->m_OverlaySettings.GetmstobfFactor(vkn) *
406 vkn))); // wind gust unit bf
407 if (datatype == 1) { // wind gust unit other than bf
408 skn.Prepend(
409 wxString::Format(
410 _T("%2d ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
411 GribOverlaySettings::WIND_GUST),
412 (int)wxRound(cvkn)) +
413 _T(" - " ));
414 }
415 }
416 }
417 return skn;
418}
419
420wxString GRIBTable::GetPressure(GribRecord **recordarray) {
421 wxString skn(wxEmptyString);
422 if (recordarray[Idx_PRESSURE]) {
423 double press = recordarray[Idx_PRESSURE]->getInterpolatedValue(
424 m_cursor_lon, m_cursor_lat, true);
425
426 if (press != GRIB_NOTDEF) {
427 press = m_pGDialog->m_OverlaySettings.CalibrateValue(
428 GribOverlaySettings::PRESSURE, press);
429 int p =
430 (m_pGDialog->m_OverlaySettings.Settings[GribOverlaySettings::PRESSURE]
431 .m_Units == 2)
432 ? 2
433 : 0; // if PRESSURE & inHG = two decimals
434 skn.Printf(wxString::Format(
435 _T("%2.*f ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
436 GribOverlaySettings::PRESSURE),
437 p, (press)));
438 }
439 }
440 return skn;
441}
442
443wxString GRIBTable::GetWaves(GribRecord **recordarray, int datatype,
444 double &wdir) {
445 wxString skn(wxEmptyString);
446 wdir = GRIB_NOTDEF;
447 switch (datatype) {
448 case Idx_HTSIGW:
449 if (recordarray[Idx_HTSIGW]) {
450 double height = recordarray[Idx_HTSIGW]->getInterpolatedValue(
451 m_cursor_lon, m_cursor_lat, true);
452 if (height != GRIB_NOTDEF) {
453 double cheight = m_pGDialog->m_OverlaySettings.CalibrateValue(
454 GribOverlaySettings::WAVE, height);
455 skn.Printf(wxString::Format(
456 _T("%4.1f ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
457 GribOverlaySettings::WAVE),
458 cheight));
459 m_pDataCellsColour =
460 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
461 GribOverlaySettings::WAVE, cheight);
462 }
463 }
464 break;
465 case Idx_WVDIR:
466 if (recordarray[Idx_WVDIR]) {
467 double direction = recordarray[Idx_WVDIR]->getInterpolatedValue(
468 m_cursor_lon, m_cursor_lat, true, true);
469 wdir = direction;
470 return skn;
471 }
472 break;
473 case Idx_WVPER:
474 if (recordarray[Idx_WVPER]) {
475 double period = recordarray[Idx_WVPER]->getInterpolatedValue(
476 m_cursor_lon, m_cursor_lat, true);
477 if (period != GRIB_NOTDEF)
478 skn.Printf(wxString::Format(_T("%01ds"), (int)(period + 0.5)));
479 }
480 }
481 return skn;
482}
483
484wxString GRIBTable::GetRainfall(GribRecord **recordarray) {
485 wxString skn(wxEmptyString);
486 if (recordarray[Idx_PRECIP_TOT]) {
487 double precip = recordarray[Idx_PRECIP_TOT]->getInterpolatedValue(
488 m_cursor_lon, m_cursor_lat, true);
489
490 if (precip != GRIB_NOTDEF) {
491 precip = m_pGDialog->m_OverlaySettings.CalibrateValue(
492 GribOverlaySettings::PRECIPITATION, precip);
493 skn.Printf(_T("%6.2f ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
494 GribOverlaySettings::PRECIPITATION),
495 precip);
496 m_pDataCellsColour =
497 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
498 GribOverlaySettings::PRECIPITATION, precip);
499 }
500 }
501 return skn;
502}
503
504wxString GRIBTable::GetCloudCover(GribRecord **recordarray) {
505 wxString skn(wxEmptyString);
506 if (recordarray[Idx_CLOUD_TOT]) {
507 double cloud = recordarray[Idx_CLOUD_TOT]->getInterpolatedValue(
508 m_cursor_lon, m_cursor_lat, true);
509
510 if (cloud != GRIB_NOTDEF) {
511 cloud = m_pGDialog->m_OverlaySettings.CalibrateValue(
512 GribOverlaySettings::CLOUD, cloud);
513 skn.Printf(_T("%5.1f "), cloud);
514 skn.Append(m_pGDialog->m_OverlaySettings.GetUnitSymbol(
515 GribOverlaySettings::CLOUD));
516 m_pDataCellsColour =
517 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
518 GribOverlaySettings::CLOUD, cloud);
519 }
520 }
521 return skn;
522}
523
524wxString GRIBTable::GetAirTemp(GribRecord **recordarray) {
525 wxString skn(wxEmptyString);
526 if (recordarray[Idx_AIR_TEMP]) {
527 double temp = recordarray[Idx_AIR_TEMP]->getInterpolatedValue(
528 m_cursor_lon, m_cursor_lat, true);
529
530 if (temp != GRIB_NOTDEF) {
531 temp = m_pGDialog->m_OverlaySettings.CalibrateValue(
532 GribOverlaySettings::AIR_TEMPERATURE, temp);
533 skn.Printf(_T("%5.1f ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
534 GribOverlaySettings::AIR_TEMPERATURE),
535 temp);
536 m_pDataCellsColour =
537 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
538 GribOverlaySettings::AIR_TEMPERATURE, temp);
539 }
540 }
541 return skn;
542}
543
544wxString GRIBTable::GetSeaTemp(GribRecord **recordarray) {
545 wxString skn(wxEmptyString);
546 if (recordarray[Idx_SEA_TEMP]) {
547 double temp = recordarray[Idx_SEA_TEMP]->getInterpolatedValue(
548 m_cursor_lon, m_cursor_lat, true);
549
550 if (temp != GRIB_NOTDEF) {
551 temp = m_pGDialog->m_OverlaySettings.CalibrateValue(
552 GribOverlaySettings::SEA_TEMPERATURE, temp);
553 skn.Printf(_T("%5.1f ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
554 GribOverlaySettings::SEA_TEMPERATURE),
555 temp);
556 m_pDataCellsColour =
557 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
558 GribOverlaySettings::SEA_TEMPERATURE, temp);
559 }
560 }
561 return skn;
562}
563
564wxString GRIBTable::GetCAPE(GribRecord **recordarray) {
565 wxString skn(wxEmptyString);
566 if (recordarray[Idx_CAPE]) {
567 double cape = recordarray[Idx_CAPE]->getInterpolatedValue(
568 m_cursor_lon, m_cursor_lat, true);
569
570 if (cape != GRIB_NOTDEF) {
571 cape = m_pGDialog->m_OverlaySettings.CalibrateValue(
572 GribOverlaySettings::CAPE, cape);
573 skn.Printf(wxString::Format(
574 _T("%5.0f ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
575 GribOverlaySettings::CAPE),
576 cape));
577 m_pDataCellsColour =
578 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
579 GribOverlaySettings::CAPE, cape);
580 }
581 }
582 return skn;
583}
584
585wxString GRIBTable::GetCompRefl(GribRecord **recordarray) {
586 wxString skn(wxEmptyString);
587 if (recordarray[Idx_COMP_REFL]) {
588 double refl = recordarray[Idx_COMP_REFL]->getInterpolatedValue(
589 m_cursor_lon, m_cursor_lat, true);
590
591 if (refl != GRIB_NOTDEF) {
592 refl = m_pGDialog->m_OverlaySettings.CalibrateValue(
593 GribOverlaySettings::COMP_REFL, refl);
594 skn.Printf(wxString::Format(
595 _T("%5.0f ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
596 GribOverlaySettings::COMP_REFL),
597 refl));
598 m_pDataCellsColour =
599 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
600 GribOverlaySettings::COMP_REFL, refl);
601 }
602 }
603 return skn;
604}
605
606wxString GRIBTable::GetCurrent(GribRecord **recordarray, int datatype,
607 double &wdir) {
608 wxString skn(wxEmptyString);
609 double vkn, ang;
610 wdir = GRIB_NOTDEF;
612 vkn, ang, recordarray[Idx_SEACURRENT_VX],
613 recordarray[Idx_SEACURRENT_VY], m_cursor_lon, m_cursor_lat)) {
614 if (datatype == 1) {
615 wdir = ang;
616 return skn;
617 }
618 vkn = m_pGDialog->m_OverlaySettings.CalibrateValue(
619 GribOverlaySettings::CURRENT, vkn);
620 skn.Printf(wxString::Format(
621 _T("%4.1f ") + m_pGDialog->m_OverlaySettings.GetUnitSymbol(
622 GribOverlaySettings::CURRENT),
623 vkn));
624 m_pDataCellsColour =
625 m_pGDialog->pPlugIn->m_pGRIBOverlayFactory->GetGraphicColor(
626 GribOverlaySettings::CURRENT, vkn);
627 }
628 return skn;
629}
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_WVPER
Wave period.
@ 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.
Class GRIBTableBase.
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.
Definition GribRecord.h:182
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.
Configuration options for date and time formatting.
DateTimeFormatOptions & SetFormatString(const wxString &fmt)
Sets the date/time format pattern string.