mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
GCS/map: A map gadget to have something more interesting to look at than the emptygadget.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@339 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
7884356cf6
commit
3c15818b3b
10
ground/src/plugins/map/MapGadget.pluginspec
Normal file
10
ground/src/plugins/map/MapGadget.pluginspec
Normal file
@ -0,0 +1,10 @@
|
||||
<plugin name="MapGadget" version="1.0.0" compatVersion="1.0.0">
|
||||
<vendor>The OpenPilot Project</vendor>
|
||||
<copyright>(C) 2010 OpenPilot Project</copyright>
|
||||
<license></license>
|
||||
<description>A map gadget!</description>
|
||||
<url>http://www.openpilot.org</url>
|
||||
<dependencyList>
|
||||
<dependency name="Core" version="1.0.0"/>
|
||||
</dependencyList>
|
||||
</plugin>
|
18
ground/src/plugins/map/map.pro
Normal file
18
ground/src/plugins/map/map.pro
Normal file
@ -0,0 +1,18 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = MapGadget
|
||||
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
|
||||
include(../../libs/qmapcontrol/qmapcontrol.pri)
|
||||
|
||||
HEADERS += mapplugin.h
|
||||
HEADERS += mapgadget.h
|
||||
HEADERS += mapgadgetwidget.h
|
||||
HEADERS += mapgadgetfactory.h
|
||||
SOURCES += mapplugin.cpp
|
||||
SOURCES += mapgadget.cpp
|
||||
SOURCES += mapgadgetfactory.cpp
|
||||
SOURCES += mapgadgetwidget.cpp
|
||||
|
||||
OTHER_FILES += MapGadget.pluginspec
|
21
ground/src/plugins/map/mapgadget.cpp
Normal file
21
ground/src/plugins/map/mapgadget.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* mapgadget.cpp
|
||||
*
|
||||
* Created on: Mar 11, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
#include "mapgadget.h"
|
||||
#include "mapgadgetwidget.h"
|
||||
#include <QtGui/QToolBar>
|
||||
|
||||
MapGadget::MapGadget(MapGadgetWidget *widget) :
|
||||
IUAVGadget(widget),
|
||||
m_widget(widget),
|
||||
m_toolbar(new QToolBar())
|
||||
{
|
||||
}
|
||||
|
||||
MapGadget::~MapGadget()
|
||||
{
|
||||
|
||||
}
|
40
ground/src/plugins/map/mapgadget.h
Normal file
40
ground/src/plugins/map/mapgadget.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* mapgadget.h
|
||||
*
|
||||
* Created on: Mar 11, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
|
||||
#ifndef MAPGADGET_H_
|
||||
#define MAPGADGET_H_
|
||||
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
class IUAVGadget;
|
||||
//class QList<int>;
|
||||
class QWidget;
|
||||
class QString;
|
||||
class MapGadgetWidget;
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class MapGadget : public Core::IUAVGadget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MapGadget(MapGadgetWidget *widget = 0);
|
||||
~MapGadget();
|
||||
|
||||
QList<int> context() const { return m_context; }
|
||||
QWidget *widget() { return m_widget; }
|
||||
QString contextHelpId() const { return QString(); }
|
||||
|
||||
QWidget *toolBar() { return m_toolbar; }
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
QWidget *m_toolbar;
|
||||
QList<int> m_context;
|
||||
};
|
||||
|
||||
|
||||
#endif // MAPGADGET_H_
|
28
ground/src/plugins/map/mapgadgetfactory.cpp
Normal file
28
ground/src/plugins/map/mapgadgetfactory.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* mapgadgetfactory.cpp
|
||||
*
|
||||
* Created on: Mar 11, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
#include "mapgadgetfactory.h"
|
||||
#include "mapgadgetwidget.h"
|
||||
#include "mapgadget.h"
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
MapGadgetFactory::MapGadgetFactory(QObject *parent) : IUAVGadgetFactory(parent)
|
||||
{
|
||||
}
|
||||
|
||||
MapGadgetFactory::~MapGadgetFactory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Core::IUAVGadget* MapGadgetFactory::createUAVGadget(QWidget *parent) {
|
||||
MapGadgetWidget* gadgetWidget = new MapGadgetWidget(parent);
|
||||
return new MapGadget(gadgetWidget);
|
||||
}
|
||||
|
||||
QString MapGadgetFactory::name() {
|
||||
return QString("MapGadget");
|
||||
}
|
28
ground/src/plugins/map/mapgadgetfactory.h
Normal file
28
ground/src/plugins/map/mapgadgetfactory.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* mapgadgetfactory.h
|
||||
*
|
||||
* Created on: Mar 6, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
|
||||
#ifndef MAPGADGETFACTORY_H_
|
||||
#define MAPGADGETFACTORY_H_
|
||||
|
||||
#include <coreplugin/iuavgadgetfactory.h>
|
||||
|
||||
using namespace Core;
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetFactory;
|
||||
|
||||
class MapGadgetFactory : public Core::IUAVGadgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MapGadgetFactory(QObject *parent = 0);
|
||||
~MapGadgetFactory();
|
||||
|
||||
Core::IUAVGadget *createUAVGadget(QWidget *parent);
|
||||
QString name();
|
||||
};
|
||||
|
||||
#endif // MAPGADGETFACTORY_H_
|
66
ground/src/plugins/map/mapgadgetwidget.cpp
Normal file
66
ground/src/plugins/map/mapgadgetwidget.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* mapgadgetwidget.cpp
|
||||
*
|
||||
* Created on: Mar 6, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
#include "mapgadgetwidget.h"
|
||||
#include <QStringList>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
|
||||
MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
int size = 256;
|
||||
mc = new MapControl(QSize(size, size));
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
mc->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
mc->setMinimumSize(64, 64);
|
||||
mc->showScale(true);
|
||||
mapadapter = new OSMMapAdapter();
|
||||
mainlayer = new MapLayer("OpenStreetMap-Layer", mapadapter);
|
||||
mc->addLayer(mainlayer);
|
||||
|
||||
addZoomButtons();
|
||||
mc->setView(QPointF(5.718888888888, 58.963333333333));
|
||||
mc->setZoom(10);
|
||||
mc->updateRequestNew();
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(mc);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
MapGadgetWidget::~MapGadgetWidget()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void MapGadgetWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
mc->resize(QSize(width(), height()));
|
||||
update();
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void MapGadgetWidget::addZoomButtons()
|
||||
{
|
||||
// create buttons as controls for zoom
|
||||
QPushButton* zoomin = new QPushButton("+");
|
||||
QPushButton* zoomout = new QPushButton("-");
|
||||
zoomin->setMaximumWidth(50);
|
||||
zoomout->setMaximumWidth(50);
|
||||
|
||||
connect(zoomin, SIGNAL(clicked(bool)),
|
||||
mc, SLOT(zoomIn()));
|
||||
connect(zoomout, SIGNAL(clicked(bool)),
|
||||
mc, SLOT(zoomOut()));
|
||||
|
||||
// add zoom buttons to the layout of the MapControl
|
||||
QVBoxLayout* innerlayout = new QVBoxLayout;
|
||||
innerlayout->addWidget(zoomin);
|
||||
innerlayout->addWidget(zoomout);
|
||||
mc->setLayout(innerlayout);
|
||||
}
|
||||
|
35
ground/src/plugins/map/mapgadgetwidget.h
Normal file
35
ground/src/plugins/map/mapgadgetwidget.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* mapgadgetwidget.h
|
||||
*
|
||||
* Created on: Mar 6, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
|
||||
#ifndef MAPGADGETWIDGET_H_
|
||||
#define MAPGADGETWIDGET_H_
|
||||
|
||||
#include "qmapcontrol/qmapcontrol.h"
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
using namespace qmapcontrol;
|
||||
|
||||
class MapGadgetWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MapGadgetWidget(QWidget *parent = 0);
|
||||
~MapGadgetWidget();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
MapControl *mc;
|
||||
MapAdapter *mapadapter;
|
||||
Layer *mainlayer;
|
||||
|
||||
void addZoomButtons();
|
||||
};
|
||||
|
||||
#endif /* MAPGADGETWIDGET_H_ */
|
46
ground/src/plugins/map/mapplugin.cpp
Normal file
46
ground/src/plugins/map/mapplugin.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* mapplugin.cpp
|
||||
*
|
||||
* Created on: Mar 6, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
#include "mapplugin.h"
|
||||
#include "mapgadgetfactory.h"
|
||||
#include <QDebug>
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
|
||||
MapPlugin::MapPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
MapPlugin::~MapPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
bool MapPlugin::initialize(const QStringList& args, QString *errMsg)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
Q_UNUSED(errMsg);
|
||||
mf = new MapGadgetFactory(this);
|
||||
addAutoReleasedObject(mf);
|
||||
qDebug() << "MapPlugin::initialize()";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MapPlugin::extensionsInitialized()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void MapPlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
Q_EXPORT_PLUGIN(MapPlugin)
|
||||
|
27
ground/src/plugins/map/mapplugin.h
Normal file
27
ground/src/plugins/map/mapplugin.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* mapplugin.h
|
||||
*
|
||||
* Created on: Mar 6, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
|
||||
#ifndef MAPPLUGIN_H_
|
||||
#define MAPPLUGIN_H_
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
class MapGadgetFactory;
|
||||
|
||||
class MapPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
public:
|
||||
MapPlugin();
|
||||
~MapPlugin();
|
||||
|
||||
void extensionsInitialized();
|
||||
bool initialize(const QStringList & arguments, QString * errorString);
|
||||
void shutdown();
|
||||
private:
|
||||
MapGadgetFactory *mf;
|
||||
};
|
||||
#endif /* MAPPLUGIN_H_ */
|
Loading…
Reference in New Issue
Block a user