OpenCPN Partial API docs
Loading...
Searching...
No Matches
GribRequestDialog.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 ***************************************************************************
19 */
47#ifndef __GRIBREQUESTDIALOG_H__
48#define __GRIBREQUESTDIALOG_H__
49
50#ifndef WX_PRECOMP
51#include "wx/wx.h"
52#endif // precompiled headers
53
54#include "GribUIDialogBase.h"
55#include "GribUIDialog.h"
56#include "pi_ocpndc.h"
57#include "wx/jsonreader.h"
58
66
67const std::string CATALOG_URL =
68 "https://raw.githubusercontent.com/chartcatalogs/gribcatalog/main/"
69 "sources.json";
70
71#define XYGRIB_MAX_DOWNLOADABLE_GRIB_SIZE_MB 10
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
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 double GetMinLat() const;
175 double GetMaxLat() const;
184 double GetMinLon() const;
193 double GetMaxLon() const;
194
195 int GetBoundingBoxCanvasIndex() const { return m_boundingBoxCanvasIndex; }
196
197 void Save() {
198 wxCommandEvent evt;
199 OnOK(evt);
200 }
201
202 wxString m_RequestConfigBase;
203 wxString m_MailToAddresses;
210
221
232 double m_Lat;
234 double m_Lon;
235
236private:
237 void HighlightArea(double latmax, double lonmax, double latmin,
238 double lonmin);
239 void ReadLocalCatalog();
240 void FillTreeCtrl(wxJSONValue &data);
241 void ApplyRequestConfig(unsigned rs, unsigned it, unsigned tr);
242 wxString WriteMail();
243 int EstimateFileSize(double *size);
244
245 template <typename T>
246 static std::string FormatPerLocale(T value);
247
248 static wxString GetDownloadProgressText(long bytesTransferred,
249 long bytesTotal);
251 void SaveConfig() override;
254 void InitRequestConfig();
255 void OnExit(wxCommandEvent &event) {
256 wxCloseEvent evt;
257 OnClose(evt);
258 }
259 void OnTopChange(wxCommandEvent &event) override;
260 void OnMovingClick(wxCommandEvent &event) override;
261 void OnAnyChange(wxCommandEvent &event) override;
262 void OnAnySpinChange(wxSpinEvent &event) override {
263 wxCommandEvent evt;
264 OnAnyChange(evt);
265 }
266 void OnNotebookPageChanged(wxNotebookEvent &event) override {
267 HighlightArea(0, 0, 0, 0);
268 }
269 void OnTimeRangeChange(wxCommandEvent &event) override;
270 void OnSendMaiL(wxCommandEvent &event) override;
271 void OnOK(wxCommandEvent &event) override;
272 void OnZoneSelectionModeChange(wxCommandEvent &event) override;
273 void OnCancel(wxCommandEvent &event) override {
274 wxCloseEvent evt;
275 OnClose(evt);
276 }
277 void OnCoordinatesChange(wxSpinEvent &event) override;
278 void OnMouseEventTimer(wxTimerEvent &event);
279 void SetCoordinatesText();
280 void OnWorldLengthChoice(wxCommandEvent &event) override { event.Skip(); }
281 void OnWorldResolutionChoice(wxCommandEvent &event) override { event.Skip(); }
282 void OnWorldDownload(wxCommandEvent &event) override;
283 void OnLocalTreeItemExpanded(wxTreeEvent &event) override { event.Skip(); }
284 void OnLocalTreeSelChanged(wxTreeEvent &event) override;
285 void OnUpdateLocalCatalog(wxCommandEvent &event) override;
286 void OnDownloadLocal(wxCommandEvent &event) override;
287 void onDLEvent(OCPN_downloadEvent &ev);
288 void EnableDownloadButtons();
289
290 // Xygrib internal methods
291 void InitializeXygribDialog();
292 wxString BuildXyGribUrl();
293 wxString BuildGribFileName();
294 // XyGrib GUI callbacks
295 void OnXyGribDownloadButton(wxCommandEvent &event) override;
296 void OnXyGribAtmModelChoice(wxCommandEvent &event) override;
297 void OnXyGribWaveModelChoice(wxCommandEvent &event) override;
298 void OnXyGribConfigChange(wxCommandEvent &event) override;
299 // Manage XyGrib UI Configuration
300 void ApplyXyGribConfiguration();
301 void MemorizeXyGribConfiguration();
302 // Calculate estimated size of GRIB file
303 void UpdateGribSizeEstimate();
304
305 // Index of currently selected XyGrib atmospheric model
306 int m_selectedAtmModelIndex;
307 // Index of currently selected XyGrib wave model
308 int m_selectedWaveModelIndex;
309 // Last size estimation of the GRIB file
310 int m_gribSizeEstimate;
311
312 GRIBUICtrlBar &m_parent;
313
314 wxDC *m_pdc;
315 pi_ocpnDC *m_oDC; // Used for selection overlay on GL
316
317 wxTimer m_tMouseEventTimer;
318 wxTimer m_tMouseClickTimer;
319 wxMouseEvent m_SingleClickEvent;
320
321 bool IsZYGRIB;
322 bool IsGFS;
323 int m_MailError_Nb;
324 int m_SendMethod;
325 bool m_AllowSend;
326 bool m_IsMaxLong;
327 double m_displayScale;
328 bool m_connected;
329 bool m_downloading;
330 long m_download_handle;
331 bool m_bTransferSuccess;
332 bool m_canceled;
333 bool m_bLocal_source_selected;
334 GribDownloadType m_downloadType;
337 int m_boundingBoxCanvasIndex;
338};
339
340#endif
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.
Base User Interface Components for GRIB Plugin.
GRIB Weather Data Control Interface.
Class GribRequestSettingBase.
Manages GRIB file request configuration and downloads.
double m_StartLat
The latitude at the starting point of the bounding box.
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 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.
wxPoint m_StartPoint
Starting point of the bounding box in physical pixels.
bool DoRenderZoneOverlay()
Draws the GRIB area selection overlay on the chart.
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.
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.
Contains view parameters and status information for a chart display viewport.
The JSON value class implementation.
Definition jsonval.h:84