Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGQSceneGraphViewFunctions.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
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 //    static Char8 cvsid_inl[] = OSGQSCENEGRAPHVIEWFUNCTIONS_INLINE_CVSID;
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 //    pSGVThread->kill();
00127 
00128     return true;
00129 }
00130 
00131 OSG_END_NAMESPACE

Generated on Thu Aug 25 04:08:59 2005 for OpenSG by  doxygen 1.4.3