00001
00002 #include "OglGui/OglLib.cpp"
00003
00004 #include "Basis/CmdOptions.h"
00005
00006 #include "GridWindow.h"
00007 #include "SelectionCollection.h"
00008 #include "ImageCache.h"
00009 #include "TableWindow.h"
00010 #include "TableControlBarWindow.h"
00011 #include "TableOverviewWindow.h"
00012 #include "TableDataSource.h"
00013 #include "TableDataSourceImageDir.h"
00014
00015
00016 #ifdef VE_USING_SQLITE
00017 #include "TableDataSourceSqliteDb.h"
00018 #endif
00019
00020 #define VE_USING_TREC
00021 #ifdef VE_USING_TREC
00022 #include "TableDataSourceTrec.h"
00023 #endif
00024
00025 namespace Impala {
00026 namespace Application {
00027 namespace VideoExcel {
00028
00029
00030
00031 class VideoExcel: public OglGui::Window
00032 {
00033 typedef OglGui::Window Window;
00034
00035 public:
00036 VideoExcel(int w, int h) : Window(0, 0, w, h)
00037 {
00038 Impala::CmdOptions& options = Impala::CmdOptions::GetInstance();
00039
00040 ILOG_STARTACTION("building GUI", ILOG_LEVEL_INFO);
00041 Init(w,h);
00042 ILOG_ENDACTION("building GUI");
00043
00044 GetOGLWND()->topTitle = "VideoExcel";
00045 }
00046
00047 void Go()
00048 {
00049 Start();
00050 OglEventLoop();
00051 }
00052
00053 virtual void KeyboardFunc(int c, int state)
00054 {
00055 if (mTable->GetVisible())
00056 mTable->KeyboardFunc(c, state);
00057 if (mGrid->GetVisible())
00058 mGrid->KeyboardFunc(c, state);
00059 Window::KeyboardFunc(c, state);
00060 }
00061
00062 void Init(int w, int h)
00063 {
00064
00065 Impala::CmdOptions& options = Impala::CmdOptions::GetInstance();
00066
00067
00068 ULONG bgCol = oglGUI_BG;
00069 String bgStr = options.GetString("wndBg");
00070 if (!bgStr.empty())
00071 bgCol = OglColorStr(bgStr.c_str());
00072 SetBackground(bgCol);
00073
00074 TableDataSource *src = 0;
00075
00076 #ifdef VE_USING_SQLITE
00077 if (options.GetString("database") != "")
00078 src = new TableDataSourceSqliteDb(options.GetString("database"));
00079 #endif
00080 if (options.GetString("directory") != "")
00081 src = new TableDataSourceImageDir(options.GetString("directory"));
00082 #ifdef VE_USING_TREC
00083 if (options.GetBool("trec"))
00084 src = new TableDataSourceTrec();
00085 #endif
00086 if (!src)
00087 {
00088 ILOG_ERROR("Please start with either -a <db>, -d <directory> " <<
00089 "or --trec --ini <inifile>");
00090 return;
00091 }
00092
00093 int csize = options.GetInt("imageCacheSize");
00094 if (csize < 100) csize = 100;
00095 ImageCache::InitializeCache(src, csize);
00096
00097 if (options.GetBool("preload"))
00098 {
00099 ILOG_INFO("Pre-filling cache with content...");
00100 ImageCache::GetInstance()->PreloadCache();
00101 }
00102
00103 int btnH = 32;
00104 int botH = 140;
00105 int centerH = h - 10 - btnH - botH;
00106
00107 GridWindow *grid = new GridWindow(this,src,5,5+botH,w-160,centerH);
00108 grid->ConnectTo(this);
00109
00110 TableWindow *table = new TableWindow(this,src,5,5+botH,w-160,centerH);
00111 table->ConnectTo(this);
00112
00113 TableOverviewWindow *overview =
00114 new TableOverviewWindow(this,src,w-155,5+botH,150,centerH);
00115
00116 overview->ConnectTo(this, OglGui::TORIGHT|OglGui::TOTOPBOTTOM);
00117
00118 TableControlBarWindow *buttonbar =
00119 new TableControlBarWindow(this,table,grid,5,h-btnH-5,w-10,btnH);
00120
00121 buttonbar->ConnectTo(this, OglGui::TOLEFTRIGHT | OglGui::TOTOP);
00122
00123 SelectionCollection *selcol =
00124 new SelectionCollection(this,src,5,5,w-10,botH);
00125
00126 selcol->ConnectTo(this, OglGui::TOLEFTRIGHT | OglGui::TOBOTTOM);
00127
00128
00129
00130 Window *overlay = new Window(this, 0, 0, w, h);
00131 overlay->ConnectTo(this);
00132 oglSys.SetNoMouseInput(overlay->GetOGLWND(),1);
00133
00134 grid->SetListenTableUpdates(false);
00135 table->SetListenTableUpdates(true);
00136 overview->SetListenTableUpdates(true);
00137
00138
00139 table->AddColumnsFromDataSource();
00140 grid->AddColumnsFromDataSource();
00141
00142
00143
00144 table->SetZoomViewTargetWindow(overlay, true);
00145 grid->SetZoomViewTargetWindow(overlay, true);
00146
00147 table->SetVisible(true);
00148 grid->SetVisible(false);
00149
00150
00151 mTable = table;
00152 mGrid = grid;
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 }
00185
00186 private:
00187
00188 TableWindow *mTable;
00189 GridWindow *mGrid;
00190
00191 ILOG_VAR_DEC;
00192 };
00193
00194 int mainVideoExcel(int argc, char* argv[])
00195 {
00196 OglInit(&argc, &argv[0]);
00197
00198
00199 Impala::CmdOptions& options = Impala::CmdOptions::GetInstance();
00200 options.Initialise(true, false, true);
00201 options.SetDefault("wndWidth", "1270");
00202 options.SetDefault("wndHeight", "975");
00203 options.AddOption(0, "imageCacheSize", "size of image cache", "800");
00204 options.AddOption('a',"database", "database file to use","");
00205 options.AddOption('d',"directory", "directory of images to use","");
00206 options.AddOption(0, "trec", "", "0");
00207 options.AddOption(0, "preload","", "0");
00208
00209 if (! options.ParseArgs(argc, argv, "", 0))
00210 return 1;
00211
00212 ILOG_VAR(VideoExcel.mainVideoExcel);
00213
00214 ILOG_SYSTEM("LOADING......");
00215 int w = options.GetInt("wndWidth");
00216 int h = options.GetInt("wndHeight");
00217
00218
00219 Impala::Application::VideoExcel::VideoExcel *d =
00220 new Impala::Application::VideoExcel::VideoExcel(w,h);
00221 ILOG_SYSTEM("STARTING -----------------------------");
00222 d->Go();
00223 return 0;
00224 }
00225
00226 ILOG_VAR_INIT(VideoExcel, VideoExcel);
00227
00228 }
00229 }
00230 }
00231
00232 int main(int argc, char* argv[])
00233 {
00234 return Impala::Application::VideoExcel::mainVideoExcel(argc, argv);
00235 }
00236