mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-05 21:52:10 +01:00
Additions to the new OPMap plug-in.
Working on fixing the Options Page menu locking up git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@782 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
092c22f542
commit
c86c875572
@ -4,8 +4,18 @@ include(../../openpilotgcsplugin.pri)
|
|||||||
include(../../plugins/coreplugin/coreplugin.pri)
|
include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
include(../../libs/opmapcontrol/opmapcontrol.pri)
|
include(../../libs/opmapcontrol/opmapcontrol.pri)
|
||||||
include(../../plugins/uavobjects/uavobjects.pri)
|
include(../../plugins/uavobjects/uavobjects.pri)
|
||||||
HEADERS += opmapplugin.h
|
HEADERS += opmapplugin.h \
|
||||||
SOURCES += opmapplugin.cpp
|
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
|
OTHER_FILES += OPMapGadget.pluginspec
|
||||||
FORMS += opmapgadgetoptionspage.ui
|
FORMS += opmapgadgetoptionspage.ui
|
||||||
RESOURCES += opmap.qrc
|
RESOURCES += opmap.qrc
|
||||||
|
49
ground/src/plugins/opmap/opmapgadget.cpp
Normal file
49
ground/src/plugins/opmap/opmapgadget.cpp
Normal file
@ -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<OPMapGadgetConfiguration*>(config);
|
||||||
|
m_widget->setMapProvider(m->mapProvider());
|
||||||
|
m_widget->setZoom(m->zoom());
|
||||||
|
m_widget->setPosition(QPointF(m->longitude(), m->latitude()));
|
||||||
|
}
|
||||||
|
|
57
ground/src/plugins/opmap/opmapgadget.h
Normal file
57
ground/src/plugins/opmap/opmapgadget.h
Normal file
@ -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 <coreplugin/iuavgadget.h>
|
||||||
|
#include "opmapgadgetwidget.h"
|
||||||
|
|
||||||
|
class IUAVGadget;
|
||||||
|
//class QList<int>;
|
||||||
|
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_
|
77
ground/src/plugins/opmap/opmapgadgetconfiguration.cpp
Normal file
77
ground/src/plugins/opmap/opmapgadgetconfiguration.cpp
Normal file
@ -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 <QtCore/QDataStream>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
67
ground/src/plugins/opmap/opmapgadgetconfiguration.h
Normal file
67
ground/src/plugins/opmap/opmapgadgetconfiguration.h
Normal file
@ -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 <coreplugin/iuavgadgetconfiguration.h>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
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
|
58
ground/src/plugins/opmap/opmapgadgetfactory.cpp
Normal file
58
ground/src/plugins/opmap/opmapgadgetfactory.cpp
Normal file
@ -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 <coreplugin/iuavgadget.h>
|
||||||
|
|
||||||
|
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<OPMapGadgetConfiguration*>(config));
|
||||||
|
}
|
||||||
|
|
52
ground/src/plugins/opmap/opmapgadgetfactory.h
Normal file
52
ground/src/plugins/opmap/opmapgadgetfactory.h
Normal file
@ -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 <coreplugin/iuavgadgetfactory.h>
|
||||||
|
|
||||||
|
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_
|
74
ground/src/plugins/opmap/opmapgadgetoptionspage.cpp
Normal file
74
ground/src/plugins/opmap/opmapgadgetoptionspage.cpp
Normal file
@ -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 <QtGui/QLabel>
|
||||||
|
#include <QtGui/QComboBox>
|
||||||
|
#include <QtGui/QSpinBox>
|
||||||
|
#include <QtGui/QDoubleSpinBox>
|
||||||
|
#include <QtGui/QHBoxLayout>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
63
ground/src/plugins/opmap/opmapgadgetoptionspage.h
Normal file
63
ground/src/plugins/opmap/opmapgadgetoptionspage.h
Normal file
@ -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
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>Map2GadgetOptionsPage</class>
|
<class>OPMapGadgetOptionsPage</class>
|
||||||
<widget class="QWidget" name="Map2GadgetOptionsPage">
|
<widget class="QWidget" name="OPMapGadgetOptionsPage">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
160
ground/src/plugins/opmap/opmapgadgetwidget.cpp
Normal file
160
ground/src/plugins/opmap/opmapgadgetwidget.cpp
Normal file
@ -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 <QStringList>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
#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<UAVObjectManager>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// *************************************************************************************
|
78
ground/src/plugins/opmap/opmapgadgetwidget.h
Normal file
78
ground/src/plugins/opmap/opmapgadgetwidget.h
Normal file
@ -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 <QtGui/QWidget>
|
||||||
|
#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_ */
|
@ -25,7 +25,7 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "opmapplugin.h"
|
#include "opmapplugin.h"
|
||||||
//#include "opmapgadgetfactory.h"
|
#include "opmapgadgetfactory.h"
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
@ -45,8 +45,8 @@ bool OPMapPlugin::initialize(const QStringList& args, QString *errMsg)
|
|||||||
Q_UNUSED(args);
|
Q_UNUSED(args);
|
||||||
Q_UNUSED(errMsg);
|
Q_UNUSED(errMsg);
|
||||||
|
|
||||||
// mf = new OPMapGadgetFactory(this);
|
mf = new OPMapGadgetFactory(this);
|
||||||
// addAutoReleasedObject(mf);
|
addAutoReleasedObject(mf);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
//class OPMapGadgetFactory;
|
class OPMapGadgetFactory;
|
||||||
|
|
||||||
class OPMapPlugin : public ExtensionSystem::IPlugin
|
class OPMapPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
@ -42,6 +42,6 @@ public:
|
|||||||
bool initialize(const QStringList & arguments, QString * errorString);
|
bool initialize(const QStringList & arguments, QString * errorString);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
private:
|
private:
|
||||||
// OPMapGadgetFactory *mf;
|
OPMapGadgetFactory *mf;
|
||||||
};
|
};
|
||||||
#endif /* OPMAP_PLUGIN_H_ */
|
#endif /* OPMAP_PLUGIN_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user