VRCWTrackingHw::VRCWTrackingHw(QWidget* parent) : QWidget(parent) { ui.setupUi(this); //GUI erstellen // //hand sensors handSensor_1 = new VRCWHSensBIndex(ui.handSensWidget_1); ui.handSensWidget_1HLayout->addWidget(handSensor_1); handSensor_1->setHSensLabel("Hand sensor 1"); handSensor_2 = new VRCWHSensBIndex(ui.handSensWidget_2); ui.handSensWidget_2HLayout->addWidget(handSensor_2); handSensor_2->setHSensLabel("Hand sensor 2"); handSensor_3 = new VRCWHSensBIndex(ui.handSensWidget_3); ui.handSensWidget_3HLayout->addWidget(handSensor_3); handSensor_3->setHSensLabel("Hand sensor 3"); //head sensors headSensor_0 = new VRCWHSensBIndex(ui.headSensWidget_0); ui.headSensWidget_0HLayout->addWidget(headSensor_0); headSensor_0->setHSensLabel("Head sensor 0"); headSensor_0->constHeaderDescOnly("Constant head - not tracked"); headSensor_1 = new VRCWHSensBIndex(ui.headSensWidget_1); ui.headSensWidget_1HLayout->addWidget(headSensor_1); headSensor_1->setHSensLabel("Head sensor 1"); headSensor_1->bodyIndexOnly(); headSensor_1->headSensLayout(); headSensor_2 = new VRCWHSensBIndex(ui.headSensWidget_2); ui.headSensWidget_2HLayout->addWidget(headSensor_2); headSensor_2->setHSensLabel("Head sensor 2"); headSensor_2->bodyIndexOnly(); headSensor_2->headSensLayout(); headSensor_3 = new VRCWHSensBIndex(ui.headSensWidget_3); ui.headSensWidget_3HLayout->addWidget(headSensor_3); headSensor_3->setHSensLabel("Head sensor 3"); headSensor_3->bodyIndexOnly(); headSensor_3->headSensLayout(); //persons person_1 = new VRCWPerson(ui.personWidget_1); ui.personWidget_1HLayout->addWidget(person_1); person_1->setPersonsLabel("Tracked person 1"); person_2 = new VRCWPerson(ui.personWidget_2); ui.personWidget_2HLayout->addWidget(person_2); person_2->setPersonsLabel("Tracked person 2"); person_3 = new VRCWPerson(ui.personWidget_3); ui.personWidget_3HLayout->addWidget(person_3); person_3->setPersonsLabel("Tracked person 3"); person_4 = new VRCWPerson(ui.personWidget_4); ui.personWidget_4HLayout->addWidget(person_4); person_4->setPersonsLabel("Tracked person 4"); person_5 = new VRCWPerson(ui.personWidget_5); ui.personWidget_5HLayout->addWidget(person_5); person_5->setPersonsLabel("Tracked person 5"); person_6 = new VRCWPerson(ui.personWidget_6); ui.personWidget_6HLayout->addWidget(person_6); person_6->setPersonsLabel("Tracked person 6"); person_7 = new VRCWPerson(ui.personWidget_7); ui.personWidget_7HLayout->addWidget(person_7); person_7->setPersonsLabel("Tracked person 7"); person_8 = new VRCWPerson(ui.personWidget_8); ui.personWidget_8HLayout->addWidget(person_8); person_8->setPersonsLabel("Tracked person 8"); person_9 = new VRCWPerson(ui.personWidget_9); ui.personWidget_9HLayout->addWidget(person_9); person_9->setPersonsLabel("Tracked person 9"); //QVector<VRCWHSensBIndex*> handSensors erzeugen handSensors.append(handSensor_1); handSensors.append(handSensor_2); handSensors.append(handSensor_3); //QVector<VRCWHSensBIndex*> headSensors erzeugen headSensors.append(headSensor_0); headSensors.append(headSensor_1); headSensors.append(headSensor_2); headSensors.append(headSensor_3); //QVector<VRCWPerson*> persons erzeugen persons.append(person_1); persons.append(person_2); persons.append(person_3); persons.append(person_4); persons.append(person_5); persons.append(person_6); persons.append(person_7); persons.append(person_8); persons.append(person_9); //QVector<QWidget*> personWidgets erzeugen personWidgets.append(ui.personWidget_1); personWidgets.append(ui.personWidget_2); personWidgets.append(ui.personWidget_3); personWidgets.append(ui.personWidget_4); personWidgets.append(ui.personWidget_5); personWidgets.append(ui.personWidget_6); personWidgets.append(ui.personWidget_7); personWidgets.append(ui.personWidget_8); personWidgets.append(ui.personWidget_9); //Variable setzen expertMode = false; osData = Linux; //setup GUI ui.vrcTrackSysHintLabel->setWordWrap(true); ui.interSenseHintLabel->setWordWrap(true); setupGui(); trackHandleParty_exec(); numHandSens_exec(1); numHeadSens_exec(0); numPersons_exec(1); //Validator for Motionstar IP-Address QRegExp rxIp("((00[1-9]|0?[1-9][0-9]|[1][0-9][0-9]|2[0-4][0-9]|25[0-4])\\.)" "(([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-4])\\.){2}" "(00[1-9]|0?[1-9][0-9]|[1][0-9][0-9]|2[0-4][0-9]|25[0-4])"); ui.moStarIPLineEdit->setValidator(new QRegExpValidator(rxIp, ui.moStarIPLineEdit)); //Signals and Slots // connect(this, SIGNAL(trackSysChanged(trackSys)), handSensor_1, SLOT(trackSysChanged_exec(trackSys))); connect(this, SIGNAL(trackSysChanged(trackSys)), handSensor_2, SLOT(trackSysChanged_exec(trackSys))); connect(this, SIGNAL(trackSysChanged(trackSys)), handSensor_3, SLOT(trackSysChanged_exec(trackSys))); connect(this, SIGNAL(trackHandleVrcChecked(bool)), handSensor_1, SLOT(trackHandleVrcChecked_exec(bool))); connect(this, SIGNAL(trackHandleVrcChecked(bool)), handSensor_2, SLOT(trackHandleVrcChecked_exec(bool))); connect(this, SIGNAL(trackHandleVrcChecked(bool)), handSensor_3, SLOT(trackHandleVrcChecked_exec(bool))); }
void Daemon::on_startListenButton_clicked() { ip.clear(); port.clear(); ip = ui->ipLineEdit->text().trimmed(); port = ui->portLineEdit->text().trimmed(); if ( "开始监听" == ui->startListenButton->text() ) { //close listening // server.close(); //QMessageBox::critical( NULL, tr("提示"), tr("2.") ); //udpSocket->close(); //use regular expression to verify input information QRegExp rxIp("\\d+\\.\\d+\\.\\d+\\.\\d+"); QRegExp rxPort(("[1-9]\\d{3,4}")); rxIp.setPatternSyntax(QRegExp::RegExp); rxPort.setPatternSyntax(QRegExp::RegExp); if ( !rxPort.exactMatch(port) || !rxIp.exactMatch(ip) ) { QMessageBox::critical( NULL, tr("提示"), tr("请输入正确的IP和端口.") ); } else { //Tells the server to listen for incoming connections on address address and port port if ( !server.listen( QHostAddress(ip), (quint16)port.toUInt() ) ) { QMessageBox::critical(NULL, tr("提示"), tr("TCP监听失败: %1.").arg(server.errorString() ) ); } else { //When Tcp listen established, then start Udp bind. udpSocket = new QUdpSocket(this); if ( !udpSocket->bind(QHostAddress(ip), (quint16)port.toUInt()+1 ) ) { QMessageBox::critical(NULL, tr("提示"), tr("UDP绑定失败: %1.").arg(udpSocket->errorString() ) ); } connect(udpSocket, SIGNAL(readyRead()), this, SLOT(on_read_Datagrams())); ui->startListenButton->setText("断开监听"); ui->ipLineEdit->setEnabled(false); ui->portLineEdit->setEnabled(false); } } } else if ( "断开监听" == ui->startListenButton->text() ) { //close listening server.close(); udpSocket->close(); ui->startListenButton->setText("开始监听"); ui->ipLineEdit->setEnabled(true); ui->portLineEdit->setEnabled(true); } }