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
193 wxDateTime TimelineTime();
219 void StopPlayBack();
220 void TimelineChanged();
221 void CreateActiveFileFromNames(const wxArrayString &filenames);
222 void PopulateComboDataList();
223 void ComputeBestForecastForNow();
228 void SetDataBackGroundColor();
229 void SetTimeLineMax(bool SetValue);
230 void SetCursorLatLon(double lat, double lon);
243 void SetDialogsStyleSizePosition(bool force_recompute = false);
245 void SetRequestButtonBitmap(int type);
246 void OnMouseEvent(wxMouseEvent &event);
247 GRIBUICData *GetCDataDialog() { return m_gGRIBUICData; }
248 bool InDataPlot(int id) {
249 return id > wxID_ANY && id < (int)GribOverlaySettings::GEO_ALTITUDE;
250 }
251 void SetScaledBitmap(double factor);
252 void OpenFileFromJSON(wxString json);
253
254 //
255 double getTimeInterpolatedValue(int idx, double lon, double lat,
256 wxDateTime t);
257 bool getTimeInterpolatedValues(double &M, double &A, int idx1, int idx2,
258 double lon, double lat, wxDateTime t);
259
260 wxWindow *pParent;
265
267 wxTimer m_tPlayStop;
270 GribRequestSetting *pReq_Dialog;
273 bool m_bDataPlot[GribOverlaySettings::GEO_ALTITUDE]; // only for no altitude
274 // parameters
275 bool m_CDataIsShown;
276 int m_ZoneSelAllowed;
277 int m_old_DialogStyle;
278 void DoZoomToCenter();
279 const wxString GetGribDir() {
280 if (m_grib_dir.IsEmpty() || !wxDirExists(m_grib_dir)) {
282 ->Append(wxFileName::GetPathSeparator())
283 .Append("grib");
284
285 if (!wxDirExists(m_grib_dir)) wxMkdir(m_grib_dir);
286
287 wxString dir_spec;
288 int response = PlatformDirSelectorDialog(
289 this, &dir_spec, _("Choose GRIB File Directory"), m_grib_dir);
290
291 if (response == wxID_OK) {
292 m_grib_dir = (dir_spec);
293 }
294 }
295 return m_grib_dir;
296 }
297
315 void GetProjectedLatLon(int &x, int &y, PlugIn_ViewPort *vp);
316 bool ProjectionEnabled() {
317 if (m_ProjectBoatPanel)
318 return m_ProjectBoatPanel->ProjectionEnabled();
319 else
320 return false;
321 }
322 double m_highlight_latmax;
323 double m_highlight_lonmax;
324 double m_highlight_latmin;
325 double m_highlight_lonmin;
327 wxString m_grib_dir;
329 wxArrayString m_file_names;
330
331private:
332 void OnClose(wxCloseEvent &event);
333 void OnSize(wxSizeEvent &event);
334 void OnPaint(wxPaintEvent &event);
335 void OnSettings(wxCommandEvent &event);
336 void OnPlayStop(wxCommandEvent &event);
337 void OnPlayStopTimer(wxTimerEvent &event);
338 void OnMove(wxMoveEvent &event);
339 void OnMenuEvent(wxMenuEvent &event);
340 void MenuAppend(wxMenu *menu, int id, wxString label, wxItemKind kind,
341 wxBitmap bitmap = wxNullBitmap, wxMenu *submenu = nullptr);
342 void OnZoomToCenterClick(wxCommandEvent &event);
343 void OnPrev(wxCommandEvent &event);
344 void OnRecordForecast(wxCommandEvent &event) {
345 StopPlayBack();
346 m_InterpolateMode = false;
347 m_pNowMode = false;
348 TimelineChanged();
349 }
350 void OnNext(wxCommandEvent &event);
351 void OnNow(wxCommandEvent &event) {
352 StopPlayBack();
353 ComputeBestForecastForNow();
354 }
355 void OnAltitude(wxCommandEvent &event);
356 void OnOpenFile(wxCommandEvent &event);
358 void OnRequestForecastData(wxCommandEvent &event);
359 void createRequestDialog();
360 void OnCompositeDialog(wxCommandEvent &event);
361
362 void OnTimeline(wxScrollEvent &event);
363 void OnShowCursorData(wxCommandEvent &event);
364
365 wxDateTime MinTime();
366 wxArrayString GetFilesInDirectory();
367 void SetGribTimelineRecordSet(GribTimelineRecordSet *pTimelineSet);
368 int GetNearestIndex(wxDateTime time, int model);
369 int GetNearestValue(wxDateTime time, int model);
370 bool GetGribZoneLimits(GribTimelineRecordSet *timelineSet, double *latmin,
371 double *latmax, double *lonmin, double *lonmax);
372 wxDateTime GetNow();
373 void RestaureSelectionString();
374 void SaveSelectionString() {
375 m_SelectionIsSaved = true;
376 m_Selection_index = m_cRecordForecast->GetSelection();
377 m_Selection_label = m_cRecordForecast->GetString(m_Selection_index);
378 }
379
380 // Data
381 CursorData *m_gCursorData;
382 GribGrabberWin *m_gGrabber;
383 GRIBUICData *m_gGRIBUICData;
385 PlugIn_ViewPort *m_vpMouse;
386 int m_lastdatatype;
387
388 int m_TimeLineHours;
389 int m_FileIntervalIndex;
390 bool m_InterpolateMode;
391 bool m_pNowMode;
392 bool m_HasAltitude;
393
394 bool m_SelectionIsSaved;
395 int m_Selection_index;
396 wxString m_Selection_label;
397 wxSize m_DialogsOffset;
398 double m_projected_lat;
399 double m_projected_lon;
400 // XyGrib panel configuration
401 XyGribConfig_t xyGribConfig;
402 bool m_gtk_started;
403};
404
421class GRIBFile {
422public:
435 GRIBFile(const wxArrayString &file_names, bool CumRec, bool WaveRec,
436 bool newestFile = false);
437 ~GRIBFile();
438
443 bool IsOK(void) { return m_bOK; }
449 wxArrayString &GetFileNames(void) { return m_FileNames; }
453 wxString GetLastMessage(void) { return m_last_message; }
459 ArrayOfGribRecordSets *GetRecordSetArrayPtr(void) {
460 return &m_GribRecordSetArray;
461 }
471 time_t GetRefDateTime(void) { return m_pRefDateTime; }
472
473 const unsigned int GetCounter() { return m_counter; }
474
475 WX_DEFINE_ARRAY_INT(int, GribIdxArray);
476 GribIdxArray m_GribIdxArray;
477
478private:
479 static unsigned int ID;
480
481 const unsigned int m_counter;
482 bool m_bOK;
483 wxString m_last_message;
484 wxArrayString m_FileNames;
485 GribReader *m_pGribReader;
486 time_t m_pRefDateTime;
487
489 ArrayOfGribRecordSets m_GribRecordSetArray;
490
491 int m_nGribRecords;
492};
493
494//----------------------------------------------------------------------------------------------------------
495// GRIB CursorData Dialog Specification
496//----------------------------------------------------------------------------------------------------------
498public:
499 GRIBUICData(GRIBUICtrlBar &parent);
500 ~GRIBUICData() {}
501
502 // GribGrabberWin *m_gGrabber;
503 GRIBUICtrlBar &m_gpparent;
504 CursorData *m_gCursorData;
505
506private:
507 void OnMove(wxMoveEvent &event);
508};
509
510#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)
Returns the reference datetime of the GRIB data, as the number of seconds since the epoch.
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.
wxDateTime TimelineTime()
Returns the selected time in the GRIB timeline widget.
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.