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
80enum ZoneSelection {
81 AUTO_SELECTION,
82 SAVED_SELECTION,
83 START_SELECTION,
84 DRAW_SELECTION,
85 COMPLETE_SELECTION
86};
87
91typedef struct {
92 int atmModelIndex;
93 int waveModelIndex;
94 int resolutionIndex;
95 int durationIndex;
96 int runIndex;
97 int intervalIndex;
98 bool wind;
99 bool gust;
100 bool pressure;
101 bool temperature;
102 bool cape;
103 bool reflectivity;
104 bool cloudCover;
105 bool precipitation;
106 bool waveHeight;
107 bool windWaves;
109
129public:
139 GribTimelineRecordSet(unsigned int cnt);
140 // GribTimelineRecordSet(GribRecordSet &GRS1, GribRecordSet &GRS2, double
141 // interp_const);
143
144 void ClearCachedData();
145
153 wxArrayPtrVoid *m_IsobarArray[Idx_COUNT];
154};
155
156//----------------------------------------------------------------------------------------------------------
157// GRIB CtrlBar Specification
158//----------------------------------------------------------------------------------------------------------
160 friend class GribRequestSetting;
161
162public:
163 GRIBUICtrlBar(wxWindow *parent, wxWindowID id, const wxString &title,
164 const wxPoint &pos, const wxSize &size, long style,
165 grib_pi *ppi);
167
168 void OpenFile(bool newestFile = false);
169
170 void ContextMenuItemCallback(int id);
171 void SetFactoryOptions();
172
173 wxDateTime TimelineTime();
199 void StopPlayBack();
200 void TimelineChanged();
201 void CreateActiveFileFromNames(const wxArrayString &filenames);
202 void PopulateComboDataList();
203 void ComputeBestForecastForNow();
204 void SetViewPort(PlugIn_ViewPort *vp);
205 void SetDataBackGroundColor();
206 void SetTimeLineMax(bool SetValue);
207 void SetCursorLatLon(double lat, double lon);
208 void UpdateTrackingControl();
209 void SetDialogsStyleSizePosition(bool force_recompute = false);
210 void SetRequestBitmap(int type);
211 void OnMouseEvent(wxMouseEvent &event);
212 GRIBUICData *GetCDataDialog() { return m_gGRIBUICData; }
213 bool InDataPlot(int id) {
214 return id > wxID_ANY && id < (int)GribOverlaySettings::GEO_ALTITUDE;
215 }
216 void SetScaledBitmap(double factor);
217 wxBitmap GetScaledBitmap(wxBitmap bitmap, const wxString svgFileName,
218 double scale_factor);
219 void OpenFileFromJSON(wxString json);
220
221 //
222 double getTimeInterpolatedValue(int idx, double lon, double lat,
223 wxDateTime t);
224 bool getTimeInterpolatedValues(double &M, double &A, int idx1, int idx2,
225 double lon, double lat, wxDateTime t);
226
227 wxWindow *pParent;
232
234 wxTimer m_tPlayStop;
237 GribRequestSetting *pReq_Dialog;
240 bool m_bDataPlot[GribOverlaySettings::GEO_ALTITUDE]; // only for no altitude
241 // parameters
242 bool m_CDataIsShown;
243 int m_ZoneSelAllowed;
244 int m_old_DialogStyle;
245 double m_ScaledFactor;
246 void DoZoomToCenter();
247 const wxString GetGribDir() {
248 if (m_grib_dir.IsEmpty() || !wxDirExists(m_grib_dir)) {
249 m_grib_dir = GetpPrivateApplicationDataLocation()
250 ->Append(wxFileName::GetPathSeparator())
251 .Append("grib");
252
253 if (!wxDirExists(m_grib_dir)) wxMkdir(m_grib_dir);
254
255 wxString dir_spec;
256 int response = PlatformDirSelectorDialog(
257 this, &dir_spec, _("Choose GRIB File Directory"), m_grib_dir);
258
259 if (response == wxID_OK) {
260 m_grib_dir = (dir_spec);
261 }
262 }
263 return m_grib_dir;
264 }
265
266 void GetProjectedLatLon(int &x, int &y);
267 bool ProjectionEnabled() {
268 if (m_ProjectBoatPanel)
269 return m_ProjectBoatPanel->ProjectionEnabled();
270 else
271 return false;
272 }
273 double m_highlight_latmax;
274 double m_highlight_lonmax;
275 double m_highlight_latmin;
276 double m_highlight_lonmin;
278 wxString m_grib_dir;
280 wxArrayString m_file_names;
281
282private:
283 void OnClose(wxCloseEvent &event);
284 void OnSize(wxSizeEvent &event);
285 void OnPaint(wxPaintEvent &event);
286 void OnSettings(wxCommandEvent &event);
287 void OnPlayStop(wxCommandEvent &event);
288 void OnPlayStopTimer(wxTimerEvent &event);
289 void OnMove(wxMoveEvent &event);
290 void OnMenuEvent(wxMenuEvent &event);
291 void MenuAppend(wxMenu *menu, int id, wxString label, wxItemKind kind,
292 wxBitmap bitmap = wxNullBitmap, wxMenu *submenu = nullptr);
293 void OnZoomToCenterClick(wxCommandEvent &event);
294 void OnPrev(wxCommandEvent &event);
295 void OnRecordForecast(wxCommandEvent &event) {
296 StopPlayBack();
297 m_InterpolateMode = false;
298 m_pNowMode = false;
299 TimelineChanged();
300 }
301 void OnNext(wxCommandEvent &event);
302 void OnNow(wxCommandEvent &event) {
303 StopPlayBack();
304 ComputeBestForecastForNow();
305 }
306 void OnAltitude(wxCommandEvent &event);
307 void OnOpenFile(wxCommandEvent &event);
308 void OnRequest(wxCommandEvent &event);
309 void OnCompositeDialog(wxCommandEvent &event);
310
311 void OnTimeline(wxScrollEvent &event);
312 void OnShowCursorData(wxCommandEvent &event);
313
314 wxDateTime MinTime();
315 wxArrayString GetFilesInDirectory();
316 void SetGribTimelineRecordSet(GribTimelineRecordSet *pTimelineSet);
317 int GetNearestIndex(wxDateTime time, int model);
318 int GetNearestValue(wxDateTime time, int model);
319 bool GetGribZoneLimits(GribTimelineRecordSet *timelineSet, double *latmin,
320 double *latmax, double *lonmin, double *lonmax);
321 wxDateTime GetNow();
322 void RestaureSelectionString();
323 void SaveSelectionString() {
324 m_SelectionIsSaved = true;
325 m_Selection_index = m_cRecordForecast->GetSelection();
326 m_Selection_label = m_cRecordForecast->GetString(m_Selection_index);
327 }
328
329 // Data
330 CursorData *m_gCursorData;
331 GribGrabberWin *m_gGrabber;
332 GRIBUICData *m_gGRIBUICData;
333
334 PlugIn_ViewPort *m_vp;
335 int m_lastdatatype;
336
337 int m_TimeLineHours;
338 int m_FileIntervalIndex;
339 bool m_InterpolateMode;
340 bool m_pNowMode;
341 bool m_HasAltitude;
342
343 bool m_SelectionIsSaved;
344 int m_Selection_index;
345 wxString m_Selection_label;
346 wxSize m_DialogsOffset;
347 double m_projected_lat;
348 double m_projected_lon;
349 // XyGrib panel configuration
350 XyGribConfig_t xyGribConfig;
351 bool m_gtk_started;
352};
353
370class GRIBFile {
371public:
384 GRIBFile(const wxArrayString &file_names, bool CumRec, bool WaveRec,
385 bool newestFile = false);
386 ~GRIBFile();
387
392 bool IsOK(void) { return m_bOK; }
398 wxArrayString &GetFileNames(void) { return m_FileNames; }
402 wxString GetLastMessage(void) { return m_last_message; }
408 ArrayOfGribRecordSets *GetRecordSetArrayPtr(void) {
409 return &m_GribRecordSetArray;
410 }
419 time_t GetRefDateTime(void) { return m_pRefDateTime; }
420
421 const unsigned int GetCounter() { return m_counter; }
422
423 WX_DEFINE_ARRAY_INT(int, GribIdxArray);
424 GribIdxArray m_GribIdxArray;
425
426private:
427 static unsigned int ID;
428
429 const unsigned int m_counter;
430 bool m_bOK;
431 wxString m_last_message;
432 wxArrayString m_FileNames;
433 GribReader *m_pGribReader;
434 time_t m_pRefDateTime;
435
437 ArrayOfGribRecordSets m_GribRecordSetArray;
438
439 int m_nGribRecords;
440};
441
442//----------------------------------------------------------------------------------------------------------
443// GRIB CursorData Dialog Specification
444//----------------------------------------------------------------------------------------------------------
446public:
447 GRIBUICData(GRIBUICtrlBar &parent);
448 ~GRIBUICData() {}
449
450 // GribGrabberWin *m_gGrabber;
451 GRIBUICtrlBar &m_gpparent;
452 CursorData *m_gCursorData;
453
454private:
455 void OnMove(wxMoveEvent &event);
456};
457
458#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.
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.
GribOverlaySettings m_OverlaySettings
Settings that control how GRIB data is displayed and overlaid.
wxTimer m_tPlayStop
Timer for controlling GRIB animation playback.
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.
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).
Structure used to store XyGrib configuration.