CUtilityDlg::CUtilityDlg(CUtility *u, const char *szId, unsigned long nPPID, CICQDaemon *_server) : QWidget(0, "UtilityDialog", WDestructiveClose) { m_szId = szId ? strdup(szId) : 0; m_nPPID = nPPID; m_xUtility = u; server = _server; m_bIntWin = false; intwin = NULL; snOut = snErr = NULL; m_xUtility->SetFields(m_szId, m_nPPID); QGridLayout *lay = new QGridLayout(this, 1, 3, 8, 4); lay->setColStretch(2, 2); lay->addColSpacing(1, 8); setCaption(QString(tr("Licq Utility: %1")).arg(m_xUtility->Name())); lblUtility = new QLabel(tr("Command:"), this); lay->addWidget(lblUtility, 0, 0); nfoUtility = new CInfoField(this, true); nfoUtility->setMinimumWidth(nfoUtility->sizeHint().width()*2); lay->addWidget(nfoUtility, 0, 2); nfoUtility->setText(m_xUtility->FullCommand()); lay->addWidget(new QLabel(tr("Window:"), this), 1, 0); nfoWinType = new CInfoField(this, true); lay->addWidget(nfoWinType, 1, 2); switch (m_xUtility->WinType()) { case UtilityWinGui: nfoWinType->setText(tr("GUI")); break; case UtilityWinTerm: nfoWinType->setText(tr("Terminal")); break; case UtilityWinLicq: nfoWinType->setText(tr("Internal")); break; } lay->addWidget(new QLabel(tr("Description:"), this), 2, 0); nfoDesc = new CInfoField(this, true); lay->addWidget(nfoDesc, 2, 2); nfoDesc->setText(m_xUtility->Description()); chkEditFinal = new QCheckBox(tr("Edit final command"), this); lay->addMultiCellWidget(chkEditFinal, 3, 3, 0, 2); boxFields = new QGroupBox(1, Horizontal, tr("User Fields"), this); lay->addMultiCellWidget(boxFields, 4, 4, 0, 2); for (unsigned short i = 0; i < m_xUtility->NumUserFields(); i++) { QString s; s.sprintf("%s (%%%d): ", m_xUtility->UserField(i)->Title(), i+1); QLabel *lbl = new QLabel(s, boxFields); lblFields.push_back(lbl); QLineEdit *edt = new QLineEdit(boxFields); edt->setText(m_xUtility->UserField(i)->FullDefault()); edt->setMinimumSize(edt->sizeHint()); edtFields.push_back(edt); } splOutput = new QSplitter(Vertical, boxFields); splOutput->setOpaqueResize(); mleOut = new MLEditWrap(true, splOutput); mleOut->setReadOnly(true); mleErr = new MLEditWrap(true, splOutput); mleErr->setReadOnly(true); splOutput->setResizeMode(mleErr, QSplitter::Stretch);//FollowSizeHint); splOutput->setResizeMode(mleOut, QSplitter::Stretch); splOutput->hide(); if (m_xUtility->NumUserFields() == 0) boxFields->hide(); QHBoxLayout *hlay = new QHBoxLayout(); lay->addMultiCell(hlay, 5, 5, 0, 2); hlay->addStretch(1); btnRun = new QPushButton(tr("&Run"), this); btnRun->setDefault(true); btnRun->setMinimumWidth(75); hlay->addWidget(btnRun, 0, AlignRight); hlay->addSpacing(20); btnCancel = new QPushButton(tr("&Cancel"), this); btnCancel->setMinimumWidth(75); hlay->addWidget(btnCancel, 0, AlignLeft); connect(btnRun, SIGNAL(clicked()), SLOT(slot_run())); connect(btnCancel, SIGNAL(clicked()), SLOT(slot_cancel())); show(); }
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())); }