CMS 3D CMS Logo

Ig3DSystem.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "Iguana/GLBrowsers/interface/Ig3DSystem.h"
00004 #include "Iguana/Studio/interface/IgQtAppLoopService.h"
00005 #include "Iguana/Framework/interface/IgPluginLoader.h"
00006 #include <Inventor/Qt/SoQt.h>
00007 #include <functional>
00008 #include <algorithm>
00009 
00010 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00011 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00012 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00013 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00014 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00015 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00016 
00017 bool                            Ig3DSystem::s_initialised = false;
00018 std::list<lat::Callback>        Ig3DSystem::s_actions;
00019 
00020 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00021 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00022 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00023 
00024 void
00025 Ig3DSystem::doinit (IgState *state)
00026 {
00027     // Override the event loop with SoQt's special filters
00028     ASSERT (IgQtAppLoopService::get (state));
00029     IgQtAppLoopService::get(state)->override(lat::CreateCallback(&SoQt::mainLoop));
00030 
00031     // Run all initialisers already registered
00032     std::for_each (s_actions.begin (), s_actions.end (),
00033                    std::mem_fun_ref (&lat::Callback::operator ()));
00034 
00035     // Autoload OpenInventor nodekit extensions.  Their
00036     // initialisation is global so put them into the global
00037     // (plug-in loader) state.
00038     ASSERT (IgPluginLoader::get (state));
00039     IgPluginLoader::get (state)->load ("Services/Inventor/NodeKits/",true);
00040 }
00041 
00042 void
00043 Ig3DSystem::init (IgState *state, QWidget *mainWindow)
00044 {
00045     // We need to initialise the 3D subsystem properly before using
00046     // it.  This function is that magic initialiser hook.  It is safe
00047     // to invoke this many times, only the first time around counts.
00048 
00049     if (s_initialised)
00050         return;
00051 
00052     s_initialised = true;
00053 
00054     // Initialise SoQt
00055     SoQt::init (mainWindow);
00056     doinit (state);
00057 }
00058 
00059 QWidget *
00060 Ig3DSystem::init (IgState *state, int argc, char **argv,
00061                   const char *appname, const char *classname)
00062 {
00063     // We need to initialise the 3D subsystem properly before using
00064     // it.  This function is that magic initialiser hook.  It is safe
00065     // to invoke this many times, only the first time around counts.
00066     ASSERT (! s_initialised);
00067 
00068     s_initialised = true;
00069 
00070     // Initialise SoQt
00071     QWidget *w = SoQt::init (argc, argv, appname, classname);
00072     doinit (state);
00073     return w;
00074 }
00075 
00076 void
00077 Ig3DSystem::initAction (lat::Callback action)
00078 {
00079     if (! s_initialised)
00080         s_actions.push_back (action);
00081     else
00082         action ();
00083 }

Generated on Tue Jun 9 17:38:37 2009 for CMSSW by  doxygen 1.5.4