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_car_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_go->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_go_clicked(bool check)
00090 {
00091 std::cout << "go clicked" << std::endl;
00092 this->qnode.go();
00093 ui.button_demo_go->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_go->setEnabled(true);
00134 }
00135 }
00136
00137 void MainWindow::setLanguage(int index)
00138 {
00139 if(index!=this->lastLanguage)
00140 {
00141 for(unsigned int i=0; i<this->tabs.size(); i++)
00142 {
00143 ui.tab_manager->setTabText(i, this->tabs[i][index].c_str());
00144 }
00145 ui.label_info_title->setText(this->info[0][index].c_str());
00146 ui.label_info_1->setText(this->info[1][index].c_str());
00147 ui.label_info_2->setText(this->info[2][index].c_str());
00148 ui.label_info_3->setText(this->info[3][index].c_str());
00149 ui.label_info_4->setText(this->info[4][index].c_str());
00150 ui.label_info_5->setText(this->info[5][index].c_str());
00151 ui.label_info_title_2->setText(this->info[6][index].c_str());
00152 ui.label_info_6->setText(this->info[7][index].c_str());
00153 ui.label_info_7->setText(this->info[8][index].c_str());
00154 ui.label_info_8->setText(this->info[9][index].c_str());
00155 ui.label_info_9->setText(this->info[10][index].c_str());
00156 ui.label_info_10->setText(this->info[11][index].c_str());
00157
00158 ui.label_demo->setText(this->goals[4][index].c_str());
00159 ui.label_demo_2->setText(this->goals[5][index].c_str());
00160 ui.label_goal->setText(this->goals[this->currentGoalIndex][index].c_str());
00161
00162
00163 if(index==0)
00164 {
00165 std::cout << "Setting language to Catalan" << std::endl;
00166 ui.button_cat->setIcon(QIcon(":/images/lang/cat.png"));
00167 ui.button_eng->setIcon(QIcon(":/images/lang/eng_bw.png"));
00168 ui.button_esp->setIcon(QIcon(":/images/lang/esp_bw.png"));
00169 }
00170 else if(index==1)
00171 {
00172 std::cout << "Setting language to English" << std::endl;
00173 ui.button_cat->setIcon(QIcon(":/images/lang/cat_bw.png"));
00174 ui.button_eng->setIcon(QIcon(":/images/lang/eng.png"));
00175 ui.button_esp->setIcon(QIcon(":/images/lang/esp_bw.png"));
00176 }
00177 else if(index==2)
00178 {
00179 std::cout << "Setting language to Spanish" << std::endl;
00180 ui.button_cat->setIcon(QIcon(":/images/lang/cat_bw.png"));
00181 ui.button_eng->setIcon(QIcon(":/images/lang/eng_bw.png"));
00182 ui.button_esp->setIcon(QIcon(":/images/lang/esp.png"));
00183 }
00184
00185 this->lastLanguage=index;
00186 }
00187 }
00188
00189 void MainWindow::getGoals()
00190 {
00191 std::vector<std::string>locations;
00192 if(this->qnode.getLocations(locations))
00193 {
00194
00195 std::cout << "Locations ("<< locations.size() << "): ";
00196 for(unsigned int i=0; i<locations.size(); i++)
00197 {
00198 std::cout << locations[i] << " ";
00199 }
00200 std::cout << std::endl;
00201 }
00202 }
00203
00204 void MainWindow::loadTexts()
00205 {
00206 std::vector<std::string> tab;
00207 tab.push_back("Demo");
00208 tab.push_back("Demo");
00209 tab.push_back("Demo");
00210 this->tabs.push_back(tab);
00211 tab.clear();
00212 tab.push_back("Info");
00213 tab.push_back("Info");
00214 tab.push_back("Info");
00215 this->tabs.push_back(tab);
00216 tab.clear();
00217 tab.push_back("Sobre");
00218 tab.push_back("About");
00219 tab.push_back("Acerca de");
00220 this->tabs.push_back(tab);
00221 tab.clear();
00222
00223 std::vector<std::string> text;
00224 text.push_back("<b>Tibi i Dabo</b>");
00225 text.push_back("<b>Tibi and Dabo<b>");
00226 text.push_back("<b>Tibi y Dabo<b>");
00227 this->info.push_back(text);
00228 text.clear();
00229 text.push_back("- Robots socials i urbans.");
00230 text.push_back("- Social and urban robots.");
00231 text.push_back("- Robots sociales y urbanos");
00232 this->info.push_back(text);
00233 text.clear();
00234 text.push_back("- Plataforma <i><b>Segway rmp200</i></b> per navegació en entorns urbans.");
00235 text.push_back("- <i><b>Segway rmp200</i></b> platform for navigation in urban environments.");
00236 text.push_back("- Plataforma <i><b>Segway rmp200</i></b> para navegación en entornos urbanos.");
00237 this->info.push_back(text);
00238 text.clear();
00239 text.push_back("- Sensors de rang làser <i><b>Hokuyo</i></b> per localització i detecció d'obstacles.");
00240 text.push_back("- <i><b>Hokuyo</i></b> range laser sensors for localization and obstacle detection.");
00241 text.push_back("- Sensores de rango láser <i><b>Hokuyo</i></b> para localización y detección de obstáculos.");
00242 this->info.push_back(text);
00243 text.clear();
00244 text.push_back("- Càmara estèreo <i><b>Bumblebee2</i></b> per visió per computador.");
00245 text.push_back("- <i><b>Bumblebee2</i></b> Stereo camera for computer visión.");
00246 text.push_back("- Cámara estéreo <i><b>Bumblebee2</i></b> para visión por computador.");
00247 this->info.push_back(text);
00248 text.clear();
00249 text.push_back("- Cap, braços, pantalla tàctil i parla per la interacció humà robot");
00250 text.push_back("- Head, arms, touch screen and speech for human robot interaction.");
00251 text.push_back("- Cabeza, brazos, pantalla táctil y habla para la interacción humano robot.");
00252 this->info.push_back(text);
00253 text.clear();
00254 text.push_back("<b>Cotxe</b>");
00255 text.push_back("<b>Car</b>");
00256 text.push_back("<b>Coche</b>");
00257 this->info.push_back(text);
00258 text.clear();
00259 text.push_back("- Vehicle de transport autònom.");
00260 text.push_back("- Autonomous transport vehicle.");
00261 text.push_back("- Vehículo de transporte autónomo.");
00262 this->info.push_back(text);
00263 text.clear();
00264 text.push_back("- Plataforma Ackerman tipus cotxe.");
00265 text.push_back("- Ackerman car-like platform.");
00266 text.push_back("- Plataforma Ackerman tipo coche");
00267 this->info.push_back(text);
00268 text.clear();
00269 text.push_back("- Sensors de rang làser: parada de seguretat, detecció d'obstacles i localització.");
00270 text.push_back("- Range laser sensors: security stop, obstacle detection and localization.");
00271 text.push_back("- Sensores de rango láser para parada de seguridad, detección de obstáculos y localización.");
00272 this->info.push_back(text);
00273 text.clear();
00274 text.push_back("- Làser 3D Velodyne i Càmara 360º Ladybug: percepció de l'entorn.");
00275 text.push_back("- 3D laser Velodyne and 360 camera Ladybug: environment perception.");
00276 text.push_back("- Láser 3D Velodyne i cámara 360º Ladybug: percepción del entorno.");
00277 this->info.push_back(text);
00278 text.clear();
00279 text.push_back("- Pantalla tàctil: interacció amb passatgers.");
00280 text.push_back("- Touchscreen: passengers interaction.");
00281 text.push_back("- Pantalla táctil: interacción con pasajeros.");
00282 this->info.push_back(text);
00283 text.clear();
00284
00285 std::vector<std::string> goal;
00286 goal.push_back("");
00287 goal.push_back("");
00288 goal.push_back("");
00289 this->goals.push_back(goal);
00290 goal.clear();
00291 goal.push_back("Monument");
00292 goal.push_back("Monument");
00293 goal.push_back("Monumento");
00294 this->goals.push_back(goal);
00295 goal.clear();
00296 goal.push_back("Forn de pa");
00297 goal.push_back("Bakery");
00298 goal.push_back("Panadería");
00299 this->goals.push_back(goal);
00300 goal.clear();
00301 goal.push_back("Quiosc");
00302 goal.push_back("Kiosk");
00303 goal.push_back("Quiosco");
00304 this->goals.push_back(goal);
00305 goal.clear();
00306 goal.push_back("Destinació:");
00307 goal.push_back("Destination:");
00308 goal.push_back("Destino:");
00309 this->goals.push_back(goal);
00310 goal.clear();
00311 goal.push_back("Preparat?");
00312 goal.push_back("Ready?");
00313 goal.push_back("¿Preparado?");
00314 this->goals.push_back(goal);
00315 goal.clear();
00316 }
00317
00318
00319
00320
00321
00322 void MainWindow::on_actionAbout_triggered() {
00323 QMessageBox::about(this, tr("About ..."),tr("<h2>Tibi Dabo Gui</h2><p>Copyright IRI</p><p>Graphic User Interface for Tibi Dabo robots.</p>"));
00324 }
00325
00326
00327
00328
00329
00330 void MainWindow::ReadSettings() {
00331 QSettings settings("Qt-Ros Package", "tibi_dabo_gui");
00332 restoreGeometry(settings.value("geometry").toByteArray());
00333 restoreState(settings.value("windowState").toByteArray());
00334 }
00335
00336 void MainWindow::WriteSettings() {
00337 QSettings settings("Qt-Ros Package", "tibi_dabo_gui");
00338 settings.setValue("geometry", saveGeometry());
00339 settings.setValue("windowState", saveState());
00340 }
00341
00342 void MainWindow::closeEvent(QCloseEvent *event)
00343 {
00344 WriteSettings();
00345 QMainWindow::closeEvent(event);
00346 }
00347
00348 }
00349