1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

LP-29 remove modelview sources

This commit is contained in:
Philippe Renon 2016-01-19 22:44:17 +01:00
parent 80dafbe446
commit 62c8f4c4ad
20 changed files with 0 additions and 22685 deletions

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,48 +0,0 @@
# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
# File Created: 14.10.2010 00:38:26
newmtl red
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 1.0000 0.0000 0.0000
Kd 1.0000 0.0000 0.0000
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
newmtl white
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 1.0000 1.0000 1.0000
Kd 1.0000 1.0000 1.0000
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
newmtl black
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.0000 0.0000 0.0000
Kd 0.0000 0.0000 0.0000
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
newmtl wire_000000000
Ns 32
d 1
Tr 0
Tf 1 1 1
illum 2
Ka 0.0000 0.0000 0.0000
Kd 0.0000 0.0000 0.0000
Ks 0.3500 0.3500 0.3500

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
TEMPLATE = lib
TARGET = ModelViewGadget
include(../../plugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/glc_lib/glc_lib.pri)
include(modelview_dependencies.pri)
INCLUDEPATH += ../../libs/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 += ModelViewGadget.pluginspec
FORMS += modelviewoptionspage.ui
RESOURCES += \
modelview.qrc

View File

@ -1,7 +0,0 @@
<RCC>
<qresource prefix="/modelview">
<file>models/black.jpg</file>
<file>models/warning_sign.mtl</file>
<file>models/warning_sign.obj</file>
</qresource>
</RCC>

View File

@ -1,3 +0,0 @@
include(../../plugins/uavobjects/uavobjects.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/utils/utils.pri)

View File

@ -1,49 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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()
{
delete m_widget;
}
void ModelViewGadget::loadConfiguration(IUAVGadgetConfiguration *config)
{
ModelViewGadgetConfiguration *m = qobject_cast<ModelViewGadgetConfiguration *>(config);
m_widget->setAcFilename(m->acFilename());
m_widget->setBgFilename(m->bgFilename());
m_widget->setVboEnable(m->vboEnabled());
m_widget->reloadScene();
}

View File

@ -1,58 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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

@ -1,66 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadgetconfiguration.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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 "utils/pathutils.h"
ModelViewGadgetConfiguration::ModelViewGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_acFilename(Utils::GetDataPath() + QString("models/planes/Easystar/EasyStar.3ds")),
m_bgFilename(""),
m_enableVbo(false)
{
// if a saved configuration exists load it
if (qSettings != 0) {
QString modelFile = qSettings->value("acFilename").toString();
QString bgFile = qSettings->value("bgFilename").toString();
m_enableVbo = qSettings->value("enableVbo").toBool();
m_acFilename = Utils::InsertDataPath(modelFile);
m_bgFilename = Utils::InsertDataPath(bgFile);
}
}
IUAVGadgetConfiguration *ModelViewGadgetConfiguration::clone()
{
ModelViewGadgetConfiguration *mv = new ModelViewGadgetConfiguration(this->classId());
mv->m_acFilename = m_acFilename;
mv->m_bgFilename = m_bgFilename;
mv->m_enableVbo = m_enableVbo;
return mv;
}
/**
* Saves a configuration.
*
*/
void ModelViewGadgetConfiguration::saveConfig(QSettings *qSettings) const
{
qSettings->setValue("acFilename", Utils::RemoveDataPath(m_acFilename));
qSettings->setValue("bgFilename", Utils::RemoveDataPath(m_bgFilename));
qSettings->setValue("enableVbo", m_enableVbo);
}

View File

@ -1,76 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadgetconfiguration.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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, QSettings *qSettings = 0, QObject *parent = 0);
void saveConfig(QSettings *settings) 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;
}
bool vboEnabled()
{
return m_enableVbo;
}
void setVboEnabled(bool vboEnable)
{
m_enableVbo = vboEnable;
}
signals:
public slots:
private:
QString m_acFilename;
QString m_bgFilename;
bool m_enableVbo; // Vertex buffer objects, a few GPUs crash if enabled
};
#endif // MODELVIEWGADGETCONFIGURATION_H

