Go to the documentation of this file.00001
00008
00009
00010
00011
00012 #include <QtGui>
00013 #include <QMessageBox>
00014 #include <iostream>
00015 #include "../include/tibi_dabo_gui/main_window_dabo_coop.hpp"
00016
00017
00018
00019
00020
00021 namespace tibi_dabo_gui {
00022
00023 using namespace Qt;
00024
00025
00026
00027
00028
00029 MainWindow::MainWindow(int argc, char** argv, QWidget *parent)
00030 : QMainWindow(parent)
00031 , qnode(argc,argv)
00032 {
00033 ui.setupUi(this);
00034 QObject::connect(ui.actionAbout_Qt, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt()));
00035
00036 ReadSettings();
00037 setWindowIcon(QIcon(":/images/logos/iri.png"));
00038 ui.tab_manager->setCurrentIndex(0);
00039 QObject::connect(&qnode, SIGNAL(rosShutdown()), this, SLOT(close()));
00040
00041 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
00042 this->loadTexts();
00043 this->currentGoalIndex=0;
00044
00045
00046
00047
00048 this->qnode.initialize();
00049
00050 this->setLanguage(1);
00051 ui.label_goal->setStyleSheet("");
00052 ui.button_demo_exit->setEnabled(false);
00053
00054
00055
00056
00057 qApp->setOverrideCursor(QCursor(Qt::ArrowCursor));
00058
00059 QTimer *timer = new QTimer(this);
00060 connect(timer, SIGNAL(timeout()), this, SLOT(timerDone()));
00061 timer->start(1000);
00062 }
00063
00064 MainWindow::~MainWindow() {}
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 void MainWindow::on_button_cat_clicked(bool check)
00075 {
00076 this->setLanguage(0);
00077 }
00078
00079 void MainWindow::on_button_eng_clicked(bool check)
00080 {
00081 this->setLanguage(1);
00082 }
00083
00084 void MainWindow::on_button_esp_clicked(bool check)
00085 {
00086 this->setLanguage(2);
00087 }
00088
00089 void MainWindow::on_button_demo_exit_clicked(bool check)
00090 {
00091 std::cout << "exit clicked" << std::endl;
00092 this->qnode.exit();
00093 ui.button_demo_exit->setEnabled(false);
00094 }
00095
00096
00097
00098
00099
00100
00107 void MainWindow::timerDone()
00108 {
00109 std::string goal;
00110 if(this->qnode.getGoal(goal))
00111 {
00112 if(goal=="monument")
00113 {
00114 this->currentGoalIndex=1;
00115 ui.label_goal->setStyleSheet("QLabel { image: url(:/images/goals/monument.png); image-position: left; }");
00116 }
00117 else if(goal=="bakery")
00118 {
00119 this->currentGoalIndex=2;
00120 ui.label_goal->setStyleSheet("QLabel { image: url(:/images/goals/bakery.png); image-position: left; }");
00121 }
00122 else if(goal=="kiosk")
00123 {
00124 this->currentGoalIndex=3;
00125 ui.label_goal->setStyleSheet("QLabel { image: url(:/images/goals/kiosk.ico); image-position: left; }");
00126 }
00127 else
00128 {
00129 this->currentGoalIndex=0;
00130 ui.label_goal->setStyleSheet("");
00131 }
00132 ui.label_goal->setText(this->goals[this->currentGoalIndex][this->lastLanguage].c_str());
00133 ui.button_demo_exit->setEnabled(true);
00134 }
00135
00136 double sentence_id;
00137 if(this->qnode.getSentence(sentence_id))
00138 {
00139 ui.label_goal->setText(this->sentences[sentence_id][this->lastLanguage].c_str());
00140 }
00141 }
00142
00143 void MainWindow::setLanguage(int index)
00144 {
00145 if(index!=this->lastLanguage)
00146 {
00147 for(unsigned int i=0; i<this->tabs.size(); i++)
00148 {
00149 ui.tab_manager->setTabText(i, this->tabs[i][index].c_str());
00150 }
00151 ui.label_info_title->setText(this->info[0][index].c_str());
00152 ui.label_info_1->setText(this->info[1][index].c_str());
00153 ui.label_info_2->setText(this->info[2][index].c_str());
00154 ui.label_info_3->setText(this->info[3][index].c_str());
00155 ui.label_info_4->setText(this->info[4][index].c_str());
00156 ui.label_info_5->setText(this->info[5][index].c_str());
00157 ui.label_info_title_2->setText(this->info[6][index].c_str());
00158 ui.label_info_6->setText(this->info[7][index].c_str());
00159 ui.label_info_7->setText(this->info[8][index].c_str());
00160 ui.label_info_8->setText(this->info[9][index].c_str());
00161 ui.label_info_9->setText(this->info[10][index].c_str());
00162 ui.label_info_10->setText(this->info[11][index].c_str());
00163
00164 ui.label_demo->setText(this->goals[4][index].c_str());
00165 ui.label_goal->setText(this->goals[this->currentGoalIndex][index].c_str());
00166
00167 if(index==0)
00168 {
00169 std::cout << "Setting language to Catalan" << std::endl;
00170 ui.button_cat->setIcon(QIcon(":/images/lang/cat.png"));
00171 ui.button_eng->setIcon(QIcon(":/images/lang/eng_bw.png"));
00172 ui.button_esp->setIcon(QIcon(":/images/lang/esp_bw.png"));
00173 }
00174 else if(index==1)
00175 {
00176 std::cout << "Setting language to English" << std::endl;
00177 ui.button_cat->setIcon(QIcon(":/images/lang/cat_bw.png"));
00178 ui.button_eng->setIcon(QIcon(":/images/lang/eng.png"));
00179 ui.button_esp->setIcon(QIcon(":/images/lang/esp_bw.png"));
00180 }
00181 else if(index==2)
00182 {
00183 std::cout << "Setting language to Spanish" << std::endl;
00184 ui.button_cat->setIcon(QIcon(":/images/lang/cat_bw.png"));
00185 ui.button_eng->setIcon(QIcon(":/images/lang/eng_bw.png"));
00186 ui.button_esp->setIcon(QIcon(":/images/lang/esp.png"));
00187 }
00188
00189 this->lastLanguage=index;
00190 }
00191 }
00192
00193 void MainWindow::getGoals()
00194 {
00195 std::vector<std::string>locations;
00196 if(this->qnode.getLocations(locations))
00197 {
00198
00199 std::cout << "Locations ("<< locations.size() << "): ";
00200 for(unsigned int i=0; i<locations.size(); i++)
00201 {
00202 std::cout << locations[i] << " ";
00203 }
00204 std::cout << std::endl;
00205 }
00206 }
00207
00208 void MainWindow::loadTexts()
00209 {
00210 std::vector<std::string> tab;
00211 tab.push_back("Demo");
00212 tab.push_back("Demo");
00213 tab.push_back("Demo");
00214 this->tabs.push_back(tab);
00215 tab.clear();
00216 tab.push_back("Info");
00217 tab.push_back("Info");
00218 tab.push_back("Info");
00219 this->tabs.push_back(tab);
00220 tab.clear();
00221 tab.push_back("Sobre");
00222 tab.push_back("About");
00223 tab.push_back("Acerca de");
00224 this->tabs.push_back(tab);
00225 tab.clear();
00226
00227 std::vector<std::string> text;
00228 text.push_back("<b>Tibi i Dabo</b>");
00229 text.push_back("<b>Tibi and Dabo<b>");
00230 text.push_back("<b>Tibi y Dabo<b>");
00231 this->info.push_back(text);
00232 text.clear();
00233 text.push_back("- Robots socials i urbans.");
00234 text.push_back("- Social and urban robots.");
00235 text.push_back("- Robots sociales y urbanos");
00236 this->info.push_back(text);
00237 text.clear();
00238 text.push_back("- Plataforma <i><b>Segway rmp200</i></b> per navegació en entorns urbans.");
00239 text.push_back("- <i><b>Segway rmp200</i></b> platform for navigation in urban environments.");
00240 text.push_back("- Plataforma <i><b>Segway rmp200</i></b> para navegación en entornos urbanos.");
00241 this->info.push_back(text);
00242 text.clear();
00243 text.push_back("- Sensors de rang làser <i><b>Hokuyo</i></b> per localització i detecció d'obstacles.");
00244 text.push_back("- <i><b>Hokuyo</i></b> range laser sensors for localization and obstacle detection.");
00245 text.push_back("- Sensores de rango láser <i><b>Hokuyo</i></b> para localización y detección de obstáculos.");
00246 this->info.push_back(text);
00247 text.clear();
00248 text.push_back("- Càmara estèreo <i><b>Bumblebee2</i></b> per visió per computador.");
00249 text.push_back("- <i><b>Bumblebee2</i></b> Stereo camera for computer visión.");
00250 text.push_back("- Cámara estéreo <i><b>Bumblebee2</i></b> para visión por computador.");
00251 this->info.push_back(text);
00252 text.clear();
00253 text.push_back("- Cap, braços, pantalla tàctil i parla per la interacció humà robot");
00254 text.push_back("- Head, arms, touch screen and speech for human robot interaction.");
00255 text.push_back("- Cabeza, brazos, pantalla táctil y habla para la interacción humano robot.");
00256 this->info.push_back(text);
00257 text.clear();
00258 text.push_back("<b>Cotxe</b>");
00259 text.push_back("<b>Car</b>");
00260 text.push_back("<b>Coche</b>");
00261 this->info.push_back(text);
00262 text.clear();
00263 text.push_back("- Vehicle de transport autònom.");
00264 text.push_back("- Autonomous transport vehicle.");
00265 text.push_back("- Vehículo de transporte autónomo.");
00266 this->info.push_back(text);
00267 text.clear();
00268 text.push_back("- Plataforma Ackerman tipus cotxe.");
00269 text.push_back("- Ackerman car-like platform.");
00270 text.push_back("- Plataforma Ackerman tipo coche");
00271 this->info.push_back(text);
00272 text.clear();
00273 text.push_back("- Sensors de rang làser: parada de seguretat, detecció d'obstacles i localització.");
00274 text.push_back("- Range laser sensors: security stop, obstacle detection and localization.");
00275 text.push_back("- Sensores de rango láser para parada de seguridad, detección de obstáculos y localización.");
00276 this->info.push_back(text);
00277 text.clear();
00278 text.push_back("- Làser 3D Velodyne i Càmara 360º Ladybug: percepció de l'entorn.");
00279 text.push_back("- 3D laser Velodyne and 360 camera Ladybug: environment perception.");
00280 text.push_back("- Láser 3D Velodyne i cámara 360º Ladybug: percepción del entorno.");
00281 this->info.push_back(text);
00282 text.clear();
00283 text.push_back("- Pantalla tàctil: interacció amb passatgers.");
00284 text.push_back("- Touchscreen: passengers interaction.");
00285 text.push_back("- Pantalla táctil: interacción con pasajeros.");
00286 this->info.push_back(text);
00287 text.clear();
00288
00289 std::vector<std::string> goal;
00290 goal.push_back("");
00291 goal.push_back("");
00292 goal.push_back("");
00293 this->goals.push_back(goal);
00294 goal.clear();
00295 goal.push_back("Monument");
00296 goal.push_back("Monument");
00297 goal.push_back("Monumento");
00298 this->goals.push_back(goal);
00299 goal.clear();
00300 goal.push_back("Forn de pa");
00301 goal.push_back("Bakery");
00302 goal.push_back("Panadería");
00303 this->goals.push_back(goal);
00304 goal.clear();
00305 goal.push_back("Quiosc");
00306 goal.push_back("Kiosk");
00307 goal.push_back("Quiosco");
00308 this->goals.push_back(goal);
00309 goal.clear();
00310 goal.push_back("Benvingut al:");
00311 goal.push_back("Welcome to the:");
00312 goal.push_back("Bienvenido a:");
00313 this->goals.push_back(goal);
00314 goal.clear();
00315
00316 std::vector<std::string> sentence;
00317 sentence.push_back("Benvingut al:");
00318 sentence.push_back("Welcome to the:");
00319 sentence.push_back("Bienvenido a:");
00320 this->sentences.push_back(sentence);
00321 sentence.clear();
00322 sentence.push_back("Segueix-me fins a la sortida.");
00323 sentence.push_back("Follow me towards the exit.");
00324 sentence.push_back("Sígueme hasta la salida");
00325 this->sentences.push_back(sentence);
00326 sentence.clear();
00327 sentence.push_back("Adeu!");
00328 sentence.push_back("Good bye!");
00329 sentence.push_back("Adios!");
00330 this->sentences.push_back(sentence);
00331 sentence.clear();
00332
00333 }
00334
00335
00336
00337
00338
00339 void MainWindow::on_actionAbout_triggered() {
00340 QMessageBox::about(this, tr("About ..."),tr("<h2>Tibi Dabo Gui</h2><p>Copyright IRI</p><p>Graphic User Interface for Tibi Dabo robots.</p>"));
00341 }
00342
00343
00344
00345
00346
00347 void MainWindow::ReadSettings() {
00348 QSettings settings("Qt-Ros Package", "tibi_dabo_gui");
00349 restoreGeometry(settings.value("geometry").toByteArray());
00350 restoreState(settings.value("windowState").toByteArray());
00351 }
00352
00353 void MainWindow::WriteSettings() {
00354 QSettings settings("Qt-Ros Package", "tibi_dabo_gui");
00355 settings.setValue("geometry", saveGeometry());
00356 settings.setValue("windowState", saveState());
00357 }
00358
00359 void MainWindow::closeEvent(QCloseEvent *event)
00360 {
00361 WriteSettings();
00362 QMainWindow::closeEvent(event);
00363 }
00364
00365 }
00366