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

SegmentationDocumentGuiMain.h

Go to the documentation of this file.
00001 #ifndef Impala_Visualization_SegmentationDocumentGuiMain_h
00002 #define Impala_Visualization_SegmentationDocumentGuiMain_h
00003 
00004 #include "Visualization/ImageStrip.h"
00005 #include "Visualization/ImageSet.h"
00006 #include "OglGui/TextField.h"
00007 #include "OglGui/TextArea.h"
00008 #include "OglGui/Strut.h"
00009 #include "OglGui/Button.h"
00010 #include "Visualization/LogoWindow.h"
00011 #include "Visualization/DataDocumentGui.h"
00012 #include "Core/VideoSet/SegmentationDocument.h"
00013 #include "Core/VideoSet/PlayShot.h"
00014 
00015 namespace Impala
00016 {
00017 namespace Visualization
00018 {
00019 
00020 
00021 class SegmentationDocumentGuiMain :
00022         public DataDocumentGui<Core::VideoSet::SegmentationDocument>,
00023         public ImagesListener, public OglGui::ViewListener
00024 {
00025     static const int PLAY = 100;
00026 
00027     static const int IM_BOOKMARKED = 1;
00028     static const int IM_CURRENT = 2;
00029     static const int IM_RETRIEVED = 3;
00030     static const int IM_CROSS = 4;
00031 
00032 public:
00033 
00034     typedef Core::VideoSet::SegmentationDocument SegmentationDocument;
00035     typedef Core::Array::Array2dVec3UInt8 Array2dVec3UInt8;
00036 
00037     SegmentationDocumentGuiMain(OglGui::Window* parent,
00038                                 int wndWidth, int wndHeight,
00039                                 int nrImOnRow, int imWidth, int imHeight,
00040                                 double viewScale, bool showAnno,
00041                                 SegmentationDocument* segDoc,
00042                                 Array2dVec3UInt8* logoIm, bool logoAnim,
00043                                 int controlId) :
00044         DataDocumentGui<SegmentationDocument>(parent, wndWidth, wndHeight,
00045                                               segDoc, controlId, showAnno,
00046                                               showAnno, false, 1, 6, showAnno,
00047                                               showAnno)
00048     {
00049         mSegDoc = segDoc;
00050 
00051         int line = 20;
00052         mBookmarkedImages = new ImageStrip(this, imWidth, imHeight,
00053                                                 viewScale, nrImOnRow);
00054         mBookmarkedImages->SetImagesListener(this, IM_BOOKMARKED);
00055         mBookmarkedImages->ActivateInfoBox(false);
00056 
00057         mCurrentShotStrip = 0;
00058         if (logoAnim || logoIm)
00059         {
00060             mCurrentShotStrip = new ImageStrip(this, imWidth, imHeight,
00061                                                viewScale, nrImOnRow-1);
00062             new LogoWindow(this, logoIm, logoAnim, 190, 170);
00063         }
00064         else
00065         {
00066             mCurrentShotStrip = new ImageStrip(this, imWidth, imHeight,
00067                                                viewScale, nrImOnRow);
00068         }
00069         mCurrentShotStrip->SetImagesListener(this, IM_CURRENT);
00070         mCurrentShotStrip->SetMakeViewWithRect(true);
00071         mCurrentShotStrip->SetViewListener(this);
00072         mCurrentShotStrip->ActivateInfoBox(false);
00073         //mCurrentShotText = new OglGui::TextArea(this, wndWidth-20, 3*line, "");
00074 
00075         // buttons
00076         OglGui::Button* but;
00077         OglGui::Strut* strut = new OglGui::Strut(this, 4000, 1);
00078 
00079         OglGui::TextArea* tArea = new OglGui::TextArea(this, 80, line,
00080                                                        "Current shot");
00081         tArea->SetBorderType(0);
00082         but = new OglGui::Button(this, 100, 22, "Play");
00083         but->SetButtonListener(this, PLAY);
00084         if (!showAnno)
00085         {
00086             but = new OglGui::Button(this, 150, 22, "Bookmark (b)");
00087             but->SetButtonListener(this, BUT_BOOKMARK);
00088             but = new OglGui::Button(this, 170, 22, "Unbookmark (B)");
00089             but->SetButtonListener(this, BUT_UNBOOKMARK);
00090         }
00091 
00092         strut = new OglGui::Strut(this, 4000, 1);
00093 
00094         mRetrievedImages = new ImageSet(this, imWidth, imHeight, viewScale,
00095                                         nrImOnRow, 3);
00096         mRetrievedImages->SetImagesListener(this, IM_RETRIEVED);
00097         mRetrievedImages->ActivateInfoBox(false);
00098     }
00099 
00100     virtual void
00101     HandleNewFile()
00102     {
00103         DataDocumentGui<SegmentationDocument>::HandleNewFile();
00104         HandleNewShot();
00105     }
00106 
00107     virtual void
00108     HandleNewShot()
00109     {
00110         mCurrentShotStrip->ReplaceImages(mSegDoc->CurKeyframes(),
00111                                          mSegDoc->GetImSetKeyframes(true));
00112         Core::Geometry::Rectangle r = mSegDoc->GetRectThumb();
00113         for (int i=0 ; i<mCurrentShotStrip->NrViewers() ; i++)
00114             mCurrentShotStrip->GetViewWithRect(i)->SetRect(r);
00115         //mCurrentShotText->SetText(mSegDoc->CurShotText());
00116     }
00117 
00118     virtual void
00119     HandleNewBookmarked()
00120     {
00121         DataDocumentGui<SegmentationDocument>::HandleNewBookmarked();
00122         mBookmarkedImages->ReplaceImages(mSegDoc->GetBookmarkedIds(),
00123                                          mSegDoc->GetImSetKeyframes(true));
00124     }
00125 
00126     virtual void
00127     HandleAddedBookmark()
00128     {
00129         mBookmarkedImages->AddImage(mSegDoc->CurKeyfr(),
00130                                     mSegDoc->GetImSetKeyframes(true));
00131         DataDocumentGui<SegmentationDocument>::HandleNewBookmarked(); // has no Added
00132     }
00133 
00134     virtual void
00135     HandleCursorBookmarked()
00136     {
00137         DataDocumentGui<SegmentationDocument>::HandleCursorBookmarked();
00138         mBookmarkedImages->SetImageSelected(mSegDoc->CurBookmark());
00139     }
00140 
00141     virtual void
00142     HandleNewRetrieved()
00143     {
00144         /*
00145         int firstVisY = mRetrievedImages->GetFirstVisY();
00146         mRetrievedImages->ReplaceImages(mSegDoc->GetRetrieved(),
00147                                            mSegDoc->GetImSetKeyframes(true));
00148         mRetrievedImages->SetFirstVisY(0, true);
00149         */
00150     }
00151 
00152     virtual void
00153     ImageSelectionEvent(ImagesWindow* src, int imIndex, void* vData)
00154     {
00155         int listenerData = (int)(long long) vData;
00156         switch (listenerData)
00157         {
00158         case IM_BOOKMARKED:
00159             mSegDoc->CursorToBookmark(imIndex);
00160             AllHandleNewCursor(Core::Database::LEVEL_SHOT, true);
00161             break;
00162         case IM_CURRENT:
00163             mSegDoc->GotoShotKeyfr(imIndex);
00164             break;
00165         case IM_RETRIEVED:
00166             //mSegDoc->GotoKeyfr(mSegDoc->GetRetrieved()->GetId(imIndex));
00167             //AllHandleNewCursor(Core::Database::LEVEL_SHOT, false);
00168             break;
00169         }
00170     }
00171 
00172     virtual void
00173     OnViewMouse(OglGui::View* view, int msg, int btn, int state,
00174                 float x, float y)
00175     {
00176         ViewWithRect* viewR = (ViewWithRect*) view;
00177         Core::Geometry::Rectangle r = viewR->GetRect();
00178         mSegDoc->SetRectThumb(r);
00179     }
00180 
00181     virtual void
00182     ButtonSelectionEvent(OglGui::Button* src, void* vData)
00183     {
00184         int listenerData = (long long) vData;
00185         DataDocumentGui<SegmentationDocument>::ButtonSelectionEvent(src, vData);
00186         switch (listenerData)
00187         {
00188         case PLAY:
00189             if (! mSegDoc->HasCurShot())
00190                 break;
00191             Core::VideoSet::PlayShot(mSegDoc->GetSegmentation(),
00192                                      mSegDoc->CurShot());
00193             break;
00194         } // end switch
00195     }
00196 
00197 private:
00198 
00199     SegmentationDocument* mSegDoc;
00200 
00201     ImageStrip*       mBookmarkedImages;
00202     ImageStrip*       mCurrentShotStrip;
00203     //OglGui::TextArea* mCurrentShotText;
00204     ImageSet*         mRetrievedImages;
00205 
00206 };
00207 
00208 } // namespace Visualization
00209 } // namespace Impala
00210 
00211 #endif

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