00001
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
00011
00012
00013
00014
00015
00016
00017 bool Ig3DSystem::s_initialised = false;
00018 std::list<lat::Callback> Ig3DSystem::s_actions;
00019
00020
00021
00022
00023
00024 void
00025 Ig3DSystem::doinit (IgState *state)
00026 {
00027
00028 ASSERT (IgQtAppLoopService::get (state));
00029 IgQtAppLoopService::get(state)->override(lat::CreateCallback(&SoQt::mainLoop));
00030
00031
00032 std::for_each (s_actions.begin (), s_actions.end (),
00033 std::mem_fun_ref (&lat::Callback::operator ()));
00034
00035
00036
00037
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
00046
00047
00048
00049 if (s_initialised)
00050 return;
00051
00052 s_initialised = true;
00053
00054
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
00064
00065
00066 ASSERT (! s_initialised);
00067
00068 s_initialised = true;
00069
00070
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 }