40#ifndef GRIBUICTRLBAR_H_
41#define GRIBUICTRLBAR_H_
48#include <wx/glcanvas.h>
60#define PI 3.1415926535897931160E0
63extern double m_cursor_lat, m_cursor_lon;
78class wxGraphicsContext;
165 void ClearCachedData();
184 GRIBUICtrlBar(wxWindow *parent, wxWindowID
id,
const wxString &title,
185 const wxPoint &pos,
const wxSize &size,
long style,
GribPi *ppi,
186 double scale_factor);
189 void OpenFile(
bool newestFile =
false);
191 void ContextMenuItemCallback(
int id);
192 void SetFactoryOptions();
222 void TimelineChanged();
223 void CreateActiveFileFromNames(
const wxArrayString &filenames);
224 void PopulateComboDataList();
225 void ComputeBestForecastForNow();
230 void SetTimeLineMax(
bool SetValue);
231 void SetCursorLatLon(
double lat,
double lon);
244 void SetDialogsStyleSizePosition(
bool force_recompute =
false);
247 GRIBUICData *GetCDataDialog() {
return m_gGRIBUICData; }
248 bool InDataPlot(
int id) {
249 return id > wxID_ANY &&
id < (int)GribOverlaySettings::GEO_ALTITUDE;
251 void SetScaledBitmap(
double factor);
252 void OpenFileFromJSON(wxString json);
255 double getTimeInterpolatedValue(
int idx,
double lon,
double lat,
257 bool getTimeInterpolatedValues(
double &M,
double &A,
int idx1,
int idx2,
258 double lon,
double lat, wxDateTime t);
273 bool m_bDataPlot[GribOverlaySettings::GEO_ALTITUDE];
276 int m_ZoneSelAllowed;
277 int m_old_DialogStyle;
278 void DoZoomToCenter();
279 wxString GetGribDir() {
282 ->Append(wxFileName::GetPathSeparator())
289 this, &dir_spec, _(
"Choose GRIB File Directory"),
m_grib_dir);
291 if (response == wxID_OK) {
316 bool ProjectionEnabled() {
317 if (m_ProjectBoatPanel)
318 return m_ProjectBoatPanel->ProjectionEnabled();
322 double m_highlight_latmax;
323 double m_highlight_lonmax;
324 double m_highlight_latmin;
325 double m_highlight_lonmin;
330 void DoOnMouseEvent(wxMouseEvent &event) { OnMouseEvent(event); }
333 void OnClose(wxCloseEvent &event)
override;
334 void OnSize(wxSizeEvent &event)
override;
335 void OnPaint(wxPaintEvent &event)
override;
336 void OnSettings(wxCommandEvent &event)
override;
337 void OnPlayStop(wxCommandEvent &event)
override;
338 void OnZoomToCenterClick(wxCommandEvent &event)
override;
339 void OnPrev(wxCommandEvent &event)
override;
340 void OnMouseEvent(wxMouseEvent &event)
override;
341 void OnRecordForecast(wxCommandEvent &event)
override {
343 m_InterpolateMode =
false;
347 void OnNext(wxCommandEvent &event)
override;
348 void OnNow(wxCommandEvent &event)
override {
350 ComputeBestForecastForNow();
352 void OnAltitude(wxCommandEvent &event)
override;
353 void OnOpenFile(wxCommandEvent &event)
override;
356 void OnCompositeDialog(wxCommandEvent &event)
override;
358 void OnTimeline(wxScrollEvent &event)
override;
359 void OnShowCursorData(wxCommandEvent &event)
override;
362 void OnPlayStopTimer(wxTimerEvent &event);
363 void OnMove(wxMoveEvent &event);
364 void OnMenuEvent(wxMenuEvent &event);
365 void MenuAppend(wxMenu *menu,
int id, wxString label, wxItemKind kind,
366 wxBitmap bitmap = wxNullBitmap, wxMenu *submenu =
nullptr);
368 void createRequestDialog();
370 wxDateTime MinTime();
371 wxArrayString GetFilesInDirectory();
373 int GetNearestIndex(wxDateTime time,
int model);
374 int GetNearestValue(wxDateTime time,
int model);
376 double *latmax,
double *lonmin,
double *lonmax);
378 void RestaureSelectionString();
379 void SaveSelectionString() {
380 m_SelectionIsSaved =
true;
381 m_Selection_index = m_cRecordForecast->GetSelection();
382 m_Selection_label = m_cRecordForecast->GetString(m_Selection_index);
394 int m_FileIntervalIndex;
395 bool m_InterpolateMode;
399 bool m_SelectionIsSaved;
400 int m_Selection_index;
401 wxString m_Selection_label;
402 wxSize m_DialogsOffset;
403 double m_projected_lat;
404 double m_projected_lon;
409 wxTimer m_tFormatRefresh;
410 wxString m_sLastTimeFormat;
412 void OnFormatRefreshTimer(wxTimerEvent &event);
445 GRIBFile(
const wxArrayString &file_names,
bool CumRec,
bool WaveRec,
446 bool newestFile =
false);
453 [[nodiscard]]
bool IsOK()
const {
return m_bOK; }
470 return &m_GribRecordSetArray;
483 [[nodiscard]]
unsigned int GetCounter()
const {
return m_counter; }
485 WX_DEFINE_ARRAY_INT(
int, GribIdxArray);
486 GribIdxArray m_GribIdxArray;
489 static unsigned int ID;
491 const unsigned int m_counter;
493 wxString m_last_message;
494 wxArrayString m_FileNames;
496 time_t m_pRefDateTime;
499 ArrayOfGribRecordSets m_GribRecordSetArray;
517 void OnMove(wxMoveEvent &event);
Tracks and displays GRIB meteorological data at cursor position.
Manages multiple GRIB record sets from one or more GRIB files.
bool IsOK() const
Checks if file loading and parsing was successful.
wxArrayString & GetFileNames()
Gets the list of source filenames being used.
wxString GetLastMessage()
Gets the last error message if file loading failed.
ArrayOfGribRecordSets * GetRecordSetArrayPtr()
Gets pointer to array of record sets organized by timestamp.
time_t GetRefDateTime() const
Returns the reference datetime of the GRIB data, as the number of seconds since the epoch.
Factory class for creating and managing GRIB data visualizations.
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.
GribPi * pPlugIn
Plugin instance that owns this control bar.
wxString m_grib_dir
Directory containing GRIB files.
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.
void OnRequestForecastData(wxCommandEvent &event) override
Callback invoked when user clicks download/request forecast data.
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.
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.
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.
Base User Interface Components for GRIB Plugin.
GRIB Isobar and Isoline Generation System.
int PlatformDirSelectorDialog(wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir)
Shows platform-optimized directory selector dialog.
wxString * GetpPrivateApplicationDataLocation()
Gets private application data directory.
Structure used to store XyGrib configuration.