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

CameraMoveControl.h

Go to the documentation of this file.
00001 #ifndef OglGui_CameraMoveControl_h
00002 #define OglGui_CameraMoveControl_h
00003 
00004 #ifndef OglGui_CrossControl_h
00005 #include "OglGui/CrossControl.h"
00006 #endif
00007 
00008 namespace OglGui
00009 {
00010 
00011 class CameraMoveControl : public CrossControl, WindowListener
00012 {
00013 public:
00014 
00015     CameraMoveControl(int x, int y, int w, int h, Window* targetWnd=0) :
00016         CrossControl(x,y,w,h, targetWnd, CAMMOVE_FW, "Move Cam",true)
00017         {
00018                 Init(w, h, targetWnd);
00019         }
00020 
00021     CameraMoveControl(Window *parent, int w, int h, Window* targetWnd=0) :
00022         CrossControl(parent,w,h, targetWnd, CAMMOVE_FW, "Move Cam", true)
00023         {
00024                 Init(w, h, targetWnd);
00025         }
00026 
00027     CameraMoveControl(Window *parent, int x, int y, int w, int h,
00028                       Window* targetWnd=0) :
00029         CrossControl(parent,x,y,w,h,targetWnd,CAMMOVE_FW,"Move Cam",true)
00030         {
00031                 Init(w, h, targetWnd);
00032         }
00033 
00034     enum {
00035         CAMMOVE_FW,
00036         CAMMOVE_BW,
00037         CAMMOVE_LEFT,
00038         CAMMOVE_RIGHT,
00039         CAMMOVE_UP,
00040         CAMMOVE_DOWN
00041     };
00042 
00043 // Listeners
00044 
00045     virtual void
00046     ButtonSelectionEvent(Button *src, void* userData)
00047     {
00048         if (!mTargetWnd)
00049             return;
00050         OGLWND* oglWnd = mTargetWnd->GetOGLWND();
00051         if (userData == (void*)CAMMOVE_FW)
00052             view3DSys.KeyFunc(oglWnd, mCamMove?oglPAGEUP:oglPAGEDOWN, 0);
00053         if (userData == (void*)CAMMOVE_BW)
00054             view3DSys.KeyFunc(oglWnd, mCamMove?oglPAGEDOWN:oglPAGEUP, 0);
00055         if (userData == (void*)CAMMOVE_LEFT)
00056             view3DSys.KeyFunc(oglWnd, mCamMove?oglLEFT:oglRIGHT, 0);
00057         if (userData == (void*)CAMMOVE_RIGHT)
00058             view3DSys.KeyFunc(oglWnd, mCamMove?oglRIGHT:oglLEFT, 0);
00059         if (userData == (void*)CAMMOVE_UP)
00060             view3DSys.KeyFunc(oglWnd, mCamMove?oglUP:oglDOWN, 0);
00061         if (userData == (void*)CAMMOVE_DOWN)
00062             view3DSys.KeyFunc(oglWnd, mCamMove?oglDOWN:oglUP, 0);
00063 
00064         if (src==mResetButton)
00065             view3DSys.KeyFunc(oglWnd, oglHOME, 0);
00066     }
00067 
00068     virtual void
00069     WindowMouseEvent(Window *src, int msg, int but, int state,
00070                      int x, int y, void* listenerData)
00071     {
00072         if (src==mButtonGroup && msg == oglMouseDblClick)
00073             mCamMove = !mCamMove;
00074     }
00075 
00076     virtual void
00077     SetTargetWindow(Window* targetWnd)
00078     {
00079         CrossControl::SetTargetWindow(targetWnd);
00080         mCamModelInitialized = false;
00081     }
00082 
00083     virtual void
00084     DisplayFunc()
00085     {
00086         char        buf[30];
00087             SCENE3D*    cam;
00088         
00089         if (mTargetWnd && mTargetWnd->GetOGLWND())
00090         {
00091             cam = (SCENE3D *) mTargetWnd->GetOGLWND()->sceneInfo;
00092             if (!mCamModelInitialized)
00093             {
00094                 cam->moveModel = DIR_MOVE;
00095                 cam->rotateModel = CAM_ROT;
00096                 mCamModelInitialized = true;
00097             }
00098             sprintf(buf, "%s %s", mCamMove ? "Move Cam" : "Move Scene",
00099                                   (cam->moveModel==GRID_MOVE) ? "(#)" : "(*)");
00100             mButtonGroup->SetText(buf);
00101         }
00102         Window::DisplayFunc();
00103     }
00104 
00105 private:
00106     bool            mCamModelInitialized;
00107     bool            mCamMove; // If false scene movement
00108 
00109         void Init(int w, int h, Window* targetWnd)
00110         {
00111         SetTargetWindow(targetWnd);
00112         mCamMove = true;
00113         mCamModelInitialized = false;
00114         mButtonGroup->SetWindowListener(this);
00115         }
00116 };
00117 
00118 } // namespace OglGui
00119 
00120 #endif

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