00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef Impala_Application_IDash_ScreenDossier_h
00014 #define Impala_Application_IDash_ScreenDossier_h
00015
00016 #include "ScreenBase.h"
00017 #include "DossierEntry.h"
00018 #include "DossierListener.h"
00019 #include "OglGui/ScrollWnd.h"
00020 #include <list>
00021
00022 namespace Impala {
00023 namespace Application {
00024 namespace IDash {
00025
00026
00027
00028 class ScreenDossier : public ScreenBase
00029 {
00030 public:
00031 typedef OglGui::Window Window;
00032 typedef OglGui::StaticText StaticText;
00033 typedef OglGui::Button Button;
00034 typedef OglGui::ScrollWnd ScrollWnd;
00035
00036 ScreenDossier(int width, int height) :
00037 ScreenBase(width, height)
00038 {
00039 InitScreen(width, height);
00040 }
00041
00042 ScreenDossier(Window *parent, int width, int height) :
00043 ScreenBase(parent, width, height)
00044 {
00045 InitScreen(width,height);
00046 }
00047
00048 ScreenDossier(Window *parent) :
00049 ScreenBase(parent)
00050 {
00051 InitScreen(parent->W(), parent->H());
00052 }
00053
00054
00055
00056 virtual void HandleBookmarkEvent(int shotid, bool isSelected)
00057 {
00058 ILOG_DEBUG("HandleBookmarkEvent(" << shotid << ":" << isSelected << ")");
00059 if (isSelected) {
00060 AddShot(shotid);
00061 } else {
00062 DelShot(shotid);
00063 }
00064 }
00065
00066
00067 void AddDossierListener(DossierListener *l)
00068 {
00069 mListeners.push_back(l);
00070 }
00071
00072 private:
00073
00074 void PlayFile(int videoID) {
00075 for (int i=0; i<mListeners.size();i++)
00076 mListeners[i]->PlayFileEvent(videoID);
00077 }
00078
00079 void AddShot(int shotID)
00080 {
00081 ILOG_DEBUG("AddShot(" << shotID <<"): ");
00082
00083
00084 int videoID =
00085 Engine()->ThreadSet()->GetSegmentation()->GetVideoId(shotID);
00086 ILOG_DEBUG("video = " << videoID);
00087 std::string name =
00088 Engine()->ThreadSet()->GetSegmentation()->GetName(shotID);
00089 ILOG_DEBUG("Name: " << name);
00090
00091
00092 DossierEntry *d = FindVideo(videoID);
00093
00094 if (!d)
00095 d = AddVideo(videoID);
00096
00097 d->AddShot(shotID);
00098 UpdateScene();
00099 }
00100
00101 void DelShot(int shotID)
00102 {
00103 int videoID =
00104 Engine()->ThreadSet()->GetSegmentation()->GetVideoId(shotID);
00105
00106 DossierEntry *d = FindVideo(videoID);
00107 if (!d)
00108 return;
00109 d->DelShot(shotID);
00110 if (d->NrOfEntries() == 0)
00111 DelVideo(videoID);
00112 UpdateScene();
00113 }
00114
00115
00116 DossierEntry* FindVideo(int s)
00117 {
00118 std::list<DossierEntry*>::iterator i;
00119 for (i = videos.begin(); i != videos.end(); ++i) {
00120 if ((*i)->GetVideoID() == s) {
00121 return *i;
00122 }
00123 }
00124 return 0;
00125 }
00126
00127 DossierEntry* AddVideo(int videoID)
00128 {
00129 ILOG_DEBUG("AddVideo(" << videoID <<"): ");
00130 if (FindVideo(videoID))
00131 return 0;
00132
00133 int yPos = (videos.size() + 1) * (DossierEntry::ENTRY_HEIGHT + 5);
00134
00135 Window* pane = mScrollWnd->ContentPane();
00136 DossierEntry* entry = new DossierEntry(pane,Engine(),this,videoID);
00137 entry->ConnectTo(mScrollWnd,OglGui::TOLEFTRIGHT);
00138 pane->RepositionViewports();
00139
00140 videos.push_back(entry);
00141
00142 return entry;
00143 }
00144
00145 void DelVideo(int v)
00146 {
00147 ILOG_DEBUG("DelVideo(" << v <<")");
00148 std::list<DossierEntry*>::iterator i;
00149 for (i = videos.begin(); i != videos.end(); ++i) {
00150 if ((*i)->GetVideoID() == v) {
00151 delete *i;
00152 videos.erase(i);
00153 mScrollWnd->ContentPane()->RepositionViewports();
00154 break;
00155 }
00156 }
00157 }
00158
00159 void EmptyDossier()
00160 {
00161 std::list<DossierEntry*>::iterator i;
00162 for (i = videos.begin(); i != videos.end(); ++i)
00163 delete *i;
00164 videos.clear();
00165 mScrollWnd->VerticalScrollBar()->SetValue(0);
00166 }
00167
00168
00169
00170
00171 virtual void
00172 ButtonSelectionEvent(Button *src, void* vData)
00173 {
00174 int userData = (long long) vData;
00175 if (userData >= 2000) {
00176
00177 ILOG_USER("BTN: remove video from dossier for VideoID = "
00178 << userData - 2000);
00179 DelVideo(userData - 2000);
00180 }
00181 else if (userData >= 20) {
00182
00183 ILOG_USER("BTN: play video for VideoID = " << userData - 20);
00184 PlayFile(userData - 20);
00185 }
00186 else if (userData == BTN_EMPTYDOSSIER)
00187 {
00188 ILOG_USER("BTN: empty dossier");
00189 EmptyDossier();
00190 }
00191 }
00192
00193 void InitScreen(int w, int h)
00194 {
00195
00196 ILOG_DEBUG("constructing screen Dossier");
00197
00198 int startheight = 30;
00199 Window *titlebar = new Window(this,0,h-startheight-16,w,36);
00200 SetAsBox(titlebar,false);
00201 titlebar->SetBackground(0x99eeaaaa);
00202
00203 titlebar->ConnectTo(this,OglGui::TOLEFTRIGHT|OglGui::TOTOP);
00204
00205 StaticText* txt = new StaticText(titlebar,8,8,200,20,"Evidence found:");
00206 txt->SetAlign(oglLeftAlign);
00207
00208 Button* emptyDossier =
00209 new Button(titlebar,w-200,8,180,20,"Empty Dossier");
00210 emptyDossier->SetButtonListener(this, BTN_EMPTYDOSSIER);
00211 emptyDossier->ConnectTo(this,OglGui::TORIGHT);
00212
00213
00214 mScrollWnd = new ScrollWnd(this,0,0,w,h-startheight-16,true,0,1);
00215 mScrollWnd->ContentPane()->SetDimensions(0,0,w-16,4000);
00216 mScrollWnd->ConnectTo(this);
00217 SetAsBox(mScrollWnd,false);
00218
00219
00220 SetAllowChildScaling(false);
00221 }
00222
00223 void DoScrollWindow(Window *w)
00224 {
00225 mScrollWnd = new ScrollWnd(w, w->W()-6,w->H(),true,0,1);
00226 mScrollWnd->ContentPane()->SetDimensions(0,0,w->W()-6,4000);
00227 mScrollWnd->ConnectTo(w);
00228 }
00229
00230
00231 const static int BTN_EMPTYDOSSIER = 1;
00232
00233
00234 ScrollWnd *mScrollWnd;
00235
00236 std::list<DossierEntry*> videos;
00237 std::vector<DossierListener*> mListeners;
00238
00239 ILOG_VAR_DEC;
00240 };
00241
00242 ILOG_VAR_INIT(ScreenDossier, IDash);
00243
00244 }
00245 }
00246 }
00247 #endif