diff --git a/artwork/3D Model/default_background.png b/artwork/3D Model/default_background.png
new file mode 100644
index 000000000..67094ecce
Binary files /dev/null and b/artwork/3D Model/default_background.png differ
diff --git a/ground/src/plugins/modelview/ModelViewGadget.pluginspec b/ground/src/plugins/modelview/ModelViewGadget.pluginspec
new file mode 100644
index 000000000..523ee9329
--- /dev/null
+++ b/ground/src/plugins/modelview/ModelViewGadget.pluginspec
@@ -0,0 +1,10 @@
+
+ The OpenPilot Project
+ (C) 2010 OpenPilot Project
+
+ A 3D model view gadget!
+ http://www.openpilot.org
+
+
+
+
diff --git a/ground/src/plugins/modelview/modelview.pro b/ground/src/plugins/modelview/modelview.pro
new file mode 100644
index 000000000..767be4788
--- /dev/null
+++ b/ground/src/plugins/modelview/modelview.pro
@@ -0,0 +1,19 @@
+TEMPLATE = lib
+TARGET = ModelViewGadget
+include(../../openpilotgcsplugin.pri)
+include(../../plugins/coreplugin/coreplugin.pri)
+include(../../libs/glc_lib/glc_lib.pri)
+INCLUDEPATH += ../../libs/glc_lib/install/include/GLC_lib
+HEADERS += modelviewplugin.h \
+ modelviewgadgetconfiguration.h \
+ modelviewgadget.h \
+ modelviewgadgetwidget.h \
+ modelviewgadgetfactory.h \
+ modelviewgadgetoptionspage.h
+SOURCES += modelviewplugin.cpp \
+ modelviewgadgetconfiguration.cpp \
+ modelviewgadget.cpp \
+ modelviewgadgetfactory.cpp \
+ modelviewgadgetwidget.cpp \
+ modelviewgadgetoptionspage.cpp
+OTHER_FILES += ModelView.pluginspec
diff --git a/ground/src/plugins/modelview/modelviewgadget.cpp b/ground/src/plugins/modelview/modelviewgadget.cpp
new file mode 100644
index 000000000..f9121c4b2
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadget.cpp
@@ -0,0 +1,48 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadget.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 "modelviewgadget.h"
+#include "modelviewgadgetwidget.h"
+#include "modelviewgadgetconfiguration.h"
+
+ModelViewGadget::ModelViewGadget(QString classId, ModelViewGadgetWidget *widget, QWidget *parent) :
+ IUAVGadget(classId, parent),
+ m_widget(widget)
+{
+}
+
+ModelViewGadget::~ModelViewGadget()
+{
+
+}
+
+void ModelViewGadget::loadConfiguration(IUAVGadgetConfiguration* config)
+{
+ ModelViewGadgetConfiguration *m = qobject_cast(config);
+ m_widget->setAcFilename(m->acFilename());
+ m_widget->setBgFilename(m->bgFilename());
+}
+
diff --git a/ground/src/plugins/modelview/modelviewgadget.h b/ground/src/plugins/modelview/modelviewgadget.h
new file mode 100644
index 000000000..899bd4c7e
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadget.h
@@ -0,0 +1,56 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadget.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 MODELVIEWGADGET_H_
+#define MODELVIEWGADGET_H_
+
+#include
+#include "modelviewgadgetwidget.h"
+
+class IUAVGadget;
+class QWidget;
+class QString;
+class ModelViewGadgetWidget;
+
+using namespace Core;
+
+class ModelViewGadget : public Core::IUAVGadget
+{
+ Q_OBJECT
+public:
+ ModelViewGadget(QString classId, ModelViewGadgetWidget *widget, QWidget *parent = 0);
+ ~ModelViewGadget();
+
+ QWidget *widget() { return m_widget; }
+ void loadConfiguration(IUAVGadgetConfiguration* config);
+
+private:
+ ModelViewGadgetWidget *m_widget;
+};
+
+
+#endif // MODELVIEWGADGET_H_
diff --git a/ground/src/plugins/modelview/modelviewgadgetconfiguration.cpp b/ground/src/plugins/modelview/modelviewgadgetconfiguration.cpp
new file mode 100644
index 000000000..7d19e7e57
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadgetconfiguration.cpp
@@ -0,0 +1,60 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadgetconfiguration.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 "modelviewgadgetconfiguration.h"
+#include
+
+ModelViewGadgetConfiguration::ModelViewGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) :
+ IUAVGadgetConfiguration(classId, parent),
+ m_acFilename("../artwork/3D Model/quad.dae"),
+ m_bgFilename("../artwork/3D Model/default_background.png")
+{
+ if (state.count() > 0) {
+ QDataStream stream(state);
+ stream >> m_acFilename;
+ stream >> m_bgFilename;
+ }
+}
+
+IUAVGadgetConfiguration *ModelViewGadgetConfiguration::clone()
+{
+ ModelViewGadgetConfiguration *mv = new ModelViewGadgetConfiguration(this->classId());
+ mv->m_acFilename = m_acFilename;
+ mv->m_bgFilename = m_bgFilename;
+ return mv;
+}
+
+QByteArray ModelViewGadgetConfiguration::saveState() const
+{
+
+ QByteArray bytes;
+ QDataStream stream(&bytes, QIODevice::WriteOnly);
+ stream << m_acFilename;
+ stream << m_bgFilename;
+ return bytes;
+}
+
diff --git a/ground/src/plugins/modelview/modelviewgadgetconfiguration.h b/ground/src/plugins/modelview/modelviewgadgetconfiguration.h
new file mode 100644
index 000000000..d1a420022
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadgetconfiguration.h
@@ -0,0 +1,55 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadgetconfiguration.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 MODELVIEWGADGETCONFIGURATION_H
+#define MODELVIEWGADGETCONFIGURATION_H
+
+#include
+
+using namespace Core;
+
+class ModelViewGadgetConfiguration : public IUAVGadgetConfiguration
+{
+Q_OBJECT
+public:
+ explicit ModelViewGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
+ QByteArray saveState() const;
+ IUAVGadgetConfiguration *clone();
+ QString acFilename() {return m_acFilename;}
+ void setAcFilename(QString acFile) { m_acFilename = acFile; }
+ QString bgFilename() { return m_bgFilename; }
+ void setBgFilename(QString bgFile) { m_bgFilename = bgFile; }
+signals:
+
+public slots:
+
+private:
+ QString m_acFilename;
+ QString m_bgFilename;
+};
+
+#endif // MODELVIEWGADGETCONFIGURATION_H
diff --git a/ground/src/plugins/modelview/modelviewgadgetfactory.cpp b/ground/src/plugins/modelview/modelviewgadgetfactory.cpp
new file mode 100644
index 000000000..ae08a8ba1
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadgetfactory.cpp
@@ -0,0 +1,59 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadgetfactory.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 "modelviewgadgetfactory.h"
+#include "modelviewgadgetwidget.h"
+#include "modelviewgadget.h"
+#include "modelviewgadgetconfiguration.h"
+#include "modelviewgadgetoptionspage.h"
+#include
+#include
+
+ModelViewGadgetFactory::ModelViewGadgetFactory(QObject *parent) :
+ IUAVGadgetFactory(QString("ModelViewGadget"), tr("ModelView Gadget"), parent)
+{
+}
+
+ModelViewGadgetFactory::~ModelViewGadgetFactory()
+{
+}
+
+Core::IUAVGadget* ModelViewGadgetFactory::createGadget(QWidget *parent)
+{
+ ModelViewGadgetWidget* gadgetWidget = new ModelViewGadgetWidget(parent);
+ return new ModelViewGadget(QString("ModelViewGadget"), gadgetWidget, parent);
+}
+
+IUAVGadgetConfiguration *ModelViewGadgetFactory::createConfiguration(const QByteArray &state)
+{
+ return new ModelViewGadgetConfiguration(QString("ModelViewGadget"), state);
+}
+
+IOptionsPage *ModelViewGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
+{
+ return new ModelViewGadgetOptionsPage(qobject_cast(config));
+}
+
diff --git a/ground/src/plugins/modelview/modelviewgadgetfactory.h b/ground/src/plugins/modelview/modelviewgadgetfactory.h
new file mode 100644
index 000000000..bd7197e48
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadgetfactory.h
@@ -0,0 +1,52 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadgetfactory.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 MODELVIEWGADGETFACTORY_H_
+#define MODELVIEWGADGETFACTORY_H_
+
+#include
+
+namespace Core {
+class IUAVGadget;
+class IUAVGadgetFactory;
+}
+
+using namespace Core;
+
+class ModelViewGadgetFactory : public Core::IUAVGadgetFactory
+{
+ Q_OBJECT
+public:
+ ModelViewGadgetFactory(QObject *parent = 0);
+ ~ModelViewGadgetFactory();
+
+ Core::IUAVGadget *createGadget(QWidget *parent);
+ IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
+ IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
+};
+
+#endif // MODELVIEWGADGETFACTORY_H_
diff --git a/ground/src/plugins/modelview/modelviewgadgetoptionspage.cpp b/ground/src/plugins/modelview/modelviewgadgetoptionspage.cpp
new file mode 100644
index 000000000..44b5ba9f6
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadgetoptionspage.cpp
@@ -0,0 +1,96 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadgetoptionspage.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 "modelviewgadgetoptionspage.h"
+#include "modelviewgadgetconfiguration.h"
+
+
+ModelViewGadgetOptionsPage::ModelViewGadgetOptionsPage(ModelViewGadgetConfiguration *config, QObject *parent) :
+ IOptionsPage(parent),
+ m_config(config)
+{
+}
+
+QWidget *ModelViewGadgetOptionsPage::createPage(QWidget *parent)
+{
+ QWidget *widget = new QWidget;
+ QVBoxLayout *vl = new QVBoxLayout();
+ widget->setLayout(vl);
+
+ QWidget *label = new QLabel("3D Object File:");
+ vl->addWidget(label);
+
+ m_acFileLabel = new QLabel(m_config->acFilename());
+ QWidget* acPushbutton = new QPushButton("Change model");
+ vl->addWidget(m_acFileLabel);
+ vl->addWidget(acPushbutton);
+
+ QSpacerItem *spacer = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
+ vl->addSpacerItem(spacer);
+
+ label = new QLabel("Background image file:");
+ vl->addWidget(label);
+
+ m_bgFileLabel = new QLabel(m_config->bgFilename());
+ QWidget* bgPushbutton = new QPushButton("Change background");
+ vl->addWidget(m_bgFileLabel);
+ vl->addWidget(bgPushbutton);
+
+ QSpacerItem *spacer2 = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
+ vl->addSpacerItem(spacer2);
+
+ connect(acPushbutton, SIGNAL(clicked()), this, SLOT(changeAC()) );
+ connect(bgPushbutton, SIGNAL(clicked()), this, SLOT(changeBG()) );
+
+ return widget;
+}
+
+void ModelViewGadgetOptionsPage::apply()
+{
+ //m_config->setAcFilename(m_acFileName->selectedFiles());
+ //m_config->setBgFilename(m_bgFileName->selectedFiles());
+}
+
+void ModelViewGadgetOptionsPage::finish()
+{
+}
+
+void ModelViewGadgetOptionsPage::changeAC()
+{
+ QString ac = QFileDialog::getOpenFileName(qobject_cast(this),
+ tr("Model 3D File"), "../artwork/", tr("3D File (*.dae)") );
+ m_config->setAcFilename(ac);
+ m_acFileLabel->setText(ac);
+}
+
+void ModelViewGadgetOptionsPage::changeBG()
+{
+ QString bg = QFileDialog::getOpenFileName(qobject_cast(this),
+ tr("Background Image File"), "../artwork", tr("Image Files (*.png *.jpg *.bmp)") );
+ m_config->setBgFilename(bg);
+ m_bgFileLabel->setText(bg);
+}
diff --git a/ground/src/plugins/modelview/modelviewgadgetoptionspage.h b/ground/src/plugins/modelview/modelviewgadgetoptionspage.h
new file mode 100644
index 000000000..9e9b8dfcd
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadgetoptionspage.h
@@ -0,0 +1,74 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadgetoptionspage.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 MODELVIEWGADGETOPTIONSPAGE_H
+#define MODELVIEWGADGETOPTIONSPAGE_H
+
+#include "coreplugin/dialogs/ioptionspage.h"
+#include
+#include
+#include
+#include
+#include
+
+namespace Core {
+class IUAVGadgetConfiguration;
+}
+class ModelViewGadgetConfiguration;
+class QFileDialog;
+
+using namespace Core;
+
+class ModelViewGadgetOptionsPage : public IOptionsPage
+{
+Q_OBJECT
+public:
+ explicit ModelViewGadgetOptionsPage(ModelViewGadgetConfiguration *config, QObject *parent = 0);
+ QString id() const { return ""; }
+ QString trName() const { return ""; }
+ QString category() const { return ""; }
+ QString trCategory() const { return ""; }
+
+ QWidget *createPage(QWidget *parent);
+ void apply();
+ void finish();
+private:
+
+signals:
+
+public slots:
+private slots:
+ void changeAC();
+ void changeBG();
+
+private:
+ ModelViewGadgetConfiguration *m_config;
+ QLabel *m_acFileLabel;
+ QLabel *m_bgFileLabel;
+};
+
+#endif // MODELVIEWGADGETOPTIONSPAGE_H
diff --git a/ground/src/plugins/modelview/modelviewgadgetwidget.cpp b/ground/src/plugins/modelview/modelviewgadgetwidget.cpp
new file mode 100644
index 000000000..a23e292d3
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadgetwidget.cpp
@@ -0,0 +1,164 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadgetwidget.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 "modelviewgadgetwidget.h"
+
+ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
+: QGLWidget(parent)
+, m_pFactory(GLC_Factory::instance(this->context()))
+, m_Light()
+, m_World()
+, m_GlView(this)
+, m_MoverController()
+, m_ModelBoundingBox()
+, m_MotionTimer()
+{
+ setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+
+
+ m_Light.setPosition(4000.0, 40000.0, 80000.0);
+ m_Light.setAmbientColor(Qt::lightGray);
+
+ QColor repColor;
+ repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0);
+ m_MoverController= m_pFactory->createDefaultMoverController(repColor, &m_GlView);
+
+ m_GlView.cameraHandle()->setDefaultUpVector(glc::Z_AXIS);
+ m_GlView.cameraHandle()->setIsoView();
+
+ // Create objects to display
+ CreateScene();
+ connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(rotateView()));
+}
+
+ModelViewGadgetWidget::~ModelViewGadgetWidget()
+{
+ delete m_pFactory;
+}
+
+void ModelViewGadgetWidget::initializeGL()
+{
+ // OpenGL initialization
+ m_GlView.initGl();
+
+ m_GlView.reframe(m_ModelBoundingBox);
+ //m_GlView.reframe(m_World.boundingBox());
+ // Calculate camera depth of view
+ m_GlView.setDistMinAndMax(m_World.boundingBox());
+ glEnable(GL_NORMALIZE);
+
+ m_MotionTimer.start(60);
+}
+
+void ModelViewGadgetWidget::resizeEvent(QResizeEvent *event)
+{
+// printf("%d,%d\n", width(), height());
+// m_GlView.setWinGLSize(width(), height());
+ QWidget::resizeEvent(event);
+}
+
+void ModelViewGadgetWidget::paintGL()
+{
+ // Clear screen
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ // Load identity matrix
+ glLoadIdentity();
+
+ // define the light
+ m_Light.enable();
+
+ // define view matrix
+ m_GlView.glExecuteCam();
+ m_Light.glExecute();
+
+ // Display the collection of GLC_Object
+ m_World.glExecute(0, false);
+
+ // Display UI Info (orbit circle)
+ m_MoverController.drawActiveMoverRep();
+}
+
+void ModelViewGadgetWidget::resizeGL(int width, int height)
+{
+ m_GlView.setWinGLSize(width, height); // Compute window aspect ratio
+}
+
+// Create GLC_Object to display
+void ModelViewGadgetWidget::CreateScene()
+{
+ // TODO: Replace with files from configuration page
+ m_GlView.loadBackGroundImage("../artwork/3D\ Model/default_background.png");
+ QFile aircraft("../artwork/3D\ Model/quad.dae");
+
+ GLC_World* pWorld= m_pFactory->createWorld(aircraft);
+ m_World= *pWorld;
+ delete pWorld;
+
+ m_ModelBoundingBox= m_World.boundingBox();
+}
+
+void ModelViewGadgetWidget::mousePressEvent(QMouseEvent *e)
+{
+ if (m_MoverController.hasActiveMover()) return;
+
+ switch (e->button())
+ {
+ case (Qt::LeftButton):
+ m_MotionTimer.stop();
+ m_MoverController.setActiveMover(GLC_MoverController::TurnTable, e->x(), e->y());
+ updateGL();
+ break;
+ default:
+ break;
+ }
+}
+
+void ModelViewGadgetWidget::mouseMoveEvent(QMouseEvent * e)
+{
+ if (not m_MoverController.hasActiveMover()) return;
+ m_MoverController.move(e->x(), e->y());
+ m_GlView.setDistMinAndMax(m_World.boundingBox());
+ updateGL();
+}
+
+void ModelViewGadgetWidget::mouseReleaseEvent(QMouseEvent*)
+{
+ if (not m_MoverController.hasActiveMover()) return;
+ m_MoverController.setNoMover();
+ m_MotionTimer.start();
+ updateGL();
+}
+
+//////////////////////////////////////////////////////////////////////
+// Private slots Functions
+//////////////////////////////////////////////////////////////////////
+// Rotate the view
+void ModelViewGadgetWidget::rotateView()
+{
+ m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS, 2.0 * glc::PI / static_cast(200));
+ updateGL();
+}
+
diff --git a/ground/src/plugins/modelview/modelviewgadgetwidget.h b/ground/src/plugins/modelview/modelviewgadgetwidget.h
new file mode 100644
index 000000000..25f248df5
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewgadgetwidget.h
@@ -0,0 +1,89 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewgadgetwidget.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 MODELVIEWGADGETWIDGET_H_
+#define MODELVIEWGADGETWIDGET_H_
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+
+
+class ModelViewGadgetWidget : public QGLWidget
+{
+ Q_OBJECT
+
+public:
+ ModelViewGadgetWidget(QWidget *parent = 0);
+ ~ModelViewGadgetWidget();
+ void setAcFilename(QString acf) { acFilename = acf; }
+ void setBgFilename(QString bgf) { bgFilename = bgf; }
+ void updateAttitude(int value);
+
+protected:
+ void resizeEvent(QResizeEvent *event);
+
+private:
+ void initializeGL();
+ void paintGL();
+ void resizeGL(int width, int height);
+ // Create GLC_Object to display
+ void CreateScene();
+
+ //Mouse events
+ void mousePressEvent(QMouseEvent * e);
+ void mouseMoveEvent(QMouseEvent * e);
+ void mouseReleaseEvent(QMouseEvent * e);
+
+//////////////////////////////////////////////////////////////////////
+// Private slots Functions
+//////////////////////////////////////////////////////////////////////
+private slots:
+ //! Rotate the view
+ void rotateView();
+
+private:
+ GLC_Factory* m_pFactory;
+ GLC_Light m_Light;
+ GLC_World m_World;
+ GLC_Viewport m_GlView;
+ GLC_MoverController m_MoverController;
+ GLC_BoundingBox m_ModelBoundingBox;
+ //! The timer used for motion
+ QTimer m_MotionTimer;
+
+ QString acFilename;
+ QString bgFilename;
+};
+
+#endif /* MODELVIEWGADGETWIDGET_H_ */
diff --git a/ground/src/plugins/modelview/modelviewplugin.cpp b/ground/src/plugins/modelview/modelviewplugin.cpp
new file mode 100644
index 000000000..c56aafa92
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewplugin.cpp
@@ -0,0 +1,65 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewplugin.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 "modelviewplugin.h"
+#include "modelviewgadgetfactory.h"
+#include
+#include
+#include
+#include
+
+
+ModelViewPlugin::ModelViewPlugin()
+{
+ // Do nothing
+}
+
+ModelViewPlugin::~ModelViewPlugin()
+{
+ // Do nothing
+}
+
+bool ModelViewPlugin::initialize(const QStringList& args, QString *errMsg)
+{
+ Q_UNUSED(args);
+ Q_UNUSED(errMsg);
+ mvf = new ModelViewGadgetFactory(this);
+ addAutoReleasedObject(mvf);
+
+ return true;
+}
+
+void ModelViewPlugin::extensionsInitialized()
+{
+ // Do nothing
+}
+
+void ModelViewPlugin::shutdown()
+{
+ // Do nothing
+}
+Q_EXPORT_PLUGIN(ModelViewPlugin)
+
diff --git a/ground/src/plugins/modelview/modelviewplugin.h b/ground/src/plugins/modelview/modelviewplugin.h
new file mode 100644
index 000000000..c28e06ee6
--- /dev/null
+++ b/ground/src/plugins/modelview/modelviewplugin.h
@@ -0,0 +1,47 @@
+/**
+ ******************************************************************************
+ *
+ * @file modelviewplugin.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup modelview
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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 MODELVIEWPLUGIN_H_
+#define MODELVIEWPLUGIN_H_
+
+#include
+
+class ModelViewGadgetFactory;
+
+class ModelViewPlugin : public ExtensionSystem::IPlugin
+{
+public:
+ ModelViewPlugin();
+ ~ModelViewPlugin();
+
+ void extensionsInitialized();
+ bool initialize(const QStringList & arguments, QString * errorString);
+ void shutdown();
+private:
+ ModelViewGadgetFactory *mvf;
+};
+#endif /* MODELVIEWPLUGIN_H_ */
diff --git a/ground/src/plugins/plugins.pro b/ground/src/plugins/plugins.pro
index 4fbeab02c..15e736bd4 100644
--- a/ground/src/plugins/plugins.pro
+++ b/ground/src/plugins/plugins.pro
@@ -49,4 +49,9 @@ plugin_scope.subdir = scope
plugin_scope.depends = plugin_coreplugin
SUBDIRS += plugin_scope
+# ModelView UAVGadget
+plugin_modelview.subdir = modelview
+plugin_scope.depends = plugin_coreplugin
+SUBDIRS += plugin_modelview
+