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

DossierEntry.h

Go to the documentation of this file.
00001 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00002 #ifndef Impala_Application_IDash_DossierEntry_h
00003 #define Impala_Application_IDash_DossierEntry_h
00004 
00005 #include "OglGui/Window.h"
00006 #include "OglGui/Button.h"
00007 #include "OglGui/TextEdit.h"
00008 #include "Visualization/ImageSet.h"
00009 #include <vector>
00010 
00011 
00012 namespace Impala {
00013 namespace Application {
00014 namespace IDash {
00015 
00016 //using namespace OglGui;
00017 
00018 class DossierEntryTextListener : public OglGui::TextEditListener
00019 {
00020     virtual void TextEditChangedEvent(OglGui::TextEdit *src, void* userData)
00021     {
00022         //printf("Text: %s\n", src->GetText().c_str());
00023     }
00024 };
00025 
00026 class DossierEntry : public OglGui::Window
00027 {
00028 public:
00029     typedef OglGui::Window                          Window;
00030     typedef OglGui::StaticText                      StaticText;
00031     typedef OglGui::Button                          Button;
00032     typedef OglGui::ButtonListener                  ButtonListener;
00033     typedef OglGui::TextEdit                        TextEdit;
00034     typedef Visualization::ImageSet                 ImageSet;
00035 
00036     static const int ENTRY_HEIGHT = 130;
00037 
00038     DossierEntry(Window *parent, TrecEngine *engine,
00039                  ButtonListener *btnListener, int videoID) :
00040         Window(parent,parent->W()-24,ENTRY_HEIGHT,true)
00041     {
00042         mBtnListener = btnListener;
00043         mVideoID = videoID;
00044         mEngine = engine;
00045         InitScreen();
00046     }
00047 
00048     ~DossierEntry()
00049     {
00050         ILOG_DEBUG("Removing DossierEntry " << mVideoID << "...");
00051 /* RvB: 3-2-2009 OGL does automatic cleanup again. Now illegal to delete here
00052         if (mShotImages)
00053             delete mShotImages;
00054 */
00055     }
00056 
00057     int NrOfEntries()
00058     {
00059         return shots.size();
00060     }
00061 
00062     int GetVideoID()
00063     {
00064         return mVideoID;
00065     }
00066 
00067     int FindShot(int s) 
00068     {
00069         for (int i = 0; i < shots.size();i++) {
00070             if (shots[i] == s) return i;
00071         }       
00072         return -1;
00073     }
00074     
00075     
00076     void AddShot(int shotID) 
00077     {
00078         if (FindShot(shotID) == -1) {
00079             shots.push_back(shotID);
00080         }
00081         //show pic
00082         std::ostringstream title;
00083         title << shotID;
00084 
00085         mShotImages->AddImage(mEngine->ThreadSet()->GetImageByShotID(shotID),
00086                               "Direct", title.str(), true);
00087         UpdateText();
00088     }
00089     
00090     void DelShot(int i)
00091     {
00092         int in = FindShot(i);
00093         if (in == -1)
00094             return;
00095         shots.erase(shots.begin() + in);
00096         mShotImages->RemoveImages();
00097         int sz = shots.size();
00098         for (int i=0; i<sz; i++)
00099             AddShot(shots[i]);
00100         UpdateText();
00101     }
00102 
00103     
00104 private:
00105 
00106     Button* RestDiv3Btn(int restW, int i, char *str)
00107     {
00108         return new Button(this, W()-restW+i*restW/3, 4, (restW-30)/3, 20, str);
00109     }
00110 
00111     void UpdateText()
00112     {
00113         std::ostringstream s;
00114         s << "Selected shots: ";
00115         for (int i = 0; i < shots.size();i++)
00116             s << shots[i] << ", ";
00117         s << std::endl;
00118         textEdit->SetText(s.str());
00119     }
00120     
00121     void PrintShots() 
00122     {
00123         for (int i = 0; i < shots.size();i++) {
00124             printf("%d\n", shots[i]);
00125         }
00126     }
00127     
00128     void InitScreen()
00129     {
00130         ILOG_DEBUG("DossierEntry added for video " << mVideoID);
00131         
00132         SetBorderType(0);
00133         SetRoundness(0,15,15,0);
00134         SetBorderType(4);
00135         SetBorderFillShaded(2);
00136         SetBackground(0x88999999);
00137    
00138         // Frank: hier de constructie van een ImageSet:
00139         int     thumbwidth  = 352;
00140         int     thumbheight = 288;
00141         int     nrCols      = 4;
00142         int     nrRows      = 2;
00143         double  scale       = 0.2;
00144 
00145         //set preview window
00146         mShotImages = new ImageSet(this,4,4,thumbwidth,thumbheight,
00147                                    scale,nrCols,nrRows);
00148         // RvB: Does not function to take notes
00149         // Textfield with shot numbers
00150         int previewW = ((double)thumbwidth * scale * nrCols) + 30;
00151         textEdit = new TextEdit(this,8+previewW,28,W()-(20+previewW),
00152                                 ENTRY_HEIGHT-36,"Notes for this video.",2);
00153         textEdit->SetTextEditListener(new DossierEntryTextListener(),0);
00154         std::ostringstream o;
00155         o << "Video: " << mVideoID;
00156         StaticText *title = new StaticText(this,8+previewW,4,120,20,o.str());
00157 
00158         // Command buttons
00159         int restW = W() - (previewW+136);
00160         Button *markcp = RestDiv3Btn(restW,0,"Mark as CP");
00161         Button *remove = RestDiv3Btn(restW,1,"Remove video");
00162         Button *play   = RestDiv3Btn(restW,2,"Play video");
00163         play->SetButtonListener(mBtnListener, 20 + mVideoID);
00164         remove->SetButtonListener(mBtnListener, 2000 + mVideoID);
00165         ScaleChildren();
00166         SetAllowChildScaling(false);
00167     }
00168 
00169     // member variables:
00170     TrecEngine                  *mEngine; // thingy that contains everything(TM)
00171     TextEdit                    *textEdit;
00172     ButtonListener              *mBtnListener;
00173     ImageSet                    *mShotImages;
00174 
00175     // RvB: To be removed
00176     DossierEntryTextListener    *dossierEntryTextListener;
00177 
00178     std::vector<int>            shots;
00179 
00180     int                         mVideoID;
00181 
00182 
00183     ILOG_VAR_DEC;
00184 };
00185 
00186 ILOG_VAR_INIT(DossierEntry, IDash);
00187 }
00188 }
00189 }
00190 
00191 #endif

Generated on Fri Mar 19 09:30:26 2010 for ImpalaSrc by  doxygen 1.5.1