void ServerInterface::slot_menuFileActivated( int num ) { switch( num ) { case FIL_LOAD:{ QString filename; filename = QFileDialog::getOpenFileName( "", "*.scn", this ); slot_load( filename ); break; } case FIL_SAVE: slot_save(); break; case FIL_END: slot_stop(); break; case FIL_QUIT: qApp->quit(); } }
/** add comments here */ ServerInterface::ServerInterface() :QMainWindow() { setCaption( "Attal - Lords of Doom (Server)" ); initMenuBar(); initStatusBar(); DataTheme.init(); _widget = new ServerWidget( this ); setCentralWidget( _widget ); connect( _widget, SIGNAL( sig_stop() ), SLOT( slot_stop() ) ); connect( _widget, SIGNAL( sig_load( QString ) ), SLOT( slot_load( QString ) ) ); connect( _widget, SIGNAL( sig_save() ), SLOT( slot_save() ) ); setMinimumSize( 350, 200 ); if( !init() ) { logDD( "quit" ); qApp->quit(); } connect( _server, SIGNAL( sig_endConnection( QString ) ), _widget, SLOT( slot_endConnection( QString ) ) ); }
MainWindow::MainWindow() { _rrtWidget = new RRTWidget(); setWindowTitle("Interactive RRT"); _iterationCountLabel = new QLabel(this); _iterationCountLabel->setText("Iterations: 0"); statusBar()->addPermanentWidget(_iterationCountLabel); QPushButton *run = new QPushButton(this); run->setText("Run"); run->setStyleSheet("background-color: green;"); QPushButton *runFast = new QPushButton(this); runFast->setText("Run Fast"); runFast->setStyleSheet("background-color: darkGreen;"); QPushButton *stop = new QPushButton(this); stop->setText("Stop"); QPushButton *step = new QPushButton(this); step->setText("Step"); QPushButton *stepBig = new QPushButton(this); stepBig->setText("Step 100"); QPushButton *reset = new QPushButton(this); reset->setText("Reset"); QPushButton *clearObstacles = new QPushButton(this); clearObstacles->setText("Clear Obstacles"); clearObstacles->setStyleSheet("background-color: red;"); QSlider *goalBias = new QSlider(Qt::Horizontal, this); goalBias->setTickPosition(QSlider::TicksBelow); goalBias->setMinimum(0); goalBias->setMaximum(100); goalBias->setTickInterval(10); _goalBiasLabel = new QLabel("Goal Bias: 0", this); QSlider *waypointBias = new QSlider(Qt::Horizontal, this); waypointBias->setTickPosition(QSlider::TicksBelow); waypointBias->setMinimum(0); waypointBias->setMaximum(100); waypointBias->setTickInterval(10); _waypointBiasLabel = new QLabel("Waypoint Bias: 0", this); QDoubleSpinBox *stepSizeBox = new QDoubleSpinBox(this); stepSizeBox->setMinimum(0.01); stepSizeBox->setMaximum(1); stepSizeBox->setValue(0.1); stepSizeBox->setSingleStep(0.01); QLabel *stepSizeLabel = new QLabel("Step Size:"); QDoubleSpinBox *curvatureIncreaseFactorBox = new QDoubleSpinBox(this); curvatureIncreaseFactorBox->setMinimum(1); curvatureIncreaseFactorBox->setMaximum(5); curvatureIncreaseFactorBox->setValue(1.1); curvatureIncreaseFactorBox->setSingleStep(0.01); QLabel *angleDiffDecayFactorLabel = new QLabel("Curv. Inc. factor"); QGridLayout *layout = new QGridLayout(); layout->addWidget(run, 0, 0); layout->addWidget(stop, 1, 0); layout->addWidget(runFast, 2, 0); layout->addWidget(step, 0, 1); layout->addWidget(stepBig, 1, 1); layout->addWidget(reset, 0, 2); layout->addWidget(clearObstacles, 1, 2); layout->addWidget(goalBias, 1, 3); layout->addWidget(_goalBiasLabel, 0, 3); layout->addWidget(waypointBias, 1, 4); layout->addWidget(_waypointBiasLabel, 0, 4); layout->addWidget(stepSizeBox, 1, 5); layout->addWidget(stepSizeLabel, 0, 5); layout->addWidget(curvatureIncreaseFactorBox, 1, 6); layout->addWidget(angleDiffDecayFactorLabel, 0, 6); layout->addWidget(_rrtWidget, 3, 0, 1, 7); QWidget *centralWidget = new QWidget(this); centralWidget->setLayout(layout); this->setCentralWidget(centralWidget); // prevent the window from being resized setFixedSize(sizeHint()); // make the buttons do things connect(run, SIGNAL(clicked()), _rrtWidget, SLOT(slot_run())); connect(runFast, SIGNAL(clicked()), _rrtWidget, SLOT(slot_runFast())); connect(stop, SIGNAL(clicked()), _rrtWidget, SLOT(slot_stop())); connect(step, SIGNAL(clicked()), _rrtWidget, SLOT(slot_step())); connect(stepBig, SIGNAL(clicked()), _rrtWidget, SLOT(slot_stepBig())); connect(reset, SIGNAL(clicked()), _rrtWidget, SLOT(slot_reset())); connect(clearObstacles, SIGNAL(clicked()), _rrtWidget, SLOT(slot_clearObstacles())); connect(goalBias, SIGNAL(valueChanged(int)), _rrtWidget, SLOT(slot_setGoalBias(int))); connect(goalBias, SIGNAL(valueChanged(int)), this, SLOT(slot_updateGoalBiasLabel(int))); connect(waypointBias, SIGNAL(valueChanged(int)), _rrtWidget, SLOT(slot_setWaypointBias(int))); connect(waypointBias, SIGNAL(valueChanged(int)), this, SLOT(slot_updateWaypointBiasLabel(int))); connect(stepSizeBox, SIGNAL(valueChanged(double)), _rrtWidget, SLOT(slot_setStepSize(double))); connect(curvatureIncreaseFactorBox, SIGNAL(valueChanged(double)), _rrtWidget, SLOT(slot_setCurvatureIncreaseFactor(double))); connect(_rrtWidget, SIGNAL(signal_stepped(int)), this, SLOT(slot_updateIterationCount(int))); // keyboard shortcuts new QShortcut(QKeySequence(Qt::Key_R), _rrtWidget, SLOT(slot_run())); new QShortcut(QKeySequence(Qt::Key_S), _rrtWidget, SLOT(slot_stop())); new QShortcut(QKeySequence(Qt::Key_C), _rrtWidget, SLOT(slot_reset())); new QShortcut(QKeySequence(Qt::Key_F), _rrtWidget, SLOT(slot_runFast())); }
// Initialisiert das Kommando-Fenster. bool CommandWindow::init( GameData* dataP ) { bool retValue = true; #ifdef DEBUG { std::ostringstream out; out << "(DD) CommandWindow::init " << std::hex << this << std::dec << " Begin" << std::endl; std::clog << out.str(); } #endif /* DEBUG */ mCommandHandlerP = new CommandHandler(); if ( !mCommandHandlerP ) { std::ostringstream out; out << "(EE) CommandWindow::init " << std::hex << this << std::dec << " CommandHandler is 0!" << std::endl; std::cerr << out.str(); QMessageBox::critical( this, windowTitle(), tr("CommandHandler is 0!"), QMessageBox::Abort ); return false; } if ( !mCommandHandlerP->init( dataP ) ) { return false; } mCommandListP = new QListWidget(); if ( !mCommandListP ) { std::ostringstream out; out << "(EE) CommandWindow::init " << std::hex << this << std::dec << " QListWidget is 0!" << std::endl; std::cerr << out.str(); QMessageBox::critical( this, windowTitle(), tr("QListWidget is 0!"), QMessageBox::Abort ); return false; } // Anwahl einzelner Zeilen moeglich. mCommandListP->setSelectionBehavior( QAbstractItemView::SelectItems ); mCommandListP->setSelectionMode( QAbstractItemView::SingleSelection ); #ifdef DEBUG { std::ostringstream out; out << "(DD) CommandWindow::init " << std::hex << this << std::dec << " Creation complete " << std::endl; std::clog << out.str(); } #endif /* DEBUG */ mStartButtonP = new QPushButton(tr("St&art")); mStopButtonP = new QPushButton( tr("St&op")); mResetButtonP = new QPushButton(tr("&Reset")); mGotoButtonP = new QPushButton(tr("&Go to line")); mSingleStepButtonP = new QCheckBox(tr("&Single step")); mOpenButtonP = new QPushButton(tr("Open game &file")); connect( mStartButtonP, SIGNAL(clicked()), this, SLOT(slot_start()) ); connect( mStopButtonP, SIGNAL(clicked()), this, SLOT(slot_stop()) ); connect( mResetButtonP, SIGNAL(clicked()), this, SLOT(slot_reset()) ); connect( mGotoButtonP, SIGNAL(clicked()), this, SLOT(slot_gotoLine()) ); connect( mOpenButtonP, SIGNAL(clicked()), this, SIGNAL(sig_openFile()) ); #ifdef DEBUG { std::ostringstream out; out << "(DD) CommandWindow::init " << std::hex << this << std::dec << " Buttons complete " << std::endl; std::clog << out.str(); } #endif /* DEBUG */ QGridLayout *layout = new QGridLayout; layout->addWidget( mCommandListP, 0, 0, 1, 2 ); layout->addWidget( mOpenButtonP, 1, 0 ); layout->addWidget( mGotoButtonP, 1, 1 ); layout->addWidget( mStartButtonP, 2, 0 ); layout->addWidget( mSingleStepButtonP, 2, 1 ); layout->addWidget( mStopButtonP, 3, 0 ); layout->addWidget( mResetButtonP, 3, 1 ); this->setLayout(layout); // Alles zuruecksetzen. slot_reset(); #ifdef DEBUG { std::ostringstream out; out << "(DD) CommandWindow::init " << std::hex << this << std::dec << " End " << retValue << std::endl; std::clog << out.str(); } #endif /* DEBUG */ return retValue; }