00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "simplecontrol.h"
00021 #include "world.h"
00022 #include <QLabel>
00023 #include <QBoxLayout>
00024 #include <QPushButton>
00025 #include "renderworld.h"
00026
00027 namespace farsa {
00028
00029 SimpleControl::SimpleControl( QWidget* centralUI, World* world, QWidget* parent )
00030 : QWidget( parent ) {
00031 cui = centralUI;
00032 cui->setParent( this );
00033 this->world = world;
00034
00035 QBoxLayout* toplay = new QVBoxLayout( this );
00036
00037
00038 RenderWorld* rw = dynamic_cast<RenderWorld*>(cui);
00039 if ( rw ) {
00040 infoObject = new QLabel("Info about selected Object", this );
00041 infoObject->setFixedHeight( 50 );
00042 connect( rw, SIGNAL( drawFinished(bool) ),
00043 this, SLOT( updateInfoObject() ), Qt::DirectConnection );
00044 toplay->addWidget( infoObject );
00045 }
00046 toplay->addWidget( cui );
00047
00048 QBoxLayout* inlay = new QHBoxLayout( );
00049 toplay->addLayout( inlay );
00050
00051 QPushButton* bt = new QPushButton( "Play", this );
00052 connect( bt, SIGNAL( clicked() ),
00053 world, SLOT( play() ), Qt::DirectConnection );
00054 inlay->addWidget( bt );
00055
00056 bt = new QPushButton( "Pause", this );
00057 connect( bt, SIGNAL( clicked() ),
00058 world, SLOT( pause() ), Qt::DirectConnection );
00059 inlay->addWidget( bt );
00060
00061 bt = new QPushButton( "Stop", this );
00062 connect( bt, SIGNAL( clicked() ),
00063 world, SLOT( stop() ), Qt::DirectConnection );
00064 inlay->addWidget( bt );
00065
00066 bt = new QPushButton( "Step", this );
00067 connect( bt, SIGNAL( clicked() ),
00068 world, SLOT( advance() ), Qt::DirectConnection );
00069 bt->setAutoRepeat( true );
00070 inlay->addWidget( bt );
00071 }
00072
00073 void SimpleControl::onQuit() {
00074 delete world;
00075 }
00076
00077 void SimpleControl::updateInfoObject() {
00078 RenderWorld* rw = (RenderWorld*)(cui);
00079 int i = rw->selectedName();
00080 if ( i != -1 ) {
00081 QString name = rw->graphics()[i]->object()->name();
00082 wVector pos = rw->graphics()[i]->object()->matrix().w_pos;
00083 infoObject->setText( QString("Name: %1 \t Pos: %2, %3, %4").arg(name).arg(pos[0]).arg(pos[1]).arg(pos[2]) );
00084 }
00085 }
00086
00087 }