OpenCPN Partial API docs
Loading...
Searching...
No Matches
grib_request_dlg.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, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
47#ifndef GRIBREQUESTDIALOG_H_
48#define GRIBREQUESTDIALOG_H_
49
50#ifndef WX_PRECOMP
51#include <wx/wx.h>
52#endif
53
54#include "grib_ui_dlg_base.h"
55#include "grib_ui_dlg.h"
56#include "jsonreader.h"
57#include "pi_ocpndc.h"
58
59#define XYGRIB_MAX_DOWNLOADABLE_GRIB_SIZE_MB 10
60
68
69const std::string CATALOG_URL =
70 "https://raw.githubusercontent.com/chartcatalogs/gribcatalog/main/"
71 "sources.json";
72
77 RENDER_NONE = 0, // No selection zone to render
78 RENDER_COMPLETE = 1, // Selection is complete, render the final zone
79 RENDER_DRAWING = 2 // User is actively drawing the selection zone
80};
81
94public:
96
97 ~GribRequestSetting() override;
98
99 void OnClose(wxCloseEvent &event) override;
100 void SetVpSize(PlugIn_ViewPort *vp);
128 bool MouseEventHook(wxMouseEvent &event);
137 bool RenderZoneOverlay(wxDC &dc);
145 bool RenderGlZoneOverlay();
154 bool DoRenderZoneOverlay();
155 void SetRequestDialogSize();
156 void StopGraphicalZoneSelection();
157 void UpdateAreaSelectionState();
166 [[nodiscard]] double GetMinLat() const;
175 [[nodiscard]] double GetMaxLat() const;
184 [[nodiscard]] double GetMinLon() const;
193 [[nodiscard]] double GetMaxLon() const;
194
195 [[nodiscard]] int GetBoundingBoxCanvasIndex() const {
196 return m_boundingBoxCanvasIndex;
197 }
198
199 void Save() {
200 wxCommandEvent evt;
201 OnOK(evt);
202 }
203
204 wxString m_RequestConfigBase;
205 wxString m_MailToAddresses;
212
223
234 double m_Lat;
236 double m_Lon;
237
238protected:
239 void OnTopChange(wxCommandEvent &event) override;
240 void OnMovingClick(wxCommandEvent &event) override;
241 void OnAnyChange(wxCommandEvent &event) override;
242 void OnAnySpinChange(wxSpinEvent &event) override {
243 wxCommandEvent evt;
244 OnAnyChange(evt);
245 }
247 void OnNotebookPageChanged(wxNotebookEvent &event) override {
248 HighlightArea(0, 0, 0, 0);
249 }
250 void OnTimeRangeChange(wxCommandEvent &event) override;
251 void OnSendMaiL(wxCommandEvent &event) override;
252 void OnOK(wxCommandEvent &event) override;
253 void OnZoneSelectionModeChange(wxCommandEvent &event) override;
254 void OnCancel(wxCommandEvent &event) override {
255 wxCloseEvent evt;
256 OnClose(evt);
257 }
258 void OnWorldLengthChoice(wxCommandEvent &event) override { event.Skip(); }
259 void OnWorldResolutionChoice(wxCommandEvent &event) override { event.Skip(); }
260 void OnWorldDownload(wxCommandEvent &event) override;
261 void OnLocalTreeItemExpanded(wxTreeEvent &event) override { event.Skip(); }
262 void OnLocalTreeSelChanged(wxTreeEvent &event) override;
263 void OnUpdateLocalCatalog(wxCommandEvent &event) override;
264 // XyGrib GUI callbacks
265 void OnXyGribDownloadButton(wxCommandEvent &event) override;
266 void OnXyGribAtmModelChoice(wxCommandEvent &event) override;
267 void OnXyGribWaveModelChoice(wxCommandEvent &event) override;
268 void OnXyGribConfigChange(wxCommandEvent &event) override;
269 void OnDownloadLocal(wxCommandEvent &event) override;
270 void OnCoordinatesChange(wxSpinEvent &event) override;
271 void SaveConfig() override;
272
273private:
274 void HighlightArea(double latmax, double lonmax, double latmin,
275 double lonmin);
276 void ReadLocalCatalog();
277 void FillTreeCtrl(wxJSONValue &data);
278 void ApplyRequestConfig(unsigned rs, unsigned it, unsigned tr);
279 wxString WriteMail();
280 int EstimateFileSize(double *size);
281
282 template <typename T>
283 static std::string FormatPerLocale(T value);
284
285 static wxString GetDownloadProgressText(long bytesTransferred,
286 long bytesTotal);
289 void InitRequestConfig();
290 void OnExit(wxCommandEvent &event) {
291 wxCloseEvent evt;
292 OnClose(evt);
293 }
294
295 void OnMouseEventTimer(wxTimerEvent &event);
296 void SetCoordinatesText();
297
298 void onDLEvent(OCPN_downloadEvent &ev);
299 void EnableDownloadButtons();
300
301 // Xygrib internal methods
302 void InitializeXygribDialog();
303 wxString BuildXyGribUrl();
304 wxString BuildGribFileName();
305
306 // Manage XyGrib UI Configuration
307 void ApplyXyGribConfiguration();
308 void MemorizeXyGribConfiguration();
309 // Calculate estimated size of GRIB file
310 void UpdateGribSizeEstimate();
311
312 // Index of currently selected XyGrib atmospheric model
313 int m_selectedAtmModelIndex;
314 // Index of currently selected XyGrib wave model
315 int m_selectedWaveModelIndex;
316 // Last size estimation of the GRIB file
317 int m_gribSizeEstimate;
318
319 GRIBUICtrlBar &m_parent;
320
321 wxDC *m_pdc;
322 pi_ocpnDC *m_oDC; // Used for selection overlay on GL
323
324 wxTimer m_tMouseEventTimer;
325 wxTimer m_tMouseClickTimer;
326 wxMouseEvent m_SingleClickEvent;
327
328 bool IsZYGRIB;
329 bool IsGFS;
330 int m_MailError_Nb;
331 int m_SendMethod;
332 bool m_AllowSend;
333 bool m_IsMaxLong;
334 double m_displayScale;
335 bool m_connected;
336 bool m_downloading;
337 long m_download_handle;
338 bool m_bTransferSuccess;
339 bool m_canceled;
340 bool m_bLocal_source_selected;
341 GribDownloadType m_downloadType;
344 int m_boundingBoxCanvasIndex;
345};
346
347#endif // GRIBREQUESTDIALOG_H_
Class GribRequestSettingBase.
Manages GRIB file request configuration and downloads.
double m_StartLat
The latitude at the starting point of the bounding box.
void OnXyGribWaveModelChoice(wxCommandEvent &event) override
Handle action of changing wave model selection.
void OnSendMaiL(wxCommandEvent &event) override
Callback invoked when the user clicks the "Send" button in the "e-mail" tab.
double GetMinLat() const
Get the minimum latitude of the bounding box for the download request.
double GetMaxLat() const
Get the maximum latitude of the bounding box for the download request.
double m_Lat
The latitude at the mouse cursor while drawing a bounding box.
void OnCancel(wxCommandEvent &event) override
Callback invoked when the user clicks the "Cancel" button in the "download" dialog.
void OnVpUnderMouseChange(PlugIn_ViewPort *vp)
Callback invoked when the view port under mouse has changed.
bool RenderGlZoneOverlay()
Renders the GRIB area selection overlay using OpenGL.
bool RenderZoneOverlay(wxDC &dc)
Renders the GRIB area selection overlay using standard device context.
double m_Lon
The longitude at the mouse cursor while drawing a bounding box.
void OnXyGribAtmModelChoice(wxCommandEvent &event) override
Handle action of changing atmospheric model selection.
wxPoint m_StartPoint
Starting point of the bounding box in physical pixels.
bool DoRenderZoneOverlay()
Draws the GRIB area selection overlay on the chart.
void OnNotebookPageChanged(wxNotebookEvent &event) override
Save the "download" configuration to disk.
bool MouseEventHook(wxMouseEvent &event)
Intercepts mouse events to handle GRIB area selection.
void OnVpWithFocusChange(PlugIn_ViewPort *vp)
Callback invoked when the focused view port has changed, such as in multi-chart mode when user switch...
PlugIn_ViewPort * m_VpMouse
The viewport under the mouse.
ZoneSelectionRenderState m_RenderSelectionZoneState
Current state of the bounding box overlay rendering.
void OnXyGribConfigChange(wxCommandEvent &event) override
Handle action of changing a GRIB configuration parameter.
double GetMaxLon() const
Get the maximum longitude of the bounding box for the download request.
PlugIn_ViewPort * m_VpFocus
The viewport currently in focus.
double m_StartLon
The longitude at the starting point of the bounding box.
double GetMinLon() const
Get the minimum longitude of the bounding box for the download request.
void OnOK(wxCommandEvent &event) override
Callback invoked when the user clicks the "OK" button in the "download" dialog.
Contains view parameters and status information for a chart display viewport.
The JSON value class implementation.
Definition jsonval.h:79
ZoneSelectionRenderState
Enumeration defining the states of the GRIB zone selection overlay rendering.
GribDownloadType
@ WORLD
Global forecast downloads (e.g., GFS)
@ XYGRIB
Downloads from XyGrib service.
@ NONE
No download source selected.
@ LOCAL_CATALOG
Downloads from configured catalogs.
@ LOCAL
Downloads from local sources.
GRIB Weather Data Control Interface.
Base User Interface Components for GRIB Plugin.
Graphics abstraction layer on top of wxDC or OpenGL.