test-SeaBee3GUI.cpp
00001 #include "Component/ModelManager.H"
00002 #include <Ice/Ice.h>
00003 #include <Ice/Service.h>
00004 #include "Image/CutPaste.H"
00005 #include "Image/Image.H"
00006 #include "Image/Pixels.H"
00007 #include "Media/FrameSeries.H"
00008 #include <qapplication.h>
00009 #include "Qt/SeaBee3GUIIce.H"
00010 #include "Qt/ui/SeaBee3GUI2.h"
00011 #include "Raster/Raster.H"
00012 #include "Robots/SeaBeeIII/XBox360RemoteControlI.H"
00013 #include "Transport/FrameIstream.H"
00014
00015 class SeaBee3GUIService : public Ice::Service {
00016 protected:
00017 virtual bool start(int, char* argv[]);
00018 virtual bool stop() {
00019 if (itsMgr)
00020 delete itsMgr;
00021 return true;
00022 }
00023
00024 private:
00025 Ice::ObjectAdapterPtr itsAdapter;
00026 ModelManager *itsMgr;
00027 };
00028
00029 bool SeaBee3GUIService::start( int argc, char ** argv )
00030 {
00031 QApplication a( argc, argv );
00032
00033 itsMgr = new ModelManager("SeaBee3 GUI");
00034
00035
00036
00037 char adapterStr[255];
00038 LINFO("Creating Adapter");
00039 sprintf(adapterStr, "default -p %i", 12345);
00040 itsAdapter = communicator()->createObjectAdapterWithEndpoints("RobotBrainPort",
00041 adapterStr);
00042
00043 LINFO("Initializing Main Form");
00044 SeaBee3MainDisplayForm *mainForm = new SeaBee3MainDisplayForm();
00045 mainForm->init(itsMgr);
00046
00047 LINFO("Creating Communicator");
00048 nub::soft_ref<SeaBee3GUIIce> GUIComm(new SeaBee3GUIIce(*itsMgr, "SeaBee3GUIIce", "SeaBee3GUIIce"));
00049 itsMgr->addSubComponent(GUIComm);
00050
00051 LINFO("Registering GUI With GUICommunicator");
00052 GUIComm->registerGUI(mainForm);
00053
00054 LINFO("Registering Communicator with GUI");
00055 mainForm->registerCommunicator(GUIComm);
00056
00057 LINFO("Starting Up GUI Comm");
00058 GUIComm->init(communicator(), itsAdapter);
00059
00060 LINFO("Starting XBox360RemoteControl");
00061 nub::soft_ref<XBox360RemoteControlI> xbox360remote(new XBox360RemoteControlI(0,*itsMgr, "XBox360RemoteControl", "XBox360RemoteControl"));
00062
00063 LINFO("XBox360RemoteControl Created");
00064 itsMgr->addSubComponent(xbox360remote);
00065
00066 LINFO("XBox360RemoteControl Added As Sub Component");
00067 xbox360remote->init(communicator(), itsAdapter);
00068
00069 LINFO("XBox360RemoteControl Inited");
00070
00071
00072
00073 if (itsMgr->parseCommandLine(argc, argv, "", 0, 0) == false) return(1);
00074
00075 itsAdapter->activate();
00076
00077 LINFO("Starting Manager");
00078 itsMgr->start();
00079
00080 LINFO("Showing Main Form");
00081 mainForm->show();
00082
00083 LINFO("Waiting for Main Form to exit");
00084 a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
00085
00086 int retval = a.exec();
00087
00088 itsMgr->stop();
00089
00090 return retval;
00091
00092 }
00093
00094
00095 int main(int argc, char** argv) {
00096
00097 SeaBee3GUIService svc;
00098 return svc.main(argc, argv);
00099 }
00100