00001 #include "OglGui/Tabs.h"
00002 #include "OglGui/CheckBox.h"
00003 #include "OglGui/Button.h"
00004 #include "OglGui/Strut.h"
00005 #include "OglGui/DropDownWindow.h"
00006 #include "OglGui/StringSelector.h"
00007 #include "OglGui/SixButtonCross.h"
00008 #include "OglGui/GroupBox.h"
00009 #include "OglGui/Strut.h"
00010 #include "OglGui/OglLib.cpp"
00011
00012
00013
00014 #include "Core/Array/Arrays.h"
00015 #include "Core/Array/ReadFile.h"
00016 #include "Core/Array/Set.h"
00017 #include "Core/Array/ArrayListDelete.h"
00018
00019 #include "VidolviView.h"
00020 #include "RawImageDataset.h"
00021 #include "VidolviWindow.h"
00022 #include "ServerConnector.h"
00023
00024 #include "Link/ImpalaLib.cpp"
00025
00026 using namespace OglGui;
00027
00028 namespace Impala {
00029 namespace Application {
00030 namespace Videolympics {
00031
00032 class Vidolvi {
00033 public:
00034 Vidolvi() {
00035 ILOG_DEBUG("Vidolvi() constructor");
00036 Impala::CmdOptions& options = Impala::CmdOptions::GetInstance();
00037
00038 mReady = false;
00039
00040 mNrTeams = options.GetInt("nrTeams");
00041 mServerLocation = options.GetString("serverLocation");
00042 mServerPort = options.GetInt("serverPort");
00043 mServerPassword = options.GetString("serverPassword");
00044
00045 ILOG_DEBUG("Connecting to server...");
00046 mServer = new ServerConnector(mServerLocation, mServerPort, mServerPassword);
00047
00048 ILOG_DEBUG("Reading images...");
00049 mImages = new RawImageDataset("videolympics.raw");
00050 if (mImages == NULL) {
00051 ILOG_ERROR("ERROR: could not load images.");
00052 return;
00053 }
00054 ILOG_DEBUG("images loaded.");
00055
00056 BuildGUI(options.GetInt("wndWidth"), options.GetInt("wndHeight"));
00057
00058 mWin->SetDataset(mImages);
00059 mWin->AddTeamIcons(mNrTeams);
00060 mWin->SetServer(mServer);
00061 mReady = true;
00062 }
00063
00064 void Go()
00065 {
00066 if (!mReady) {
00067 ILOG_ERROR("Application not ready.");
00068 return;
00069 }
00070
00071
00072
00073 ILOG_INFO("Starting main loop...");
00074 OglEventLoop();
00075 }
00076
00077 void Debug()
00078 {
00079 ILOG_INFO("Entering SERVER DEBUG loop. Hit Ctrl-C to exit.");
00080 while(1)
00081 {
00082 mServer->Update();
00083
00084 while (1)
00085 {
00086 ShotPacket *x = mServer->GetPacket();
00087 if (x!=NULL)
00088 {
00089 ILOG_INFO("Received: SHOT: " << x->shotName << " TEAM:" << x->teamID << " SEQ:" << x->sequenceNo << " at " << x->timestamp);
00090 delete x;
00091 }
00092 else
00093 {
00094 ILOG_INFO("no more packets.");
00095 break;
00096 }
00097 }
00098
00099 }
00100 }
00101
00102 private:
00103 void
00104 BuildGUI(int w, int h)
00105 {
00106 Window *vidolvi = new Window(0, 0, w, h);
00107 vidolvi->SetBackground(0x0000000);
00108 vidolvi->GetOGLWND()->topTitle = "VideOlympics Scoreboard";
00109 mWin = new VidolviWindow(vidolvi, w, h);
00110 mWin->ConnectTo(vidolvi);
00111 vidolvi->Start();
00112
00113 }
00114
00115
00116 int mNrTeams;
00117 std::string mServerLocation;
00118 int mServerPort;
00119 std::string mServerPassword;
00120
00121
00122 RawImageDataset *mImages;
00123 ServerConnector *mServer;
00124 VidolviWindow *mWin;
00125 bool mReady;
00126 ILOG_VAR_DEC;
00127
00128 };
00129
00130 ILOG_VAR_INIT(Vidolvi, Application.Videolympics);
00131
00132
00133 }
00134 }
00135 }
00136
00137 int main(int argc, char* argv[])
00138 {
00139 OglInit(&argc, &argv[0]);
00140
00141
00142 Impala::CmdOptions& options = Impala::CmdOptions::GetInstance();
00143 options.Initialise(true, false, true);
00144
00145 options.SetDefault("wndWidth", "1280");
00146 options.SetDefault("wndHeight", "1024");
00147
00148 options.AddOption(0, "imageSet", "imageset to display", "videolympics.raw");
00149
00150
00151 options.AddOption(0, "noArchive", "", "0");
00152 options.AddOption(0, "imFileArchive", "", "0");
00153 options.AddOption(0, "imServer", "name", "");
00154
00155
00156 options.AddOption(0, "loglevel", "0=all .. 10=nothing", "2");
00157 options.AddOption(0, "logfile", "filename", "trecsearch.log");
00158 options.AddOption(0, "logtofile", "0 = no, 1 = yes", "1");
00159
00160
00161 options.AddOption(0, "maxImagesOnRow", "nr of images per team", "25");
00162 options.AddOption(0, "nrTeams", "number of teams", "9");
00163 options.AddOption(0, "serverLocation", "hostname", "localhost");
00164 options.AddOption(0, "serverPort", "port", "14001");
00165 options.AddOption(0, "serverPassword", "secret password", "Mijn naam is haas");
00166
00167 if (! options.ParseArgs(argc, argv, "", 0))
00168 return 1;
00169
00170 Impala::Application::Videolympics::Vidolvi *d =
00171 new Impala::Application::Videolympics::Vidolvi();
00172 d->Go();
00173 return 0;
00174 }
00175