#include "dialogroadobject.h" #include "ui_dialogroadobject.h" #include static std::string strobjecttypelist[] ={"none","obstacle","car","pole", "tree","vegetation","barrier","building","parkingSpace","patch", "railing","trafficIsland","crosswalk","streetLamp","gantry", "soundBarrier","van","bus","trailer","bike","motorbike", "tram","train","pedestrian","wind","roadMark"}; const static int objectlistcount = 26; DialogRoadObject::DialogRoadObject(Road * pRoad,QWidget *parent) : QDialog(parent), ui(new Ui::DialogRoadObject) { ui->setupUi(this); mpRoad = pRoad; if(pRoad == 0) { ui->pushButton_add->setEnabled(false); ui->pushButton_change->setEnabled(false); ui->pushButton_delete->setEnabled(false); } else { ui->lineEdit_RoadID->setText(pRoad->GetRoadId().data()); ui->lineEdit_RoadLen->setText(QString::number(pRoad->GetRoadLength())); } CreateView(); int i; for(i=0;iaddItem(strobjecttypelist[i].data()); } mpCBtype->setCurrentIndex(8); mpCBdynamic->addItem("no"); mpCBdynamic->addItem("yes"); mpCBdynamic->addItem("undefined"); mpCBdynamic->setCurrentIndex(2); mpCBorientation->addItem("+"); mpCBorientation->addItem("-"); mpCBorientation->addItem("none"); mpCBorientation->addItem("undefined"); mpCBorientation->setCurrentIndex(3); int nobjectcount = pRoad->GetObjectCount(); for(i=0;iGetObject(i); ui->comboBox_Object->addItem("Object s:"+QString::number(pObject->Gets())); } setWindowTitle("Edit Road Object"); } DialogRoadObject::~DialogRoadObject() { delete ui; } void DialogRoadObject::CreateView() { int startpos_x = 30; int startpos_y = 150; int nSpace = 300; int nLabelWidth = 100; int nLEWidth = 150; int nHeight = 30; int nVSpace = 50; int nVIndex = 0; mpLEt = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"t",this); mpLEzOffset = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"zOffset",this); mpCBtype = ViewCreate::CreateCB(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"type",this); nVIndex++; mpLEvalidLength = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"validLength",this); mpCBorientation = ViewCreate::CreateCB(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"orientation",this); mpLEsubtype = ViewCreate::CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"subtype",this); nVIndex++; mpCBdynamic = ViewCreate::CreateCB(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"dynamic",this); mpLEhdg = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"hdg",this); mpLEname = ViewCreate::CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"name",this); nVIndex++; mpLEpitch = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"pitch",this); mpLEid = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"id",this); mpLEroll = ViewCreate::CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"roll",this); nVIndex++; mpLEheight = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"height",this); mpLEs = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"s",this); mpLElength = ViewCreate::CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"length",this); nVIndex++; mpLEwidth = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"width",this); mpLEradius = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"radius",this); int nPBSpace = 200; int nPBWidth = 150; nVIndex++; mpPBmaterial = ViewCreate::CreatePB(startpos_x+0*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"material",this); mpPBrepeat = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"repeat",this); mpPBparkingspace = ViewCreate::CreatePB(startpos_x+2*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"parkingspace",this); mpPBoutlines = ViewCreate::CreatePB(startpos_x+3*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"outlines",this); nVIndex++; mpPBoutline = ViewCreate::CreatePB(startpos_x+0*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"outline",this); mpPBmarkings = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"markings",this); mpPBborders = ViewCreate::CreatePB(startpos_x+2*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"borders",this); mpPBvalidity = ViewCreate::CreatePB(startpos_x+3*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"validity",this); connect(mpPBmaterial,SIGNAL(clicked(bool)),this,SLOT(onClickMaterial())); connect(mpPBrepeat,SIGNAL(clicked(bool)),this,SLOT(onClickRepeat())); connect(mpPBparkingspace,SIGNAL(clicked(bool)),this,SLOT(onClickParkingSpace())); } void DialogRoadObject::on_pushButton_add_clicked() { Road * pRoad = mpRoad; if(ViewCreate::CheckLE(mpLEid,"id",true,this) == false)return; string id = mpLEid->text().toStdString(); if(ViewCreate::CheckLE(mpLEt,"t",true,this) == false)return; double t = mpLEt->text().toDouble(); if(ViewCreate::CheckLE(mpLEs,"s",true,this) == false)return; double s = mpLEs->text().toDouble(); if(ViewCreate::CheckLE(mpLEzOffset,"zOffset",true,this) == false)return; double zOffset = mpLEzOffset->text().toDouble(); double length,width,hdg; if(mpCBtype->currentText() == "parkingSpace") { if(ViewCreate::CheckLE(mpLElength,"length",true,this) == false)return; length = mpLElength->text().toDouble(); if(ViewCreate::CheckLE(mpLEwidth,"width",true,this) == false)return; width = mpLEwidth->text().toDouble(); if(ViewCreate::CheckLE(mpLEhdg,"hdg",true,this) == false)return; hdg = mpLEhdg->text().toDouble(); } pRoad->AddObject(id,s,t,zOffset); Object * pObject = pRoad->GetLastAddedObject(); pObject->Settype(mpCBtype->currentText().toStdString()); if(ViewCreate::CheckLE(mpLEvalidLength,"validLength",false,this)) { pObject->SetvalidLength(mpLEvalidLength->text().toDouble()); } if(mpCBorientation->currentIndex() != 3) { pObject->Setorientation(mpCBorientation->currentText().toStdString()); } if(ViewCreate::CheckLE(mpLEsubtype,"subtype",false,this)) { pObject->Setsubtype(mpLEsubtype->text().toStdString()); } if(mpCBdynamic->currentIndex()!= 2) { pObject->Setdynamic(mpCBdynamic->currentText().toStdString()); } if(ViewCreate::CheckLE(mpLEname,"name",false,this)) { pObject->Setname(mpLEname->text().toStdString()); } if(ViewCreate::CheckLE(mpLEhdg,"hdg",false,this)) { pObject->Sethdg(mpLEhdg->text().toDouble()); } if(ViewCreate::CheckLE(mpLEpitch,"pitch",false,this)) { pObject->Setpitch(mpLEpitch->text().toDouble()); } if(ViewCreate::CheckLE(mpLEroll,"roll",false,this)) { pObject->Setroll(mpLEroll->text().toDouble()); } if(ViewCreate::CheckLE(mpLEheight,"height",false,this)) { pObject->Setheight(mpLEheight->text().toDouble()); } if(ViewCreate::CheckLE(mpLElength,"length",false,this)) { pObject->Setlength(mpLElength->text().toDouble()); } if(ViewCreate::CheckLE(mpLEwidth,"width",false,this)) { pObject->Setwidth(mpLEwidth->text().toDouble()); } if(ViewCreate::CheckLE(mpLEradius,"radius",false,this)) { pObject->Setradius(mpLEradius->text().toDouble()); } ui->comboBox_Object->addItem("Object s:"+QString::number(pObject->Gets())); } void DialogRoadObject::on_comboBox_Object_currentIndexChanged(int index) { Road * pRoad = mpRoad; if(pRoad == 0)return; if(index < 0)return; if(index >= mpRoad->GetObjectCount()) { return; } Object * pObject = mpRoad->GetObject(index); if(pObject == 0)return; mpLEt->setText(QString::number(pObject->Gett())); mpLEzOffset->setText(QString::number(pObject->GetzOffset())); string type = pObject->Gettype(); int i; for(i=0;isetCurrentIndex(i); double validLength; if(pObject->GetvalidLength(validLength) == 1) { mpLEvalidLength->setText(QString::number(validLength)); } else mpLEvalidLength->setText(""); string strorientation = pObject->Getorientation(); if(strorientation == "") { mpCBorientation->setCurrentIndex(3); } else { if(strorientation == "+")mpCBorientation->setCurrentIndex(0); else { if(strorientation == "-")mpCBorientation->setCurrentIndex(1); else mpCBorientation->setCurrentIndex(2); } } string strtype = pObject->Getsubtype(); if(strtype != "")pObject->Setsubtype(strtype); string strdynamic = pObject->Getdynamic(); if(strdynamic == "") { mpCBdynamic->setCurrentIndex(2); } else { if(strdynamic == "no")mpCBdynamic->setCurrentIndex(0); else mpCBdynamic->setCurrentIndex(1); } double hdg; if(pObject->Gethdg(hdg) == 1)mpLEhdg->setText(QString::number(hdg)); else mpLEhdg->setText(""); mpLEname->setText(pObject->Getname().data()); double pitch; if(pObject->Getpitch(pitch) == 1)mpLEpitch->setText(QString::number(pitch)); else mpLEpitch->setText(""); mpLEid->setText(pObject->Getid().data()); double roll; if(pObject->Getroll(roll) == 1)mpLEroll->setText(QString::number(roll)); else mpLEroll->setText(""); double height; if(pObject->Getheight(height) == 1)mpLEheight->setText(QString::number(height)); else mpLEheight->setText(""); mpLEs->setText(QString::number(pObject->Gets())); double length; if(pObject->Getlength(length) == 1)mpLElength->setText(QString::number(length)); else mpLElength->setText(""); double width; if(pObject->Getwidth(width) == 1)mpLEwidth->setText(QString::number(width)); else mpLEwidth->setText(""); double radius; if(pObject->Getradius(radius) == 1)mpLEradius->setText(QString::number(radius)); else mpLEradius->setText(""); } void DialogRoadObject::on_pushButton_delete_clicked() { if(mpRoad == 0)return; Road * pRoad = mpRoad; if(pRoad->GetObjectCount() == 0) { QMessageBox::warning(this,"Warning","No Object.",QMessageBox::YesAll); return; } int index = ui->comboBox_Object->currentIndex(); if(index<0)return; if(index >= mpRoad->GetObjectCount())return; pRoad->DeleteObject(index); ui->comboBox_Object->removeItem(index); } void DialogRoadObject::on_pushButton_change_clicked() { if(mpRoad == 0)return; Road * pRoad = mpRoad; if(pRoad->GetObjectCount() == 0) { QMessageBox::warning(this,"Warning","No Object.",QMessageBox::YesAll); return; } int index = ui->comboBox_Object->currentIndex(); if(index<0)return; if(index >= mpRoad->GetObjectCount())return; Object * pObject = mpRoad->GetObject(index); if(pObject == 0) { QMessageBox::warning(this,"Warning","Can't found Object.",QMessageBox::YesAll); return; } if(ViewCreate::CheckLE(mpLEid,"id",true,this) == false)return; string id = mpLEid->text().toStdString(); if(ViewCreate::CheckLE(mpLEt,"t",true,this) == false)return; double t = mpLEt->text().toDouble(); if(ViewCreate::CheckLE(mpLEs,"s",true,this) == false)return; double s = mpLEs->text().toDouble(); if(ViewCreate::CheckLE(mpLEzOffset,"zOffset",true,this) == false)return; double zOffset = mpLEzOffset->text().toDouble(); double length,width,hdg; if(mpCBtype->currentText() == "parkingSpace") { if(ViewCreate::CheckLE(mpLElength,"length",true,this) == false)return; length = mpLElength->text().toDouble(); if(ViewCreate::CheckLE(mpLEwidth,"width",true,this) == false)return; width = mpLEwidth->text().toDouble(); if(ViewCreate::CheckLE(mpLEhdg,"hdg",true,this) == false)return; hdg = mpLEhdg->text().toDouble(); } pObject->Setid(id); pObject->Sets(s); pObject->Sett(t); pObject->SetzOffset(zOffset); pObject->Settype(mpCBtype->currentText().toStdString()); if(ViewCreate::CheckLE(mpLEvalidLength,"validLength",false,this)) { pObject->SetvalidLength(mpLEvalidLength->text().toDouble()); } if(mpCBorientation->currentIndex() != 3) { pObject->Setorientation(mpCBorientation->currentText().toStdString()); } if(ViewCreate::CheckLE(mpLEsubtype,"subtype",false,this)) { pObject->Setsubtype(mpLEsubtype->text().toStdString()); } if(mpCBdynamic->currentIndex()!= 2) { pObject->Setdynamic(mpCBdynamic->currentText().toStdString()); } if(ViewCreate::CheckLE(mpLEhdg,"hdg",false,this)) { pObject->Sethdg(mpLEhdg->text().toDouble()); } if(ViewCreate::CheckLE(mpLEname,"name",false,this)) { pObject->Setname(mpLEname->text().toStdString()); } if(ViewCreate::CheckLE(mpLEpitch,"pitch",false,this)) { pObject->Setpitch(mpLEpitch->text().toDouble()); } if(ViewCreate::CheckLE(mpLEroll,"roll",false,this)) { pObject->Setroll(mpLEroll->text().toDouble()); } if(ViewCreate::CheckLE(mpLEheight,"height",false,this)) { pObject->Setheight(mpLEheight->text().toDouble()); } if(ViewCreate::CheckLE(mpLElength,"length",false,this)) { pObject->Setlength(mpLElength->text().toDouble()); } if(ViewCreate::CheckLE(mpLEwidth,"width",false,this)) { pObject->Setwidth(mpLEwidth->text().toDouble()); } if(ViewCreate::CheckLE(mpLEradius,"radius",false,this)) { pObject->Setradius(mpLEradius->text().toDouble()); } QMessageBox::information(this,"Info","Change Object Successfull.",QMessageBox::YesAll); } void DialogRoadObject::onClickMaterial() { if(mpRoad == 0)return; Road * pRoad = mpRoad; if(pRoad->GetObjectCount() == 0) { QMessageBox::warning(this,"Warning","No Object.",QMessageBox::YesAll); return; } int index = ui->comboBox_Object->currentIndex(); if(index<0)return; if(index >= mpRoad->GetObjectCount())return; Object * pObject = mpRoad->GetObject(index); if(pObject == 0) { QMessageBox::warning(this,"Warning","Can't found Object.",QMessageBox::YesAll); return; } DialogRoadObject_material dlgmaterail(pObject); dlgmaterail.exec(); } void DialogRoadObject::onClickRepeat() { if(mpRoad == 0)return; Road * pRoad = mpRoad; if(pRoad->GetObjectCount() == 0) { QMessageBox::warning(this,"Warning","No Object.",QMessageBox::YesAll); return; } int index = ui->comboBox_Object->currentIndex(); if(index<0)return; if(index >= mpRoad->GetObjectCount())return; Object * pObject = mpRoad->GetObject(index); if(pObject == 0) { QMessageBox::warning(this,"Warning","Can't found Object.",QMessageBox::YesAll); return; } DialogRoadObject_repeat dlgrepeat(pObject); dlgrepeat.exec(); } void DialogRoadObject::onClickParkingSpace() { if(mpRoad == 0)return; Road * pRoad = mpRoad; if(pRoad->GetObjectCount() == 0) { QMessageBox::warning(this,"Warning","No Object.",QMessageBox::YesAll); return; } int index = ui->comboBox_Object->currentIndex(); if(index<0)return; if(index >= mpRoad->GetObjectCount())return; Object * pObject = mpRoad->GetObject(index); if(pObject == 0) { QMessageBox::warning(this,"Warning","Can't found Object.",QMessageBox::YesAll); return; } DialogRoadObject_parkingSpace dlgparkingspace(pObject); dlgparkingspace.exec(); }