00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "OSGQSceneGraphViewFunctions.h"
00040
00041 #include "OSGQSceneGraphView_qt.h"
00042
00043 #include <OSGLog.h>
00044 #include <OSGThread.h>
00045
00046 #include <qapplication.h>
00047
00048 OSG_BEGIN_NAMESPACE
00049
00050 #ifdef __sgi
00051 #pragma set woff 1174
00052 #endif
00053
00054 namespace
00055 {
00056 static Char8 cvsid_cpp[] = "@(#)$Id: OSGQSceneGraphViewFunctions.cpp,v 1.1 2003/05/07 14:03:40 neumannc Exp $";
00057 static Char8 cvsid_hpp[] = OSGQSCENEGRAPHVIEWFUNCTIONS_HEADER_CVSID;
00058
00059 }
00060
00061 #ifdef __sgi
00062 #pragma reset woff 1174
00063 #endif
00064
00065 void sceneGraphViewThreadFunc(void *pThreadArg)
00066 {
00067 NodePtr pRootNode = *(reinterpret_cast<NodePtr *>(pThreadArg));
00068
00069 int argc = 0;
00070 char **argv = NULL;
00071 bool bOwnQTApp = false;
00072 QApplication *pOwnQTApp = NULL;
00073
00074 if(qApp == NULL)
00075 {
00076 bOwnQTApp = true;
00077 pOwnQTApp = new QApplication(argc, argv);
00078 }
00079
00080 QSceneGraphView *pSGView = new QSceneGraphView(NULL, "pSGView");
00081
00082 pSGView->setRoot(pRootNode);
00083 pSGView->show ( );
00084
00085 if(bOwnQTApp)
00086 pOwnQTApp->exec();
00087 }
00088
00089 bool startSceneGraphViewThread(NodePtr &pRootNode)
00090 {
00091 Thread *pSGVThread = Thread::find("osg::SceneGraphViewThread");
00092
00093 if(pSGVThread != NULL)
00094 {
00095 FWARNING(("startSceneGraphViewThread: thread already running.\n"));
00096
00097 return false;
00098 }
00099
00100 pSGVThread = Thread::get("osg::SceneGraphViewThread");
00101
00102 if(pSGVThread == NULL)
00103 {
00104 FFATAL(("startSceneGraphViewThread: could not create thread."));
00105
00106 return false;
00107 }
00108
00109 return pSGVThread->runFunction(&sceneGraphViewThreadFunc,
00110 0, (void *) &pRootNode );
00111 }
00112
00113 bool stopSceneGraphViewThread(void)
00114 {
00115 Thread *pSGVThread = Thread::find("osg::SceneGraphViewThread");
00116
00117 if(pSGVThread == NULL)
00118 {
00119 FFATAL(("stopSceneGraphViewThread: could not find thread."));
00120
00121 return false;
00122 }
00123
00124 qApp->quit();
00125
00126
00127
00128 return true;
00129 }
00130
00131 OSG_END_NAMESPACE