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

VxsDocumentGuiPlay.h

Go to the documentation of this file.
00001 #ifndef Impala_Visualization_VxsDocumentGuiPlay_h
00002 #define Impala_Visualization_VxsDocumentGuiPlay_h
00003 
00004 #include "Visualization/DataDocumentGui.h"
00005 #include "OglGui/CheckBox.h"
00006 #include "Visualization/VideoNav.h"
00007 #include "Core/VideoSet/VxsDocument.h"
00008 
00009 namespace Impala
00010 {
00011 namespace Visualization
00012 {
00013 
00014 
00015 class VxsDocumentGuiPlay : public DataDocumentGui<Core::VideoSet::VxsDocument>,
00016                            public OglGui::CheckBoxListener,
00017                            public OglGui::ViewListener,
00018                            public VideoNavListener
00019 {
00020 public:
00021     typedef Core::VideoSet::VxsDocument VxsDocument;
00022 
00023     static const int SETBEGIN = 1;
00024     static const int GOTOBEGIN = 2;
00025     static const int SETEND = 3;
00026     static const int GOTOEND = 4;
00027 
00028     VxsDocumentGuiPlay(OglGui::Window* parent, int wndWidth, int wndHeight,
00029                        int imWidth, int imHeight, bool showAnno,
00030                        VxsDocument* vxsDoc, int controlId,
00031                        double viewScale = 1.0) :
00032         DataDocumentGui<VxsDocument>(parent, wndWidth, wndHeight, vxsDoc,
00033                                      controlId, showAnno, showAnno, false,
00034                                      1, 6, showAnno, showAnno)
00035     {
00036         mVxsDoc = vxsDoc;
00037         mViewScale = viewScale;
00038 
00039         mBeginText = 0;
00040         if (showAnno)
00041         {
00042             new OglGui::Strut(this, wndWidth, 1);
00043             int line = 22;
00044             OglGui::Button* but;
00045             mBeginText = new OglGui::TextArea(this, 200, line,
00046                                               "Marked frame begin");
00047             but = new OglGui::Button(this, 80, line, "Set (D)");
00048             but->SetButtonListener(this, SETBEGIN);
00049             but = new OglGui::Button(this, 80, line, "Goto (d)");
00050             but->SetButtonListener(this, GOTOBEGIN);
00051             new OglGui::Strut(this, 50, 1);
00052             mEndText = new OglGui::TextArea(this, 200, line,
00053                                             "Marked frame end");
00054             but = new OglGui::Button(this, 80, line, "Set (E)");
00055             but->SetButtonListener(this, SETEND);
00056             but = new OglGui::Button(this, 80, line, "Goto (e)");
00057             but->SetButtonListener(this, GOTOEND);
00058         }
00059 
00060         new OglGui::Strut(this, wndWidth, 1);
00061         int line = 22;
00062         mCheckBoxFBM = new OglGui::CheckBox(this, 150, line,
00063                                             "Frame between marked");
00064         mCheckBoxFBM->SetSelected(true);
00065         mCheckBoxFBM->SetCheckBoxListener(this, 0);
00066 
00067         new OglGui::Strut(this, wndWidth, 1);
00068         mVideoNav = new VideoNav(this, imWidth, imHeight, mViewScale);
00069         mVideoNav->SetVideoNavListener(this);
00070     }
00071 
00072     virtual void
00073     HandleActivate()
00074     {
00075         mVxsDoc->SetFrameNavBetweenMarked(mCheckBoxFBM->GetSelected());
00076         //AppControlDoc::HandleActivate();
00077         HandleNewFile();
00078         DataDocumentGui<VxsDocument>::HandleNewBookmarked();
00079     }
00080 
00081     virtual void
00082     HandleNewFile()
00083     {
00084         DataDocumentGui<VxsDocument>::HandleNewFile();
00085         mVideoNav->ChangeSrc(mVxsDoc->CurVideo());
00086         HandleNewFrame();
00087     }
00088 
00089     virtual void
00090     HandleNewFrame()
00091     {
00092         Core::Stream::RgbDataSrc* src = mVxsDoc->CurVideo();
00093         if (src)
00094         {
00095             mVideoNav->UpdateView(0, src->DataPtr(), src->FrameWidth(),
00096                                   src->FrameHeight(), mViewScale, this);
00097             mVideoNav->SetRect(mVxsDoc->GetRect());
00098             int endFrame = mVxsDoc->GetMarkedFrameEnd();
00099             if ((endFrame != -1) && (src->FrameNr() == endFrame))
00100                 SetDoContinuous(false);
00101         }
00102         UpdateTextArea();
00103     }
00104 
00105     virtual void
00106     HandleNewKey(int c, int state)
00107     {
00108         if (c == 'D')
00109         {
00110             mVxsDoc->SetMarkedFrameBegin(mVxsDoc->CurFrame());
00111             AllHandleNewCursor(Core::Database::LEVEL_FRAME, false);
00112         }
00113         if (c == 'd')
00114         {
00115             mVxsDoc->GotoFrame(mVxsDoc->GetMarkedFrameBegin());
00116             AllHandleNewCursor(Core::Database::LEVEL_FRAME, false);
00117         }
00118         if (c == 'E')
00119         {
00120             mVxsDoc->SetMarkedFrameEnd(mVxsDoc->CurFrame());
00121             AllHandleNewCursor(Core::Database::LEVEL_FRAME, false);
00122         }
00123         if (c == 'e')
00124         {
00125             mVxsDoc->GotoFrame(mVxsDoc->GetMarkedFrameEnd());
00126             AllHandleNewCursor(Core::Database::LEVEL_FRAME, false);
00127         }
00128     }
00129 
00130     virtual void
00131     HandleCycleDoc()
00132     {
00133         mOglWnd->updateScene = 1;
00134     }
00135 
00136     virtual void
00137     CheckBoxEvent(OglGui::CheckBox *src, bool checked, void* userData)
00138     {
00139         if (src == mCheckBoxFBM)
00140             mVxsDoc->SetFrameNavBetweenMarked(checked);
00141     }
00142 
00143     virtual void
00144     ButtonSelectionEvent(OglGui::Button* src, void* vData)
00145     {
00146         DataDocumentGui<VxsDocument>::ButtonSelectionEvent(src, vData);
00147         int listenerData = (int)(long long) vData;
00148         switch (listenerData)
00149         {
00150         case SETBEGIN:
00151             mVxsDoc->SetMarkedFrameBegin(mVxsDoc->CurFrame());
00152             AllHandleNewCursor(Core::Database::LEVEL_FRAME, false);
00153             break;
00154         case GOTOBEGIN:
00155             mVxsDoc->GotoFrame(mVxsDoc->GetMarkedFrameBegin());
00156             AllHandleNewCursor(Core::Database::LEVEL_FRAME, false);
00157             break;
00158         case SETEND:
00159             mVxsDoc->SetMarkedFrameEnd(mVxsDoc->CurFrame());
00160             AllHandleNewCursor(Core::Database::LEVEL_FRAME, false);
00161             break;
00162         case GOTOEND:
00163             mVxsDoc->GotoFrame(mVxsDoc->GetMarkedFrameEnd());
00164             AllHandleNewCursor(Core::Database::LEVEL_FRAME, false);
00165             break;
00166         } // end switch
00167     }
00168 
00169     virtual void
00170     NavFrameEvent(VideoNav* navSrc, int requestedFrame, void* listenerData)
00171     {
00172         mVxsDoc->GotoFrame(requestedFrame);
00173         AllHandleNewCursor(Core::Database::LEVEL_FRAME, false);
00174     }
00175 
00176     virtual void
00177     OnViewMouse(OglGui::View* view, int msg, int btn, int state,
00178                 float x, float y)
00179     {
00180         Core::Geometry::Rectangle r = mVideoNav->GetRect();
00181         mVxsDoc->SetRect(r);
00182     }
00183 
00184 private:
00185 
00186     void
00187     UpdateTextArea()
00188     {
00189         if (!mBeginText)
00190             return;
00191         std::string s = std::string("Marked frame begin = ")
00192                      + MakeString(mVxsDoc->GetMarkedFrameBegin());
00193         mBeginText->SetText(s);
00194         s = std::string("Marked frame end = ")
00195             + MakeString(mVxsDoc->GetMarkedFrameEnd());
00196         mEndText->SetText(s);
00197     }
00198 
00199     VxsDocument*          mVxsDoc;
00200     double                mViewScale;
00201     VideoNav*             mVideoNav;
00202     OglGui::TextArea*     mBeginText;
00203     OglGui::TextArea*     mEndText;
00204     OglGui::CheckBox*     mCheckBoxFBM;
00205 
00206 };
00207 
00208 } // namespace Visualization
00209 } // namespace Impala
00210 
00211 #endif

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