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

ConceptPreviewBar.h

Go to the documentation of this file.
00001 #ifndef Impala_Visualization_GUI_ConceptPreviewBar_h
00002 #define Impala_Visualization_GUI_ConceptPreviewBar_h
00003 
00004 #include "PreviewBar.h"
00005 #include "Core/Trec/ThreadSet.h"
00006 #include "Basis/CmdOptions.h"
00007 #include "Basis/ILog.h"
00008 
00009 namespace Impala {
00010 namespace Visualization {
00011 namespace GUI {
00012 
00013 //using namespace OglGui;
00014 //using namespace Core::Trec;
00015 
00016 class ConceptPreviewBar : public PreviewBar
00017 {
00018 public:
00019     typedef Core::Trec::Thread                  Thread;
00020     typedef Core::Trec::ThreadSet               ThreadSet;
00021 
00022     ConceptPreviewBar(OglGui::Window *parent, int w, int h, String concept,
00023                       ThreadSet *threadset, double quality, bool selected,
00024                       int thumbW, int thumbH, double viewscale) :
00025         PreviewBar(parent, w, h, concept, quality, selected)
00026     {
00027         Init(threadset, thumbW, thumbH, viewscale);
00028     }
00029 
00030 private:
00031     void Init(ThreadSet *threadset, int thumbW, int thumbH, double viewscale)
00032     {
00033         int wndW = WndWidth();
00034         int wndH = WndHeight();
00035 
00036         if (wndH < thumbH) // H smaller than thumbH, adjusting scale to fit
00037             viewscale = (wndH-2) / (double)thumbH;
00038 
00039         mThread    = NULL;
00040         mThreadSet = threadset;
00041         mMaxImages = CmdOptions::GetInstance().GetInt("maxImagesOnRow");
00042 
00043         // images:
00044         if (threadset == NULL)
00045         {
00046             mPreviewImages = NULL;
00047             return;
00048         }
00049 
00050         int nrImOnRow = (wndW - 174) / (thumbW * viewscale) + 1;
00051         if (nrImOnRow > mMaxImages)
00052             nrImOnRow = mMaxImages;
00053 
00054         Window *c      = new Window(this, 170, 0, wndW - 174, wndH);
00055         mPreviewImages = new Visualization::ImageSet(c, thumbW, thumbH,
00056                                                      viewscale,nrImOnRow,1,0);
00057         mPreviewImages->ActivateInfoBox(false);
00058         mPreviewImages->SetImagesListener(this, 0);
00059 
00060         // 1. find the Thread using the "concept" name
00061         //    TODO: make this less hardcoded.
00062         Thread *t = NULL;
00063         for (int i=0; i < threadset->GetNrThreads(); i++)
00064         {
00065             if (threadset->GetThread(i)->GetName() == String("rank_") + mName)
00066             {
00067                 t = threadset->GetThread(i);
00068                 break;
00069             }
00070         }
00071 
00072         ILOG_DEBUG("finding " << mName << " thread=" << t);
00073 
00074         // 2. show one row of images
00075         if (t != NULL)
00076         {
00077             int firstShot = t->GetFirstShot();
00078             for (int i=0; i<nrImOnRow; i++)
00079             {
00080                 int shot = t->GetShotAt(firstShot, i);
00081                 if (shot < 0)
00082                     break;
00083                 // shot name is not interesting for end users, but if you need
00084                 // it: threadset->GetShotName(shot)
00085                 mPreviewImages->AddImage(threadset->GetImageByShotID(shot),
00086                                          "Direct", "", true);
00087             }
00088             mThread = t;
00089         }
00090         else
00091         {
00092             ILOG_WARN("Could not find thread for concept '" << mName << "'");
00093         }
00094     }
00095 
00096     virtual int GetImageKeyframeID(int rank)
00097     {
00098         if (mThread == NULL)
00099             return -1;
00100 
00101         int shot = mThread->GetShotAt(mThread->GetFirstShot(), rank);
00102         return mThreadSet->GetShotRKF(shot);
00103     }
00104 
00105     Thread*     mThread;
00106     ThreadSet*  mThreadSet;
00107     int         mMaxImages;
00108 
00109     ILOG_VAR_DEC;
00110 };
00111 
00112 ILOG_VAR_INIT(ConceptPreviewBar, Visualization.GUI);
00113 
00114 } // GUI
00115 } // Visualization
00116 } // Impala
00117 
00118 #endif

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