mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-01 18:29:16 +01:00
Improvement by pip1996 on opmpap widget, to limit update rate and solve the CPU hogging issue.
This commit is contained in:
parent
dceae1a9b0
commit
fab880a7d2
@ -1,102 +1,116 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file opmapgadgetconfiguration.cpp
|
* @file opmapgadgetconfiguration.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief The OpenPilot Map plugin
|
* @brief The OpenPilot Map plugin
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opmapgadgetconfiguration.h"
|
#include "opmapgadgetconfiguration.h"
|
||||||
#include "utils/pathutils.h"
|
#include "utils/pathutils.h"
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, parent),
|
IUAVGadgetConfiguration(classId, parent),
|
||||||
m_mapProvider("GoogleHybrid"),
|
m_mapProvider("GoogleHybrid"),
|
||||||
m_defaultZoom(2),
|
m_defaultZoom(2),
|
||||||
m_defaultLatitude(0),
|
m_defaultLatitude(0),
|
||||||
m_defaultLongitude(0),
|
m_defaultLongitude(0),
|
||||||
m_useOpenGL(false),
|
m_useOpenGL(false),
|
||||||
m_showTileGridLines(false),
|
m_showTileGridLines(false),
|
||||||
m_accessMode("ServerAndCache"),
|
m_accessMode("ServerAndCache"),
|
||||||
m_useMemoryCache(true),
|
m_useMemoryCache(true),
|
||||||
m_cacheLocation(Utils::PathUtils().GetStoragePath() + "mapscache" + QDir::separator()),
|
m_cacheLocation(Utils::PathUtils().GetStoragePath() + "mapscache" + QDir::separator()),
|
||||||
m_uavSymbol(QString::fromUtf8(":/uavs/images/mapquad.png"))
|
m_uavSymbol(QString::fromUtf8(":/uavs/images/mapquad.png")),
|
||||||
{
|
m_maxUpdateRate(2000) // ms
|
||||||
|
{
|
||||||
//if a saved configuration exists load it
|
|
||||||
if(qSettings != 0) {
|
//if a saved configuration exists load it
|
||||||
QString mapProvider = qSettings->value("mapProvider").toString();
|
if (qSettings != 0) {
|
||||||
int zoom = qSettings->value("defaultZoom").toInt();
|
|
||||||
double latitude= qSettings->value("defaultLatitude").toDouble();
|
QString mapProvider = qSettings->value("mapProvider").toString();
|
||||||
double longitude= qSettings->value("defaultLongitude").toDouble();
|
int zoom = qSettings->value("defaultZoom").toInt();
|
||||||
bool useOpenGL= qSettings->value("useOpenGL").toBool();
|
double latitude= qSettings->value("defaultLatitude").toDouble();
|
||||||
bool showTileGridLines= qSettings->value("showTileGridLines").toBool();
|
double longitude= qSettings->value("defaultLongitude").toDouble();
|
||||||
QString accessMode= qSettings->value("accessMode").toString();
|
bool useOpenGL= qSettings->value("useOpenGL").toBool();
|
||||||
bool useMemoryCache= qSettings->value("useMemoryCache").toBool();
|
bool showTileGridLines= qSettings->value("showTileGridLines").toBool();
|
||||||
QString cacheLocation= qSettings->value("cacheLocation").toString();
|
QString accessMode= qSettings->value("accessMode").toString();
|
||||||
QString uavSymbol=qSettings->value("uavSymbol").toString();
|
bool useMemoryCache= qSettings->value("useMemoryCache").toBool();
|
||||||
if (!mapProvider.isEmpty()) m_mapProvider = mapProvider;
|
QString cacheLocation= qSettings->value("cacheLocation").toString();
|
||||||
m_defaultZoom = zoom;
|
QString uavSymbol=qSettings->value("uavSymbol").toString();
|
||||||
m_defaultLatitude = latitude;
|
int max_update_rate = qSettings->value("maxUpdateRate").toInt();
|
||||||
m_defaultLongitude = longitude;
|
|
||||||
m_useOpenGL = useOpenGL;
|
if (!mapProvider.isEmpty()) m_mapProvider = mapProvider;
|
||||||
m_showTileGridLines = showTileGridLines;
|
m_defaultZoom = zoom;
|
||||||
m_uavSymbol=uavSymbol;
|
m_defaultLatitude = latitude;
|
||||||
if (!accessMode.isEmpty()) m_accessMode = accessMode;
|
m_defaultLongitude = longitude;
|
||||||
m_useMemoryCache = useMemoryCache;
|
m_useOpenGL = useOpenGL;
|
||||||
if (!cacheLocation.isEmpty()) m_cacheLocation = Utils::PathUtils().InsertStoragePath(cacheLocation);
|
m_showTileGridLines = showTileGridLines;
|
||||||
}
|
m_uavSymbol = uavSymbol;
|
||||||
}
|
|
||||||
|
m_maxUpdateRate = max_update_rate;
|
||||||
IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
|
if (m_maxUpdateRate < 100 || m_maxUpdateRate > 5000)
|
||||||
{
|
m_maxUpdateRate = 2000;
|
||||||
OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId());
|
|
||||||
|
if (!accessMode.isEmpty())
|
||||||
m->m_mapProvider = m_mapProvider;
|
m_accessMode = accessMode;
|
||||||
m->m_defaultZoom = m_defaultZoom;
|
m_useMemoryCache = useMemoryCache;
|
||||||
m->m_defaultLatitude = m_defaultLatitude;
|
if (!cacheLocation.isEmpty())
|
||||||
m->m_defaultLongitude = m_defaultLongitude;
|
m_cacheLocation = Utils::PathUtils().InsertStoragePath(cacheLocation);
|
||||||
m->m_useOpenGL = m_useOpenGL;
|
}
|
||||||
m->m_showTileGridLines = m_showTileGridLines;
|
}
|
||||||
m->m_accessMode = m_accessMode;
|
|
||||||
m->m_useMemoryCache = m_useMemoryCache;
|
IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
|
||||||
m->m_cacheLocation = m_cacheLocation;
|
{
|
||||||
m->m_uavSymbol=m_uavSymbol;
|
OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId());
|
||||||
return m;
|
|
||||||
}
|
m->m_mapProvider = m_mapProvider;
|
||||||
|
m->m_defaultZoom = m_defaultZoom;
|
||||||
void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
m->m_defaultLatitude = m_defaultLatitude;
|
||||||
qSettings->setValue("mapProvider", m_mapProvider);
|
m->m_defaultLongitude = m_defaultLongitude;
|
||||||
qSettings->setValue("defaultZoom", m_defaultZoom);
|
m->m_useOpenGL = m_useOpenGL;
|
||||||
qSettings->setValue("defaultLatitude", m_defaultLatitude);
|
m->m_showTileGridLines = m_showTileGridLines;
|
||||||
qSettings->setValue("defaultLongitude", m_defaultLongitude);
|
m->m_accessMode = m_accessMode;
|
||||||
qSettings->setValue("useOpenGL", m_useOpenGL);
|
m->m_useMemoryCache = m_useMemoryCache;
|
||||||
qSettings->setValue("showTileGridLines", m_showTileGridLines);
|
m->m_cacheLocation = m_cacheLocation;
|
||||||
qSettings->setValue("accessMode", m_accessMode);
|
m->m_uavSymbol = m_uavSymbol;
|
||||||
qSettings->setValue("useMemoryCache", m_useMemoryCache);
|
m->m_maxUpdateRate = m_maxUpdateRate;
|
||||||
qSettings->setValue("uavSymbol", m_uavSymbol);
|
|
||||||
qSettings->setValue("cacheLocation", Utils::PathUtils().RemoveStoragePath(m_cacheLocation));
|
return m;
|
||||||
}
|
}
|
||||||
void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation){
|
|
||||||
m_cacheLocation = cacheLocation;
|
void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||||
}
|
qSettings->setValue("mapProvider", m_mapProvider);
|
||||||
|
qSettings->setValue("defaultZoom", m_defaultZoom);
|
||||||
|
qSettings->setValue("defaultLatitude", m_defaultLatitude);
|
||||||
|
qSettings->setValue("defaultLongitude", m_defaultLongitude);
|
||||||
|
qSettings->setValue("useOpenGL", m_useOpenGL);
|
||||||
|
qSettings->setValue("showTileGridLines", m_showTileGridLines);
|
||||||
|
qSettings->setValue("accessMode", m_accessMode);
|
||||||
|
qSettings->setValue("useMemoryCache", m_useMemoryCache);
|
||||||
|
qSettings->setValue("uavSymbol", m_uavSymbol);
|
||||||
|
qSettings->setValue("cacheLocation", Utils::PathUtils().RemoveStoragePath(m_cacheLocation));
|
||||||
|
qSettings->setValue("maxUpdateRate", m_maxUpdateRate);
|
||||||
|
}
|
||||||
|
void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation){
|
||||||
|
m_cacheLocation = cacheLocation;
|
||||||
|
}
|
||||||
|
@ -1,93 +1,97 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file opmapgadgetconfiguration.h
|
* @file opmapgadgetconfiguration.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief The OpenPilot Map plugin
|
* @brief The OpenPilot Map plugin
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OPMAP_GADGETCONFIGURATION_H
|
#ifndef OPMAP_GADGETCONFIGURATION_H
|
||||||
#define OPMAP_GADGETCONFIGURATION_H
|
#define OPMAP_GADGETCONFIGURATION_H
|
||||||
|
|
||||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
class OPMapGadgetConfiguration : public IUAVGadgetConfiguration
|
class OPMapGadgetConfiguration : public IUAVGadgetConfiguration
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString mapProvider READ mapProvider WRITE setMapProvider)
|
Q_PROPERTY(QString mapProvider READ mapProvider WRITE setMapProvider)
|
||||||
Q_PROPERTY(int zoommo READ zoom WRITE setZoom)
|
Q_PROPERTY(int zoommo READ zoom WRITE setZoom)
|
||||||
Q_PROPERTY(double latitude READ latitude WRITE setLatitude)
|
Q_PROPERTY(double latitude READ latitude WRITE setLatitude)
|
||||||
Q_PROPERTY(double longitude READ longitude WRITE setLongitude)
|
Q_PROPERTY(double longitude READ longitude WRITE setLongitude)
|
||||||
Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL)
|
Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL)
|
||||||
Q_PROPERTY(bool showTileGridLines READ showTileGridLines WRITE setShowTileGridLines)
|
Q_PROPERTY(bool showTileGridLines READ showTileGridLines WRITE setShowTileGridLines)
|
||||||
Q_PROPERTY(QString accessMode READ accessMode WRITE setAccessMode)
|
Q_PROPERTY(QString accessMode READ accessMode WRITE setAccessMode)
|
||||||
Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache)
|
Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache)
|
||||||
Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation)
|
Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation)
|
||||||
Q_PROPERTY(QString uavSymbol READ uavSymbol WRITE setUavSymbol)
|
Q_PROPERTY(QString uavSymbol READ uavSymbol WRITE setUavSymbol)
|
||||||
|
Q_PROPERTY(int maxUpdateRate READ maxUpdateRate WRITE setMaxUpdateRate)
|
||||||
public:
|
|
||||||
explicit OPMapGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
public:
|
||||||
|
explicit OPMapGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||||
void saveConfig(QSettings* settings) const;
|
|
||||||
IUAVGadgetConfiguration *clone();
|
void saveConfig(QSettings* settings) const;
|
||||||
|
IUAVGadgetConfiguration *clone();
|
||||||
QString mapProvider() const { return m_mapProvider; }
|
|
||||||
int zoom() const { return m_defaultZoom; }
|
QString mapProvider() const { return m_mapProvider; }
|
||||||
double latitude() const { return m_defaultLatitude; }
|
int zoom() const { return m_defaultZoom; }
|
||||||
double longitude() const { return m_defaultLongitude; }
|
double latitude() const { return m_defaultLatitude; }
|
||||||
bool useOpenGL() const { return m_useOpenGL; }
|
double longitude() const { return m_defaultLongitude; }
|
||||||
bool showTileGridLines() const { return m_showTileGridLines; }
|
bool useOpenGL() const { return m_useOpenGL; }
|
||||||
QString accessMode() const { return m_accessMode; }
|
bool showTileGridLines() const { return m_showTileGridLines; }
|
||||||
bool useMemoryCache() const { return m_useMemoryCache; }
|
QString accessMode() const { return m_accessMode; }
|
||||||
QString cacheLocation() const { return m_cacheLocation; }
|
bool useMemoryCache() const { return m_useMemoryCache; }
|
||||||
QString uavSymbol() const { return m_uavSymbol; }
|
QString cacheLocation() const { return m_cacheLocation; }
|
||||||
|
QString uavSymbol() const { return m_uavSymbol; }
|
||||||
public slots:
|
int maxUpdateRate() const { return m_maxUpdateRate; }
|
||||||
void setMapProvider(QString provider) { m_mapProvider = provider; }
|
|
||||||
void setZoom(int zoom) { m_defaultZoom = zoom; }
|
public slots:
|
||||||
void setLatitude(double latitude) { m_defaultLatitude = latitude; }
|
void setMapProvider(QString provider) { m_mapProvider = provider; }
|
||||||
void setLongitude(double longitude) { m_defaultLongitude = longitude; }
|
void setZoom(int zoom) { m_defaultZoom = zoom; }
|
||||||
void setUseOpenGL(bool useOpenGL) { m_useOpenGL = useOpenGL; }
|
void setLatitude(double latitude) { m_defaultLatitude = latitude; }
|
||||||
void setShowTileGridLines(bool showTileGridLines) { m_showTileGridLines = showTileGridLines; }
|
void setLongitude(double longitude) { m_defaultLongitude = longitude; }
|
||||||
void setAccessMode(QString accessMode) { m_accessMode = accessMode; }
|
void setUseOpenGL(bool useOpenGL) { m_useOpenGL = useOpenGL; }
|
||||||
void setUseMemoryCache(bool useMemoryCache) { m_useMemoryCache = useMemoryCache; }
|
void setShowTileGridLines(bool showTileGridLines) { m_showTileGridLines = showTileGridLines; }
|
||||||
void setCacheLocation(QString cacheLocation);
|
void setAccessMode(QString accessMode) { m_accessMode = accessMode; }
|
||||||
void setUavSymbol(QString symbol){m_uavSymbol=symbol;}
|
void setUseMemoryCache(bool useMemoryCache) { m_useMemoryCache = useMemoryCache; }
|
||||||
private:
|
void setCacheLocation(QString cacheLocation);
|
||||||
QString m_mapProvider;
|
void setUavSymbol(QString symbol){m_uavSymbol=symbol;}
|
||||||
int m_defaultZoom;
|
void setMaxUpdateRate(int update_rate){m_maxUpdateRate = update_rate;}
|
||||||
double m_defaultLatitude;
|
|
||||||
double m_defaultLongitude;
|
private:
|
||||||
bool m_useOpenGL;
|
QString m_mapProvider;
|
||||||
bool m_showTileGridLines;
|
int m_defaultZoom;
|
||||||
QString m_accessMode;
|
double m_defaultLatitude;
|
||||||
bool m_useMemoryCache;
|
double m_defaultLongitude;
|
||||||
QString m_cacheLocation;
|
bool m_useOpenGL;
|
||||||
QString m_uavSymbol;
|
bool m_showTileGridLines;
|
||||||
|
QString m_accessMode;
|
||||||
};
|
bool m_useMemoryCache;
|
||||||
|
QString m_cacheLocation;
|
||||||
#endif // OPMAP_GADGETCONFIGURATION_H
|
QString m_uavSymbol;
|
||||||
|
int m_maxUpdateRate;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OPMAP_GADGETCONFIGURATION_H
|
||||||
|
@ -1,133 +1,149 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file opmapgadgetoptionspage.cpp
|
* @file opmapgadgetoptionspage.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief The OpenPilot Map plugin
|
* @brief The OpenPilot Map plugin
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opmapgadgetoptionspage.h"
|
#include "opmapgadgetoptionspage.h"
|
||||||
#include "opmapgadgetconfiguration.h"
|
#include "opmapgadgetconfiguration.h"
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
#include <QtGui/QComboBox>
|
#include <QtGui/QComboBox>
|
||||||
#include <QtGui/QSpinBox>
|
#include <QtGui/QSpinBox>
|
||||||
#include <QtGui/QDoubleSpinBox>
|
#include <QtGui/QDoubleSpinBox>
|
||||||
#include <QtGui/QHBoxLayout>
|
#include <QtGui/QHBoxLayout>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QtGui/QVBoxLayout>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
#include "opmapcontrol/opmapcontrol.h"
|
#include "opmapcontrol/opmapcontrol.h"
|
||||||
#include "utils/pathutils.h"
|
#include "utils/pathutils.h"
|
||||||
#include "ui_opmapgadgetoptionspage.h"
|
#include "ui_opmapgadgetoptionspage.h"
|
||||||
|
|
||||||
// *********************************************
|
// *********************************************
|
||||||
|
|
||||||
OPMapGadgetOptionsPage::OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent) :
|
OPMapGadgetOptionsPage::OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent) :
|
||||||
IOptionsPage(parent),
|
IOptionsPage(parent),
|
||||||
m_config(config)
|
m_config(config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
|
QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
m_page = new Ui::OPMapGadgetOptionsPage();
|
int index;
|
||||||
QWidget *w = new QWidget(parent);
|
|
||||||
m_page->setupUi(w);
|
m_page = new Ui::OPMapGadgetOptionsPage();
|
||||||
|
QWidget *w = new QWidget(parent);
|
||||||
// populate the map provider combobox
|
m_page->setupUi(w);
|
||||||
m_page->providerComboBox->clear();
|
|
||||||
m_page->providerComboBox->addItems(mapcontrol::Helper::MapTypes());
|
// populate the map provider combobox
|
||||||
|
m_page->providerComboBox->clear();
|
||||||
// populate the access mode combobox
|
m_page->providerComboBox->addItems(mapcontrol::Helper::MapTypes());
|
||||||
m_page->accessModeComboBox->clear();
|
|
||||||
m_page->accessModeComboBox->addItems(mapcontrol::Helper::AccessModeTypes());
|
// populate the access mode combobox
|
||||||
|
m_page->accessModeComboBox->clear();
|
||||||
int index = m_page->providerComboBox->findText(m_config->mapProvider());
|
m_page->accessModeComboBox->addItems(mapcontrol::Helper::AccessModeTypes());
|
||||||
index = (index >= 0) ? index : 0;
|
|
||||||
m_page->providerComboBox->setCurrentIndex(index);
|
index = m_page->providerComboBox->findText(m_config->mapProvider());
|
||||||
|
index = (index >= 0) ? index : 0;
|
||||||
m_page->zoomSpinBox->setValue(m_config->zoom());
|
m_page->providerComboBox->setCurrentIndex(index);
|
||||||
m_page->latitudeSpinBox->setValue(m_config->latitude());
|
|
||||||
m_page->longitudeSpinBox->setValue(m_config->longitude());
|
// populate the map max update rate combobox
|
||||||
|
m_page->maxUpdateRateComboBox->clear();
|
||||||
m_page->checkBoxUseOpenGL->setChecked(m_config->useOpenGL());
|
m_page->maxUpdateRateComboBox->addItem("100ms", 100);
|
||||||
m_page->checkBoxShowTileGridLines->setChecked(m_config->showTileGridLines());
|
m_page->maxUpdateRateComboBox->addItem("200ms", 200);
|
||||||
|
m_page->maxUpdateRateComboBox->addItem("500ms", 500);
|
||||||
index = m_page->accessModeComboBox->findText(m_config->accessMode());
|
m_page->maxUpdateRateComboBox->addItem("1 sec", 1000);
|
||||||
index = (index >= 0) ? index : 0;
|
m_page->maxUpdateRateComboBox->addItem("2 sec", 2000);
|
||||||
m_page->accessModeComboBox->setCurrentIndex(index);
|
m_page->maxUpdateRateComboBox->addItem("5 sec", 5000);
|
||||||
|
|
||||||
m_page->checkBoxUseMemoryCache->setChecked(m_config->useMemoryCache());
|
index = m_page->maxUpdateRateComboBox->findData(m_config->maxUpdateRate());
|
||||||
|
index = (index >= 0) ? index : 4;
|
||||||
m_page->lineEditCacheLocation->setExpectedKind(Utils::PathChooser::Directory);
|
m_page->maxUpdateRateComboBox->setCurrentIndex(index);
|
||||||
m_page->lineEditCacheLocation->setPromptDialogTitle(tr("Choose Cache Directory"));
|
|
||||||
m_page->lineEditCacheLocation->setPath(m_config->cacheLocation());
|
m_page->zoomSpinBox->setValue(m_config->zoom());
|
||||||
|
m_page->latitudeSpinBox->setValue(m_config->latitude());
|
||||||
QDir dir(":/uavs/images/");
|
m_page->longitudeSpinBox->setValue(m_config->longitude());
|
||||||
QStringList list=dir.entryList();
|
|
||||||
foreach(QString i,list)
|
m_page->checkBoxUseOpenGL->setChecked(m_config->useOpenGL());
|
||||||
{
|
m_page->checkBoxShowTileGridLines->setChecked(m_config->showTileGridLines());
|
||||||
QIcon icon(QPixmap(":/uavs/images/"+i));
|
|
||||||
m_page->uavSymbolComboBox->addItem(icon,QString(),i);
|
index = m_page->accessModeComboBox->findText(m_config->accessMode());
|
||||||
}
|
index = (index >= 0) ? index : 0;
|
||||||
for(int x=0;x<m_page->uavSymbolComboBox->count();++x)
|
m_page->accessModeComboBox->setCurrentIndex(index);
|
||||||
{
|
|
||||||
if(m_page->uavSymbolComboBox->itemData(x).toString()==m_config->uavSymbol())
|
m_page->checkBoxUseMemoryCache->setChecked(m_config->useMemoryCache());
|
||||||
{
|
|
||||||
m_page->uavSymbolComboBox->setCurrentIndex(x);
|
m_page->lineEditCacheLocation->setExpectedKind(Utils::PathChooser::Directory);
|
||||||
}
|
m_page->lineEditCacheLocation->setPromptDialogTitle(tr("Choose Cache Directory"));
|
||||||
}
|
m_page->lineEditCacheLocation->setPath(m_config->cacheLocation());
|
||||||
|
|
||||||
connect(m_page->pushButtonCacheDefaults, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheDefaults_clicked()));
|
QDir dir(":/uavs/images/");
|
||||||
|
QStringList list=dir.entryList();
|
||||||
return w;
|
foreach(QString i,list)
|
||||||
}
|
{
|
||||||
|
QIcon icon(QPixmap(":/uavs/images/"+i));
|
||||||
void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked()
|
m_page->uavSymbolComboBox->addItem(icon,QString(),i);
|
||||||
{
|
}
|
||||||
int index = m_page->accessModeComboBox->findText("ServerAndCache");
|
for(int x=0;x<m_page->uavSymbolComboBox->count();++x)
|
||||||
index = (index >= 0) ? index : 0;
|
{
|
||||||
m_page->accessModeComboBox->setCurrentIndex(index);
|
if(m_page->uavSymbolComboBox->itemData(x).toString()==m_config->uavSymbol())
|
||||||
|
{
|
||||||
m_page->checkBoxUseMemoryCache->setChecked(true);
|
m_page->uavSymbolComboBox->setCurrentIndex(x);
|
||||||
m_page->lineEditCacheLocation->setPath(Utils::PathUtils().GetStoragePath() + "mapscache" + QDir::separator());
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
connect(m_page->pushButtonCacheDefaults, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheDefaults_clicked()));
|
||||||
void OPMapGadgetOptionsPage::apply()
|
|
||||||
{
|
return w;
|
||||||
m_config->setMapProvider(m_page->providerComboBox->currentText());
|
}
|
||||||
m_config->setZoom(m_page->zoomSpinBox->value());
|
|
||||||
m_config->setLatitude(m_page->latitudeSpinBox->value());
|
void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked()
|
||||||
m_config->setLongitude(m_page->longitudeSpinBox->value());
|
{
|
||||||
m_config->setUseOpenGL(m_page->checkBoxUseOpenGL->isChecked());
|
int index = m_page->accessModeComboBox->findText("ServerAndCache");
|
||||||
m_config->setShowTileGridLines(m_page->checkBoxShowTileGridLines->isChecked());
|
index = (index >= 0) ? index : 0;
|
||||||
m_config->setAccessMode(m_page->accessModeComboBox->currentText());
|
m_page->accessModeComboBox->setCurrentIndex(index);
|
||||||
m_config->setUseMemoryCache(m_page->checkBoxUseMemoryCache->isChecked());
|
|
||||||
m_config->setCacheLocation(m_page->lineEditCacheLocation->path());
|
m_page->checkBoxUseMemoryCache->setChecked(true);
|
||||||
m_config->setUavSymbol(m_page->uavSymbolComboBox->itemData(m_page->uavSymbolComboBox->currentIndex()).toString());
|
m_page->lineEditCacheLocation->setPath(Utils::PathUtils().GetStoragePath() + "mapscache" + QDir::separator());
|
||||||
}
|
|
||||||
|
}
|
||||||
void OPMapGadgetOptionsPage::finish()
|
|
||||||
{
|
void OPMapGadgetOptionsPage::apply()
|
||||||
delete m_page;
|
{
|
||||||
}
|
m_config->setMapProvider(m_page->providerComboBox->currentText());
|
||||||
|
m_config->setZoom(m_page->zoomSpinBox->value());
|
||||||
|
m_config->setLatitude(m_page->latitudeSpinBox->value());
|
||||||
|
m_config->setLongitude(m_page->longitudeSpinBox->value());
|
||||||
|
m_config->setUseOpenGL(m_page->checkBoxUseOpenGL->isChecked());
|
||||||
|
m_config->setShowTileGridLines(m_page->checkBoxShowTileGridLines->isChecked());
|
||||||
|
m_config->setAccessMode(m_page->accessModeComboBox->currentText());
|
||||||
|
m_config->setUseMemoryCache(m_page->checkBoxUseMemoryCache->isChecked());
|
||||||
|
m_config->setCacheLocation(m_page->lineEditCacheLocation->path());
|
||||||
|
m_config->setUavSymbol(m_page->uavSymbolComboBox->itemData(m_page->uavSymbolComboBox->currentIndex()).toString());
|
||||||
|
m_config->setMaxUpdateRate(m_page->maxUpdateRateComboBox->itemData(m_page->maxUpdateRateComboBox->currentIndex()).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OPMapGadgetOptionsPage::finish()
|
||||||
|
{
|
||||||
|
delete m_page;
|
||||||
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0" rowminimumheight="22,22,22,0,22">
|
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0" rowminimumheight="22,22,22,0,22,0">
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<spacer name="horizontalSpacer_4">
|
<spacer name="horizontalSpacer_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -249,6 +249,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="3">
|
||||||
|
<widget class="QComboBox" name="maxUpdateRateComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="2">
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>Default Max Update Rate </string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="8" column="0">
|
||||||
|
@ -1,2371 +1,2451 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file opmapgadgetwidget.cpp
|
* @file opmapgadgetwidget.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief The OpenPilot Map plugin
|
* @brief The OpenPilot Map plugin
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opmapgadgetwidget.h"
|
#include "opmapgadgetwidget.h"
|
||||||
#include "ui_opmap_widget.h"
|
#include "ui_opmap_widget.h"
|
||||||
|
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
#include <QtGui/QHBoxLayout>
|
#include <QtGui/QHBoxLayout>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QtGui/QVBoxLayout>
|
||||||
#include <QtGui/QClipboard>
|
#include <QtGui/QClipboard>
|
||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "utils/stylehelper.h"
|
#include "utils/stylehelper.h"
|
||||||
#include "utils/homelocationutil.h"
|
#include "utils/homelocationutil.h"
|
||||||
#include "utils/worldmagmodel.h"
|
#include "utils/worldmagmodel.h"
|
||||||
|
|
||||||
#include "uavtalk/telemetrymanager.h"
|
#include "uavtalk/telemetrymanager.h"
|
||||||
|
|
||||||
#include "positionactual.h"
|
#include "positionactual.h"
|
||||||
#include "homelocation.h"
|
#include "homelocation.h"
|
||||||
|
|
||||||
#define allow_manual_home_location_move
|
#define allow_manual_home_location_move
|
||||||
|
|
||||||
// *************************************************************************************
|
// *************************************************************************************
|
||||||
|
|
||||||
#define deg_to_rad ((double)M_PI / 180.0)
|
#define deg_to_rad ((double)M_PI / 180.0)
|
||||||
#define rad_to_deg (180.0 / (double)M_PI)
|
#define rad_to_deg (180.0 / (double)M_PI)
|
||||||
|
|
||||||
#define earth_mean_radius 6371 // kilometers
|
#define earth_mean_radius 6371 // kilometers
|
||||||
|
|
||||||
#define max_digital_zoom 3 // maximum allowed digital zoom level
|
#define max_digital_zoom 3 // maximum allowed digital zoom level
|
||||||
|
|
||||||
const int safe_area_radius_list[] = {5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000}; // meters
|
const int safe_area_radius_list[] = {5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000}; // meters
|
||||||
|
|
||||||
const int uav_trail_time_list[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // seconds
|
const int uav_trail_time_list[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // seconds
|
||||||
|
|
||||||
const int uav_trail_distance_list[] = {1, 2, 5, 10, 20, 50, 100, 200, 500}; // meters
|
const int uav_trail_distance_list[] = {1, 2, 5, 10, 20, 50, 100, 200, 500}; // meters
|
||||||
|
|
||||||
// *************************************************************************************
|
const int max_update_rate_list[] = {100, 200, 500, 1000, 2000, 5000}; // milliseconds
|
||||||
|
|
||||||
|
// *************************************************************************************
|
||||||
// *************************************************************************************
|
|
||||||
// NOTE: go back to SVN REV 2137 and earlier to get back to experimental waypoint support.
|
|
||||||
// *************************************************************************************
|
// *************************************************************************************
|
||||||
|
// NOTE: go back to SVN REV 2137 and earlier to get back to experimental waypoint support.
|
||||||
|
// *************************************************************************************
|
||||||
// constructor
|
|
||||||
OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
|
||||||
{
|
// constructor
|
||||||
// **************
|
OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
m_widget = NULL;
|
// **************
|
||||||
m_map = NULL;
|
|
||||||
findPlaceCompleter = NULL;
|
m_widget = NULL;
|
||||||
|
m_map = NULL;
|
||||||
m_mouse_waypoint = NULL;
|
findPlaceCompleter = NULL;
|
||||||
|
|
||||||
pm = NULL;
|
m_mouse_waypoint = NULL;
|
||||||
obm = NULL;
|
|
||||||
obum = NULL;
|
pm = NULL;
|
||||||
|
obm = NULL;
|
||||||
prev_tile_number = 0;
|
obum = NULL;
|
||||||
|
|
||||||
min_zoom = max_zoom = 0;
|
m_prev_tile_number = 0;
|
||||||
|
|
||||||
m_map_mode = Normal_MapMode;
|
m_min_zoom = m_max_zoom = 0;
|
||||||
|
|
||||||
telemetry_connected = false;
|
m_map_mode = Normal_MapMode;
|
||||||
|
|
||||||
context_menu_lat_lon = mouse_lat_lon = internals::PointLatLng(0, 0);
|
m_maxUpdateRate = max_update_rate_list[4]; // 2 seconds
|
||||||
|
|
||||||
setMouseTracking(true);
|
m_telemetry_connected = false;
|
||||||
|
|
||||||
pm = ExtensionSystem::PluginManager::instance();
|
m_context_menu_lat_lon = m_mouse_lat_lon = internals::PointLatLng(0, 0);
|
||||||
if (pm)
|
|
||||||
{
|
setMouseTracking(true);
|
||||||
obm = pm->getObject<UAVObjectManager>();
|
|
||||||
obum = pm->getObject<UAVObjectUtilManager>();
|
pm = ExtensionSystem::PluginManager::instance();
|
||||||
}
|
if (pm)
|
||||||
|
{
|
||||||
// **************
|
obm = pm->getObject<UAVObjectManager>();
|
||||||
// get current location
|
obum = pm->getObject<UAVObjectUtilManager>();
|
||||||
|
}
|
||||||
double latitude = 0;
|
|
||||||
double longitude = 0;
|
// **************
|
||||||
double altitude = 0;
|
// get current location
|
||||||
|
|
||||||
// current position
|
double latitude = 0;
|
||||||
getUAVPosition(latitude, longitude, altitude);
|
double longitude = 0;
|
||||||
|
double altitude = 0;
|
||||||
internals::PointLatLng pos_lat_lon = internals::PointLatLng(latitude, longitude);
|
|
||||||
|
// current position
|
||||||
// **************
|
getUAVPosition(latitude, longitude, altitude);
|
||||||
// default home position
|
|
||||||
|
internals::PointLatLng pos_lat_lon = internals::PointLatLng(latitude, longitude);
|
||||||
home_position.coord = pos_lat_lon;
|
|
||||||
home_position.altitude = altitude;
|
// **************
|
||||||
home_position.locked = false;
|
// default home position
|
||||||
|
|
||||||
// **************
|
m_home_position.coord = pos_lat_lon;
|
||||||
// default magic waypoint params
|
m_home_position.altitude = altitude;
|
||||||
|
m_home_position.locked = false;
|
||||||
magic_waypoint.map_wp_item = NULL;
|
|
||||||
magic_waypoint.coord = home_position.coord;
|
// **************
|
||||||
magic_waypoint.altitude = altitude;
|
// default magic waypoint params
|
||||||
magic_waypoint.description = "Magic waypoint";
|
|
||||||
magic_waypoint.locked = false;
|
m_magic_waypoint.map_wp_item = NULL;
|
||||||
magic_waypoint.time_seconds = 0;
|
m_magic_waypoint.coord = m_home_position.coord;
|
||||||
magic_waypoint.hold_time_seconds = 0;
|
m_magic_waypoint.altitude = altitude;
|
||||||
|
m_magic_waypoint.description = "Magic waypoint";
|
||||||
// **************
|
m_magic_waypoint.locked = false;
|
||||||
// create the widget that holds the user controls and the map
|
m_magic_waypoint.time_seconds = 0;
|
||||||
|
m_magic_waypoint.hold_time_seconds = 0;
|
||||||
m_widget = new Ui::OPMap_Widget();
|
|
||||||
m_widget->setupUi(this);
|
// **************
|
||||||
|
// create the widget that holds the user controls and the map
|
||||||
// **************
|
|
||||||
// create the central map widget
|
m_widget = new Ui::OPMap_Widget();
|
||||||
|
m_widget->setupUi(this);
|
||||||
m_map = new mapcontrol::OPMapWidget(); // create the map object
|
|
||||||
|
// **************
|
||||||
m_map->setFrameStyle(QFrame::NoFrame); // no border frame
|
// create the central map widget
|
||||||
m_map->setBackgroundBrush(QBrush(Utils::StyleHelper::baseColor())); // tile background
|
|
||||||
|
m_map = new mapcontrol::OPMapWidget(); // create the map object
|
||||||
m_map->configuration->DragButton = Qt::LeftButton; // use the left mouse button for map dragging
|
|
||||||
|
m_map->setFrameStyle(QFrame::NoFrame); // no border frame
|
||||||
m_widget->horizontalSliderZoom->setMinimum(m_map->MinZoom()); //
|
m_map->setBackgroundBrush(QBrush(Utils::StyleHelper::baseColor())); // tile background
|
||||||
m_widget->horizontalSliderZoom->setMaximum(m_map->MaxZoom() + max_digital_zoom); //
|
|
||||||
|
m_map->configuration->DragButton = Qt::LeftButton; // use the left mouse button for map dragging
|
||||||
min_zoom = m_widget->horizontalSliderZoom->minimum(); // minimum zoom we can accept
|
|
||||||
max_zoom = m_widget->horizontalSliderZoom->maximum(); // maximum zoom we can accept
|
m_widget->horizontalSliderZoom->setMinimum(m_map->MinZoom()); //
|
||||||
|
m_widget->horizontalSliderZoom->setMaximum(m_map->MaxZoom() + max_digital_zoom); //
|
||||||
m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::MousePositionWithoutCenter); // set how the mouse wheel zoom functions
|
|
||||||
m_map->SetFollowMouse(true); // we want a contiuous mouse position reading
|
m_min_zoom = m_widget->horizontalSliderZoom->minimum(); // minimum zoom we can accept
|
||||||
|
m_max_zoom = m_widget->horizontalSliderZoom->maximum(); // maximum zoom we can accept
|
||||||
m_map->SetShowHome(true); // display the HOME position on the map
|
|
||||||
m_map->SetShowUAV(true); // display the UAV position on the map
|
m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::MousePositionWithoutCenter); // set how the mouse wheel zoom functions
|
||||||
|
m_map->SetFollowMouse(true); // we want a contiuous mouse position reading
|
||||||
m_map->Home->SetSafeArea(safe_area_radius_list[0]); // set radius (meters)
|
|
||||||
m_map->Home->SetShowSafeArea(true); // show the safe area
|
m_map->SetShowHome(true); // display the HOME position on the map
|
||||||
|
m_map->SetShowUAV(true); // display the UAV position on the map
|
||||||
m_map->UAV->SetTrailTime(uav_trail_time_list[0]); // seconds
|
|
||||||
m_map->UAV->SetTrailDistance(uav_trail_distance_list[1]); // meters
|
m_map->Home->SetSafeArea(safe_area_radius_list[0]); // set radius (meters)
|
||||||
|
m_map->Home->SetShowSafeArea(true); // show the safe area
|
||||||
m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed);
|
|
||||||
// m_map->UAV->SetTrailType(UAVTrailType::ByDistance);
|
m_map->UAV->SetTrailTime(uav_trail_time_list[0]); // seconds
|
||||||
|
m_map->UAV->SetTrailDistance(uav_trail_distance_list[1]); // meters
|
||||||
m_map->GPS->SetTrailTime(uav_trail_time_list[0]); // seconds
|
|
||||||
m_map->GPS->SetTrailDistance(uav_trail_distance_list[1]); // meters
|
m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed);
|
||||||
|
// m_map->UAV->SetTrailType(UAVTrailType::ByDistance);
|
||||||
m_map->GPS->SetTrailType(UAVTrailType::ByTimeElapsed);
|
|
||||||
// m_map->GPS->SetTrailType(UAVTrailType::ByDistance);
|
m_map->GPS->SetTrailTime(uav_trail_time_list[0]); // seconds
|
||||||
|
m_map->GPS->SetTrailDistance(uav_trail_distance_list[1]); // meters
|
||||||
// **************
|
|
||||||
|
m_map->GPS->SetTrailType(UAVTrailType::ByTimeElapsed);
|
||||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
// m_map->GPS->SetTrailType(UAVTrailType::ByDistance);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
// **************
|
||||||
layout->setSpacing(0);
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
layout->addWidget(m_map);
|
|
||||||
m_widget->mapWidget->setLayout(layout);
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
layout->setSpacing(0);
|
||||||
// **************
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
// set the user control options
|
layout->addWidget(m_map);
|
||||||
|
m_widget->mapWidget->setLayout(layout);
|
||||||
// TODO: this switch does not make sense, does it??
|
|
||||||
|
// **************
|
||||||
switch (m_map_mode)
|
// set the user control options
|
||||||
{
|
|
||||||
case Normal_MapMode:
|
// TODO: this switch does not make sense, does it??
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(true);
|
switch (m_map_mode)
|
||||||
hideMagicWaypointControls();
|
{
|
||||||
break;
|
case Normal_MapMode:
|
||||||
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
||||||
case MagicWaypoint_MapMode:
|
m_widget->toolButtonNormalMapMode->setChecked(true);
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(false);
|
hideMagicWaypointControls();
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
break;
|
||||||
showMagicWaypointControls();
|
|
||||||
break;
|
case MagicWaypoint_MapMode:
|
||||||
|
m_widget->toolButtonNormalMapMode->setChecked(false);
|
||||||
default:
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
||||||
m_map_mode = Normal_MapMode;
|
showMagicWaypointControls();
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
break;
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(true);
|
|
||||||
hideMagicWaypointControls();
|
default:
|
||||||
break;
|
m_map_mode = Normal_MapMode;
|
||||||
}
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
||||||
|
m_widget->toolButtonNormalMapMode->setChecked(true);
|
||||||
m_widget->labelUAVPos->setText("---");
|
hideMagicWaypointControls();
|
||||||
m_widget->labelMapPos->setText("---");
|
break;
|
||||||
m_widget->labelMousePos->setText("---");
|
}
|
||||||
m_widget->labelMapZoom->setText("---");
|
|
||||||
|
m_widget->labelUAVPos->setText("---");
|
||||||
|
m_widget->labelMapPos->setText("---");
|
||||||
// Splitter is not used at the moment:
|
m_widget->labelMousePos->setText("---");
|
||||||
// m_widget->splitter->setCollapsible(1, false);
|
m_widget->labelMapZoom->setText("---");
|
||||||
|
|
||||||
// set the size of the collapsable widgets
|
|
||||||
//QList<int> m_SizeList;
|
// Splitter is not used at the moment:
|
||||||
//m_SizeList << 0 << 0 << 0;
|
// m_widget->splitter->setCollapsible(1, false);
|
||||||
//m_widget->splitter->setSizes(m_SizeList);
|
|
||||||
|
// set the size of the collapsable widgets
|
||||||
m_widget->progressBarMap->setMaximum(1);
|
//QList<int> m_SizeList;
|
||||||
|
//m_SizeList << 0 << 0 << 0;
|
||||||
/*
|
//m_widget->splitter->setSizes(m_SizeList);
|
||||||
#if defined(Q_OS_MAC)
|
|
||||||
#elif defined(Q_OS_WIN)
|
m_widget->progressBarMap->setMaximum(1);
|
||||||
m_widget->comboBoxFindPlace->clear();
|
|
||||||
loadComboBoxLines(m_widget->comboBoxFindPlace, QCoreApplication::applicationDirPath() + "/opmap_find_place_history.txt");
|
/*
|
||||||
m_widget->comboBoxFindPlace->setCurrentIndex(-1);
|
#if defined(Q_OS_MAC)
|
||||||
#else
|
#elif defined(Q_OS_WIN)
|
||||||
#endif
|
m_widget->comboBoxFindPlace->clear();
|
||||||
*/
|
loadComboBoxLines(m_widget->comboBoxFindPlace, QCoreApplication::applicationDirPath() + "/opmap_find_place_history.txt");
|
||||||
|
m_widget->comboBoxFindPlace->setCurrentIndex(-1);
|
||||||
|
#else
|
||||||
// **************
|
#endif
|
||||||
// map stuff
|
*/
|
||||||
|
|
||||||
connect(m_map, SIGNAL(zoomChanged(double, double, double)), this, SLOT(zoomChanged(double, double, double))); // map zoom change signals
|
|
||||||
connect(m_map, SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)), this, SLOT(OnCurrentPositionChanged(internals::PointLatLng))); // map poisition change signals
|
// **************
|
||||||
connect(m_map, SIGNAL(OnTileLoadComplete()), this, SLOT(OnTileLoadComplete())); // tile loading stop signals
|
// map stuff
|
||||||
connect(m_map, SIGNAL(OnTileLoadStart()), this, SLOT(OnTileLoadStart())); // tile loading start signals
|
|
||||||
connect(m_map, SIGNAL(OnMapDrag()), this, SLOT(OnMapDrag())); // map drag signals
|
connect(m_map, SIGNAL(zoomChanged(double, double, double)), this, SLOT(zoomChanged(double, double, double))); // map zoom change signals
|
||||||
connect(m_map, SIGNAL(OnMapZoomChanged()), this, SLOT(OnMapZoomChanged())); // map zoom changed
|
connect(m_map, SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)), this, SLOT(OnCurrentPositionChanged(internals::PointLatLng))); // map poisition change signals
|
||||||
connect(m_map, SIGNAL(OnMapTypeChanged(MapType::Types)), this, SLOT(OnMapTypeChanged(MapType::Types))); // map type changed
|
connect(m_map, SIGNAL(OnTileLoadComplete()), this, SLOT(OnTileLoadComplete())); // tile loading stop signals
|
||||||
connect(m_map, SIGNAL(OnEmptyTileError(int, core::Point)), this, SLOT(OnEmptyTileError(int, core::Point))); // tile error
|
connect(m_map, SIGNAL(OnTileLoadStart()), this, SLOT(OnTileLoadStart())); // tile loading start signals
|
||||||
connect(m_map, SIGNAL(OnTilesStillToLoad(int)), this, SLOT(OnTilesStillToLoad(int))); // tile loading signals
|
connect(m_map, SIGNAL(OnMapDrag()), this, SLOT(OnMapDrag())); // map drag signals
|
||||||
connect(m_map, SIGNAL(WPNumberChanged(int const&,int const&,WayPointItem*)), this, SLOT(WPNumberChanged(int const&,int const&,WayPointItem*)));
|
connect(m_map, SIGNAL(OnMapZoomChanged()), this, SLOT(OnMapZoomChanged())); // map zoom changed
|
||||||
connect(m_map, SIGNAL(WPValuesChanged(WayPointItem*)), this, SLOT(WPValuesChanged(WayPointItem*)));
|
connect(m_map, SIGNAL(OnMapTypeChanged(MapType::Types)), this, SLOT(OnMapTypeChanged(MapType::Types))); // map type changed
|
||||||
connect(m_map, SIGNAL(WPInserted(int const&, WayPointItem*)), this, SLOT(WPInserted(int const&, WayPointItem*)));
|
connect(m_map, SIGNAL(OnEmptyTileError(int, core::Point)), this, SLOT(OnEmptyTileError(int, core::Point))); // tile error
|
||||||
connect(m_map, SIGNAL(WPDeleted(int const&)), this, SLOT(WPDeleted(int const&)));
|
connect(m_map, SIGNAL(OnTilesStillToLoad(int)), this, SLOT(OnTilesStillToLoad(int))); // tile loading signals
|
||||||
|
connect(m_map, SIGNAL(WPNumberChanged(int const&,int const&,WayPointItem*)), this, SLOT(WPNumberChanged(int const&,int const&,WayPointItem*)));
|
||||||
m_map->SetCurrentPosition(home_position.coord); // set the map position
|
connect(m_map, SIGNAL(WPValuesChanged(WayPointItem*)), this, SLOT(WPValuesChanged(WayPointItem*)));
|
||||||
m_map->Home->SetCoord(home_position.coord); // set the HOME position
|
connect(m_map, SIGNAL(WPInserted(int const&, WayPointItem*)), this, SLOT(WPInserted(int const&, WayPointItem*)));
|
||||||
m_map->UAV->SetUAVPos(home_position.coord, 0.0); // set the UAV position
|
connect(m_map, SIGNAL(WPDeleted(int const&)), this, SLOT(WPDeleted(int const&)));
|
||||||
m_map->GPS->SetUAVPos(home_position.coord, 0.0); // set the UAV position
|
|
||||||
|
m_map->SetCurrentPosition(m_home_position.coord); // set the map position
|
||||||
// **************
|
m_map->Home->SetCoord(m_home_position.coord); // set the HOME position
|
||||||
// create various context menu (mouse right click menu) actions
|
m_map->UAV->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
||||||
|
m_map->GPS->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
||||||
createActions();
|
|
||||||
|
// **************
|
||||||
// **************
|
// create various context menu (mouse right click menu) actions
|
||||||
// connect to the UAVObject updates we require to become a bit aware of our environment:
|
|
||||||
|
createActions();
|
||||||
if (pm)
|
|
||||||
{
|
// **************
|
||||||
// Register for Home Location state changes
|
// connect to the UAVObject updates we require to become a bit aware of our environment:
|
||||||
if (obm)
|
|
||||||
{
|
if (pm)
|
||||||
UAVDataObject *obj = dynamic_cast<UAVDataObject *>(obm->getObject(QString("HomeLocation")));
|
{
|
||||||
if (obj)
|
// Register for Home Location state changes
|
||||||
{
|
if (obm)
|
||||||
connect(obj, SIGNAL(objectUpdated(UAVObject *)), this , SLOT(homePositionUpdated(UAVObject *)));
|
{
|
||||||
}
|
UAVDataObject *obj = dynamic_cast<UAVDataObject *>(obm->getObject(QString("HomeLocation")));
|
||||||
}
|
if (obj)
|
||||||
|
{
|
||||||
// Listen to telemetry connection events
|
connect(obj, SIGNAL(objectUpdated(UAVObject *)), this , SLOT(homePositionUpdated(UAVObject *)));
|
||||||
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
}
|
||||||
if (telMngr)
|
}
|
||||||
{
|
|
||||||
connect(telMngr, SIGNAL(connected()), this, SLOT(onTelemetryConnect()));
|
// Listen to telemetry connection events
|
||||||
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onTelemetryDisconnect()));
|
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
||||||
}
|
if (telMngr)
|
||||||
}
|
{
|
||||||
|
connect(telMngr, SIGNAL(connected()), this, SLOT(onTelemetryConnect()));
|
||||||
// **************
|
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onTelemetryDisconnect()));
|
||||||
// create the desired timers
|
}
|
||||||
|
}
|
||||||
m_updateTimer = new QTimer();
|
|
||||||
m_updateTimer->setInterval(200);
|
// **************
|
||||||
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updatePosition()));
|
// create the desired timers
|
||||||
m_updateTimer->start();
|
|
||||||
|
m_updateTimer = new QTimer();
|
||||||
m_statusUpdateTimer = new QTimer();
|
m_updateTimer->setInterval(m_maxUpdateRate);
|
||||||
m_statusUpdateTimer->setInterval(100);
|
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updatePosition()));
|
||||||
connect(m_statusUpdateTimer, SIGNAL(timeout()), this, SLOT(updateMousePos()));
|
m_updateTimer->start();
|
||||||
m_statusUpdateTimer->start();
|
|
||||||
|
m_statusUpdateTimer = new QTimer();
|
||||||
// **************
|
m_statusUpdateTimer->setInterval(200);
|
||||||
|
// m_statusUpdateTimer->setInterval(m_maxUpdateRate);
|
||||||
m_map->setFocus();
|
connect(m_statusUpdateTimer, SIGNAL(timeout()), this, SLOT(updateMousePos()));
|
||||||
}
|
m_statusUpdateTimer->start();
|
||||||
|
|
||||||
// destructor
|
// **************
|
||||||
OPMapGadgetWidget::~OPMapGadgetWidget()
|
|
||||||
{
|
m_map->setFocus();
|
||||||
if (m_map)
|
}
|
||||||
{
|
|
||||||
disconnect(m_map, 0, 0, 0);
|
// destructor
|
||||||
m_map->SetShowHome(false); // doing this appears to stop the map lib crashing on exit
|
OPMapGadgetWidget::~OPMapGadgetWidget()
|
||||||
m_map->SetShowUAV(false); // " "
|
{
|
||||||
}
|
if (m_map)
|
||||||
|
{
|
||||||
|
disconnect(m_map, 0, 0, 0);
|
||||||
// this destructor doesn't appear to be called at shutdown???
|
m_map->SetShowHome(false); // doing this appears to stop the map lib crashing on exit
|
||||||
|
m_map->SetShowUAV(false); // " "
|
||||||
// #if defined(Q_OS_MAC)
|
}
|
||||||
// #elif defined(Q_OS_WIN)
|
|
||||||
// saveComboBoxLines(m_widget->comboBoxFindPlace, QCoreApplication::applicationDirPath() + "/opmap_find_place_history.txt");
|
|
||||||
// #else
|
// this destructor doesn't appear to be called at shutdown???
|
||||||
// #endif
|
|
||||||
|
// #if defined(Q_OS_MAC)
|
||||||
m_waypoint_list_mutex.lock();
|
// #elif defined(Q_OS_WIN)
|
||||||
foreach (t_waypoint *wp, m_waypoint_list)
|
// saveComboBoxLines(m_widget->comboBoxFindPlace, QCoreApplication::applicationDirPath() + "/opmap_find_place_history.txt");
|
||||||
{
|
// #else
|
||||||
if (!wp) continue;
|
// #endif
|
||||||
|
|
||||||
|
m_waypoint_list_mutex.lock();
|
||||||
// todo:
|
foreach (t_waypoint *wp, m_waypoint_list)
|
||||||
|
{
|
||||||
|
if (!wp) continue;
|
||||||
delete wp->map_wp_item;
|
|
||||||
}
|
|
||||||
m_waypoint_list_mutex.unlock();
|
// todo:
|
||||||
m_waypoint_list.clear();
|
|
||||||
|
|
||||||
if (m_map)
|
delete wp->map_wp_item;
|
||||||
{
|
}
|
||||||
delete m_map;
|
m_waypoint_list_mutex.unlock();
|
||||||
m_map = NULL;
|
m_waypoint_list.clear();
|
||||||
}
|
|
||||||
}
|
if (m_map)
|
||||||
|
{
|
||||||
// *************************************************************************************
|
delete m_map;
|
||||||
// widget signals .. the mouseMoveEvent does not get called - don't yet know why
|
m_map = NULL;
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::resizeEvent(QResizeEvent *event)
|
}
|
||||||
{
|
|
||||||
qDebug("opmap: resizeEvent");
|
// *************************************************************************************
|
||||||
|
// widget signals .. the mouseMoveEvent does not get called - don't yet know why
|
||||||
QWidget::resizeEvent(event);
|
|
||||||
}
|
void OPMapGadgetWidget::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
void OPMapGadgetWidget::mouseMoveEvent(QMouseEvent *event)
|
qDebug("opmap: resizeEvent");
|
||||||
{
|
|
||||||
qDebug("opmap: mouseMoveEvent");
|
QWidget::resizeEvent(event);
|
||||||
|
}
|
||||||
if (m_widget && m_map)
|
|
||||||
{
|
void OPMapGadgetWidget::mouseMoveEvent(QMouseEvent *event)
|
||||||
}
|
{
|
||||||
|
qDebug("opmap: mouseMoveEvent");
|
||||||
if (event->buttons() & Qt::LeftButton)
|
|
||||||
{
|
if (m_widget && m_map)
|
||||||
// QPoint pos = event->pos();
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget::mouseMoveEvent(event);
|
if (event->buttons() & Qt::LeftButton)
|
||||||
}
|
{
|
||||||
|
// QPoint pos = event->pos();
|
||||||
void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
|
}
|
||||||
{ // the user has right clicked on the map - create the pop-up context menu and display it
|
|
||||||
|
QWidget::mouseMoveEvent(event);
|
||||||
QString s;
|
}
|
||||||
|
|
||||||
if (!m_widget || !m_map)
|
void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||||
return;
|
{ // the user has right clicked on the map - create the pop-up context menu and display it
|
||||||
|
|
||||||
if (event->reason() != QContextMenuEvent::Mouse)
|
QString s;
|
||||||
return; // not a mouse click event
|
|
||||||
|
if (!m_widget || !m_map)
|
||||||
// current mouse position
|
return;
|
||||||
QPoint p = m_map->mapFromGlobal(event->globalPos());
|
|
||||||
context_menu_lat_lon = m_map->GetFromLocalToLatLng(p);
|
if (event->reason() != QContextMenuEvent::Mouse)
|
||||||
// context_menu_lat_lon = m_map->currentMousePosition();
|
return; // not a mouse click event
|
||||||
|
|
||||||
if (!m_map->contentsRect().contains(p))
|
// current mouse position
|
||||||
return; // the mouse click was not on the map
|
QPoint p = m_map->mapFromGlobal(event->globalPos());
|
||||||
|
m_context_menu_lat_lon = m_map->GetFromLocalToLatLng(p);
|
||||||
// show the mouse position
|
// m_context_menu_lat_lon = m_map->currentMousePosition();
|
||||||
s = QString::number(context_menu_lat_lon.Lat(), 'f', 7) + " " + QString::number(context_menu_lat_lon.Lng(), 'f', 7);
|
|
||||||
m_widget->labelMousePos->setText(s);
|
if (!m_map->contentsRect().contains(p))
|
||||||
|
return; // the mouse click was not on the map
|
||||||
// find out if we have a waypoint under the mouse cursor
|
|
||||||
QGraphicsItem *item = m_map->itemAt(p);
|
// show the mouse position
|
||||||
m_mouse_waypoint = qgraphicsitem_cast<mapcontrol::WayPointItem *>(item);
|
s = QString::number(m_context_menu_lat_lon.Lat(), 'f', 7) + " " + QString::number(m_context_menu_lat_lon.Lng(), 'f', 7);
|
||||||
|
m_widget->labelMousePos->setText(s);
|
||||||
// find out if the waypoint is locked (or not)
|
|
||||||
bool waypoint_locked = false;
|
// find out if we have a waypoint under the mouse cursor
|
||||||
if (m_mouse_waypoint)
|
QGraphicsItem *item = m_map->itemAt(p);
|
||||||
waypoint_locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0;
|
m_mouse_waypoint = qgraphicsitem_cast<mapcontrol::WayPointItem *>(item);
|
||||||
|
|
||||||
// ****************
|
// find out if the waypoint is locked (or not)
|
||||||
// Dynamically create the popup menu
|
bool waypoint_locked = false;
|
||||||
|
if (m_mouse_waypoint)
|
||||||
QMenu menu(this);
|
waypoint_locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0;
|
||||||
|
|
||||||
menu.addAction(closeAct1);
|
// ****************
|
||||||
|
// Dynamically create the popup menu
|
||||||
menu.addSeparator();
|
|
||||||
|
QMenu menu(this);
|
||||||
menu.addAction(reloadAct);
|
|
||||||
|
menu.addAction(closeAct1);
|
||||||
menu.addSeparator();
|
|
||||||
|
menu.addSeparator();
|
||||||
switch (m_map_mode)
|
|
||||||
{
|
menu.addAction(reloadAct);
|
||||||
case Normal_MapMode: s = tr(" (Normal)"); break;
|
|
||||||
case MagicWaypoint_MapMode: s = tr(" (Magic Waypoint)"); break;
|
menu.addSeparator();
|
||||||
default: s = tr(" (Unknown)"); break;
|
|
||||||
}
|
QMenu maxUpdateRateSubMenu(tr("&Max Update Rate ") + "(" + QString::number(m_maxUpdateRate) + " ms)", this);
|
||||||
for (int i = 0; i < mapModeAct.count(); i++)
|
for (int i = 0; i < maxUpdateRateAct.count(); i++)
|
||||||
{ // set the menu to checked (or not)
|
maxUpdateRateSubMenu.addAction(maxUpdateRateAct.at(i));
|
||||||
QAction *act = mapModeAct.at(i);
|
menu.addMenu(&maxUpdateRateSubMenu);
|
||||||
if (!act) continue;
|
|
||||||
if (act->data().toInt() == (int)m_map_mode)
|
menu.addSeparator();
|
||||||
act->setChecked(true);
|
|
||||||
}
|
switch (m_map_mode)
|
||||||
QMenu mapModeSubMenu(tr("Map mode") + s, this);
|
{
|
||||||
for (int i = 0; i < mapModeAct.count(); i++)
|
case Normal_MapMode: s = tr(" (Normal)"); break;
|
||||||
mapModeSubMenu.addAction(mapModeAct.at(i));
|
case MagicWaypoint_MapMode: s = tr(" (Magic Waypoint)"); break;
|
||||||
menu.addMenu(&mapModeSubMenu);
|
default: s = tr(" (Unknown)"); break;
|
||||||
|
}
|
||||||
menu.addSeparator();
|
for (int i = 0; i < mapModeAct.count(); i++)
|
||||||
|
{ // set the menu to checked (or not)
|
||||||
QMenu copySubMenu(tr("Copy"), this);
|
QAction *act = mapModeAct.at(i);
|
||||||
copySubMenu.addAction(copyMouseLatLonToClipAct);
|
if (!act) continue;
|
||||||
copySubMenu.addAction(copyMouseLatToClipAct);
|
if (act->data().toInt() == (int)m_map_mode)
|
||||||
copySubMenu.addAction(copyMouseLonToClipAct);
|
act->setChecked(true);
|
||||||
menu.addMenu(©SubMenu);
|
}
|
||||||
|
QMenu mapModeSubMenu(tr("Map mode") + s, this);
|
||||||
menu.addSeparator();
|
for (int i = 0; i < mapModeAct.count(); i++)
|
||||||
|
mapModeSubMenu.addAction(mapModeAct.at(i));
|
||||||
/*
|
menu.addMenu(&mapModeSubMenu);
|
||||||
menu.addAction(findPlaceAct);
|
|
||||||
|
menu.addSeparator();
|
||||||
menu.addSeparator();
|
|
||||||
*/
|
QMenu copySubMenu(tr("Copy"), this);
|
||||||
|
copySubMenu.addAction(copyMouseLatLonToClipAct);
|
||||||
menu.addAction(showSafeAreaAct);
|
copySubMenu.addAction(copyMouseLatToClipAct);
|
||||||
QMenu safeAreaSubMenu(tr("Safe Area Radius") + " (" + QString::number(m_map->Home->SafeArea()) + "m)", this);
|
copySubMenu.addAction(copyMouseLonToClipAct);
|
||||||
for (int i = 0; i < safeAreaAct.count(); i++)
|
menu.addMenu(©SubMenu);
|
||||||
safeAreaSubMenu.addAction(safeAreaAct.at(i));
|
|
||||||
menu.addMenu(&safeAreaSubMenu);
|
menu.addSeparator();
|
||||||
|
|
||||||
menu.addSeparator();
|
/*
|
||||||
|
menu.addAction(findPlaceAct);
|
||||||
menu.addAction(showCompassAct);
|
|
||||||
|
menu.addSeparator();
|
||||||
menu.addAction(showDiagnostics);
|
*/
|
||||||
|
|
||||||
menu.addSeparator()->setText(tr("Zoom"));
|
menu.addAction(showSafeAreaAct);
|
||||||
|
QMenu safeAreaSubMenu(tr("Safe Area Radius") + " (" + QString::number(m_map->Home->SafeArea()) + "m)", this);
|
||||||
menu.addAction(zoomInAct);
|
for (int i = 0; i < safeAreaAct.count(); i++)
|
||||||
menu.addAction(zoomOutAct);
|
safeAreaSubMenu.addAction(safeAreaAct.at(i));
|
||||||
|
menu.addMenu(&safeAreaSubMenu);
|
||||||
QMenu zoomSubMenu(tr("&Zoom ") + "(" + QString::number(m_map->ZoomTotal()) + ")", this);
|
|
||||||
for (int i = 0; i < zoomAct.count(); i++)
|
menu.addSeparator();
|
||||||
zoomSubMenu.addAction(zoomAct.at(i));
|
|
||||||
menu.addMenu(&zoomSubMenu);
|
menu.addAction(showCompassAct);
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addAction(showDiagnostics);
|
||||||
|
|
||||||
menu.addAction(goMouseClickAct);
|
menu.addSeparator()->setText(tr("Zoom"));
|
||||||
|
|
||||||
menu.addSeparator()->setText(tr("HOME"));
|
menu.addAction(zoomInAct);
|
||||||
|
menu.addAction(zoomOutAct);
|
||||||
menu.addAction(setHomeAct);
|
|
||||||
menu.addAction(showHomeAct);
|
QMenu zoomSubMenu(tr("&Zoom ") + "(" + QString::number(m_map->ZoomTotal()) + ")", this);
|
||||||
menu.addAction(goHomeAct);
|
for (int i = 0; i < zoomAct.count(); i++)
|
||||||
|
zoomSubMenu.addAction(zoomAct.at(i));
|
||||||
// ****
|
menu.addMenu(&zoomSubMenu);
|
||||||
// uav trails
|
|
||||||
|
menu.addSeparator();
|
||||||
menu.addSeparator()->setText(tr("UAV Trail"));
|
|
||||||
|
menu.addAction(goMouseClickAct);
|
||||||
QMenu uavTrailTypeSubMenu(tr("UAV trail type") + " (" + mapcontrol::Helper::StrFromUAVTrailType(m_map->UAV->GetTrailType()) + ")", this);
|
|
||||||
for (int i = 0; i < uavTrailTypeAct.count(); i++)
|
menu.addSeparator()->setText(tr("HOME"));
|
||||||
uavTrailTypeSubMenu.addAction(uavTrailTypeAct.at(i));
|
|
||||||
menu.addMenu(&uavTrailTypeSubMenu);
|
menu.addAction(setHomeAct);
|
||||||
|
menu.addAction(showHomeAct);
|
||||||
QMenu uavTrailTimeSubMenu(tr("UAV trail time") + " (" + QString::number(m_map->UAV->TrailTime()) + " sec)", this);
|
menu.addAction(goHomeAct);
|
||||||
for (int i = 0; i < uavTrailTimeAct.count(); i++)
|
|
||||||
uavTrailTimeSubMenu.addAction(uavTrailTimeAct.at(i));
|
// ****
|
||||||
menu.addMenu(&uavTrailTimeSubMenu);
|
// uav trails
|
||||||
|
|
||||||
QMenu uavTrailDistanceSubMenu(tr("UAV trail distance") + " (" + QString::number(m_map->UAV->TrailDistance()) + " meters)", this);
|
menu.addSeparator()->setText(tr("UAV Trail"));
|
||||||
for (int i = 0; i < uavTrailDistanceAct.count(); i++)
|
|
||||||
uavTrailDistanceSubMenu.addAction(uavTrailDistanceAct.at(i));
|
QMenu uavTrailTypeSubMenu(tr("UAV trail type") + " (" + mapcontrol::Helper::StrFromUAVTrailType(m_map->UAV->GetTrailType()) + ")", this);
|
||||||
menu.addMenu(&uavTrailDistanceSubMenu);
|
for (int i = 0; i < uavTrailTypeAct.count(); i++)
|
||||||
|
uavTrailTypeSubMenu.addAction(uavTrailTypeAct.at(i));
|
||||||
menu.addAction(showTrailAct);
|
menu.addMenu(&uavTrailTypeSubMenu);
|
||||||
|
|
||||||
menu.addAction(showTrailLineAct);
|
QMenu uavTrailTimeSubMenu(tr("UAV trail time") + " (" + QString::number(m_map->UAV->TrailTime()) + " sec)", this);
|
||||||
|
for (int i = 0; i < uavTrailTimeAct.count(); i++)
|
||||||
menu.addAction(clearUAVtrailAct);
|
uavTrailTimeSubMenu.addAction(uavTrailTimeAct.at(i));
|
||||||
|
menu.addMenu(&uavTrailTimeSubMenu);
|
||||||
// ****
|
|
||||||
|
QMenu uavTrailDistanceSubMenu(tr("UAV trail distance") + " (" + QString::number(m_map->UAV->TrailDistance()) + " meters)", this);
|
||||||
menu.addSeparator()->setText(tr("UAV"));
|
for (int i = 0; i < uavTrailDistanceAct.count(); i++)
|
||||||
|
uavTrailDistanceSubMenu.addAction(uavTrailDistanceAct.at(i));
|
||||||
menu.addAction(showUAVAct);
|
menu.addMenu(&uavTrailDistanceSubMenu);
|
||||||
menu.addAction(followUAVpositionAct);
|
|
||||||
menu.addAction(followUAVheadingAct);
|
menu.addAction(showTrailAct);
|
||||||
menu.addAction(goUAVAct);
|
|
||||||
|
menu.addAction(showTrailLineAct);
|
||||||
// *********
|
|
||||||
|
menu.addAction(clearUAVtrailAct);
|
||||||
switch (m_map_mode)
|
|
||||||
{
|
// ****
|
||||||
case Normal_MapMode:
|
|
||||||
// only show the waypoint stuff if not in 'magic waypoint' mode
|
menu.addSeparator()->setText(tr("UAV"));
|
||||||
/*
|
|
||||||
menu.addSeparator()->setText(tr("Waypoints"));
|
menu.addAction(showUAVAct);
|
||||||
|
menu.addAction(followUAVpositionAct);
|
||||||
menu.addAction(wayPointEditorAct);
|
menu.addAction(followUAVheadingAct);
|
||||||
menu.addAction(addWayPointAct);
|
menu.addAction(goUAVAct);
|
||||||
|
|
||||||
if (m_mouse_waypoint)
|
// *********
|
||||||
{ // we have a waypoint under the mouse
|
|
||||||
menu.addAction(editWayPointAct);
|
switch (m_map_mode)
|
||||||
|
{
|
||||||
lockWayPointAct->setChecked(waypoint_locked);
|
case Normal_MapMode:
|
||||||
menu.addAction(lockWayPointAct);
|
// only show the waypoint stuff if not in 'magic waypoint' mode
|
||||||
|
/*
|
||||||
if (!waypoint_locked)
|
menu.addSeparator()->setText(tr("Waypoints"));
|
||||||
menu.addAction(deleteWayPointAct);
|
|
||||||
}
|
menu.addAction(wayPointEditorAct);
|
||||||
|
menu.addAction(addWayPointAct);
|
||||||
m_waypoint_list_mutex.lock();
|
|
||||||
if (m_waypoint_list.count() > 0)
|
if (m_mouse_waypoint)
|
||||||
menu.addAction(clearWayPointsAct); // we have waypoints
|
{ // we have a waypoint under the mouse
|
||||||
m_waypoint_list_mutex.unlock();
|
menu.addAction(editWayPointAct);
|
||||||
*/
|
|
||||||
|
lockWayPointAct->setChecked(waypoint_locked);
|
||||||
break;
|
menu.addAction(lockWayPointAct);
|
||||||
|
|
||||||
case MagicWaypoint_MapMode:
|
if (!waypoint_locked)
|
||||||
menu.addSeparator()->setText(tr("Waypoints"));
|
menu.addAction(deleteWayPointAct);
|
||||||
menu.addAction(homeMagicWaypointAct);
|
}
|
||||||
break;
|
|
||||||
}
|
m_waypoint_list_mutex.lock();
|
||||||
|
if (m_waypoint_list.count() > 0)
|
||||||
// *********
|
menu.addAction(clearWayPointsAct); // we have waypoints
|
||||||
|
m_waypoint_list_mutex.unlock();
|
||||||
menu.addSeparator();
|
*/
|
||||||
|
|
||||||
menu.addAction(closeAct2);
|
break;
|
||||||
|
|
||||||
menu.exec(event->globalPos()); // popup the menu
|
case MagicWaypoint_MapMode:
|
||||||
|
menu.addSeparator()->setText(tr("Waypoints"));
|
||||||
// ****************
|
menu.addAction(homeMagicWaypointAct);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event)
|
|
||||||
{
|
// *********
|
||||||
qDebug() << "opmap: keyPressEvent, key =" << event->key() << endl;
|
|
||||||
|
menu.addSeparator();
|
||||||
switch (event->key())
|
|
||||||
{
|
menu.addAction(closeAct2);
|
||||||
case Qt::Key_Escape:
|
|
||||||
break;
|
menu.exec(event->globalPos()); // popup the menu
|
||||||
|
|
||||||
case Qt::Key_F1:
|
// ****************
|
||||||
break;
|
}
|
||||||
|
|
||||||
case Qt::Key_F2:
|
void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event)
|
||||||
break;
|
{
|
||||||
|
qDebug() << "opmap: keyPressEvent, key =" << event->key() << endl;
|
||||||
case Qt::Key_Up:
|
|
||||||
break;
|
switch (event->key())
|
||||||
|
{
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Escape:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Left:
|
case Qt::Key_F1:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Right:
|
case Qt::Key_F2:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_PageUp:
|
case Qt::Key_Up:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_PageDown:
|
case Qt::Key_Down:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
case Qt::Key_Left:
|
||||||
|
break;
|
||||||
// *************************************************************************************
|
|
||||||
// timer signals
|
case Qt::Key_Right:
|
||||||
|
break;
|
||||||
|
|
||||||
/**
|
case Qt::Key_PageUp:
|
||||||
Updates the UAV position on the map. It is called every 200ms
|
break;
|
||||||
by a timer.
|
|
||||||
|
case Qt::Key_PageDown:
|
||||||
TODO: consider updating upon object update, not timer.
|
break;
|
||||||
*/
|
}
|
||||||
void OPMapGadgetWidget::updatePosition()
|
}
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
// *************************************************************************************
|
||||||
return;
|
// timer signals
|
||||||
|
|
||||||
QMutexLocker locker(&m_map_mutex);
|
/**
|
||||||
//Pip I'm sorry, I know this was here with a purpose vvv
|
Updates the UAV position on the map. It is called every 200ms
|
||||||
//if (!telemetry_connected)
|
by a timer.
|
||||||
// return;
|
|
||||||
|
TODO: consider updating upon object update, not timer.
|
||||||
double latitude;
|
|
||||||
double longitude;
|
from Pip: No don't update on object update - had reports that peoples PC's can't cope with high update rates - have had to allow user to set map update from 100ms to 5 seconds (depending on their PC's graphics processing ability), so this needs to be kept on a timer.
|
||||||
double altitude;
|
*/
|
||||||
|
void OPMapGadgetWidget::updatePosition()
|
||||||
// get current UAV position
|
{
|
||||||
if (!getUAVPosition(latitude, longitude, altitude))
|
double uav_latitude, uav_longitude, uav_altitude, uav_yaw;
|
||||||
return;
|
double gps_latitude, gps_longitude, gps_altitude, gps_heading;
|
||||||
|
|
||||||
// get current UAV heading
|
internals::PointLatLng uav_pos;
|
||||||
float yaw = getUAV_Yaw();
|
internals::PointLatLng gps_pos;
|
||||||
|
|
||||||
internals::PointLatLng uav_pos = internals::PointLatLng(latitude, longitude); // current UAV position
|
if (!m_widget || !m_map)
|
||||||
float uav_heading_degrees = yaw; // current UAV heading
|
return;
|
||||||
float uav_altitude_meters = altitude; // current UAV height
|
|
||||||
float uav_ground_speed_meters_per_second = 0; //data.Groundspeed; // current UAV ground speed
|
QMutexLocker locker(&m_map_mutex);
|
||||||
|
// Pip I'm sorry, I know this was here with a purpose vvv
|
||||||
// display the UAV lat/lon position
|
// from Pip: let you off :)
|
||||||
QString str =
|
//if (!telemetry_connected)
|
||||||
"lat: " + QString::number(uav_pos.Lat(), 'f', 7) +
|
// return;
|
||||||
" lon: " + QString::number(uav_pos.Lng(), 'f', 7) +
|
|
||||||
" " + QString::number(uav_heading_degrees, 'f', 1) + "deg" +
|
// *************
|
||||||
" " + QString::number(uav_altitude_meters, 'f', 1) + "m" +
|
// get the current UAV details
|
||||||
" " + QString::number(uav_ground_speed_meters_per_second, 'f', 1) + "m/s";
|
|
||||||
m_widget->labelUAVPos->setText(str);
|
// get current UAV position
|
||||||
|
if (!getUAVPosition(uav_latitude, uav_longitude, uav_altitude))
|
||||||
m_map->UAV->SetUAVPos(uav_pos, uav_altitude_meters); // set the maps UAV position
|
return;
|
||||||
// qDebug()<<"UAVPOSITION"<<uav_pos.ToString();
|
|
||||||
m_map->UAV->SetUAVHeading(uav_heading_degrees); // set the maps UAV heading
|
// get current UAV heading
|
||||||
|
uav_yaw = getUAV_Yaw();
|
||||||
if (!getGPSPosition(latitude, longitude, altitude))
|
|
||||||
return;
|
uav_pos = internals::PointLatLng(uav_latitude, uav_longitude);
|
||||||
|
|
||||||
uav_pos = internals::PointLatLng(latitude, longitude); // current UAV position
|
// *************
|
||||||
m_map->GPS->SetUAVPos(uav_pos, uav_altitude_meters); // set the maps UAV position
|
// get the current GPS details
|
||||||
m_map->GPS->SetUAVHeading(uav_heading_degrees); // set the maps UAV heading
|
|
||||||
}
|
// get current GPS position
|
||||||
|
if (!getGPSPosition(gps_latitude, gps_longitude, gps_altitude))
|
||||||
/**
|
return;
|
||||||
Update plugin behaviour based on mouse position; Called every few ms by a
|
|
||||||
timer.
|
// get current GPS heading
|
||||||
*/
|
// gps_heading = getGPS_Heading();
|
||||||
void OPMapGadgetWidget::updateMousePos()
|
gps_heading = 0;
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
gps_pos = internals::PointLatLng(gps_latitude, gps_longitude);
|
||||||
return;
|
|
||||||
|
// *************
|
||||||
QMutexLocker locker(&m_map_mutex);
|
// display the UAV position
|
||||||
|
|
||||||
QPoint p = m_map->mapFromGlobal(QCursor::pos());
|
QString str =
|
||||||
internals::PointLatLng lat_lon = m_map->GetFromLocalToLatLng(p); // fetch the current lat/lon mouse position
|
"lat: " + QString::number(uav_pos.Lat(), 'f', 7) +
|
||||||
|
" lon: " + QString::number(uav_pos.Lng(), 'f', 7) +
|
||||||
if (!m_map->contentsRect().contains(p))
|
" " + QString::number(uav_yaw, 'f', 1) + "deg" +
|
||||||
return; // the mouse is not on the map
|
" " + QString::number(uav_altitude, 'f', 1) + "m";
|
||||||
|
// " " + QString::number(uav_ground_speed_meters_per_second, 'f', 1) + "m/s";
|
||||||
// internals::PointLatLng lat_lon = m_map->currentMousePosition(); // fetch the current lat/lon mouse position
|
m_widget->labelUAVPos->setText(str);
|
||||||
|
|
||||||
QGraphicsItem *item = m_map->itemAt(p);
|
// *************
|
||||||
|
// set the UAV icon position on the map
|
||||||
// find out if we are over the home position
|
|
||||||
mapcontrol::HomeItem *home = qgraphicsitem_cast<mapcontrol::HomeItem *>(item);
|
m_map->UAV->SetUAVPos(uav_pos, uav_altitude); // set the maps UAV position
|
||||||
|
// qDebug()<<"UAVPOSITION"<<uav_pos.ToString();
|
||||||
// find out if we are over the UAV
|
m_map->UAV->SetUAVHeading(uav_yaw); // set the maps UAV heading
|
||||||
mapcontrol::UAVItem *uav = qgraphicsitem_cast<mapcontrol::UAVItem *>(item);
|
|
||||||
|
// *************
|
||||||
// find out if we have a waypoint under the mouse cursor
|
// set the GPS icon position on the map
|
||||||
mapcontrol::WayPointItem *wp = qgraphicsitem_cast<mapcontrol::WayPointItem *>(item);
|
|
||||||
|
m_map->GPS->SetUAVPos(gps_pos, gps_altitude); // set the maps GPS position
|
||||||
if (mouse_lat_lon == lat_lon)
|
m_map->GPS->SetUAVHeading(gps_heading); // set the maps GPS heading
|
||||||
return; // the mouse has not moved
|
|
||||||
|
// *************
|
||||||
mouse_lat_lon = lat_lon; // yes it has!
|
}
|
||||||
|
|
||||||
internals::PointLatLng home_lat_lon = m_map->Home->Coord();
|
/**
|
||||||
|
Update plugin behaviour based on mouse position; Called every few ms by a
|
||||||
QString s = QString::number(mouse_lat_lon.Lat(), 'f', 7) + " " + QString::number(mouse_lat_lon.Lng(), 'f', 7);
|
timer.
|
||||||
if (wp)
|
*/
|
||||||
{
|
void OPMapGadgetWidget::updateMousePos()
|
||||||
s += " wp[" + QString::number(wp->Number()) + "]";
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
double dist = distance(home_lat_lon, wp->Coord());
|
return;
|
||||||
double bear = bearing(home_lat_lon, wp->Coord());
|
|
||||||
s += " " + QString::number(dist * 1000, 'f', 1) + "m";
|
QMutexLocker locker(&m_map_mutex);
|
||||||
s += " " + QString::number(bear, 'f', 1) + "deg";
|
|
||||||
}
|
QPoint p = m_map->mapFromGlobal(QCursor::pos());
|
||||||
else
|
internals::PointLatLng lat_lon = m_map->GetFromLocalToLatLng(p); // fetch the current lat/lon mouse position
|
||||||
if (home)
|
|
||||||
{
|
if (!m_map->contentsRect().contains(p))
|
||||||
s += " home";
|
return; // the mouse is not on the map
|
||||||
|
|
||||||
double dist = distance(home_lat_lon, mouse_lat_lon);
|
// internals::PointLatLng lat_lon = m_map->currentMousePosition(); // fetch the current lat/lon mouse position
|
||||||
double bear = bearing(home_lat_lon, mouse_lat_lon);
|
|
||||||
s += " " + QString::number(dist * 1000, 'f', 1) + "m";
|
QGraphicsItem *item = m_map->itemAt(p);
|
||||||
s += " " + QString::number(bear, 'f', 1) + "deg";
|
|
||||||
}
|
// find out if we are over the home position
|
||||||
else
|
mapcontrol::HomeItem *home = qgraphicsitem_cast<mapcontrol::HomeItem *>(item);
|
||||||
if (uav)
|
|
||||||
{
|
// find out if we are over the UAV
|
||||||
s += " uav";
|
mapcontrol::UAVItem *uav = qgraphicsitem_cast<mapcontrol::UAVItem *>(item);
|
||||||
|
|
||||||
double latitude;
|
// find out if we have a waypoint under the mouse cursor
|
||||||
double longitude;
|
mapcontrol::WayPointItem *wp = qgraphicsitem_cast<mapcontrol::WayPointItem *>(item);
|
||||||
double altitude;
|
|
||||||
if (getUAVPosition(latitude, longitude, altitude)) // get current UAV position
|
if (m_mouse_lat_lon == lat_lon)
|
||||||
{
|
return; // the mouse has not moved
|
||||||
internals::PointLatLng uav_pos = internals::PointLatLng(latitude, longitude);
|
|
||||||
|
m_mouse_lat_lon = lat_lon; // yes it has!
|
||||||
// double dist = distance(home_lat_lon, uav_pos);
|
|
||||||
// double bear = bearing(home_lat_lon, uav_pos);
|
internals::PointLatLng home_lat_lon = m_map->Home->Coord();
|
||||||
// s += " " + QString::number(dist * 1000, 'f', 1) + "m";
|
|
||||||
// s += " " + QString::number(bear, 'f', 1) + "deg";
|
QString s = QString::number(m_mouse_lat_lon.Lat(), 'f', 7) + " " + QString::number(m_mouse_lat_lon.Lng(), 'f', 7);
|
||||||
}
|
if (wp)
|
||||||
}
|
{
|
||||||
m_widget->labelMousePos->setText(s);
|
s += " wp[" + QString::number(wp->Number()) + "]";
|
||||||
}
|
|
||||||
|
double dist = distance(home_lat_lon, wp->Coord());
|
||||||
// *************************************************************************************
|
double bear = bearing(home_lat_lon, wp->Coord());
|
||||||
// map signals
|
s += " " + QString::number(dist * 1000, 'f', 1) + "m";
|
||||||
|
s += " " + QString::number(bear, 'f', 1) + "deg";
|
||||||
|
}
|
||||||
/**
|
else
|
||||||
Update the Plugin UI to reflect a change in zoom level
|
if (home)
|
||||||
*/
|
{
|
||||||
void OPMapGadgetWidget::zoomChanged(double zoomt, double zoom, double zoomd)
|
s += " home";
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
double dist = distance(home_lat_lon, m_mouse_lat_lon);
|
||||||
return;
|
double bear = bearing(home_lat_lon, m_mouse_lat_lon);
|
||||||
|
s += " " + QString::number(dist * 1000, 'f', 1) + "m";
|
||||||
QString s = "tot:" + QString::number(zoomt, 'f', 1) + " rea:" + QString::number(zoom, 'f', 1) + " dig:" + QString::number(zoomd, 'f', 1);
|
s += " " + QString::number(bear, 'f', 1) + "deg";
|
||||||
m_widget->labelMapZoom->setText(s);
|
}
|
||||||
|
else
|
||||||
int i_zoom = (int)(zoomt + 0.5);
|
if (uav)
|
||||||
|
{
|
||||||
if (i_zoom < min_zoom) i_zoom = min_zoom;
|
s += " uav";
|
||||||
else
|
|
||||||
if (i_zoom > max_zoom) i_zoom = max_zoom;
|
double latitude;
|
||||||
|
double longitude;
|
||||||
if (m_widget->horizontalSliderZoom->value() != i_zoom)
|
double altitude;
|
||||||
m_widget->horizontalSliderZoom->setValue(i_zoom); // set the GUI zoom slider position
|
if (getUAVPosition(latitude, longitude, altitude)) // get current UAV position
|
||||||
|
{
|
||||||
int index0_zoom = i_zoom - min_zoom; // zoom level starting at index level '0'
|
internals::PointLatLng uav_pos = internals::PointLatLng(latitude, longitude);
|
||||||
if (index0_zoom < zoomAct.count())
|
|
||||||
zoomAct.at(index0_zoom)->setChecked(true); // set the right-click context menu zoom level
|
// double dist = distance(home_lat_lon, uav_pos);
|
||||||
}
|
// double bear = bearing(home_lat_lon, uav_pos);
|
||||||
|
// s += " " + QString::number(dist * 1000, 'f', 1) + "m";
|
||||||
void OPMapGadgetWidget::OnMapDrag()
|
// s += " " + QString::number(bear, 'f', 1) + "deg";
|
||||||
{
|
}
|
||||||
}
|
}
|
||||||
|
m_widget->labelMousePos->setText(s);
|
||||||
void OPMapGadgetWidget::OnCurrentPositionChanged(internals::PointLatLng point)
|
}
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
// *************************************************************************************
|
||||||
return;
|
// map signals
|
||||||
|
|
||||||
QString coord_str = QString::number(point.Lat(), 'f', 7) + " " + QString::number(point.Lng(), 'f', 7) + " ";
|
|
||||||
m_widget->labelMapPos->setText(coord_str);
|
/**
|
||||||
}
|
Update the Plugin UI to reflect a change in zoom level
|
||||||
|
*/
|
||||||
/**
|
void OPMapGadgetWidget::zoomChanged(double zoomt, double zoom, double zoomd)
|
||||||
Update the progress bar while there are still tiles to load
|
{
|
||||||
*/
|
if (!m_widget || !m_map)
|
||||||
void OPMapGadgetWidget::OnTilesStillToLoad(int number)
|
return;
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
QString s = "tot:" + QString::number(zoomt, 'f', 1) + " rea:" + QString::number(zoom, 'f', 1) + " dig:" + QString::number(zoomd, 'f', 1);
|
||||||
return;
|
m_widget->labelMapZoom->setText(s);
|
||||||
|
|
||||||
// if (prev_tile_number < number || m_widget->progressBarMap->maximum() < number)
|
int i_zoom = (int)(zoomt + 0.5);
|
||||||
// m_widget->progressBarMap->setMaximum(number);
|
|
||||||
|
if (i_zoom < m_min_zoom) i_zoom = m_min_zoom;
|
||||||
if (m_widget->progressBarMap->maximum() < number)
|
else
|
||||||
m_widget->progressBarMap->setMaximum(number);
|
if (i_zoom > m_max_zoom) i_zoom = m_max_zoom;
|
||||||
|
|
||||||
m_widget->progressBarMap->setValue(m_widget->progressBarMap->maximum() - number); // update the progress bar
|
if (m_widget->horizontalSliderZoom->value() != i_zoom)
|
||||||
|
m_widget->horizontalSliderZoom->setValue(i_zoom); // set the GUI zoom slider position
|
||||||
// m_widget->labelNumTilesToLoad->setText(QString::number(number));
|
|
||||||
|
int index0_zoom = i_zoom - m_min_zoom; // zoom level starting at index level '0'
|
||||||
prev_tile_number = number;
|
if (index0_zoom < zoomAct.count())
|
||||||
}
|
zoomAct.at(index0_zoom)->setChecked(true); // set the right-click context menu zoom level
|
||||||
|
}
|
||||||
/**
|
|
||||||
Show the progress bar as soon as the map lib starts downloading
|
void OPMapGadgetWidget::OnMapDrag()
|
||||||
*/
|
{
|
||||||
void OPMapGadgetWidget::OnTileLoadStart()
|
}
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
void OPMapGadgetWidget::OnCurrentPositionChanged(internals::PointLatLng point)
|
||||||
return;
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
m_widget->progressBarMap->setVisible(true);
|
return;
|
||||||
}
|
|
||||||
|
QString coord_str = QString::number(point.Lat(), 'f', 7) + " " + QString::number(point.Lng(), 'f', 7) + " ";
|
||||||
/**
|
m_widget->labelMapPos->setText(coord_str);
|
||||||
Hide the progress bar once the map lib has finished downloading
|
}
|
||||||
|
|
||||||
TODO: somehow this gets called before tile load is actually complete?
|
/**
|
||||||
*/
|
Update the progress bar while there are still tiles to load
|
||||||
|
*/
|
||||||
void OPMapGadgetWidget::OnTileLoadComplete()
|
void OPMapGadgetWidget::OnTilesStillToLoad(int number)
|
||||||
{
|
{
|
||||||
if (!m_widget || !m_map)
|
if (!m_widget || !m_map)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_widget->progressBarMap->setVisible(false);
|
// if (prev_tile_number < number || m_widget->progressBarMap->maximum() < number)
|
||||||
}
|
// m_widget->progressBarMap->setMaximum(number);
|
||||||
|
|
||||||
void OPMapGadgetWidget::OnMapZoomChanged()
|
if (m_widget->progressBarMap->maximum() < number)
|
||||||
{
|
m_widget->progressBarMap->setMaximum(number);
|
||||||
}
|
|
||||||
|
m_widget->progressBarMap->setValue(m_widget->progressBarMap->maximum() - number); // update the progress bar
|
||||||
void OPMapGadgetWidget::OnMapTypeChanged(MapType::Types type)
|
|
||||||
{
|
// m_widget->labelNumTilesToLoad->setText(QString::number(number));
|
||||||
Q_UNUSED(type);
|
|
||||||
}
|
m_prev_tile_number = number;
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::OnEmptyTileError(int zoom, core::Point pos)
|
|
||||||
{
|
/**
|
||||||
Q_UNUSED(zoom);
|
Show the progress bar as soon as the map lib starts downloading
|
||||||
Q_UNUSED(pos);
|
*/
|
||||||
}
|
void OPMapGadgetWidget::OnTileLoadStart()
|
||||||
|
{
|
||||||
void OPMapGadgetWidget::WPNumberChanged(int const &oldnumber, int const &newnumber, WayPointItem *waypoint)
|
if (!m_widget || !m_map)
|
||||||
{
|
return;
|
||||||
Q_UNUSED(oldnumber);
|
|
||||||
Q_UNUSED(newnumber);
|
m_widget->progressBarMap->setVisible(true);
|
||||||
Q_UNUSED(waypoint);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
void OPMapGadgetWidget::WPValuesChanged(WayPointItem *waypoint)
|
Hide the progress bar once the map lib has finished downloading
|
||||||
{
|
|
||||||
// qDebug("opmap: WPValuesChanged");
|
TODO: somehow this gets called before tile load is actually complete?
|
||||||
|
*/
|
||||||
switch (m_map_mode)
|
|
||||||
{
|
void OPMapGadgetWidget::OnTileLoadComplete()
|
||||||
case Normal_MapMode:
|
{
|
||||||
m_waypoint_list_mutex.lock();
|
if (!m_widget || !m_map)
|
||||||
foreach (t_waypoint *wp, m_waypoint_list)
|
return;
|
||||||
{ // search for the waypoint in our own waypoint list and update it
|
|
||||||
if (!wp) continue;
|
m_widget->progressBarMap->setVisible(false);
|
||||||
if (!wp->map_wp_item) continue;
|
}
|
||||||
if (wp->map_wp_item != waypoint) continue;
|
|
||||||
// found the waypoint in our list
|
void OPMapGadgetWidget::OnMapZoomChanged()
|
||||||
wp->coord = waypoint->Coord();
|
{
|
||||||
wp->altitude = waypoint->Altitude();
|
}
|
||||||
wp->description = waypoint->Description();
|
|
||||||
break;
|
void OPMapGadgetWidget::OnMapTypeChanged(MapType::Types type)
|
||||||
}
|
{
|
||||||
m_waypoint_list_mutex.unlock();
|
Q_UNUSED(type);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case MagicWaypoint_MapMode:
|
void OPMapGadgetWidget::OnEmptyTileError(int zoom, core::Point pos)
|
||||||
// update our copy of the magic waypoint
|
{
|
||||||
if (magic_waypoint.map_wp_item && magic_waypoint.map_wp_item == waypoint)
|
Q_UNUSED(zoom);
|
||||||
{
|
Q_UNUSED(pos);
|
||||||
magic_waypoint.coord = waypoint->Coord();
|
}
|
||||||
magic_waypoint.altitude = waypoint->Altitude();
|
|
||||||
magic_waypoint.description = waypoint->Description();
|
void OPMapGadgetWidget::WPNumberChanged(int const &oldnumber, int const &newnumber, WayPointItem *waypoint)
|
||||||
|
{
|
||||||
// move the UAV to the magic waypoint position
|
Q_UNUSED(oldnumber);
|
||||||
// moveToMagicWaypointPosition();
|
Q_UNUSED(newnumber);
|
||||||
}
|
Q_UNUSED(waypoint);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
void OPMapGadgetWidget::WPValuesChanged(WayPointItem *waypoint)
|
||||||
}
|
{
|
||||||
|
// qDebug("opmap: WPValuesChanged");
|
||||||
/**
|
|
||||||
TODO: slot to do something upon Waypoint insertion
|
switch (m_map_mode)
|
||||||
*/
|
{
|
||||||
void OPMapGadgetWidget::WPInserted(int const &number, WayPointItem *waypoint)
|
case Normal_MapMode:
|
||||||
{
|
m_waypoint_list_mutex.lock();
|
||||||
Q_UNUSED(number);
|
foreach (t_waypoint *wp, m_waypoint_list)
|
||||||
Q_UNUSED(waypoint);
|
{ // search for the waypoint in our own waypoint list and update it
|
||||||
}
|
if (!wp) continue;
|
||||||
|
if (!wp->map_wp_item) continue;
|
||||||
/**
|
if (wp->map_wp_item != waypoint) continue;
|
||||||
TODO: slot to do something upon Waypoint deletion
|
// found the waypoint in our list
|
||||||
*/
|
wp->coord = waypoint->Coord();
|
||||||
void OPMapGadgetWidget::WPDeleted(int const &number)
|
wp->altitude = waypoint->Altitude();
|
||||||
{
|
wp->description = waypoint->Description();
|
||||||
Q_UNUSED(number);
|
break;
|
||||||
}
|
}
|
||||||
|
m_waypoint_list_mutex.unlock();
|
||||||
|
break;
|
||||||
void OPMapGadgetWidget::on_toolButtonZoomP_clicked()
|
|
||||||
{
|
case MagicWaypoint_MapMode:
|
||||||
QMutexLocker locker(&m_map_mutex);
|
// update our copy of the magic waypoint
|
||||||
zoomIn();
|
if (m_magic_waypoint.map_wp_item && m_magic_waypoint.map_wp_item == waypoint)
|
||||||
}
|
{
|
||||||
|
m_magic_waypoint.coord = waypoint->Coord();
|
||||||
void OPMapGadgetWidget::on_toolButtonZoomM_clicked()
|
m_magic_waypoint.altitude = waypoint->Altitude();
|
||||||
{
|
m_magic_waypoint.description = waypoint->Description();
|
||||||
QMutexLocker locker(&m_map_mutex);
|
|
||||||
zoomOut();
|
// move the UAV to the magic waypoint position
|
||||||
}
|
// moveToMagicWaypointPosition();
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::on_toolButtonMapHome_clicked()
|
break;
|
||||||
{
|
}
|
||||||
QMutexLocker locker(&m_map_mutex);
|
|
||||||
goHome();
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
void OPMapGadgetWidget::on_toolButtonMapUAV_clicked()
|
TODO: slot to do something upon Waypoint insertion
|
||||||
{
|
*/
|
||||||
if (!m_widget || !m_map)
|
void OPMapGadgetWidget::WPInserted(int const &number, WayPointItem *waypoint)
|
||||||
return;
|
{
|
||||||
|
Q_UNUSED(number);
|
||||||
QMutexLocker locker(&m_map_mutex);
|
Q_UNUSED(waypoint);
|
||||||
|
}
|
||||||
followUAVpositionAct->toggle();
|
|
||||||
}
|
/**
|
||||||
|
TODO: slot to do something upon Waypoint deletion
|
||||||
void OPMapGadgetWidget::on_toolButtonMapUAVheading_clicked()
|
*/
|
||||||
{
|
void OPMapGadgetWidget::WPDeleted(int const &number)
|
||||||
if (!m_widget || !m_map)
|
{
|
||||||
return;
|
Q_UNUSED(number);
|
||||||
|
}
|
||||||
followUAVheadingAct->toggle();
|
|
||||||
}
|
|
||||||
|
void OPMapGadgetWidget::on_toolButtonZoomP_clicked()
|
||||||
void OPMapGadgetWidget::on_horizontalSliderZoom_sliderMoved(int position)
|
{
|
||||||
{
|
QMutexLocker locker(&m_map_mutex);
|
||||||
if (!m_widget || !m_map)
|
zoomIn();
|
||||||
return;
|
}
|
||||||
|
|
||||||
QMutexLocker locker(&m_map_mutex);
|
void OPMapGadgetWidget::on_toolButtonZoomM_clicked()
|
||||||
|
{
|
||||||
setZoom(position);
|
QMutexLocker locker(&m_map_mutex);
|
||||||
}
|
zoomOut();
|
||||||
|
}
|
||||||
|
|
||||||
void OPMapGadgetWidget::on_toolButtonNormalMapMode_clicked()
|
void OPMapGadgetWidget::on_toolButtonMapHome_clicked()
|
||||||
{
|
{
|
||||||
setMapMode(Normal_MapMode);
|
QMutexLocker locker(&m_map_mutex);
|
||||||
}
|
goHome();
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::on_toolButtonMagicWaypointMapMode_clicked()
|
|
||||||
{
|
void OPMapGadgetWidget::on_toolButtonMapUAV_clicked()
|
||||||
setMapMode(MagicWaypoint_MapMode);
|
{
|
||||||
}
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
void OPMapGadgetWidget::on_toolButtonHomeWaypoint_clicked()
|
|
||||||
{
|
QMutexLocker locker(&m_map_mutex);
|
||||||
homeMagicWaypoint();
|
|
||||||
}
|
followUAVpositionAct->toggle();
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::on_toolButtonMoveToWP_clicked()
|
|
||||||
{
|
void OPMapGadgetWidget::on_toolButtonMapUAVheading_clicked()
|
||||||
moveToMagicWaypointPosition();
|
{
|
||||||
}
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
// *************************************************************************************
|
|
||||||
// public slots
|
followUAVheadingAct->toggle();
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::onTelemetryConnect()
|
|
||||||
{
|
void OPMapGadgetWidget::on_horizontalSliderZoom_sliderMoved(int position)
|
||||||
telemetry_connected = true;
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
if (!obum) return;
|
return;
|
||||||
|
|
||||||
bool set;
|
QMutexLocker locker(&m_map_mutex);
|
||||||
double LLA[3];
|
|
||||||
|
setZoom(position);
|
||||||
// ***********************
|
}
|
||||||
// fetch the home location
|
|
||||||
|
|
||||||
if (obum->getHomeLocation(set, LLA) < 0)
|
void OPMapGadgetWidget::on_toolButtonNormalMapMode_clicked()
|
||||||
return; // error
|
{
|
||||||
|
setMapMode(Normal_MapMode);
|
||||||
setHome(internals::PointLatLng(LLA[0], LLA[1]));
|
}
|
||||||
|
|
||||||
if (m_map)
|
void OPMapGadgetWidget::on_toolButtonMagicWaypointMapMode_clicked()
|
||||||
m_map->SetCurrentPosition(home_position.coord); // set the map position
|
{
|
||||||
|
setMapMode(MagicWaypoint_MapMode);
|
||||||
// ***********************
|
}
|
||||||
}
|
|
||||||
|
void OPMapGadgetWidget::on_toolButtonHomeWaypoint_clicked()
|
||||||
void OPMapGadgetWidget::onTelemetryDisconnect()
|
{
|
||||||
{
|
homeMagicWaypoint();
|
||||||
telemetry_connected = false;
|
}
|
||||||
}
|
|
||||||
|
void OPMapGadgetWidget::on_toolButtonMoveToWP_clicked()
|
||||||
// Updates the Home position icon whenever the HomePosition object is updated
|
{
|
||||||
void OPMapGadgetWidget::homePositionUpdated(UAVObject *hp)
|
moveToMagicWaypointPosition();
|
||||||
{
|
}
|
||||||
if (!hp)
|
|
||||||
return;
|
// *************************************************************************************
|
||||||
|
// public slots
|
||||||
double lat = hp->getField("Latitude")->getDouble() * 1e-7;
|
|
||||||
double lon = hp->getField("Longitude")->getDouble() * 1e-7;
|
void OPMapGadgetWidget::onTelemetryConnect()
|
||||||
setHome(internals::PointLatLng(lat, lon));
|
{
|
||||||
}
|
m_telemetry_connected = true;
|
||||||
|
|
||||||
// *************************************************************************************
|
if (!obum) return;
|
||||||
// public functions
|
|
||||||
|
bool set;
|
||||||
/**
|
double LLA[3];
|
||||||
Sets the home position on the map widget
|
|
||||||
*/
|
// ***********************
|
||||||
void OPMapGadgetWidget::setHome(QPointF pos)
|
// fetch the home location
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
if (obum->getHomeLocation(set, LLA) < 0)
|
||||||
return;
|
return; // error
|
||||||
|
|
||||||
double latitude = pos.x();
|
setHome(internals::PointLatLng(LLA[0], LLA[1]));
|
||||||
double longitude = pos.y();
|
|
||||||
|
if (m_map)
|
||||||
if (latitude > 90) latitude = 90;
|
m_map->SetCurrentPosition(m_home_position.coord); // set the map position
|
||||||
else
|
|
||||||
if (latitude < -90) latitude = -90;
|
// ***********************
|
||||||
|
}
|
||||||
if (longitude != longitude) longitude = 0; // nan detection
|
|
||||||
else
|
void OPMapGadgetWidget::onTelemetryDisconnect()
|
||||||
if (longitude > 180) longitude = 180;
|
{
|
||||||
else
|
m_telemetry_connected = false;
|
||||||
if (longitude < -180) longitude = -180;
|
}
|
||||||
|
|
||||||
setHome(internals::PointLatLng(latitude, longitude));
|
// Updates the Home position icon whenever the HomePosition object is updated
|
||||||
}
|
void OPMapGadgetWidget::homePositionUpdated(UAVObject *hp)
|
||||||
|
{
|
||||||
/**
|
if (!hp)
|
||||||
Sets the home position on the map widget
|
return;
|
||||||
*/
|
|
||||||
void OPMapGadgetWidget::setHome(internals::PointLatLng pos_lat_lon)
|
double lat = hp->getField("Latitude")->getDouble() * 1e-7;
|
||||||
{
|
double lon = hp->getField("Longitude")->getDouble() * 1e-7;
|
||||||
if (!m_widget || !m_map)
|
setHome(internals::PointLatLng(lat, lon));
|
||||||
return;
|
}
|
||||||
|
|
||||||
if (pos_lat_lon.Lat() != pos_lat_lon.Lat() || pos_lat_lon.Lng() != pos_lat_lon.Lng())
|
// *************************************************************************************
|
||||||
return;; // nan prevention
|
// public functions
|
||||||
|
|
||||||
double latitude = pos_lat_lon.Lat();
|
/**
|
||||||
double longitude = pos_lat_lon.Lng();
|
Sets the home position on the map widget
|
||||||
|
*/
|
||||||
if (latitude != latitude) latitude = 0; // nan detection
|
void OPMapGadgetWidget::setHome(QPointF pos)
|
||||||
else
|
{
|
||||||
if (latitude > 90) latitude = 90;
|
if (!m_widget || !m_map)
|
||||||
else
|
return;
|
||||||
if (latitude < -90) latitude = -90;
|
|
||||||
|
double latitude = pos.x();
|
||||||
if (longitude != longitude) longitude = 0; // nan detection
|
double longitude = pos.y();
|
||||||
else
|
|
||||||
if (longitude > 180) longitude = 180;
|
if (latitude > 90) latitude = 90;
|
||||||
else
|
else
|
||||||
if (longitude < -180) longitude = -180;
|
if (latitude < -90) latitude = -90;
|
||||||
|
|
||||||
// *********
|
if (longitude != longitude) longitude = 0; // nan detection
|
||||||
|
else
|
||||||
home_position.coord = internals::PointLatLng(latitude, longitude);
|
if (longitude > 180) longitude = 180;
|
||||||
|
else
|
||||||
m_map->Home->SetCoord(home_position.coord);
|
if (longitude < -180) longitude = -180;
|
||||||
m_map->Home->RefreshPos();
|
|
||||||
|
setHome(internals::PointLatLng(latitude, longitude));
|
||||||
// move the magic waypoint to keep it within the safe area boundry
|
}
|
||||||
keepMagicWaypointWithInSafeArea();
|
|
||||||
}
|
/**
|
||||||
|
Sets the home position on the map widget
|
||||||
|
*/
|
||||||
/**
|
void OPMapGadgetWidget::setHome(internals::PointLatLng pos_lat_lon)
|
||||||
Centers the map over the home position
|
{
|
||||||
*/
|
if (!m_widget || !m_map)
|
||||||
void OPMapGadgetWidget::goHome()
|
return;
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
if (pos_lat_lon.Lat() != pos_lat_lon.Lat() || pos_lat_lon.Lng() != pos_lat_lon.Lng())
|
||||||
return;
|
return;; // nan prevention
|
||||||
|
|
||||||
followUAVpositionAct->setChecked(false);
|
double latitude = pos_lat_lon.Lat();
|
||||||
|
double longitude = pos_lat_lon.Lng();
|
||||||
internals::PointLatLng home_pos = home_position.coord; // get the home location
|
|
||||||
m_map->SetCurrentPosition(home_pos); // center the map onto the home location
|
if (latitude != latitude) latitude = 0; // nan detection
|
||||||
}
|
else
|
||||||
|
if (latitude > 90) latitude = 90;
|
||||||
|
else
|
||||||
void OPMapGadgetWidget::zoomIn()
|
if (latitude < -90) latitude = -90;
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
if (longitude != longitude) longitude = 0; // nan detection
|
||||||
return;
|
else
|
||||||
|
if (longitude > 180) longitude = 180;
|
||||||
int zoom = m_map->ZoomTotal() + 1;
|
else
|
||||||
|
if (longitude < -180) longitude = -180;
|
||||||
if (zoom < min_zoom) zoom = min_zoom;
|
|
||||||
else
|
// *********
|
||||||
if (zoom > max_zoom) zoom = max_zoom;
|
|
||||||
|
m_home_position.coord = internals::PointLatLng(latitude, longitude);
|
||||||
m_map->SetZoom(zoom);
|
|
||||||
}
|
m_map->Home->SetCoord(m_home_position.coord);
|
||||||
|
m_map->Home->RefreshPos();
|
||||||
void OPMapGadgetWidget::zoomOut()
|
|
||||||
{
|
// move the magic waypoint to keep it within the safe area boundry
|
||||||
if (!m_widget || !m_map)
|
keepMagicWaypointWithInSafeArea();
|
||||||
return;
|
}
|
||||||
|
|
||||||
int zoom = m_map->ZoomTotal() - 1;
|
|
||||||
|
/**
|
||||||
if (zoom < min_zoom) zoom = min_zoom;
|
Centers the map over the home position
|
||||||
else
|
*/
|
||||||
if (zoom > max_zoom) zoom = max_zoom;
|
void OPMapGadgetWidget::goHome()
|
||||||
|
{
|
||||||
m_map->SetZoom(zoom);
|
if (!m_widget || !m_map)
|
||||||
}
|
return;
|
||||||
|
|
||||||
void OPMapGadgetWidget::setZoom(int zoom)
|
followUAVpositionAct->setChecked(false);
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
internals::PointLatLng home_pos = m_home_position.coord; // get the home location
|
||||||
return;
|
m_map->SetCurrentPosition(home_pos); // center the map onto the home location
|
||||||
|
}
|
||||||
if (zoom < min_zoom) zoom = min_zoom;
|
|
||||||
else
|
|
||||||
if (zoom > max_zoom) zoom = max_zoom;
|
void OPMapGadgetWidget::zoomIn()
|
||||||
|
{
|
||||||
internals::MouseWheelZoomType::Types zoom_type = m_map->GetMouseWheelZoomType();
|
if (!m_widget || !m_map)
|
||||||
m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::ViewCenter);
|
return;
|
||||||
|
|
||||||
m_map->SetZoom(zoom);
|
int zoom = m_map->ZoomTotal() + 1;
|
||||||
|
|
||||||
m_map->SetMouseWheelZoomType(zoom_type);
|
if (zoom < m_min_zoom) zoom = m_min_zoom;
|
||||||
}
|
else
|
||||||
|
if (zoom > m_max_zoom) zoom = m_max_zoom;
|
||||||
void OPMapGadgetWidget::setPosition(QPointF pos)
|
|
||||||
{
|
m_map->SetZoom(zoom);
|
||||||
if (!m_widget || !m_map)
|
}
|
||||||
return;
|
|
||||||
|
void OPMapGadgetWidget::zoomOut()
|
||||||
double latitude = pos.y();
|
{
|
||||||
double longitude = pos.x();
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
if (latitude != latitude || longitude != longitude)
|
|
||||||
return; // nan prevention
|
int zoom = m_map->ZoomTotal() - 1;
|
||||||
|
|
||||||
if (latitude > 90) latitude = 90;
|
if (zoom < m_min_zoom) zoom = m_min_zoom;
|
||||||
else
|
else
|
||||||
if (latitude < -90) latitude = -90;
|
if (zoom > m_max_zoom) zoom = m_max_zoom;
|
||||||
|
|
||||||
if (longitude > 180) longitude = 180;
|
m_map->SetZoom(zoom);
|
||||||
else
|
}
|
||||||
if (longitude < -180) longitude = -180;
|
|
||||||
|
void OPMapGadgetWidget::setMaxUpdateRate(int update_rate)
|
||||||
m_map->SetCurrentPosition(internals::PointLatLng(latitude, longitude));
|
{
|
||||||
}
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
void OPMapGadgetWidget::setMapProvider(QString provider)
|
|
||||||
{
|
int list_size = sizeof(max_update_rate_list) / sizeof(max_update_rate_list[0]);
|
||||||
if (!m_widget || !m_map)
|
int min_rate = max_update_rate_list[0];
|
||||||
return;
|
int max_rate = max_update_rate_list[list_size - 1];
|
||||||
|
|
||||||
m_map->SetMapType(mapcontrol::Helper::MapTypeFromString(provider));
|
if (update_rate < min_rate) update_rate = min_rate;
|
||||||
}
|
else
|
||||||
|
if (update_rate > max_rate) update_rate = max_rate;
|
||||||
void OPMapGadgetWidget::setAccessMode(QString accessMode)
|
|
||||||
{
|
m_maxUpdateRate = update_rate;
|
||||||
if (!m_widget || !m_map)
|
|
||||||
return;
|
if (m_updateTimer)
|
||||||
|
m_updateTimer->setInterval(m_maxUpdateRate);
|
||||||
m_map->configuration->SetAccessMode(mapcontrol::Helper::AccessModeFromString(accessMode));
|
|
||||||
}
|
// if (m_statusUpdateTimer)
|
||||||
|
// m_statusUpdateTimer->setInterval(m_maxUpdateRate);
|
||||||
void OPMapGadgetWidget::setUseOpenGL(bool useOpenGL)
|
}
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
void OPMapGadgetWidget::setZoom(int zoom)
|
||||||
return;
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
m_map->SetUseOpenGL(useOpenGL);
|
return;
|
||||||
}
|
|
||||||
|
if (zoom < m_min_zoom) zoom = m_min_zoom;
|
||||||
void OPMapGadgetWidget::setShowTileGridLines(bool showTileGridLines)
|
else
|
||||||
{
|
if (zoom > m_max_zoom) zoom = m_max_zoom;
|
||||||
if (!m_widget || !m_map)
|
|
||||||
return;
|
internals::MouseWheelZoomType::Types zoom_type = m_map->GetMouseWheelZoomType();
|
||||||
|
m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::ViewCenter);
|
||||||
m_map->SetShowTileGridLines(showTileGridLines);
|
|
||||||
}
|
m_map->SetZoom(zoom);
|
||||||
|
|
||||||
void OPMapGadgetWidget::setUseMemoryCache(bool useMemoryCache)
|
m_map->SetMouseWheelZoomType(zoom_type);
|
||||||
{
|
}
|
||||||
if (!m_widget || !m_map)
|
|
||||||
return;
|
void OPMapGadgetWidget::setPosition(QPointF pos)
|
||||||
|
{
|
||||||
m_map->configuration->SetUseMemoryCache(useMemoryCache);
|
if (!m_widget || !m_map)
|
||||||
}
|
return;
|
||||||
|
|
||||||
void OPMapGadgetWidget::setCacheLocation(QString cacheLocation)
|
double latitude = pos.y();
|
||||||
{
|
double longitude = pos.x();
|
||||||
if (!m_widget || !m_map)
|
|
||||||
return;
|
if (latitude != latitude || longitude != longitude)
|
||||||
|
return; // nan prevention
|
||||||
cacheLocation = cacheLocation.simplified(); // remove any surrounding spaces
|
|
||||||
|
if (latitude > 90) latitude = 90;
|
||||||
if (cacheLocation.isEmpty()) return;
|
else
|
||||||
|
if (latitude < -90) latitude = -90;
|
||||||
// #if defined(Q_WS_WIN)
|
|
||||||
// if (!cacheLocation.endsWith('\\')) cacheLocation += '\\';
|
if (longitude > 180) longitude = 180;
|
||||||
// #elif defined(Q_WS_X11)
|
else
|
||||||
if (!cacheLocation.endsWith(QDir::separator())) cacheLocation += QDir::separator();
|
if (longitude < -180) longitude = -180;
|
||||||
// #elif defined(Q_WS_MAC)
|
|
||||||
// if (!cacheLocation.endsWith(QDir::separator())) cacheLocation += QDir::separator();
|
m_map->SetCurrentPosition(internals::PointLatLng(latitude, longitude));
|
||||||
// #endif
|
}
|
||||||
|
|
||||||
QDir dir;
|
void OPMapGadgetWidget::setMapProvider(QString provider)
|
||||||
if (!dir.exists(cacheLocation))
|
{
|
||||||
if (!dir.mkpath(cacheLocation))
|
if (!m_widget || !m_map)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// qDebug() << "opmap: map cache dir: " << cacheLocation;
|
m_map->SetMapType(mapcontrol::Helper::MapTypeFromString(provider));
|
||||||
|
}
|
||||||
m_map->configuration->SetCacheLocation(cacheLocation);
|
|
||||||
}
|
void OPMapGadgetWidget::setAccessMode(QString accessMode)
|
||||||
|
{
|
||||||
void OPMapGadgetWidget::setMapMode(opMapModeType mode)
|
if (!m_widget || !m_map)
|
||||||
{
|
return;
|
||||||
if (!m_widget || !m_map)
|
|
||||||
return;
|
m_map->configuration->SetAccessMode(mapcontrol::Helper::AccessModeFromString(accessMode));
|
||||||
|
}
|
||||||
if (mode != Normal_MapMode && mode != MagicWaypoint_MapMode)
|
|
||||||
mode = Normal_MapMode; // fix error
|
void OPMapGadgetWidget::setUseOpenGL(bool useOpenGL)
|
||||||
|
{
|
||||||
if (m_map_mode == mode)
|
if (!m_widget || !m_map)
|
||||||
{ // no change in map mode
|
return;
|
||||||
switch (mode)
|
|
||||||
{ // make sure the UI buttons are set correctly
|
m_map->SetUseOpenGL(useOpenGL);
|
||||||
case Normal_MapMode:
|
}
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(true);
|
void OPMapGadgetWidget::setShowTileGridLines(bool showTileGridLines)
|
||||||
break;
|
{
|
||||||
case MagicWaypoint_MapMode:
|
if (!m_widget || !m_map)
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(false);
|
return;
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
|
||||||
break;
|
m_map->SetShowTileGridLines(showTileGridLines);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
void OPMapGadgetWidget::setUseMemoryCache(bool useMemoryCache)
|
||||||
|
{
|
||||||
switch (mode)
|
if (!m_widget || !m_map)
|
||||||
{
|
return;
|
||||||
case Normal_MapMode:
|
|
||||||
m_map_mode = Normal_MapMode;
|
m_map->configuration->SetUseMemoryCache(useMemoryCache);
|
||||||
|
}
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(true);
|
void OPMapGadgetWidget::setCacheLocation(QString cacheLocation)
|
||||||
|
{
|
||||||
hideMagicWaypointControls();
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
// delete the magic waypoint from the map
|
|
||||||
if (magic_waypoint.map_wp_item)
|
cacheLocation = cacheLocation.simplified(); // remove any surrounding spaces
|
||||||
{
|
|
||||||
magic_waypoint.coord = magic_waypoint.map_wp_item->Coord();
|
if (cacheLocation.isEmpty()) return;
|
||||||
magic_waypoint.altitude = magic_waypoint.map_wp_item->Altitude();
|
|
||||||
magic_waypoint.description = magic_waypoint.map_wp_item->Description();
|
// #if defined(Q_WS_WIN)
|
||||||
magic_waypoint.map_wp_item = NULL;
|
// if (!cacheLocation.endsWith('\\')) cacheLocation += '\\';
|
||||||
}
|
// #elif defined(Q_WS_X11)
|
||||||
m_map->WPDeleteAll();
|
if (!cacheLocation.endsWith(QDir::separator())) cacheLocation += QDir::separator();
|
||||||
|
// #elif defined(Q_WS_MAC)
|
||||||
// restore the normal waypoints on the map
|
// if (!cacheLocation.endsWith(QDir::separator())) cacheLocation += QDir::separator();
|
||||||
m_waypoint_list_mutex.lock();
|
// #endif
|
||||||
foreach (t_waypoint *wp, m_waypoint_list)
|
|
||||||
{
|
QDir dir;
|
||||||
if (!wp) continue;
|
if (!dir.exists(cacheLocation))
|
||||||
wp->map_wp_item = m_map->WPCreate(wp->coord, wp->altitude, wp->description);
|
if (!dir.mkpath(cacheLocation))
|
||||||
if (!wp->map_wp_item) continue;
|
return;
|
||||||
wp->map_wp_item->setZValue(10 + wp->map_wp_item->Number());
|
|
||||||
wp->map_wp_item->setFlag(QGraphicsItem::ItemIsMovable, !wp->locked);
|
// qDebug() << "opmap: map cache dir: " << cacheLocation;
|
||||||
if (!wp->locked)
|
|
||||||
wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png"));
|
m_map->configuration->SetCacheLocation(cacheLocation);
|
||||||
else
|
}
|
||||||
wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker2.png"));
|
|
||||||
wp->map_wp_item->update();
|
void OPMapGadgetWidget::setMapMode(opMapModeType mode)
|
||||||
}
|
{
|
||||||
m_waypoint_list_mutex.unlock();
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
break;
|
|
||||||
|
if (mode != Normal_MapMode && mode != MagicWaypoint_MapMode)
|
||||||
case MagicWaypoint_MapMode:
|
mode = Normal_MapMode; // fix error
|
||||||
m_map_mode = MagicWaypoint_MapMode;
|
|
||||||
|
if (m_map_mode == mode)
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(false);
|
{ // no change in map mode
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
switch (mode)
|
||||||
|
{ // make sure the UI buttons are set correctly
|
||||||
showMagicWaypointControls();
|
case Normal_MapMode:
|
||||||
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
||||||
// delete the normal waypoints from the map
|
m_widget->toolButtonNormalMapMode->setChecked(true);
|
||||||
m_waypoint_list_mutex.lock();
|
break;
|
||||||
foreach (t_waypoint *wp, m_waypoint_list)
|
case MagicWaypoint_MapMode:
|
||||||
{
|
m_widget->toolButtonNormalMapMode->setChecked(false);
|
||||||
if (!wp) continue;
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
||||||
if (!wp->map_wp_item) continue;
|
break;
|
||||||
wp->coord = wp->map_wp_item->Coord();
|
}
|
||||||
wp->altitude = wp->map_wp_item->Altitude();
|
return;
|
||||||
wp->description = wp->map_wp_item->Description();
|
}
|
||||||
wp->locked = (wp->map_wp_item->flags() & QGraphicsItem::ItemIsMovable) == 0;
|
|
||||||
wp->map_wp_item = NULL;
|
switch (mode)
|
||||||
}
|
{
|
||||||
m_map->WPDeleteAll();
|
case Normal_MapMode:
|
||||||
m_waypoint_list_mutex.unlock();
|
m_map_mode = Normal_MapMode;
|
||||||
|
|
||||||
// restore the magic waypoint on the map
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
||||||
magic_waypoint.map_wp_item = m_map->WPCreate(magic_waypoint.coord, magic_waypoint.altitude, magic_waypoint.description);
|
m_widget->toolButtonNormalMapMode->setChecked(true);
|
||||||
magic_waypoint.map_wp_item->setZValue(10 + magic_waypoint.map_wp_item->Number());
|
|
||||||
magic_waypoint.map_wp_item->SetShowNumber(false);
|
hideMagicWaypointControls();
|
||||||
magic_waypoint.map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker3.png"));
|
|
||||||
|
// delete the magic waypoint from the map
|
||||||
break;
|
if (m_magic_waypoint.map_wp_item)
|
||||||
}
|
{
|
||||||
}
|
m_magic_waypoint.coord = m_magic_waypoint.map_wp_item->Coord();
|
||||||
|
m_magic_waypoint.altitude = m_magic_waypoint.map_wp_item->Altitude();
|
||||||
// *************************************************************************************
|
m_magic_waypoint.description = m_magic_waypoint.map_wp_item->Description();
|
||||||
// Context menu stuff
|
m_magic_waypoint.map_wp_item = NULL;
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::createActions()
|
m_map->WPDeleteAll();
|
||||||
{
|
|
||||||
if (!m_widget)
|
// restore the normal waypoints on the map
|
||||||
return;
|
m_waypoint_list_mutex.lock();
|
||||||
|
foreach (t_waypoint *wp, m_waypoint_list)
|
||||||
// ***********************
|
{
|
||||||
// create menu actions
|
if (!wp) continue;
|
||||||
|
wp->map_wp_item = m_map->WPCreate(wp->coord, wp->altitude, wp->description);
|
||||||
closeAct1 = new QAction(tr("Close menu"), this);
|
if (!wp->map_wp_item) continue;
|
||||||
closeAct1->setStatusTip(tr("Close the context menu"));
|
wp->map_wp_item->setZValue(10 + wp->map_wp_item->Number());
|
||||||
|
wp->map_wp_item->setFlag(QGraphicsItem::ItemIsMovable, !wp->locked);
|
||||||
closeAct2 = new QAction(tr("Close menu"), this);
|
if (!wp->locked)
|
||||||
closeAct2->setStatusTip(tr("Close the context menu"));
|
wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png"));
|
||||||
|
else
|
||||||
reloadAct = new QAction(tr("&Reload map"), this);
|
wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker2.png"));
|
||||||
reloadAct->setShortcut(tr("F5"));
|
wp->map_wp_item->update();
|
||||||
reloadAct->setStatusTip(tr("Reload the map tiles"));
|
}
|
||||||
connect(reloadAct, SIGNAL(triggered()), this, SLOT(onReloadAct_triggered()));
|
m_waypoint_list_mutex.unlock();
|
||||||
|
|
||||||
copyMouseLatLonToClipAct = new QAction(tr("Mouse latitude and longitude"), this);
|
break;
|
||||||
copyMouseLatLonToClipAct->setStatusTip(tr("Copy the mouse latitude and longitude to the clipboard"));
|
|
||||||
connect(copyMouseLatLonToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLatLonToClipAct_triggered()));
|
case MagicWaypoint_MapMode:
|
||||||
|
m_map_mode = MagicWaypoint_MapMode;
|
||||||
copyMouseLatToClipAct = new QAction(tr("Mouse latitude"), this);
|
|
||||||
copyMouseLatToClipAct->setStatusTip(tr("Copy the mouse latitude to the clipboard"));
|
m_widget->toolButtonNormalMapMode->setChecked(false);
|
||||||
connect(copyMouseLatToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLatToClipAct_triggered()));
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
||||||
|
|
||||||
copyMouseLonToClipAct = new QAction(tr("Mouse longitude"), this);
|
showMagicWaypointControls();
|
||||||
copyMouseLonToClipAct->setStatusTip(tr("Copy the mouse longitude to the clipboard"));
|
|
||||||
connect(copyMouseLonToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLonToClipAct_triggered()));
|
// delete the normal waypoints from the map
|
||||||
|
m_waypoint_list_mutex.lock();
|
||||||
/*
|
foreach (t_waypoint *wp, m_waypoint_list)
|
||||||
findPlaceAct = new QAction(tr("&Find place"), this);
|
{
|
||||||
findPlaceAct->setShortcut(tr("Ctrl+F"));
|
if (!wp) continue;
|
||||||
findPlaceAct->setStatusTip(tr("Find a location"));
|
if (!wp->map_wp_item) continue;
|
||||||
connect(findPlaceAct, SIGNAL(triggered()), this, SLOT(onFindPlaceAct_triggered()));
|
wp->coord = wp->map_wp_item->Coord();
|
||||||
*/
|
wp->altitude = wp->map_wp_item->Altitude();
|
||||||
|
wp->description = wp->map_wp_item->Description();
|
||||||
showCompassAct = new QAction(tr("Show compass"), this);
|
wp->locked = (wp->map_wp_item->flags() & QGraphicsItem::ItemIsMovable) == 0;
|
||||||
showCompassAct->setStatusTip(tr("Show/Hide the compass"));
|
wp->map_wp_item = NULL;
|
||||||
showCompassAct->setCheckable(true);
|
}
|
||||||
showCompassAct->setChecked(true);
|
m_map->WPDeleteAll();
|
||||||
connect(showCompassAct, SIGNAL(toggled(bool)), this, SLOT(onShowCompassAct_toggled(bool)));
|
m_waypoint_list_mutex.unlock();
|
||||||
|
|
||||||
showDiagnostics = new QAction(tr("Show Diagnostics"), this);
|
// restore the magic waypoint on the map
|
||||||
showDiagnostics->setStatusTip(tr("Show/Hide the diagnostics"));
|
m_magic_waypoint.map_wp_item = m_map->WPCreate(m_magic_waypoint.coord, m_magic_waypoint.altitude, m_magic_waypoint.description);
|
||||||
showDiagnostics->setCheckable(true);
|
m_magic_waypoint.map_wp_item->setZValue(10 + m_magic_waypoint.map_wp_item->Number());
|
||||||
showDiagnostics->setChecked(false);
|
m_magic_waypoint.map_wp_item->SetShowNumber(false);
|
||||||
connect(showDiagnostics, SIGNAL(toggled(bool)), this, SLOT(onShowDiagnostics_toggled(bool)));
|
m_magic_waypoint.map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker3.png"));
|
||||||
|
|
||||||
showHomeAct = new QAction(tr("Show Home"), this);
|
break;
|
||||||
showHomeAct->setStatusTip(tr("Show/Hide the Home location"));
|
}
|
||||||
showHomeAct->setCheckable(true);
|
}
|
||||||
showHomeAct->setChecked(true);
|
|
||||||
connect(showHomeAct, SIGNAL(toggled(bool)), this, SLOT(onShowHomeAct_toggled(bool)));
|
// *************************************************************************************
|
||||||
|
// Context menu stuff
|
||||||
showUAVAct = new QAction(tr("Show UAV"), this);
|
|
||||||
showUAVAct->setStatusTip(tr("Show/Hide the UAV"));
|
void OPMapGadgetWidget::createActions()
|
||||||
showUAVAct->setCheckable(true);
|
{
|
||||||
showUAVAct->setChecked(true);
|
int list_size;
|
||||||
connect(showUAVAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVAct_toggled(bool)));
|
|
||||||
|
if (!m_widget || !m_map)
|
||||||
zoomInAct = new QAction(tr("Zoom &In"), this);
|
return;
|
||||||
zoomInAct->setShortcut(Qt::Key_PageUp);
|
|
||||||
zoomInAct->setStatusTip(tr("Zoom the map in"));
|
// ***********************
|
||||||
connect(zoomInAct, SIGNAL(triggered()), this, SLOT(onGoZoomInAct_triggered()));
|
// create menu actions
|
||||||
|
|
||||||
zoomOutAct = new QAction(tr("Zoom &Out"), this);
|
closeAct1 = new QAction(tr("Close menu"), this);
|
||||||
zoomOutAct->setShortcut(Qt::Key_PageDown);
|
closeAct1->setStatusTip(tr("Close the context menu"));
|
||||||
zoomOutAct->setStatusTip(tr("Zoom the map out"));
|
|
||||||
connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(onGoZoomOutAct_triggered()));
|
closeAct2 = new QAction(tr("Close menu"), this);
|
||||||
|
closeAct2->setStatusTip(tr("Close the context menu"));
|
||||||
goMouseClickAct = new QAction(tr("Go to where you right clicked the mouse"), this);
|
|
||||||
goMouseClickAct->setStatusTip(tr("Center the map onto where you right clicked the mouse"));
|
reloadAct = new QAction(tr("&Reload map"), this);
|
||||||
connect(goMouseClickAct, SIGNAL(triggered()), this, SLOT(onGoMouseClickAct_triggered()));
|
reloadAct->setShortcut(tr("F5"));
|
||||||
|
reloadAct->setStatusTip(tr("Reload the map tiles"));
|
||||||
setHomeAct = new QAction(tr("Set the home location"), this);
|
connect(reloadAct, SIGNAL(triggered()), this, SLOT(onReloadAct_triggered()));
|
||||||
setHomeAct->setStatusTip(tr("Set the home location to where you clicked"));
|
|
||||||
#if !defined(allow_manual_home_location_move)
|
copyMouseLatLonToClipAct = new QAction(tr("Mouse latitude and longitude"), this);
|
||||||
setHomeAct->setEnabled(false);
|
copyMouseLatLonToClipAct->setStatusTip(tr("Copy the mouse latitude and longitude to the clipboard"));
|
||||||
#endif
|
connect(copyMouseLatLonToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLatLonToClipAct_triggered()));
|
||||||
connect(setHomeAct, SIGNAL(triggered()), this, SLOT(onSetHomeAct_triggered()));
|
|
||||||
|
copyMouseLatToClipAct = new QAction(tr("Mouse latitude"), this);
|
||||||
goHomeAct = new QAction(tr("Go to &Home location"), this);
|
copyMouseLatToClipAct->setStatusTip(tr("Copy the mouse latitude to the clipboard"));
|
||||||
goHomeAct->setShortcut(tr("Ctrl+H"));
|
connect(copyMouseLatToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLatToClipAct_triggered()));
|
||||||
goHomeAct->setStatusTip(tr("Center the map onto the home location"));
|
|
||||||
connect(goHomeAct, SIGNAL(triggered()), this, SLOT(onGoHomeAct_triggered()));
|
copyMouseLonToClipAct = new QAction(tr("Mouse longitude"), this);
|
||||||
|
copyMouseLonToClipAct->setStatusTip(tr("Copy the mouse longitude to the clipboard"));
|
||||||
goUAVAct = new QAction(tr("Go to &UAV location"), this);
|
connect(copyMouseLonToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLonToClipAct_triggered()));
|
||||||
goUAVAct->setShortcut(tr("Ctrl+U"));
|
|
||||||
goUAVAct->setStatusTip(tr("Center the map onto the UAV location"));
|
/*
|
||||||
connect(goUAVAct, SIGNAL(triggered()), this, SLOT(onGoUAVAct_triggered()));
|
findPlaceAct = new QAction(tr("&Find place"), this);
|
||||||
|
findPlaceAct->setShortcut(tr("Ctrl+F"));
|
||||||
followUAVpositionAct = new QAction(tr("Follow UAV position"), this);
|
findPlaceAct->setStatusTip(tr("Find a location"));
|
||||||
followUAVpositionAct->setShortcut(tr("Ctrl+F"));
|
connect(findPlaceAct, SIGNAL(triggered()), this, SLOT(onFindPlaceAct_triggered()));
|
||||||
followUAVpositionAct->setStatusTip(tr("Keep the map centered onto the UAV"));
|
*/
|
||||||
followUAVpositionAct->setCheckable(true);
|
|
||||||
followUAVpositionAct->setChecked(false);
|
showCompassAct = new QAction(tr("Show compass"), this);
|
||||||
connect(followUAVpositionAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVpositionAct_toggled(bool)));
|
showCompassAct->setStatusTip(tr("Show/Hide the compass"));
|
||||||
|
showCompassAct->setCheckable(true);
|
||||||
followUAVheadingAct = new QAction(tr("Follow UAV heading"), this);
|
showCompassAct->setChecked(true);
|
||||||
followUAVheadingAct->setShortcut(tr("Ctrl+F"));
|
connect(showCompassAct, SIGNAL(toggled(bool)), this, SLOT(onShowCompassAct_toggled(bool)));
|
||||||
followUAVheadingAct->setStatusTip(tr("Keep the map rotation to the UAV heading"));
|
|
||||||
followUAVheadingAct->setCheckable(true);
|
showDiagnostics = new QAction(tr("Show Diagnostics"), this);
|
||||||
followUAVheadingAct->setChecked(false);
|
showDiagnostics->setStatusTip(tr("Show/Hide the diagnostics"));
|
||||||
connect(followUAVheadingAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVheadingAct_toggled(bool)));
|
showDiagnostics->setCheckable(true);
|
||||||
|
showDiagnostics->setChecked(false);
|
||||||
/*
|
connect(showDiagnostics, SIGNAL(toggled(bool)), this, SLOT(onShowDiagnostics_toggled(bool)));
|
||||||
TODO: Waypoint support is disabled for v1.0
|
|
||||||
*/
|
showHomeAct = new QAction(tr("Show Home"), this);
|
||||||
|
showHomeAct->setStatusTip(tr("Show/Hide the Home location"));
|
||||||
/*
|
showHomeAct->setCheckable(true);
|
||||||
wayPointEditorAct = new QAction(tr("&Waypoint editor"), this);
|
showHomeAct->setChecked(true);
|
||||||
wayPointEditorAct->setShortcut(tr("Ctrl+W"));
|
connect(showHomeAct, SIGNAL(toggled(bool)), this, SLOT(onShowHomeAct_toggled(bool)));
|
||||||
wayPointEditorAct->setStatusTip(tr("Open the waypoint editor"));
|
|
||||||
wayPointEditorAct->setEnabled(false); // temporary
|
showUAVAct = new QAction(tr("Show UAV"), this);
|
||||||
connect(wayPointEditorAct, SIGNAL(triggered()), this, SLOT(onOpenWayPointEditorAct_triggered()));
|
showUAVAct->setStatusTip(tr("Show/Hide the UAV"));
|
||||||
|
showUAVAct->setCheckable(true);
|
||||||
addWayPointAct = new QAction(tr("&Add waypoint"), this);
|
showUAVAct->setChecked(true);
|
||||||
addWayPointAct->setShortcut(tr("Ctrl+A"));
|
connect(showUAVAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVAct_toggled(bool)));
|
||||||
addWayPointAct->setStatusTip(tr("Add waypoint"));
|
|
||||||
connect(addWayPointAct, SIGNAL(triggered()), this, SLOT(onAddWayPointAct_triggered()));
|
zoomInAct = new QAction(tr("Zoom &In"), this);
|
||||||
|
zoomInAct->setShortcut(Qt::Key_PageUp);
|
||||||
editWayPointAct = new QAction(tr("&Edit waypoint"), this);
|
zoomInAct->setStatusTip(tr("Zoom the map in"));
|
||||||
editWayPointAct->setShortcut(tr("Ctrl+E"));
|
connect(zoomInAct, SIGNAL(triggered()), this, SLOT(onGoZoomInAct_triggered()));
|
||||||
editWayPointAct->setStatusTip(tr("Edit waypoint"));
|
|
||||||
connect(editWayPointAct, SIGNAL(triggered()), this, SLOT(onEditWayPointAct_triggered()));
|
zoomOutAct = new QAction(tr("Zoom &Out"), this);
|
||||||
|
zoomOutAct->setShortcut(Qt::Key_PageDown);
|
||||||
lockWayPointAct = new QAction(tr("&Lock waypoint"), this);
|
zoomOutAct->setStatusTip(tr("Zoom the map out"));
|
||||||
lockWayPointAct->setStatusTip(tr("Lock/Unlock a waypoint"));
|
connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(onGoZoomOutAct_triggered()));
|
||||||
lockWayPointAct->setCheckable(true);
|
|
||||||
lockWayPointAct->setChecked(false);
|
goMouseClickAct = new QAction(tr("Go to where you right clicked the mouse"), this);
|
||||||
connect(lockWayPointAct, SIGNAL(triggered()), this, SLOT(onLockWayPointAct_triggered()));
|
goMouseClickAct->setStatusTip(tr("Center the map onto where you right clicked the mouse"));
|
||||||
|
connect(goMouseClickAct, SIGNAL(triggered()), this, SLOT(onGoMouseClickAct_triggered()));
|
||||||
deleteWayPointAct = new QAction(tr("&Delete waypoint"), this);
|
|
||||||
deleteWayPointAct->setShortcut(tr("Ctrl+D"));
|
setHomeAct = new QAction(tr("Set the home location"), this);
|
||||||
deleteWayPointAct->setStatusTip(tr("Delete waypoint"));
|
setHomeAct->setStatusTip(tr("Set the home location to where you clicked"));
|
||||||
connect(deleteWayPointAct, SIGNAL(triggered()), this, SLOT(onDeleteWayPointAct_triggered()));
|
#if !defined(allow_manual_home_location_move)
|
||||||
|
setHomeAct->setEnabled(false);
|
||||||
clearWayPointsAct = new QAction(tr("&Clear waypoints"), this);
|
#endif
|
||||||
clearWayPointsAct->setShortcut(tr("Ctrl+C"));
|
connect(setHomeAct, SIGNAL(triggered()), this, SLOT(onSetHomeAct_triggered()));
|
||||||
clearWayPointsAct->setStatusTip(tr("Clear waypoints"));
|
|
||||||
connect(clearWayPointsAct, SIGNAL(triggered()), this, SLOT(onClearWayPointsAct_triggered()));
|
goHomeAct = new QAction(tr("Go to &Home location"), this);
|
||||||
*/
|
goHomeAct->setShortcut(tr("Ctrl+H"));
|
||||||
|
goHomeAct->setStatusTip(tr("Center the map onto the home location"));
|
||||||
homeMagicWaypointAct = new QAction(tr("Home magic waypoint"), this);
|
connect(goHomeAct, SIGNAL(triggered()), this, SLOT(onGoHomeAct_triggered()));
|
||||||
homeMagicWaypointAct->setStatusTip(tr("Move the magic waypoint to the home position"));
|
|
||||||
connect(homeMagicWaypointAct, SIGNAL(triggered()), this, SLOT(onHomeMagicWaypointAct_triggered()));
|
goUAVAct = new QAction(tr("Go to &UAV location"), this);
|
||||||
|
goUAVAct->setShortcut(tr("Ctrl+U"));
|
||||||
mapModeActGroup = new QActionGroup(this);
|
goUAVAct->setStatusTip(tr("Center the map onto the UAV location"));
|
||||||
connect(mapModeActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onMapModeActGroup_triggered(QAction *)));
|
connect(goUAVAct, SIGNAL(triggered()), this, SLOT(onGoUAVAct_triggered()));
|
||||||
mapModeAct.clear();
|
|
||||||
{
|
followUAVpositionAct = new QAction(tr("Follow UAV position"), this);
|
||||||
QAction *map_mode_act;
|
followUAVpositionAct->setShortcut(tr("Ctrl+F"));
|
||||||
|
followUAVpositionAct->setStatusTip(tr("Keep the map centered onto the UAV"));
|
||||||
map_mode_act = new QAction(tr("Normal"), mapModeActGroup);
|
followUAVpositionAct->setCheckable(true);
|
||||||
map_mode_act->setCheckable(true);
|
followUAVpositionAct->setChecked(false);
|
||||||
map_mode_act->setChecked(m_map_mode == Normal_MapMode);
|
connect(followUAVpositionAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVpositionAct_toggled(bool)));
|
||||||
map_mode_act->setData((int)Normal_MapMode);
|
|
||||||
mapModeAct.append(map_mode_act);
|
followUAVheadingAct = new QAction(tr("Follow UAV heading"), this);
|
||||||
|
followUAVheadingAct->setShortcut(tr("Ctrl+F"));
|
||||||
map_mode_act = new QAction(tr("Magic Waypoint"), mapModeActGroup);
|
followUAVheadingAct->setStatusTip(tr("Keep the map rotation to the UAV heading"));
|
||||||
map_mode_act->setCheckable(true);
|
followUAVheadingAct->setCheckable(true);
|
||||||
map_mode_act->setChecked(m_map_mode == MagicWaypoint_MapMode);
|
followUAVheadingAct->setChecked(false);
|
||||||
map_mode_act->setData((int)MagicWaypoint_MapMode);
|
connect(followUAVheadingAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVheadingAct_toggled(bool)));
|
||||||
mapModeAct.append(map_mode_act);
|
|
||||||
}
|
/*
|
||||||
|
TODO: Waypoint support is disabled for v1.0
|
||||||
zoomActGroup = new QActionGroup(this);
|
*/
|
||||||
connect(zoomActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onZoomActGroup_triggered(QAction *)));
|
|
||||||
zoomAct.clear();
|
/*
|
||||||
for (int i = min_zoom; i <= max_zoom; i++)
|
wayPointEditorAct = new QAction(tr("&Waypoint editor"), this);
|
||||||
{
|
wayPointEditorAct->setShortcut(tr("Ctrl+W"));
|
||||||
QAction *zoom_act = new QAction(QString::number(i), zoomActGroup);
|
wayPointEditorAct->setStatusTip(tr("Open the waypoint editor"));
|
||||||
zoom_act->setCheckable(true);
|
wayPointEditorAct->setEnabled(false); // temporary
|
||||||
zoom_act->setData(i);
|
connect(wayPointEditorAct, SIGNAL(triggered()), this, SLOT(onOpenWayPointEditorAct_triggered()));
|
||||||
zoomAct.append(zoom_act);
|
|
||||||
}
|
addWayPointAct = new QAction(tr("&Add waypoint"), this);
|
||||||
|
addWayPointAct->setShortcut(tr("Ctrl+A"));
|
||||||
// *****
|
addWayPointAct->setStatusTip(tr("Add waypoint"));
|
||||||
// safe area
|
connect(addWayPointAct, SIGNAL(triggered()), this, SLOT(onAddWayPointAct_triggered()));
|
||||||
|
|
||||||
showSafeAreaAct = new QAction(tr("Show Safe Area"), this);
|
editWayPointAct = new QAction(tr("&Edit waypoint"), this);
|
||||||
showSafeAreaAct->setStatusTip(tr("Show/Hide the Safe Area around the home location"));
|
editWayPointAct->setShortcut(tr("Ctrl+E"));
|
||||||
showSafeAreaAct->setCheckable(true);
|
editWayPointAct->setStatusTip(tr("Edit waypoint"));
|
||||||
showSafeAreaAct->setChecked(m_map->Home->ShowSafeArea());
|
connect(editWayPointAct, SIGNAL(triggered()), this, SLOT(onEditWayPointAct_triggered()));
|
||||||
connect(showSafeAreaAct, SIGNAL(toggled(bool)), this, SLOT(onShowSafeAreaAct_toggled(bool)));
|
|
||||||
|
lockWayPointAct = new QAction(tr("&Lock waypoint"), this);
|
||||||
safeAreaActGroup = new QActionGroup(this);
|
lockWayPointAct->setStatusTip(tr("Lock/Unlock a waypoint"));
|
||||||
connect(safeAreaActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onSafeAreaActGroup_triggered(QAction *)));
|
lockWayPointAct->setCheckable(true);
|
||||||
safeAreaAct.clear();
|
lockWayPointAct->setChecked(false);
|
||||||
for (int i = 0; i < (int)(sizeof(safe_area_radius_list) / sizeof(safe_area_radius_list[0])); i++)
|
connect(lockWayPointAct, SIGNAL(triggered()), this, SLOT(onLockWayPointAct_triggered()));
|
||||||
{
|
|
||||||
int safeArea = safe_area_radius_list[i];
|
deleteWayPointAct = new QAction(tr("&Delete waypoint"), this);
|
||||||
QAction *safeArea_act = new QAction(QString::number(safeArea) + "m", safeAreaActGroup);
|
deleteWayPointAct->setShortcut(tr("Ctrl+D"));
|
||||||
safeArea_act->setCheckable(true);
|
deleteWayPointAct->setStatusTip(tr("Delete waypoint"));
|
||||||
safeArea_act->setChecked(safeArea == m_map->Home->SafeArea());
|
connect(deleteWayPointAct, SIGNAL(triggered()), this, SLOT(onDeleteWayPointAct_triggered()));
|
||||||
safeArea_act->setData(safeArea);
|
|
||||||
safeAreaAct.append(safeArea_act);
|
clearWayPointsAct = new QAction(tr("&Clear waypoints"), this);
|
||||||
}
|
clearWayPointsAct->setShortcut(tr("Ctrl+C"));
|
||||||
|
clearWayPointsAct->setStatusTip(tr("Clear waypoints"));
|
||||||
// *****
|
connect(clearWayPointsAct, SIGNAL(triggered()), this, SLOT(onClearWayPointsAct_triggered()));
|
||||||
// UAV trail
|
*/
|
||||||
|
|
||||||
uavTrailTypeActGroup = new QActionGroup(this);
|
homeMagicWaypointAct = new QAction(tr("Home magic waypoint"), this);
|
||||||
connect(uavTrailTypeActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onUAVTrailTypeActGroup_triggered(QAction *)));
|
homeMagicWaypointAct->setStatusTip(tr("Move the magic waypoint to the home position"));
|
||||||
uavTrailTypeAct.clear();
|
connect(homeMagicWaypointAct, SIGNAL(triggered()), this, SLOT(onHomeMagicWaypointAct_triggered()));
|
||||||
QStringList uav_trail_type_list = mapcontrol::Helper::UAVTrailTypes();
|
|
||||||
for (int i = 0; i < uav_trail_type_list.count(); i++)
|
mapModeActGroup = new QActionGroup(this);
|
||||||
{
|
connect(mapModeActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onMapModeActGroup_triggered(QAction *)));
|
||||||
mapcontrol::UAVTrailType::Types uav_trail_type = mapcontrol::Helper::UAVTrailTypeFromString(uav_trail_type_list[i]);
|
mapModeAct.clear();
|
||||||
QAction *uavTrailType_act = new QAction(mapcontrol::Helper::StrFromUAVTrailType(uav_trail_type), uavTrailTypeActGroup);
|
{
|
||||||
uavTrailType_act->setCheckable(true);
|
QAction *map_mode_act;
|
||||||
uavTrailType_act->setChecked(uav_trail_type == m_map->UAV->GetTrailType());
|
|
||||||
uavTrailType_act->setData(i);
|
map_mode_act = new QAction(tr("Normal"), mapModeActGroup);
|
||||||
uavTrailTypeAct.append(uavTrailType_act);
|
map_mode_act->setCheckable(true);
|
||||||
}
|
map_mode_act->setChecked(m_map_mode == Normal_MapMode);
|
||||||
|
map_mode_act->setData((int)Normal_MapMode);
|
||||||
showTrailAct = new QAction(tr("Show Trail dots"), this);
|
mapModeAct.append(map_mode_act);
|
||||||
showTrailAct->setStatusTip(tr("Show/Hide the Trail dots"));
|
|
||||||
showTrailAct->setCheckable(true);
|
map_mode_act = new QAction(tr("Magic Waypoint"), mapModeActGroup);
|
||||||
showTrailAct->setChecked(true);
|
map_mode_act->setCheckable(true);
|
||||||
connect(showTrailAct, SIGNAL(toggled(bool)), this, SLOT(onShowTrailAct_toggled(bool)));
|
map_mode_act->setChecked(m_map_mode == MagicWaypoint_MapMode);
|
||||||
|
map_mode_act->setData((int)MagicWaypoint_MapMode);
|
||||||
showTrailLineAct = new QAction(tr("Show Trail lines"), this);
|
mapModeAct.append(map_mode_act);
|
||||||
showTrailLineAct->setStatusTip(tr("Show/Hide the Trail lines"));
|
}
|
||||||
showTrailLineAct->setCheckable(true);
|
|
||||||
showTrailLineAct->setChecked(true);
|
zoomActGroup = new QActionGroup(this);
|
||||||
connect(showTrailLineAct, SIGNAL(toggled(bool)), this, SLOT(onShowTrailLineAct_toggled(bool)));
|
connect(zoomActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onZoomActGroup_triggered(QAction *)));
|
||||||
|
zoomAct.clear();
|
||||||
clearUAVtrailAct = new QAction(tr("Clear UAV trail"), this);
|
for (int i = m_min_zoom; i <= m_max_zoom; i++)
|
||||||
clearUAVtrailAct->setStatusTip(tr("Clear the UAV trail"));
|
{
|
||||||
connect(clearUAVtrailAct, SIGNAL(triggered()), this, SLOT(onClearUAVtrailAct_triggered()));
|
QAction *zoom_act = new QAction(QString::number(i), zoomActGroup);
|
||||||
|
zoom_act->setCheckable(true);
|
||||||
uavTrailTimeActGroup = new QActionGroup(this);
|
zoom_act->setData(i);
|
||||||
connect(uavTrailTimeActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onUAVTrailTimeActGroup_triggered(QAction *)));
|
zoomAct.append(zoom_act);
|
||||||
uavTrailTimeAct.clear();
|
}
|
||||||
for (int i = 0; i < (int)(sizeof(uav_trail_time_list) / sizeof(uav_trail_time_list[0])); i++)
|
|
||||||
{
|
maxUpdateRateActGroup = new QActionGroup(this);
|
||||||
int uav_trail_time = uav_trail_time_list[i];
|
connect(maxUpdateRateActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onMaxUpdateRateActGroup_triggered(QAction *)));
|
||||||
QAction *uavTrailTime_act = new QAction(QString::number(uav_trail_time) + " sec", uavTrailTimeActGroup);
|
maxUpdateRateAct.clear();
|
||||||
uavTrailTime_act->setCheckable(true);
|
list_size = sizeof(max_update_rate_list) / sizeof(max_update_rate_list[0]);
|
||||||
uavTrailTime_act->setChecked(uav_trail_time == m_map->UAV->TrailTime());
|
for (int i = 0; i < list_size; i++)
|
||||||
uavTrailTime_act->setData(uav_trail_time);
|
{
|
||||||
uavTrailTimeAct.append(uavTrailTime_act);
|
QAction *maxUpdateRate_act;
|
||||||
}
|
int j = max_update_rate_list[i];
|
||||||
|
maxUpdateRate_act = new QAction(QString::number(j), maxUpdateRateActGroup);
|
||||||
uavTrailDistanceActGroup = new QActionGroup(this);
|
maxUpdateRate_act->setCheckable(true);
|
||||||
connect(uavTrailDistanceActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onUAVTrailDistanceActGroup_triggered(QAction *)));
|
maxUpdateRate_act->setData(j);
|
||||||
uavTrailDistanceAct.clear();
|
maxUpdateRate_act->setChecked(j == m_maxUpdateRate);
|
||||||
for (int i = 0; i < (int)(sizeof(uav_trail_distance_list) / sizeof(uav_trail_distance_list[0])); i++)
|
maxUpdateRateAct.append(maxUpdateRate_act);
|
||||||
{
|
}
|
||||||
int uav_trail_distance = uav_trail_distance_list[i];
|
|
||||||
QAction *uavTrailDistance_act = new QAction(QString::number(uav_trail_distance) + " meters", uavTrailDistanceActGroup);
|
// *****
|
||||||
uavTrailDistance_act->setCheckable(true);
|
// safe area
|
||||||
uavTrailDistance_act->setChecked(uav_trail_distance == m_map->UAV->TrailDistance());
|
|
||||||
uavTrailDistance_act->setData(uav_trail_distance);
|
showSafeAreaAct = new QAction(tr("Show Safe Area"), this);
|
||||||
uavTrailDistanceAct.append(uavTrailDistance_act);
|
showSafeAreaAct->setStatusTip(tr("Show/Hide the Safe Area around the home location"));
|
||||||
}
|
showSafeAreaAct->setCheckable(true);
|
||||||
|
showSafeAreaAct->setChecked(m_map->Home->ShowSafeArea());
|
||||||
// *****
|
connect(showSafeAreaAct, SIGNAL(toggled(bool)), this, SLOT(onShowSafeAreaAct_toggled(bool)));
|
||||||
|
|
||||||
// ***********************
|
safeAreaActGroup = new QActionGroup(this);
|
||||||
}
|
connect(safeAreaActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onSafeAreaActGroup_triggered(QAction *)));
|
||||||
|
safeAreaAct.clear();
|
||||||
void OPMapGadgetWidget::onReloadAct_triggered()
|
list_size = sizeof(safe_area_radius_list) / sizeof(safe_area_radius_list[0]);
|
||||||
{
|
for (int i = 0; i < list_size; i++)
|
||||||
if (!m_widget || !m_map)
|
{
|
||||||
return;
|
int safeArea = safe_area_radius_list[i];
|
||||||
|
QAction *safeArea_act = new QAction(QString::number(safeArea) + "m", safeAreaActGroup);
|
||||||
m_map->ReloadMap();
|
safeArea_act->setCheckable(true);
|
||||||
}
|
safeArea_act->setChecked(safeArea == m_map->Home->SafeArea());
|
||||||
|
safeArea_act->setData(safeArea);
|
||||||
void OPMapGadgetWidget::onCopyMouseLatLonToClipAct_triggered()
|
safeAreaAct.append(safeArea_act);
|
||||||
{
|
}
|
||||||
// QClipboard *clipboard = qApp->clipboard();
|
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
// *****
|
||||||
clipboard->setText(QString::number(context_menu_lat_lon.Lat(), 'f', 7) + ", " + QString::number(context_menu_lat_lon.Lng(), 'f', 7), QClipboard::Clipboard);
|
// UAV trail
|
||||||
}
|
|
||||||
|
uavTrailTypeActGroup = new QActionGroup(this);
|
||||||
void OPMapGadgetWidget::onCopyMouseLatToClipAct_triggered()
|
connect(uavTrailTypeActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onUAVTrailTypeActGroup_triggered(QAction *)));
|
||||||
{
|
uavTrailTypeAct.clear();
|
||||||
// QClipboard *clipboard = qApp->clipboard();
|
QStringList uav_trail_type_list = mapcontrol::Helper::UAVTrailTypes();
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
for (int i = 0; i < uav_trail_type_list.count(); i++)
|
||||||
clipboard->setText(QString::number(context_menu_lat_lon.Lat(), 'f', 7), QClipboard::Clipboard);
|
{
|
||||||
}
|
mapcontrol::UAVTrailType::Types uav_trail_type = mapcontrol::Helper::UAVTrailTypeFromString(uav_trail_type_list[i]);
|
||||||
|
QAction *uavTrailType_act = new QAction(mapcontrol::Helper::StrFromUAVTrailType(uav_trail_type), uavTrailTypeActGroup);
|
||||||
void OPMapGadgetWidget::onCopyMouseLonToClipAct_triggered()
|
uavTrailType_act->setCheckable(true);
|
||||||
{
|
uavTrailType_act->setChecked(uav_trail_type == m_map->UAV->GetTrailType());
|
||||||
// QClipboard *clipboard = qApp->clipboard();
|
uavTrailType_act->setData(i);
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
uavTrailTypeAct.append(uavTrailType_act);
|
||||||
clipboard->setText(QString::number(context_menu_lat_lon.Lng(), 'f', 7), QClipboard::Clipboard);
|
}
|
||||||
}
|
|
||||||
|
showTrailAct = new QAction(tr("Show Trail dots"), this);
|
||||||
|
showTrailAct->setStatusTip(tr("Show/Hide the Trail dots"));
|
||||||
void OPMapGadgetWidget::onShowCompassAct_toggled(bool show)
|
showTrailAct->setCheckable(true);
|
||||||
{
|
showTrailAct->setChecked(true);
|
||||||
if (!m_widget || !m_map)
|
connect(showTrailAct, SIGNAL(toggled(bool)), this, SLOT(onShowTrailAct_toggled(bool)));
|
||||||
return;
|
|
||||||
|
showTrailLineAct = new QAction(tr("Show Trail lines"), this);
|
||||||
m_map->SetShowCompass(show);
|
showTrailLineAct->setStatusTip(tr("Show/Hide the Trail lines"));
|
||||||
}
|
showTrailLineAct->setCheckable(true);
|
||||||
|
showTrailLineAct->setChecked(true);
|
||||||
void OPMapGadgetWidget::onShowDiagnostics_toggled(bool show)
|
connect(showTrailLineAct, SIGNAL(toggled(bool)), this, SLOT(onShowTrailLineAct_toggled(bool)));
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
clearUAVtrailAct = new QAction(tr("Clear UAV trail"), this);
|
||||||
return;
|
clearUAVtrailAct->setStatusTip(tr("Clear the UAV trail"));
|
||||||
|
connect(clearUAVtrailAct, SIGNAL(triggered()), this, SLOT(onClearUAVtrailAct_triggered()));
|
||||||
m_map->SetShowDiagnostics(show);
|
|
||||||
}
|
uavTrailTimeActGroup = new QActionGroup(this);
|
||||||
|
connect(uavTrailTimeActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onUAVTrailTimeActGroup_triggered(QAction *)));
|
||||||
void OPMapGadgetWidget::onShowHomeAct_toggled(bool show)
|
uavTrailTimeAct.clear();
|
||||||
{
|
list_size = sizeof(uav_trail_time_list) / sizeof(uav_trail_time_list[0]);
|
||||||
if (!m_widget || !m_map)
|
for (int i = 0; i < list_size; i++)
|
||||||
return;
|
{
|
||||||
|
int uav_trail_time = uav_trail_time_list[i];
|
||||||
m_map->Home->setVisible(show);
|
QAction *uavTrailTime_act = new QAction(QString::number(uav_trail_time) + " sec", uavTrailTimeActGroup);
|
||||||
}
|
uavTrailTime_act->setCheckable(true);
|
||||||
|
uavTrailTime_act->setChecked(uav_trail_time == m_map->UAV->TrailTime());
|
||||||
void OPMapGadgetWidget::onShowUAVAct_toggled(bool show)
|
uavTrailTime_act->setData(uav_trail_time);
|
||||||
{
|
uavTrailTimeAct.append(uavTrailTime_act);
|
||||||
if (!m_widget || !m_map)
|
}
|
||||||
return;
|
|
||||||
|
uavTrailDistanceActGroup = new QActionGroup(this);
|
||||||
m_map->UAV->setVisible(show);
|
connect(uavTrailDistanceActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onUAVTrailDistanceActGroup_triggered(QAction *)));
|
||||||
m_map->GPS->setVisible(show);
|
uavTrailDistanceAct.clear();
|
||||||
}
|
list_size = sizeof(uav_trail_distance_list) / sizeof(uav_trail_distance_list[0]);
|
||||||
|
for (int i = 0; i < list_size; i++)
|
||||||
void OPMapGadgetWidget::onShowTrailAct_toggled(bool show)
|
{
|
||||||
{
|
int uav_trail_distance = uav_trail_distance_list[i];
|
||||||
if (!m_widget || !m_map)
|
QAction *uavTrailDistance_act = new QAction(QString::number(uav_trail_distance) + " meters", uavTrailDistanceActGroup);
|
||||||
return;
|
uavTrailDistance_act->setCheckable(true);
|
||||||
|
uavTrailDistance_act->setChecked(uav_trail_distance == m_map->UAV->TrailDistance());
|
||||||
m_map->UAV->SetShowTrail(show);
|
uavTrailDistance_act->setData(uav_trail_distance);
|
||||||
m_map->GPS->SetShowTrail(show);
|
uavTrailDistanceAct.append(uavTrailDistance_act);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OPMapGadgetWidget::onShowTrailLineAct_toggled(bool show)
|
// *****
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
// ***********************
|
||||||
return;
|
}
|
||||||
|
|
||||||
m_map->UAV->SetShowTrailLine(show);
|
void OPMapGadgetWidget::onReloadAct_triggered()
|
||||||
m_map->GPS->SetShowTrailLine(show);
|
{
|
||||||
}
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
void OPMapGadgetWidget::onMapModeActGroup_triggered(QAction *action)
|
|
||||||
{
|
m_map->ReloadMap();
|
||||||
if (!m_widget || !m_map || !action)
|
}
|
||||||
return;
|
|
||||||
|
void OPMapGadgetWidget::onCopyMouseLatLonToClipAct_triggered()
|
||||||
opMapModeType mode = (opMapModeType)action->data().toInt();
|
{
|
||||||
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
setMapMode(mode);
|
clipboard->setText(QString::number(m_context_menu_lat_lon.Lat(), 'f', 7) + ", " + QString::number(m_context_menu_lat_lon.Lng(), 'f', 7), QClipboard::Clipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OPMapGadgetWidget::onGoZoomInAct_triggered()
|
void OPMapGadgetWidget::onCopyMouseLatToClipAct_triggered()
|
||||||
{
|
{
|
||||||
zoomIn();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
}
|
clipboard->setText(QString::number(m_context_menu_lat_lon.Lat(), 'f', 7), QClipboard::Clipboard);
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::onGoZoomOutAct_triggered()
|
|
||||||
{
|
void OPMapGadgetWidget::onCopyMouseLonToClipAct_triggered()
|
||||||
zoomOut();
|
{
|
||||||
}
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
clipboard->setText(QString::number(m_context_menu_lat_lon.Lng(), 'f', 7), QClipboard::Clipboard);
|
||||||
void OPMapGadgetWidget::onZoomActGroup_triggered(QAction *action)
|
}
|
||||||
{
|
|
||||||
if (!m_widget || !action)
|
|
||||||
return;
|
void OPMapGadgetWidget::onShowCompassAct_toggled(bool show)
|
||||||
|
{
|
||||||
setZoom(action->data().toInt());
|
if (!m_widget || !m_map)
|
||||||
}
|
return;
|
||||||
|
|
||||||
void OPMapGadgetWidget::onGoMouseClickAct_triggered()
|
m_map->SetShowCompass(show);
|
||||||
{
|
}
|
||||||
if (!m_widget || !m_map)
|
|
||||||
return;
|
void OPMapGadgetWidget::onShowDiagnostics_toggled(bool show)
|
||||||
|
{
|
||||||
m_map->SetCurrentPosition(m_map->currentMousePosition()); // center the map onto the mouse position
|
if (!m_widget || !m_map)
|
||||||
}
|
return;
|
||||||
|
|
||||||
void OPMapGadgetWidget::onSetHomeAct_triggered()
|
m_map->SetShowDiagnostics(show);
|
||||||
{
|
}
|
||||||
if (!m_widget || !m_map)
|
|
||||||
return;
|
void OPMapGadgetWidget::onShowHomeAct_toggled(bool show)
|
||||||
|
{
|
||||||
setHome(context_menu_lat_lon);
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
setHomeLocationObject(); // update the HomeLocation UAVObject
|
|
||||||
}
|
m_map->Home->setVisible(show);
|
||||||
|
}
|
||||||
void OPMapGadgetWidget::onGoHomeAct_triggered()
|
|
||||||
{
|
void OPMapGadgetWidget::onShowUAVAct_toggled(bool show)
|
||||||
if (!m_widget || !m_map)
|
{
|
||||||
return;
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
goHome();
|
|
||||||
}
|
m_map->UAV->setVisible(show);
|
||||||
|
m_map->GPS->setVisible(show);
|
||||||
void OPMapGadgetWidget::onGoUAVAct_triggered()
|
}
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
void OPMapGadgetWidget::onShowTrailAct_toggled(bool show)
|
||||||
return;
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
double latitude;
|
return;
|
||||||
double longitude;
|
|
||||||
double altitude;
|
m_map->UAV->SetShowTrail(show);
|
||||||
if (getUAVPosition(latitude, longitude, altitude)) // get current UAV position
|
m_map->GPS->SetShowTrail(show);
|
||||||
{
|
}
|
||||||
internals::PointLatLng uav_pos = internals::PointLatLng(latitude, longitude); // current UAV position
|
|
||||||
internals::PointLatLng map_pos = m_map->CurrentPosition(); // current MAP position
|
void OPMapGadgetWidget::onShowTrailLineAct_toggled(bool show)
|
||||||
if (map_pos != uav_pos) m_map->SetCurrentPosition(uav_pos); // center the map onto the UAV
|
{
|
||||||
}
|
if (!m_widget || !m_map)
|
||||||
}
|
return;
|
||||||
|
|
||||||
void OPMapGadgetWidget::onFollowUAVpositionAct_toggled(bool checked)
|
m_map->UAV->SetShowTrailLine(show);
|
||||||
{
|
m_map->GPS->SetShowTrailLine(show);
|
||||||
if (!m_widget || !m_map)
|
}
|
||||||
return;
|
|
||||||
|
void OPMapGadgetWidget::onMapModeActGroup_triggered(QAction *action)
|
||||||
if (m_widget->toolButtonMapUAV->isChecked() != checked)
|
{
|
||||||
m_widget->toolButtonMapUAV->setChecked(checked);
|
if (!m_widget || !m_map || !action)
|
||||||
|
return;
|
||||||
setMapFollowingMode();
|
|
||||||
}
|
opMapModeType mode = (opMapModeType)action->data().toInt();
|
||||||
|
|
||||||
void OPMapGadgetWidget::onFollowUAVheadingAct_toggled(bool checked)
|
setMapMode(mode);
|
||||||
{
|
}
|
||||||
if (!m_widget || !m_map)
|
|
||||||
return;
|
void OPMapGadgetWidget::onGoZoomInAct_triggered()
|
||||||
|
{
|
||||||
if (m_widget->toolButtonMapUAVheading->isChecked() != checked)
|
zoomIn();
|
||||||
m_widget->toolButtonMapUAVheading->setChecked(checked);
|
}
|
||||||
|
|
||||||
setMapFollowingMode();
|
void OPMapGadgetWidget::onGoZoomOutAct_triggered()
|
||||||
}
|
{
|
||||||
|
zoomOut();
|
||||||
void OPMapGadgetWidget::onUAVTrailTypeActGroup_triggered(QAction *action)
|
}
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
void OPMapGadgetWidget::onZoomActGroup_triggered(QAction *action)
|
||||||
return;
|
{
|
||||||
|
if (!m_widget || !m_map || !action)
|
||||||
int trail_type_idx = action->data().toInt();
|
return;
|
||||||
|
|
||||||
QStringList uav_trail_type_list = mapcontrol::Helper::UAVTrailTypes();
|
setZoom(action->data().toInt());
|
||||||
mapcontrol::UAVTrailType::Types uav_trail_type = mapcontrol::Helper::UAVTrailTypeFromString(uav_trail_type_list[trail_type_idx]);
|
}
|
||||||
|
|
||||||
m_map->UAV->SetTrailType(uav_trail_type);
|
void OPMapGadgetWidget::onMaxUpdateRateActGroup_triggered(QAction *action)
|
||||||
}
|
{
|
||||||
|
if (!m_widget || !m_map || !action)
|
||||||
void OPMapGadgetWidget::onClearUAVtrailAct_triggered()
|
return;
|
||||||
{
|
|
||||||
if (!m_widget || !m_map)
|
setMaxUpdateRate(action->data().toInt());
|
||||||
return;
|
}
|
||||||
|
|
||||||
m_map->UAV->DeleteTrail();
|
void OPMapGadgetWidget::onGoMouseClickAct_triggered()
|
||||||
m_map->GPS->DeleteTrail();
|
{
|
||||||
}
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
void OPMapGadgetWidget::onUAVTrailTimeActGroup_triggered(QAction *action)
|
|
||||||
{
|
m_map->SetCurrentPosition(m_map->currentMousePosition()); // center the map onto the mouse position
|
||||||
if (!m_widget || !m_map)
|
}
|
||||||
return;
|
|
||||||
|
void OPMapGadgetWidget::onSetHomeAct_triggered()
|
||||||
int trail_time = (double)action->data().toInt();
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
m_map->UAV->SetTrailTime(trail_time);
|
return;
|
||||||
}
|
|
||||||
|
setHome(m_context_menu_lat_lon);
|
||||||
void OPMapGadgetWidget::onUAVTrailDistanceActGroup_triggered(QAction *action)
|
|
||||||
{
|
setHomeLocationObject(); // update the HomeLocation UAVObject
|
||||||
if (!m_widget || !m_map)
|
}
|
||||||
return;
|
|
||||||
|
void OPMapGadgetWidget::onGoHomeAct_triggered()
|
||||||
int trail_distance = action->data().toInt();
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
m_map->UAV->SetTrailDistance(trail_distance);
|
return;
|
||||||
}
|
|
||||||
|
goHome();
|
||||||
/**
|
}
|
||||||
* TODO: unused for v1.0
|
|
||||||
**/
|
void OPMapGadgetWidget::onGoUAVAct_triggered()
|
||||||
/*
|
{
|
||||||
void OPMapGadgetWidget::onAddWayPointAct_triggered()
|
if (!m_widget || !m_map)
|
||||||
{
|
return;
|
||||||
if (!m_widget || !m_map)
|
|
||||||
return;
|
double latitude;
|
||||||
|
double longitude;
|
||||||
if (m_map_mode != Normal_MapMode)
|
double altitude;
|
||||||
return;
|
if (getUAVPosition(latitude, longitude, altitude)) // get current UAV position
|
||||||
|
{
|
||||||
m_waypoint_list_mutex.lock();
|
internals::PointLatLng uav_pos = internals::PointLatLng(latitude, longitude); // current UAV position
|
||||||
|
internals::PointLatLng map_pos = m_map->CurrentPosition(); // current MAP position
|
||||||
// create a waypoint on the map at the last known mouse position
|
if (map_pos != uav_pos) m_map->SetCurrentPosition(uav_pos); // center the map onto the UAV
|
||||||
t_waypoint *wp = new t_waypoint;
|
}
|
||||||
wp->map_wp_item = NULL;
|
}
|
||||||
wp->coord = context_menu_lat_lon;
|
|
||||||
wp->altitude = 0;
|
void OPMapGadgetWidget::onFollowUAVpositionAct_toggled(bool checked)
|
||||||
wp->description = "";
|
{
|
||||||
wp->locked = false;
|
if (!m_widget || !m_map)
|
||||||
wp->time_seconds = 0;
|
return;
|
||||||
wp->hold_time_seconds = 0;
|
|
||||||
wp->map_wp_item = m_map->WPCreate(wp->coord, wp->altitude, wp->description);
|
if (m_widget->toolButtonMapUAV->isChecked() != checked)
|
||||||
|
m_widget->toolButtonMapUAV->setChecked(checked);
|
||||||
wp->map_wp_item->setZValue(10 + wp->map_wp_item->Number());
|
|
||||||
|
setMapFollowingMode();
|
||||||
wp->map_wp_item->setFlag(QGraphicsItem::ItemIsMovable, !wp->locked);
|
}
|
||||||
|
|
||||||
if (wp->map_wp_item)
|
void OPMapGadgetWidget::onFollowUAVheadingAct_toggled(bool checked)
|
||||||
{
|
{
|
||||||
if (!wp->locked)
|
if (!m_widget || !m_map)
|
||||||
wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png"));
|
return;
|
||||||
else
|
|
||||||
wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker2.png"));
|
if (m_widget->toolButtonMapUAVheading->isChecked() != checked)
|
||||||
wp->map_wp_item->update();
|
m_widget->toolButtonMapUAVheading->setChecked(checked);
|
||||||
}
|
|
||||||
|
setMapFollowingMode();
|
||||||
// and remember it in our own local waypoint list
|
}
|
||||||
m_waypoint_list.append(wp);
|
|
||||||
|
void OPMapGadgetWidget::onUAVTrailTypeActGroup_triggered(QAction *action)
|
||||||
m_waypoint_list_mutex.unlock();
|
{
|
||||||
}
|
if (!m_widget || !m_map || !action)
|
||||||
*/
|
return;
|
||||||
|
|
||||||
/**
|
int trail_type_idx = action->data().toInt();
|
||||||
* Called when the user asks to edit a waypoint from the map
|
|
||||||
*
|
QStringList uav_trail_type_list = mapcontrol::Helper::UAVTrailTypes();
|
||||||
* TODO: should open an interface to edit waypoint properties, or
|
mapcontrol::UAVTrailType::Types uav_trail_type = mapcontrol::Helper::UAVTrailTypeFromString(uav_trail_type_list[trail_type_idx]);
|
||||||
* propagate the signal to a specific WP plugin (tbd).
|
|
||||||
**/
|
m_map->UAV->SetTrailType(uav_trail_type);
|
||||||
/*
|
}
|
||||||
void OPMapGadgetWidget::onEditWayPointAct_triggered()
|
|
||||||
{
|
void OPMapGadgetWidget::onClearUAVtrailAct_triggered()
|
||||||
if (!m_widget || !m_map)
|
{
|
||||||
return;
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
if (m_map_mode != Normal_MapMode)
|
|
||||||
return;
|
m_map->UAV->DeleteTrail();
|
||||||
|
m_map->GPS->DeleteTrail();
|
||||||
if (!m_mouse_waypoint)
|
}
|
||||||
return;
|
|
||||||
|
void OPMapGadgetWidget::onUAVTrailTimeActGroup_triggered(QAction *action)
|
||||||
//waypoint_edit_dialog.editWaypoint(m_mouse_waypoint);
|
{
|
||||||
|
if (!m_widget || !m_map || !action)
|
||||||
m_mouse_waypoint = NULL;
|
return;
|
||||||
}
|
|
||||||
*/
|
int trail_time = (double)action->data().toInt();
|
||||||
|
|
||||||
/**
|
m_map->UAV->SetTrailTime(trail_time);
|
||||||
* TODO: unused for v1.0
|
}
|
||||||
*/
|
|
||||||
/*
|
void OPMapGadgetWidget::onUAVTrailDistanceActGroup_triggered(QAction *action)
|
||||||
void OPMapGadgetWidget::onLockWayPointAct_triggered()
|
{
|
||||||
{
|
if (!m_widget || !m_map || !action)
|
||||||
if (!m_widget || !m_map || !m_mouse_waypoint)
|
return;
|
||||||
return;
|
|
||||||
|
int trail_distance = action->data().toInt();
|
||||||
if (m_map_mode != Normal_MapMode)
|
|
||||||
return;
|
m_map->UAV->SetTrailDistance(trail_distance);
|
||||||
|
}
|
||||||
bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0;
|
|
||||||
m_mouse_waypoint->setFlag(QGraphicsItem::ItemIsMovable, locked);
|
/**
|
||||||
|
* TODO: unused for v1.0
|
||||||
if (!locked)
|
**/
|
||||||
m_mouse_waypoint->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker2.png"));
|
/*
|
||||||
else
|
void OPMapGadgetWidget::onAddWayPointAct_triggered()
|
||||||
m_mouse_waypoint->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png"));
|
{
|
||||||
m_mouse_waypoint->update();
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
m_mouse_waypoint = NULL;
|
|
||||||
}
|
if (m_map_mode != Normal_MapMode)
|
||||||
*/
|
return;
|
||||||
|
|
||||||
/**
|
m_waypoint_list_mutex.lock();
|
||||||
* TODO: unused for v1.0
|
|
||||||
*/
|
// create a waypoint on the map at the last known mouse position
|
||||||
/*
|
t_waypoint *wp = new t_waypoint;
|
||||||
void OPMapGadgetWidget::onDeleteWayPointAct_triggered()
|
wp->map_wp_item = NULL;
|
||||||
{
|
wp->coord = context_menu_lat_lon;
|
||||||
if (!m_widget || !m_map)
|
wp->altitude = 0;
|
||||||
return;
|
wp->description = "";
|
||||||
|
wp->locked = false;
|
||||||
if (m_map_mode != Normal_MapMode)
|
wp->time_seconds = 0;
|
||||||
return;
|
wp->hold_time_seconds = 0;
|
||||||
|
wp->map_wp_item = m_map->WPCreate(wp->coord, wp->altitude, wp->description);
|
||||||
if (!m_mouse_waypoint)
|
|
||||||
return;
|
wp->map_wp_item->setZValue(10 + wp->map_wp_item->Number());
|
||||||
|
|
||||||
bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0;
|
wp->map_wp_item->setFlag(QGraphicsItem::ItemIsMovable, !wp->locked);
|
||||||
|
|
||||||
if (locked) return; // waypoint is locked
|
if (wp->map_wp_item)
|
||||||
|
{
|
||||||
QMutexLocker locker(&m_waypoint_list_mutex);
|
if (!wp->locked)
|
||||||
|
wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png"));
|
||||||
for (int i = 0; i < m_waypoint_list.count(); i++)
|
else
|
||||||
{
|
wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker2.png"));
|
||||||
t_waypoint *wp = m_waypoint_list.at(i);
|
wp->map_wp_item->update();
|
||||||
if (!wp) continue;
|
}
|
||||||
if (!wp->map_wp_item || wp->map_wp_item != m_mouse_waypoint) continue;
|
|
||||||
|
// and remember it in our own local waypoint list
|
||||||
// delete the waypoint from the map
|
m_waypoint_list.append(wp);
|
||||||
m_map->WPDelete(wp->map_wp_item);
|
|
||||||
|
m_waypoint_list_mutex.unlock();
|
||||||
// delete the waypoint from our local waypoint list
|
}
|
||||||
m_waypoint_list.removeAt(i);
|
*/
|
||||||
|
|
||||||
delete wp;
|
/**
|
||||||
|
* Called when the user asks to edit a waypoint from the map
|
||||||
break;
|
*
|
||||||
}
|
* TODO: should open an interface to edit waypoint properties, or
|
||||||
//
|
* propagate the signal to a specific WP plugin (tbd).
|
||||||
// foreach (t_waypoint *wp, m_waypoint_list)
|
**/
|
||||||
// {
|
/*
|
||||||
// if (!wp) continue;
|
void OPMapGadgetWidget::onEditWayPointAct_triggered()
|
||||||
// if (!wp->map_wp_item || wp->map_wp_item != m_mouse_waypoint) continue;
|
{
|
||||||
//
|
if (!m_widget || !m_map)
|
||||||
// // delete the waypoint from the map
|
return;
|
||||||
// m_map->WPDelete(wp->map_wp_item);
|
|
||||||
//
|
if (m_map_mode != Normal_MapMode)
|
||||||
// // delete the waypoint from our local waypoint list
|
return;
|
||||||
// m_waypoint_list.removeOne(wp);
|
|
||||||
//
|
if (!m_mouse_waypoint)
|
||||||
// delete wp;
|
return;
|
||||||
//
|
|
||||||
// break;
|
//waypoint_edit_dialog.editWaypoint(m_mouse_waypoint);
|
||||||
// }
|
|
||||||
|
m_mouse_waypoint = NULL;
|
||||||
m_mouse_waypoint = NULL;
|
}
|
||||||
}
|
*/
|
||||||
*/
|
|
||||||
|
/**
|
||||||
/**
|
* TODO: unused for v1.0
|
||||||
* TODO: No Waypoint support in v1.0
|
*/
|
||||||
*/
|
/*
|
||||||
/*
|
void OPMapGadgetWidget::onLockWayPointAct_triggered()
|
||||||
void OPMapGadgetWidget::onClearWayPointsAct_triggered()
|
{
|
||||||
{
|
if (!m_widget || !m_map || !m_mouse_waypoint)
|
||||||
if (!m_widget || !m_map)
|
return;
|
||||||
return;
|
|
||||||
|
if (m_map_mode != Normal_MapMode)
|
||||||
if (m_map_mode != Normal_MapMode)
|
return;
|
||||||
return;
|
|
||||||
|
bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0;
|
||||||
QMutexLocker locker(&m_waypoint_list_mutex);
|
m_mouse_waypoint->setFlag(QGraphicsItem::ItemIsMovable, locked);
|
||||||
|
|
||||||
m_map->WPDeleteAll();
|
if (!locked)
|
||||||
|
m_mouse_waypoint->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker2.png"));
|
||||||
foreach (t_waypoint *wp, m_waypoint_list)
|
else
|
||||||
{
|
m_mouse_waypoint->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png"));
|
||||||
if (wp)
|
m_mouse_waypoint->update();
|
||||||
{
|
|
||||||
delete wp;
|
m_mouse_waypoint = NULL;
|
||||||
wp = NULL;
|
}
|
||||||
}
|
*/
|
||||||
}
|
|
||||||
|
/**
|
||||||
m_waypoint_list.clear();
|
* TODO: unused for v1.0
|
||||||
}
|
*/
|
||||||
*/
|
/*
|
||||||
|
void OPMapGadgetWidget::onDeleteWayPointAct_triggered()
|
||||||
void OPMapGadgetWidget::onHomeMagicWaypointAct_triggered()
|
{
|
||||||
{
|
if (!m_widget || !m_map)
|
||||||
// center the magic waypoint on the home position
|
return;
|
||||||
homeMagicWaypoint();
|
|
||||||
}
|
if (m_map_mode != Normal_MapMode)
|
||||||
|
return;
|
||||||
void OPMapGadgetWidget::onShowSafeAreaAct_toggled(bool show)
|
|
||||||
{
|
if (!m_mouse_waypoint)
|
||||||
if (!m_widget || !m_map)
|
return;
|
||||||
return;
|
|
||||||
|
bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0;
|
||||||
m_map->Home->SetShowSafeArea(show); // show the safe area
|
|
||||||
m_map->Home->RefreshPos();
|
if (locked) return; // waypoint is locked
|
||||||
}
|
|
||||||
|
QMutexLocker locker(&m_waypoint_list_mutex);
|
||||||
void OPMapGadgetWidget::onSafeAreaActGroup_triggered(QAction *action)
|
|
||||||
{
|
for (int i = 0; i < m_waypoint_list.count(); i++)
|
||||||
if (!m_widget || !m_map)
|
{
|
||||||
return;
|
t_waypoint *wp = m_waypoint_list.at(i);
|
||||||
|
if (!wp) continue;
|
||||||
int radius = action->data().toInt();
|
if (!wp->map_wp_item || wp->map_wp_item != m_mouse_waypoint) continue;
|
||||||
|
|
||||||
m_map->Home->SetSafeArea(radius); // set the radius (meters)
|
// delete the waypoint from the map
|
||||||
m_map->Home->RefreshPos();
|
m_map->WPDelete(wp->map_wp_item);
|
||||||
|
|
||||||
// move the magic waypoint if need be to keep it within the safe area around the home position
|
// delete the waypoint from our local waypoint list
|
||||||
keepMagicWaypointWithInSafeArea();
|
m_waypoint_list.removeAt(i);
|
||||||
}
|
|
||||||
|
delete wp;
|
||||||
/**
|
|
||||||
* move the magic waypoint to the home position
|
break;
|
||||||
**/
|
}
|
||||||
void OPMapGadgetWidget::homeMagicWaypoint()
|
//
|
||||||
{
|
// foreach (t_waypoint *wp, m_waypoint_list)
|
||||||
if (!m_widget || !m_map)
|
// {
|
||||||
return;
|
// if (!wp) continue;
|
||||||
|
// if (!wp->map_wp_item || wp->map_wp_item != m_mouse_waypoint) continue;
|
||||||
if (m_map_mode != MagicWaypoint_MapMode)
|
//
|
||||||
return;
|
// // delete the waypoint from the map
|
||||||
|
// m_map->WPDelete(wp->map_wp_item);
|
||||||
magic_waypoint.coord = home_position.coord;
|
//
|
||||||
|
// // delete the waypoint from our local waypoint list
|
||||||
if (magic_waypoint.map_wp_item)
|
// m_waypoint_list.removeOne(wp);
|
||||||
magic_waypoint.map_wp_item->SetCoord(magic_waypoint.coord);
|
//
|
||||||
}
|
// delete wp;
|
||||||
|
//
|
||||||
// *************************************************************************************
|
// break;
|
||||||
// move the UAV to the magic waypoint position
|
// }
|
||||||
|
|
||||||
void OPMapGadgetWidget::moveToMagicWaypointPosition()
|
m_mouse_waypoint = NULL;
|
||||||
{
|
}
|
||||||
if (!m_widget || !m_map)
|
*/
|
||||||
return;
|
|
||||||
|
/**
|
||||||
if (m_map_mode != MagicWaypoint_MapMode)
|
* TODO: No Waypoint support in v1.0
|
||||||
return;
|
*/
|
||||||
|
/*
|
||||||
// internals::PointLatLng coord = magic_waypoint.coord;
|
void OPMapGadgetWidget::onClearWayPointsAct_triggered()
|
||||||
// double altitude = magic_waypoint.altitude;
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
// ToDo:
|
|
||||||
|
if (m_map_mode != Normal_MapMode)
|
||||||
}
|
return;
|
||||||
|
|
||||||
// *************************************************************************************
|
QMutexLocker locker(&m_waypoint_list_mutex);
|
||||||
// temporary until an object is created for managing the save/restore
|
|
||||||
|
m_map->WPDeleteAll();
|
||||||
// load the contents of a simple text file into a combobox
|
|
||||||
void OPMapGadgetWidget::loadComboBoxLines(QComboBox *comboBox, QString filename)
|
foreach (t_waypoint *wp, m_waypoint_list)
|
||||||
{
|
{
|
||||||
if (!comboBox) return;
|
if (wp)
|
||||||
if (filename.isNull() || filename.isEmpty()) return;
|
{
|
||||||
|
delete wp;
|
||||||
QFile file(filename);
|
wp = NULL;
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
}
|
||||||
return;
|
}
|
||||||
|
|
||||||
QTextStream in(&file);
|
m_waypoint_list.clear();
|
||||||
|
}
|
||||||
while (!in.atEnd())
|
*/
|
||||||
{
|
|
||||||
QString line = in.readLine().simplified();
|
void OPMapGadgetWidget::onHomeMagicWaypointAct_triggered()
|
||||||
if (line.isNull() || line.isEmpty()) continue;
|
{
|
||||||
comboBox->addItem(line);
|
// center the magic waypoint on the home position
|
||||||
}
|
homeMagicWaypoint();
|
||||||
|
}
|
||||||
file.close();
|
|
||||||
}
|
void OPMapGadgetWidget::onShowSafeAreaAct_toggled(bool show)
|
||||||
|
{
|
||||||
// save a combobox text contents to a simple text file
|
if (!m_widget || !m_map)
|
||||||
void OPMapGadgetWidget::saveComboBoxLines(QComboBox *comboBox, QString filename)
|
return;
|
||||||
{
|
|
||||||
if (!comboBox) return;
|
m_map->Home->SetShowSafeArea(show); // show the safe area
|
||||||
if (filename.isNull() || filename.isEmpty()) return;
|
m_map->Home->RefreshPos();
|
||||||
|
}
|
||||||
QFile file(filename);
|
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
void OPMapGadgetWidget::onSafeAreaActGroup_triggered(QAction *action)
|
||||||
return;
|
{
|
||||||
|
if (!m_widget || !m_map || !action)
|
||||||
QTextStream out(&file);
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < comboBox->count(); i++)
|
int radius = action->data().toInt();
|
||||||
{
|
|
||||||
QString line = comboBox->itemText(i).simplified();
|
m_map->Home->SetSafeArea(radius); // set the radius (meters)
|
||||||
if (line.isNull() || line.isEmpty()) continue;
|
m_map->Home->RefreshPos();
|
||||||
out << line << "\n";
|
|
||||||
}
|
// move the magic waypoint if need be to keep it within the safe area around the home position
|
||||||
|
keepMagicWaypointWithInSafeArea();
|
||||||
file.close();
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
// *************************************************************************************
|
* move the magic waypoint to the home position
|
||||||
// show/hide the magic waypoint controls
|
**/
|
||||||
|
void OPMapGadgetWidget::homeMagicWaypoint()
|
||||||
void OPMapGadgetWidget::hideMagicWaypointControls()
|
{
|
||||||
{
|
if (!m_widget || !m_map)
|
||||||
m_widget->lineWaypoint->setVisible(false);
|
return;
|
||||||
m_widget->toolButtonHomeWaypoint->setVisible(false);
|
|
||||||
m_widget->toolButtonMoveToWP->setVisible(false);
|
if (m_map_mode != MagicWaypoint_MapMode)
|
||||||
}
|
return;
|
||||||
|
|
||||||
void OPMapGadgetWidget::showMagicWaypointControls()
|
m_magic_waypoint.coord = m_home_position.coord;
|
||||||
{
|
|
||||||
m_widget->lineWaypoint->setVisible(true);
|
if (m_magic_waypoint.map_wp_item)
|
||||||
m_widget->toolButtonHomeWaypoint->setVisible(true);
|
m_magic_waypoint.map_wp_item->SetCoord(m_magic_waypoint.coord);
|
||||||
|
}
|
||||||
#if defined(allow_manual_home_location_move)
|
|
||||||
m_widget->toolButtonMoveToWP->setVisible(true);
|
// *************************************************************************************
|
||||||
#else
|
// move the UAV to the magic waypoint position
|
||||||
m_widget->toolButtonMoveToWP->setVisible(false);
|
|
||||||
#endif
|
void OPMapGadgetWidget::moveToMagicWaypointPosition()
|
||||||
}
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
// *************************************************************************************
|
return;
|
||||||
// move the magic waypoint to keep it within the safe area boundry
|
|
||||||
|
if (m_map_mode != MagicWaypoint_MapMode)
|
||||||
void OPMapGadgetWidget::keepMagicWaypointWithInSafeArea()
|
return;
|
||||||
{
|
|
||||||
|
// internals::PointLatLng coord = magic_waypoint.coord;
|
||||||
// calcute the bearing and distance from the home position to the magic waypoint
|
// double altitude = magic_waypoint.altitude;
|
||||||
double dist = distance(home_position.coord, magic_waypoint.coord);
|
|
||||||
double bear = bearing(home_position.coord, magic_waypoint.coord);
|
|
||||||
|
// ToDo:
|
||||||
// get the maximum safe distance - in kilometers
|
|
||||||
double boundry_dist = (double)m_map->Home->SafeArea() / 1000;
|
}
|
||||||
|
|
||||||
// if (dist <= boundry_dist)
|
// *************************************************************************************
|
||||||
// return; // the magic waypoint is still within the safe area, don't move it
|
// temporary until an object is created for managing the save/restore
|
||||||
|
|
||||||
if (dist > boundry_dist) dist = boundry_dist;
|
// load the contents of a simple text file into a combobox
|
||||||
|
void OPMapGadgetWidget::loadComboBoxLines(QComboBox *comboBox, QString filename)
|
||||||
// move the magic waypoint
|
{
|
||||||
|
if (!comboBox) return;
|
||||||
magic_waypoint.coord = destPoint(home_position.coord, bear, dist);
|
if (filename.isNull() || filename.isEmpty()) return;
|
||||||
|
|
||||||
if (m_map_mode == MagicWaypoint_MapMode)
|
QFile file(filename);
|
||||||
{ // move the on-screen waypoint
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
if (magic_waypoint.map_wp_item)
|
return;
|
||||||
magic_waypoint.map_wp_item->SetCoord(magic_waypoint.coord);
|
|
||||||
}
|
QTextStream in(&file);
|
||||||
}
|
|
||||||
|
while (!in.atEnd())
|
||||||
// *************************************************************************************
|
{
|
||||||
// return the distance between two points .. in kilometers
|
QString line = in.readLine().simplified();
|
||||||
|
if (line.isNull() || line.isEmpty()) continue;
|
||||||
double OPMapGadgetWidget::distance(internals::PointLatLng from, internals::PointLatLng to)
|
comboBox->addItem(line);
|
||||||
{
|
}
|
||||||
double lat1 = from.Lat() * deg_to_rad;
|
|
||||||
double lon1 = from.Lng() * deg_to_rad;
|
file.close();
|
||||||
|
}
|
||||||
double lat2 = to.Lat() * deg_to_rad;
|
|
||||||
double lon2 = to.Lng() * deg_to_rad;
|
// save a combobox text contents to a simple text file
|
||||||
|
void OPMapGadgetWidget::saveComboBoxLines(QComboBox *comboBox, QString filename)
|
||||||
// ***********************
|
{
|
||||||
// Haversine formula
|
if (!comboBox) return;
|
||||||
/*
|
if (filename.isNull() || filename.isEmpty()) return;
|
||||||
double delta_lat = lat2 - lat1;
|
|
||||||
double delta_lon = lon2 - lon1;
|
QFile file(filename);
|
||||||
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
double t1 = sin(delta_lat / 2);
|
return;
|
||||||
double t2 = sin(delta_lon / 2);
|
|
||||||
double a = (t1 * t1) + cos(lat1) * cos(lat2) * (t2 * t2);
|
QTextStream out(&file);
|
||||||
double c = 2 * atan2(sqrt(a), sqrt(1 - a));
|
|
||||||
|
for (int i = 0; i < comboBox->count(); i++)
|
||||||
return (earth_mean_radius * c);
|
{
|
||||||
*/
|
QString line = comboBox->itemText(i).simplified();
|
||||||
// ***********************
|
if (line.isNull() || line.isEmpty()) continue;
|
||||||
// Spherical Law of Cosines
|
out << line << "\n";
|
||||||
|
}
|
||||||
return (acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1)) * earth_mean_radius);
|
|
||||||
|
file.close();
|
||||||
// ***********************
|
}
|
||||||
}
|
|
||||||
|
// *************************************************************************************
|
||||||
// *************************************************************************************
|
// show/hide the magic waypoint controls
|
||||||
// return the bearing from one point to another .. in degrees
|
|
||||||
|
void OPMapGadgetWidget::hideMagicWaypointControls()
|
||||||
double OPMapGadgetWidget::bearing(internals::PointLatLng from, internals::PointLatLng to)
|
{
|
||||||
{
|
m_widget->lineWaypoint->setVisible(false);
|
||||||
double lat1 = from.Lat() * deg_to_rad;
|
m_widget->toolButtonHomeWaypoint->setVisible(false);
|
||||||
double lon1 = from.Lng() * deg_to_rad;
|
m_widget->toolButtonMoveToWP->setVisible(false);
|
||||||
|
}
|
||||||
double lat2 = to.Lat() * deg_to_rad;
|
|
||||||
double lon2 = to.Lng() * deg_to_rad;
|
void OPMapGadgetWidget::showMagicWaypointControls()
|
||||||
|
{
|
||||||
// double delta_lat = lat2 - lat1;
|
m_widget->lineWaypoint->setVisible(true);
|
||||||
double delta_lon = lon2 - lon1;
|
m_widget->toolButtonHomeWaypoint->setVisible(true);
|
||||||
|
|
||||||
double y = sin(delta_lon) * cos(lat2);
|
#if defined(allow_manual_home_location_move)
|
||||||
double x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(delta_lon);
|
m_widget->toolButtonMoveToWP->setVisible(true);
|
||||||
double bear = atan2(y, x) * rad_to_deg;
|
#else
|
||||||
|
m_widget->toolButtonMoveToWP->setVisible(false);
|
||||||
bear += 360;
|
#endif
|
||||||
while (bear < 0) bear += 360;
|
}
|
||||||
while (bear >= 360) bear -= 360;
|
|
||||||
|
// *************************************************************************************
|
||||||
return bear;
|
// move the magic waypoint to keep it within the safe area boundry
|
||||||
}
|
|
||||||
|
void OPMapGadgetWidget::keepMagicWaypointWithInSafeArea()
|
||||||
// *************************************************************************************
|
{
|
||||||
// return a destination lat/lon point given a source lat/lon point and the bearing and distance from the source point
|
|
||||||
|
// calcute the bearing and distance from the home position to the magic waypoint
|
||||||
internals::PointLatLng OPMapGadgetWidget::destPoint(internals::PointLatLng source, double bear, double dist)
|
double dist = distance(m_home_position.coord, m_magic_waypoint.coord);
|
||||||
{
|
double bear = bearing(m_home_position.coord, m_magic_waypoint.coord);
|
||||||
double lat1 = source.Lat() * deg_to_rad;
|
|
||||||
double lon1 = source.Lng() * deg_to_rad;
|
// get the maximum safe distance - in kilometers
|
||||||
|
double boundry_dist = (double)m_map->Home->SafeArea() / 1000;
|
||||||
bear *= deg_to_rad;
|
|
||||||
|
// if (dist <= boundry_dist)
|
||||||
double ad = dist / earth_mean_radius;
|
// return; // the magic waypoint is still within the safe area, don't move it
|
||||||
|
|
||||||
double lat2 = asin(sin(lat1) * cos(ad) + cos(lat1) * sin(ad) * cos(bear));
|
if (dist > boundry_dist) dist = boundry_dist;
|
||||||
double lon2 = lon1 + atan2(sin(bear) * sin(ad) * cos(lat1), cos(ad) - sin(lat1) * sin(lat2));
|
|
||||||
|
// move the magic waypoint
|
||||||
return internals::PointLatLng(lat2 * rad_to_deg, lon2 * rad_to_deg);
|
|
||||||
}
|
m_magic_waypoint.coord = destPoint(m_home_position.coord, bear, dist);
|
||||||
|
|
||||||
// *************************************************************************************
|
if (m_map_mode == MagicWaypoint_MapMode)
|
||||||
|
{ // move the on-screen waypoint
|
||||||
bool OPMapGadgetWidget::getUAVPosition(double &latitude, double &longitude, double &altitude)
|
if (m_magic_waypoint.map_wp_item)
|
||||||
{
|
m_magic_waypoint.map_wp_item->SetCoord(m_magic_waypoint.coord);
|
||||||
double BaseECEF[3];
|
}
|
||||||
double NED[3];
|
}
|
||||||
double LLA[3];
|
|
||||||
UAVObject *obj;
|
// *************************************************************************************
|
||||||
|
// return the distance between two points .. in kilometers
|
||||||
if (!obm)
|
|
||||||
return false;
|
double OPMapGadgetWidget::distance(internals::PointLatLng from, internals::PointLatLng to)
|
||||||
|
{
|
||||||
obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("HomeLocation")));
|
double lat1 = from.Lat() * deg_to_rad;
|
||||||
if (!obj) return false;
|
double lon1 = from.Lng() * deg_to_rad;
|
||||||
BaseECEF[0] = obj->getField(QString("ECEF"))->getDouble(0) / 100;
|
|
||||||
BaseECEF[1] = obj->getField(QString("ECEF"))->getDouble(1) / 100;
|
double lat2 = to.Lat() * deg_to_rad;
|
||||||
BaseECEF[2] = obj->getField(QString("ECEF"))->getDouble(2) / 100;
|
double lon2 = to.Lng() * deg_to_rad;
|
||||||
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("PositionActual")));
|
// ***********************
|
||||||
if (!obj) return false;
|
// Haversine formula
|
||||||
NED[0] = obj->getField(QString("North"))->getDouble() / 100;
|
/*
|
||||||
NED[1] = obj->getField(QString("East"))->getDouble() / 100;
|
double delta_lat = lat2 - lat1;
|
||||||
NED[2] = obj->getField(QString("Down"))->getDouble() / 100;
|
double delta_lon = lon2 - lon1;
|
||||||
|
|
||||||
// obj = dynamic_cast<UAVDataObject*>(om->getObject(QString("PositionDesired")));
|
double t1 = sin(delta_lat / 2);
|
||||||
|
double t2 = sin(delta_lon / 2);
|
||||||
// obj = dynamic_cast<UAVDataObject*>(objManager->getObject("VelocityActual")); // air speed
|
double a = (t1 * t1) + cos(lat1) * cos(lat2) * (t2 * t2);
|
||||||
|
double c = 2 * atan2(sqrt(a), sqrt(1 - a));
|
||||||
Utils::CoordinateConversions().GetLLA(BaseECEF, NED, LLA);
|
|
||||||
|
return (earth_mean_radius * c);
|
||||||
latitude = LLA[0];
|
*/
|
||||||
longitude = LLA[1];
|
// ***********************
|
||||||
altitude = LLA[2];
|
// Spherical Law of Cosines
|
||||||
|
|
||||||
if (latitude != latitude) latitude = 0; // nan detection
|
return (acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1)) * earth_mean_radius);
|
||||||
// if (isNan(latitude)) latitude = 0; // nan detection
|
|
||||||
else
|
// ***********************
|
||||||
// if (!isFinite(latitude)) latitude = 0;
|
}
|
||||||
// else
|
|
||||||
if (latitude > 90) latitude = 90;
|
// *************************************************************************************
|
||||||
else
|
// return the bearing from one point to another .. in degrees
|
||||||
if (latitude < -90) latitude = -90;
|
|
||||||
|
double OPMapGadgetWidget::bearing(internals::PointLatLng from, internals::PointLatLng to)
|
||||||
if (longitude != longitude) longitude = 0; // nan detection
|
{
|
||||||
else
|
double lat1 = from.Lat() * deg_to_rad;
|
||||||
// if (longitude > std::numeric_limits<double>::max()) longitude = 0; // +infinite
|
double lon1 = from.Lng() * deg_to_rad;
|
||||||
// else
|
|
||||||
// if (longitude < -std::numeric_limits<double>::max()) longitude = 0; // -infinite
|
double lat2 = to.Lat() * deg_to_rad;
|
||||||
// else
|
double lon2 = to.Lng() * deg_to_rad;
|
||||||
if (longitude > 180) longitude = 180;
|
|
||||||
else
|
// double delta_lat = lat2 - lat1;
|
||||||
if (longitude < -180) longitude = -180;
|
double delta_lon = lon2 - lon1;
|
||||||
|
|
||||||
if (altitude != altitude) altitude = 0; // nan detection
|
double y = sin(delta_lon) * cos(lat2);
|
||||||
|
double x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(delta_lon);
|
||||||
return true;
|
double bear = atan2(y, x) * rad_to_deg;
|
||||||
}
|
|
||||||
|
bear += 360;
|
||||||
// *************************************************************************************
|
while (bear < 0) bear += 360;
|
||||||
|
while (bear >= 360) bear -= 360;
|
||||||
bool OPMapGadgetWidget::getGPSPosition(double &latitude, double &longitude, double &altitude)
|
|
||||||
{
|
return bear;
|
||||||
double LLA[3];
|
}
|
||||||
|
|
||||||
if (!obum)
|
// *************************************************************************************
|
||||||
return false;
|
// return a destination lat/lon point given a source lat/lon point and the bearing and distance from the source point
|
||||||
|
|
||||||
if (obum->getGPSPosition(LLA) < 0)
|
internals::PointLatLng OPMapGadgetWidget::destPoint(internals::PointLatLng source, double bear, double dist)
|
||||||
return false; // error
|
{
|
||||||
|
double lat1 = source.Lat() * deg_to_rad;
|
||||||
latitude = LLA[0];
|
double lon1 = source.Lng() * deg_to_rad;
|
||||||
longitude = LLA[1];
|
|
||||||
altitude = LLA[2];
|
bear *= deg_to_rad;
|
||||||
|
|
||||||
return true;
|
double ad = dist / earth_mean_radius;
|
||||||
}
|
|
||||||
|
double lat2 = asin(sin(lat1) * cos(ad) + cos(lat1) * sin(ad) * cos(bear));
|
||||||
double OPMapGadgetWidget::getUAV_Yaw()
|
double lon2 = lon1 + atan2(sin(bear) * sin(ad) * cos(lat1), cos(ad) - sin(lat1) * sin(lat2));
|
||||||
{
|
|
||||||
if (!obm)
|
return internals::PointLatLng(lat2 * rad_to_deg, lon2 * rad_to_deg);
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
UAVObject *obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("AttitudeActual")));
|
// *************************************************************************************
|
||||||
double yaw = obj->getField(QString("Yaw"))->getDouble();
|
|
||||||
|
bool OPMapGadgetWidget::getUAVPosition(double &latitude, double &longitude, double &altitude)
|
||||||
if (yaw != yaw) yaw = 0; // nan detection
|
{
|
||||||
|
double BaseECEF[3];
|
||||||
while (yaw < 0) yaw += 360;
|
double NED[3];
|
||||||
while (yaw >= 360) yaw -= 360;
|
double LLA[3];
|
||||||
|
UAVObject *obj;
|
||||||
return yaw;
|
|
||||||
}
|
if (!obm)
|
||||||
|
return false;
|
||||||
// *************************************************************************************
|
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("HomeLocation")));
|
||||||
void OPMapGadgetWidget::setMapFollowingMode()
|
if (!obj) return false;
|
||||||
{
|
BaseECEF[0] = obj->getField(QString("ECEF"))->getDouble(0) / 100;
|
||||||
if (!m_widget || !m_map)
|
BaseECEF[1] = obj->getField(QString("ECEF"))->getDouble(1) / 100;
|
||||||
return;
|
BaseECEF[2] = obj->getField(QString("ECEF"))->getDouble(2) / 100;
|
||||||
|
|
||||||
if (!followUAVpositionAct->isChecked())
|
obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("PositionActual")));
|
||||||
{
|
if (!obj) return false;
|
||||||
m_map->UAV->SetMapFollowType(UAVMapFollowType::None);
|
NED[0] = obj->getField(QString("North"))->getDouble() / 100;
|
||||||
m_map->SetRotate(0); // reset map rotation to 0deg
|
NED[1] = obj->getField(QString("East"))->getDouble() / 100;
|
||||||
}
|
NED[2] = obj->getField(QString("Down"))->getDouble() / 100;
|
||||||
else
|
|
||||||
if (!followUAVheadingAct->isChecked())
|
// obj = dynamic_cast<UAVDataObject*>(om->getObject(QString("PositionDesired")));
|
||||||
{
|
|
||||||
m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap);
|
// obj = dynamic_cast<UAVDataObject*>(objManager->getObject("VelocityActual")); // air speed
|
||||||
m_map->SetRotate(0); // reset map rotation to 0deg
|
|
||||||
}
|
Utils::CoordinateConversions().GetLLA(BaseECEF, NED, LLA);
|
||||||
else
|
|
||||||
{
|
latitude = LLA[0];
|
||||||
m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap); // the map library won't let you reset the uav rotation if it's already in rotate mode
|
longitude = LLA[1];
|
||||||
|
altitude = LLA[2];
|
||||||
m_map->UAV->SetUAVHeading(0); // reset the UAV heading to 0deg
|
|
||||||
m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterAndRotateMap);
|
if (latitude != latitude) latitude = 0; // nan detection
|
||||||
}
|
// if (isNan(latitude)) latitude = 0; // nan detection
|
||||||
}
|
else
|
||||||
|
// if (!isFinite(latitude)) latitude = 0;
|
||||||
// *************************************************************************************
|
// else
|
||||||
// update the HomeLocation UAV Object
|
if (latitude > 90) latitude = 90;
|
||||||
|
else
|
||||||
bool OPMapGadgetWidget::setHomeLocationObject()
|
if (latitude < -90) latitude = -90;
|
||||||
{
|
|
||||||
if (!obum)
|
if (longitude != longitude) longitude = 0; // nan detection
|
||||||
return false;
|
else
|
||||||
|
// if (longitude > std::numeric_limits<double>::max()) longitude = 0; // +infinite
|
||||||
double LLA[3] = {home_position.coord.Lat(), home_position.coord.Lng(), home_position.altitude};
|
// else
|
||||||
return (obum->setHomeLocation(LLA, true) >= 0);
|
// if (longitude < -std::numeric_limits<double>::max()) longitude = 0; // -infinite
|
||||||
}
|
// else
|
||||||
|
if (longitude > 180) longitude = 180;
|
||||||
// *************************************************************************************
|
else
|
||||||
|
if (longitude < -180) longitude = -180;
|
||||||
void OPMapGadgetWidget::SetUavPic(QString UAVPic)
|
|
||||||
{
|
if (altitude != altitude) altitude = 0; // nan detection
|
||||||
m_map->SetUavPic(UAVPic);
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
double OPMapGadgetWidget::getUAV_Yaw()
|
||||||
|
{
|
||||||
|
if (!obm)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
UAVObject *obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("AttitudeActual")));
|
||||||
|
double yaw = obj->getField(QString("Yaw"))->getDouble();
|
||||||
|
|
||||||
|
if (yaw != yaw) yaw = 0; // nan detection
|
||||||
|
|
||||||
|
while (yaw < 0) yaw += 360;
|
||||||
|
while (yaw >= 360) yaw -= 360;
|
||||||
|
|
||||||
|
return yaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OPMapGadgetWidget::getGPSPosition(double &latitude, double &longitude, double &altitude)
|
||||||
|
{
|
||||||
|
double LLA[3];
|
||||||
|
|
||||||
|
if (!obum)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (obum->getGPSPosition(LLA) < 0)
|
||||||
|
return false; // error
|
||||||
|
|
||||||
|
latitude = LLA[0];
|
||||||
|
longitude = LLA[1];
|
||||||
|
altitude = LLA[2];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// *************************************************************************************
|
||||||
|
|
||||||
|
void OPMapGadgetWidget::setMapFollowingMode()
|
||||||
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!followUAVpositionAct->isChecked())
|
||||||
|
{
|
||||||
|
m_map->UAV->SetMapFollowType(UAVMapFollowType::None);
|
||||||
|
m_map->SetRotate(0); // reset map rotation to 0deg
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (!followUAVheadingAct->isChecked())
|
||||||
|
{
|
||||||
|
m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap);
|
||||||
|
m_map->SetRotate(0); // reset map rotation to 0deg
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap); // the map library won't let you reset the uav rotation if it's already in rotate mode
|
||||||
|
|
||||||
|
m_map->UAV->SetUAVHeading(0); // reset the UAV heading to 0deg
|
||||||
|
m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterAndRotateMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// *************************************************************************************
|
||||||
|
// update the HomeLocation UAV Object
|
||||||
|
|
||||||
|
bool OPMapGadgetWidget::setHomeLocationObject()
|
||||||
|
{
|
||||||
|
if (!obum)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
double LLA[3] = {m_home_position.coord.Lat(), m_home_position.coord.Lng(), m_home_position.altitude};
|
||||||
|
return (obum->setHomeLocation(LLA, true) >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// *************************************************************************************
|
||||||
|
|
||||||
|
void OPMapGadgetWidget::SetUavPic(QString UAVPic)
|
||||||
|
{
|
||||||
|
m_map->SetUavPic(UAVPic);
|
||||||
|
}
|
||||||
|
@ -1,347 +1,361 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file opmapgadgetwidget.h
|
* @file opmapgadgetwidget.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
* @addtogroup OPMapPlugin OpenPilot Map Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief The OpenPilot Map plugin
|
* @brief The OpenPilot Map plugin
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OPMAP_GADGETWIDGET_H_
|
#ifndef OPMAP_GADGETWIDGET_H_
|
||||||
#define OPMAP_GADGETWIDGET_H_
|
#define OPMAP_GADGETWIDGET_H_
|
||||||
|
|
||||||
// ******************************************************
|
// ******************************************************
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
|
||||||
#include "opmapcontrol/opmapcontrol.h"
|
#include "opmapcontrol/opmapcontrol.h"
|
||||||
|
|
||||||
#include "opmap_overlay_widget.h"
|
#include "opmap_overlay_widget.h"
|
||||||
#include "opmap_zoom_slider_widget.h"
|
#include "opmap_zoom_slider_widget.h"
|
||||||
#include "opmap_statusbar_widget.h"
|
#include "opmap_statusbar_widget.h"
|
||||||
|
|
||||||
#include "utils/coordinateconversions.h"
|
#include "utils/coordinateconversions.h"
|
||||||
|
|
||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjectutilmanager.h"
|
#include "uavobjectutilmanager.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include "objectpersistence.h"
|
#include "objectpersistence.h"
|
||||||
|
|
||||||
// ******************************************************
|
// ******************************************************
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class OPMap_Widget;
|
class OPMap_Widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace mapcontrol;
|
using namespace mapcontrol;
|
||||||
|
|
||||||
// ******************************************************
|
// ******************************************************
|
||||||
|
|
||||||
typedef struct t_home
|
typedef struct t_home
|
||||||
{
|
{
|
||||||
internals::PointLatLng coord;
|
internals::PointLatLng coord;
|
||||||
double altitude;
|
double altitude;
|
||||||
bool locked;
|
bool locked;
|
||||||
} t_home;
|
} t_home;
|
||||||
|
|
||||||
// local waypoint list item structure
|
// local waypoint list item structure
|
||||||
typedef struct t_waypoint
|
typedef struct t_waypoint
|
||||||
{
|
{
|
||||||
mapcontrol::WayPointItem *map_wp_item;
|
mapcontrol::WayPointItem *map_wp_item;
|
||||||
internals::PointLatLng coord;
|
internals::PointLatLng coord;
|
||||||
double altitude;
|
double altitude;
|
||||||
QString description;
|
QString description;
|
||||||
bool locked;
|
bool locked;
|
||||||
int time_seconds;
|
int time_seconds;
|
||||||
int hold_time_seconds;
|
int hold_time_seconds;
|
||||||
} t_waypoint;
|
} t_waypoint;
|
||||||
|
|
||||||
// ******************************************************
|
// ******************************************************
|
||||||
|
|
||||||
enum opMapModeType { Normal_MapMode = 0,
|
enum opMapModeType { Normal_MapMode = 0,
|
||||||
MagicWaypoint_MapMode = 1};
|
MagicWaypoint_MapMode = 1};
|
||||||
|
|
||||||
// ******************************************************
|
// ******************************************************
|
||||||
|
|
||||||
class OPMapGadgetWidget : public QWidget
|
class OPMapGadgetWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OPMapGadgetWidget(QWidget *parent = 0);
|
OPMapGadgetWidget(QWidget *parent = 0);
|
||||||
~OPMapGadgetWidget();
|
~OPMapGadgetWidget();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief public functions
|
* @brief public functions
|
||||||
*
|
*
|
||||||
* @param
|
* @param
|
||||||
*/
|
*/
|
||||||
void setHome(QPointF pos);
|
void setHome(QPointF pos);
|
||||||
void setHome(internals::PointLatLng pos_lat_lon);
|
void setHome(internals::PointLatLng pos_lat_lon);
|
||||||
void goHome();
|
void goHome();
|
||||||
void setZoom(int zoom);
|
void setZoom(int zoom);
|
||||||
void setPosition(QPointF pos);
|
void setPosition(QPointF pos);
|
||||||
void setMapProvider(QString provider);
|
void setMapProvider(QString provider);
|
||||||
void setUseOpenGL(bool useOpenGL);
|
void setUseOpenGL(bool useOpenGL);
|
||||||
void setShowTileGridLines(bool showTileGridLines);
|
void setShowTileGridLines(bool showTileGridLines);
|
||||||
void setAccessMode(QString accessMode);
|
void setAccessMode(QString accessMode);
|
||||||
void setUseMemoryCache(bool useMemoryCache);
|
void setUseMemoryCache(bool useMemoryCache);
|
||||||
void setCacheLocation(QString cacheLocation);
|
void setCacheLocation(QString cacheLocation);
|
||||||
void setMapMode(opMapModeType mode);
|
void setMapMode(opMapModeType mode);
|
||||||
void SetUavPic(QString UAVPic);
|
void SetUavPic(QString UAVPic);
|
||||||
|
void setMaxUpdateRate(int update_rate);
|
||||||
public slots:
|
|
||||||
void homePositionUpdated(UAVObject *);
|
public slots:
|
||||||
void onTelemetryConnect();
|
void homePositionUpdated(UAVObject *);
|
||||||
void onTelemetryDisconnect();
|
void onTelemetryConnect();
|
||||||
|
void onTelemetryDisconnect();
|
||||||
protected:
|
|
||||||
void resizeEvent(QResizeEvent *event);
|
protected:
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
void keyPressEvent(QKeyEvent* event);
|
||||||
private slots:
|
|
||||||
void updatePosition();
|
private slots:
|
||||||
|
void updatePosition();
|
||||||
void updateMousePos();
|
|
||||||
|
void updateMousePos();
|
||||||
void zoomIn();
|
|
||||||
void zoomOut();
|
void zoomIn();
|
||||||
|
void zoomOut();
|
||||||
/**
|
|
||||||
* @brief signals received from the various map plug-in widget user controls
|
/**
|
||||||
*
|
* @brief signals received from the various map plug-in widget user controls
|
||||||
* Some are currently disabled for the v1.0 plugin version.
|
*
|
||||||
*/
|
* Some are currently disabled for the v1.0 plugin version.
|
||||||
// void comboBoxFindPlace_returnPressed();
|
*/
|
||||||
// void on_toolButtonFindPlace_clicked();
|
// void comboBoxFindPlace_returnPressed();
|
||||||
void on_toolButtonZoomM_clicked();
|
// void on_toolButtonFindPlace_clicked();
|
||||||
void on_toolButtonZoomP_clicked();
|
void on_toolButtonZoomM_clicked();
|
||||||
void on_toolButtonMapHome_clicked();
|
void on_toolButtonZoomP_clicked();
|
||||||
void on_toolButtonMapUAV_clicked();
|
void on_toolButtonMapHome_clicked();
|
||||||
void on_toolButtonMapUAVheading_clicked();
|
void on_toolButtonMapUAV_clicked();
|
||||||
void on_horizontalSliderZoom_sliderMoved(int position);
|
void on_toolButtonMapUAVheading_clicked();
|
||||||
// void on_toolButtonAddWaypoint_clicked();
|
void on_horizontalSliderZoom_sliderMoved(int position);
|
||||||
// void on_treeViewWaypoints_clicked(QModelIndex index);
|
// void on_toolButtonAddWaypoint_clicked();
|
||||||
// void on_toolButtonHome_clicked();
|
// void on_treeViewWaypoints_clicked(QModelIndex index);
|
||||||
// void on_toolButtonNextWaypoint_clicked();
|
// void on_toolButtonHome_clicked();
|
||||||
// void on_toolButtonPrevWaypoint_clicked();
|
// void on_toolButtonNextWaypoint_clicked();
|
||||||
// void on_toolButtonHoldPosition_clicked();
|
// void on_toolButtonPrevWaypoint_clicked();
|
||||||
// void on_toolButtonGo_clicked();
|
// void on_toolButtonHoldPosition_clicked();
|
||||||
void on_toolButtonMagicWaypointMapMode_clicked();
|
// void on_toolButtonGo_clicked();
|
||||||
void on_toolButtonNormalMapMode_clicked();
|
void on_toolButtonMagicWaypointMapMode_clicked();
|
||||||
void on_toolButtonHomeWaypoint_clicked();
|
void on_toolButtonNormalMapMode_clicked();
|
||||||
void on_toolButtonMoveToWP_clicked();
|
void on_toolButtonHomeWaypoint_clicked();
|
||||||
|
void on_toolButtonMoveToWP_clicked();
|
||||||
/**
|
|
||||||
* @brief signals received from the map object
|
/**
|
||||||
*/
|
* @brief signals received from the map object
|
||||||
void zoomChanged(double zoomt,double zoom, double zoomd);
|
*/
|
||||||
void OnCurrentPositionChanged(internals::PointLatLng point);
|
void zoomChanged(double zoomt,double zoom, double zoomd);
|
||||||
void OnTileLoadComplete();
|
void OnCurrentPositionChanged(internals::PointLatLng point);
|
||||||
void OnTileLoadStart();
|
void OnTileLoadComplete();
|
||||||
void OnMapDrag();
|
void OnTileLoadStart();
|
||||||
void OnMapZoomChanged();
|
void OnMapDrag();
|
||||||
void OnMapTypeChanged(MapType::Types type);
|
void OnMapZoomChanged();
|
||||||
void OnEmptyTileError(int zoom, core::Point pos);
|
void OnMapTypeChanged(MapType::Types type);
|
||||||
void OnTilesStillToLoad(int number);
|
void OnEmptyTileError(int zoom, core::Point pos);
|
||||||
|
void OnTilesStillToLoad(int number);
|
||||||
/**
|
|
||||||
* Unused for now, hooks for future waypoint support
|
/**
|
||||||
*/
|
* Unused for now, hooks for future waypoint support
|
||||||
void WPNumberChanged(int const& oldnumber,int const& newnumber, WayPointItem* waypoint);
|
*/
|
||||||
void WPValuesChanged(WayPointItem* waypoint);
|
void WPNumberChanged(int const& oldnumber,int const& newnumber, WayPointItem* waypoint);
|
||||||
void WPInserted(int const& number, WayPointItem* waypoint);
|
void WPValuesChanged(WayPointItem* waypoint);
|
||||||
void WPDeleted(int const& number);
|
void WPInserted(int const& number, WayPointItem* waypoint);
|
||||||
|
void WPDeleted(int const& number);
|
||||||
/**
|
|
||||||
* @brief mouse right click context menu signals
|
/**
|
||||||
*/
|
* @brief mouse right click context menu signals
|
||||||
void onReloadAct_triggered();
|
*/
|
||||||
void onCopyMouseLatLonToClipAct_triggered();
|
void onReloadAct_triggered();
|
||||||
void onCopyMouseLatToClipAct_triggered();
|
void onCopyMouseLatLonToClipAct_triggered();
|
||||||
void onCopyMouseLonToClipAct_triggered();
|
void onCopyMouseLatToClipAct_triggered();
|
||||||
// void onFindPlaceAct_triggered();
|
void onCopyMouseLonToClipAct_triggered();
|
||||||
void onShowCompassAct_toggled(bool show);
|
// void onFindPlaceAct_triggered();
|
||||||
void onShowDiagnostics_toggled(bool show);
|
void onShowCompassAct_toggled(bool show);
|
||||||
void onShowUAVAct_toggled(bool show);
|
void onShowDiagnostics_toggled(bool show);
|
||||||
void onShowHomeAct_toggled(bool show);
|
void onShowUAVAct_toggled(bool show);
|
||||||
void onShowTrailLineAct_toggled(bool show);
|
void onShowHomeAct_toggled(bool show);
|
||||||
void onShowTrailAct_toggled(bool show);
|
void onShowTrailLineAct_toggled(bool show);
|
||||||
void onGoZoomInAct_triggered();
|
void onShowTrailAct_toggled(bool show);
|
||||||
void onGoZoomOutAct_triggered();
|
void onGoZoomInAct_triggered();
|
||||||
void onGoMouseClickAct_triggered();
|
void onGoZoomOutAct_triggered();
|
||||||
void onSetHomeAct_triggered();
|
void onGoMouseClickAct_triggered();
|
||||||
void onGoHomeAct_triggered();
|
void onSetHomeAct_triggered();
|
||||||
void onGoUAVAct_triggered();
|
void onGoHomeAct_triggered();
|
||||||
void onFollowUAVpositionAct_toggled(bool checked);
|
void onGoUAVAct_triggered();
|
||||||
void onFollowUAVheadingAct_toggled(bool checked);
|
void onFollowUAVpositionAct_toggled(bool checked);
|
||||||
/*
|
void onFollowUAVheadingAct_toggled(bool checked);
|
||||||
void onOpenWayPointEditorAct_triggered();
|
/*
|
||||||
void onAddWayPointAct_triggered();
|
void onOpenWayPointEditorAct_triggered();
|
||||||
void onEditWayPointAct_triggered();
|
void onAddWayPointAct_triggered();
|
||||||
void onLockWayPointAct_triggered();
|
void onEditWayPointAct_triggered();
|
||||||
void onDeleteWayPointAct_triggered();
|
void onLockWayPointAct_triggered();
|
||||||
void onClearWayPointsAct_triggered();
|
void onDeleteWayPointAct_triggered();
|
||||||
*/
|
void onClearWayPointsAct_triggered();
|
||||||
void onMapModeActGroup_triggered(QAction *action);
|
*/
|
||||||
void onZoomActGroup_triggered(QAction *action);
|
void onMapModeActGroup_triggered(QAction *action);
|
||||||
void onHomeMagicWaypointAct_triggered();
|
void onZoomActGroup_triggered(QAction *action);
|
||||||
void onShowSafeAreaAct_toggled(bool show);
|
void onHomeMagicWaypointAct_triggered();
|
||||||
void onSafeAreaActGroup_triggered(QAction *action);
|
void onShowSafeAreaAct_toggled(bool show);
|
||||||
void onUAVTrailTypeActGroup_triggered(QAction *action);
|
void onSafeAreaActGroup_triggered(QAction *action);
|
||||||
void onClearUAVtrailAct_triggered();
|
void onUAVTrailTypeActGroup_triggered(QAction *action);
|
||||||
void onUAVTrailTimeActGroup_triggered(QAction *action);
|
void onClearUAVtrailAct_triggered();
|
||||||
void onUAVTrailDistanceActGroup_triggered(QAction *action);
|
void onUAVTrailTimeActGroup_triggered(QAction *action);
|
||||||
|
void onUAVTrailDistanceActGroup_triggered(QAction *action);
|
||||||
private:
|
void onMaxUpdateRateActGroup_triggered(QAction *action);
|
||||||
int min_zoom;
|
|
||||||
int max_zoom;
|
private:
|
||||||
|
|
||||||
double m_heading; // uav heading
|
// *****
|
||||||
|
|
||||||
internals::PointLatLng mouse_lat_lon;
|
int m_min_zoom;
|
||||||
internals::PointLatLng context_menu_lat_lon;
|
int m_max_zoom;
|
||||||
|
|
||||||
int prev_tile_number;
|
double m_heading; // uav heading
|
||||||
|
|
||||||
opMapModeType m_map_mode;
|
internals::PointLatLng m_mouse_lat_lon;
|
||||||
|
internals::PointLatLng m_context_menu_lat_lon;
|
||||||
t_home home_position;
|
|
||||||
|
int m_prev_tile_number;
|
||||||
t_waypoint magic_waypoint;
|
|
||||||
|
opMapModeType m_map_mode;
|
||||||
QStringList findPlaceWordList;
|
|
||||||
QCompleter *findPlaceCompleter;
|
int m_maxUpdateRate;
|
||||||
|
|
||||||
QTimer *m_updateTimer;
|
t_home m_home_position;
|
||||||
QTimer *m_statusUpdateTimer;
|
|
||||||
|
t_waypoint m_magic_waypoint;
|
||||||
Ui::OPMap_Widget *m_widget;
|
|
||||||
|
QStringList findPlaceWordList;
|
||||||
mapcontrol::OPMapWidget *m_map;
|
QCompleter *findPlaceCompleter;
|
||||||
|
|
||||||
ExtensionSystem::PluginManager *pm;
|
QTimer *m_updateTimer;
|
||||||
UAVObjectManager *obm;
|
QTimer *m_statusUpdateTimer;
|
||||||
UAVObjectUtilManager *obum;
|
|
||||||
|
Ui::OPMap_Widget *m_widget;
|
||||||
//opmap_waypointeditor_dialog waypoint_editor_dialog;
|
|
||||||
|
mapcontrol::OPMapWidget *m_map;
|
||||||
//opmap_edit_waypoint_dialog waypoint_edit_dialog;
|
|
||||||
|
ExtensionSystem::PluginManager *pm;
|
||||||
QStandardItemModel wayPoint_treeView_model;
|
UAVObjectManager *obm;
|
||||||
|
UAVObjectUtilManager *obum;
|
||||||
mapcontrol::WayPointItem *m_mouse_waypoint;
|
|
||||||
|
//opmap_waypointeditor_dialog waypoint_editor_dialog;
|
||||||
QList<t_waypoint *> m_waypoint_list;
|
|
||||||
QMutex m_waypoint_list_mutex;
|
//opmap_edit_waypoint_dialog waypoint_edit_dialog;
|
||||||
|
|
||||||
QMutex m_map_mutex;
|
QStandardItemModel wayPoint_treeView_model;
|
||||||
|
|
||||||
bool telemetry_connected;
|
mapcontrol::WayPointItem *m_mouse_waypoint;
|
||||||
|
|
||||||
void createActions();
|
QList<t_waypoint *> m_waypoint_list;
|
||||||
|
QMutex m_waypoint_list_mutex;
|
||||||
QAction *closeAct1;
|
|
||||||
QAction *closeAct2;
|
QMutex m_map_mutex;
|
||||||
QAction *reloadAct;
|
|
||||||
QAction *copyMouseLatLonToClipAct;
|
bool m_telemetry_connected;
|
||||||
QAction *copyMouseLatToClipAct;
|
|
||||||
QAction *copyMouseLonToClipAct;
|
// *****
|
||||||
QAction *findPlaceAct;
|
|
||||||
QAction *showCompassAct;
|
void createActions();
|
||||||
QAction *showDiagnostics;
|
|
||||||
QAction *showHomeAct;
|
QAction *closeAct1;
|
||||||
QAction *showUAVAct;
|
QAction *closeAct2;
|
||||||
QAction *zoomInAct;
|
QAction *reloadAct;
|
||||||
QAction *zoomOutAct;
|
QAction *copyMouseLatLonToClipAct;
|
||||||
QAction *goMouseClickAct;
|
QAction *copyMouseLatToClipAct;
|
||||||
QAction *setHomeAct;
|
QAction *copyMouseLonToClipAct;
|
||||||
QAction *goHomeAct;
|
QAction *findPlaceAct;
|
||||||
QAction *goUAVAct;
|
QAction *showCompassAct;
|
||||||
QAction *followUAVpositionAct;
|
QAction *showDiagnostics;
|
||||||
QAction *followUAVheadingAct;
|
QAction *showHomeAct;
|
||||||
/*
|
QAction *showUAVAct;
|
||||||
QAction *wayPointEditorAct;
|
QAction *zoomInAct;
|
||||||
QAction *addWayPointAct;
|
QAction *zoomOutAct;
|
||||||
QAction *editWayPointAct;
|
QAction *goMouseClickAct;
|
||||||
QAction *lockWayPointAct;
|
QAction *setHomeAct;
|
||||||
QAction *deleteWayPointAct;
|
QAction *goHomeAct;
|
||||||
QAction *clearWayPointsAct;
|
QAction *goUAVAct;
|
||||||
*/
|
QAction *followUAVpositionAct;
|
||||||
QAction *homeMagicWaypointAct;
|
QAction *followUAVheadingAct;
|
||||||
|
/*
|
||||||
QAction *showSafeAreaAct;
|
QAction *wayPointEditorAct;
|
||||||
QActionGroup *safeAreaActGroup;
|
QAction *addWayPointAct;
|
||||||
QList<QAction *> safeAreaAct;
|
QAction *editWayPointAct;
|
||||||
|
QAction *lockWayPointAct;
|
||||||
QActionGroup *uavTrailTypeActGroup;
|
QAction *deleteWayPointAct;
|
||||||
QList<QAction *> uavTrailTypeAct;
|
QAction *clearWayPointsAct;
|
||||||
QAction *clearUAVtrailAct;
|
*/
|
||||||
QActionGroup *uavTrailTimeActGroup;
|
QAction *homeMagicWaypointAct;
|
||||||
QAction *showTrailLineAct;
|
|
||||||
QAction *showTrailAct;
|
QAction *showSafeAreaAct;
|
||||||
QList<QAction *> uavTrailTimeAct;
|
QActionGroup *safeAreaActGroup;
|
||||||
QActionGroup *uavTrailDistanceActGroup;
|
QList<QAction *> safeAreaAct;
|
||||||
QList<QAction *> uavTrailDistanceAct;
|
|
||||||
|
QActionGroup *uavTrailTypeActGroup;
|
||||||
QActionGroup *mapModeActGroup;
|
QList<QAction *> uavTrailTypeAct;
|
||||||
QList<QAction *> mapModeAct;
|
QAction *clearUAVtrailAct;
|
||||||
|
QActionGroup *uavTrailTimeActGroup;
|
||||||
QActionGroup *zoomActGroup;
|
QAction *showTrailLineAct;
|
||||||
QList<QAction *> zoomAct;
|
QAction *showTrailAct;
|
||||||
|
QList<QAction *> uavTrailTimeAct;
|
||||||
void homeMagicWaypoint();
|
QActionGroup *uavTrailDistanceActGroup;
|
||||||
|
QList<QAction *> uavTrailDistanceAct;
|
||||||
void moveToMagicWaypointPosition();
|
|
||||||
|
QActionGroup *mapModeActGroup;
|
||||||
void loadComboBoxLines(QComboBox *comboBox, QString filename);
|
QList<QAction *> mapModeAct;
|
||||||
void saveComboBoxLines(QComboBox *comboBox, QString filename);
|
|
||||||
|
QActionGroup *zoomActGroup;
|
||||||
void hideMagicWaypointControls();
|
QList<QAction *> zoomAct;
|
||||||
void showMagicWaypointControls();
|
|
||||||
|
QActionGroup *maxUpdateRateActGroup;
|
||||||
void keepMagicWaypointWithInSafeArea();
|
QList<QAction *> maxUpdateRateAct;
|
||||||
|
|
||||||
double distance(internals::PointLatLng from, internals::PointLatLng to);
|
// *****
|
||||||
double bearing(internals::PointLatLng from, internals::PointLatLng to);
|
|
||||||
internals::PointLatLng destPoint(internals::PointLatLng source, double bear, double dist);
|
void homeMagicWaypoint();
|
||||||
|
|
||||||
bool getUAVPosition(double &latitude, double &longitude, double &altitude);
|
void moveToMagicWaypointPosition();
|
||||||
bool getGPSPosition(double &latitude, double &longitude, double &altitude);
|
|
||||||
double getUAV_Yaw();
|
void loadComboBoxLines(QComboBox *comboBox, QString filename);
|
||||||
|
void saveComboBoxLines(QComboBox *comboBox, QString filename);
|
||||||
void setMapFollowingMode();
|
|
||||||
|
void hideMagicWaypointControls();
|
||||||
bool setHomeLocationObject();
|
void showMagicWaypointControls();
|
||||||
};
|
|
||||||
|
void keepMagicWaypointWithInSafeArea();
|
||||||
#endif /* OPMAP_GADGETWIDGET_H_ */
|
|
||||||
|
double distance(internals::PointLatLng from, internals::PointLatLng to);
|
||||||
|
double bearing(internals::PointLatLng from, internals::PointLatLng to);
|
||||||
|
internals::PointLatLng destPoint(internals::PointLatLng source, double bear, double dist);
|
||||||
|
|
||||||
|
bool getUAVPosition(double &latitude, double &longitude, double &altitude);
|
||||||
|
bool getGPSPosition(double &latitude, double &longitude, double &altitude);
|
||||||
|
double getUAV_Yaw();
|
||||||
|
|
||||||
|
void setMapFollowingMode();
|
||||||
|
|
||||||
|
bool setHomeLocationObject();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* OPMAP_GADGETWIDGET_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user