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

SegmentationDocumentGuiKeyframes.h

Go to the documentation of this file.
00001 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00002 #ifndef Impala_Visualization_SegmentationDocumentGuiKeyframes_h
00003 #define Impala_Visualization_SegmentationDocumentGuiKeyframes_h
00004 
00005 #include "Core/VideoSet/SegmentationDocument.h"
00006 #include "Visualization/ImageSet.h"
00007 #include "Visualization/AppControlDoc.h"
00008 #include "Visualization/ImageSetIdxGridScroller.h"
00009 
00010 namespace Impala
00011 {
00012 namespace Visualization
00013 {
00014 
00015 
00016 class SegmentationDocumentGuiKeyframes :
00017         public Window,
00018         public AppControlDoc,
00019         public Core::Database::DataDocumentListener,
00020         public ImageSetIdxGridListener,
00021         public ImagesListener
00022 {
00023 public:
00024     typedef Core::VideoSet::SegmentationDocument SegmentationDocument;
00025 
00026     SegmentationDocumentGuiKeyframes(OglGui::Window* parent,
00027                                      int wndWidth, int wndHeight, int nrImOnRow,
00028                                      int thumbWidth, int thumbHeight,
00029                                      double viewScale,
00030                                      SegmentationDocument* segDoc,
00031                                      int controlId) :
00032         Window(parent, wndWidth, wndHeight, true),
00033         AppControlDoc(controlId, segDoc)
00034     {
00035         Init(parent,nrImOnRow,thumbWidth,thumbHeight,viewScale,segDoc);
00036     }
00037 
00038     SegmentationDocumentGuiKeyframes(OglGui::Window* parent, int x, int y,
00039                                      int wndWidth, int wndHeight, int nrImOnRow,
00040                                      int thumbWidth, int thumbHeight,
00041                                      double viewScale,
00042                                      SegmentationDocument* segDoc,
00043                                      int controlId) :
00044         Window(parent, x, y, wndWidth, wndHeight, true),
00045         AppControlDoc(controlId, segDoc)
00046     {
00047         Init(parent,nrImOnRow,thumbWidth,thumbHeight,viewScale,segDoc);
00048     }
00049 
00050     virtual void
00051     HandleNewFile()
00052     {
00053         Core::VideoSet::Keyframes* keys = mSegDoc->GetKeyframes();
00054         Core::ImageSet::ImageSet* imSet = mSegDoc->GetImSetKeyframes(true);
00055         if (!(mSegDoc->HasCursor() && keys && imSet))
00056         {
00057             mCurFile = -1;
00058             if (mImagesSet)
00059                 mImagesSet->RemoveImages();
00060             if (mImSetIdxGrid)
00061                 mImSetIdxGrid->Clear();
00062             return;
00063         }
00064         int fileId = mSegDoc->CurFileId();
00065         if (fileId == mCurFile)
00066             return;
00067         mCurFile = fileId;
00068         if (mImagesSet)
00069         {
00070             mImagesSet->RemoveImages();
00071             mImagesSet->SetFirstVisY(0, true);
00072         }
00073         if (mImSetIdxGrid)
00074             mImSetIdxGrid->Clear();
00075         mStartKey = keys->GetFirstKeyframeVideo(fileId);
00076         int nrKey = keys->GetNrKeyframesVideo(fileId);
00077         int end = mStartKey + (mImagesSet ? Min(nrKey, 3000) : nrKey);
00078         for (int i=mStartKey ; i<end ; i++)
00079         {
00080             if (mImagesSet)
00081                 mImagesSet->AddImage(i, imSet);
00082             if (mImSetIdxGrid)
00083                 mImSetIdxGrid->AddImageSetIdx(imSet,i);
00084         }
00085         if (mImSetIdxGrid)
00086             mImSetIdxGrid->UpdateLayout(true);
00087     }
00088 
00089     virtual void
00090     ImageSelectionEvent(ImagesWindow* src, int imIndex, void* listenerData)
00091     {
00092         mSegDoc->GotoKeyfr(mStartKey + imIndex);
00093         AllHandleNewCursor(Core::Database::LEVEL_SHOT, false);
00094     }
00095 
00096     virtual void
00097     ImageSelectionEvent(ImageSetIdxGrid* src, int imIndex, void* listenerData)
00098     {
00099         mSegDoc->GotoKeyfr(mStartKey + imIndex);
00100         AllHandleNewCursor(Core::Database::LEVEL_SHOT, false);
00101     }
00102 
00103 private:
00104 
00105     void Init(OglGui::Window* parent, int nrImOnRow, int thumbWidth, int thumbHeight,
00106               double viewScale, SegmentationDocument* segDoc)
00107     {
00108         mSegDoc = segDoc;
00109         mCurFile = -1;
00110         mImagesSet = 0;
00111         mImSetIdxGrid = 0;
00112         AddDocListener(this);
00113 
00114         CmdOptions& options = CmdOptions::GetInstance();
00115 
00116         if (!options.GetBool("keyframesIdxGrid",false))
00117         {
00118             int nrRow = H() / (thumbHeight + 3);
00119             mImagesSet = new ImageSet(this,0,0,thumbWidth, thumbHeight, viewScale,
00120                                       nrImOnRow, nrRow);
00121             mImagesSet->SetDimensions(2,2,parent->W()-4,parent->H()-4);
00122             mImagesSet->ActivateInfoBox(false);
00123             mImagesSet->SetImagesListener(this, 0);
00124         }
00125         else
00126         {
00127             mImSetIdxGridScroller =
00128                 new ImageSetIdxGridScroller(this,2,2,parent->W()-4,
00129                                             parent->H()-4,nrImOnRow);
00130             mImSetIdxGrid = mImSetIdxGridScroller->ImSetIdxGrid();
00131             mImSetIdxGrid->SetImageSetIdxGridListener(this);
00132             //mImSetIdxGrid->ShowNames(false);
00133             mImSetIdxGrid->ShowDims(false);
00134         }
00135     }
00136 
00137     SegmentationDocument*       mSegDoc;
00138     int                         mCurFile;
00139     int                         mStartKey;
00140     ImageSet*                   mImagesSet;
00141     ImageSetIdxGridScroller*    mImSetIdxGridScroller;
00142     ImageSetIdxGrid*            mImSetIdxGrid;
00143 
00144     ILOG_VAR_DEC;
00145 };
00146 
00147 ILOG_VAR_INIT(SegmentationDocumentGuiKeyframes, Visualization);
00148 
00149 } // namespace Visualization
00150 } // namespace Impala
00151 
00152 #endif

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