test-VisionGUI.C

00001 /*
00002  * test-VisionGUI.C
00003  *
00004  *                Description: Basically just runs the Vision GUI (VisionGUI.qt.C).
00005  */
00006 
00007 #include <QtGui/QApplication>
00008 
00009 #include "Component/ModelManager.H"
00010 #include "Component/ModelComponent.H"
00011 #include "Component/ModelOptionDef.H"
00012 #include "Robots/BeoHawk/gui/VisionGUI.qt.H"
00013 #include <Ice/Ice.h>
00014 #include <Ice/Service.h>
00015 #include "Ice/RobotSimEvents.ice.H"
00016 #include "Ice/RobotBrainObjects.ice.H"
00017 #include "Ice/SimEventsUtils.H"
00018 #include "Ice/IceImageUtils.H"
00019 
00020 
00021 class VisionGUIService : public Ice::Service {
00022 protected:
00023         virtual bool start(int, char * argv[]);
00024         virtual bool stop() {
00025                 if (itsMgr)
00026                         delete itsMgr;
00027                 return true;
00028         }
00029 
00030 private:
00031         Ice::ObjectAdapterPtr itsAdapter;
00032         ModelManager *itsMgr;
00033 };
00034 
00035 
00036 bool VisionGUIService::start (int argc, char * argv[]) {
00037 
00038         char adapterStr[255];
00039 
00040         int port = RobotBrainObjects::RobotBrainPort;
00041         bool connected = false;
00042         LDEBUG("Opening Connection");
00043 
00044         while (!connected) {
00045                 try {
00046                         LINFO("Trying Port: %d", port);
00047                         sprintf(adapterStr, "default -p %i", port);
00048                         itsAdapter = communicator()->createObjectAdapterWithEndpoints(
00049                                         "VisionGUI", adapterStr);
00050                         connected = true;
00051                 } catch (Ice::SocketException) {
00052                         port++;
00053                 }
00054         }
00055 
00056         itsMgr = new ModelManager("VisionGUIService");
00057 
00058         LINFO("Creating VisionGUI");
00059         QApplication gui(argc, argv);
00060         nub::ref<VisionGUI> ret (new VisionGUI(*itsMgr, "VisionGUI", "VisionGUI"));
00061         LINFO("VisionGUI Created");
00062         itsMgr->addSubComponent(ret);
00063         ret->init(communicator(), itsAdapter);
00064 
00065         itsMgr->parseCommandLine((const int) argc, (const char **) argv, "", 0, 0);
00066         itsAdapter->activate();
00067         itsMgr->start();
00068 
00069         //load up the vision gui
00070         LINFO("VisionGUI Initialized");
00071         ret->show();
00072         gui.connect(&gui, SIGNAL(lastWindowClosed()), &gui, SLOT(quit()));
00073 
00074         return gui.exec();
00075 }
00076 
00077 
00078 int main (int argc, char ** argv) {
00079         VisionGUIService svc;
00080         return svc.main(argc, argv);
00081         return 0;
00082 }
Generated on Sun May 8 08:05:39 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3