1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-98 GCS/ModelView - Update ModelView to use GLC_lib 2.0

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1259 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
chebuzz 2010-08-10 16:57:14 +00:00 committed by chebuzz
parent d02b0d2da3
commit 1fd3018684
2 changed files with 24 additions and 16 deletions

View File

@ -41,6 +41,7 @@ ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
CreateScene();
m_Light.setPosition(4000.0, 40000.0, 80000.0);
m_Light.setAmbientColor(Qt::lightGray);
@ -59,7 +60,6 @@ ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
attActual = AttitudeActual::GetInstance(objManager);
// Create objects to display
CreateScene();
connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(updateAttitude()));
}
@ -119,7 +119,7 @@ void ModelViewGadgetWidget::paintGL()
m_Light.glExecute();
// Display the collection of GLC_Object
m_World.glExecute(0, false);
m_World.render(0, glc::ShadingFlag);
// Display UI Info (orbit circle)
m_MoverController.drawActiveMoverRep();
@ -133,23 +133,30 @@ void ModelViewGadgetWidget::resizeGL(int width, int height)
// Create GLC_Object to display
void ModelViewGadgetWidget::CreateScene()
{
if (QFile::exists(bgFilename))
try
{
m_GlView.loadBackGroundImage(bgFilename);
}
//else { std::cout << "File doesn't exist" << bgFilename.toStdString() << std::endl; }
if (QFile::exists(acFilename))
catch(GLC_Exception e)
{
QFile aircraft(acFilename);
GLC_World* pWorld= m_pFactory->createWorld(aircraft);
m_World= *pWorld;
delete pWorld;
m_ModelBoundingBox= m_World.boundingBox();
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();
}
}
catch(GLC_Exception e)
{
qDebug("ModelView aircraft texture file loading failed.");
}
//else { std::cout << "File doesn't exist" << acFilename.toStdString() << std::endl; }
}
void ModelViewGadgetWidget::mousePressEvent(QMouseEvent *e)
@ -160,7 +167,7 @@ void ModelViewGadgetWidget::mousePressEvent(QMouseEvent *e)
{
case (Qt::LeftButton):
m_MotionTimer.stop();
m_MoverController.setActiveMover(GLC_MoverController::TurnTable, e->x(), e->y());
m_MoverController.setActiveMover(GLC_MoverController::TurnTable, e);
updateGL();
break;
default:
@ -171,7 +178,7 @@ void ModelViewGadgetWidget::mousePressEvent(QMouseEvent *e)
void ModelViewGadgetWidget::mouseMoveEvent(QMouseEvent * e)
{
if (not m_MoverController.hasActiveMover()) return;
m_MoverController.move(e->x(), e->y());
m_MoverController.move(e);
m_GlView.setDistMinAndMax(m_World.boundingBox());
updateGL();
}

View File

@ -36,6 +36,7 @@
#include <GLC_MoverController>
#include <GLC_Light>
#include <GLC_World>
#include <GLC_Exception>
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/attitudeactual.h"