NeuronTileDisplayDialog::NeuronTileDisplayDialog(V3DPluginCallback2 * cb, V3dR_MainWindow* inwin) { v3dwin=inwin; callback=cb; //create spin_x = new QDoubleSpinBox(); spin_x->setRange(0,100000); spin_x->setValue(0); // connect(spin_x, SIGNAL(valueChanged(double)), this, SLOT(tile(double))); spin_y = new QDoubleSpinBox(); spin_y->setRange(0,100000); spin_y->setValue(100); // connect(spin_y, SIGNAL(valueChanged(double)), this, SLOT(tile(double))); spin_z = new QDoubleSpinBox(); spin_z->setRange(0,100000); spin_z->setValue(0); // connect(spin_z, SIGNAL(valueChanged(double)), this, SLOT(tile(double))); btn_quit = new QPushButton("Quit"); connect(btn_quit, SIGNAL(clicked()), this, SLOT(reject())); btn_tile = new QPushButton("Tile"); connect(btn_tile, SIGNAL(clicked()), this, SLOT(tile())); btn_reset = new QPushButton("Reset"); connect(btn_reset, SIGNAL(clicked()), this, SLOT(slot_reset())); //layout QGridLayout * gridLayout = new QGridLayout(); // gridLayout->addWidget(check_tile,0,0,1,1); QLabel* label_1 = new QLabel("X direction steps:"); gridLayout->addWidget(label_1,1,0,1,2); gridLayout->addWidget(spin_x,1,2,1,1); QLabel* label_2 = new QLabel("Y direction steps:"); gridLayout->addWidget(label_2,2,0,1,2); gridLayout->addWidget(spin_y,2,2,1,1); QLabel* label_3 = new QLabel("Z direction steps:"); gridLayout->addWidget(label_3,3,0,1,2); gridLayout->addWidget(spin_z,3,2,1,1); gridLayout->addWidget(btn_tile,4,0,1,1); gridLayout->addWidget(btn_reset,4,1,1,1); gridLayout->addWidget(btn_quit,4,2,1,1); setLayout(gridLayout); //load neuron tree ntList=callback->getHandleNeuronTrees_Any3DViewer(v3dwin); cur_x = cur_y = cur_z = 0; cur_num = ntList->size(); }
/* Update the slot SLOT. */ CK_RV slots_update_slot (slot_iterator_t id) { struct slot *slot = scute_table_data (slots, id); gpg_error_t err; if (slot->token_present) { err = scute_agent_check_status (); if (gpg_err_code (err) == GPG_ERR_CARD_REMOVED) slot_reset (id); else if (err) return scute_gpg_err_to_ck (err); else return 0; } /* At this point, the card was or is removed, and we need to reopen the session, if possible. */ err = scute_agent_learn (&slot->info); /* First check if this is really an OpenPGP card. FIXME: Should probably report the error in a better way. */ if (!err && (!slot->info.serialno || strncmp (slot->info.serialno, "D27600012401", 12) || strlen (slot->info.serialno) != 32)) { DEBUG (DBG_INFO, "token not an OpenPGP card: %s", slot->info.serialno); err = gpg_error (GPG_ERR_CARD_NOT_PRESENT); scute_agent_release_card_info (&slot->info); } /* We also ignore card errors, because unusable cards should not affect slots, and firefox is quite unhappy about returning errors here. */ if (gpg_err_code (err) == GPG_ERR_CARD_REMOVED || gpg_err_code (err) == GPG_ERR_CARD_NOT_PRESENT || gpg_err_code (err) == GPG_ERR_CARD) /* Nothing to do. */ err = 0; else if (err == 0) err = slot_init (id); return scute_sys_to_ck (err); }
// Verarbeite alles bis zur ausgewaehlten Zeile (exklusive). void CommandWindow::slot_gotoLine() { // Hole die aktuell ausgewaehlte Zeile. const int currentRow = mCommandListP->currentRow(); if ( currentRow > mCommandIndex ) { // Die angesteuerte Zeile liegt hinter der aktuellen. // Wir koennen diese also normal ansteuern. startUntilLine( currentRow, true ); } else if ( currentRow < mCommandIndex ) { // Die angesteuerte Zeile liegt vor der aktuellen. // Wir muessen also zuerst das Spiel zuruecksetzen. slot_reset(); startUntilLine( currentRow, true ); } }
/* Initialize the slot after a token has been inserted. SLOT->info must already be valid. */ static gpg_error_t slot_init (slot_iterator_t id) { gpg_error_t err = 0; struct slot *slot = scute_table_data (slots, id); err = scute_gpgsm_get_cert (slot->info.grip3, 3, add_object, slot); if (err) goto init_out; /* FIXME: Perform the rest of the initialization of the token. */ slot->token_present = true; init_out: if (err) slot_reset (id); return err; }
// Starte die Kommandoverarbeitung von der aktuellen Zeile an. void CommandWindow::slot_start() { // Wenn wir am Ende der Datei sind, dann resetten wir zuerst alles. if ( mCommandIndex >= mCommandListP->count() ) { slot_reset(); } if ( mSingleStepButtonP->isChecked() ) { // Der Einzelschritt-Knopf ist angehakt, wir hoeren nach // einer Zeile auf. startUntilLine( mCommandIndex+1, false ); } else { // Wir iterieren ganz langsam von der aktuellen Position // bis zum Ende der Liste, falls uns nichts vorher aufhaelt. startUntilLine( mCommandListP->count(), false ); } }
// Datei oeffen und darstellen. bool CommandWindow::openFile( const QString& fileName ) { bool retValue = false; QFile file(fileName); if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) { // Vorherigen Text loeschen und Zeile fuer Zeile // hinzufuegen. mCommandListP->clear(); QTextStream in(&file); while ( !in.atEnd() ) { mCommandListP->addItem( in.readLine() ); } // Alles auf Anfang setzen. slot_reset(); retValue = true; } else { std::ostringstream out; out << "(EE) CommandWindow::openFile " << std::hex << this << std::dec << " Could not open file '" << fileName.toStdString() << "' for reading." << std::endl; std::cerr << out.str(); } return retValue; }
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; }