diff --git a/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditor.pro b/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditor.pro
index a020e52b5..94e6caadf 100644
--- a/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditor.pro
+++ b/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditor.pro
@@ -5,12 +5,14 @@ include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/uavobjects/uavobjects.pri)
-HEADERS += waypointeditorgadget.h
+HEADERS += waypointeditorgadget.h \
+ waypointtable.h
HEADERS += waypointeditorgadgetwidget.h
HEADERS += waypointeditorgadgetfactory.h
HEADERS += waypointeditorplugin.h
-SOURCES += waypointeditorgadget.cpp
+SOURCES += waypointeditorgadget.cpp \
+ waypointtable.cpp
SOURCES += waypointeditorgadgetwidget.cpp
SOURCES += waypointeditorgadgetfactory.cpp
SOURCES += waypointeditorplugin.cpp
@@ -20,3 +22,5 @@ OTHER_FILES += waypointeditor.pluginspec
FORMS += waypointeditor.ui
RESOURCES += waypointeditor.qrc
+
+
diff --git a/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditor.ui b/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditor.ui
index 2774b3148..5384f3e95 100644
--- a/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditor.ui
+++ b/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditor.ui
@@ -21,19 +21,33 @@
-
-
+
false
-
-
+
New Waypoint
+ -
+
+
+ Save to File
+
+
+
+ -
+
+
+ Load from File
+
+
+
diff --git a/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditorgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditorgadgetwidget.cpp
index b88119f25..50866885a 100644
--- a/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditorgadgetwidget.cpp
+++ b/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditorgadgetwidget.cpp
@@ -34,16 +34,29 @@
#include
#include
-#include "uavobject.h"
-#include "uavobjectmanager.h"
-#include "manualcontrolcommand.h"
-#include "extensionsystem/pluginmanager.h"
#include "extensionsystem/pluginmanager.h"
WaypointEditorGadgetWidget::WaypointEditorGadgetWidget(QWidget *parent) : QLabel(parent)
{
m_waypointeditor = new Ui_WaypointEditor();
m_waypointeditor->setupUi(this);
+
+ waypointTable = new WaypointTable(this);
+ m_waypointeditor->waypoints->setModel(waypointTable);
+
+ // Get the objects used here
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ Q_ASSERT(pm != NULL);
+ UAVObjectManager *objManager = pm->getObject();
+ Q_ASSERT(objManager != NULL);
+ waypointActiveObj = WaypointActive::GetInstance(objManager);
+ Q_ASSERT(waypointActiveObj != NULL);
+
+ // Connect the signals
+ connect(waypointActiveObj, SIGNAL(objectUpdated(UAVObject*)),
+ this, SLOT(waypointActiveChanged(UAVObject*)));
+ connect(m_waypointeditor->buttonNewWaypoint, SIGNAL(clicked()),
+ this, SLOT(addInstance()));
}
WaypointEditorGadgetWidget::~WaypointEditorGadgetWidget()
diff --git a/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditorgadgetwidget.h b/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditorgadgetwidget.h
index 63bfd0d1c..c829dbceb 100644
--- a/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditorgadgetwidget.h
+++ b/ground/openpilotgcs/src/plugins/waypointeditor/waypointeditorgadgetwidget.h
@@ -28,7 +28,7 @@
#define WaypointEditorGADGETWIDGET_H_
#include
-#include
+#include
#include
class Ui_WaypointEditor;
@@ -50,6 +50,8 @@ protected slots:
private:
Ui_WaypointEditor * m_waypointeditor;
+ WaypointTable *waypointTable;
+ WaypointActive *waypointActiveObj;
};
#endif /* WaypointEditorGADGETWIDGET_H_ */
diff --git a/ground/openpilotgcs/src/plugins/waypointeditor/waypointtable.cpp b/ground/openpilotgcs/src/plugins/waypointeditor/waypointtable.cpp
new file mode 100644
index 000000000..60a895c75
--- /dev/null
+++ b/ground/openpilotgcs/src/plugins/waypointeditor/waypointtable.cpp
@@ -0,0 +1,141 @@
+/**
+ ******************************************************************************
+ * @file waypointtable.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
+ * @addtogroup Waypoint Editor GCS Plugins
+ * @{
+ * @addtogroup WaypointEditorGadgetPlugin Waypoint Editor Gadget Plugin
+ * @{
+ * @brief Table model for listing waypoint
+ *****************************************************************************/
+/*
+ * 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
+#include
+#include "waypointtable.h"
+#include "extensionsystem/pluginmanager.h"
+
+WaypointTable::WaypointTable(QObject *parent) :
+ QAbstractTableModel(parent)
+{
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ Q_ASSERT(pm != NULL);
+ UAVObjectManager *objManager = pm->getObject();
+ Q_ASSERT(objManager != NULL);
+ waypointObj = Waypoint::GetInstance(objManager);
+ Q_ASSERT(waypointObj != NULL);
+ waypointActiveObj = WaypointActive::GetInstance(objManager);
+ Q_ASSERT(waypointObj != NULL);
+
+ elements = 0;
+
+ connect(waypointActiveObj, SIGNAL(objectUpdated(UAVObject*)),
+ this, SLOT(waypointsUpdated(UAVObject*)));
+ connect(waypointObj, SIGNAL(),
+ this, SLOT(waypointsUpdated(UAVObject*)));
+
+ headers.clear();
+ headers.append(QString("North"));
+ headers.append(QString("East"));
+ headers.append(QString("Down"));
+}
+
+int WaypointTable::rowCount(const QModelIndex &parent) const
+{
+ return elements;
+}
+
+int WaypointTable::columnCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+
+ return headers.length();
+}
+
+QVariant WaypointTable::data(const QModelIndex &index, int role) const
+{
+ if(role == Qt::DisplayRole) {
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ Q_ASSERT(pm != NULL);
+ UAVObjectManager *objManager = pm->getObject();
+ Q_ASSERT(objManager != NULL);
+
+ Waypoint *obj = Waypoint::GetInstance(objManager, index.row());
+ Q_ASSERT(obj);
+ Waypoint::DataFields waypoint = obj->getData();
+
+ switch(index.column()) {
+ case 0:
+ return waypoint.Position[Waypoint::POSITION_NORTH];
+ case 1:
+ return waypoint.Position[Waypoint::POSITION_EAST];
+ case 2:
+ return waypoint.Position[Waypoint::POSITION_DOWN];
+ default:
+ Q_ASSERT(0);
+ return 0;
+ }
+ } else if (role == Qt::BackgroundRole) {
+ WaypointActive::DataFields waypointActive = waypointActiveObj->getData();
+
+ if(index.row() == waypointActive.Index) {
+ return QBrush(Qt::lightGray);
+ } else
+ return QVariant::Invalid;
+ }
+ else {
+ return QVariant::Invalid;
+ }
+
+}
+
+QVariant WaypointTable::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if(role == Qt::DisplayRole && orientation == Qt::Horizontal) {
+ if(section < headers.length())
+ return headers[section];
+ return QVariant::Invalid;
+ } else
+ return QAbstractTableModel::headerData(section, orientation, role);
+}
+
+/**
+ * Called whenever the waypoints are updated to inform
+ * the view
+ */
+void WaypointTable::waypointsUpdated(UAVObject *)
+{
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ Q_ASSERT(pm != NULL);
+ UAVObjectManager *objManager = pm->getObject();
+ Q_ASSERT(objManager != NULL);
+ int elementsNow = objManager->getNumInstances(waypointObj->getObjID());
+
+ // Currently only support adding instances which is all the UAVO manager
+ // supports
+ if (elementsNow > elements) {
+ beginInsertRows(QModelIndex(), elements, elementsNow);
+ elements = elementsNow;
+ endInsertRows();
+ }
+
+ QModelIndex i1 = index(0,0);
+ QModelIndex i2 = index(elements, columnCount(QModelIndex()));
+ qDebug() << "Waypoints updated. Found " << rowCount(QModelIndex());
+ emit dataChanged(i1, i2);
+}
diff --git a/ground/openpilotgcs/src/plugins/waypointeditor/waypointtable.h b/ground/openpilotgcs/src/plugins/waypointeditor/waypointtable.h
new file mode 100644
index 000000000..e213c1cf8
--- /dev/null
+++ b/ground/openpilotgcs/src/plugins/waypointeditor/waypointtable.h
@@ -0,0 +1,61 @@
+/**
+ ******************************************************************************
+ * @file waypointtable.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
+ * @addtogroup Waypoint Editor GCS Plugins
+ * @{
+ * @addtogroup WaypointEditorGadgetPlugin Waypoint Editor Gadget Plugin
+ * @{
+ * @brief Table model for listing waypoint
+ *****************************************************************************/
+/*
+ * 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 WAYPOINTTABLE_H
+#define WAYPOINTTABLE_H
+
+#include
+#include
+#include
+#include
+#include
+
+class WaypointTable : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ explicit WaypointTable(QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent) const;
+ int columnCount(const QModelIndex &parent) const;
+
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+signals:
+
+protected slots:
+ void waypointsUpdated(UAVObject *);
+
+public slots:
+
+private:
+ Waypoint *waypointObj;
+ WaypointActive *waypointActiveObj;
+ QList headers;
+ int elements;
+};
+
+#endif // WAYPOINTTABLE_H