int mainAdapterWidget(QApplication& a, osg::ArgumentParser& arguments) { // load the scene. osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); if (!loadedModel) { std::cout << arguments[0] <<": No data loaded." << std::endl; return 1; } std::cout<<"Using AdapterWidget - QGLWidget subclassed to integrate with osgViewer using its embedded graphics window support."<<std::endl; ViewerQT* viewerWindow = new ViewerQT; viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator); viewerWindow->setSceneData(loadedModel.get()); viewerWindow->show(); a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ); return a.exec(); }
int main( int argc, char **argv ) { QApplication a( argc, argv ); // if (argc<2) { // std::cout << argv[0] <<": requires filename argument." << std::endl; // return 1; // } // osg::ArgumentParser arguments(&argc, argv); // load the scene. // osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); // if (!loadedModel) { // std::cout << argv[0] <<": No data loaded." << std::endl; // return 1; // } osg::ref_ptr<osg::Node> root = new osg::Node; root = createSceneGraph(); ViewerQT* viewerWindow = new ViewerQT; viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator); // viewerWindow->setSceneData(loadedModel.get()); viewerWindow->setSceneData( root.get() ); viewerWindow->show(); a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ); return a.exec(); }
int mainAdapterWidget(QApplication& a, osg::ArgumentParser& arguments) { // load the scene. osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); if (!loadedModel) { std::cerr << arguments[0] << ": No data loaded." << std::endl; std::cout << "usage: " << arguments[0] << " [--mdi] nodefile" << std::endl; return 1; } std::cout << "Using AdapterWidget - QGLWidget subclassed to integrate with " "osgViewer using its embedded graphics window support." << std::endl; if (arguments.read("--mdi")) { std::cout << "Using ViewetQT MDI version" << std::endl; /* Following problems are found here: - miminize causes loaded model to disappear (some problem with Camera matrix? - clampProjectionMatrix is invalid) */ ViewerQT* viewerWindow = new ViewerQT; viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator); viewerWindow->setSceneData(loadedModel.get()); QMainWindow* mw = new QMainWindow(); QMdiArea* mdiArea = new QMdiArea(mw); mw->setCentralWidget(mdiArea); QMdiSubWindow* subWindow = mdiArea->addSubWindow(viewerWindow); subWindow->showMaximized(); subWindow->setWindowTitle("New Window"); mw->show(); } else { ViewerQT* viewerWindow = new ViewerQT; viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator); viewerWindow->setSceneData(loadedModel.get()); viewerWindow->show(); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec(); }
int mainAdapterWidget(QApplication& a, osg::ArgumentParser& arguments) { // load the scene. osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); if (!loadedModel) { std::cout << arguments[0] <<": No data loaded." << std::endl; return 1; } std::cout<<"Using AdapterWidget - QGLWidget subclassed to integrate with osgViewer using its embedded graphics window support."<<std::endl; if (arguments.read("--CompositeViewer")) { CompositeViewerQT* viewerWindow = new CompositeViewerQT; unsigned int width = viewerWindow->width(); unsigned int height = viewerWindow->height(); { osgViewer::View* view1 = new osgViewer::View; view1->getCamera()->setGraphicsContext(viewerWindow->getGraphicsWindow()); view1->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height/2), 1.0, 1000.0); view1->getCamera()->setViewport(new osg::Viewport(0,0,width,height/2)); view1->setCameraManipulator(new osgGA::TrackballManipulator); view1->setSceneData(loadedModel.get()); viewerWindow->addView(view1); } { osgViewer::View* view2 = new osgViewer::View; view2->getCamera()->setGraphicsContext(viewerWindow->getGraphicsWindow()); view2->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height/2), 1.0, 1000.0); view2->getCamera()->setViewport(new osg::Viewport(0,height/2,width,height/2)); view2->setCameraManipulator(new osgGA::TrackballManipulator); view2->setSceneData(loadedModel.get()); viewerWindow->addView(view2); } viewerWindow->show(); } else if (arguments.read("--mdi")) { std::cout<<"Using ViewetQT MDI version"<<std::endl; /* Following problems are found here: - miminize causes loaded model to disappear (some problem with Camera matrix? - clampProjectionMatrix is invalid) */ ViewerQT* viewerWindow = new ViewerQT; viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator); viewerWindow->setSceneData(loadedModel.get()); QMainWindow* mw = new QMainWindow(); QMdiArea* mdiArea = new QMdiArea(mw); mw->setCentralWidget(mdiArea); QMdiSubWindow *subWindow = mdiArea->addSubWindow(viewerWindow); subWindow->showMaximized(); subWindow->setWindowTitle("New Window"); mw->show(); } else { ViewerQT* viewerWindow = new ViewerQT; viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator); viewerWindow->setSceneData(loadedModel.get()); viewerWindow->show(); } a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ); return a.exec(); }