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

ShowImSetGuiMain.h

Go to the documentation of this file.
00001 #ifndef Impala_Visualization_ShowImSetGuiMain_h
00002 #define Impala_Visualization_ShowImSetGuiMain_h
00003 
00004 #include "Visualization/ImageStrip.h"
00005 #include "Visualization/ImageSetIdxGridScroller.h"
00006 #include "Visualization/DataDocumentGui.h"
00007 #include "Core/ImageSet/IxsDocument.h"
00008 
00009 
00010 namespace Impala {
00011 namespace Visualization {
00012 
00013 class ShowImSetGuiMain : public DataDocumentGui<Core::ImageSet::IxsDocument>,
00014                          public ImageSetIdxGridListener,
00015                          public ImagesListener,
00016                          public OglGui::ViewListener
00017 {
00018     static const int IM_BOOKMARKED = 1;
00019     static const int IM_CURRENT = 2;
00020     static const int IM_SET = 3;
00021 
00022 public:
00023 
00024     typedef Core::ImageSet::IxsDocument         IxsDocument;
00025     typedef Core::Array::Array2dVec3UInt8       Array2dVec3UInt8;
00026 
00027     ShowImSetGuiMain(OglGui::Window* parent, int wndWidth, int wndHeight,
00028                        int nrImOnRow, bool showAnno, IxsDocument* ixsDoc,
00029                        int controlId) :
00030         DataDocumentGui<IxsDocument>(parent, wndWidth, wndHeight, ixsDoc,
00031                                      controlId, true, true, false, 3, 6,
00032                                      false, false)
00033     {
00034         Init(ixsDoc, wndWidth, wndHeight, nrImOnRow);
00035     }
00036 
00037     virtual void HandleNewDir()
00038     {
00039         HandleNewFile();
00040     }
00041 
00042     virtual void HandleNewFile()
00043     {
00044         DataDocumentGui<IxsDocument>::HandleNewFile();
00045         int curDir = mIxsDoc->CurDirId();           
00046         if (mCurDir != mIxsDoc->CurDirId())
00047         {
00048             mImSetIdxGrid->Clear();
00049             if ((mCurDir = mIxsDoc->CurDirId())==-1)
00050                 return;
00051             Core::Table::TableIds* table = mIxsDoc->GetFilesOfDir(-1);
00052             Core::ImageSet::ImageSet* imageSet = mIxsDoc->GetImageSet();
00053             for (int i=0; i<table->Size(); i++)
00054                 mImSetIdxGrid->AddImageSetIdx(imageSet, table->Get1(i));
00055             mImSetIdxGrid->UpdateLayout(true);
00056             mFirstFileOfDir = table->Get1(0);
00057         }
00058         if (mCurDir == -1)
00059             return;
00060         int idx = mIxsDoc->CurFileId() - mFirstFileOfDir;
00061         mImSetIdxGrid->SetSelected(idx);
00062         mImSetIdxGrid->SetFirstVisRow(idx);
00063     }
00064 
00065     virtual void HandleNewBookmarked()
00066     {
00067         DataDocumentGui<IxsDocument>::HandleNewBookmarked();
00068         /*
00069         if (mBookmarkedStrip)
00070             mBookmarkedStrip->ReplaceImages(mIxsDoc->GetBookmarkedIds(), 
00071                                             mIxsDoc->GetImageSet());
00072         */
00073     }
00074 
00075     virtual void
00076     HandleAddedBookmark()
00077     {
00078         /*
00079         if (mBookmarkedStrip)
00080             mBookmarkedStrip->AddImage(mIxsDoc->CurFileId(),
00081                                        mIxsDoc->GetImageSet());
00082         DataDocumentGui<IxsDocument>::HandleNewBookmarked(); // has no Added
00083         */
00084     }
00085 
00086     virtual void
00087     ImageSelectionEvent(ImagesWindow* src, int imIndex, void* vData)
00088     {
00089         /*
00090         int listenerData = (int)(long long) vData;
00091         switch (listenerData)
00092         {
00093         case IM_BOOKMARKED:
00094             mIxsDoc->CursorToBookmark(imIndex);
00095             AllHandleNewCursor(Core::Database::LEVEL_FILE, false);
00096             break;
00097         case IM_SET:
00098             mIxsDoc->CursorToFile(mIxsDoc->GetFileOfDir(imIndex, -1));
00099             AllHandleNewCursor(Core::Database::LEVEL_FILE, false);
00100             break;
00101         }
00102         */
00103     }
00104 
00105     virtual void
00106     ImageSelectionEvent(ImageSetIdxGrid* src, int imIndex, void* listenerData)
00107     {
00108         mIxsDoc->CursorToFile(imIndex + mFirstFileOfDir);
00109         DataDocumentGui<IxsDocument>::HandleNewFile();
00110     }
00111 
00112 
00113     virtual void
00114     OnViewMouse(OglGui::View* view, int msg, int btn, int state,
00115                 float x, float y)
00116     {
00117         /*
00118         Core::Geometry::Rectangle r = mCurImWnd->GetViewWithRect(0)->GetRect();
00119         mIxsDoc->SetRect(r);
00120         */
00121     }
00122 
00123 private:
00124 
00125     void Init(IxsDocument* ixsDoc, int w, int h, int nrImOnRow)
00126     {
00127         mIxsDoc = ixsDoc;
00128         mFirstFileOfDir = -1;
00129         mCurDir = -1;
00130         //mViewScale = viewScale;
00131 
00132         /*
00133         mBookmarkedStrip = 0;
00134         if (nrImOnRow > 0)
00135         {
00136             mBookmarkedStrip = new ImageStrip(this, thumbWidth, thumbHeight,
00137                                               viewScale, nrImOnRow);
00138             mBookmarkedStrip->SetImagesListener(this, IM_BOOKMARKED);
00139             mBookmarkedStrip->ActivateInfoBox(false);
00140         }
00141 
00142         new OglGui::Strut(this, 4000, 1);
00143 
00144         mImageSet = 0;
00145         if (nrImOnRow > 0)
00146         {
00147             mImageSet = new ImageSet(this, thumbWidth, thumbHeight, viewScale,
00148                                      nrImOnRow*3/4, 4);
00149             mImageSet->SetImagesListener(this, IM_SET);
00150             mImageSet->ActivateInfoBox(false);
00151         }
00152         */
00153         /*
00154         mCurImWnd = new ImagesWindow(this, 360, 360);
00155         mCurImWnd->SetImagesListener(this, IM_CURRENT);
00156         mCurImWnd->SetMakeViewWithRect(true);
00157         mCurImWnd->SetViewListener(this);
00158         mCurImWnd->ActivateInfoBox(false);
00159         */
00160         mImSetIdxScroller =
00161             new ImageSetIdxGridScroller(this, 2, 2, w-4, h-160, nrImOnRow);
00162         mImSetIdxGrid = mImSetIdxScroller->ImSetIdxGrid();
00163         mImSetIdxGrid->SetImageSetIdxGridListener(this);
00164         oglSys.SetSelectColor(mImSetIdxGrid->GetOGLWND(),0xffffa500);
00165     }
00166 
00167     int                         mCurDir;
00168     int                         mFirstFileOfDir;
00169     double                      mViewScale;
00170 
00171     IxsDocument*                mIxsDoc;
00172     ImageStrip*                 mBookmarkedStrip;
00173     ImageSetIdxGridScroller*    mImSetIdxScroller;
00174     ImageSetIdxGrid*            mImSetIdxGrid;
00175     ImagesWindow*               mCurImWnd;
00176 };
00177 
00178 } // namespace Visualization
00179 } // namespace Impala
00180 
00181 #endif

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