123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527 |
- #include "dialogroadobject.h"
- #include "ui_dialogroadobject.h"
- #include <QMessageBox>
- 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;i<objectlistcount;i++)
- {
- mpCBtype->addItem(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;i<nobjectcount;i++)
- {
- Object * pObject = pRoad->GetObject(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;i<objectlistcount;i++)
- {
- if(strobjecttypelist[i] == type)break;
- }
- if(i<objectlistcount)mpCBtype->setCurrentIndex(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();
- }
|