From 97a195baf14defa820ecf3e051006eaef4c1db85 Mon Sep 17 00:00:00 2001 From: pip Date: Mon, 14 Jun 2010 19:34:04 +0000 Subject: [PATCH] New map gadget addition .. not yet operational though. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@770 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/map/mapgadgetwidget.cpp | 49 ++++--- ground/src/plugins/map/mapgadgetwidget.h | 14 +- ground/src/plugins/map2/Map2Gadget.pluginspec | 10 ++ ground/src/plugins/map2/map2.pro | 11 ++ ground/src/plugins/map2/map2.qrc | 7 + .../src/plugins/map2/map2gadgetoptionspage.ui | 130 ++++++++++++++++++ ground/src/plugins/map2/map2plugin.cpp | 63 +++++++++ ground/src/plugins/map2/map2plugin.h | 47 +++++++ ground/src/plugins/plugins.pro | 6 + 9 files changed, 304 insertions(+), 33 deletions(-) create mode 100644 ground/src/plugins/map2/Map2Gadget.pluginspec create mode 100644 ground/src/plugins/map2/map2.pro create mode 100644 ground/src/plugins/map2/map2.qrc create mode 100644 ground/src/plugins/map2/map2gadgetoptionspage.ui create mode 100644 ground/src/plugins/map2/map2plugin.cpp create mode 100644 ground/src/plugins/map2/map2plugin.h diff --git a/ground/src/plugins/map/mapgadgetwidget.cpp b/ground/src/plugins/map/mapgadgetwidget.cpp index 2f312aab0..9010f67b3 100644 --- a/ground/src/plugins/map/mapgadgetwidget.cpp +++ b/ground/src/plugins/map/mapgadgetwidget.cpp @@ -37,24 +37,21 @@ MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent) { int size = 256; - gscButton = NULL; + gcsButton = NULL; uavButton = NULL; follow_uav = false; - gsc_pixmap.load(QString::fromUtf8(":/map/images/gsc.png")); + gcs_pixmap.load(QString::fromUtf8(":/map/images/gsc.png")); uav_pixmap.load(QString::fromUtf8(":/map/images/uav.png")); waypoint_pixmap.load(QString::fromUtf8(":/map/images/waypoint.png")); // waypoint_pixmap.load(QCoreApplication::applicationDirPath() + "/images/waypoint.png"); // test - if (gsc_pixmap.isNull()) QMessageBox::warning(this, tr("Image Error"), tr("Missing ") + QString::fromUtf8(":/map/images/gsc.png")); + if (gcs_pixmap.isNull()) QMessageBox::warning(this, tr("Image Error"), tr("Missing ") + QString::fromUtf8(":/map/images/gsc.png")); if (uav_pixmap.isNull()) QMessageBox::warning(this, tr("Image Error"), tr("Missing ") + QString::fromUtf8(":/map/images/uav.png")); if (waypoint_pixmap.isNull()) QMessageBox::warning(this, tr("Image Error"), tr("Missing ") + QString::fromUtf8(":/map/images/waypoint.png")); - // test - gsc_pixmap.save(QCoreApplication::applicationDirPath() + "/images/gsc2.png", "PNG"); - // Get required UAVObjects ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager* objManager = pm->getObject(); @@ -81,7 +78,7 @@ MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent) m_googleSatLayer = new MapLayer("Google Sat", m_googleSatAdapter); m_yahooLayer = new MapLayer("Yahoo", m_yahooAdapter); - // gsc and uav position layer + // gcs and uav position layer m_positionLayer = new GeometryLayer("PositionsLayer", m_osmAdapter); // Waypoint layer @@ -107,19 +104,19 @@ MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent) addCompass(QPointF(100, 100), 200); - // create and add the GSC icon - gscPoint = new ImagePoint(data.Longitude, data.Latitude, &gsc_pixmap, "GSC", Point::Middle); - m_positionLayer->addGeometry(gscPoint); - connect(gscPoint, SIGNAL(geometryClicked(Geometry*, QPoint)), this, SLOT(gsc_uav_ClickEvent(Geometry*, QPoint))); + // create and add the GCS icon + gcsPoint = new ImagePoint(data.Longitude, data.Latitude, &gcs_pixmap, "GSC", Point::Middle); + m_positionLayer->addGeometry(gcsPoint); + connect(gcsPoint, SIGNAL(geometryClicked(Geometry*, QPoint)), this, SLOT(gcs_uav_ClickEvent(Geometry*, QPoint))); // create and add the UAV icon uavPoint = new ImagePoint(data.Longitude, data.Latitude, &uav_pixmap, "UAV", Point::Middle); m_positionLayer->addGeometry(uavPoint); - connect(uavPoint, SIGNAL(geometryClicked(Geometry*, QPoint)), this, SLOT(gsc_uav_ClickEvent(Geometry*, QPoint))); + connect(uavPoint, SIGNAL(geometryClicked(Geometry*, QPoint)), this, SLOT(gcs_uav_ClickEvent(Geometry*, QPoint))); addUserControls(); - m_mc->setView(gscPoint->coordinate()); + m_mc->setView(gcsPoint->coordinate()); m_mc->setZoom(2); m_mc->updateRequestNew(); @@ -216,11 +213,11 @@ void MapGadgetWidget::resizeEvent(QResizeEvent *event) void MapGadgetWidget::addUserControls() { // create the user controls - gscButton = new QPushButton(tr("GCS")); - gscButton->setMinimumWidth(50); - gscButton->setMaximumWidth(50); - gscButton->setToolTip(tr("Center onto ground station control")); - connect(gscButton, SIGNAL(clicked(bool)), this, SLOT(gscButtonClick())); + gcsButton = new QPushButton(tr("GCS")); + gcsButton->setMinimumWidth(50); + gcsButton->setMaximumWidth(50); + gcsButton->setToolTip(tr("Center onto ground control station")); + connect(gcsButton, SIGNAL(clicked(bool)), this, SLOT(gcsButtonClick())); uavButton = new QPushButton(tr("UAV")); uavButton->setMinimumWidth(50); @@ -246,7 +243,7 @@ void MapGadgetWidget::addUserControls() innerlayout->setSpacing(3); innerlayout->setMargin(2); innerlayout->addSpacing(10); - innerlayout->addWidget(gscButton); + innerlayout->addWidget(gcsButton); innerlayout->addWidget(uavButton); innerlayout->addSpacing(10); innerlayout->addWidget(zoomin); @@ -257,12 +254,12 @@ void MapGadgetWidget::addUserControls() // ************************************************************************************* -void MapGadgetWidget::gscButtonClick() +void MapGadgetWidget::gcsButtonClick() { follow_uav = false; uavButton->setChecked(follow_uav); - setPosition(gscPoint->coordinate()); // center the map onto the ground station + setPosition(gcsPoint->coordinate()); // center the map onto the ground station } // ************************************************************************************* @@ -302,9 +299,9 @@ void MapGadgetWidget::coordinateEvent(const QMouseEvent * evnt, const QPointF co } // ************************************************************************************* -// comes here when the user mouse clicks on the GSC or the UAV +// comes here when the user mouse clicks on the GCS or the UAV -void MapGadgetWidget::gsc_uav_ClickEvent(Geometry* geom, QPoint) +void MapGadgetWidget::gcs_uav_ClickEvent(Geometry* geom, QPoint) { qDebug() << "parent: " << geom->parentGeometry(); qDebug() << "Element clicked: " << geom->name(); @@ -328,9 +325,9 @@ void MapGadgetWidget::gsc_uav_ClickEvent(Geometry* geom, QPoint) QMessageBox::information(this, geom->name(), tr("The UAV location")); } else - if (geom->name() == "GSC") + if (geom->name() == "GCS") { - QMessageBox::information(this, geom->name(), tr("The GSC location")); + QMessageBox::information(this, geom->name(), tr("The GCS location")); } else QMessageBox::information(this, geom->name(), tr("just a point")); @@ -439,7 +436,7 @@ void MapGadgetWidget::keyPressEvent(QKeyEvent* event) else if (event->key() == Qt::Key_F1) // F1 { - gscButtonClick(); + gcsButtonClick(); } else if (event->key() == Qt::Key_F2) // F2 diff --git a/ground/src/plugins/map/mapgadgetwidget.h b/ground/src/plugins/map/mapgadgetwidget.h index 4bcde1bc2..a156e3ae6 100644 --- a/ground/src/plugins/map/mapgadgetwidget.h +++ b/ground/src/plugins/map/mapgadgetwidget.h @@ -50,10 +50,10 @@ public: public slots: void coordinateEvent(const QMouseEvent* evnt, const QPointF coordinate); // added by cathy - void gsc_uav_ClickEvent(Geometry* geom, QPoint coord_px); // added by cathy + void gcs_uav_ClickEvent(Geometry* geom, QPoint coord_px); // added by cathy void wayPointClickEvent(Geometry* geom, QPoint coord_px); // added by cathy - void gscButtonClick(); // added by cathy + void gcsButtonClick(); // added by cathy void uavButtonClick(bool checked); // added by cathy protected: @@ -64,7 +64,7 @@ private slots: void updatePosition(); private: - void addUserControls(); // changed by cathy + void addUserControls(); bool follow_uav; // true if the map is to stay centered on the UAV @@ -87,17 +87,17 @@ private: FixedImageOverlay *m_compassImageOverlay; - ImagePoint *gscPoint; + ImagePoint *gcsPoint; ImagePoint *uavPoint; QTimer *m_updateTimer; PositionActual *m_positionActual; - QPushButton *gscButton; // added by cathy - QPushButton *uavButton; // added by cathy + QPushButton *gcsButton; + QPushButton *uavButton; - QPixmap gsc_pixmap; + QPixmap gcs_pixmap; QPixmap uav_pixmap; QPixmap waypoint_pixmap; QPixmap compass_background_pixmap; diff --git a/ground/src/plugins/map2/Map2Gadget.pluginspec b/ground/src/plugins/map2/Map2Gadget.pluginspec new file mode 100644 index 000000000..243b4c68b --- /dev/null +++ b/ground/src/plugins/map2/Map2Gadget.pluginspec @@ -0,0 +1,10 @@ + + The OpenPilot Project + (C) 2010 OpenPilot Project + The GNU Public License (GPL) Version 3 + A new map gadget! + http://www.openpilot.org + + + + diff --git a/ground/src/plugins/map2/map2.pro b/ground/src/plugins/map2/map2.pro new file mode 100644 index 000000000..f8c919160 --- /dev/null +++ b/ground/src/plugins/map2/map2.pro @@ -0,0 +1,11 @@ +TEMPLATE = lib +TARGET = Map2Gadget +include(../../openpilotgcsplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) +include(../../libs/opmapcontrol/opmapcontrol.pri) +include(../../plugins/uavobjects/uavobjects.pri) +HEADERS += map2plugin.h +SOURCES += map2plugin.cpp +OTHER_FILES += Map2Gadget.pluginspec +FORMS += map2gadgetoptionspage.ui +RESOURCES += map2.qrc diff --git a/ground/src/plugins/map2/map2.qrc b/ground/src/plugins/map2/map2.qrc new file mode 100644 index 000000000..909914592 --- /dev/null +++ b/ground/src/plugins/map2/map2.qrc @@ -0,0 +1,7 @@ + + + images/waypoint.png + images/uav.png + images/gcs.png + + diff --git a/ground/src/plugins/map2/map2gadgetoptionspage.ui b/ground/src/plugins/map2/map2gadgetoptionspage.ui new file mode 100644 index 000000000..ee91b339d --- /dev/null +++ b/ground/src/plugins/map2/map2gadgetoptionspage.ui @@ -0,0 +1,130 @@ + + + MapGadgetOptionsPage + + + + 0 + 0 + 400 + 300 + + + + Form + + + + 0 + + + + + Map provider: + + + + + + + + OpenStreetMap + + + + + Google + + + + + Google Sat + + + + + + + + Default zoom: + + + + + + + 18 + + + + + + + Default latitude: + + + + + + + 8 + + + -90.000000000000000 + + + 90.000000000000000 + + + + + + + Default longitude: + + + + + + + 8 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + diff --git a/ground/src/plugins/map2/map2plugin.cpp b/ground/src/plugins/map2/map2plugin.cpp new file mode 100644 index 000000000..354222dcb --- /dev/null +++ b/ground/src/plugins/map2/map2plugin.cpp @@ -0,0 +1,63 @@ +/** + ****************************************************************************** + * + * @file map2plugin.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup map2 + * @{ + * + *****************************************************************************/ +/* + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * 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., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "map2plugin.h" +//#include "map2gadgetfactory.h" +#include +#include +#include + +Map2Plugin::Map2Plugin() +{ + // Do nothing +} + +Map2Plugin::~Map2Plugin() +{ + // Do nothing +} + +bool Map2Plugin::initialize(const QStringList& args, QString *errMsg) +{ + Q_UNUSED(args); + Q_UNUSED(errMsg); + +// mf = new Map2GadgetFactory(this); +// addAutoReleasedObject(mf); + + return true; +} + +void Map2Plugin::extensionsInitialized() +{ + // Do nothing +} + +void Map2Plugin::shutdown() +{ + // Do nothing +} +Q_EXPORT_PLUGIN(Map2Plugin) diff --git a/ground/src/plugins/map2/map2plugin.h b/ground/src/plugins/map2/map2plugin.h new file mode 100644 index 000000000..cb7c77032 --- /dev/null +++ b/ground/src/plugins/map2/map2plugin.h @@ -0,0 +1,47 @@ +/** + ****************************************************************************** + * + * @file map2plugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup map2 + * @{ + * + *****************************************************************************/ +/* + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * 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., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MAP2_PLUGIN_H_ +#define MAP2_PLUGIN_H_ + +#include + +//class Map2GadgetFactory; + +class Map2Plugin : public ExtensionSystem::IPlugin +{ +public: + Map2Plugin(); + ~Map2Plugin(); + + void extensionsInitialized(); + bool initialize(const QStringList & arguments, QString * errorString); + void shutdown(); +private: +// Map2GadgetFactory *mf; +}; +#endif /* MAP2_PLUGIN_H_ */ diff --git a/ground/src/plugins/plugins.pro b/ground/src/plugins/plugins.pro index bd90b1602..52599b34e 100644 --- a/ground/src/plugins/plugins.pro +++ b/ground/src/plugins/plugins.pro @@ -50,6 +50,12 @@ plugin_map.depends = plugin_coreplugin plugin_map.depends = plugin_uavobjects SUBDIRS += plugin_map +# Map2 UAVGadget +plugin_map2.subdir = map2 +plugin_map2.depends = plugin_coreplugin +plugin_map2.depends = plugin_uavobjects +SUBDIRS += plugin_map2 + # Scope UAVGadget plugin_scope.subdir = scope plugin_scope.depends = plugin_coreplugin