1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Added an 'Access Mode' option to the new map plug-in options page.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@888 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2010-06-25 09:03:54 +00:00 committed by pip
parent c74eb2f0e9
commit 9f0d8795c8
10 changed files with 348 additions and 126 deletions

View File

@ -25,18 +25,83 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <QPainter>
#include "opmap_waypointeditor_dialog.h"
#include "ui_opmap_waypointeditor_dialog.h"
#include "extensionsystem/pluginmanager.h"
// ***************************************************************
Waypoint::Waypoint()
{
}
QRectF Waypoint::boundingRect() const
{
return QRectF(-6, -10, 12, 20);
}
QPainterPath Waypoint::shape() const
{
QPainterPath path;
path.addEllipse(QPointF(0, 0), 6, 10);
return path;
}
void Waypoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
painter->setPen(Qt::black);
painter->setBrush(QColor(255, 0, 0, 128));
painter->drawEllipse(QPointF(0, 0), 6, 10);
}
// ***************************************************************
opmap_waypointeditor_dialog::opmap_waypointeditor_dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::opmap_waypointeditor_dialog)
{
ui->setupUi(this);
setWindowFlags(Qt::Dialog);
view = ui->graphicsViewWaypointHeightAndTimeline;
scene = new QGraphicsScene(0, 0, 1800, 1000);
view->setScene(scene);
view->setRenderHint(QPainter::HighQualityAntialiasing);
//view->setDragMode(QGraphicsView::ScrollHandDrag);
// *****
// test
Waypoint *waypoint1 = new Waypoint;
waypoint1->setPos(scene->width() / 2, scene->height() / 2);
waypoint1->setFlag(QGraphicsItem::ItemIsMovable, true);
waypoint1->setFlag(QGraphicsItem::ItemIsSelectable, true);
waypoint1->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
waypoint1->setToolTip(tr("Waypoint 1"));
scene->addItem(waypoint1);
Waypoint *waypoint2 = new Waypoint;
waypoint2->setPos(scene->width() / 2 + 30, scene->height() / 2);
waypoint2->setFlag(QGraphicsItem::ItemIsMovable);
waypoint2->setFlag(QGraphicsItem::ItemIsSelectable, true);
waypoint2->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
waypoint2->setToolTip(tr("Waypoint 2"));
scene->addItem(waypoint2);
Waypoint *waypoint3 = new Waypoint;
waypoint3->setPos(scene->width() / 2 + 60, scene->height() / 2);
waypoint3->setFlag(QGraphicsItem::ItemIsMovable);
waypoint3->setFlag(QGraphicsItem::ItemIsSelectable, true);
waypoint3->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
waypoint3->setToolTip(tr("Waypoint 3"));
scene->addItem(waypoint3);
// *****
}
opmap_waypointeditor_dialog::~opmap_waypointeditor_dialog()

View File

