예제 #1
0
void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceWidget* widget, CSVWidget::SceneToolbar* toolbar)
{
    assert(mLayout);

    if (mScene)
    {
        mLayout->removeWidget(mScene);
        mScene->deleteLater();
    }

    if (mToolbar)
    {
        mLayout->removeWidget(mToolbar);
        mToolbar->deleteLater();
    }

    mScene = widget;
    mToolbar = toolbar;

    connect (mScene, SIGNAL (focusToolbarRequest()), mToolbar, SLOT (setFocus()));
    connect (mToolbar, SIGNAL (focusSceneRequest()), mScene, SLOT (setFocus()));

    mLayout->addWidget (mToolbar, 0);
    mLayout->addWidget (mScene, 1);

    mScene->selectDefaultNavigationMode();
    setFocusProxy (mScene);
}
예제 #2
0
SceneWidget::SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget *parent, Qt::WindowFlags f)
    : RenderWidget(parent, f)
    , mResourceSystem(resourceSystem)
    , mLighting(NULL)
    , mHasDefaultAmbient(false)
{
    // we handle lighting manually
    mView->setLightingMode(osgViewer::View::NO_LIGHT);

    setLighting(&mLightingDay);

    mResourceSystem->getSceneManager()->setParticleSystemMask(Mask_ParticleSystem);

    /// \todo make shortcut configurable
    QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut);
    connect (focusToolbar, SIGNAL (activated()), this, SIGNAL (focusToolbarRequest()));
}
예제 #3
0
    SceneWidget::SceneWidget(QWidget *parent)
        : QWidget(parent)
        , mWindow(NULL)
        , mCamera(NULL)
        , mSceneMgr(NULL), mNavigation (0), mLighting (0), mUpdate (false)
        , mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false)
        , mKeyRollLeft (false), mKeyRollRight (false)
        , mFast (false), mDragging (false), mMod1 (false)
        , mFastFactor (4) /// \todo make this configurable
        , mDefaultAmbient (0, 0, 0, 0), mHasDefaultAmbient (false)
    {
        setAttribute(Qt::WA_PaintOnScreen);
        setAttribute(Qt::WA_NoSystemBackground);

        setFocusPolicy (Qt::StrongFocus);

        mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);

        mSceneMgr->setAmbientLight (Ogre::ColourValue (0,0,0,1));

        mCamera = mSceneMgr->createCamera("foo");

        mCamera->setPosition (300, 0, 0);
        mCamera->lookAt (0, 0, 0);
        mCamera->setNearClipDistance (0.1);
        mCamera->setFarClipDistance (300000); ///< \todo make this configurable
        mCamera->roll (Ogre::Degree (90));

        setLighting (&mLightingDay);

        QTimer *timer = new QTimer (this);

        connect (timer, SIGNAL (timeout()), this, SLOT (update()));
        timer->start (20); ///< \todo make this configurable

        /// \todo make shortcut configurable
        QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut);
        connect (focusToolbar, SIGNAL (activated()), this, SIGNAL (focusToolbarRequest()));
    }