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

Missed these files during initial modelview plugin checkin

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@413 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
chebuzz 2010-03-31 13:35:04 +00:00 committed by chebuzz
parent 7f49a2d84f
commit 09aa791f29
16 changed files with 899 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

View File

@ -0,0 +1,10 @@
<plugin name="ModelViewGadget" version="1.0.0" compatVersion="1.0.0">
<vendor>The OpenPilot Project</vendor>
<copyright>(C) 2010 OpenPilot Project</copyright>
<license></license>
<description>A 3D model view gadget!</description>
<url>http://www.openpilot.org</url>
<dependencyList>
<dependency name="Core" version="1.0.0"/>
</dependencyList>
</plugin>

View File

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

View File

@ -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<ModelViewGadgetConfiguration*>(config);
m_widget->setAcFilename(m->acFilename());
m_widget->setBgFilename(m->bgFilename());
}

View File

@ -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 <coreplugin/iuavgadget.h>
#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_

View File

@ -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 <QtCore/QDataStream>
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;
}

View File

@ -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 <coreplugin/iuavgadgetconfiguration.h>
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

View File

@ -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 <coreplugin/uavgadgetoptionspagedecorator.h>
#include <coreplugin/iuavgadget.h>
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<ModelViewGadgetConfiguration*>(config));
}

View File

@ -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 <coreplugin/iuavgadgetfactory.h>
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_

View File

@ -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<QWidget*>(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<QWidget*>(this),
tr("Background Image File"), "../artwork", tr("Image Files (*.png *.jpg *.bmp)") );
m_config->setBgFilename(bg);
m_bgFileLabel->setText(bg);
}

View File

@ -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 <QtGui/QLabel>
#include <QtGui/QFileDialog>
#include <QtGui/QPushButton>
#include <QtGui/QHBoxLayout>
#include <QtGui/QVBoxLayout>
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

View File

@ -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<double>(200));
updateGL();
}

View File

@ -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 <QtOpenGL/QGLWidget>
#include <QTimer>
#include <GLC_Factory>
#include <GLC_Viewport>
#include <GLC_MoverController>
#include <GLC_Light>
#include <GLC_World>
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_ */

View File

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

View File

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

View File

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