@ -31,6 +31,10 @@
#include <QtGui/QWidget>
#include <QtGui/QMenu>
#include <QtGui/QDialog>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsItem>
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/positionactual.h"
@ -38,7 +42,38 @@ namespace Ui {
class opmap_waypointeditor_dialog;
}
class opmap_waypointeditor_dialog : public QDialog {
// ***************************************************************
class Waypoint : public QObject, public QGraphicsItem
{
Q_OBJECT
public:
Waypoint();
double latitude_degress;
double longitude_degress;
double height_feet;
double relative_time_seconds;
QRectF boundingRect() const;
QPainterPath shape() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
protected:
// void timerEvent(QTimerEvent *event);
private:
// qreal angle;
// qreal speed;
// qreal mouseEyeDirection;
// QColor color;
};
// ***************************************************************
class opmap_waypointeditor_dialog : public QDialog
{
Q_OBJECT
public:
opmap_waypointeditor_dialog(QWidget *parent = 0);
@ -48,7 +83,12 @@ protected:
void changeEvent(QEvent *e);
private:
QGraphicsView *view;
QGraphicsScene *scene;
Ui::opmap_waypointeditor_dialog *ui;
};
// ***************************************************************
#endif // OPMAP_WAYPOINTEDITOR_DIALOG_H

View File

@ -7,13 +7,19 @@
<x>0</x>
<y>0</y>
<width>399</width>
<height>359</height>
<height>345</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>260</height>
<height>0</height>
</size>
</property>
<property name="windowTitle">
@ -41,12 +47,24 @@
</item>
<item>
<widget class="QGroupBox" name="groupBoxWaypoints">
<property name="minimumSize">
<size>
<width>0</width>
<height>130</height>
</size>
</property>
<property name="title">
<string>Waypoints</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTableWidget" name="tableWidgetWaypoints">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
@ -78,7 +96,12 @@
</column>
<column>
<property name="text">
<string>Relative Time</string>
<string>Time</string>
</property>
</column>
<column>
<property name="text">
<string>Pause Time</string>
</property>
</column>
</widget>

View File

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

View File

@ -35,6 +35,7 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteA
m_defaultZoom(2),
m_defaultLatitude(0),
m_defaultLongitude(0),
m_accessMode("ServerAndCache"),
m_useMemoryCache(true),
m_cacheLocation(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator())
{
@ -46,6 +47,7 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteA
double latitude;
double longitude;
QString mapProvider;
QString accessMode;
bool useMemoryCache;
QString cacheLocation;
@ -53,6 +55,7 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteA
stream >> latitude;
stream >> longitude;
stream >> mapProvider;
stream >> accessMode;
stream >> useMemoryCache;
stream >> cacheLocation;
@ -60,6 +63,7 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteA
m_defaultLatitude = latitude;
m_defaultLongitude = longitude;
if (!mapProvider.isEmpty()) m_mapProvider = mapProvider;
if (!accessMode.isEmpty()) m_accessMode = accessMode;
m_useMemoryCache = useMemoryCache;
if (!cacheLocation.isEmpty()) m_cacheLocation = cacheLocation;
}
@ -73,6 +77,7 @@ IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
m->m_defaultLatitude = m_defaultLatitude;
m->m_defaultLongitude = m_defaultLongitude;
m->m_mapProvider = m_mapProvider;
m->m_accessMode = m_accessMode;
m->m_useMemoryCache = m_useMemoryCache;
m->m_cacheLocation = m_cacheLocation;
@ -88,6 +93,7 @@ QByteArray OPMapGadgetConfiguration::saveState() const
stream << m_defaultLatitude;
stream << m_defaultLongitude;
stream << m_mapProvider;
stream << m_accessMode;
stream << m_useMemoryCache;
stream << m_cacheLocation;

View File

@ -41,6 +41,7 @@ Q_PROPERTY(QString mapProvider READ mapProvider WRITE setMapProvider)
Q_PROPERTY(int zoommo READ zoom WRITE setZoom)
Q_PROPERTY(double latitude READ latitude WRITE setLatitude)
Q_PROPERTY(double longitude READ longitude WRITE setLongitude)
Q_PROPERTY(QString accessMode READ accessMode WRITE setAccessMode)
Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache)
Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation)
@ -53,6 +54,7 @@ public:
int zoom() const { return m_defaultZoom; }
double latitude() const { return m_defaultLatitude; }
double longitude() const { return m_defaultLongitude; }
QString accessMode() const { return m_accessMode; }
bool useMemoryCache() const { return m_useMemoryCache; }
QString cacheLocation() const { return m_cacheLocation; }
@ -61,6 +63,7 @@ public slots:
void setZoom(int zoom) { m_defaultZoom = zoom; }
void setLatitude(double latitude) { m_defaultLatitude = latitude; }
void setLongitude(double longitude) { m_defaultLongitude = longitude; }
void setAccessMode(QString accessMode) { m_accessMode = accessMode; }
void setUseMemoryCache(bool useMemoryCache) { m_useMemoryCache = useMemoryCache; }
void setCacheLocation(QString cacheLocation) { m_cacheLocation = cacheLocation; }
@ -69,6 +72,7 @@ private:
int m_defaultZoom;
double m_defaultLatitude;
double m_defaultLongitude;
QString m_accessMode;
bool m_useMemoryCache;
QString m_cacheLocation;

View File

