From 1fd3018684a63fe47f302dc10ff32d1b6372151a Mon Sep 17 00:00:00 2001 From: chebuzz Date: Tue, 10 Aug 2010 16:57:14 +0000 Subject: [PATCH] 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 --- .../modelview/modelviewgadgetwidget.cpp | 39 +++++++++++-------- .../plugins/modelview/modelviewgadgetwidget.h | 1 + 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ground/src/plugins/modelview/modelviewgadgetwidget.cpp b/ground/src/plugins/modelview/modelviewgadgetwidget.cpp index 67e577362..fbebcdcde 100644 --- a/ground/src/plugins/modelview/modelviewgadgetwidget.cpp +++ b/ground/src/plugins/modelview/modelviewgadgetwidget.cpp @@ -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(); } diff --git a/ground/src/plugins/modelview/modelviewgadgetwidget.h b/ground/src/plugins/modelview/modelviewgadgetwidget.h index 05295ddbf..ba5b069c9 100644 --- a/ground/src/plugins/modelview/modelviewgadgetwidget.h +++ b/ground/src/plugins/modelview/modelviewgadgetwidget.h @@ -36,6 +36,7 @@ #include #include #include +#include #include "uavobjects/uavobjectmanager.h" #include "uavobjects/attitudeactual.h"