Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

Sys.h

Go to the documentation of this file.
00001 // RvB: Not created by me!!!!
00002 // RvB: I am not a fan of this construction.
00003 // There should be no need to circumvent OGL's own mainLoop: OglEventLoop.
00004 // Only extra functionality is the construction to close all windows when
00005 // 1 window is closed. This should be implemented within OGL C rather then here.
00006 // Used by Impala::Visualization::AppController, which causes a lot of headaches
00007 // Unfortunately all of Impala::Visualization is build upon the AppController.
00008 #ifndef OglGui_Sys_h
00009 #define OglGui_Sys_h
00010 
00011 extern "C" {
00012 #ifndef OGLVIEW2D_H
00013 #include "Link/OGL/OGLView2D.h"
00014 #endif
00015 
00016 #ifndef OGLVIEW3D_H
00017 #include "Link/OGL/OGLView3D.h"
00018 #endif
00019 
00020 #ifndef OGLBORDERS_H
00021 #include "Link/OGL/OGLBorders.h"
00022 #endif
00023 
00024 void        OGLStart(OGLWND *oglWnd);
00025 int         OglRegister();
00026 LIST        *CreateThreadWndList(int* nWnd);
00027 void        OglEventLoop();
00028 void        OglWindowManage(LIST* threadWndList, int* nWnd);
00029 OGLWND      *Navigate2DChild(OGLWND *parent, OGLWND *target2D,
00030                              int x, int y, int w, int h);
00031 void        MNAnimFuncs(OGLWND *oglWnd);
00032 void        WoggelFuncs(OGLWND *oglWnd);
00033 void        GroupRotateFuncs(OGLWND *oglWnd);
00034 OGLWND*     GroupRotateChild(OGLWND *parent, int x, int y, int w, int h);
00035 OGLVIEW3D*  ImToGroupRotate( OGLWND *oglWnd, OGLIMAGE *oglIm,
00036                                         float x, float y, float z,
00037                                         float w, float h, float d );
00038 
00039 void        MyStart2DFuncs(OGLWND *oglWnd);
00040 void        MyStart3DFuncs(OGLWND *oglWnd);
00041 }
00042 
00043 namespace OglGui
00044 {
00045 
00046 class Sys
00047 {
00048 public:
00049 
00050     virtual ~Sys()
00051     {
00052     }
00053 
00054     static Sys&
00055     Instance()
00056     {
00057         return sSystem;
00058     }
00059 
00060     void
00061     SetCloseOneWndIsCloseAll(bool mode)
00062     {
00063         mCloseOneWndIsCloseAll = mode;
00064     }
00065 
00066     void
00067     Start(OGLWND* oglWnd)
00068     {
00069         OGLStart(oglWnd);
00070         if (mThreadWndList)
00071             S_FreeList(mThreadWndList, NULL);
00072         mThreadWndList = CreateThreadWndList(&mNrWnd);
00073         mNrWndMax = mNrWnd;
00074     }
00075 
00076     // based on oglEventLoop in OGL/Window.c
00077     int
00078     WindowManage(int done = 0)
00079     {
00080         int nWndOld = mNrWnd;
00081         OglWindowManage(mThreadWndList, &mNrWnd);
00082         if (nWndOld != mNrWnd)
00083         {
00084             S_FreeList(mThreadWndList, NULL);
00085             mThreadWndList = CreateThreadWndList(&mNrWnd);
00086             if (mNrWnd > mNrWndMax)
00087                 mNrWndMax = mNrWnd;
00088         }
00089         // RvB: QUESTION: WHY HAS NEXT LINE BEEN CHANGED
00090         // ANSWER: NEEDED WHEN CLOSING 1 WINDOW SHOULD CLOSE ALL
00091         // Moet instelbaar worden. Hier in Sys
00092         // ******
00093         // RvB: Gedaan, maar werkt om een of andere reden niet meer!!!!
00094         // Alternatief is om hier de threadWndList te doorlopen en
00095         // alle Top oglWnd te exitten. Dit lijkt wel te werken
00096         if ((mNrWnd < mNrWndMax) && mCloseOneWndIsCloseAll){
00097             LIST    *obj;
00098             OGLWND  *oglWnd;
00099             ForAllElements(obj, mThreadWndList){
00100                         oglWnd = (OGLWND *) obj->info;
00101                 oglSys.MakeCurrent(oglWnd);
00102                 // wglMakeCurrent(oglWnd->hDC, (HGLRC) oglWnd->hRC);
00103                 oglSys.ExitWindow(oglWnd, 0);
00104             }
00105             done = 1;
00106         }
00107         else if (mNrWnd == 0)
00108             done = 1;
00109         return done;
00110     }
00111 
00112     virtual int
00113     MainLoop()
00114     {
00115         bool done = false;
00116         while (!done)
00117         {
00118             done = (WindowManage() == 1);
00119         }
00120 
00121 #if !defined(OGL_USING_GLUT) && defined(WIN32)
00122         while(oglWndList)
00123             Sleep(300);
00124 #endif
00125 
00126         return 1;
00127     }
00128 
00129 
00130 private:
00131 
00132     Sys()
00133     {
00134         mNrWnd = 0;
00135         mNrWndMax = 0;
00136         mThreadWndList = 0;
00137         mCloseOneWndIsCloseAll = true;
00138         if (!OglRegister())
00139         {
00140             fprintf(stderr, "OglRegister failed\n");
00141             return;
00142         }
00143     }
00144 
00145     Sys(const Sys&)
00146     {
00147     }
00148 
00149     Sys&
00150     operator=(const Sys&);
00151 
00152     // private data:
00153 
00154     int            mNrWnd;
00155     int            mNrWndMax;
00156     LIST*          mThreadWndList;
00157     bool           mCloseOneWndIsCloseAll;
00158     static Sys     sSystem;
00159 };
00160 
00161 } // namespace OglGui
00162 
00163 #endif

Generated on Fri Mar 19 09:31:39 2010 for ImpalaSrc by  doxygen 1.5.1