diff --git a/ground/src/plugins/opmap/opmap.pro b/ground/src/plugins/opmap/opmap.pro index ce5a15cfa..e34b9c00f 100644 --- a/ground/src/plugins/opmap/opmap.pro +++ b/ground/src/plugins/opmap/opmap.pro @@ -4,8 +4,18 @@ include(../../openpilotgcsplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../libs/opmapcontrol/opmapcontrol.pri) include(../../plugins/uavobjects/uavobjects.pri) -HEADERS += opmapplugin.h -SOURCES += opmapplugin.cpp +HEADERS += opmapplugin.h \ + opmapgadgetoptionspage.h \ + opmapgadgetfactory.h \ + opmapgadgetconfiguration.h \ + opmapgadget.h \ + opmapgadgetwidget.h +SOURCES += opmapplugin.cpp \ + opmapgadgetwidget.cpp \ + opmapgadgetoptionspage.cpp \ + opmapgadgetfactory.cpp \ + opmapgadgetconfiguration.cpp \ + opmapgadget.cpp OTHER_FILES += OPMapGadget.pluginspec FORMS += opmapgadgetoptionspage.ui RESOURCES += opmap.qrc diff --git a/ground/src/plugins/opmap/opmapgadget.cpp b/ground/src/plugins/opmap/opmapgadget.cpp new file mode 100644 index 000000000..436ec2455 --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadget.cpp @@ -0,0 +1,49 @@ +/** + ****************************************************************************** + * + * @file opmapgadget.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 "opmapgadget.h" +#include "opmapgadgetwidget.h" +#include "opmapgadgetconfiguration.h" + +OPMapGadget::OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *parent) : + IUAVGadget(classId, parent), + m_widget(widget) +{ +} + +OPMapGadget::~OPMapGadget() +{ + +} + +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/opmapgadget.h b/ground/src/plugins/opmap/opmapgadget.h new file mode 100644 index 000000000..813862f97 --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadget.h @@ -0,0 +1,57 @@ +/** + ****************************************************************************** + * + * @file opmapgadget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 OPMAP_GADGET_H_ +#define OPMAP_GADGET_H_ + +#include +#include "opmapgadgetwidget.h" + +class IUAVGadget; +//class QList; +class QWidget; +class QString; +class OPMapGadgetWidget; + +using namespace Core; + +class OPMapGadget : public Core::IUAVGadget +{ + Q_OBJECT +public: + OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *parent = 0); + ~OPMapGadget(); + + QWidget *widget() { return m_widget; } + void loadConfiguration(IUAVGadgetConfiguration* config); + +private: + OPMapGadgetWidget *m_widget; +}; + + +#endif // OPMAP_GADGET_H_ diff --git a/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp b/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp new file mode 100644 index 000000000..cd1f47657 --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp @@ -0,0 +1,77 @@ +/** + ****************************************************************************** + * + * @file opmapgadgetconfiguration.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 "opmapgadgetconfiguration.h" +#include + +OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) : + IUAVGadgetConfiguration(classId, parent), + m_mapProvider("OpenStreetMap"), + m_defaultZoom(10), + m_defaultLatitude(0), + m_defaultLongitude(0) +{ + if (state.count() > 0) { + QDataStream stream(state); + int zoom; + double latitude; + double longitude; + QString mapProvider; + stream >> zoom; + stream >> latitude; + stream >> longitude; + stream >> mapProvider; + m_defaultZoom = zoom; + m_defaultLatitude = latitude; + m_defaultLongitude = longitude; + if (mapProvider != "") + m_mapProvider = mapProvider; + + } +} + +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; + return m; +} + +QByteArray OPMapGadgetConfiguration::saveState() const +{ + QByteArray bytes; + QDataStream stream(&bytes, QIODevice::WriteOnly); + stream << m_defaultZoom; + stream << m_defaultLatitude; + stream << m_defaultLongitude; + stream << m_mapProvider; + return bytes; +} + diff --git a/ground/src/plugins/opmap/opmapgadgetconfiguration.h b/ground/src/plugins/opmap/opmapgadgetconfiguration.h new file mode 100644 index 000000000..3a3938d36 --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadgetconfiguration.h @@ -0,0 +1,67 @@ +/** + ****************************************************************************** + * + * @file opmapgadgetconfiguration.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 OPMAP_GADGETCONFIGURATION_H +#define OPMAP_GADGETCONFIGURATION_H + +#include +#include + +using namespace Core; + +class OPMapGadgetConfiguration : public IUAVGadgetConfiguration +{ +Q_OBJECT +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) +public: + explicit OPMapGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); + QByteArray saveState() const; + IUAVGadgetConfiguration *clone(); + + QString mapProvider() const { return m_mapProvider; } + int zoom() const { return m_defaultZoom; } + double latitude() const { return m_defaultLatitude; } + double longitude() const { return m_defaultLongitude; } + +public slots: + void setMapProvider(QString provider) { m_mapProvider = provider; } + void setZoom(int zoom) { m_defaultZoom = zoom; } + void setLatitude(double latitude) { m_defaultLatitude = latitude; } + void setLongitude(double longitude) { m_defaultLongitude = longitude; } + +private: + QString m_mapProvider; + int m_defaultZoom; + double m_defaultLatitude; + double m_defaultLongitude; + +}; + +#endif // OPMAP_GADGETCONFIGURATION_H diff --git a/ground/src/plugins/opmap/opmapgadgetfactory.cpp b/ground/src/plugins/opmap/opmapgadgetfactory.cpp new file mode 100644 index 000000000..aaf11c9ef --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadgetfactory.cpp @@ -0,0 +1,58 @@ +/** + ****************************************************************************** + * + * @file opmapgadgetfactory.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 "opmapgadgetfactory.h" +#include "opmapgadgetwidget.h" +#include "opmapgadget.h" +#include "opmapgadgetconfiguration.h" +#include "opmapgadgetoptionspage.h" +#include + +OPMapGadgetFactory::OPMapGadgetFactory(QObject *parent) : + IUAVGadgetFactory(QString("OPMapGadget"), tr("OPMap Gadget"), parent) +{ +} + +OPMapGadgetFactory::~OPMapGadgetFactory() +{ +} + +Core::IUAVGadget* OPMapGadgetFactory::createGadget(QWidget *parent) +{ + OPMapGadgetWidget* gadgetWidget = new OPMapGadgetWidget(parent); + return new OPMapGadget(QString("MapGadget"), gadgetWidget, parent); +} + +IUAVGadgetConfiguration *OPMapGadgetFactory::createConfiguration(const QByteArray &state) +{ + return new OPMapGadgetConfiguration(QString("OPMapGadget"), state); +} + +IOptionsPage *OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) +{ + return new OPMapGadgetOptionsPage(qobject_cast(config)); +} + diff --git a/ground/src/plugins/opmap/opmapgadgetfactory.h b/ground/src/plugins/opmap/opmapgadgetfactory.h new file mode 100644 index 000000000..75a538929 --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadgetfactory.h @@ -0,0 +1,52 @@ +/** + ****************************************************************************** + * + * @file opmapgadgetfactory.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 OPAMP_GADGETFACTORY_H_ +#define OPMAP_GADGETFACTORY_H_ + +#include + +namespace Core { +class IUAVGadget; +class IUAVGadgetFactory; +} + +using namespace Core; + +class OPMapGadgetFactory : public Core::IUAVGadgetFactory +{ + Q_OBJECT +public: + OPMapGadgetFactory(QObject *parent = 0); + ~OPMapGadgetFactory(); + + Core::IUAVGadget *createGadget(QWidget *parent); + IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); + IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); +}; + +#endif // OPMAP_GADGETFACTORY_H_ diff --git a/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp b/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp new file mode 100644 index 000000000..47dc67b29 --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp @@ -0,0 +1,74 @@ +/** + ****************************************************************************** + * + * @file opmapgadgetoptionspage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 "opmapgadgetoptionspage.h" +#include "opmapgadgetconfiguration.h" +#include +#include +#include +#include +#include +#include + +#include "ui_opmapgadgetoptionspage.h" + + +OPMapGadgetOptionsPage::OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent) : + IOptionsPage(parent), + m_config(config) +{ +} + +QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent) +{ + m_page = new Ui::OPMapGadgetOptionsPage(); + QWidget *w = new QWidget(parent); + m_page->setupUi(w); + + 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()); + + return w; +} + +void OPMapGadgetOptionsPage::apply() +{ + m_config->setMapProvider(m_page->providerComboBox->currentText()); + m_config->setZoom(m_page->zoomSpinBox->value()); + m_config->setLatitude(m_page->latitudeSpinBox->value()); + m_config->setLongitude(m_page->longitudeSpinBox->value()); +} + +void OPMapGadgetOptionsPage::finish() +{ + delete m_page; +} + diff --git a/ground/src/plugins/opmap/opmapgadgetoptionspage.h b/ground/src/plugins/opmap/opmapgadgetoptionspage.h new file mode 100644 index 000000000..9a477f416 --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadgetoptionspage.h @@ -0,0 +1,63 @@ +/** + ****************************************************************************** + * + * @file opmapgadgetoptionspage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 OPMAP_GADGETOPTIONSPAGE_H +#define OPMAP_GADGETOPTIONSPAGE_H + +#include "coreplugin/dialogs/ioptionspage.h" + +class OPMapGadgetConfiguration; + +namespace Core { + class IUAVGadgetConfiguration; +} + +namespace Ui { + class OPMapGadgetOptionsPage; +} + +using namespace Core; + +class OPMapGadgetOptionsPage : public IOptionsPage +{ +Q_OBJECT +public: + explicit OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent = 0); + + QWidget *createPage(QWidget *parent); + void apply(); + void finish(); + +signals: + +public slots: +private: + OPMapGadgetConfiguration *m_config; + Ui::OPMapGadgetOptionsPage *m_page; +}; + +#endif // OPMAP_GADGETOPTIONSPAGE_H diff --git a/ground/src/plugins/opmap/opmapgadgetoptionspage.ui b/ground/src/plugins/opmap/opmapgadgetoptionspage.ui index 10f1cb258..7d10c1ce1 100644 --- a/ground/src/plugins/opmap/opmapgadgetoptionspage.ui +++ b/ground/src/plugins/opmap/opmapgadgetoptionspage.ui @@ -1,7 +1,7 @@ - Map2GadgetOptionsPage - + OPMapGadgetOptionsPage + 0 diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.cpp b/ground/src/plugins/opmap/opmapgadgetwidget.cpp new file mode 100644 index 000000000..eb1a450ea --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadgetwidget.cpp @@ -0,0 +1,160 @@ +/** + ****************************************************************************** + * + * @file opmapgadgetwidget.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 "opmapgadgetwidget.h" +#include +#include +#include +#include "extensionsystem/pluginmanager.h" + +// ************************************************************************************* +// constructor + +OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) +{ + int size = 256; + + // Get required UAVObjects + ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager* objManager = pm->getObject(); + m_positionActual = PositionActual::GetInstance(objManager); + + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + + map = NULL; +// map = new mapcontrol::OPMapWidget(); +// map->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); +// map->setMinimumSize(64, 64); + + PositionActual::DataFields data = m_positionActual->getData(); // get current position data + +// QVBoxLayout *layout = new QVBoxLayout; +// layout->setSpacing(0); +// layout->setContentsMargins(0, 0, 0, 0); +// layout->addWidget(map); +// setLayout(layout); + +// m_updateTimer = new QTimer(); +// m_updateTimer->setInterval(250); +// connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updatePosition())); +// m_updateTimer->start(); +} + +// ************************************************************************************* +// destructor + +OPMapGadgetWidget::~OPMapGadgetWidget() +{ + if (map) delete map; + // Do nothing +} + +// ************************************************************************************* + +void OPMapGadgetWidget::setZoom(int value) +{ +// map->setZoom(value); +// map->updateRequestNew(); +} + +void OPMapGadgetWidget::setPosition(QPointF pos) +{ +// map->setView(pos); +// map->updateRequestNew(); +} + +void OPMapGadgetWidget::setMapProvider(QString provider) +{ +// map-> +} + +// ************************************************************************************* + +void OPMapGadgetWidget::updatePosition() +{ + PositionActual::DataFields data = m_positionActual->getData(); // get current position data + +// uavPoint->setCoordinate(QPointF(data.Longitude, data.Latitude)); // move the UAV icon +// +// if (follow_uav) +// setPosition(uavPoint->coordinate()); // center the map onto the UAV +} + +// ************************************************************************************* + +void OPMapGadgetWidget::resizeEvent(QResizeEvent *event) +{ +// map->resize(QSize(width(), height())); + update(); + QWidget::resizeEvent(event); +} + +// ************************************************************************************* + +void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Escape) // ESC + { + } + else + if (event->key() == Qt::Key_F1) // F1 + { + } + else + if (event->key() == Qt::Key_F2) // F2 + { + } + else + if (event->key() == Qt::Key_Up) + { + } + else + if (event->key() == Qt::Key_Down) + { + } + else + if (event->key() == Qt::Key_Left) + { + } + else + if (event->key() == Qt::Key_Right) + { + } + else + if (event->key() == Qt::Key_PageUp) + { + } + else + if (event->key() == Qt::Key_PageDown) + { + } + else + { + qDebug() << event->key() << endl; + } +} + +// ************************************************************************************* diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.h b/ground/src/plugins/opmap/opmapgadgetwidget.h new file mode 100644 index 000000000..70029b8b8 --- /dev/null +++ b/ground/src/plugins/opmap/opmapgadgetwidget.h @@ -0,0 +1,78 @@ +/** + ****************************************************************************** + * + * @file opmapgadgetwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup opmap + * @{ + * + *****************************************************************************/ +/* + * 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 OPMAP_GADGETWIDGET_H_ +#define OPMAP_GADGETWIDGET_H_ + +#include "opmapcontrol/opmapcontrol.h" +#include +#include "uavobjects/uavobjectmanager.h" +#include "uavobjects/positionactual.h" + +using namespace mapcontrol; + +class OPMapGadgetWidget : public QWidget +{ + Q_OBJECT + +public: + OPMapGadgetWidget(QWidget *parent = 0); + ~OPMapGadgetWidget(); + + void setZoom(int value); + void setPosition(QPointF pos); + void setMapProvider(QString provider); + +public slots: +// void gcsButtonClick(); // added by cathy +// void uavButtonClick(bool checked); // added by cathy + +protected: + void resizeEvent(QResizeEvent *event); + void keyPressEvent(QKeyEvent* event); // added by cathy + +private slots: + void updatePosition(); + +private: +// void addUserControls(); + + bool follow_uav; // true if the map is to stay centered on the UAV + + double heading; // compass/uav heading + + mapcontrol::OPMapWidget *map; + + QTimer *m_updateTimer; + + PositionActual *m_positionActual; + + QPushButton *gcsButton; + QPushButton *uavButton; +}; + +#endif /* OPMAP_GADGETWIDGET_H_ */ diff --git a/ground/src/plugins/opmap/opmapplugin.cpp b/ground/src/plugins/opmap/opmapplugin.cpp index 26d1293cc..c12eb6781 100644 --- a/ground/src/plugins/opmap/opmapplugin.cpp +++ b/ground/src/plugins/opmap/opmapplugin.cpp @@ -25,7 +25,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "opmapplugin.h" -//#include "opmapgadgetfactory.h" +#include "opmapgadgetfactory.h" #include #include #include @@ -45,8 +45,8 @@ bool OPMapPlugin::initialize(const QStringList& args, QString *errMsg) Q_UNUSED(args); Q_UNUSED(errMsg); -// mf = new OPMapGadgetFactory(this); -// addAutoReleasedObject(mf); + mf = new OPMapGadgetFactory(this); + addAutoReleasedObject(mf); return true; } diff --git a/ground/src/plugins/opmap/opmapplugin.h b/ground/src/plugins/opmap/opmapplugin.h index df34d4e55..78c844da7 100644 --- a/ground/src/plugins/opmap/opmapplugin.h +++ b/ground/src/plugins/opmap/opmapplugin.h @@ -30,7 +30,7 @@ #include -//class OPMapGadgetFactory; +class OPMapGadgetFactory; class OPMapPlugin : public ExtensionSystem::IPlugin { @@ -42,6 +42,6 @@ public: bool initialize(const QStringList & arguments, QString * errorString); void shutdown(); private: -// OPMapGadgetFactory *mf; + OPMapGadgetFactory *mf; }; #endif /* OPMAP_PLUGIN_H_ */