diff --git a/ground/src/plugins/opmap/images/ok.png b/ground/src/plugins/opmap/images/ok.png
new file mode 100644
index 000000000..15cd35d27
Binary files /dev/null and b/ground/src/plugins/opmap/images/ok.png differ
diff --git a/ground/src/plugins/opmap/opmap.qrc b/ground/src/plugins/opmap/opmap.qrc
index f133b0240..9435d2fa3 100644
--- a/ground/src/plugins/opmap/opmap.qrc
+++ b/ground/src/plugins/opmap/opmap.qrc
@@ -5,5 +5,6 @@
images/waypoint.png
images/minus.png
images/plus.png
+ images/ok.png
diff --git a/ground/src/plugins/opmap/opmapgadget.cpp b/ground/src/plugins/opmap/opmapgadget.cpp
index 78f691540..a11cca6b3 100644
--- a/ground/src/plugins/opmap/opmapgadget.cpp
+++ b/ground/src/plugins/opmap/opmapgadget.cpp
@@ -36,12 +36,12 @@ OPMapGadget::OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *pa
OPMapGadget::~OPMapGadget()
{
-
}
-void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration* config)
+void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config)
{
OPMapGadgetConfiguration *m = qobject_cast(config);
+
m_widget->setMapProvider(m->mapProvider());
m_widget->setZoom(m->zoom());
m_widget->setPosition(QPointF(m->longitude(), m->latitude()));
diff --git a/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp b/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp
index 266711dac..28f91a098 100644
--- a/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp
+++ b/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp
@@ -27,48 +27,55 @@
#include "opmapgadgetconfiguration.h"
#include
+#include
OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
- m_mapProvider("OpenStreetMap"),
+ m_mapProvider("GoogleHybrid"),
m_defaultZoom(2),
m_defaultLatitude(0),
m_defaultLongitude(0),
m_useMemoryCache(true),
- m_cacheLocation("")
+ m_cacheLocation(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator())
{
- if (state.count() > 0) {
+ if (state.count() > 0)
+ {
QDataStream stream(state);
+
int zoom;
double latitude;
double longitude;
QString mapProvider;
bool useMemoryCache;
QString cacheLocation;
+
stream >> zoom;
stream >> latitude;
stream >> longitude;
stream >> mapProvider;
stream >> useMemoryCache;
stream >> cacheLocation;
+
m_defaultZoom = zoom;
m_defaultLatitude = latitude;
m_defaultLongitude = longitude;
- if (mapProvider != "") m_mapProvider = mapProvider;
+ if (!mapProvider.isEmpty()) m_mapProvider = mapProvider;
m_useMemoryCache = useMemoryCache;
- if (cacheLocation != "") m_cacheLocation = cacheLocation;
+ if (!cacheLocation.isEmpty()) m_cacheLocation = cacheLocation;
}
}
-IUAVGadgetConfiguration *OPMapGadgetConfiguration::clone()
+IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
{
OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId());
+
m->m_defaultZoom = m_defaultZoom;
m->m_defaultLatitude = m_defaultLatitude;
m->m_defaultLongitude = m_defaultLongitude;
m->m_mapProvider = m_mapProvider;
m->m_useMemoryCache = m_useMemoryCache;
m->m_cacheLocation = m_cacheLocation;
+
return m;
}
@@ -76,12 +83,13 @@ QByteArray OPMapGadgetConfiguration::saveState() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
+
stream << m_defaultZoom;
stream << m_defaultLatitude;
stream << m_defaultLongitude;
stream << m_mapProvider;
stream << m_useMemoryCache;
stream << m_cacheLocation;
+
return bytes;
}
-
diff --git a/ground/src/plugins/opmap/opmapgadgetfactory.cpp b/ground/src/plugins/opmap/opmapgadgetfactory.cpp
index 3e30b8fca..2c665fc3b 100644
--- a/ground/src/plugins/opmap/opmapgadgetfactory.cpp
+++ b/ground/src/plugins/opmap/opmapgadgetfactory.cpp
@@ -40,18 +40,18 @@ OPMapGadgetFactory::~OPMapGadgetFactory()
{
}
-Core::IUAVGadget* OPMapGadgetFactory::createGadget(QWidget *parent)
+Core::IUAVGadget * OPMapGadgetFactory::createGadget(QWidget *parent)
{
- OPMapGadgetWidget* gadgetWidget = new OPMapGadgetWidget(parent);
+ OPMapGadgetWidget *gadgetWidget = new OPMapGadgetWidget(parent);
return new OPMapGadget(QString("OPMapGadget"), gadgetWidget, parent);
}
-IUAVGadgetConfiguration *OPMapGadgetFactory::createConfiguration(const QByteArray &state)
+IUAVGadgetConfiguration * OPMapGadgetFactory::createConfiguration(const QByteArray &state)
{
return new OPMapGadgetConfiguration(QString("OPMapGadget"), state);
}
-IOptionsPage *OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
+IOptionsPage * OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{
return new OPMapGadgetOptionsPage(qobject_cast(config));
}
diff --git a/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp b/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp
index 706716875..ae695f1dc 100644
--- a/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp
+++ b/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp
@@ -35,8 +35,11 @@
#include
#include
+#include "opmapcontrol/opmapcontrol.h"
+
#include "ui_opmapgadgetoptionspage.h"
+// *********************************************
OPMapGadgetOptionsPage::OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent) :
IOptionsPage(parent),
@@ -50,6 +53,10 @@ QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
QWidget *w = new QWidget(parent);
m_page->setupUi(w);
+ // populate the map provider combobox
+ m_page->providerComboBox->clear();
+ m_page->providerComboBox->addItems(mapcontrol::Helper::MapTypes());
+
int index = m_page->providerComboBox->findText(m_config->mapProvider());
index = (index >= 0) ? index : 0;
m_page->providerComboBox->setCurrentIndex(index);
@@ -60,6 +67,7 @@ QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
m_page->lineEditCacheLocation->setText(m_config->cacheLocation());
connect(m_page->pushButtonCacheLocation, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheLocation_clicked()));
+ connect(m_page->pushButtonCacheDefaults, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheDefaults_clicked()));
return w;
}
@@ -70,11 +78,17 @@ void OPMapGadgetOptionsPage::on_pushButtonCacheLocation_clicked()
// QDir dirPath(dir);
// dir = dirPath.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
-// m_page->lineEditCacheLocation->setText(dir);
+// if (!dir.isEmpty()) m_page->lineEditCacheLocation->setText(dir);
- QFileDialog::Options options;
- QString path = QFileDialog::getExistingDirectory(qobject_cast(this), tr("Choose a directory"), dir, options);
- if (!path.isNull()) m_page->lineEditCacheLocation->setText(path);
+ QFileDialog::Options options(QFileDialog::ShowDirsOnly);
+ QString path = QFileDialog::getExistingDirectory(qobject_cast(this), tr("Choose a cache directory"), dir, options);
+ if (!path.isEmpty()) m_page->lineEditCacheLocation->setText(path);
+}
+
+void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked()
+{
+ m_page->pushButtonUseMemoryCache->setChecked(true);
+ m_page->lineEditCacheLocation->setText(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator());
}
void OPMapGadgetOptionsPage::apply()
diff --git a/ground/src/plugins/opmap/opmapgadgetoptionspage.h b/ground/src/plugins/opmap/opmapgadgetoptionspage.h
index c1d0717a5..b796c9306 100644
--- a/ground/src/plugins/opmap/opmapgadgetoptionspage.h
+++ b/ground/src/plugins/opmap/opmapgadgetoptionspage.h
@@ -58,6 +58,7 @@ public slots:
private slots:
void on_pushButtonCacheLocation_clicked();
+ void on_pushButtonCacheDefaults_clicked();
private:
OPMapGadgetConfiguration *m_config;
diff --git a/ground/src/plugins/opmap/opmapgadgetoptionspage.ui b/ground/src/plugins/opmap/opmapgadgetoptionspage.ui
index 69e13366c..7cba3ff00 100644
--- a/ground/src/plugins/opmap/opmapgadgetoptionspage.ui
+++ b/ground/src/plugins/opmap/opmapgadgetoptionspage.ui
@@ -25,6 +25,31 @@
-
+
-
+
+
+
+ 0
+ 0
+
+
+
+ OpenHandCursor
+
+
+ Default
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+
-
@@ -49,6 +74,19 @@
OpenHandCursor
+
+ QPushButton {
+}
+QPushButton:pressed {
+}
+QPushButton:hover {
+}
+QPushButton:checked {
+/*background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+stop: 0 rgba(180, 190, 220, 255), stop: 1 rgba(200, 230, 255, 255));*/
+}
+
+
Use Memory Cache
@@ -79,21 +117,6 @@
OpenHandCursor
-
-
-
- OpenStreetMap
-
-
- -
-
- Google
-
-
- -
-
- Google Sat
-
-
-
@@ -194,7 +217,11 @@
-
-
+
+
+ false
+
+
-
diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.cpp b/ground/src/plugins/opmap/opmapgadgetwidget.cpp
index db7a0beb9..f0a94f9b4 100644
--- a/ground/src/plugins/opmap/opmapgadgetwidget.cpp
+++ b/ground/src/plugins/opmap/opmapgadgetwidget.cpp
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
#include "extensionsystem/pluginmanager.h"
#include "ui_opmap_controlpanel.h"
@@ -42,7 +43,7 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
controlpanel_ui = NULL;
map = NULL;
- follow_uav = false;
+ m_follow_uav = false;
// **************
// Get required UAVObjects
@@ -172,10 +173,9 @@ void OPMapGadgetWidget::setPosition(QPointF pos)
void OPMapGadgetWidget::setMapProvider(QString provider)
{
- // haven't yet decided how to populate the map provider combobox on the options page
-// if (map)
-// if (map->isStarted())
-// map->SetMapType(mapcontrol::Helper::MapTypeFromString(provider));
+ if (map)
+ if (map->isStarted())
+ map->SetMapType(mapcontrol::Helper::MapTypeFromString(provider));
}
void OPMapGadgetWidget::setUseMemoryCache(bool useMemoryCache)
@@ -188,18 +188,18 @@ void OPMapGadgetWidget::setCacheLocation(QString cacheLocation)
{
cacheLocation = cacheLocation.trimmed(); // remove any surrounding spaces
- if (cacheLocation.isEmpty()) return; // tut tut
+ if (cacheLocation.isEmpty()) return;
#if defined(Q_WS_WIN)
if (!cacheLocation.endsWith('/')) cacheLocation += '/';
#elif defined(Q_WS_X11)
- if (!cacheLocation.endsWith('/')) cacheLocation += '/';
+ if (!cacheLocation.endsWith(QDir::separator())) cacheLocation += QDir::separator();
#elif defined(Q_WS_MAC)
- if (!cacheLocation.endsWith('/')) cacheLocation += '/';
+ if (!cacheLocation.endsWith(QDir::separator())) cacheLocation += QDir::separator();
#endif
- QDir dir(cacheLocation);
- if (!dir.exists())
+ QDir dir;
+ if (!dir.exists(cacheLocation))
if (!dir.mkpath(cacheLocation))
return;
@@ -216,7 +216,7 @@ void OPMapGadgetWidget::updatePosition()
// get current position data
PositionActual::DataFields data = m_positionActual->getData();
- if (map && follow_uav)
+ if (map && m_follow_uav)
{ // center the map onto the UAV
map->SetCurrentPosition(internals::PointLatLng(data.Latitude, data.Longitude));
}
@@ -418,16 +418,12 @@ QPushButton * OPMapGadgetWidget::createTransparentButton(QWidget *parent, QStrin
void OPMapGadgetWidget::createMapOverlayUserControls()
{
QPushButton *zoomout = new QPushButton("");
- zoomout->setFlat(true);
zoomout->setToolTip(tr("Zoom out"));
zoomout->setCursor(Qt::OpenHandCursor);
+ zoomout->setFlat(true);
zoomout->setIcon(QIcon(QString::fromUtf8(":/opmap/images/minus.png")));
-// zoomout->setIconSize(QSize(12, 12));
zoomout->setIconSize(QSize(32, 32));
zoomout->setFixedSize(32, 32);
-// zoomout->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
-// zoomout->setWindowOpacity(0.7);
-// zoomout->setBackgroundRole(QPalette(QColor(0, 0, 0, 0)));
connect(zoomout, SIGNAL(clicked(bool)), this, SLOT(zoomOut()));
// QPushButton *zoomin = createTransparentButton(map, "", QString::fromUtf8(":/core/images/plus.png"));
diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.h b/ground/src/plugins/opmap/opmapgadgetwidget.h
index 12741f549..80664fccb 100644
--- a/ground/src/plugins/opmap/opmapgadgetwidget.h
+++ b/ground/src/plugins/opmap/opmapgadgetwidget.h
@@ -81,15 +81,16 @@ private slots:
void OnTilesStillToLoad(int number);
private:
- bool follow_uav; // true if the map is to stay centered on the UAV
+ bool m_follow_uav; // true if the map is to stay centered on the UAV
- double heading; // compass/uav heading
+ double m_heading; // uav heading
QTimer *m_updateTimer;
PositionActual *m_positionActual;
Ui::OPMapControlPanel *controlpanel_ui;
+
mapcontrol::OPMapWidget *map;
QPushButton * createTransparentButton(QWidget *parent, QString text, QString icon);