Revision: 35365 http://brlcad.svn.sourceforge.net/brlcad/?rev=35365&view=rev Author: ralith Date: 2009-07-29 10:48:14 +0000 (Wed, 29 Jul 2009)
Log Message: ----------- Partially restored camera controls. Modified Paths: -------------- rt^3/trunk/src/g3d/CMakeLists.txt rt^3/trunk/src/g3d/MainWindow.cxx rt^3/trunk/src/g3d/MainWindow.h rt^3/trunk/src/g3d/OgreGLWidget.cxx rt^3/trunk/src/g3d/OgreGLWidget.h rt^3/trunk/src/g3d/mainwindow.ui Modified: rt^3/trunk/src/g3d/CMakeLists.txt =================================================================== --- rt^3/trunk/src/g3d/CMakeLists.txt 2009-07-29 09:52:18 UTC (rev 35364) +++ rt^3/trunk/src/g3d/CMakeLists.txt 2009-07-29 10:48:14 UTC (rev 35365) @@ -23,6 +23,7 @@ MainWindow.cxx main.cxx OgreGraphicsView.cxx + CameraInputLayer.cxx ) set(G3D_HEADERS @@ -49,6 +50,7 @@ MainWindow.h Console.h OgreGraphicsView.h + CameraInputLayer.h ) set(G3D_UIS Modified: rt^3/trunk/src/g3d/MainWindow.cxx =================================================================== --- rt^3/trunk/src/g3d/MainWindow.cxx 2009-07-29 09:52:18 UTC (rev 35364) +++ rt^3/trunk/src/g3d/MainWindow.cxx 2009-07-29 10:48:14 UTC (rev 35365) @@ -29,11 +29,13 @@ #include "MainWindow.h" #include <QString> +#include <QApplication> + -MainWindow::MainWindow() : window(new QWidget()), - ogreView(new OgreGLWidget()), +MainWindow::MainWindow() : ogreView(new OgreGLWidget()), scene(new QGraphicsScene()), - cmdInterp(new CommandInterpreter()) + cmdInterp(new CommandInterpreter()), + window(new CameraInputLayer(*ogreView)) { setViewport(ogreView); setViewportUpdateMode(QGraphicsView::FullViewportUpdate); @@ -45,6 +47,7 @@ scene->addWidget(window); window->move(0, 0); + window->setFocusPolicy(Qt::ClickFocus); // WARNING: The entries of the cameraProjection dropdown MUST be // listed in the same order as the elements of @@ -52,12 +55,12 @@ QObject::connect(cameraProjection, SIGNAL(activated(int)), ogreView, SLOT(setProjection(int))); QObject::connect(cameraProjection, SIGNAL(activated(int)), - ogreView, SLOT(setFocus(void))); + window, SLOT(setFocus(void))); QObject::connect(cameraMode, SIGNAL(activated(int)), ogreView, SLOT(setCameraMode(int))); QObject::connect(cameraMode, SIGNAL(activated(int)), - ogreView, SLOT(setFocus(void))); + window, SLOT(setFocus(void))); QObject::connect(console, SIGNAL(commandRan(QString)), cmdInterp, SLOT(execute(QString))); @@ -65,7 +68,7 @@ console, SLOT(pushOutput(QString))); // Give focus to the render area, and thus camera control. - ogreView->setFocus(Qt::OtherFocusReason); + window->setFocus(Qt::OtherFocusReason); } MainWindow::~MainWindow() @@ -76,6 +79,7 @@ void MainWindow::resizeEvent(QResizeEvent *event) { + // Just large enough not to cause scrollbars to appear. window->resize(event->size() - QSize(1, 1)); OgreGraphicsView::resizeEvent(event); } Modified: rt^3/trunk/src/g3d/MainWindow.h =================================================================== --- rt^3/trunk/src/g3d/MainWindow.h 2009-07-29 09:52:18 UTC (rev 35364) +++ rt^3/trunk/src/g3d/MainWindow.h 2009-07-29 10:48:14 UTC (rev 35365) @@ -36,10 +36,11 @@ #include "OgreGraphicsView.h" #include "OgreGLWidget.h" +#include "CameraInputLayer.h" #include "CommandInterpreter.h" -class MainWindow : public OgreGraphicsView, private Ui::MainWindow +class MainWindow : public OgreGraphicsView, private Ui::MainWindow { Q_OBJECT @@ -50,11 +51,11 @@ void resizeEvent(QResizeEvent *event); private: - QWidget *window; - OgreGLWidget *ogreView; QGraphicsScene *scene; CommandInterpreter *cmdInterp; + + CameraInputLayer *window; }; #endif Modified: rt^3/trunk/src/g3d/OgreGLWidget.cxx =================================================================== --- rt^3/trunk/src/g3d/OgreGLWidget.cxx 2009-07-29 09:52:18 UTC (rev 35364) +++ rt^3/trunk/src/g3d/OgreGLWidget.cxx 2009-07-29 10:48:14 UTC (rev 35365) @@ -59,7 +59,9 @@ _ogreContext(0), _renderWindow(0), _camera(0), _viewport(0), _scene(0), _cameraCtl(new CameraModeBlender) { + // We need to swap carefully to prevent flicker. setAutoBufferSwap(false); + // Take keyboard focus after being clicked setFocusPolicy(Qt::ClickFocus); @@ -84,6 +86,12 @@ } +CameraMode& OgreGLWidget::getCameraMode() const +{ + return *_cameraCtl; +} + + void OgreGLWidget::initializeGL() { Ogre::NameValuePairList params; @@ -215,49 +223,6 @@ } -void OgreGLWidget::keyPressEvent(QKeyEvent *e) -{ - if(!_cameraCtl->injectKeyPressed(e)) { - e->ignore(); - } -} - -void OgreGLWidget::keyReleaseEvent(QKeyEvent *e) -{ - if(!_cameraCtl->injectKeyReleased(e)) { - e->ignore(); - } -} - -void OgreGLWidget::mousePressEvent(QMouseEvent *e) -{ - if(_cameraCtl->injectMousePressed(e)) { - e->ignore(); - } -} - -void OgreGLWidget::mouseReleaseEvent(QMouseEvent *e) -{ - if(!_cameraCtl->injectMouseReleased(e)) { - e->ignore(); - } -} - -void OgreGLWidget::mouseMoveEvent(QMouseEvent *e) -{ - if(!_cameraCtl->injectMouseMotion(e)) { - e->ignore(); - } -} - -void OgreGLWidget::wheelEvent(QWheelEvent *e) -{ - if(!_cameraCtl->injectMouseScrolled((e->delta() > 0) ? CameraMode::POSITIVE : CameraMode::NEGATIVE)) { - e->ignore(); - } -} - - void OgreGLWidget::setProjection(int type) { if(_camera) { Modified: rt^3/trunk/src/g3d/OgreGLWidget.h =================================================================== --- rt^3/trunk/src/g3d/OgreGLWidget.h 2009-07-29 09:52:18 UTC (rev 35364) +++ rt^3/trunk/src/g3d/OgreGLWidget.h 2009-07-29 10:48:14 UTC (rev 35365) @@ -55,11 +55,12 @@ Q_OBJECT friend class OgreGraphicsView; - public: OgreGLWidget(QWidget *parent = NULL); ~OgreGLWidget(); + CameraMode& getCameraMode() const; + public slots: void setProjection(int type); void setCameraMode(int type); @@ -74,13 +75,6 @@ void resizeGL(int, int); void paintGL(); - void keyPressEvent(QKeyEvent *e); - void keyReleaseEvent(QKeyEvent *e); - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void wheelEvent(QWheelEvent *e); - void makeOgreCurrent(); #ifdef Q_WS_X11 Modified: rt^3/trunk/src/g3d/mainwindow.ui =================================================================== --- rt^3/trunk/src/g3d/mainwindow.ui 2009-07-29 09:52:18 UTC (rev 35364) +++ rt^3/trunk/src/g3d/mainwindow.ui 2009-07-29 10:48:14 UTC (rev 35365) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> - <widget class="QWidget" name="mainWindow"> + <widget class="QWidget" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> @@ -18,7 +18,7 @@ <number>9</number> </property> <item> - <widget class="QWidget" name="widget_2" native="true"> + <widget class="QWidget" name="configBar" native="true"> <layout class="QHBoxLayout" name="horizontalLayout"> <property name="margin"> <number>0</number> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits