OpenCPN Partial API docs
Loading...
Searching...
No Matches
GribUIDialog.h
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 ***************************************************************************/
39#ifndef __GRIBUICTRLBAR_H__
40#define __GRIBUICTRLBAR_H__
41
42#include "wx/wxprec.h"
43
44#ifndef WX_PRECOMP
45#include "wx/wx.h"
46#endif // precompiled headers
47#include <wx/fileconf.h>
48#include <wx/glcanvas.h>
49
50#include "GribUIDialogBase.h"
51#include "CursorData.h"
52#include "GribSettingsDialog.h"
53#include "GribRequestDialog.h"
54#include "GribReader.h"
55#include "GribRecordSet.h"
56#include "IsoLine.h"
57#include "GrabberWin.h"
58
59#ifndef PI
60#define PI 3.1415926535897931160E0 /* pi */
61#endif
62
63class GRIBUICtrlBar;
64class GRIBUICData;
65class GRIBFile;
66class GRIBRecord;
67class GribRecordTree;
69class GribRecordSet;
71class GribGrabberWin;
72class GribSpacerWin;
73
74class wxFileConfig;
75class grib_pi;
76class wxGraphicsContext;
77
78WX_DECLARE_OBJARRAY(GribRecordSet, ArrayOfGribRecordSets);
79
106
110typedef struct {
111 int atmModelIndex;
112 int waveModelIndex;
113 int resolutionIndex;
114 int durationIndex;
115 int runIndex;
116 int intervalIndex;
117 bool wind;
118 bool gust;
119 bool pressure;
120 bool temperature;
121 bool cape;
122 bool reflectivity;
123 bool cloudCover;
124 bool precipitation;
125 bool waveHeight;
126 bool windWaves;
128
148public:
158 GribTimelineRecordSet(unsigned int cnt);
159 // GribTimelineRecordSet(GribRecordSet &GRS1, GribRecordSet &GRS2, double
160 // interp_const);
162
163 void ClearCachedData();
164
172 wxArrayPtrVoid *m_IsobarArray[Idx_COUNT];
173};
174
175//----------------------------------------------------------------------------------------------------------
176// GRIB CtrlBar Specification
177//----------------------------------------------------------------------------------------------------------
179 friend class GribRequestSetting;
180
181public:
182 GRIBUICtrlBar(wxWindow *parent, wxWindowID id, const wxString &title,
183 const wxPoint &pos, const wxSize &size, long style,
184 grib_pi *ppi, double scale_factor);
186
187 void OpenFile(bool newestFile = false);
188
189 void ContextMenuItemCallback(int id);
190 void SetFactoryOptions();
191
192 wxDateTime TimelineTime();
218 void StopPlayBack();
219 void TimelineChanged();
220 void CreateActiveFileFromNames(const wxArrayString &filenames);
221 void PopulateComboDataList();
222 void ComputeBestForecastForNow();
227 void SetDataBackGroundColor();
228 void SetTimeLineMax(bool SetValue);
229 void SetCursorLatLon(double lat, double lon);
242 void SetDialogsStyleSizePosition(bool force_recompute = false);
244 void SetRequestButtonBitmap(int type);
245 void OnMouseEvent(wxMouseEvent &event);
246 GRIBUICData *GetCDataDialog() { return m_gGRIBUICData; }
247 bool InDataPlot(int id) {
248 return id > wxID_ANY && id < (int)GribOverlaySettings::GEO_ALTITUDE;
249 }
250 void SetScaledBitmap(double factor);
251 void OpenFileFromJSON(wxString json);
252
253 //
254 double getTimeInterpolatedValue(int idx, double lon, double lat,
255 wxDateTime t);
256 bool getTimeInterpolatedValues(double &M, double &A, int idx1, int idx2,
257 double lon, double lat, wxDateTime t);
258
259 wxWindow *pParent;
264
266 wxTimer m_tPlayStop;
269 GribRequestSetting *pReq_Dialog;
272 bool m_bDataPlot[GribOverlaySettings::GEO_ALTITUDE]; // only for no altitude
273 // parameters
274 bool m_CDataIsShown;
275 int m_ZoneSelAllowed;
276 int m_old_DialogStyle;
277 void DoZoomToCenter();
278 const wxString GetGribDir() {
279 if (m_grib_dir.IsEmpty() || !wxDirExists(m_grib_dir)) {
281 ->Append(wxFileName::GetPathSeparator())
282 .Append("grib");
283
284 if (!wxDirExists(m_grib_dir)) wxMkdir(m_grib_dir);
285
286 wxString dir_spec;
287 int response = PlatformDirSelectorDialog(
288 this, &dir_spec, _("Choose GRIB File Directory"), m_grib_dir);
289
290 if (response == wxID_OK) {
291 m_grib_dir = (dir_spec);
292 }
293 }
294 return m_grib_dir;
295 }
296
314 void GetProjectedLatLon(int &x, int &y, PlugIn_ViewPort *vp);
315 bool ProjectionEnabled() {
316 if (m_ProjectBoatPanel)
317 return m_ProjectBoatPanel->ProjectionEnabled();
318 else
319 return false;
320 }
321 double m_highlight_latmax;
322 double m_highlight_lonmax;
323 double m_highlight_latmin;
324 double m_highlight_lonmin;
326 wxString m_grib_dir;
328 wxArrayString m_file_names;
329
330private:
331 void OnClose(wxCloseEvent &event);
332 void OnSize(wxSizeEvent &event);
333 void OnPaint(wxPaintEvent &event);
334 void OnSettings(wxCommandEvent &event);
335 void OnPlayStop(wxCommandEvent &event);
336 void OnPlayStopTimer(wxTimerEvent &event);
337 void OnMove(wxMoveEvent &event);
338 void OnMenuEvent(wxMenuEvent &event);
339 void MenuAppend(wxMenu *menu, int id, wxString label, wxItemKind kind,
340 wxBitmap bitmap = wxNullBitmap, wxMenu *submenu = nullptr);
341 void OnZoomToCenterClick(wxCommandEvent &event);
342 void OnPrev(wxCommandEvent &event);
343 void OnRecordForecast(wxCommandEvent &event) {
344 StopPlayBack();
345 m_InterpolateMode = false;
346 m_pNowMode = false;
347 TimelineChanged();
348 }
349 void OnNext(wxCommandEvent &event);
350 void OnNow(wxCommandEvent &event) {
351 StopPlayBack();
352 ComputeBestForecastForNow();
353 }
354 void OnAltitude(wxCommandEvent &event);
355 void OnOpenFile(wxCommandEvent &event);
357 void OnRequestForecastData(wxCommandEvent &event);
358 void createRequestDialog();
359 void OnCompositeDialog(wxCommandEvent &event);
360
361 void OnTimeline(wxScrollEvent &event);
362 void OnShowCursorData(wxCommandEvent &event);
363
364 wxDateTime MinTime();
365 wxArrayString GetFilesInDirectory();
366 void SetGribTimelineRecordSet(GribTimelineRecordSet *pTimelineSet);
367 int GetNearestIndex(wxDateTime time, int model);
368 int GetNearestValue(wxDateTime time, int model);
369 bool GetGribZoneLimits(GribTimelineRecordSet *timelineSet, double *latmin,
370 double *latmax, double *lonmin, double *lonmax);
371 wxDateTime GetNow();
372 void RestaureSelectionString();
373 void SaveSelectionString() {
374 m_SelectionIsSaved = true;
375 m_Selection_index = m_cRecordForecast->GetSelection();
376 m_Selection_label = m_cRecordForecast->GetString(m_Selection_index);
377 }
378
379 // Data
380 CursorData *m_gCursorData;
381 GribGrabberWin *m_gGrabber;
382 GRIBUICData *m_gGRIBUICData;
384 PlugIn_ViewPort *m_vpMouse;
385 int m_lastdatatype;
386
387 int m_TimeLineHours;
388 int m_FileIntervalIndex;
389 bool m_InterpolateMode;
390 bool m_pNowMode;
391 bool m_HasAltitude;
392
393 bool m_SelectionIsSaved;
394 int m_Selection_index;
395 wxString m_Selection_label;
396 wxSize m_DialogsOffset;
397 double m_projected_lat;
398 double m_projected_lon;
399 // XyGrib panel configuration
400 XyGribConfig_t xyGribConfig;
401 bool m_gtk_started;
402};
403
420class GRIBFile {
421public:
434 GRIBFile(const wxArrayString &file_names, bool CumRec, bool WaveRec,
435 bool newestFile = false);
436 ~GRIBFile();
437
442 bool IsOK(void) { return m_bOK; }
448 wxArrayString &GetFileNames(void) { return m_FileNames; }
452 wxString GetLastMessage(void) { return m_last_message; }
458 ArrayOfGribRecordSets *GetRecordSetArrayPtr(void) {
459 return &m_GribRecordSetArray;
460 }
469 time_t GetRefDateTime(void) { return m_pRefDateTime; }
470
471 const unsigned int GetCounter() { return m_counter; }
472
473 WX_DEFINE_ARRAY_INT(int, GribIdxArray);
474 GribIdxArray m_GribIdxArray;
475
476private:
477 static unsigned int ID;
478
479 const unsigned int m_counter;
480 bool m_bOK;
481 wxString m_last_message;
482 wxArrayString m_FileNames;
483 GribReader *m_pGribReader;
484 time_t m_pRefDateTime;
485
487 ArrayOfGribRecordSets m_GribRecordSetArray;
488
489 int m_nGribRecords;
490};
491
492//----------------------------------------------------------------------------------------------------------
493// GRIB CursorData Dialog Specification
494//----------------------------------------------------------------------------------------------------------
496public:
497 GRIBUICData(GRIBUICtrlBar &parent);
498 ~GRIBUICData() {}
499
500 // GribGrabberWin *m_gGrabber;
501 GRIBUICtrlBar &m_gpparent;
502 CursorData *m_gCursorData;
503
504private:
505 void OnMove(wxMoveEvent &event);
506};
507
508#endif
GRIB Cursor Data Tracking and Display.
GRIB Dialog Grabber Control Interface.
GRIB (GRIdded Binary) file reader and parser.
GRIB Record Set Management.
@ Idx_COUNT
Number of supported GRIB record types.
GRIB Weather Data Request and Download Management.
GRIB Display Settings Configuration Interface.
Base User Interface Components for GRIB Plugin.
ZoneSelection
Defines the possible states for GRIB area selection.
@ AUTO_SELECTION
Area automatically set from current viewport bounds.
@ DRAW_SELECTION
Manual mode has been selected.
@ START_SELECTION
User has clicked Shift + Left click and is drawing the bounding box by dragging the mouse.
@ COMPLETE_SELECTION
Selection box completed in manual mode, coordinates have been captured after the user has released th...
@ SAVED_SELECTION
Area loaded from previously saved coordinates.
GRIB Isobar and Isoline Generation System.
Tracks and displays GRIB meteorological data at cursor position.
Definition CursorData.h:52
Manages multiple GRIB record sets from one or more GRIB files.
time_t GetRefDateTime(void)
Gets reference datetime of the GRIB data.
ArrayOfGribRecordSets * GetRecordSetArrayPtr(void)
Gets pointer to array of record sets organized by timestamp.
wxArrayString & GetFileNames(void)
Gets the list of source filenames being used.
wxString GetLastMessage(void)
Gets the last error message if file loading failed.
bool IsOK(void)
Checks if file loading and parsing was successful.
Factory class for creating and managing GRIB data visualizations.
Class GRIBUICDataBase.
Class GRIBUICtrlBarBase.
void SetViewPortWithFocus(PlugIn_ViewPort *vp)
Set the ViewPort that has the focus.
void GetProjectedLatLon(int &x, int &y, PlugIn_ViewPort *vp)
Gets the projected position of vessel based on current course, speed and forecast time.
GribOverlaySettings m_OverlaySettings
Settings that control how GRIB data is displayed and overlaid.
void SetRequestButtonBitmap(int type)
Set the icon and tooltip for the download request button.
wxTimer m_tPlayStop
Timer for controlling GRIB animation playback.
void SetViewPortUnderMouse(PlugIn_ViewPort *vp)
Set the ViewPort under the mouse.
wxString m_grib_dir
Directory containing GRIB files.
grib_pi * pPlugIn
Plugin instance that owns this control bar.
GRIBFile * m_bGRIBActiveFile
Currently active GRIB file being displayed.
void UpdateTrackingControl()
Schedules an update of the GRIB data values display at current cursor position.
GribTimelineRecordSet * m_pTimelineSet
Current set of GRIB records for timeline playback.
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.
Manages a collection of GribRecord objects representing multiple meteorological parameters at a singl...
Manages GRIB file request configuration and downloads.
A specialized GribRecordSet that represents temporally interpolated weather data with isobar renderin...
wxArrayPtrVoid * m_IsobarArray[Idx_COUNT]
Array of cached isobar calculations for each data type (wind, pressure, etc).
Contains view parameters and status information for a chart display viewport.
int PlatformDirSelectorDialog(wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir)
Shows platform-optimized directory selector dialog.
wxString * GetpPrivateApplicationDataLocation(void)
Gets private application data directory.
Structure used to store XyGrib configuration.