Aded support for downloading hillshading DEMs
[GPXSee.git] / src / GUI / gui.h
blob1d96e31127d42071fcaefe55c55d7f1a4142f097
1 #ifndef GUI_H
2 #define GUI_H
4 #include <QMainWindow>
5 #include <QString>
6 #include <QList>
7 #include <QDate>
8 #include <QPrinter>
9 #include "common/treenode.h"
10 #include "common/rectc.h"
11 #include "data/graph.h"
12 #include "units.h"
13 #include "timetype.h"
14 #include "format.h"
15 #include "pdfexportdialog.h"
16 #include "pngexportdialog.h"
17 #include "optionsdialog.h"
19 class QMenu;
20 class QToolBar;
21 class QTabWidget;
22 class QActionGroup;
23 class QAction;
24 class QLabel;
25 class QSplitter;
26 class QPrinter;
27 class QGeoPositionInfoSource;
28 class FileBrowser;
29 class GraphTab;
30 class MapView;
31 class Map;
32 class POI;
33 class QScreen;
34 class MapAction;
35 class POIAction;
36 class Data;
37 class DEMLoader;
38 class NavigationWidget;
40 class GUI : public QMainWindow
42 Q_OBJECT
44 public:
45 GUI();
47 bool openFile(const QString &fileName, bool tryUnknown, int &showError);
48 bool loadMap(const QString &fileName, MapAction *&action, int &showError);
49 void show();
50 void writeSettings();
52 private slots:
53 void about();
54 #ifndef Q_OS_ANDROID
55 void keys();
56 #endif // Q_OS_ANDROID
57 void paths();
58 void printFile();
59 void exportPDFFile();
60 void exportPNGFile();
61 void openFile();
62 void openDir();
63 void closeAll();
64 void reloadFiles();
65 void statistics();
66 void openPOIFile();
67 void showGraphs(bool show);
68 void showGraphGrids(bool show);
69 void showGraphSliderInfo(bool show);
70 void showPathMarkerInfo(QAction *action);
71 #ifdef Q_OS_ANDROID
72 void showGraphTabs(bool show);
73 #else // Q_OS_ANDROID
74 void showToolbars(bool show);
75 void showFullscreen(bool show);
76 #endif // Q_OS_ANDROID
77 void showTracks(bool show);
78 void showRoutes(bool show);
79 void showAreas(bool show);
80 void showWaypoints(bool show);
81 void loadMap();
82 void loadMapDir();
83 void nextMap();
84 void prevMap();
85 void openOptions();
86 void clearMapCache();
87 void downloadDataDEM();
88 void downloadMapDEM();
89 void showDEMTiles();
91 void mapChanged(QAction *action);
92 void graphChanged(int);
93 void poiFileChecked(QAction *action);
94 void selectAllPOIs();
95 void unselectAllPOIs();
96 #ifndef Q_OS_ANDROID
97 void recentFileSelected(QAction *action);
98 void clearRecentFiles();
99 #endif // Q_OS_ANDROID
101 void next();
102 void prev();
103 void last();
104 void first();
105 void updateNavigationActions();
107 void setTotalTime() {setTimeType(Total);}
108 void setMovingTime() {setTimeType(Moving);}
109 void setMetricUnits() {setUnits(Metric);}
110 void setImperialUnits() {setUnits(Imperial);}
111 void setNauticalUnits() {setUnits(Nautical);}
112 void setDistanceGraph() {setGraphType(Distance);}
113 void setTimeGraph() {setGraphType(Time);}
114 void setDecimalDegrees() {setCoordinatesFormat(DecimalDegrees);}
115 void setDegreesMinutes() {setCoordinatesFormat(DegreesMinutes);}
116 void setDMS() {setCoordinatesFormat(DMS);}
118 void screenChanged(QScreen *screen);
119 void logicalDotsPerInchChanged(qreal dpi);
121 void mapLoaded();
122 void mapLoadedDir();
123 void mapInitialized();
125 void demLoaded();
127 private:
128 typedef QPair<QDateTime, QDateTime> DateTimeRange;
130 void closeFiles();
131 void plot(QPrinter *printer);
132 void plotMainPage(QPainter *painter, const QRectF &rect, qreal ratio,
133 bool expand = false);
134 void plotGraphsPage(QPainter *painter, const QRectF &rect, qreal ratio);
135 qreal graphPlotHeight(const QRectF &rect, qreal ratio);
137 TreeNode<POIAction*> createPOIActionsNode(const TreeNode<QString> &node);
138 TreeNode<MapAction*> createMapActionsNode(const TreeNode<Map*> &node);
139 void createMapNodeMenu(const TreeNode<MapAction*> &node, QMenu *menu,
140 QAction *action = 0);
141 void createPOINodeMenu(const TreeNode<POIAction*> &node, QMenu *menu,
142 QAction *action = 0);
143 void createActions();
144 void createMenus();
145 #ifdef Q_OS_ANDROID
146 void createNavigation();
147 #else // Q_OS_ANDROID
148 void createToolBars();
149 #endif // Q_OS_ANDROID
150 void createStatusBar();
151 void createMapView();
152 void createGraphTabs();
153 void createBrowser();
155 #ifndef Q_OS_ANDROID
156 void openDir(const QString &path, int &showError);
157 #endif // Q_OS_ANDROID
158 bool openPOIFile(const QString &fileName);
159 bool loadFile(const QString &fileName, bool tryUnknown, int &showError);
160 void loadData(const Data &data);
161 bool loadMapNode(const TreeNode<Map*> &node, MapAction *&action,
162 const QList<QAction*> &existingActions, int &showError);
163 void loadMapDirNode(const TreeNode<Map*> &node, QList<MapAction*> &actions,
164 QMenu *menu, const QList<QAction*> &existingActions, int &showError);
165 void updateStatusBarInfo();
166 void updateWindowTitle();
167 bool updateGraphTabs();
168 void updateDataDEMDownloadAction();
169 void updateMapDEMDownloadAction();
170 #ifndef Q_OS_ANDROID
171 void updateRecentFiles(const QString &fileName);
172 #endif // Q_OS_ANDROID
174 TimeType timeType() const;
175 Units units() const;
176 void setTimeType(TimeType type);
177 void setUnits(Units units);
178 void setCoordinatesFormat(CoordinatesFormat format);
179 void setGraphType(GraphType type);
181 qreal distance() const;
182 qreal time() const;
183 qreal movingTime() const;
184 QAction *mapAction(const QString &name);
185 QGeoPositionInfoSource *positionSource(const Options &options);
186 void readSettings(QString &activeMap, QStringList &disabledPOIs,
187 QStringList &recentFiles);
189 void reloadMap();
190 void loadInitialMaps(const QString &selected);
191 void loadInitialPOIs(const QStringList &disabled);
192 #ifndef Q_OS_ANDROID
193 void loadRecentFiles(const QStringList &files);
194 #endif // Q_OS_ANDROID
196 void downloadDEM(const RectC &rect);
198 void loadOptions();
199 void updateOptions(const Options &options);
201 #ifndef Q_OS_ANDROID
202 void keyPressEvent(QKeyEvent *event);
203 #endif // Q_OS_ANDROID
204 void closeEvent(QCloseEvent *event);
205 void dragEnterEvent(QDragEnterEvent *event);
206 void dropEvent(QDropEvent *event);
208 #ifdef Q_OS_ANDROID
209 NavigationWidget *_navigation;
210 #else // Q_OS_ANDROID
211 QToolBar *_fileToolBar;
212 QToolBar *_showToolBar;
213 QToolBar *_navigationToolBar;
214 #endif // Q_OS_ANDROID
215 QMenu *_poiMenu;
216 QMenu *_mapMenu;
217 #ifndef Q_OS_ANDROID
218 QMenu *_recentFilesMenu;
219 #endif // Q_OS_ANDROID
221 QActionGroup *_fileActionGroup;
222 QActionGroup *_navigationActionGroup;
223 QActionGroup *_mapsActionGroup;
224 QActionGroup *_poisActionGroup;
225 #ifndef Q_OS_ANDROID
226 QActionGroup *_recentFilesActionGroup;
227 #endif // Q_OS_ANDROID
228 #if !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID)
229 QAction *_exitAction;
230 #endif // Q_OS_MAC + Q_OS_ANDROID
231 QAction *_pathsAction;
232 QAction *_aboutAction;
233 QAction *_printFileAction;
234 QAction *_exportPDFFileAction;
235 QAction *_exportPNGFileAction;
236 QAction *_openFileAction;
237 QAction *_openDirAction;
238 QAction *_closeFileAction;
239 QAction *_reloadFileAction;
240 QAction *_statisticsAction;
241 QAction *_openPOIAction;
242 QAction *_selectAllPOIAction;
243 QAction *_unselectAllPOIAction;
244 QAction *_showPOIAction;
245 QAction *_overlapPOIAction;
246 QAction *_showPOILabelsAction;
247 QAction *_showPOIIconsAction;
248 QAction *_showMapAction;
249 QAction *_showPositionAction;
250 QAction *_followPositionAction;
251 QAction *_showPositionCoordinatesAction;
252 QAction *_showMotionInfoAction;
253 QAction *_loadMapAction;
254 QAction *_loadMapDirAction;
255 QAction *_clearMapCacheAction;
256 QAction *_showGraphsAction;
257 QAction *_showGraphGridAction;
258 QAction *_showGraphSliderInfoAction;
259 QAction *_distanceGraphAction;
260 QAction *_timeGraphAction;
261 #ifdef Q_OS_ANDROID
262 QAction *_showGraphTabsAction;
263 #else // Q_OS_ANDROID
264 QAction *_keysAction;
265 QAction *_fullscreenAction;
266 QAction *_showToolbarsAction;
267 QAction *_nextAction;
268 QAction *_prevAction;
269 QAction *_lastAction;
270 QAction *_firstAction;
271 #endif // Q_OS_ANDROID
272 QAction *_metricUnitsAction;
273 QAction *_imperialUnitsAction;
274 QAction *_nauticalUnitsAction;
275 QAction *_decimalDegreesAction;
276 QAction *_degreesMinutesAction;
277 QAction *_dmsAction;
278 QAction *_totalTimeAction;
279 QAction *_movingTimeAction;
280 QAction *_nextMapAction;
281 QAction *_prevMapAction;
282 QAction *_showTracksAction;
283 QAction *_showRoutesAction;
284 QAction *_showWaypointsAction;
285 QAction *_showWaypointLabelsAction;
286 QAction *_showWaypointIconsAction;
287 QAction *_showAreasAction;
288 QAction *_showRouteWaypointsAction;
289 QAction *_hideMarkersAction;
290 QAction *_showMarkersAction;
291 QAction *_showMarkerDateAction;
292 QAction *_showMarkerCoordinatesAction;
293 QAction *_showTicksAction;
294 QAction *_useStylesAction;
295 QAction *_showCoordinatesAction;
296 QAction *_openOptionsAction;
297 QAction *_downloadDataDEMAction;
298 QAction *_downloadMapDEMAction;
299 QAction *_showDEMTilesAction;
300 QAction *_drawHillShadingAction;
301 QAction *_mapsEnd;
302 QAction *_poisEnd;
303 #ifndef Q_OS_ANDROID
304 QAction *_clearRecentFilesAction;
305 QAction *_recentFilesEnd;
306 #endif // Q_OS_ANDROID
308 QLabel *_fileNameLabel;
309 QLabel *_distanceLabel;
310 QLabel *_timeLabel;
312 QSplitter *_splitter;
313 MapView *_mapView;
314 QTabWidget *_graphTabWidget;
315 QList<GraphTab*> _tabs;
316 GraphTab *_lastTab;
318 POI *_poi;
319 Map *_map;
320 QGeoPositionInfoSource *_positionSource;
321 DEMLoader *_dem;
323 FileBrowser *_browser;
324 QList<QString> _files;
326 int _trackCount, _routeCount, _areaCount, _waypointCount;
327 qreal _trackDistance, _routeDistance;
328 qreal _time, _movingTime;
329 DateTimeRange _dateRange;
330 QString _pathName;
332 #ifndef Q_OS_ANDROID
333 QList<QByteArray> _windowStates;
334 QList<QByteArray> _windowGeometries;
335 int _frameStyle;
336 #endif // Q_OS_ANDROID
338 PDFExport _pdfExport;
339 PNGExport _pngExport;
340 Options _options;
342 QString _dataDir, _mapDir, _poiDir;
344 Units _units;
346 QList<RectC> _demRects;
349 #endif // GUI_H