Definition at line 147 of file MediaTable.h. References OglGui::OglImageCache::Add(), Impala::Application::MediaTable::GridWindow::AddColumnsFromDataSource(), Impala::Application::MediaTable::TableWindow::AddColumnsFromDataSource(), Impala::Application::MediaTable::TableDataStore::AddTableDataSource(), Impala::Application::MediaTable::TableDataSourceCombinedViews::AddTableDataView(), OglGui::OglWindow::ConnectTo(), OglGui::Tabs::CreateTab(), Impala::Application::MediaTable::TableDataView::DoUpdateSelectionEvent(), Impala::CmdOptions::GetBool(), Impala::Application::MediaTable::TableDataView::GetColumns(), Impala::Application::MediaTable::ModuleStore::GetInstance(), Impala::Application::MediaTable::OglImageCacheStore::GetInstance(), Impala::Application::MediaTable::TableDataStore::GetInstance(), Impala::CmdOptions::GetInstance(), Impala::CmdOptions::GetInt(), Impala::Application::MediaTable::ModuleStore::GetModulesOfType(), Impala::Application::MediaTable::ImageLoader::GetOglImageById(), OglGui::OglWindow::GetOGLWND(), Impala::Application::MediaTable::TableDataView::GetSortedQuid(), Impala::CmdOptions::GetString(), Impala::Application::MediaTable::TableDataStore::GetTableDataView(), Impala::Application::MediaTable::TableDataView::GetTotalRows(), Impala::Application::MediaTable::TableDataSource::GetTotalRows(), OglGui::OglWindow::H(), ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, Impala::Application::MediaTable::OglImageCacheStore::Initialize(), mGrid, mImageLoader, mOverlayWindow, mOverview, mTable, mTabs, Impala::Application::MediaTable::ModuleStore::Register(), Impala::Application::MediaTable::ModuleStore::RegisterListener(), OglGui::Window::ScaleChildren(), OglGui::Tabs::SetActiveTab(), OglGui::Window::SetAllowScaling(), OglGui::OglWindow::SetBackground(), OglGui::Button::SetButtonListener(), Impala::Application::MediaTable::GridWindow::SetGetOglImageByIdInterface(), Impala::Application::MediaTable::TableWindow::SetGetOglImageByIdInterface(), Impala::Application::MediaTable::VisualizationModule::SetGetOglImageByIdInterface(), Impala::Application::MediaTable::GridWindow::SetGridSize(), Impala::Application::MediaTable::TableOverviewWindow::SetHeaderHeight(), Impala::Application::MediaTable::TableDataViewListener::SetListenTableUpdates(), OglGui::OglWindow::SetRoundness(), OglGui::Tabs::SetTabsListener(), OglGui::OglWindow::SetVisible(), Impala::Application::MediaTable::GridWindow::SetZoomViewTargetWindow(), Impala::Application::MediaTable::TableWindow::SetZoomViewTargetWindow(), OglGui::Tabs::TabBar(), OglGui::TOBOTTOM, OglGui::TOLEFTRIGHT, OglGui::TORIGHT, OglGui::TOTOP, OglGui::TOTOPBOTTOM, Impala::Application::MediaTable::TableDataSource::TYPE_FLAG_IMAGE, OglGui::OglWindow::W(), and Impala::Application::MediaTable::ImageLoader::WaitUntilDone(). 00148 { 00149 /* quick parsing of options, to be redone later */ 00150 Impala::CmdOptions& options = Impala::CmdOptions::GetInstance(); 00151 00152 //ULONG bgCol = 0xffd2c799; 00153 ULONG bgCol = oglGUI_BG; 00154 String bgStr = options.GetString("wndBg"); 00155 if (!bgStr.empty()) 00156 bgCol = OglColorStr(bgStr.c_str()); 00157 SetBackground(bgCol); 00158 00159 TableDataSource *src = 0; 00160 00161 #ifdef MEDIATABLE_BASIC 00162 ILOG_INFO("loading data.csv..."); 00163 src = new TableDataSourceCSV("data.csv"); 00164 if(!src->GetTotalRows()) 00165 { 00166 ILOG_ERROR("data.csv could not be opened"); 00167 exit(0); 00168 } 00169 ILOG_INFO("..done. " << src->GetTotalRows() << " rows loaded."); 00170 #else 00171 #ifdef MEDIATABLE_USING_SQLITE 00172 if (options.GetString("database") != "") 00173 src = new TableDataSourceSqliteDb(options.GetString("database")); 00174 #endif 00175 #ifdef MEDIATABLE_USING_IMAGEDIR 00176 if (options.GetString("directory") != "") 00177 src = new TableDataSourceImageDir(options.GetString("directory")); 00178 #endif 00179 #ifdef MEDIATABLE_USING_TREC 00180 if (options.GetBool("trec")) 00181 src = new TableDataSourceTrec(); 00182 #endif 00183 00184 #ifdef MEDIATABLE_USING_CSV 00185 if (options.GetString("csv") != "" && !src) 00186 src = new TableDataSourceCSV(options.GetString("csv")); 00187 if (options.GetString("csv") != "" && src) 00188 { 00189 TableDataSource *src1 = src; 00190 TableDataSource *src2 = new TableDataSourceCSV(options.GetString("csv")); 00191 TableDataView *view1 = new TableDataView(src1); 00192 TableDataView *view2 = new TableDataView(src2); 00193 00194 TableDataSourceCombinedViews *csrc = new TableDataSourceCombinedViews(); 00195 csrc->AddTableDataView(view1, "filename"); 00196 csrc->AddTableDataView(view2, "filename"); 00197 src = csrc; 00198 } 00199 #endif 00200 00201 #ifdef MEDIATABLE_USING_FLICKR 00202 if(!src) 00203 src = new TableDataSourceFlickrPhotoList(); 00204 #endif 00205 if (!src) 00206 { 00207 ILOG_ERROR("Please start with either -a <db>, -d <directory> " << 00208 "or --trec --ini <inifile>"); 00209 return; 00210 } 00211 #endif 00212 00213 TableDataStore *store = TableDataStore::GetInstance(); 00214 store->AddTableDataSource("Default", src); 00215 TableDataView *view = store->GetTableDataView("Default", "Default"); 00216 00217 mImageLoader = new ImageLoader(this); 00218 00219 int csize = options.GetInt("imageCacheSize"); 00220 csize = (csize > 100) ? csize : 100; 00221 OglImageCacheStore::Initialize(csize); 00222 00223 if (options.GetBool("preload")) 00224 { 00225 std::string column = ""; 00226 std::vector<TableColumn*>::iterator it; 00227 std::vector<TableColumn*> columns; 00228 columns = view->GetColumns(true, true); 00229 for(it = columns.begin(); it != columns.end(); it++) 00230 { 00231 if((*it)->GetType() && TableDataSource::TYPE_FLAG_IMAGE) 00232 { 00233 column = (*it)->GetName(); 00234 break; 00235 } 00236 } 00237 if(column != "") 00238 { 00239 int maxPreload = csize; 00240 if(view->GetTotalRows() < maxPreload) 00241 maxPreload = view->GetTotalRows(); 00242 ILOG_INFO("Pre-filling cache with " << maxPreload << " images."); 00243 for(int i = 0; i < maxPreload; i++) 00244 { 00245 if(i%100 == 0 && i != 0) 00246 { 00247 ILOG_DEBUG("Preloading images until " << i << " of " << maxPreload); 00248 mImageLoader->WaitUntilDone(); 00249 } 00250 long long id = view->GetSortedQuid(column, i); 00251 OGLIMAGE* im = mImageLoader->GetOglImageById(id); 00252 OglImageCacheStore::GetInstance()->Add(im, id); 00253 } 00254 mImageLoader->WaitUntilDone(); 00255 } 00256 } 00257 00258 int btnH = 32; 00259 int botH = 124; 00260 int centerH = h - 10 - btnH - botH; 00261 00262 #ifdef MEDIATABLE_USING_MULTIPLE_VIEWS 00263 #ifdef IMAGEDIRMODULE_H 00264 ModuleStore::GetInstance()->Register(new ImageDirModule()); 00265 #endif 00266 #ifdef CSVMODULE_H 00267 ModuleStore::GetInstance()->Register(new CSVModule()); 00268 #endif 00269 #ifdef FLICKRMODULE_H 00270 ModuleStore::GetInstance()->Register(new FlickrModule()); 00271 #endif 00272 #ifdef COMBINEDVIEWSMODULE_H 00273 ModuleStore::GetInstance()->Register(new CombinedViewsModule()); 00274 #endif 00275 #endif 00276 00277 VisualizationModule* m; 00278 #ifdef BARPLOTMODULE_H_ 00279 m = new BarPlotModule(); 00280 m->SetGetOglImageByIdInterface(mImageLoader); 00281 ModuleStore::GetInstance()->Register(m); 00282 #endif 00283 #ifdef MAPMODULE_H_ 00284 m = new MapModule(); 00285 m->SetGetOglImageByIdInterface(mImageLoader); 00286 ModuleStore::GetInstance()->Register(m); 00287 #endif 00288 #ifdef GRAPHMODULE_H_ 00289 m = new GraphModule(); 00290 m->SetGetOglImageByIdInterface(mImageLoader); 00291 ModuleStore::GetInstance()->Register(m); 00292 #endif 00293 #ifdef VIEWERPOINTCLOUDMODULE_H_ 00294 m = new ViewerPointCloudModule(); 00295 m->SetGetOglImageByIdInterface(mImageLoader); 00296 ModuleStore::GetInstance()->Register(m); 00297 #endif 00298 #ifdef TIMELINEMODULE_H_ 00299 m = new TimeLineModule(); 00300 m->SetGetOglImageByIdInterface(mImageLoader); 00301 ModuleStore::GetInstance()->Register(m); 00302 #endif 00303 #ifdef RANDOMIMAGEMODULE_H_ 00304 m = new RandomImageModule(); 00305 m->SetGetOglImageByIdInterface(mImageLoader); 00306 ModuleStore::GetInstance()->Register(m); 00307 #endif 00308 00309 ModuleStore::GetInstance()->RegisterListener(static_cast<VisualizationModuleListener*>(this)); 00310 ModuleStore::GetInstance()->RegisterListener(static_cast<TableDataSourceModuleListener*>(this)); 00311 00312 ModuleStore::ModuleMapType vModules = 00313 ModuleStore::GetInstance()->GetModulesOfType("VisualizationModule"); 00314 ILOG_DEBUG("VisualizationModules = " << vModules.size()); 00315 00316 ModuleStore::ModuleMapType::iterator it; 00317 for (it=vModules.begin() ; it != vModules.end(); it++ ) 00318 { 00319 ILOG_DEBUG("VisualizationModule:" << (*it).first << " => " << 00320 (*it).second); 00321 } 00322 00323 mTabs = new OglGui::Tabs(this, 5, 5+botH, w-60, centerH+btnH, 120); 00324 mTabs->ConnectTo(this); 00325 00326 OglGui::Window* wnd = mTabs->CreateTab("Table"); 00327 TableWindow *table = 00328 new TableWindow(wnd, view, 0, 0, wnd->W(), wnd->H()-btnH); 00329 table->ConnectTo(wnd); 00330 00331 TableControlBarWindow *buttonbar = 00332 new TableControlBarWindow(wnd, table, 0, table->H(), wnd->W(), btnH); 00333 buttonbar->ConnectTo(wnd, OglGui::TOLEFTRIGHT | OglGui::TOTOP); 00334 buttonbar->SetVisible(true); 00335 00336 wnd = mTabs->CreateTab("Grid"); 00337 GridWindow *grid = new GridWindow(wnd, view, 0, 0, wnd->W(), wnd->H()); 00338 grid->ConnectTo(wnd); 00339 grid->SetGridSize(75, 75); 00340 00341 if(ModuleStore::GetInstance()->CountModulesOfType("VisualizationModule") || 00342 ModuleStore::GetInstance()->CountModulesOfType("TableDataSourceModule")) 00343 { 00344 Window* tabBar = mTabs->TabBar(); 00345 Button* but = new Button(tabBar, tabBar->W()-45, -2, 35, 26, "+"); 00346 but->SetRoundness(200, 200, 2, 2); 00347 but->SetButtonListener(this); 00348 but->ConnectTo(tabBar, OglGui::TORIGHT); 00349 } 00350 00351 mTabs->SetActiveTab(0); 00352 mTabs->SetTabsListener(this); 00353 00354 mOverview = 00355 new TableOverviewWindow(this, view, w-55, 5+botH, 50, centerH); 00356 mOverview->ConnectTo(this, OglGui::TORIGHT|OglGui::TOTOPBOTTOM); 00357 mOverview->SetHeaderHeight(40); 00358 00359 SelectionCollection *selcol = 00360 new SelectionCollection(this,view,5,5,w-10,botH); 00361 selcol->ScaleChildren(); 00362 selcol->SetAllowScaling(false); 00363 selcol->ConnectTo(this, OglGui::TOLEFTRIGHT | OglGui::TOBOTTOM); 00364 00365 // overlay window to show preview of table on top of everything else.. 00366 // there must be a better way to do this though :) 00367 mOverlayWindow = new Window(this, 0, 0, w, h); 00368 mOverlayWindow->ConnectTo(this); 00369 oglSys.SetNoMouseInput(mOverlayWindow->GetOGLWND(), 1); 00370 00371 grid->SetListenTableUpdates(false); 00372 table->SetListenTableUpdates(true); 00373 mOverview->SetListenTableUpdates(true); 00374 00375 // add default data columns for specified data source: 00376 table->AddColumnsFromDataSource(); 00377 grid->AddColumnsFromDataSource(); 00378 00379 table->SetGetOglImageByIdInterface(mImageLoader); 00380 grid->SetGetOglImageByIdInterface(mImageLoader); 00381 00382 // for which column/cache should the table display larger images 00383 // OBS: (need to set here because there can be more than one images row) 00384 table->SetZoomViewTargetWindow(mOverlayWindow, true); 00385 grid->SetZoomViewTargetWindow(mOverlayWindow, true); 00386 00387 mTable = table; 00388 mGrid = grid; 00389 00390 // TODO: Remove this, needed to show bucket sizes at start. 00391 view->DoUpdateSelectionEvent(); 00392 00393 #ifdef MEDIATABLE_USING_MULTIPLE_VIEWS 00394 DoTableDataStoreWindow(this, w-160+5, h-btnH+3, 150, centerH+btnH+8); 00395 #endif 00396 00397 //ScaleChildren(); 00398 }
Here is the call graph for this function:
|