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
00014
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)
00037 viewscale = (wndH-2) / (double)thumbH;
00038
00039 mThread = NULL;
00040 mThreadSet = threadset;
00041 mMaxImages = CmdOptions::GetInstance().GetInt("maxImagesOnRow");
00042
00043
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
00061
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
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
00084
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 }
00115 }
00116 }
00117
00118 #endif