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

CameraEventList.h

Go to the documentation of this file.
00001 /*
00002 12345678901234567890123456789012345678901234567890123456789012345678901234567890
00003 */
00004 // Author: Richard van Balen
00005 
00006 #ifndef Impala_Application_SDash_CameraEventList_h
00007 #define Impala_Application_SDash_CameraEventList_h
00008 
00009 #ifndef Impala_Application_SDash_CameraEventButton_h
00010 #include "Application/SDash/CameraEventButton.h"
00011 #endif
00012 
00013 #ifndef OglGui_DropDownWindow_h
00014 #include "OglGui/DropDownWindow.h"
00015 #endif
00016 
00017 namespace Impala {
00018 namespace Application {
00019 namespace SDash {
00020 
00021 class CameraEventList : public OglGui::DropDownWindow,
00022                         public OglGui::ButtonListener
00023 {
00024 typedef OglGui::Window                                  Window;
00025 typedef OglGui::Button                                  Button;
00026 typedef OglGui::DropDownWindow                          DropDownWindow;
00027 typedef Impala::Application::SDash::CameraEvent         CameraEvent;
00028 typedef Impala::Application::SDash::CameraEventButton   CameraEventButton;
00029 
00030 public:
00031     CameraEventList(Window* parent, int w, int h, strconst str) :
00032         DropDownWindow(parent,w,h,str,0)
00033     {
00034         Init();
00035     }
00036     CameraEventList(Window* parent, int x, int y, int w, int h, strconst str) :
00037         DropDownWindow(parent,x,y,w,h,str,0)
00038     {
00039         Init();
00040     }
00041 
00042     void SetButtonListener(ButtonListener* li, void* userData=0)
00043     {
00044         mBtnListener = li;
00045         mBtnListenerData = userData;
00046     }
00047 
00048     void AddCameraEvent(const CameraEvent* cameraEvent)
00049     {
00050         static int cnt = 0;
00051         CameraEventButton* camEventButton =
00052             new CameraEventButton(this,-2,0,800,23,cameraEvent);
00053         camEventButton->SetButtonListener(this);
00054         camEventButton->SetVisible(IsVisible(camEventButton));
00055         mCameraEventButtons.push_back(camEventButton);
00056         AddWindow(camEventButton, 0, 0);
00057     }
00058 
00059     void SelectTopCameraEvent()
00060     {
00061         for (int i = mCameraEventButtons.size()-1; i >= 0; i--)
00062         {
00063             CameraEventButton* btn = mCameraEventButtons[i];
00064             if (IsVisible(btn))
00065             {
00066                 btn->DoButtonSelectionEvent();
00067                 return;
00068             }
00069         }
00070 
00071         // no visible events; hide video player
00072         mBtnListener->ButtonSelectionEvent(0, mBtnListenerData);
00073     }
00074 
00075     void SelectCameraEvent(CameraEvent* cameraEvent)
00076     {
00077         for (int i = 0; i < mCameraEventButtons.size(); i++)
00078         {
00079             CameraEventButton& btn = *(mCameraEventButtons[i]);
00080             if (IsVisible(&btn)
00081                 && btn.CameraId() == cameraEvent->CameraId()
00082                 && btn.FrameNr() == cameraEvent->FrameNr()
00083                 && btn.Seconds() == cameraEvent->Seconds() )
00084 
00085                 btn.DoButtonSelectionEvent();
00086         }
00087     }
00088 
00089     void DiscardCurrent(bool mode=true)
00090     {
00091         if (mCurrentButton)
00092         {
00093             mCurrentButton->SetState(mode ? 0 : 1);
00094             if (mHideDiscarded)
00095             {
00096                 HideDiscarded(true);
00097             }
00098         }
00099     }
00100 
00101     void RemoveEvents()
00102     {
00103         for (int i=0 ; i<mCameraEventButtons.size() ; i++)
00104             delete mCameraEventButtons[i];
00105         mCameraEventButtons.clear();
00106         mCurrentButton = 0;
00107     }
00108 
00109     bool IsVisible(CameraEventButton* btn)
00110     {
00111         return ( (mCurrentCamera == -1 || mCurrentCamera == btn->CameraId()) 
00112             && (!mHideDiscarded || btn->GetState()) );
00113     }
00114 
00115     void ShowCameraWithId(int id)
00116     {
00117         mCurrentCamera = id;
00118         for (int i=0; i<mCameraEventButtons.size(); i++)
00119             mCameraEventButtons[i]->SetVisible(IsVisible(mCameraEventButtons[i]));
00120     }
00121 
00122     void ShowAllCameras()
00123     {
00124         mCurrentCamera = -1;
00125         for (int i=0; i<mCameraEventButtons.size(); i++)
00126         {
00127             bool mode = true;
00128             if (mHideDiscarded && !mCameraEventButtons[i]->GetState())
00129                 mode = false;
00130             mCameraEventButtons[i]->SetVisible(mode);
00131         }
00132     }
00133 
00134     void HideDiscarded(bool mode)
00135     {
00136         mHideDiscarded = mode;
00137         if (mCurrentCamera == -1)
00138             ShowAllCameras();
00139         else
00140             ShowCameraWithId(mCurrentCamera);
00141     }
00142 
00143     // responds to event buttons
00144     virtual void ButtonSelectionEvent(Button *src, void* userData)
00145     {
00146         if (mCurrentButton)
00147             mCurrentButton->SetSelected(false);
00148         src->SetSelected(true);
00149         mCurrentButton = (CameraEventButton*) src;
00150 
00151         if (mBtnListener)
00152             mBtnListener->ButtonSelectionEvent(mCurrentButton,mBtnListenerData);
00153     }
00154 
00155 private:
00156     void Init()
00157     {
00158         SetBorderType(BEV_ETCHED);
00159         mCurrentButton = 0;
00160         mCurrentCamera = -1;
00161         mBtnListener = 0;
00162         mHideDiscarded = false;
00163         Spacing(-1);
00164     }
00165 
00166     std::vector<CameraEventButton*>     mCameraEventButtons;
00167     CameraEventButton*                  mCurrentButton;
00168 
00169     ButtonListener*                     mBtnListener;
00170     void*                               mBtnListenerData;
00171 
00172     int  mCurrentCamera;
00173     bool mHideDiscarded;
00174 };
00175 
00176 }
00177 }
00178 }
00179 #endif

Generated on Fri Mar 19 09:30:37 2010 for ImpalaSrc by  doxygen 1.5.1