2013-05-17 11:14:10 +00:00
|
|
|
#include "globe.h"
|
2014-03-26 22:08:56 +00:00
|
|
|
#ifndef NO_MARBLE
|
2013-06-05 06:41:52 +00:00
|
|
|
#include "mainwindow.h"
|
2014-05-01 17:47:52 +00:00
|
|
|
#include "helpers.h"
|
2015-02-09 20:27:59 +00:00
|
|
|
#include "divelistview.h"
|
2015-02-09 20:58:40 +00:00
|
|
|
#include "maintab.h"
|
2015-02-09 21:51:31 +00:00
|
|
|
#include "display.h"
|
2015-02-09 20:58:40 +00:00
|
|
|
|
2013-10-17 21:53:12 +00:00
|
|
|
#include <QTimer>
|
2015-02-09 20:58:40 +00:00
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QMouseEvent>
|
2013-05-17 16:28:02 +00:00
|
|
|
|
2013-05-17 11:14:10 +00:00
|
|
|
#include <marble/AbstractFloatItem.h>
|
2013-05-17 16:28:02 +00:00
|
|
|
#include <marble/GeoDataPlacemark.h>
|
|
|
|
#include <marble/GeoDataDocument.h>
|
|
|
|
#include <marble/MarbleModel.h>
|
2013-05-25 15:28:35 +00:00
|
|
|
#include <marble/MarbleDirs.h>
|
2013-05-29 19:59:38 +00:00
|
|
|
#include <marble/MapThemeManager.h>
|
2015-06-28 05:53:39 +00:00
|
|
|
#include <marble/GeoDataStyle.h>
|
|
|
|
#include <marble/GeoDataIconStyle.h>
|
2015-01-17 09:43:52 +00:00
|
|
|
|
2014-12-17 14:35:29 +00:00
|
|
|
#ifdef MARBLE_SUBSURFACE_BRANCH
|
2014-12-14 01:08:58 +00:00
|
|
|
#include <marble/MarbleDebug.h>
|
2014-12-17 14:35:29 +00:00
|
|
|
#endif
|
2013-05-18 16:44:54 +00:00
|
|
|
#if INCOMPLETE_MARBLE
|
|
|
|
#include "marble/GeoDataTreeModel.h"
|
|
|
|
#else
|
2013-05-17 16:28:02 +00:00
|
|
|
#include <marble/GeoDataTreeModel.h>
|
2013-05-18 16:44:54 +00:00
|
|
|
#endif
|
2013-05-17 11:14:10 +00:00
|
|
|
|
2014-05-04 18:35:34 +00:00
|
|
|
// as of Marble 4.10 (which has MARBLE_VERSION 0x001000) zoomView is
|
|
|
|
// deprecated and has been replaced by setZoom with the same function signature
|
|
|
|
#if MARBLE_VERSION < 0x001000
|
|
|
|
#define setZoom zoomView
|
|
|
|
#endif
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent),
|
2014-02-09 18:41:47 +00:00
|
|
|
loadedDives(0),
|
|
|
|
messageWidget(new KMessageWidget(this)),
|
|
|
|
fixZoomTimer(new QTimer(this)),
|
2014-05-01 21:48:14 +00:00
|
|
|
needResetZoom(false),
|
2015-06-22 05:19:59 +00:00
|
|
|
editingDiveLocation(false),
|
|
|
|
doubleClick(false)
|
2013-05-17 11:14:10 +00:00
|
|
|
{
|
2014-12-16 15:06:22 +00:00
|
|
|
#ifdef MARBLE_SUBSURFACE_BRANCH
|
|
|
|
// we need to make sure this gets called after the command line arguments have
|
|
|
|
// been processed but before we initialize the rest of Marble
|
|
|
|
Marble::MarbleDebug::setEnabled(verbose);
|
|
|
|
#endif
|
2015-06-27 03:29:13 +00:00
|
|
|
currentZoomLevel = zoomFromDistance(3.0);
|
2013-05-29 19:59:38 +00:00
|
|
|
// check if Google Sat Maps are installed
|
|
|
|
// if not, check if they are in a known location
|
|
|
|
MapThemeManager mtm;
|
|
|
|
QStringList list = mtm.mapThemeIds();
|
2014-02-28 04:09:57 +00:00
|
|
|
QString subsurfaceDataPath;
|
2013-05-29 19:59:38 +00:00
|
|
|
QDir marble;
|
2013-12-26 14:02:58 +00:00
|
|
|
if (!list.contains("earth/googlesat/googlesat.dgml")) {
|
2013-05-30 21:26:08 +00:00
|
|
|
subsurfaceDataPath = getSubsurfaceDataPath("marbledata");
|
2014-05-11 00:37:18 +00:00
|
|
|
if (subsurfaceDataPath.size()) {
|
2013-05-30 21:26:08 +00:00
|
|
|
MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
|
2013-11-29 19:46:41 +00:00
|
|
|
} else {
|
|
|
|
subsurfaceDataPath = getSubsurfaceDataPath("data");
|
2014-05-11 00:37:18 +00:00
|
|
|
if (subsurfaceDataPath.size())
|
2013-11-29 19:46:41 +00:00
|
|
|
MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
|
|
|
|
}
|
2013-05-30 07:08:11 +00:00
|
|
|
}
|
2013-05-24 19:15:49 +00:00
|
|
|
messageWidget->setCloseButtonVisible(false);
|
|
|
|
messageWidget->setHidden(true);
|
2013-05-18 01:52:04 +00:00
|
|
|
|
2013-05-24 14:07:59 +00:00
|
|
|
setMapThemeId("earth/googlesat/googlesat.dgml");
|
2013-05-18 01:52:04 +00:00
|
|
|
//setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
|
2013-05-23 04:25:05 +00:00
|
|
|
setProjection(Marble::Spherical);
|
2013-05-17 11:14:10 +00:00
|
|
|
|
2013-05-17 17:09:10 +00:00
|
|
|
setAnimationsEnabled(true);
|
2014-05-22 18:40:22 +00:00
|
|
|
Q_FOREACH (AbstractFloatItem *i, floatItems()) {
|
2013-11-22 02:33:44 +00:00
|
|
|
i->setVisible(false);
|
|
|
|
}
|
|
|
|
|
2013-05-23 04:25:05 +00:00
|
|
|
setShowClouds(false);
|
|
|
|
setShowBorders(false);
|
|
|
|
setShowPlaces(true);
|
|
|
|
setShowCrosshairs(false);
|
|
|
|
setShowGrid(false);
|
2013-05-17 11:14:10 +00:00
|
|
|
setShowOverviewMap(false);
|
2013-05-18 01:52:04 +00:00
|
|
|
setShowScaleBar(true);
|
2013-05-24 19:21:16 +00:00
|
|
|
setShowCompass(false);
|
2013-09-26 21:14:09 +00:00
|
|
|
connect(this, SIGNAL(mouseClickGeoPosition(qreal, qreal, GeoDataCoordinates::Unit)),
|
2014-02-28 04:09:57 +00:00
|
|
|
this, SLOT(mouseClicked(qreal, qreal, GeoDataCoordinates::Unit)));
|
2013-09-26 21:14:09 +00:00
|
|
|
|
|
|
|
setMinimumHeight(0);
|
|
|
|
setMinimumWidth(0);
|
2013-10-17 21:53:12 +00:00
|
|
|
connect(fixZoomTimer, SIGNAL(timeout()), this, SLOT(fixZoom()));
|
|
|
|
fixZoomTimer->setSingleShot(true);
|
2013-11-22 02:22:57 +00:00
|
|
|
installEventFilter(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GlobeGPS::eventFilter(QObject *obj, QEvent *ev)
|
|
|
|
{
|
2014-06-11 16:25:55 +00:00
|
|
|
// sometimes Marble seems not to notice double clicks and consequently not call
|
|
|
|
// the right callback - so let's remember here if the last 'click' is a 'double' or not
|
|
|
|
enum QEvent::Type type = ev->type();
|
|
|
|
if (type == QEvent::MouseButtonDblClick)
|
|
|
|
doubleClick = true;
|
|
|
|
else if (type == QEvent::MouseButtonPress)
|
|
|
|
doubleClick = false;
|
|
|
|
|
2013-11-22 02:22:57 +00:00
|
|
|
// This disables Zooming when a double click occours on the scene.
|
2014-06-11 16:25:55 +00:00
|
|
|
if (type == QEvent::MouseButtonDblClick && !editingDiveLocation)
|
2013-11-22 02:22:57 +00:00
|
|
|
return true;
|
|
|
|
// This disables the Marble's Context Menu
|
|
|
|
// we need to move this to our 'contextMenuEvent'
|
|
|
|
// if we plan to do a different one in the future.
|
2014-06-11 16:25:55 +00:00
|
|
|
if (type == QEvent::ContextMenu) {
|
2014-02-28 04:09:57 +00:00
|
|
|
contextMenuEvent(static_cast<QContextMenuEvent *>(ev));
|
2013-11-22 02:22:57 +00:00
|
|
|
return true;
|
2013-12-02 17:06:19 +00:00
|
|
|
}
|
2014-06-11 16:25:55 +00:00
|
|
|
if (type == QEvent::MouseButtonPress) {
|
2014-02-28 04:09:57 +00:00
|
|
|
QMouseEvent *e = static_cast<QMouseEvent *>(ev);
|
|
|
|
if (e->button() == Qt::RightButton)
|
2013-11-22 02:22:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-02-28 04:09:57 +00:00
|
|
|
return QObject::eventFilter(obj, ev);
|
2013-12-02 17:06:19 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
void GlobeGPS::contextMenuEvent(QContextMenuEvent *ev)
|
2013-12-02 17:06:19 +00:00
|
|
|
{
|
|
|
|
QMenu m;
|
2014-07-11 08:21:38 +00:00
|
|
|
QAction *a = m.addAction(tr("Edit selected dive locations"), this, SLOT(prepareForGetDiveCoordinates()));
|
2014-02-28 04:09:57 +00:00
|
|
|
a->setData(QVariant::fromValue<void *>(&m));
|
2014-08-17 00:35:32 +00:00
|
|
|
a->setEnabled(current_dive);
|
2013-12-02 17:06:19 +00:00
|
|
|
m.exec(ev->globalPos());
|
2013-06-05 05:44:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
|
|
|
{
|
2014-06-11 16:25:55 +00:00
|
|
|
if (doubleClick) {
|
|
|
|
// strangely sometimes we don't get the changeDiveGeoPosition callback
|
|
|
|
// and end up here instead
|
|
|
|
changeDiveGeoPosition(lon, lat, unit);
|
|
|
|
return;
|
|
|
|
}
|
2013-11-10 21:23:18 +00:00
|
|
|
// don't mess with the selection while the user is editing a dive
|
2014-05-01 16:45:43 +00:00
|
|
|
if (MainWindow::instance()->information()->isEditing() || messageWidget->isVisible())
|
2013-11-10 21:23:18 +00:00
|
|
|
return;
|
|
|
|
|
2013-06-05 05:44:12 +00:00
|
|
|
GeoDataCoordinates here(lon, lat, unit);
|
2013-06-05 06:41:52 +00:00
|
|
|
long lon_udeg = rint(1000000 * here.longitude(GeoDataCoordinates::Degree));
|
|
|
|
long lat_udeg = rint(1000000 * here.latitude(GeoDataCoordinates::Degree));
|
|
|
|
|
|
|
|
// distance() is in km above the map.
|
|
|
|
// We're going to use that to decide how
|
|
|
|
// approximate the dives have to be.
|
|
|
|
//
|
|
|
|
// Totally arbitrarily I say that 1km
|
|
|
|
// distance means that we can resolve
|
|
|
|
// to about 100m. Which in turn is about
|
|
|
|
// 1000 udeg.
|
|
|
|
//
|
|
|
|
// Trigonometry is hard, but sin x == x
|
|
|
|
// for small x, so let's just do this as
|
|
|
|
// a linear thing.
|
|
|
|
long resolve = rint(distance() * 1000);
|
|
|
|
|
|
|
|
int idx;
|
|
|
|
struct dive *dive;
|
2013-12-03 17:29:40 +00:00
|
|
|
bool clear = !(QApplication::keyboardModifiers() & Qt::ControlModifier);
|
2013-12-02 19:15:40 +00:00
|
|
|
QList<int> selectedDiveIds;
|
2014-05-22 18:40:22 +00:00
|
|
|
for_each_dive (idx, dive) {
|
2013-06-05 06:41:52 +00:00
|
|
|
long lat_diff, lon_diff;
|
2015-02-12 09:19:07 +00:00
|
|
|
struct dive_site *ds = get_dive_site_for_dive(dive);
|
|
|
|
if (!dive_site_has_gps_location(ds))
|
2013-06-05 06:41:52 +00:00
|
|
|
continue;
|
2015-02-12 09:19:07 +00:00
|
|
|
lat_diff = labs(ds->latitude.udeg - lat_udeg);
|
|
|
|
lon_diff = labs(ds->longitude.udeg - lon_udeg);
|
2013-06-05 06:41:52 +00:00
|
|
|
if (lat_diff > 180000000)
|
|
|
|
lat_diff = 360000000 - lat_diff;
|
|
|
|
if (lon_diff > 180000000)
|
|
|
|
lon_diff = 180000000 - lon_diff;
|
|
|
|
if (lat_diff > resolve || lon_diff > resolve)
|
|
|
|
continue;
|
|
|
|
|
2013-12-02 19:15:40 +00:00
|
|
|
selectedDiveIds.push_back(idx);
|
2013-06-05 06:41:52 +00:00
|
|
|
}
|
2014-01-16 04:50:56 +00:00
|
|
|
if (selectedDiveIds.empty())
|
2013-12-03 17:29:40 +00:00
|
|
|
return;
|
2014-03-04 05:24:52 +00:00
|
|
|
if (clear)
|
2014-02-12 14:22:54 +00:00
|
|
|
MainWindow::instance()->dive_list()->unselectDives();
|
|
|
|
MainWindow::instance()->dive_list()->selectDives(selectedDiveIds);
|
2013-05-17 11:14:10 +00:00
|
|
|
}
|
2013-05-17 16:28:02 +00:00
|
|
|
|
2013-11-19 12:23:59 +00:00
|
|
|
void GlobeGPS::repopulateLabels()
|
2013-05-17 16:28:02 +00:00
|
|
|
{
|
2015-06-28 05:53:39 +00:00
|
|
|
static GeoDataStyle otherSite, currentSite;
|
|
|
|
static GeoDataIconStyle darkFlag(QImage(":flagDark")), lightFlag(QImage(":flagLight"));
|
2015-02-12 09:19:07 +00:00
|
|
|
struct dive_site *ds;
|
2015-06-04 02:00:58 +00:00
|
|
|
int idx;
|
|
|
|
QMap<QString, GeoDataPlacemark *> locationMap;
|
2013-05-23 04:25:05 +00:00
|
|
|
if (loadedDives) {
|
2013-05-17 16:28:02 +00:00
|
|
|
model()->treeModel()->removeDocument(loadedDives);
|
|
|
|
delete loadedDives;
|
|
|
|
}
|
|
|
|
loadedDives = new GeoDataDocument;
|
2015-06-28 05:53:39 +00:00
|
|
|
otherSite.setIconStyle(darkFlag);
|
|
|
|
currentSite.setIconStyle(lightFlag);
|
2013-05-17 16:28:02 +00:00
|
|
|
|
2015-06-28 05:53:39 +00:00
|
|
|
if (displayed_dive_site.uuid && dive_site_has_gps_location(&displayed_dive_site)) {
|
|
|
|
GeoDataPlacemark *place = new GeoDataPlacemark(displayed_dive_site.name);
|
|
|
|
place->setStyle(¤tSite);
|
|
|
|
place->setCoordinate(displayed_dive_site.longitude.udeg / 1000000.0,
|
|
|
|
displayed_dive_site.latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
|
|
|
|
locationMap[QString(displayed_dive_site.name)] = place;
|
|
|
|
loadedDives->append(place);
|
|
|
|
}
|
2015-06-04 02:00:58 +00:00
|
|
|
for_each_dive_site(idx, ds) {
|
2015-06-07 12:31:18 +00:00
|
|
|
if (ds->uuid == displayed_dive_site.uuid)
|
|
|
|
continue;
|
2015-02-12 09:19:07 +00:00
|
|
|
if (dive_site_has_gps_location(ds)) {
|
|
|
|
GeoDataPlacemark *place = new GeoDataPlacemark(ds->name);
|
2015-06-28 05:53:39 +00:00
|
|
|
place->setStyle(&otherSite);
|
2015-02-12 09:19:07 +00:00
|
|
|
place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
|
2015-06-07 12:31:18 +00:00
|
|
|
|
2013-06-05 02:46:57 +00:00
|
|
|
// don't add dive locations twice, unless they are at least 50m apart
|
2015-02-12 09:19:07 +00:00
|
|
|
if (locationMap[QString(ds->name)]) {
|
|
|
|
GeoDataCoordinates existingLocation = locationMap[QString(ds->name)]->coordinate();
|
2013-06-05 02:46:57 +00:00
|
|
|
GeoDataLineString segment = GeoDataLineString();
|
|
|
|
segment.append(existingLocation);
|
2013-06-08 05:02:00 +00:00
|
|
|
GeoDataCoordinates newLocation = place->coordinate();
|
2013-06-05 02:46:57 +00:00
|
|
|
segment.append(newLocation);
|
|
|
|
double dist = segment.length(6371);
|
|
|
|
// the dist is scaled to the radius given - so with 6371km as radius
|
|
|
|
// 50m turns into 0.05 as threashold
|
|
|
|
if (dist < 0.05)
|
|
|
|
continue;
|
|
|
|
}
|
2015-02-12 09:19:07 +00:00
|
|
|
locationMap[QString(ds->name)] = place;
|
2013-05-23 04:25:05 +00:00
|
|
|
loadedDives->append(place);
|
2013-05-17 16:28:02 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-23 04:25:05 +00:00
|
|
|
model()->treeModel()->addDocument(loadedDives);
|
2015-06-07 12:31:18 +00:00
|
|
|
|
2015-06-04 02:00:58 +00:00
|
|
|
struct dive_site *center = displayed_dive_site.uuid != 0 ?
|
2015-06-07 12:31:18 +00:00
|
|
|
&displayed_dive_site : current_dive ?
|
|
|
|
get_dive_site_by_uuid(current_dive->dive_site_uuid) : NULL;
|
2015-06-04 02:00:58 +00:00
|
|
|
if(center)
|
|
|
|
centerOn(displayed_dive_site.longitude.udeg / 1000000.0, displayed_dive_site.latitude.udeg / 1000000.0, true);
|
2013-05-17 16:28:02 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 12:23:59 +00:00
|
|
|
void GlobeGPS::reload()
|
|
|
|
{
|
2013-12-02 17:06:19 +00:00
|
|
|
editingDiveLocation = false;
|
2014-06-30 00:45:11 +00:00
|
|
|
messageWidget->hide();
|
2013-11-19 12:23:59 +00:00
|
|
|
repopulateLabels();
|
|
|
|
}
|
|
|
|
|
2015-06-05 13:52:52 +00:00
|
|
|
void GlobeGPS::centerOnDiveSite(uint32_t uuid)
|
2013-05-17 16:28:02 +00:00
|
|
|
{
|
2015-06-05 13:52:52 +00:00
|
|
|
struct dive_site *ds = get_dive_site_by_uuid(uuid);
|
2013-05-17 19:12:55 +00:00
|
|
|
|
2015-02-12 09:19:07 +00:00
|
|
|
if (!dive_site_has_gps_location(ds)) {
|
2014-05-01 17:47:52 +00:00
|
|
|
zoomOutForNoGPS();
|
2013-05-17 19:12:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-27 17:27:14 +00:00
|
|
|
|
2015-06-05 13:52:52 +00:00
|
|
|
qreal longitude = ds->longitude.udeg / 1000000.0;
|
|
|
|
qreal latitude = ds->latitude.udeg / 1000000.0;
|
|
|
|
|
2014-05-01 21:48:14 +00:00
|
|
|
// if no zoom is set up, set the zoom as seen from 3km above
|
|
|
|
// if we come back from a dive without GPS data, reset to the last zoom value
|
|
|
|
// otherwise check to make sure we aren't still running an animation and then remember
|
|
|
|
// the current zoom level
|
2015-06-27 03:29:13 +00:00
|
|
|
if (fixZoomTimer->isActive()) {
|
|
|
|
fixZoomTimer->stop();
|
2014-05-01 21:48:14 +00:00
|
|
|
} else if (needResetZoom) {
|
|
|
|
needResetZoom = false;
|
|
|
|
fixZoom();
|
2015-06-27 03:29:13 +00:00
|
|
|
} else if (zoom() > 1000) {
|
2014-02-28 04:09:57 +00:00
|
|
|
currentZoomLevel = zoom();
|
2015-06-27 03:29:13 +00:00
|
|
|
}
|
2013-10-17 21:53:12 +00:00
|
|
|
// From the marble source code, the maximum time of
|
2015-06-27 03:29:13 +00:00
|
|
|
// 'spin and fit' is 2000 miliseconds so wait a bit them zoom again.
|
2013-10-17 21:53:12 +00:00
|
|
|
fixZoomTimer->start(2100);
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
centerOn(longitude, latitude, true);
|
2013-05-17 19:12:55 +00:00
|
|
|
}
|
|
|
|
|
2013-10-17 21:53:12 +00:00
|
|
|
void GlobeGPS::fixZoom()
|
|
|
|
{
|
2014-05-01 21:48:14 +00:00
|
|
|
setZoom(currentZoomLevel, Marble::Linear);
|
2013-10-17 21:53:12 +00:00
|
|
|
}
|
|
|
|
|
2014-05-01 17:47:52 +00:00
|
|
|
void GlobeGPS::zoomOutForNoGPS()
|
|
|
|
{
|
|
|
|
// this is called if the dive has no GPS location.
|
|
|
|
// zoom out quite a bit to show the globe and remember that the next time
|
|
|
|
// we show a dive with GPS location we need to zoom in again
|
|
|
|
if (!needResetZoom) {
|
|
|
|
needResetZoom = true;
|
2015-06-27 03:27:06 +00:00
|
|
|
if (!fixZoomTimer->isActive())
|
|
|
|
currentZoomLevel = zoom();
|
2014-05-01 17:47:52 +00:00
|
|
|
}
|
2015-06-27 03:27:06 +00:00
|
|
|
if (fixZoomTimer->isActive())
|
|
|
|
fixZoomTimer->stop();
|
|
|
|
// 1000 is supposed to make sure you see the whole globe
|
|
|
|
setZoom(1000, Marble::Linear);
|
2014-05-01 17:47:52 +00:00
|
|
|
}
|
|
|
|
|
2015-06-04 01:53:38 +00:00
|
|
|
void GlobeGPS::endGetDiveCoordinates()
|
|
|
|
{
|
|
|
|
messageWidget->animatedHide();
|
|
|
|
editingDiveLocation = false;
|
|
|
|
}
|
|
|
|
|
2014-05-07 21:01:05 +00:00
|
|
|
void GlobeGPS::prepareForGetDiveCoordinates()
|
2013-05-17 19:12:55 +00:00
|
|
|
{
|
2015-06-04 01:53:38 +00:00
|
|
|
messageWidget->setMessageType(KMessageWidget::Warning);
|
|
|
|
messageWidget->setText(QObject::tr("Move the map and double-click to set the dive location"));
|
|
|
|
messageWidget->setWordWrap(true);
|
|
|
|
messageWidget->setCloseButtonVisible(false);
|
|
|
|
messageWidget->animatedShow();
|
|
|
|
editingDiveLocation = true;
|
|
|
|
if (!dive_has_gps_location(current_dive))
|
|
|
|
zoomOutForNoGPS();
|
2013-11-19 12:12:31 +00:00
|
|
|
}
|
|
|
|
|
2013-05-17 19:12:55 +00:00
|
|
|
void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
|
|
|
{
|
2015-06-04 02:04:55 +00:00
|
|
|
if (!editingDiveLocation)
|
2013-12-02 17:06:19 +00:00
|
|
|
return;
|
|
|
|
|
2013-05-17 19:12:55 +00:00
|
|
|
// convert to degrees if in radian.
|
2013-05-23 04:25:05 +00:00
|
|
|
if (unit == GeoDataCoordinates::Radian) {
|
2013-05-17 19:12:55 +00:00
|
|
|
lon = lon * 180 / M_PI;
|
|
|
|
lat = lat * 180 / M_PI;
|
|
|
|
}
|
|
|
|
centerOn(lon, lat, true);
|
2015-01-19 05:32:17 +00:00
|
|
|
|
|
|
|
// change the location of the displayed_dive and put the UI in edit mode
|
2015-02-13 20:38:56 +00:00
|
|
|
displayed_dive_site.latitude.udeg = lrint(lat * 1000000.0);
|
|
|
|
displayed_dive_site.longitude.udeg = lrint(lon * 1000000.0);
|
2015-05-31 22:53:35 +00:00
|
|
|
emit coordinatesChanged();
|
2015-01-19 05:32:17 +00:00
|
|
|
repopulateLabels();
|
2013-05-17 16:28:02 +00:00
|
|
|
}
|
2013-05-17 19:12:55 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
void GlobeGPS::mousePressEvent(QMouseEvent *event)
|
2013-05-17 19:12:55 +00:00
|
|
|
{
|
2014-05-02 04:21:59 +00:00
|
|
|
if (event->type() != QEvent::MouseButtonDblClick)
|
|
|
|
return;
|
|
|
|
|
2013-05-17 19:12:55 +00:00
|
|
|
qreal lat, lon;
|
2013-12-02 17:06:19 +00:00
|
|
|
bool clickOnGlobe = geoCoordinates(event->pos().x(), event->pos().y(), lon, lat, GeoDataCoordinates::Degree);
|
|
|
|
|
2013-11-19 12:12:31 +00:00
|
|
|
// there could be two scenarios that got us here; let's check if we are editing a dive
|
2014-02-12 14:22:54 +00:00
|
|
|
if (MainWindow::instance()->information()->isEditing() && clickOnGlobe) {
|
2015-02-13 06:24:12 +00:00
|
|
|
//
|
|
|
|
// FIXME
|
|
|
|
// TODO
|
|
|
|
//
|
|
|
|
// this needs to do this on the dive site screen
|
|
|
|
// MainWindow::instance()->information()->updateCoordinatesText(lat, lon);
|
2013-11-19 12:23:59 +00:00
|
|
|
repopulateLabels();
|
2013-12-02 17:06:19 +00:00
|
|
|
} else if (clickOnGlobe) {
|
2013-05-24 23:06:51 +00:00
|
|
|
changeDiveGeoPosition(lon, lat, GeoDataCoordinates::Degree);
|
2013-05-17 19:12:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
void GlobeGPS::resizeEvent(QResizeEvent *event)
|
2013-05-18 00:58:49 +00:00
|
|
|
{
|
2014-02-28 04:09:57 +00:00
|
|
|
int size = event->size().width();
|
2013-05-24 19:15:49 +00:00
|
|
|
MarbleWidget::resizeEvent(event);
|
|
|
|
if (size > 600)
|
|
|
|
messageWidget->setGeometry((size - 600) / 2, 5, 600, 0);
|
|
|
|
else
|
|
|
|
messageWidget->setGeometry(5, 5, size - 10, 0);
|
|
|
|
messageWidget->setMaximumHeight(500);
|
|
|
|
}
|
2014-03-26 22:08:56 +00:00
|
|
|
#else
|
|
|
|
|
2014-05-22 18:40:22 +00:00
|
|
|
GlobeGPS::GlobeGPS(QWidget *parent)
|
|
|
|
{
|
|
|
|
setText("MARBLE DISABLED AT BUILD TIME");
|
|
|
|
}
|
|
|
|
void GlobeGPS::repopulateLabels()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void GlobeGPS::centerOnCurrentDive()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
bool GlobeGPS::eventFilter(QObject *obj, QEvent *ev)
|
|
|
|
{
|
2014-10-25 08:52:18 +00:00
|
|
|
return QObject::eventFilter(obj, ev);
|
2014-05-22 18:40:22 +00:00
|
|
|
}
|
|
|
|
void GlobeGPS::prepareForGetDiveCoordinates()
|
|
|
|
{
|
|
|
|
}
|
2015-06-04 14:25:06 +00:00
|
|
|
void GlobeGPS::endGetDiveCoordinates()
|
|
|
|
{
|
|
|
|
}
|
2014-05-22 18:40:22 +00:00
|
|
|
void GlobeGPS::reload()
|
|
|
|
{
|
|
|
|
}
|
2014-03-26 22:08:56 +00:00
|
|
|
#endif
|