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_tibi_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
00044
00045
00046
00047 this->qnode.initialize();
00048
00049 this->setLanguage(1);
00050
00051
00052
00053
00054 qApp->setOverrideCursor(QCursor(Qt::ArrowCursor));
00055
00056 QTimer *timer = new QTimer(this);
00057 connect(timer, SIGNAL(timeout()), this, SLOT(timerDone()));
00058 timer->start(1000);
00059 }
00060
00061 MainWindow::~MainWindow() {}
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 void MainWindow::on_button_cat_clicked(bool check)
00072 {
00073 this->setLanguage(0);
00074 }
00075
00076 void MainWindow::on_button_eng_clicked(bool check)
00077 {
00078 this->setLanguage(1);
00079 }
00080
00081 void MainWindow::on_button_esp_clicked(bool check)
00082 {
00083 this->setLanguage(2);
00084 }
00085
00086 void MainWindow::on_button_goal_1_clicked(bool check)
00087 {
00088 std::cout << "goal 1 clicked" << std::endl;
00089 this->qnode.askGoal("monument");
00090 ui.button_goal_2->setEnabled(false);
00091 ui.button_goal_3->setEnabled(false);
00092 }
00093
00094 void MainWindow::on_button_goal_2_clicked(bool check)
00095 {
00096 std::cout << "goal 2 clicked" << std::endl;
00097 this->qnode.askGoal("bakery");
00098 ui.button_goal_1->setEnabled(false);
00099 ui.button_goal_3->setEnabled(false);
00100 }
00101
00102 void MainWindow::on_button_goal_3_clicked(bool check)
00103 {
00104 std::cout << "goal 3 clicked" << std::endl;
00105 this->qnode.askGoal("kiosk");
00106 ui.button_goal_1->setEnabled(false);
00107 ui.button_goal_2->setEnabled(false);
00108 }
00109
00110
00111
00112
00113
00119 void MainWindow::timerDone()
00120 {
00121 if(!this->qnode.guiActionActive())
00122 {
00123 ui.button_goal_1->setEnabled(true);
00124 ui.button_goal_2->setEnabled(true);
00125 ui.button_goal_3->setEnabled(true);
00126 }
00127 }
00128
00129 void MainWindow::setLanguage(int index)
00130 {
00131 if(index!=this->lastLanguage)
00132 {
00133 for(unsigned int i=0; i<this->tabs.size(); i++)
00134 {
00135 ui.tab_manager->setTabText(i, this->tabs[i][index].c_str());
00136 }
00137 ui.label_info_title->setText(this->info[0][index].c_str());
00138 ui.label_info_1->setText(this->info[1][index].c_str());
00139 ui.label_info_2->setText(this->info[2][index].c_str());
00140 ui.label_info_3->setText(this->info[3][index].c_str());
00141 ui.label_info_4->setText(this->info[4][index].c_str());
00142 ui.label_info_5->setText(this->info[5][index].c_str());
00143 ui.label_info_title_2->setText(this->info[6][index].c_str());
00144 ui.label_info_6->setText(this->info[7][index].c_str());
00145 ui.label_info_7->setText(this->info[8][index].c_str());
00146 ui.label_info_8->setText(this->info[9][index].c_str());
00147 ui.label_info_9->setText(this->info[10][index].c_str());
00148 ui.label_info_10->setText(this->info[11][index].c_str());
00149
00150 ui.button_goal_1->setText(this->goals[0][index].c_str());
00151 ui.button_goal_2->setText(this->goals[1][index].c_str());
00152 ui.button_goal_3->setText(this->goals[2][index].c_str());
00153 ui.label_demo->setText(this->goals[3][index].c_str());
00154
00155 if(index==0)
00156 {
00157 std::cout << "Setting language to Catalan" << std::endl;
00158 ui.button_cat->setIcon(QIcon(":/images/lang/cat.png"));
00159 ui.button_eng->setIcon(QIcon(":/images/lang/eng_bw.png"));
00160 ui.button_esp->setIcon(QIcon(":/images/lang/esp_bw.png"));
00161 }
00162 else if(index==1)
00163 {
00164 std::cout << "Setting language to English" << std::endl;
00165 ui.button_cat->setIcon(QIcon(":/images/lang/cat_bw.png"));
00166 ui.button_eng->setIcon(QIcon(":/images/lang/eng.png"));
00167 ui.button_esp->setIcon(QIcon(":/images/lang/esp_bw.png"));
00168 }
00169 else if(index==2)
00170 {
00171 std::cout << "Setting language to Spanish" << std::endl;
00172 ui.button_cat->setIcon(QIcon(":/images/lang/cat_bw.png"));
00173 ui.button_eng->setIcon(QIcon(":/images/lang/eng_bw.png"));
00174 ui.button_esp->setIcon(QIcon(":/images/lang/esp.png"));
00175 }
00176
00177 this->lastLanguage=index;
00178 }
00179 }
00180
00181 void MainWindow::getGoals()
00182 {
00183 std::vector<std::string>locations;
00184 if(this->qnode.getLocations(locations))
00185 {
00186
00187 std::cout << "Locations ("<< locations.size() << "): ";
00188 for(unsigned int i=0; i<locations.size(); i++)
00189 {
00190 std::cout << locations[i] << " ";
00191 }
00192 std::cout << std::endl;
00193 }
00194 }
00195
00196 void MainWindow::loadTexts()
00197 {
00198 std::vector<std::string> tab;
00199 tab.push_back("Demo");
00200 tab.push_back("Demo");
00201 tab.push_back("Demo");
00202 this->tabs.push_back(tab);
00203 tab.clear();
00204 tab.push_back("Info");
00205 tab.push_back("Info");
00206 tab.push_back("Info");
00207 this->tabs.push_back(tab);
00208 tab.clear();
00209 tab.push_back("Sobre");
00210 tab.push_back("About");
00211 tab.push_back("Acerca de");
00212 this->tabs.push_back(tab);
00213 tab.clear();
00214
00215 std::vector<std::string> text;
00216 text.push_back("<b>Tibi i Dabo</b>");
00217 text.push_back("<b>Tibi and Dabo<b>");
00218 text.push_back("<b>Tibi y Dabo<b>");
00219 this->info.push_back(text);
00220 text.clear();
00221 text.push_back("- Robots socials i urbans.");
00222 text.push_back("- Social and urban robots.");
00223 text.push_back("- Robots sociales y urbanos");
00224 this->info.push_back(text);
00225 text.clear();
00226 text.push_back("- Plataforma <i><b>Segway rmp200</i></b> per navegació en entorns urbans.");
00227 text.push_back("- <i><b>Segway rmp200</i></b> platform for navigation in urban environments.");
00228 text.push_back("- Plataforma <i><b>Segway rmp200</i></b> para navegación en entornos urbanos.");
00229 this->info.push_back(text);
00230 text.clear();
00231 text.push_back("- Sensors de rang làser <i><b>Hokuyo</i></b> per localització i detecció d'obstacles.");
00232 text.push_back("- <i><b>Hokuyo</i></b> range laser sensors for localization and obstacle detection.");
00233 text.push_back("- Sensores de rango láser <i><b>Hokuyo</i></b> para localización y detección de obstáculos.");
00234 this->info.push_back(text);
00235 text.clear();
00236 text.push_back("- Càmara estèreo <i><b>Bumblebee2</i></b> per visió per computador.");
00237 text.push_back("- <i><b>Bumblebee2</i></b> Stereo camera for computer visión.");
00238 text.push_back("- Cámara estéreo <i><b>Bumblebee2</i></b> para visión por computador.");
00239 this->info.push_back(text);
00240 text.clear();
00241 text.push_back("- Cap, braços, pantalla tàctil i parla per la interacció humà robot");
00242 text.push_back("- Head, arms, touch screen and speech for human robot interaction.");
00243 text.push_back("- Cabeza, brazos, pantalla táctil y habla para la interacción humano robot.");
00244 this->info.push_back(text);
00245 text.clear();
00246 text.push_back("<b>Cotxe</b>");
00247 text.push_back("<b>Car</b>");
00248 text.push_back("<b>Coche</b>");
00249 this->info.push_back(text);
00250 text.clear();
00251 text.push_back("- Vehicle de transport autònom.");
00252 text.push_back("- Autonomous transport vehicle.");
00253 text.push_back("- Vehículo de transporte autónomo.");
00254 this->info.push_back(text);
00255 text.clear();
00256 text.push_back("- Plataforma Ackerman tipus cotxe.");
00257 text.push_back("- Ackerman car-like platform.");
00258 text.push_back("- Plataforma Ackerman tipo coche");
00259 this->info.push_back(text);
00260 text.clear();
00261 text.push_back("- Sensors de rang làser: parada de seguretat, detecció d'obstacles i localització.");
00262 text.push_back("- Range laser sensors: security stop, obstacle detection and localization.");
00263 text.push_back("- Sensores de rango láser para parada de seguridad, detección de obstáculos y localización.");
00264 this->info.push_back(text);
00265 text.clear();
00266 text.push_back("- Làser 3D Velodyne i Càmara 360º Ladybug: percepció de l'entorn.");
00267 text.push_back("- 3D laser Velodyne and 360 camera Ladybug: environment perception.");
00268 text.push_back("- Láser 3D Velodyne i cámara 360º Ladybug: percepción del entorno.");
00269 this->info.push_back(text);
00270 text.clear();
00271 text.push_back("- Pantalla tàctil: interacció amb passatgers.");
00272 text.push_back("- Touchscreen: passengers interaction.");
00273 text.push_back("- Pantalla táctil: interacción con pasajeros.");
00274 this->info.push_back(text);
00275 text.clear();
00276
00277 std::vector<std::string> goal;
00278 goal.push_back("Monument");
00279 goal.push_back("Monument");
00280 goal.push_back("Monumento");
00281 this->goals.push_back(goal);
00282 goal.clear();
00283 goal.push_back("Forn de pa");
00284 goal.push_back("Bakery");
00285 goal.push_back("Panadería");
00286 this->goals.push_back(goal);
00287 goal.clear();
00288 goal.push_back("Quiosc");
00289 goal.push_back("Kiosk");
00290 goal.push_back("Quiosco");
00291 this->goals.push_back(goal);
00292 goal.clear();
00293 goal.push_back("On vols anar?");
00294 goal.push_back("Where do you want to go?");
00295 goal.push_back("¿A dónde quieres ir?");
00296 this->goals.push_back(goal);
00297 goal.clear();
00298 }
00299
00300
00301
00302
00303
00304 void MainWindow::on_actionAbout_triggered() {
00305 QMessageBox::about(this, tr("About ..."),tr("<h2>Tibi Dabo Gui</h2><p>Copyright IRI</p><p>Graphic User Interface for Tibi Dabo robots.</p>"));
00306 }
00307
00308
00309
00310
00311
00312 void MainWindow::ReadSettings() {
00313 QSettings settings("Qt-Ros Package", "tibi_dabo_gui");
00314 restoreGeometry(settings.value("geometry").toByteArray());
00315 restoreState(settings.value("windowState").toByteArray());
00316 }
00317
00318 void MainWindow::WriteSettings() {
00319 QSettings settings("Qt-Ros Package", "tibi_dabo_gui");
00320 settings.setValue("geometry", saveGeometry());
00321 settings.setValue("windowState", saveState());
00322 }
00323
00324 void MainWindow::closeEvent(QCloseEvent *event)
00325 {
00326 WriteSettings();
00327 QMainWindow::closeEvent(event);
00328 }
00329
00330
00331 }
00332