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

mainShowImSet.cpp

Go to the documentation of this file.
00001 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00002 #include "OglGui/Tabs.h"
00003 #include "OglGui/SplashScreen.h"
00004 // since we are not using libraries:
00005 #include "OglGui/OglLib.cpp"
00006 
00007 #include "Visualization/Window.h"
00008 #include "Visualization/ShowImSetGuiMain.h"
00009 #include "Visualization/AnnotationTableGui.h"
00010 #include "Visualization/ImageSetIdxGridScroller.h"
00011 #include "Core/ImageSet/MakeIxsDocument.h"
00012 #include "Core/Table/SimilarityTableSet.h"
00013 
00014 #include "Visualization/SimilarityTableSetRank.h"
00015 // since we are not using libraries:
00016 #include "Link/ImpalaLib.cpp"
00017 
00018 
00019 namespace Impala {
00020 namespace Application {
00021 
00022 using namespace Visualization;
00023 //using namespace Core::ImageSet;
00024 
00025 class WindowShowImSet : public Window,
00026                         public OglGui::TabsListener
00027 {
00028 public:
00029 
00030     const static int TAB_SET = 0;
00031     const static int TAB_MAIN = 1;
00032     const static int TAB_ALL = 2;
00033     const static int TAB_ANNOTATIONS = 3;
00034     const static int TAB_CONCEPTS = 4;
00035     const static int TAB_CONCEPTSSIM = 5;
00036     const static int TAB_CONCEPTSTRUTH = 6;
00037 
00038     WindowShowImSet(int width, int height) : Window(0, 0, width, height, true)
00039     {
00040         CmdOptions& options = CmdOptions::GetInstance();
00041         mViewScale = options.GetDouble("viewScale");
00042         ILOG_INFO("loading data");
00043         InitData();
00044         ILOG_INFO("building GUI");
00045         View::SetTags(selectableTag | showBgTag | showBorderTag |
00046                       showBorderTag | showTitleTag);
00047         BuildGUI(width, height);
00048     }
00049 
00050     // specialization of base classes
00051 
00052     virtual void
00053     TabSelectionEvent(OglGui::Tabs* src, int tabNr, void* listenerData,
00054                       int tabControlData)
00055     {
00056         AppController::Instance().SetCurrentControl(tabControlData);
00057     }
00058 
00059     virtual void
00060     DisplayFunc()
00061     {
00062         static bool initialized = false;
00063 
00064         if (!initialized)
00065         {
00066             initialized = true;
00067             ScaleChildren(0, true);
00068             SetReposChildren(false, true);
00069         }
00070         Window::DisplayFunc();
00071     }
00072 
00073 private:
00074 
00075     // initialization
00076 
00077     void InitData()
00078     {
00079         CmdOptions& options = CmdOptions::GetInstance();
00080         String imSetName = options.GetString("imageSet");
00081         mIxsDoc = Core::ImageSet::MakeIxsDocument(imSetName);
00082         //mSegDoc = Core::VideoSet::MakeSegmentationDocument(videoSetName);
00083         
00084         Core::ImageSet::ImageSet* imSetThumb = mIxsDoc->GetImageSet();
00085         imSetThumb->SetImageSrc(options.GetBool("imArchive"),
00086                                 options.GetBool("imFileArchive"),
00087                                 options.GetBool("imSplitArchive"));
00088         if (imSetThumb)
00089         {
00090             Core::Array::Array2dVec3UInt8* im = imSetThumb->GetImage(0);
00091             mThumbWidth = im->CW();
00092             mThumbHeight = im->CH();
00093             delete im;
00094         }
00095 
00096         String conceptSetName = options.GetString("conceptSet");
00097         mConceptRanking = 0;
00098         if (!conceptSetName.empty())
00099         {
00100             String model = options.GetString("conceptModel");
00101             String feature = options.GetString("conceptFeature");
00102             ILOG_INFO("reading concept similarity set");
00103             mConceptRanking = Core::Table::SimilarityTableSet::MakeFromFile
00104                 (mIxsDoc->GetImageSet(), conceptSetName, model, feature);
00105         }
00106     }
00107 
00108     void BuildGUI(int wndWidth, int wndHeight)
00109     {
00110         CmdOptions& options = CmdOptions::GetInstance();
00111 
00112         SetBorderType(-1);
00113         if (!GetBorderBackground())
00114             SetBorderBackground(oglGUI_BG);
00115 
00116         mTabs = new OglGui::Tabs(this, wndWidth, wndHeight);
00117         mTabs->SetTabsListener(this);
00118 
00119         OglGui::Window* tab = mTabs->CreateTab("Main", -1, TAB_MAIN);
00120         //int nrImOnRow = wndWidth / (mThumbWidth + 3);
00121         mThumbWidth = 176;
00122         mThumbHeight = 176;
00123         int nrImOnRow = options.GetInt("NrImOnRow", 5);
00124         int height = wndHeight;
00125         mGuiMain = new ShowImSetGuiMain(tab, tab->W(), tab->H(), nrImOnRow,
00126                                         true, mIxsDoc, TAB_MAIN);
00127         AppController& ctr = AppController::Instance();
00128         ctr.AddControl((AppControlDoc*) mGuiMain);
00129 
00130         tab = mTabs->CreateTab("All", 60, TAB_ALL);
00131         mImSetIdxGridScroller =
00132             new ImageSetIdxGridScroller(tab,0,0,tab->W(),tab->H());
00133         //mImSetIdxGridScroller->PageUpDownExtra(-2);
00134         mImSetIdxGridScroller->ConnectTo(tab);
00135         ImageSetIdxGrid* idxGrid = mImSetIdxGridScroller->ImSetIdxGrid();
00136         idxGrid->AddImageSetIdxs(mIxsDoc->GetImageSet());
00137         idxGrid->UpdateLayout(true);
00138 
00139         String conceptAnnotations = options.GetString("conceptAnnotations");
00140         if (!conceptAnnotations.empty())
00141         {
00142             tab = mTabs->CreateTab("Annotations", 100, TAB_ANNOTATIONS);
00143             mAnnotation = new AnnotationTableGui
00144                 (tab, tab->W(), tab->H(), nrImOnRow, mThumbWidth, mThumbHeight,
00145                  mViewScale, mIxsDoc, conceptAnnotations, TAB_ANNOTATIONS);
00146             ctr.AddControl((AppControlDoc*) mAnnotation);
00147         }
00148 
00149         if (mConceptRanking)
00150         {
00151             tab = mTabs->CreateTab("Concepts", 82, TAB_CONCEPTS);
00152             mSimSetRank = new SimilarityTableSetRank
00153                 (tab, tab->W(), tab->H(), nrImOnRow, mThumbWidth, mThumbHeight,
00154                  mViewScale, mIxsDoc, mConceptRanking, false,
00155                  conceptAnnotations, false, TAB_CONCEPTS);
00156             ctr.AddControl((AppControlDoc*) mSimSetRank);
00157 
00158             tab = mTabs->CreateTab("ConceptsSim", -1, TAB_CONCEPTSSIM);
00159             mSimSetRankSim = new SimilarityTableSetRank
00160                 (tab, tab->W(), tab->H(), nrImOnRow, mThumbWidth, mThumbHeight,
00161                  mViewScale, mIxsDoc, mConceptRanking, true,
00162                  conceptAnnotations, false, TAB_CONCEPTSSIM);
00163             ctr.AddControl((AppControlDoc*) mSimSetRankSim);
00164 
00165             if (!conceptAnnotations.empty())
00166             {
00167                 tab = mTabs->CreateTab("ConceptsTruth", 120, TAB_CONCEPTSTRUTH);
00168                 mSimSetRankTruth = new SimilarityTableSetRank
00169                     (tab, tab->W(), tab->H(), nrImOnRow, mThumbWidth,
00170                      mThumbHeight, mViewScale, mIxsDoc, mConceptRanking, false,
00171                      conceptAnnotations, true, TAB_CONCEPTSTRUTH);
00172                 ctr.AddControl((AppControlDoc*) mSimSetRankTruth);
00173             }
00174         }
00175 
00176         // RvB: To start with the directory selected
00177         mGuiMain->StringSelectionEvent(NULL,0,(void*)1);
00178 
00179         mTabs->SetActiveTab(0);
00180     }
00181 
00182     char GetKeyBinding(std::string name, std::string dflt)
00183     {
00184         CmdOptions& options = CmdOptions::GetInstance();
00185             std::string str = options.GetString(name, dflt);
00186             return str[0];
00187     }
00188 
00189 
00190     // Configuration
00191     int         mThumbWidth;
00192     int         mThumbHeight;
00193     ULONG       mBackGround;
00194 
00195     // DATA
00196     double                              mViewScale;
00197 
00198     Core::ImageSet::IxsDocument*        mIxsDoc;
00199     Core::Table::SimilarityTableSet*    mConceptRanking;
00200 
00201     ShowImSetGuiMain*                   mGuiMain;
00202     AnnotationTableGui*                 mAnnotation;
00203     SimilarityTableSetRank*             mSimSetRank;
00204     SimilarityTableSetRank*             mSimSetRankSim;
00205     SimilarityTableSetRank*             mSimSetRankTruth;
00206 
00207     ImageSetIdxGridScroller*            mImSetIdxGridScroller;
00208 
00209     // GUI
00210     OglGui::Tabs*                     mTabs;
00211     ILOG_VAR_DEC;
00212 };
00213 
00214 ILOG_VAR_INIT(WindowShowImSet, Application);
00215 
00216 
00217 int
00218 mainShowImSet(int argc, char* argv[])
00219 {
00220     OglInit(&argc, &argv[0]);
00221     CmdOptions& options = CmdOptions::GetInstance();
00222 
00223     options.Initialise(true, false, true);
00224     options.SetDefault("wndWidth", "1272");
00225     options.SetDefault("wndHeight", "955");
00226     options.AddOption(0, "small", "", "0");
00227     options.AddOption(0, "noArchive", "", "0");
00228     options.AddOption(0, "imFileArchive", "", "0");
00229     //options.AddOption(0, "conceptSetSubDir", "featurename", "");
00230     if (! options.ParseArgs(argc, argv, "", 0))
00231         return 1;
00232 
00233     ILOG_VAR(Application.mainShowImSet);
00234 
00235     int reqWndWidth = options.GetInt("wndWidth");
00236     int reqWndHeight = options.GetInt("wndHeight");
00237     if (options.GetBool("small"))
00238     {
00239         reqWndWidth = 1020;
00240         reqWndHeight = 740;
00241     }
00242 
00243     OglGui::SplashScreen* splash;
00244     if (options.GetBool("splashScreen"))
00245     {
00246         splash = new OglGui::SplashScreen(0,0,reqWndWidth,reqWndHeight);
00247         OGLStartThread(splash->GetOGLWND());
00248     }
00249 
00250     WindowShowImSet* oglWnd = new WindowShowImSet(reqWndWidth, reqWndHeight);
00251 
00252     if (options.GetBool("splashScreen"))
00253         splash->Stop();
00254 
00255     if (! oglWnd->Valid())
00256     {
00257         ILOG_ERROR("WindowShowImSet failed");
00258         return 1;
00259     }
00260 
00261     ILOG_INFO("STARTING MAIN LOOP");
00262     AppController::Instance().MainLoop();
00263 
00264     return 0;
00265 }
00266 
00267 } // namespace Application
00268 } // namespace Impala
00269 
00270 int
00271 main(int argc, char* argv[])
00272 {
00273     return Impala::Application::mainShowImSet(argc, argv);
00274 }

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