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

New map gadget addition .. not yet operational though.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@770 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2010-06-14 19:34:04 +00:00 committed by pip
parent 3bc7c253ab
commit 97a195baf1
9 changed files with 304 additions and 33 deletions

View File

@ -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<UAVObjectManager>();
@ -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

View File

@ -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;

View File

@ -0,0 +1,10 @@
<plugin name="Map2Gadget" version="1.0.0" compatVersion="1.0.0">
<vendor>The OpenPilot Project</vendor>
<copyright>(C) 2010 OpenPilot Project</copyright>
<license>The GNU Public License (GPL) Version 3</license>
<description>A new map gadget!</description>
<url>http://www.openpilot.org</url>
<dependencyList>
<dependency name="Core" version="1.0.0"/>
</dependencyList>
</plugin>

View File

@ -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

View File

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/map2">
<file>images/waypoint.png</file>
<file>images/uav.png</file>
<file>images/gcs.png</file>
</qresource>
</RCC>

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MapGadgetOptionsPage</class>
<widget class="QWidget" name="MapGadgetOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Map provider:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="providerComboBox">
<item>
<property name="text">
<string>OpenStreetMap</string>
</property>
</item>
<item>
<property name="text">
<string>Google</string>
</property>
</item>
<item>
<property name="text">
<string>Google Sat</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Default zoom:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="zoomSpinBox">
<property name="maximum">
<number>18</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default latitude:</string>
</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>
</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>
</item>
<item row="4" column="1">
<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="3" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -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 <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
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)

View File

@ -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 <extensionsystem/iplugin.h>
//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_ */

View File

@ -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