iCub-main
main.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 RobotCub Consortium
3  * Author: Alessandro Scalzo alessandro.scalzo@iit.it
4  * CopyPolicy: Released under the terms of the GNU GPL v2.0.
5  *
6  * Based on:
7  *
8  * Qavimator
9  * Copyright (C) 2006 by Zi Ree *
10  * Zi Ree @ SecondLife *
11  * Released under the terms of the GNU GPL v2.0.
12  */
13 
120 #include <signal.h>
121 
122 #include "qavimator.h"
123 #include <QApplication>
124 
125 #include <yarp/os/ResourceFinder.h>
126 #include <yarp/os/Network.h>
127 #ifdef USE_ICUB_MOD
128 #include "drivers.h"
129 #endif
130 
131 qavimator* mw=NULL;
132 
133 std::string GUI_NAME("/iCubGui");
134 
135 void sig_handler(int sig)
136 {
137  if (mw) mw->fileExit();
138 }
139 
140 int main(int argc, char *argv[])
141 {
142  yarp::os::Network yarp; //initialize network, this goes before everything
143 
144 #ifdef USE_ICUB_MOD
145  yarp::dev::DriverCollection dev;
146 #endif
147 
148 #ifndef WIN32
149  signal(SIGINT,sig_handler);
150  signal(SIGTERM,sig_handler);
151  signal(SIGHUP,sig_handler);
152 #endif
153 
154  yarp::os::ResourceFinder rf;
155  rf.setDefaultContext("iCubGui");
156  rf.setDefaultConfigFile("iCubGui.ini");
157  rf.configure(argc,argv);
158 
159  QApplication a(argc, argv);
160 
161  mw = new qavimator(rf);
162  mw->show();
163  a.connect(&a,SIGNAL(lastWindowClosed()),&a,SLOT(quit()));
164  int ret = a.exec();
165 
166  if(mw){
167  delete mw;
168  }
169  return (ret!=0?1:0);
170 }
void fileExit()
Definition: qavimator.cpp:180
int main(int argc, char *argv[])
Definition: main.cpp:31
std::string GUI_NAME("/iCubGui")
void sig_handler(int sig)
Definition: main.cpp:135
qavimator * mw
Definition: main.cpp:131
Copyright (C) 2008 RobotCub Consortium.