int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: reconnectUdp(); break; case 1: sendPacket(); break; case 2: sendBtnClicked(); break; case 3: resetBtnClicked(); break; case 4: disconnectUdp(); break; default: ; } _id -= 5; } return _id; }
MainWindow::MainWindow(QWidget *parent) : QDialog(parent), udpsocket(this) { QGridLayout* layout = new QGridLayout(this); edtIp = new QLineEdit("127.0.0.1", this); edtPort = new QLineEdit("20011", this); edtId = new QLineEdit("0", this); edtVx = new QLineEdit("0", this); edtVy = new QLineEdit("0", this); edtW = new QLineEdit("0", this); edtV1 = new QLineEdit("0", this); edtV2 = new QLineEdit("0", this); edtV3 = new QLineEdit("0", this); edtV4 = new QLineEdit("0", this); edtChip = new QLineEdit("0", this); edtKick = new QLineEdit("0", this); this->setWindowTitle(QString("grSim Sample Client - v 2.0")); lblIp = new QLabel("Simulator Address", this); lblPort = new QLabel("Simulator Port", this); lblId = new QLabel("Id", this); lblVx = new QLabel("Velocity X (m/s)", this); lblVy = new QLabel("Velocity Y (m/s)", this); lblW = new QLabel("Velocity W (rad/s)", this); lblV1 = new QLabel("Wheel1 (rad/s)", this); lblV2 = new QLabel("Wheel2 (rad/s)", this); lblV3 = new QLabel("Wheel3 (rad/s)", this); lblV4 = new QLabel("Wheel4 (rad/s)", this); cmbTeam = new QComboBox(this); cmbTeam->addItem("Yellow"); cmbTeam->addItem("Blue"); lblChip = new QLabel("Chip (m/s)", this); lblKick = new QLabel("Kick (m/s)", this); txtInfo = new QTextEdit(this); chkVel = new QCheckBox("Send Velocity? (or wheels)", this); chkSpin = new QCheckBox("Spin", this); btnSend = new QPushButton("Send", this); btnReset = new QPushButton("Reset", this); btnConnect = new QPushButton("Connect", this); txtInfo->setReadOnly(true); txtInfo->setHtml("This program is part of <b>grSim RoboCup SSL Simulator</b> package.<br />For more information please refer to <a href=\"http://eew.aut.ac.ir/~parsian/grsim/\">http://eew.aut.ac.ir/~parsian/grsim</a><br /><font color=\"gray\">This program is free software under the terms of GNU General Public License Version 3.</font>"); txtInfo->setFixedHeight(70); layout->addWidget(lblIp, 1, 1, 1, 1);layout->addWidget(edtIp, 1, 2, 1, 1); layout->addWidget(lblPort, 1, 3, 1, 1);layout->addWidget(edtPort, 1, 4, 1, 1); layout->addWidget(lblId, 2, 1, 1, 1);layout->addWidget(edtId, 2, 2, 1, 1);layout->addWidget(cmbTeam, 2, 3, 1, 2); layout->addWidget(lblVx, 3, 1, 1, 1);layout->addWidget(edtVx, 3, 2, 1, 1); layout->addWidget(lblVy, 4, 1, 1, 1);layout->addWidget(edtVy, 4, 2, 1, 1); layout->addWidget(lblW, 5, 1, 1, 1);layout->addWidget(edtW, 5, 2, 1, 1); layout->addWidget(chkVel, 6, 1, 1, 1);layout->addWidget(edtKick, 6, 2, 1, 1); layout->addWidget(lblV1, 3, 3, 1, 1);layout->addWidget(edtV1, 3, 4, 1, 1); layout->addWidget(lblV2, 4, 3, 1, 1);layout->addWidget(edtV2, 4, 4, 1, 1); layout->addWidget(lblV3, 5, 3, 1, 1);layout->addWidget(edtV3, 5, 4, 1, 1); layout->addWidget(lblV4, 6, 3, 1, 1);layout->addWidget(edtV4, 6, 4, 1, 1); layout->addWidget(lblChip, 7, 1, 1, 1);layout->addWidget(edtChip, 7, 2, 1, 1); layout->addWidget(lblKick, 7, 3, 1, 1);layout->addWidget(edtKick, 7, 4, 1, 1); layout->addWidget(chkSpin, 8, 1, 1, 4); layout->addWidget(btnConnect, 9, 1, 1, 2);layout->addWidget(btnSend, 9, 3, 1, 1);layout->addWidget(btnReset, 9, 4, 1, 1); layout->addWidget(txtInfo, 10, 1, 1, 4); timer = new QTimer (this); timer->setInterval(20); connect(edtIp, SIGNAL(textChanged(QString)), this, SLOT(disconnectUdp())); connect(edtPort, SIGNAL(textChanged(QString)), this, SLOT(disconnectUdp())); connect(timer, SIGNAL(timeout()), this, SLOT(sendPacket())); connect(btnConnect, SIGNAL(clicked()), this, SLOT(reconnectUdp())); connect(btnSend, SIGNAL(clicked()), this, SLOT(sendBtnClicked())); connect(btnReset, SIGNAL(clicked()), this, SLOT(resetBtnClicked())); btnSend->setDisabled(true); chkVel->setChecked(true); sending = false; reseting = false; }