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