예제 #1
0
   OSGGraphicsWindowQt::OSGGraphicsWindowQt(osg::GraphicsContext::Traits* traits,
                                             GLWidgetFactory* factory,
                                             OSGAdapterWidget* adapter)
   : BaseClass()
   , mValid(false)
   , mRealized(false)
   , mCloseRequested(false)
   , mQWidget(NULL)
   , mCursorShape(Qt::ArrowCursor)
   {

      _traits = traits;

      setWindowRectangle(0, 0, traits->width, traits->height);

      QGLWidget* sharedContextWidget = NULL;
      if (traits->sharedContext != NULL)
      {
         OSGGraphicsWindowQt* sharedWin = dynamic_cast<OSGGraphicsWindowQt*>(traits->sharedContext);
         if (sharedWin != NULL)
         {
            sharedContextWidget = sharedWin->GetQGLWidget();
         }
         else
         {
            LOG_ERROR("A shared context was specified, but it is not a QGLWidget based context, so it can't be shared.");
         }
      }

      if (adapter == NULL)
      {
         AdapterCreator* creator = new AdapterCreator(this, *traits, sharedContextWidget, factory);

         if(QCoreApplication::instance()->thread() != QThread::currentThread())
         {
            creator->moveToThread(QCoreApplication::instance()->thread());
            QMetaObject::invokeMethod(creator, "Create", Qt::BlockingQueuedConnection);
            OSGAdapterWidget* w = creator->GetAdapter();
            SetQGLWidget(w);
         }
         else
         {
            creator->Create();
            SetQGLWidget(creator->GetAdapter());
         }

         delete creator;

      }
      else
      {
         adapter->SetGraphicsWindow(*this);
         adapter->setFocusPolicy(Qt::StrongFocus);
         SetQGLWidget(adapter);
      }

   }
예제 #2
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
FrameWindow::FrameWindow(const Core::Rectangle& rect, Window* aParent,
                        const std::string& aText) :
    Window(aParent, aText),
    clientWindow_(0),
    captureCount_(0),
    isMovable_(false),
    renderDesc_(0)
{
    // set the geometry
    setWindowRectangle(rect);

    mouseListener_ = new FrameWindowMouseListener(*this);
    addMessageListener(mouseListener_);
}