gui_simu_simu.cpp

gehe zur Dokumentation dieser Datei
00001 #include "gui.h"
00002 
00006 void Simulation::start_simulation_clicked() {
00007 
00008    // Buttons en- und disablen (lg=lokale Ansicht; sd=externe Ansicht)
00009    this->lg->startSimulationButton->setEnabled(false);
00010    this->lg->stopSimulationButton->setEnabled(true);
00011    this->lg->resumeSimulationButton->setEnabled(false);  
00012    this->sd->startSimulationButton->setEnabled(false);
00013    this->sd->stopSimulationButton->setEnabled(true);
00014    this->sd->resumeSimulationButton->setEnabled(false);  
00015    this->debugOutput("start simulation");
00016 
00017    // Roboter in Grundposition bringen
00018    this->simuPos.setX(0);
00019    this->simuPos.setY(0);
00020 
00021    // In GUI integrierte Simulation
00022    this->lg->canvasView->setDimension (   this->lg->numRows->value(),
00023                      this->lg->numCols->value(),
00024                   this->simuPos.y()+1,
00025                   this->simuPos.x()+1
00026    );
00027 
00028    // In externen Dialog integrierte Simulation
00029    this->sd->canvasView->setDimension (   this->lg->numRows->value(),
00030                      this->lg->numCols->value(),
00031                   this->simuPos.y()+1,
00032                   this->simuPos.x()+1
00033    );
00034 
00035    // externen Dialog sichtbar machen
00036    this->sd->show();
00037 
00038    // Timer starten um automatisch in den nächsten Zustand wechseln zu können
00039    this->st->start(1000, 0);  
00040 }
00041 
00045 void Simulation::resume_simulation_clicked() {
00046    // Buttons en- und disablen
00047    this->lg->startSimulationButton->setEnabled(false);
00048    this->lg->stopSimulationButton->setEnabled(true);
00049    this->lg->resumeSimulationButton->setEnabled(false);  
00050    this->sd->startSimulationButton->setEnabled(false);
00051    this->sd->stopSimulationButton->setEnabled(true);
00052    this->sd->resumeSimulationButton->setEnabled(false);
00053    // Timer starten um automatisch in den nächsten Zustand zu wechseln
00054    this->st->start(1000, 0);  
00055 }
00056 
00060 void Simulation::stop_simulation_clicked() {
00061    this->debugOutput("stop simulation");
00062    this->st->stop();
00063    this->lg->startSimulationButton->setEnabled(true);
00064    this->lg->stopSimulationButton->setEnabled(false);
00065    this->lg->resumeSimulationButton->setEnabled(true);   
00066    this->sd->startSimulationButton->setEnabled(true);
00067    this->sd->stopSimulationButton->setEnabled(false);
00068    this->sd->resumeSimulationButton->setEnabled(true);
00069 }
00070 
00074 void Simulation::simulationWalk() {
00075 
00076    //Thread während der Operation anhalten
00077    this->st->stop();
00078 
00079    // Aktuelle Position steht in this->simuPos
00080    // Neue Position steht in this->simuPosNeu
00081    if (this->action[simuPos.y()][simuPos.x()] == UP) {
00082       this->simuPosNew.setX( this->simuPos.x());
00083       this->simuPosNew.setY( this->simuPos.y() -1 );
00084    }
00085    else if (this->action[simuPos.y()][simuPos.x()] == DOWN) {
00086       this->simuPosNew.setX( this->simuPos.x());
00087       this->simuPosNew.setY( this->simuPos.y() +1 );
00088    }
00089    else if (this->action[simuPos.y()][simuPos.x()] == LEFT) {
00090       this->simuPosNew.setX( this->simuPos.x() -1);
00091       this->simuPosNew.setY( this->simuPos.y());
00092    }
00093    else if (this->action[simuPos.y()][simuPos.x()] == RIGHT) {
00094       this->simuPosNew.setX( this->simuPos.x() +1);
00095       this->simuPosNew.setY( this->simuPos.y());
00096    }
00097 
00098    this->simuPos = this->simuPosNew;
00099 
00100    // In GUI integrierte Simulation
00101    this->lg->canvasView->moveRobot (this->simuPos.y()+1, this->simuPos.x()+1);   
00102    // In externen Dialog integrierte Simulation
00103    this->sd->canvasView->moveRobot (this->simuPos.y()+1, this->simuPos.x()+1);
00104    this->sd->show();
00105 
00106    this->debugOutput ("Position: Row=" + QString::number(this->simuPos.y() +1) + 
00107             ", Column=" + QString::number(this->simuPos.x() +1) );
00108 
00109    //Thread wieder weiterlaufen lassen
00110    this->st->start(1000, 0);
00111 }

Erzeugt am Mon Nov 24 15:30:59 2008 für Walking Robot Simulation GUI - API Documentation von  doxygen 1.5.5