@ -57,12 +57,22 @@ QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
m_page->providerComboBox->clear();
m_page->providerComboBox->addItems(mapcontrol::Helper::MapTypes());
// populate the access mode combobox
m_page->accessModeComboBox->clear();
m_page->accessModeComboBox->addItems(mapcontrol::Helper::AccessModeTypes());
int index = m_page->providerComboBox->findText(m_config->mapProvider());
index = (index >= 0) ? index : 0;
m_page->providerComboBox->setCurrentIndex(index);
m_page->zoomSpinBox->setValue(m_config->zoom());
m_page->latitudeSpinBox->setValue(m_config->latitude());
m_page->longitudeSpinBox->setValue(m_config->longitude());
index = m_page->accessModeComboBox->findText(m_config->accessMode());
index = (index >= 0) ? index : 0;
m_page->accessModeComboBox->setCurrentIndex(index);
m_page->pushButtonUseMemoryCache->setChecked(m_config->useMemoryCache());
m_page->lineEditCacheLocation->setText(m_config->cacheLocation());
@ -87,7 +97,12 @@ void OPMapGadgetOptionsPage::on_pushButtonCacheLocation_clicked()
void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked()
{
int index = m_page->accessModeComboBox->findText("ServerAndCache");
index = (index >= 0) ? index : 0;
m_page->accessModeComboBox->setCurrentIndex(index);
m_page->pushButtonUseMemoryCache->setChecked(true);
m_page->lineEditCacheLocation->setText(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator());
}
@ -97,6 +112,7 @@ void OPMapGadgetOptionsPage::apply()
m_config->setZoom(m_page->zoomSpinBox->value());
m_config->setLatitude(m_page->latitudeSpinBox->value());
m_config->setLongitude(m_page->longitudeSpinBox->value());
m_config->setAccessMode(m_page->accessModeComboBox->currentText());
m_config->setUseMemoryCache(m_page->pushButtonUseMemoryCache->isChecked());
m_config->setCacheLocation(m_page->lineEditCacheLocation->text());
}

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>521</width>
<height>315</height>
<height>373</height>
</rect>
</property>
<property name="sizePolicy">
@ -21,49 +21,159 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
<number>5</number>
</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>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QComboBox" name="providerComboBox">
<property name="cursor">
<cursorShape>OpenHandCursor</cursorShape>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string> Default </string>
<string>Map provider </string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default latitude </string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</spacer>
</widget>
</item>
<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="2" column="2">
<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="2" column="3">
<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="0" column="2">
<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="0" column="3">
<widget class="QSpinBox" name="zoomSpinBox">
<property name="maximum">
<number>18</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxShowGrid">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Show Grid</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="checkBoxUseOpenGL">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Use OpenGL</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Server and Cache</string>
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="5">
<widget class="QComboBox" name="accessModeComboBox">
<property name="cursor">
<cursorShape>OpenHandCursor</cursorShape>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Access Mode </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonUseMemoryCache">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -101,112 +211,62 @@ stop: 0 rgba(180, 190, 220, 255), stop: 1 rgba(200, 230, 255, 255));*/
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QComboBox" name="providerComboBox">
<item row="0" column="0">
<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>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Map provider</string>
<string> Default </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Default zoom</string>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="zoomSpinBox">
<property name="maximum">
<number>18</number>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default latitude</string>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</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>
</spacer>
</item>
</layout>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>

View File

@ -556,6 +556,12 @@ void OPMapGadgetWidget::setMapProvider(QString provider)
m_map->SetMapType(mapcontrol::Helper::MapTypeFromString(provider));
}
void OPMapGadgetWidget::setAccessMode(QString accessMode)
{
if (m_map)
m_map->configuration->SetAccessMode(mapcontrol::Helper::AccessModeFromString(accessMode));
}
void OPMapGadgetWidget::setUseMemoryCache(bool useMemoryCache)
{
if (m_map)

View File

@ -55,6 +55,7 @@ public:
void setZoom(int value);
void setPosition(QPointF pos);
void setMapProvider(QString provider);
void setAccessMode(QString accessMode);
void setUseMemoryCache(bool useMemoryCache);
void setCacheLocation(QString cacheLocation);