Exemplo n.º 1
0
OSGViewWidget::OSGViewWidget( osgViewer::ViewerBase::ThreadingModel threadingModel) : QWidget()
{
	setThreadingModel(threadingModel);
	view = new osgViewer::View;
	// disable the default setting of viewer.done() by pressing Escape.
	setKeyEventSetsDone(0);
	connect( &_timer, SIGNAL(timeout()), this, SLOT(update()) );
	_timer.start( 10 );	
}
Exemplo n.º 2
0
bool SDLViewer::setUpWindow(const char *caption, const ScreenSettings & screenSettings)
{
	setKeyEventSetsDone(0);
	if ( !setUpViewerAsSDLGraphicsWindow(caption, screenSettings) ) return false;
	//if ( !setUpViewerAsOSGGraphicsWindow(caption, screenSettings) ) return false;
	m_eventHandler = new SDLEventHandler();
	addEventHandler( m_eventHandler ); // Our base class has the responsibility to destroy m_eventHandler
	getCamera()->setClearMask(0);
	return true;
}
Exemplo n.º 3
0
GraphModelViewer::GraphModelViewer(osgViewer::ViewerBase::ThreadingModel threadingModel, QWidget *parent, bool autoUpdate) : QWidget(parent)
{
	setThreadingModel(threadingModel);

	// disable the default setting of viewer.done() by pressing Escape.
	setKeyEventSetsDone(0);

	group = new osg::Group();

	QWidget* widget1 = addViewWidget( createGraphicsWindow(0,0,100,100), group );
	QGridLayout* grid = new QGridLayout;
	grid->addWidget(widget1, 0, 0 );
	setLayout(grid);

	connect(&timer, SIGNAL(timeout()), this, SLOT(update()));
	if (autoUpdate)
		connect(&timer, SIGNAL(timeout()), this, SLOT(animateStep()));
	timer.start(10);
}
Exemplo n.º 4
0
CompositeViewer::CompositeViewer()
    : mSimulationTime(0.0)
{
#if QT_VERSION >= 0x050000
    // Qt5 is currently crashing and reporting "Cannot make QOpenGLContext current in a different thread" when the viewer is run multi-threaded, this is regression from Qt4
    osgViewer::ViewerBase::ThreadingModel threadingModel = osgViewer::ViewerBase::SingleThreaded;
#else
    osgViewer::ViewerBase::ThreadingModel threadingModel = osgViewer::ViewerBase::CullDrawThreadPerContext;
#endif

    setThreadingModel(threadingModel);

    // disable the default setting of viewer.done() by pressing Escape.
    setKeyEventSetsDone(0);

    // Only render when the camera position changed, or content flagged dirty
    //setRunFrameScheme(osgViewer::ViewerBase::ON_DEMAND);
    setRunFrameScheme(osgViewer::ViewerBase::CONTINUOUS);

    connect( &mTimer, SIGNAL(timeout()), this, SLOT(update()) );
    mTimer.start( 10 );
}
Exemplo n.º 5
0
  ViewerWidget(QWidget* parent = 0,Qt::WindowFlags f = 0,osgViewer::ViewerBase::ThreadingModel threadingModel=osgViewer::CompositeViewer::SingleThreaded): QWidget(parent,f)
  {
    setThreadingModel(threadingModel);

    // disable the default setting of viewer.done() by pressing Escape.
    setKeyEventSetsDone(0);


    osg::ref_ptr<osg::Node> line = createLine(osg::Vec3(-2,0,2),osg::Vec3(2,0,2));
    osgSim::OverlayNode* overlayNode = new osgSim::OverlayNode(
      osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY);
    overlayNode->setContinuousUpdate(true);
    overlayNode->setOverlaySubgraph(line);
    overlayNode->setOverlayBaseHeight(0.99);
    osg::ref_ptr<osg::Node> cube = osgDB::readNodeFile("cube.osgb");
    overlayNode->addChild(cube);
    osg::ref_ptr<osg::Group> root = new osg::Group;
    root->addChild(overlayNode);
    root->addChild(line);

    QWidget* widget1 = addViewWidget( createGraphicsWindow(0,0,100,100), osgDB::readRefNodeFile("cow.osgt") );
//     QWidget* widget1 = addViewWidget(createGraphicsWindow(0,0,100,100),root);
    QWidget* widget2 = addViewWidget(createGraphicsWindow(0,0,100,100),osgDB::readRefNodeFile("glider.osgt"));
    QWidget* widget3 = addViewWidget(createGraphicsWindow(0,0,100,100),osgDB::readRefNodeFile("axes.osgt"));
    QWidget* widget4 = addViewWidget(createGraphicsWindow(0,0,100,100),osgDB::readRefNodeFile("fountain.osgt"));
    QWidget* popupWidget = addViewWidget(createGraphicsWindow(900,100,320,240,"Popup window",true),osgDB::readRefNodeFile("dumptruck.osgt"));
    popupWidget->show();

    QGridLayout* grid = new QGridLayout;
    grid->addWidget(widget1,0,0);
    grid->addWidget(widget2,0,1);
    grid->addWidget(widget3,1,0);
    grid->addWidget(widget4,1,1);
    setLayout(grid);

    connect(&_timer,SIGNAL(timeout()),this,SLOT(update()));
    _timer.start(10);
  }