1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Added map cache settings onto the map options page

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@812 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2010-06-18 19:07:04 +00:00 committed by pip
parent d884f46abe
commit d6332aaffa
9 changed files with 295 additions and 101 deletions

View File

@ -903,7 +903,7 @@
<property name="font"> <property name="font">
<font> <font>
<weight>50</weight> <weight>50</weight>
<italic>true</italic> <italic>false</italic>
<bold>false</bold> <bold>false</bold>
</font> </font>
</property> </property>
@ -918,6 +918,32 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="labelNumTilesToLoad">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(255, 255, 255, 0);</string>
</property>
<property name="text">
<string>Tiles</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item> <item>
<widget class="QProgressBar" name="progressBarMap"> <widget class="QProgressBar" name="progressBarMap">
<property name="sizePolicy"> <property name="sizePolicy">

View File

@ -45,5 +45,7 @@ void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration* config)
m_widget->setMapProvider(m->mapProvider()); m_widget->setMapProvider(m->mapProvider());
m_widget->setZoom(m->zoom()); m_widget->setZoom(m->zoom());
m_widget->setPosition(QPointF(m->longitude(), m->latitude())); m_widget->setPosition(QPointF(m->longitude(), m->latitude()));
m_widget->setUseMemoryCache(m->useMemoryCache());
m_widget->setCacheLocation(m->cacheLocation());
} }

View File

@ -33,7 +33,9 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteA
m_mapProvider("OpenStreetMap"), m_mapProvider("OpenStreetMap"),
m_defaultZoom(2), m_defaultZoom(2),
m_defaultLatitude(0), m_defaultLatitude(0),
m_defaultLongitude(0) m_defaultLongitude(0),
m_useMemoryCache(true),
m_cacheLocation("")
{ {
if (state.count() > 0) { if (state.count() > 0) {
QDataStream stream(state); QDataStream stream(state);
@ -41,16 +43,20 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteA
double latitude; double latitude;
double longitude; double longitude;
QString mapProvider; QString mapProvider;
stream >> zoom; bool useMemoryCache;
QString cacheLocation;
stream >> zoom;
stream >> latitude; stream >> latitude;
stream >> longitude; stream >> longitude;
stream >> mapProvider; stream >> mapProvider;
m_defaultZoom = zoom; stream >> useMemoryCache;
stream >> cacheLocation;
m_defaultZoom = zoom;
m_defaultLatitude = latitude; m_defaultLatitude = latitude;
m_defaultLongitude = longitude; m_defaultLongitude = longitude;
if (mapProvider != "") if (mapProvider != "") m_mapProvider = mapProvider;
m_mapProvider = mapProvider; m_useMemoryCache = useMemoryCache;
if (cacheLocation != "") m_cacheLocation = cacheLocation;
} }
} }
@ -61,6 +67,8 @@ IUAVGadgetConfiguration *OPMapGadgetConfiguration::clone()
m->m_defaultLatitude = m_defaultLatitude; m->m_defaultLatitude = m_defaultLatitude;
m->m_defaultLongitude = m_defaultLongitude; m->m_defaultLongitude = m_defaultLongitude;
m->m_mapProvider = m_mapProvider; m->m_mapProvider = m_mapProvider;
m->m_useMemoryCache = m_useMemoryCache;
m->m_cacheLocation = m_cacheLocation;
return m; return m;
} }
@ -72,6 +80,8 @@ QByteArray OPMapGadgetConfiguration::saveState() const
stream << m_defaultLatitude; stream << m_defaultLatitude;
stream << m_defaultLongitude; stream << m_defaultLongitude;
stream << m_mapProvider; stream << m_mapProvider;
stream << m_useMemoryCache;
stream << m_cacheLocation;
return bytes; return bytes;
} }

View File

@ -36,10 +36,14 @@ 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 useMemoryCache READ useMemoryCache WRITE setUseMemoryCache)
Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation)
public: public:
explicit OPMapGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); explicit OPMapGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
QByteArray saveState() const; QByteArray saveState() const;
@ -49,18 +53,24 @@ public:
int zoom() const { return m_defaultZoom; } int zoom() const { return m_defaultZoom; }
double latitude() const { return m_defaultLatitude; } double latitude() const { return m_defaultLatitude; }
double longitude() const { return m_defaultLongitude; } double longitude() const { return m_defaultLongitude; }
bool useMemoryCache() const { return m_useMemoryCache; }
QString cacheLocation() const { return m_cacheLocation; }
public slots: public slots:
void setMapProvider(QString provider) { m_mapProvider = provider; } void setMapProvider(QString provider) { m_mapProvider = provider; }
void setZoom(int zoom) { m_defaultZoom = zoom; } void setZoom(int zoom) { m_defaultZoom = zoom; }
void setLatitude(double latitude) { m_defaultLatitude = latitude; } void setLatitude(double latitude) { m_defaultLatitude = latitude; }
void setLongitude(double longitude) { m_defaultLongitude = longitude; } void setLongitude(double longitude) { m_defaultLongitude = longitude; }
void setUseMemoryCache(bool useMemoryCache) { m_useMemoryCache = useMemoryCache; }
void setCacheLocation(QString cacheLocation) { m_cacheLocation = cacheLocation; }
private: private:
QString m_mapProvider; QString m_mapProvider;
int m_defaultZoom; int m_defaultZoom;
double m_defaultLatitude; double m_defaultLatitude;
double m_defaultLongitude; double m_defaultLongitude;
bool m_useMemoryCache;
QString m_cacheLocation;
}; };

