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