View File

@ -1,57 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadgetfactory.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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"), parent)
{}
ModelViewGadgetFactory::~ModelViewGadgetFactory()
{}
Core::IUAVGadget *ModelViewGadgetFactory::createGadget(QWidget *parent)
{
ModelViewGadgetWidget *gadgetWidget = new ModelViewGadgetWidget(parent);
return new ModelViewGadget(QString("ModelViewGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *ModelViewGadgetFactory::createConfiguration(QSettings *qSettings)
{
return new ModelViewGadgetConfiguration(QString("ModelViewGadget"), qSettings);
}
IOptionsPage *ModelViewGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{
return new ModelViewGadgetOptionsPage(qobject_cast<ModelViewGadgetConfiguration *>(config));
}

View File

@ -1,51 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadgetfactory.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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(QSettings *qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};
#endif // MODELVIEWGADGETFACTORY_H_

View File

@ -1,71 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadgetoptionspage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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"
#include "ui_modelviewoptionspage.h"
ModelViewGadgetOptionsPage::ModelViewGadgetOptionsPage(ModelViewGadgetConfiguration *config, QObject *parent) :
IOptionsPage(parent),
m_config(config)
{}
QWidget *ModelViewGadgetOptionsPage::createPage(QWidget *parent)
{
m_page = new Ui::ModelViewOptionsPage();
QWidget *w = new QWidget(parent);
m_page->setupUi(w);
m_page->modelPathChooser->setExpectedKind(Utils::PathChooser::File);
m_page->modelPathChooser->setPromptDialogFilter(tr("3D model (*.dae *.3ds)"));
m_page->modelPathChooser->setPromptDialogTitle(tr("Choose 3D model"));
m_page->backgroundPathChooser->setExpectedKind(Utils::PathChooser::File);
m_page->backgroundPathChooser->setPromptDialogFilter(tr("Images (*.png *.jpg *.bmp *.xpm)"));
m_page->backgroundPathChooser->setPromptDialogTitle(tr("Choose background image"));
m_page->modelPathChooser->setPath(m_config->acFilename());
m_page->backgroundPathChooser->setPath(m_config->bgFilename());
m_page->enableVbo->setChecked(m_config->vboEnabled());
return w;
}
void ModelViewGadgetOptionsPage::apply()
{
m_config->setAcFilename(m_page->modelPathChooser->path());
m_config->setBgFilename(m_page->backgroundPathChooser->path());
m_config->setVboEnabled(m_page->enableVbo->isChecked());
}
void ModelViewGadgetOptionsPage::finish()
{
delete m_page;
}

View File

@ -1,85 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadgetoptionspage.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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 <QLabel>
#include <QFileDialog>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
class ModelViewGadgetConfiguration;
class QFileDialog;
namespace Core {
class IUAVGadgetConfiguration;
}
namespace Ui {
class ModelViewOptionsPage;
}
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:
private:
ModelViewGadgetConfiguration *m_config;
Ui::ModelViewOptionsPage *m_page;
};
#endif // MODELVIEWGADGETOPTIONSPAGE_H

View File

@ -1,352 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadgetwidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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 "QtDebug"
#ifdef __APPLE__
#include "OpenGL/OpenGL.h"
#endif
#include "modelviewgadgetwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "glc_context.h"
#include "glc_exception.h"
#include "glc_openglexception.h"
#include "viewport/glc_userinput.h"
#include <iostream>
ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
: QGLWidget(new GLC_Context(QGLFormat(QGL::SampleBuffers)), parent)
, m_Light()
, m_World()
, m_GlView()
, m_MoverController()
, m_ModelBoundingBox()
, m_MotionTimer()
, acFilename()
, bgFilename()
, vboEnable(false)
{
connect(&m_GlView, SIGNAL(updateOpenGL()), this, SLOT(updateGL()));
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
m_Light.setPosition(4000.0, 40000.0, 80000.0);
// m_GlView.setBackgroundColor(Qt::white);
m_Light.setAmbientColor(Qt::lightGray);
m_GlView.cameraHandle()->setDefaultUpVector(glc::Z_AXIS);
m_GlView.cameraHandle()->setRearView();
QColor repColor;
repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0);
m_MoverController = GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView);
CreateScene();
// Get required UAVObjects
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
attState = AttitudeState::GetInstance(objManager);
connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(updateAttitude()));
}
ModelViewGadgetWidget::~ModelViewGadgetWidget()
{}
void ModelViewGadgetWidget::setAcFilename(QString acf)
{
if (QFile::exists(acf)) {
acFilename = acf;
} else {
acFilename = acf = ":/modelview/models/warning_sign.obj";
m_GlView.cameraHandle()->setFrontView(); // set to front camera to see/read the warning sign
}
}
void ModelViewGadgetWidget::setBgFilename(QString bgf)
{
if (QFile::exists(bgFilename)) {
bgFilename = bgf;
} else {
qDebug() << "file " << bgf << " doesn't exists";
bgFilename = ":/modelview/models/black.jpg"; // will put a black background if there's no background
}
}
void ModelViewGadgetWidget::setVboEnable(bool eVbo)
{
vboEnable = eVbo;
m_World.collection()->setVboUsage(vboEnable);
}
//// Public funcitons ////
void ModelViewGadgetWidget::reloadScene()
{
CreateScene();
}
//// Private functions ////
void ModelViewGadgetWidget::initializeGL()
{
// For VSYNC problem under Mac OS X
#if defined(Q_OS_MAC)
const GLint swapInterval = 1;
CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &swapInterval);
#endif
// OpenGL initialization
m_GlView.initGl();
// Reframe the scene
m_GlView.reframe(m_ModelBoundingBox);
glEnable(GL_NORMALIZE);
// Enable antialiasing
glEnable(GL_MULTISAMPLE);
m_MotionTimer.start(100);
setFocusPolicy(Qt::StrongFocus); // keyboard capture for camera switching
}
void ModelViewGadgetWidget::paintGL()
{
try {
// Clear screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// OpenGL error handler
{
GLenum error = glGetError();
if (error != GL_NO_ERROR) {
GLC_OpenGlException OpenGlException("ModelViewGadgetWidget::paintGL() ", error);
throw(OpenGlException);
}
}
// Load identity matrix
GLC_Context::current()->glcLoadIdentity();
// Enable antialiasing
glEnable(GL_MULTISAMPLE);
// Calculate camera depth of view
m_GlView.setDistMinAndMax(m_World.boundingBox());
// define view matrix
m_GlView.glExecuteCam();
m_Light.glExecute();
// Display the collection of GLC_Object
m_World.render(0, glc::ShadingFlag);
m_World.render(0, glc::TransparentRenderFlag);
// Display UI Info (orbit circle)
m_MoverController.drawActiveMoverRep();
} catch(GLC_Exception &e) {
qDebug() << e.what();
}
}
void ModelViewGadgetWidget::resizeGL(int width, int height)
{
m_GlView.setWinGLSize(width, height); // Compute window aspect ratio
// OpenGL error handler
{
GLenum error = glGetError();
if (error != GL_NO_ERROR) {
GLC_OpenGlException OpenGlException("ModelViewGadgetWidget::resizeGL() ", error);
throw(OpenGlException);
}
}
}
// Create GLC_Object to display
void ModelViewGadgetWidget::CreateScene()
{
// put a black background if the 3D model is invalid or if the background image is also invalid
if (acFilename == ":/modelview/models/warning_sign.obj" or !QFile::exists(bgFilename)) {
bgFilename = ":/modelview/models/black.jpg";
}
try {
m_GlView.loadBackGroundImage(bgFilename);
} catch(GLC_Exception e) {
qDebug("ModelView: background image file loading failed.");
}
try {
if (QFile::exists(acFilename)) {
QFile aircraft(acFilename);
m_World = GLC_Factory::instance()->createWorldFromFile(aircraft);
m_ModelBoundingBox = m_World.boundingBox();
m_GlView.reframe(m_ModelBoundingBox); // center 3D model in the scene
} else {
qDebug("ModelView: aircraft file not found.");
}
} catch(GLC_Exception e) {
qDebug("ModelView: aircraft file loading failed.");
}
}
void ModelViewGadgetWidget::wheelEvent(QWheelEvent *e)
{
double delta = m_GlView.cameraHandle()->distEyeTarget() - (e->delta() / 4);
m_GlView.cameraHandle()->setDistEyeTarget(delta);
m_GlView.setDistMinAndMax(m_World.boundingBox());
}
void ModelViewGadgetWidget::mousePressEvent(QMouseEvent *e)
{
GLC_UserInput userInput(e->x(), e->y());
if (m_MoverController.hasActiveMover()) {
return;
}
switch (e->button()) {
case (Qt::LeftButton):
m_MotionTimer.stop();
m_MoverController.setActiveMover(GLC_MoverController::TurnTable, userInput);
updateGL();
break;
case (Qt::RightButton):
printf("VBO enabled: %s, VBO supported: %s, VBO used: %s\n",
vboEnable ? "yes" : "no",
GLC_State::vboSupported() ? "yes" : "no",
GLC_State::vboUsed() ? "yes" : "no");
printf("Renderer - %s \n", (char *)glGetString(GL_RENDERER));
printf("Extensions - %s\n", (char *)glGetString(GL_EXTENSIONS));
break;
default:
break;
}
}
void ModelViewGadgetWidget::mouseMoveEvent(QMouseEvent *e)
{
GLC_UserInput userInput(e->x(), e->y());
if (not m_MoverController.hasActiveMover()) {
return;
}
m_MoverController.move(userInput);
m_GlView.setDistMinAndMax(m_World.boundingBox());
updateGL();
}
void ModelViewGadgetWidget::mouseReleaseEvent(QMouseEvent *)
{
if (not m_MoverController.hasActiveMover()) {
return;
}
m_MoverController.setNoMover();
m_MotionTimer.start();
updateGL();
}
void ModelViewGadgetWidget::keyPressEvent(QKeyEvent *e) // switch between camera
{
if (e->key() == Qt::Key_1) {
m_GlView.cameraHandle()->setIsoView();
updateGL();
}
if (e->key() == Qt::Key_2) {
m_GlView.cameraHandle()->setFrontView();
updateGL();
}
if (e->key() == Qt::Key_3) {
m_GlView.cameraHandle()->setIsoView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS, glc::toRadian(90));
updateGL();
}
if (e->key() == Qt::Key_4) {
m_GlView.cameraHandle()->setLeftView();
updateGL();
}
if (e->key() == Qt::Key_5) {
m_GlView.cameraHandle()->setTopView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS, glc::toRadian(180));
updateGL();
}
if (e->key() == Qt::Key_6) {
m_GlView.cameraHandle()->setRightView();;
updateGL();
}
if (e->key() == Qt::Key_7) {
m_GlView.cameraHandle()->setIsoView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS, glc::toRadian(-90));
updateGL();
}
if (e->key() == Qt::Key_8) {
m_GlView.cameraHandle()->setRearView();;
updateGL();
}
if (e->key() == Qt::Key_9) {
m_GlView.cameraHandle()->setIsoView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS, glc::toRadian(180));
updateGL();
}
if (e->key() == Qt::Key_0) {
m_GlView.cameraHandle()->setBottomView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS, glc::toRadian(180));
updateGL();
}
}
//////////////////////////////////////////////////////////////////////
// Private slots Functions
//////////////////////////////////////////////////////////////////////
void ModelViewGadgetWidget::updateAttitude()
{
AttitudeState::DataFields data = attState->getData(); // get attitude data
GLC_StructOccurence *rootObject = m_World.rootOccurence(); // get the full 3D model
double x = data.q3;
double y = data.q2;
double z = data.q4;
double w = data.q1;
if (w == 0.0) {
w = 1.0;
}
// create and gives the product of 2 4x4 matrices to get the rotation of the 3D model's matrix
QMatrix4x4 m1;
m1.setRow(0, QVector4D(w, z, -y, x));
m1.setRow(1, QVector4D(-z, w, x, y));
m1.setRow(2, QVector4D(y, -x, w, z));
m1.setRow(3, QVector4D(-x, -y, -z, w));
QMatrix4x4 m2;
m2.setRow(0, QVector4D(w, z, -y, -x));
m2.setRow(1, QVector4D(-z, w, x, -y));
m2.setRow(2, QVector4D(y, -x, w, -z));
m2.setRow(3, QVector4D(x, y, z, w));
QMatrix4x4 m0 = m1 * m2;
// convert QMatrix4x4 to GLC_Matrix4x4
GLC_Matrix4x4 rootObjectRotation(m0.data());
rootObject->structInstance()->setMatrix(rootObjectRotation);
rootObject->updateChildrenAbsoluteMatrix();
updateGL();
}