View File

@ -33,6 +33,7 @@
#include <QtGui/QDoubleSpinBox> #include <QtGui/QDoubleSpinBox>
#include <QtGui/QHBoxLayout> #include <QtGui/QHBoxLayout>
#include <QtGui/QVBoxLayout> #include <QtGui/QVBoxLayout>
#include <QtGui/QFileDialog>
#include "ui_opmapgadgetoptionspage.h" #include "ui_opmapgadgetoptionspage.h"
@ -55,20 +56,38 @@ QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
m_page->zoomSpinBox->setValue(m_config->zoom()); m_page->zoomSpinBox->setValue(m_config->zoom());
m_page->latitudeSpinBox->setValue(m_config->latitude()); m_page->latitudeSpinBox->setValue(m_config->latitude());
m_page->longitudeSpinBox->setValue(m_config->longitude()); m_page->longitudeSpinBox->setValue(m_config->longitude());
m_page->pushButtonUseMemoryCache->setChecked(m_config->useMemoryCache());
m_page->lineEditCacheLocation->setText(m_config->cacheLocation());
connect(m_page->pushButtonCacheLocation, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheLocation_clicked()));
return w; return w;
} }
void OPMapGadgetOptionsPage::on_pushButtonCacheLocation_clicked()
{
QString dir = m_page->lineEditCacheLocation->text();
// QDir dirPath(dir);
// dir = dirPath.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
// 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);
}
void OPMapGadgetOptionsPage::apply() void OPMapGadgetOptionsPage::apply()
{ {
m_config->setMapProvider(m_page->providerComboBox->currentText()); m_config->setMapProvider(m_page->providerComboBox->currentText());
m_config->setZoom(m_page->zoomSpinBox->value()); m_config->setZoom(m_page->zoomSpinBox->value());
m_config->setLatitude(m_page->latitudeSpinBox->value()); m_config->setLatitude(m_page->latitudeSpinBox->value());
m_config->setLongitude(m_page->longitudeSpinBox->value()); m_config->setLongitude(m_page->longitudeSpinBox->value());
m_config->setUseMemoryCache(m_page->pushButtonUseMemoryCache->isChecked());
m_config->setCacheLocation(m_page->lineEditCacheLocation->text());
} }
void OPMapGadgetOptionsPage::finish() void OPMapGadgetOptionsPage::finish()
{ {
delete m_page; delete m_page;
} }

View File

@ -55,6 +55,10 @@ public:
signals: signals:
public slots: public slots:
private slots:
void on_pushButtonCacheLocation_clicked();
private: private:
OPMapGadgetConfiguration *m_config; OPMapGadgetConfiguration *m_config;
Ui::OPMapGadgetOptionsPage *m_page; Ui::OPMapGadgetOptionsPage *m_page;

View File

