diff --git a/ground/src/plugins/magicwaypoint/MagicWaypoint.pluginspec b/ground/src/plugins/magicwaypoint/MagicWaypoint.pluginspec
new file mode 100644
index 000000000..dbdfa66ba
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/MagicWaypoint.pluginspec
@@ -0,0 +1,11 @@
+
+ The OpenPilot Project
+ (C) 2010 OpenPilot Project
+ The GNU Public License (GPL) Version 3
+ Allows controlling the desired position by clicking on a display
+ http://www.openpilot.org
+
+
+
+
+
diff --git a/ground/src/plugins/magicwaypoint/images/positionfield.svg b/ground/src/plugins/magicwaypoint/images/positionfield.svg
new file mode 100644
index 000000000..d68632c16
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/images/positionfield.svg
@@ -0,0 +1,151 @@
+
+
+
+
diff --git a/ground/src/plugins/magicwaypoint/magicwaypoint.pro b/ground/src/plugins/magicwaypoint/magicwaypoint.pro
new file mode 100644
index 000000000..b4f096193
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypoint.pro
@@ -0,0 +1,25 @@
+TEMPLATE = lib
+TARGET = MagicWaypoint
+QT += svg
+
+include(../../openpilotgcsplugin.pri)
+include(../../plugins/coreplugin/coreplugin.pri)
+include(../../plugins/uavobjects/uavobjects.pri)
+
+HEADERS += magicwaypointgadget.h
+HEADERS += magicwaypointgadgetwidget.h
+HEADERS += magicwaypointgadgetfactory.h
+HEADERS += magicwaypointplugin.h
+HEADERS += positionfield.h
+
+SOURCES += magicwaypointgadget.cpp
+SOURCES += magicwaypointgadgetwidget.cpp
+SOURCES += magicwaypointgadgetfactory.cpp
+SOURCES += magicwaypointplugin.cpp
+SOURCES += positionfield.cpp
+
+OTHER_FILES += MagicWaypoint.pluginspec
+
+FORMS += magicwaypoint.ui
+
+RESOURCES += magicwaypoint.qrc
diff --git a/ground/src/plugins/magicwaypoint/magicwaypoint.qrc b/ground/src/plugins/magicwaypoint/magicwaypoint.qrc
new file mode 100644
index 000000000..29fef640f
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypoint.qrc
@@ -0,0 +1,5 @@
+
+
+ images/positionfield.svg
+
+
diff --git a/ground/src/plugins/magicwaypoint/magicwaypoint.ui b/ground/src/plugins/magicwaypoint/magicwaypoint.ui
new file mode 100644
index 000000000..e92644093
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypoint.ui
@@ -0,0 +1,161 @@
+
+
+ MagicWaypoint
+
+
+
+ 0
+ 0
+ 653
+ 295
+
+
+
+
+ 0
+ 0
+
+
+
+ Form
+
+
+
+
+
+
+
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Preferred
+
+
+
+ 10
+ 20
+
+
+
+
+
+
+
+
+ 50
+ 0
+
+
+
+
+ 50
+ 0
+
+
+
+ Scale:
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+ 1
+
+
+ 999
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBelow
+
+
+ 10
+
+
+
+
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Preferred
+
+
+
+ 10
+ 20
+
+
+
+
+
+
+
+
+
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+ 10
+
+
+ 0
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 200
+ 200
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+ PositionField
+ QWidget
+ positionfield.h
+ 1
+
+
+
+
+
diff --git a/ground/src/plugins/magicwaypoint/magicwaypointgadget.cpp b/ground/src/plugins/magicwaypoint/magicwaypointgadget.cpp
new file mode 100644
index 000000000..1e6dd5c5d
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypointgadget.cpp
@@ -0,0 +1,49 @@
+/**
+ ******************************************************************************
+ *
+ * @file GCSControlgadget.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A gadget to control the UAV, either from the keyboard or a joystick
+ *****************************************************************************/
+/*
+ * 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 "magicwaypointgadget.h"
+#include "magicwaypointgadgetwidget.h"
+
+#include "extensionsystem/pluginmanager.h"
+#include "uavobjects/uavobjectmanager.h"
+#include "uavobjects/uavobject.h"
+#include
+
+MagicWaypointGadget::MagicWaypointGadget(QString classId, MagicWaypointGadgetWidget *widget, QWidget *parent) :
+ IUAVGadget(classId, parent),
+ m_widget(widget)
+{
+ qDebug() << "Class id" << classId;
+}
+
+MagicWaypointGadget::~MagicWaypointGadget()
+{
+}
+
+void MagicWaypointGadget::loadConfiguration(IUAVGadgetConfiguration* config)
+{
+ Q_UNUSED(config);
+}
diff --git a/ground/src/plugins/magicwaypoint/magicwaypointgadget.h b/ground/src/plugins/magicwaypoint/magicwaypointgadget.h
new file mode 100644
index 000000000..51d40609e
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypointgadget.h
@@ -0,0 +1,60 @@
+/**
+ ******************************************************************************
+ *
+ * @file GCSControlgadget.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A gadget to control the UAV, either from the keyboard or a joystick
+ *****************************************************************************/
+/*
+ * 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 MagicWaypointGADGET_H_
+#define MagicWaypointGADGET_H_
+
+#include
+
+namespace Core {
+class IUAVGadget;
+}
+//class QWidget;
+//class QString;
+class MagicWaypointGadgetWidget;
+
+using namespace Core;
+
+class MagicWaypointGadget : public Core::IUAVGadget
+{
+ Q_OBJECT
+public:
+ MagicWaypointGadget(QString classId, MagicWaypointGadgetWidget *widget, QWidget *parent = 0);
+ ~MagicWaypointGadget();
+
+ QList context() const { return m_context; }
+ QWidget *widget() { return m_widget; }
+ QString contextHelpId() const { return QString(); }
+
+ void loadConfiguration(IUAVGadgetConfiguration* config);
+private:
+ QWidget *m_widget;
+ QList m_context;
+};
+
+
+#endif // MagicWaypointGADGET_H_
diff --git a/ground/src/plugins/magicwaypoint/magicwaypointgadgetfactory.cpp b/ground/src/plugins/magicwaypoint/magicwaypointgadgetfactory.cpp
new file mode 100644
index 000000000..e52e74d5d
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypointgadgetfactory.cpp
@@ -0,0 +1,48 @@
+/**
+ ******************************************************************************
+ *
+ * @file GCSControlgadgetfactory.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A gadget to control the UAV, either from the keyboard or a joystick
+ *****************************************************************************/
+/*
+ * 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 "magicwaypointgadgetfactory.h"
+#include "magicwaypointgadgetwidget.h"
+#include "magicwaypointgadget.h"
+#include
+#include
+
+MagicWaypointGadgetFactory::MagicWaypointGadgetFactory(QObject *parent) :
+ IUAVGadgetFactory(QString("MagicWaypointGadget"),
+ tr("Magic Waypoint"),
+ parent)
+{
+}
+
+MagicWaypointGadgetFactory::~MagicWaypointGadgetFactory()
+{
+
+}
+
+IUAVGadget* MagicWaypointGadgetFactory::createGadget(QWidget *parent) {
+ MagicWaypointGadgetWidget* gadgetWidget = new MagicWaypointGadgetWidget(parent);
+ return new MagicWaypointGadget(QString("MagicWaypointGadget"), gadgetWidget, parent);
+}
diff --git a/ground/src/plugins/magicwaypoint/magicwaypointgadgetfactory.h b/ground/src/plugins/magicwaypoint/magicwaypointgadgetfactory.h
new file mode 100644
index 000000000..38ab5545b
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypointgadgetfactory.h
@@ -0,0 +1,50 @@
+/**
+ ******************************************************************************
+ *
+ * @file GCSControlgadgetfactory.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A gadget to control the UAV, either from the keyboard or a joystick
+ *****************************************************************************/
+/*
+ * 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 MagicWaypointGADGETFACTORY_H_
+#define MagicWaypointGADGETFACTORY_H_
+
+#include
+
+namespace Core {
+class IUAVGadget;
+class IUAVGadgetFactory;
+}
+
+using namespace Core;
+
+class MagicWaypointGadgetFactory : public IUAVGadgetFactory
+{
+ Q_OBJECT
+public:
+ MagicWaypointGadgetFactory(QObject *parent = 0);
+ ~MagicWaypointGadgetFactory();
+
+ IUAVGadget *createGadget(QWidget *parent);
+};
+
+#endif // MagicWaypointGADGETFACTORY_H_
diff --git a/ground/src/plugins/magicwaypoint/magicwaypointgadgetwidget.cpp b/ground/src/plugins/magicwaypoint/magicwaypointgadgetwidget.cpp
new file mode 100644
index 000000000..faaf349f0
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypointgadgetwidget.cpp
@@ -0,0 +1,117 @@
+/**
+ ******************************************************************************
+ *
+ * @file GCSControlgadgetwidget.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A gadget to control the UAV, either from the keyboard or a joystick
+ *****************************************************************************/
+/*
+ * 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 "magicwaypointgadgetwidget.h"
+#include "ui_magicwaypoint.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "uavobjects/uavobject.h"
+#include "uavobjects/uavobjectmanager.h"
+#include "uavobjects/manualcontrolcommand.h"
+#include "extensionsystem/pluginmanager.h"
+#include "extensionsystem/pluginmanager.h"
+
+MagicWaypointGadgetWidget::MagicWaypointGadgetWidget(QWidget *parent) : QLabel(parent)
+{
+ qDebug() << "MagicWaypointGadgetWidget constructor";
+ m_magicwaypoint = new Ui_MagicWaypoint();
+ m_magicwaypoint->setupUi(this);
+
+ // Connect object updated event from UAVObject to also update check boxes
+ connect(getPositionDesired(), SIGNAL(objectUpdated(UAVObject*)), this, SLOT(positionDesiredObjectChanged(UAVObject*)));
+ // Connect updates from the position widget to this widget
+ connect(m_magicwaypoint->widgetPosition, SIGNAL(positionClicked(double,double)), this, SLOT(positionSelected(double,double)));
+ connect(this, SIGNAL(positionObjectChanged(double,double)), m_magicwaypoint->widgetPosition, SLOT(updateIndicator(double,double)));
+ // Catch changes in scale for visualization
+ connect(m_magicwaypoint->horizontalSliderScale, SIGNAL(valueChanged(int)), this, SLOT(scaleChanged(double)));
+}
+
+MagicWaypointGadgetWidget::~MagicWaypointGadgetWidget()
+{
+ // Do nothing
+}
+
+/*!
+ \brief Returns the ManualControlCommand UAVObject
+ */
+PositionDesired* MagicWaypointGadgetWidget::getPositionDesired()
+{
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ UAVObjectManager *objManager = pm->getObject();
+ PositionDesired* obj = dynamic_cast( objManager->getObject(QString("PositionDesired")) );
+ return obj;
+}
+
+/**
+ * Detect changes in scale and update visualization (does not change position)
+ */
+void MagicWaypointGadgetWidget::scaleChanged(int scale) {
+ Q_UNUSED(scale);
+ positionDesiredObjectChanged(getPositionDesired());
+}
+
+/**
+ * Update displayed position when @ref PositionDesired object is changed
+ */
+void MagicWaypointGadgetWidget::positionDesiredObjectChanged(UAVObject* obj)
+{
+ double north = obj->getField("North")->getDouble();
+ double east = obj->getField("East")->getDouble();
+ double scale = m_magicwaypoint->horizontalSliderScale->value();
+
+ emit positionObjectChanged(north/scale,east/scale);
+}
+
+/**
+ * Slot called by visualization when a new @ref PositionDesired is requested
+ */
+void MagicWaypointGadgetWidget::positionSelected(double north, double east) {
+ double scale = m_magicwaypoint->horizontalSliderScale->value();
+
+ PositionDesired * posDesired = getPositionDesired();
+ if(posDesired) {
+ UAVObjectField * field = posDesired->getField("North");
+ if(field)
+ field->setDouble(north * scale);
+
+ field = posDesired->getField("East");
+ if(field)
+ field->setDouble(east * scale);
+
+ posDesired->updated();
+ }
+}
+
+/**
+ * @}
+ * @}
+ */
diff --git a/ground/src/plugins/magicwaypoint/magicwaypointgadgetwidget.h b/ground/src/plugins/magicwaypoint/magicwaypointgadgetwidget.h
new file mode 100644
index 000000000..2b191565f
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypointgadgetwidget.h
@@ -0,0 +1,57 @@
+/**
+ ******************************************************************************
+ *
+ * @file GCSControlgadgetwidget.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A place holder gadget plugin
+ *****************************************************************************/
+/*
+ * 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 MagicWaypointGADGETWIDGET_H_
+#define MagicWaypointGADGETWIDGET_H_
+
+#include
+#include "uavobjects/positiondesired.h"
+
+class Ui_MagicWaypoint;
+
+class MagicWaypointGadgetWidget : public QLabel
+{
+ Q_OBJECT
+
+public:
+ MagicWaypointGadgetWidget(QWidget *parent = 0);
+ ~MagicWaypointGadgetWidget();
+
+signals:
+ void positionObjectChanged(double north, double east);
+
+protected slots:
+ void scaleChanged(int scale);
+ void positionDesiredObjectChanged(UAVObject *);
+ void positionSelected(double north, double east);
+
+private:
+ PositionDesired * getPositionDesired();
+ Ui_MagicWaypoint * m_magicwaypoint;
+};
+
+#endif /* MagicWaypointGADGETWIDGET_H_ */
diff --git a/ground/src/plugins/magicwaypoint/magicwaypointplugin.cpp b/ground/src/plugins/magicwaypoint/magicwaypointplugin.cpp
new file mode 100644
index 000000000..c26e92d08
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypointplugin.cpp
@@ -0,0 +1,69 @@
+/**
+ ******************************************************************************
+ *
+ * @file GCSControlplugin.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A gadget to control the UAV, either from the keyboard or a joystick
+ *****************************************************************************/
+/*
+ * 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 "magicwaypointplugin.h"
+#include "magicwaypointgadgetfactory.h"
+#include
+#include
+#include
+#include
+
+
+MagicWaypointPlugin::MagicWaypointPlugin()
+{
+ // Do nothing
+}
+
+MagicWaypointPlugin::~MagicWaypointPlugin()
+{
+ // Do nothing
+}
+
+bool MagicWaypointPlugin::initialize(const QStringList& args, QString *errMsg)
+{
+ Q_UNUSED(args);
+ Q_UNUSED(errMsg);
+ mf = new MagicWaypointGadgetFactory(this);
+ addAutoReleasedObject(mf);
+
+ return true;
+}
+
+void MagicWaypointPlugin::extensionsInitialized()
+{
+ // Do nothing
+}
+
+void MagicWaypointPlugin::shutdown()
+{
+ // Do nothing
+}
+Q_EXPORT_PLUGIN(MagicWaypointPlugin)
+
+/**
+ * @}
+ * @}
+ */
diff --git a/ground/src/plugins/magicwaypoint/magicwaypointplugin.h b/ground/src/plugins/magicwaypoint/magicwaypointplugin.h
new file mode 100644
index 000000000..b83fffdd9
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/magicwaypointplugin.h
@@ -0,0 +1,47 @@
+/**
+ ******************************************************************************
+ *
+ * @file GCSControlplugin.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A gadget to control the UAV, either from the keyboard or a joystick
+ *****************************************************************************/
+/*
+ * 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 MagicWaypointPLUGIN_H_
+#define MagicWaypointPLUGIN_H_
+
+#include
+
+class MagicWaypointGadgetFactory;
+
+class MagicWaypointPlugin : public ExtensionSystem::IPlugin
+{
+public:
+ MagicWaypointPlugin();
+ ~MagicWaypointPlugin();
+
+ void extensionsInitialized();
+ bool initialize(const QStringList & arguments, QString * errorString);
+ void shutdown();
+private:
+ MagicWaypointGadgetFactory *mf;
+};
+#endif /* GCSControlPLUGIN_H_ */
diff --git a/ground/src/plugins/magicwaypoint/positionfield.cpp b/ground/src/plugins/magicwaypoint/positionfield.cpp
new file mode 100644
index 000000000..c0e5e67cd
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/positionfield.cpp
@@ -0,0 +1,134 @@
+/**
+ ******************************************************************************
+ *
+ * @file joystickcontrol.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A that mimics a transmitter joystick and updates the MCC
+ *****************************************************************************/
+/*
+ * 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 "positionfield.h"
+#include "extensionsystem/pluginmanager.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/**
+ * @brief Constructor for JoystickControl widget. Sets up the image of a joystick
+ */
+PositionField::PositionField(QWidget *parent) :
+ QGraphicsView(parent)
+{
+ setMinimumSize(64,64);
+ setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ setScene(new QGraphicsScene(this));
+ setRenderHints(QPainter::Antialiasing);
+
+ m_renderer = new QSvgRenderer();
+ Q_ASSERT( m_renderer->load(QString(":/magicwaypoint/images/positionfield.svg")) != 0 );
+
+ m_background = new QGraphicsSvgItem();
+ m_background->setSharedRenderer(m_renderer);
+ m_background->setElementId(QString("background"));
+
+ m_position = new QGraphicsSvgItem();
+ m_position->setSharedRenderer(m_renderer);
+ m_position->setElementId(QString("joystickEnd"));
+ m_position->setPos(0,0);
+
+ QGraphicsScene *l_scene = scene();
+ l_scene->clear(); // This also deletes all items contained in the scene.
+ l_scene->addItem(m_background);
+ l_scene->addItem(m_position);
+ l_scene->setSceneRect(m_background->boundingRect());
+}
+
+PositionField::~PositionField()
+{
+
+}
+
+/**
+ * @brief Update aircraft position on image (values go from -1 to 1)
+ */
+void PositionField::updateIndicator(double north, double east)
+{
+ QRectF sceneSize = scene()->sceneRect();
+
+ m_position->setPos((east+1)/2*sceneSize.width(),(-north+1)/2*sceneSize.height());
+}
+
+
+/**
+ * @brief Redirect mouse move events to control position
+ */
+void PositionField::mouseMoveEvent(QMouseEvent *event)
+{
+ QPointF point = mapToScene(event->pos());
+ QRectF sceneSize = scene()->sceneRect();
+
+ double north = - (point.y() / sceneSize.height() - .5) * 2;
+ double east = (point.x() / sceneSize.width() - .5) * 2;
+ emit positionClicked(north, east);
+}
+
+/**
+ * @brief Redirect mouse move clicks to control position
+ */
+void PositionField::mousePressEvent(QMouseEvent *event)
+{
+ if( event->button() == Qt::LeftButton ) {
+ mouseMoveEvent(event);
+ }
+}
+
+void PositionField::paint()
+{
+ update();
+}
+
+void PositionField::paintEvent(QPaintEvent *event)
+{
+ // Skip painting until the dial file is loaded
+ if (! m_renderer->isValid()) {
+ qDebug()<<"Image file not loaded, not rendering";
+ }
+
+ QGraphicsView::paintEvent(event);
+}
+
+void PositionField::resizeEvent(QResizeEvent *event)
+{
+ Q_UNUSED(event);
+ fitInView(m_background, Qt::IgnoreAspectRatio );
+}
+
+
+/**
+ * @}
+ * @}
+ */
diff --git a/ground/src/plugins/magicwaypoint/positionfield.h b/ground/src/plugins/magicwaypoint/positionfield.h
new file mode 100644
index 000000000..b19b300c5
--- /dev/null
+++ b/ground/src/plugins/magicwaypoint/positionfield.h
@@ -0,0 +1,73 @@
+/**
+ ******************************************************************************
+ *
+ * @file joystickcontrol.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
+ * @{
+ * @brief A that mimics a transmitter joystick and updates the MCC
+ *****************************************************************************/
+/*
+ * 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 POSITIONFIELD_H
+#define POSITIONFIELD_H
+
+#include
+#include
+#include
+#include
+
+namespace Ui {
+ class PositionField;
+}
+
+class PositionField : public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ explicit PositionField(QWidget *parent = 0);
+ ~PositionField();
+ void paint();
+
+protected:
+ void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void paintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *event);
+
+signals:
+ void positionClicked(double north, double east);
+
+public slots:
+ void updateIndicator(double north, double east);
+
+private:
+ QSvgRenderer *m_renderer;
+ QGraphicsSvgItem *m_background;
+ QGraphicsSvgItem *m_position;
+};
+
+#endif // POSITIONFIELD_H
+
+/**
+ * @}
+ * @}
+ */
diff --git a/ground/src/plugins/pfd/pfdgadgetwidget.cpp b/ground/src/plugins/pfd/pfdgadgetwidget.cpp
index 574b035fc..22a7f8f56 100644
--- a/ground/src/plugins/pfd/pfdgadgetwidget.cpp
+++ b/ground/src/plugins/pfd/pfdgadgetwidget.cpp
@@ -118,7 +118,7 @@ void PFDGadgetWidget::connectNeedles() {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject();
- airspeedObj = dynamic_cast(objManager->getObject("PositionActual"));
+ airspeedObj = dynamic_cast(objManager->getObject("VelocityActual"));
if (attitudeObj != NULL ) {
connect(airspeedObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateAirspeed(UAVObject*)));
} else {
@@ -288,9 +288,10 @@ void PFDGadgetWidget::updateHeading(UAVObject *object) {
\brief Called by updates to @PositionActual to compute airspeed from velocity
*/
void PFDGadgetWidget::updateAirspeed(UAVObject *object) {
- UAVObjectField* velField = object->getField("Vel");
- if (velField) {
- double val = floor(sqrt(pow(velField->getDouble(0),2) + pow(velField->getDouble(1),2))*10)/10;
+ UAVObjectField* northField = object->getField("North");
+ UAVObjectField* eastField = object->getField("East");
+ if (northField && eastField) {
+ double val = floor(sqrt(pow(northField->getDouble(),2) + pow(eastField->getDouble(),2))*10)/10;
groundspeedTarget = 3.6*val*speedScaleHeight/30;
} else {
@@ -302,10 +303,10 @@ void PFDGadgetWidget::updateAirspeed(UAVObject *object) {
\brief Called by the @ref PositionActual updates to show altitude
*/
void PFDGadgetWidget::updateAltitude(UAVObject *object) {
- UAVObjectField* posField = object->getField("NED");
- if (posField) {
+ UAVObjectField* downField = object->getField("Down");
+ if (downField) {
// The altitude scale represents 30 meters
- altitudeTarget = floor(posField->getDouble(3)*10)/10*altitudeScaleHeight/30;
+ altitudeTarget = -floor(downField->getDouble(3)*10)/10*altitudeScaleHeight/30;
} else {
qDebug() << "Unable to get field for altitude update. Obj: " << object->getName();
}
diff --git a/ground/src/plugins/plugins.pro b/ground/src/plugins/plugins.pro
index d3a9213dc..c51269932 100644
--- a/ground/src/plugins/plugins.pro
+++ b/ground/src/plugins/plugins.pro
@@ -148,3 +148,8 @@ plugin_gcscontrol.depends = plugin_coreplugin
plugin_gcscontrol.depends += plugin_uavobjects
plugin_gcscontrol.depends += plugin_uavtalk
SUBDIRS += plugin_gcscontrol
+
+# Empty UAVGadget - Default for new splits
+plugin_magicwaypoint.subdir = magicwaypoint
+plugin_magicwaypoint.depends = plugin_coreplugin
+SUBDIRS += plugin_magicwaypoint
diff --git a/ground/src/plugins/uavobjects/uavobjects.pro b/ground/src/plugins/uavobjects/uavobjects.pro
index b666d9a30..0db43269d 100644
--- a/ground/src/plugins/uavobjects/uavobjects.pro
+++ b/ground/src/plugins/uavobjects/uavobjects.pro
@@ -42,14 +42,13 @@ HEADERS += uavobjects_global.h \
homelocation.h \
vtolsettings.h \
vtolstatus.h \
- attitudesettings.h \
mixersettings.h \
mixerstatus.h \
- positiondesired.h \
velocitydesired.h \
velocityactual.h \
vtolstatus.h \
guidancesettings.h \
+ positiondesired.h \
attitudesettings.h
SOURCES += uavobject.cpp \
uavmetaobject.cpp \
@@ -89,12 +88,11 @@ SOURCES += uavobject.cpp \
homelocation.cpp \
vtolsettings.cpp \
vtolstatus.cpp \
- attitudesettings.cpp \
mixersettings.cpp \
mixerstatus.cpp \
- positiondesired.cpp \
velocitydesired.cpp \
velocityactual.cpp \
guidancesettings.cpp \
+ positiondesired.cpp \
attitudesettings.cpp
OTHER_FILES += UAVObjects.pluginspec