View File

@ -1,95 +0,0 @@
/**
******************************************************************************
*
* @file modelviewgadgetwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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 <QGLWidget>
#include <QTimer>
#include "glc_factory.h"
#include "viewport/glc_viewport.h"
#include "viewport/glc_movercontroller.h"
#include "shading/glc_light.h"
#include "sceneGraph/glc_world.h"
#include "glc_exception.h"
#include "uavobjectmanager.h"
#include "attitudestate.h"
class ModelViewGadgetWidget : public QGLWidget {
Q_OBJECT
public:
ModelViewGadgetWidget(QWidget *parent = 0);
~ModelViewGadgetWidget();
void setAcFilename(QString acf);
void setBgFilename(QString bgf);
void setVboEnable(bool eVbo);
void reloadScene();
void updateAttitude(int value);
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);
void wheelEvent(QWheelEvent *e);
void keyPressEvent(QKeyEvent *e);
//////////////////////////////////////////////////////////////////////
// Private slots Functions
//////////////////////////////////////////////////////////////////////
private slots:
void updateAttitude();
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;
bool vboEnable;
AttitudeState *attState;
};
#endif /* MODELVIEWGADGETWIDGET_H_ */

View File

@ -1,95 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ModelViewOptionsPage</class>
<widget class="QWidget" name="ModelViewOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>378</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>3D model:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Background image:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Utils::PathChooser" name="backgroundPathChooser" native="true">
<property name="toolTip">
<string>Select the image that is shown in the background.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Utils::PathChooser" name="modelPathChooser" native="true">
<property name="toolTip">
<string>Select the 3D model file here.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="enableVbo">
<property name="toolTip">
<string>Click to enable the use of Vertical Blanking.
It is not enabled by default because some graphic cards do not
support it, and crash the GCS. Enabling improves performance, though, so you can experiment at your own risk.</string>
</property>
<property name="whatsThis">
<string>VBO allow for performance gains for GPUs that support it (most cards). This may cause cards with faulty drivers to crash.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Enable VBOs:</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header>utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,63 +0,0 @@
/**
******************************************************************************
*
* @file modelviewplugin.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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
}

View File

@ -1,50 +0,0 @@
/**
******************************************************************************
*
* @file modelviewplugin.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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 {
Q_OBJECT
Q_PLUGIN_METADATA(IID "Openpilot.ModelView")
public:
ModelViewPlugin();
~ModelViewPlugin();
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString *errorString);
void shutdown();
private:
ModelViewGadgetFactory *mvf;
};
#endif /* MODELVIEWPLUGIN_H_ */