@ -6,10 +6,16 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>521</width>
<height>300</height> <height>315</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
@ -17,87 +23,155 @@
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="text"> <item>
<string>Map provider:</string> <spacer name="horizontalSpacer">
</property> <property name="orientation">
</widget> <enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonUseMemoryCache">
<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> Use Memory Cache </string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="0" column="1"> <item row="2" column="0">
<widget class="QComboBox" name="providerComboBox"> <widget class="Line" name="line">
<item> <property name="orientation">
<property name="text"> <enum>Qt::Horizontal</enum>
<string>OpenStreetMap</string> </property>
</property>
</item>
<item>
<property name="text">
<string>Google</string>
</property>
</item>
<item>
<property name="text">
<string>Google Sat</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <layout class="QGridLayout" name="gridLayout_3">
<property name="text"> <item row="0" column="1">
<string>Default zoom:</string> <widget class="QComboBox" name="providerComboBox">
</property> <property name="cursor">
</widget> <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">
<widget class="QLabel" name="label">
<property name="text">
<string>Map provider</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Default zoom</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="zoomSpinBox">
<property name="maximum">
<number>18</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default latitude</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="latitudeSpinBox">
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-90.000000000000000</double>
</property>
<property name="maximum">
<double>90.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Default longitude</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="longitudeSpinBox">
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="1" column="1"> <item row="7" column="0">
<widget class="QSpinBox" name="zoomSpinBox">
<property name="maximum">
<number>18</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default latitude:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="latitudeSpinBox">
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-90.000000000000000</double>
</property>
<property name="maximum">
<double>90.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Default longitude:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="longitudeSpinBox">
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -110,21 +184,48 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="3" column="2"> <item row="5" column="0">
<spacer name="horizontalSpacer"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Cache location:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditCacheLocation"/>
</item>
<item>
<widget class="QPushButton" name="pushButtonCacheLocation">
<property name="cursor">
<cursorShape>OpenHandCursor</cursorShape>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../coreplugin/core.qrc">
<normaloff>:/core/images/dir.png</normaloff>:/core/images/dir.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="Line" name="line_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources>
<include location="../coreplugin/core.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -90,12 +90,16 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
controlpanel_ui->comboBox->setCurrentIndex(mapcontrol::Helper::MapTypes().indexOf("GoogleHybrid")); controlpanel_ui->comboBox->setCurrentIndex(mapcontrol::Helper::MapTypes().indexOf("GoogleHybrid"));
controlpanel_ui->labelZoom->setText(" " + QString::number(map->Zoom())); controlpanel_ui->labelZoom->setText(" " + QString::number(map->Zoom()));
controlpanel_ui->labelRotate->setText(" " + QString::number(map->Rotate())); controlpanel_ui->labelRotate->setText(" " + QString::number(map->Rotate()));
controlpanel_ui->labelNumTilesToLoad->setText(" 0");
// ************** // **************
// receive map zoom changes // receive map zoom changes
connect(map, SIGNAL(zoomChanged(double)), this, SLOT(zoomChanged(double))); connect(map, SIGNAL(zoomChanged(double)), this, SLOT(zoomChanged(double)));
// receive tile loading messages
connect(map, SIGNAL(OnTilesStillToLoad(int)), this, SLOT(OnTilesStillToLoad(int)));
map->SetShowTileGridLines(controlpanel_ui->checkBox->isChecked()); map->SetShowTileGridLines(controlpanel_ui->checkBox->isChecked());
// get current position data // get current position data
@ -145,17 +149,13 @@ OPMapGadgetWidget::~OPMapGadgetWidget()
void OPMapGadgetWidget::setZoom(int value) void OPMapGadgetWidget::setZoom(int value)
{ {
if (map) if (map)
{
map->SetZoom(value); map->SetZoom(value);
}
} }
void OPMapGadgetWidget::setPosition(QPointF pos) void OPMapGadgetWidget::setPosition(QPointF pos)
{ {
if (map) if (map)
{
map->SetCurrentPosition(internals::PointLatLng(pos.y(), pos.x())); map->SetCurrentPosition(internals::PointLatLng(pos.y(), pos.x()));
}
} }
void OPMapGadgetWidget::setMapProvider(QString provider) void OPMapGadgetWidget::setMapProvider(QString provider)
@ -165,6 +165,18 @@ void OPMapGadgetWidget::setMapProvider(QString provider)
// map->SetMapType(mapcontrol::Helper::MapTypeFromString(provider)); // map->SetMapType(mapcontrol::Helper::MapTypeFromString(provider));
} }
void OPMapGadgetWidget::setUseMemoryCache(bool useMemoryCache)
{
if (map)
map->configuration->SetUseMemoryCache(useMemoryCache);
}
void OPMapGadgetWidget::setCacheLocation(QString cacheLocation)
{
if (map)
map->configuration->SetCacheLocation(cacheLocation);
}
// ************************************************************************************* // *************************************************************************************
void OPMapGadgetWidget::updatePosition() void OPMapGadgetWidget::updatePosition()
@ -254,6 +266,12 @@ void OPMapGadgetWidget::zoomChanged(double zoom)
controlpanel_ui->labelZoom->setText(" " + QString::number(zoom)); controlpanel_ui->labelZoom->setText(" " + QString::number(zoom));
} }
void OPMapGadgetWidget::OnTilesStillToLoad(int number)
{
controlpanel_ui->labelNumTilesToLoad->setText(" " + QString::number(number));
}
// *************************************************************************************
void OPMapGadgetWidget::on_checkBox_clicked(bool checked) void OPMapGadgetWidget::on_checkBox_clicked(bool checked)
{ {
if (map) if (map)

View File

@ -48,6 +48,8 @@ public:
void setZoom(int value); void setZoom(int value);
void setPosition(QPointF pos); void setPosition(QPointF pos);
void setMapProvider(QString provider); void setMapProvider(QString provider);
void setUseMemoryCache(bool useMemoryCache);
void setCacheLocation(QString cacheLocation);
public slots: public slots:
@ -73,9 +75,11 @@ private slots:
void on_pushButtonZoomP_clicked(); void on_pushButtonZoomP_clicked();
void on_pushButtonGeoFenceM_clicked(); void on_pushButtonGeoFenceM_clicked();
void on_pushButtonGeoFenceP_clicked(); void on_pushButtonGeoFenceP_clicked();
void zoomChanged(double zoom);
void on_checkBox_2_clicked(bool checked); void on_checkBox_2_clicked(bool checked);
void zoomChanged(double zoom);
void OnTilesStillToLoad(int number);
private: private:
bool follow_uav; // true if the map is to stay centered on the UAV bool follow_uav; // true if the map is to stay centered on the UAV