00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef Impala_Application_IDash_ScreenBrowser_h
00014 #define Impala_Application_IDash_ScreenBrowser_h
00015
00016 #include "ScreenBase.h"
00017
00018 #include "OglGui/RadioGroup.h"
00019 #include "OglGui/CheckBox.h"
00020 #include "OglGui/SixButtonCross.h"
00021 #include "Visualization/RotorBrowser/RotorBrowserGUI.h"
00022 #include "Visualization/GUI/ShotDetailSidebar.h"
00023
00024 namespace OglGui {
00026
00027 class AnimWindowListener : public OglGui::WindowListener
00028 {
00029 virtual void
00030 WindowMouseEvent(OglGui::Window *src, int msg, int but, int state,
00031 int x, int y, void *userData )
00032 {
00033 if (msg==oglMouseDown)
00034 src->SetVisible(false);
00035 }
00036 };
00038
00039
00040 class AnimButtonListener : public ButtonListener
00041 {
00042 virtual void ButtonSelectionEvent(Button* src, void* userData)
00043 {
00044 Window* animWnd = (Window*) userData;
00045 animWnd->SetVisible(!animWnd->GetVisible());
00046 if (animWnd->GetVisible())
00047 oglFocusWnd = animWnd->GetOGLWND();
00048 }
00049 };
00050 }
00051
00052 namespace Impala {
00053 namespace Application {
00054 namespace IDash {
00055
00056
00057 #ifndef VisRotorBrowser
00058 #define VisRotorBrowser Visualization::RotorBrowser
00059 #endif
00060
00061 class ScreenBrowser : public ScreenBase,
00062 public VisRotorBrowser::RotorBrowserListener,
00063 public Visualization::GUI::ShotDetailSidebarListener,
00064 public OglGui::RadioGroupListener
00065 {
00066
00067 public:
00068 typedef VisRotorBrowser::RotorBrowserGUI RotorBrowserGUI;
00069 typedef VisRotorBrowser::RotorBrowserContext RotorBrowserContext;
00070 typedef VisRotorBrowser::RotorBrowser RotorBrowser;
00071 typedef Visualization::AppController AppController;
00072 typedef Visualization::GUI::ShotDetailSidebar ShotDetailSidebar;
00073
00074 typedef OglGui::Window Window;
00075 typedef OglGui::Strut Strut;
00076 typedef OglGui::Button Button;
00077 typedef OglGui::CheckBox CheckBox;
00078 typedef OglGui::StaticText StaticText;
00079 typedef OglGui::RadioGroup RadioGroup;
00080
00081 ScreenBrowser(int width, int height, int controlId=-1,
00082 bool enableQueryPane=false) :
00083 ScreenBase(width, height)
00084 {
00085 InitScreen(controlId,enableQueryPane);
00086 }
00087
00088 ScreenBrowser(Window *parent, int width, int height, int controlId=-1,
00089 bool enableQueryPane=false) :
00090 ScreenBase(parent, width, height)
00091 {
00092 InitScreen(controlId,enableQueryPane);
00093 }
00094
00095 ScreenBrowser(Window *parent, int controlId=-1,
00096 bool enableQueryPane=false) :
00097 ScreenBase(parent)
00098 {
00099 InitScreen(controlId,enableQueryPane);
00100 }
00101
00102 RotorBrowser* Browser()
00103 {
00104 return mRotorBrowserGUI->Browser();
00105 }
00106
00107 void HandleStillAnimation()
00108 {
00109 bool playVideo = mCenterVideoCheckBox->GetSelected();
00110 int stillMode = Browser()->AutoStills();
00111
00112 if (stillMode==RotorBrowser::STILLS_NONE)
00113 playVideo = false;
00114 Browser()->EnableCenterVideoStills(playVideo);
00115
00116 if (stillMode != RotorBrowser::STILLS_NONE)
00117 Browser()->StartStills();
00118 }
00119
00120
00121 virtual void
00122 ContextMoveEvent(Window* src, int direction, int position)
00123 {
00124 ILOG_DEBUG("ContextMoveEvent: direction=" << direction
00125 << " position=" << position);
00126 mShotDetails->Update();
00127 }
00128
00129 virtual void
00130 ContextChangeEvent(Window* src, RotorBrowserContext *newcontext)
00131 {
00132 ILOG_DEBUG("ContextChangeEvent: newcontext=" << newcontext->GetName());
00133 }
00134
00135 virtual void
00136 BookmarkEvent(Window* src, int shotid, bool isbookmarked)
00137 {
00138 ILOG_DEBUG("BookmarkEvent(" << shotid << ", " << isbookmarked << ")");
00139 mAppControlDoc->AllHandleBookmarkEvent(shotid, isbookmarked);
00140 if (isbookmarked)
00141 mAppControlDoc->AllHandleAddedBookmark();
00142 else
00143 mAppControlDoc->AllHandleRemovedBookmark();
00144 ILOG_DEBUG("BookmarkEvent(" << shotid << ", " << isbookmarked << ")");
00145 }
00146
00147
00148
00149 virtual void
00150 DoInitialQuery()
00151 {
00152 ILOG_SYSTEM("DoInitialQuery: showing all movies");
00153 ButtonSelectionEvent(0, (void*) BTN_SHOWALLMOVIES);
00154 }
00155
00156 virtual void
00157 DoConceptQuery(std::list<std::string> queryconcepts)
00158 {
00159 ILOG_SYSTEM("DoConceptQuery: " << queryconcepts.size()
00160 << " concepts in query.");
00161 mQueryComponents = queryconcepts;
00162 DoQuery();
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 virtual void DisplayFunc()
00174 {
00175 Window::DisplayFunc();
00176 int stillMode = Browser()->AutoStills();
00177 mRadioAutoStills->SetActiveRadio(stillMode-1);
00178 HandleStillAnimation();
00179 }
00180
00181 private:
00182
00183 void AddBtn(Window *w, char *text, int width=80, int userData=0)
00184 {
00185 Button *b = new Button(w,width,32,text,BEV_ETCHED,true);
00186 b->SetButtonListener(this, userData);
00187 }
00188
00189 void AddRadioBtn(RadioGroup *wnd, char *text, int w)
00190 {
00191 Button *b = new Button(wnd, w, 22, text,1,true);
00192 wnd->Add(b);
00193 }
00194
00195 void
00196 DoQueryPane(Window *w)
00197 {
00198 SetAsBox(w);
00199 }
00200
00201 Window* StillsAnimationControl(Window* wnd, int x, int y, int w, int h)
00202 {
00203 mRadioAutoStills = new RadioGroup(wnd,x,y,w,h);
00204 mRadioAutoStills->SetRadioListener(this,RADIOGROUP_AUTOSTILLS);
00205 (new StaticText(mRadioAutoStills,4,h-20,140,20,"Stills animation:"))
00206 ->SetAlign(oglLeftAlign);
00207 new StaticText(mRadioAutoStills,w-230,h-20,60,18,"Delay:");
00208
00209 (new Button(mRadioAutoStills,w-170,h-20,20,18,"-",BEV_ETCHED,true))
00210 ->SetButtonListener(this,BTN_STILL_DELAY_MIN);
00211 (new Button(mRadioAutoStills,w-150,h-20,20,18,"+",BEV_ETCHED,true))
00212 ->SetButtonListener(this,BTN_STILL_DELAY_PLUS);
00213 mCenterVideoCheckBox = new CheckBox(mRadioAutoStills,w-120,h-20,
00214 116,20,"VideoCenter",false);
00215
00216 new Strut(mRadioAutoStills,1000,h-32);
00217 int btnW = (w-25) / 5;
00218 AddRadioBtn(mRadioAutoStills,"None",btnW);
00219 AddRadioBtn(mRadioAutoStills,"Center",btnW);
00220 AddRadioBtn(mRadioAutoStills,"Local",btnW);
00221 AddRadioBtn(mRadioAutoStills,"Active",btnW);
00222 AddRadioBtn(mRadioAutoStills,"All",btnW);
00223 mRadioAutoStills->RepositionViewports();
00224 mRadioAutoStills->ScaleChildren(0,1);
00225 mRadioAutoStills->SetAllowChildScaling(false);
00226 return mRadioAutoStills;
00227 }
00228
00229 void
00230 DoControlsPane(Window *wnd)
00231 {
00232 SetAsBox(wnd,false);
00233
00234 StillsAnimationControl(wnd,0,0,380,wnd->H());
00235
00236 new Strut(wnd, 4000, 2);
00237 new Strut(wnd, 400, 2);
00238
00239 AddBtn(wnd, "All movies", 100, BTN_SHOWALLMOVIES);
00240 AddBtn(wnd, "Bookmark", 100, BTN_BOOKMARK);
00241 AddBtn(wnd, "UnBookmark", 100, BTN_UNBOOKMARK);
00242
00243 new Strut(wnd, 20, 2);
00244 AddBtn(wnd, "Toggle similarity", 140, BTN_SHOWSIMILARITY);
00245
00246 if (!CmdOptions::GetInstance().GetBool("MNAnimation"))
00247 (CreateLogos(wnd, wnd->W()-342, 0))->ConnectTo(wnd,OglGui::TORIGHT);
00248
00249 wnd->RepositionViewports();
00250 wnd->ScaleChildren();
00251 wnd->SetAllowChildScaling(false);
00252 }
00253
00254
00255 void DoQuery()
00256 {
00257 ILOG_SYSTEM("Performing IDASH query...");
00258 if (mQueryComponents.size() == 0)
00259 {
00260 ILOG_SYSTEM("Nothing selected. Showing all movies.");
00261 ShowAllMovies();
00262 return;
00263 }
00264 Engine()->PerformQuery(mQueryComponents);
00265 mRotorBrowserGUI->SetBrowseMode(RotorBrowser::MODE_CROSSBROWSER);
00266 mRotorBrowserGUI->ResetRanking();
00267 }
00268
00269 void AddComponent(std::string qomponent)
00270 {
00271 std::list<std::string>::iterator i =
00272 std::find(mQueryComponents.begin(), mQueryComponents.end(), qomponent);
00273 if (i == mQueryComponents.end())
00274 {
00275 ILOG_DEBUG("Query - adding: " << qomponent);
00276 mQueryComponents.push_back(qomponent);
00277 }
00278 }
00279
00280 void RemoveComponent(std::string qomponent)
00281 {
00282 std::list<std::string>::iterator i =
00283 std::find(mQueryComponents.begin(), mQueryComponents.end(), qomponent);
00284 if (i != mQueryComponents.end())
00285 {
00286 ILOG_DEBUG("Query - removing: " << qomponent);
00287 mQueryComponents.erase(i);
00288 }
00289 }
00290
00291 void ShowAllMovies()
00292 {
00293 mRotorBrowserGUI->SetInitialQueryToMovies();
00294 mRotorBrowserGUI->ResetRanking();
00295 mRotorBrowserGUI->SetBrowseMode(RotorBrowser::MODE_CROSSBROWSER);
00296 }
00297
00298
00299 virtual void ButtonSelectionEvent(Button *src, void* vData)
00300 {
00301 int userData = (int) (long long) vData;
00302 switch (userData)
00303 {
00304 case BTN_CROSS+0: mRotorBrowserGUI->PressKey('e'); break;
00305 case BTN_CROSS+1: mRotorBrowserGUI->PressKey('q'); break;
00306 case BTN_CROSS+2: mRotorBrowserGUI->PressKey('a'); break;
00307 case BTN_CROSS+3: mRotorBrowserGUI->PressKey('d'); break;
00308 case BTN_CROSS+4: mRotorBrowserGUI->PressKey('w'); break;
00309 case BTN_CROSS+5: mRotorBrowserGUI->PressKey('s'); break;
00310
00311 case BTN_STILL_DELAY_MIN: mRotorBrowserGUI->PressKey('='); break;
00312 case BTN_STILL_DELAY_PLUS: mRotorBrowserGUI->PressKey('-'); break;
00313
00314 case BTN_SHOWALLMOVIES:
00315 ILOG_USER("BTN: show all movies");
00316 ShowAllMovies();
00317 break;
00318
00319 case BTN_BOOKMARK: mRotorBrowserGUI->PressKey(' '); break;
00320 case BTN_UNBOOKMARK: mRotorBrowserGUI->PressKey('x'); break;
00321
00322 case BTN_SHOWSIMILARITY:
00323 ILOG_USER("BTN: show similarity");
00324 bool mode = !mShotDetails->GetShowSimilarity();
00325 mShotDetails->SetShowSimilarity(mode);
00326 mShotDetails->Update();
00327 break;
00328 }
00329 mRotorBrowserGUI->FocusToBrowser();
00330 }
00331
00332 virtual void OnRadioChange(RadioGroup *src, int button, void* data)
00333 {
00334 mRotorBrowserGUI->FocusToBrowser();
00335 Browser()->AutoStills(button+1);
00336 }
00337
00338 virtual void QueryVisualEvent(std::string visname, int keyframe)
00339 {
00340 ILOG_DEBUG("QueryVisualEvent for " << visname <<
00341 " (keyframe " << keyframe << ")");
00342 Engine()->PerformVisualQuery(visname, keyframe);
00343 mRotorBrowserGUI->ResetCrossBrowser();
00344 mRotorBrowserGUI->ResetRanking();
00345 mRotorBrowserGUI->FocusToBrowser();
00346 mShotDetails->Update();
00347 }
00348
00349 virtual void
00350 QueryByRegionEvent(int keyframe, float x, float y, float w, float h)
00351 {
00352 ILOG_DEBUG("QueryByRegionEvent for " << keyframe);
00353 mRotorBrowserGUI->DoQueryByRegion(keyframe, x, y, w, h);
00354 }
00355
00356
00357 void InitScreen(int controlId, bool enableQueryPane)
00358 {
00359 ILOG_DEBUG("constructing screen Browser");
00360 SetControlId(controlId);
00361 mEnableQueryPane = enableQueryPane;
00362
00363 int queryH = 100;
00364 int controlsH = 50;
00365 int sideW = Engine()->ImWidth() + 40;
00366
00367
00368 #ifdef AS_TODS_BROWSER
00369 mEnableQueryPane = false;
00370 #endif
00371 if (mEnableQueryPane)
00372 {
00373 mQueryPane = new Window(this,2,H()-queryH-2,W()-4,queryH);
00374 DoQueryPane(mQueryPane);
00375
00376 mQueryPane->ConnectTo(this, OglGui::TOTOP|OglGui::TOLEFTRIGHT);
00377 }
00378 else
00379 {
00380 mQueryPane = 0;
00381 queryH = 0;
00382 }
00383
00384
00385 int browseH = H()-controlsH-queryH-(queryH > 0 ? 8 : 6);
00386 int browseW = W()-sideW-6;
00387 mBrowserPane = new Window(this,2,controlsH+4,browseW,browseH);
00388 SetAsBox(mBrowserPane,false);
00389
00390 bool enableMinimap = CmdOptions::GetInstance().GetBool("enableMinimap");
00391
00392 mRotorBrowserGUI =
00393 new RotorBrowserGUI(mBrowserPane,browseW,browseH,
00394 Engine()->ThreadSet(),
00395 Engine()->SegmentationDocument(),
00396 Engine()->ImWidth(),Engine()->ImHeight(),
00397 Engine()->ImScale(),controlId,false,
00398 enableMinimap);
00399
00400 Browser()->SetRoundness(0,0,0,0);
00401 mRotorBrowserGUI->ScaleChildren();
00402 mRotorBrowserGUI->ConnectTo(mBrowserPane);
00403 mRotorBrowserGUI->AddRotorBrowserListener(this);
00404 mBrowserPane->ConnectTo(this);
00405 AppController::Instance().AddControl(mRotorBrowserGUI);
00406 Visualization::RotorBrowser::RotorView::SetSpeedFactor(3.2);
00407
00408 mRotorBrowserGUI->SetShowMinimap(true);
00409
00410
00411 mDetailPane = new Window(this,W()-sideW-2,controlsH+4,sideW,browseH);
00412 SetAsBox(mDetailPane,false);
00413
00414 mShotDetails =
00415 new ShotDetailSidebar(mDetailPane,0,0,mDetailPane->W(),
00416 mDetailPane->H(),Engine()->ImWidth(),
00417 Engine()->ImHeight(),Engine()->ThreadSet(),
00418 Engine()->SegmentationDocument());
00419 mShotDetails->ConnectTo(mDetailPane);
00420 mShotDetails->SetListener(this);
00421
00422
00423 mShotDetails->SetShowSimilarity(true);
00424
00425
00426 mDetailPane->ConnectTo(this, OglGui::TORIGHT|OglGui::TOTOPBOTTOM);
00427
00428
00429 mControlPane = new Window(this,2,2,W()-4,controlsH);
00430 DoControlsPane(mControlPane);
00431 mControlPane->ConnectTo(this, OglGui::TOLEFTRIGHT|OglGui::TOBOTTOM);
00432
00433
00434 if (CmdOptions::GetInstance().GetBool("MNAnimation"))
00435 LogoAnimation();
00436
00437
00438 OglGui::SixButtonCross* sixBtnCross =
00439 new OglGui::SixButtonCross(this,4,controlsH+4,200,200);
00440 sixBtnCross->SetTexts("Last","First","Left","Right","Up","Down");
00441 for (int i=0 ; i<6 ; i++)
00442 {
00443 OglGui::Button* btn = sixBtnCross->Btn(i);
00444 btn->SetButtonListener(this,(void*)(BTN_CROSS+i));
00445 }
00446 }
00447
00448 void LogoAnimation()
00449 {
00451
00452
00453
00454
00455
00456 OGLWND* oglWnd = oglSys.CreateOGLViewPort(mOglWnd,0,50,W(),H()-50);
00457 MNAnimFuncs(oglWnd);
00458 OglGui::Window* animWnd = new OglGui::Window(oglWnd);
00459 mAnimWnd = animWnd;
00460 animWnd->SetVisible(false);
00461 animWnd->ConnectTo(this);
00462 animWnd->SetWindowListener(new OglGui::AnimWindowListener());
00463
00464 Button *animButton = new Button(this,W()-342,2,340,50,"",4,true);
00465
00466 animButton->ConnectTo(this,OglGui::TORIGHT|OglGui::TOBOTTOM);
00467 animButton->SetButtonListener(new OglGui::AnimButtonListener(),
00468 (void*)animWnd);
00469
00470 Window* logoWnd = CreateLogos(animButton,0, 0);
00471 logoWnd->SetNoMouseInput();
00472 logoWnd->ConnectTo(animButton);
00473
00475 }
00476
00477 bool mEnableQueryPane;
00478
00479 Window* mAnimWnd;
00480 Window* mBrowserPane;
00481 Window* mQueryPane;
00482 Window* mDetailPane;
00483 Window* mControlPane;
00484
00485 RadioGroup* mRadioAutoStills;
00486 CheckBox* mCenterVideoCheckBox;
00487
00488 RotorBrowserGUI* mRotorBrowserGUI;
00489 ShotDetailSidebar* mShotDetails;
00490
00491 std::list<std::string> mQueryComponents;
00492
00493
00494
00495 const static int BTN_SHOWALLMOVIES = 2;
00496 const static int BTN_CROSS = 100;
00497 const static int BTN_BOOKMARK = 110;
00498 const static int BTN_UNBOOKMARK = 111;
00499 const static int BTN_SHOWSIMILARITY = 112;
00500 const static int RADIOGROUP_AUTOSTILLS = 113;
00501 const static int BTN_STILL_DELAY_MIN = 114;
00502 const static int BTN_STILL_DELAY_PLUS = 115;
00503
00504 ILOG_VAR_DEC;
00505 };
00506
00507 ILOG_VAR_INIT(ScreenBrowser, Application.IDash);
00508 }
00509 }
00510 }
00511 #endif