00001 #ifndef Impala_Visualization_GUI_TopicExamplePreviewBar_h
00002 #define Impala_Visualization_GUI_TopicExamplePreviewBar_h
00003
00004 #include "Core/Trec/SearchTopic.h"
00005 #include "PreviewBar.h"
00006
00007 namespace Impala {
00008 namespace Visualization {
00009 namespace GUI {
00010
00011 using namespace OglGui;
00012
00013 class TopicExamplePreviewBar : public PreviewBar
00014 {
00015 typedef Core::Trec::SearchTopic SearchTopic;
00016 public:
00017 TopicExamplePreviewBar(OglGui::Window *parent, int w, int h,
00018 SearchTopic *searchTopic, double quality,
00019 bool selected, int thumbW, int thumbH,
00020 double viewScale) :
00021 PreviewBar(parent, w, h, "Examples", quality, selected)
00022 {
00023 Init(searchTopic, w, h, thumbW, thumbH, viewScale);
00024 }
00025
00026 virtual void
00027 ImageSelectionEvent(ImagesWindow *src, int imIndex, void* listenerData)
00028 {
00029 ILOG_DEBUG("ImSelEvent: selected example image " << imIndex);
00030 if (!mListener) return;
00031
00032
00033
00034 mListener->PreviewBarImageClickEvent(this,mName,imIndex,mListenerData);
00035 }
00036
00037 private:
00038 void Init(SearchTopic *searchTopic, int wndW, int wndH,
00039 int thumbW, int thumbH, double viewscale)
00040 {
00041 mSearchTopic = searchTopic;
00042 mPreviewImages = NULL;
00043
00044 if (wndH < thumbH)
00045 viewscale = (wndH-2.0) / thumbH;
00046
00047
00048 if (searchTopic == NULL)
00049 return;
00050
00051 int nrImOnRow = (wndW - 124) / (thumbW * viewscale) + 1;
00052 Window *c = new Window(this, 120, 0, wndW - 124, wndH);
00053
00054
00055
00056 mPreviewImages = new Visualization::ImageSet(c, thumbW, thumbH,
00057 viewscale, nrImOnRow, 1,0);
00058 mPreviewImages->ActivateInfoBox(false);
00059 mPreviewImages->SetImagesListener(this, 0);
00060
00061 for (int i=0; i < mSearchTopic->GetCurTopicNrExamples(); i++)
00062 {
00063 mPreviewImages->
00064 AddImage(mSearchTopic->GetCurTopicImageExample(i,true),"Direct",
00065 mSearchTopic->GetCurTopicExampleName(i),true);
00066 }
00067 }
00068
00069
00070 virtual int GetImageKeyframeID(int rank)
00071 {
00072 if (mSearchTopic == NULL)
00073 return -1;
00074
00075 return -1;
00076 }
00077
00078 SearchTopic *mSearchTopic;
00079
00080 ILOG_VAR_DEC;
00081 };
00082 ILOG_VAR_INIT(TopicExamplePreviewBar, Visualization.GUI);
00083
00084
00085 }
00086 }
00087 }
00088
00089 #endif