mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
New map options page update.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@822 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
6d5433fdd1
commit
46be975628
BIN
ground/src/plugins/opmap/images/ok.png
Normal file
BIN
ground/src/plugins/opmap/images/ok.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 103 B |
@ -5,5 +5,6 @@
|
||||
<file>images/waypoint.png</file>
|
||||
<file>images/minus.png</file>
|
||||
<file>images/plus.png</file>
|
||||
<file>images/ok.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -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<OPMapGadgetConfiguration*>(config);
|
||||
|
||||
m_widget->setMapProvider(m->mapProvider());
|
||||
m_widget->setZoom(m->zoom());
|
||||
m_widget->setPosition(QPointF(m->longitude(), m->latitude()));
|
||||
|
@ -27,48 +27,55 @@
|
||||
|
||||
#include "opmapgadgetconfiguration.h"
|
||||
#include <QtCore/QDataStream>
|
||||
#include <QDir>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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<OPMapGadgetConfiguration*>(config));
|
||||
}
|
||||
|
@ -35,8 +35,11 @@
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QFileDialog>
|
||||
|
||||
#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<QWidget*>(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<QWidget*>(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()
|
||||
|
@ -58,6 +58,7 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void on_pushButtonCacheLocation_clicked();
|
||||
void on_pushButtonCacheDefaults_clicked();
|
||||
|
||||
private:
|
||||
OPMapGadgetConfiguration *m_config;
|
||||
|
@ -25,6 +25,31 @@
|
||||
</property>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonCacheDefaults">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>OpenHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Default </string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
@ -49,6 +74,19 @@
|
||||
<property name="cursor">
|
||||
<cursorShape>OpenHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">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));*/
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Use Memory Cache </string>
|
||||
</property>
|
||||
@ -79,21 +117,6 @@
|
||||
<property name="cursor">
|
||||
<cursorShape>OpenHandCursor</cursorShape>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>OpenStreetMap</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Google</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Google Sat</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
@ -194,7 +217,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEditCacheLocation"/>
|
||||
<widget class="QLineEdit" name="lineEditCacheLocation">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonCacheLocation">
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QStringList>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QDir>
|
||||
#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"));
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user