|
@@ -1,13 +1,63 @@
|
|
|
#include "dialogroadobject.h"
|
|
|
#include "ui_dialogroadobject.h"
|
|
|
|
|
|
-DialogRoadObject::DialogRoadObject(QWidget *parent) :
|
|
|
+#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");
|
|
|
}
|
|
|
|
|
@@ -21,15 +71,12 @@ QLineEdit * DialogRoadObject::CreateLE(int pos_x, int pos_y, int nLabelWidth, in
|
|
|
{
|
|
|
QLineEdit * pLE;
|
|
|
QLabel * pLabel;
|
|
|
-
|
|
|
pLabel = new QLabel(this);
|
|
|
pLabel->setGeometry(pos_x,pos_y,nLabelWidth,nHeight);
|
|
|
pLabel->setText(strname.data());
|
|
|
pLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
|
|
-
|
|
|
pLE = new QLineEdit(this);
|
|
|
pLE->setGeometry(pos_x+nLabelWidth+10,pos_y,nLEWidth,nHeight);
|
|
|
-
|
|
|
return pLE;
|
|
|
}
|
|
|
|
|
@@ -37,15 +84,12 @@ QComboBox * DialogRoadObject::CreateCB(int pos_x, int pos_y, int nLabelWidth, in
|
|
|
{
|
|
|
QComboBox * pCB;
|
|
|
QLabel * pLabel;
|
|
|
-
|
|
|
pLabel = new QLabel(this);
|
|
|
pLabel->setGeometry(pos_x,pos_y,nLabelWidth,nHeight);
|
|
|
pLabel->setText(strname.data());
|
|
|
pLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
|
|
-
|
|
|
pCB = new QComboBox(this);
|
|
|
pCB->setGeometry(pos_x+nLabelWidth+10,pos_y,nLEWidth,nHeight);
|
|
|
-
|
|
|
return pCB;
|
|
|
}
|
|
|
|
|
@@ -58,7 +102,6 @@ void DialogRoadObject::CreateView()
|
|
|
int nLEWidth = 150;
|
|
|
int nHeight = 30;
|
|
|
int nVSpace = 50;
|
|
|
-
|
|
|
int nVIndex = 0;
|
|
|
mpLEt = CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"t");
|
|
|
mpLEzOffset = CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"zOffset");
|
|
@@ -82,6 +125,343 @@ void DialogRoadObject::CreateView()
|
|
|
nVIndex++;
|
|
|
mpLEwidth = CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"width");
|
|
|
mpLEradius = CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"radius");
|
|
|
+}
|
|
|
+
|
|
|
+bool DialogRoadObject::CheckLE(QLineEdit *pLE, QString stritemname,bool bWarning)
|
|
|
+{
|
|
|
+ QString str = pLE->text();
|
|
|
+ if(str == "")
|
|
|
+ {
|
|
|
+ if(bWarning)QMessageBox::warning(this,"Warning",stritemname + " is not set",QMessageBox::YesAll);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+void DialogRoadObject::on_pushButton_add_clicked()
|
|
|
+{
|
|
|
+ Road * pRoad = mpRoad;
|
|
|
+ if(CheckLE(mpLEid,"id") == false)return;
|
|
|
+ string id = mpLEid->text().toStdString();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEt,"t") == false)return;
|
|
|
+ double t = mpLEt->text().toDouble();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEs,"s") == false)return;
|
|
|
+ double s = mpLEs->text().toDouble();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEzOffset,"zOffset") == false)return;
|
|
|
+ double zOffset = mpLEzOffset->text().toDouble();
|
|
|
+
|
|
|
+ double length,width,hdg;
|
|
|
+ if(mpCBtype->currentText() == "parkingSpace")
|
|
|
+ {
|
|
|
+ if(CheckLE(mpLElength,"length") == false)return;
|
|
|
+ length = mpLElength->text().toDouble();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEwidth,"width") == false)return;
|
|
|
+ width = mpLEwidth->text().toDouble();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEhdg,"hdg") == false)return;
|
|
|
+ hdg = mpLEhdg->text().toDouble();
|
|
|
+ }
|
|
|
+
|
|
|
+ pRoad->AddObject(id,s,t,zOffset);
|
|
|
+
|
|
|
+ Object * pObject = pRoad->GetLastAddedObject();
|
|
|
+
|
|
|
+ pObject->Settype(mpCBtype->currentText().toStdString());
|
|
|
+
|
|
|
+ if(CheckLE(mpLEvalidLength,"validLength",false))
|
|
|
+ {
|
|
|
+ pObject->SetvalidLength(mpLEvalidLength->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mpCBorientation->currentIndex() != 3)
|
|
|
+ {
|
|
|
+ pObject->Setorientation(mpCBorientation->currentText().toStdString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEsubtype,"subtype",false))
|
|
|
+ {
|
|
|
+ pObject->Setsubtype(mpLEsubtype->text().toStdString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mpCBdynamic->currentIndex()!= 2)
|
|
|
+ {
|
|
|
+ pObject->Setdynamic(mpCBdynamic->currentText().toStdString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEname,"name",false))
|
|
|
+ {
|
|
|
+ pObject->Setname(mpLEname->text().toStdString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEhdg,"hdg",false))
|
|
|
+ {
|
|
|
+ pObject->Sethdg(mpLEhdg->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEpitch,"pitch",false))
|
|
|
+ {
|
|
|
+ pObject->Setpitch(mpLEpitch->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEroll,"roll",false))
|
|
|
+ {
|
|
|
+ pObject->Setroll(mpLEroll->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEheight,"height",false))
|
|
|
+ {
|
|
|
+ pObject->Setheight(mpLEheight->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLElength,"length",false))
|
|
|
+ {
|
|
|
+ pObject->Setlength(mpLElength->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEwidth,"width",false))
|
|
|
+ {
|
|
|
+ pObject->Setwidth(mpLEwidth->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEradius,"radius",false))
|
|
|
+ {
|
|
|
+ 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(CheckLE(mpLEid,"id") == false)return;
|
|
|
+ string id = mpLEid->text().toStdString();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEt,"t") == false)return;
|
|
|
+ double t = mpLEt->text().toDouble();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEs,"s") == false)return;
|
|
|
+ double s = mpLEs->text().toDouble();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEzOffset,"zOffset") == false)return;
|
|
|
+ double zOffset = mpLEzOffset->text().toDouble();
|
|
|
+
|
|
|
+
|
|
|
+ double length,width,hdg;
|
|
|
+ if(mpCBtype->currentText() == "parkingSpace")
|
|
|
+ {
|
|
|
+ if(CheckLE(mpLElength,"length") == false)return;
|
|
|
+ length = mpLElength->text().toDouble();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEwidth,"width") == false)return;
|
|
|
+ width = mpLEwidth->text().toDouble();
|
|
|
+
|
|
|
+ if(CheckLE(mpLEhdg,"hdg") == false)return;
|
|
|
+ hdg = mpLEhdg->text().toDouble();
|
|
|
+ }
|
|
|
+
|
|
|
+ pObject->Setid(id);
|
|
|
+ pObject->Sets(s);
|
|
|
+ pObject->Sett(t);
|
|
|
+ pObject->SetzOffset(zOffset);
|
|
|
+
|
|
|
+ pObject->Settype(mpCBtype->currentText().toStdString());
|
|
|
+
|
|
|
+ if(CheckLE(mpLEvalidLength,"validLength",false))
|
|
|
+ {
|
|
|
+ pObject->SetvalidLength(mpLEvalidLength->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mpCBorientation->currentIndex() != 3)
|
|
|
+ {
|
|
|
+ pObject->Setorientation(mpCBorientation->currentText().toStdString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEsubtype,"subtype",false))
|
|
|
+ {
|
|
|
+ pObject->Setsubtype(mpLEsubtype->text().toStdString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mpCBdynamic->currentIndex()!= 2)
|
|
|
+ {
|
|
|
+ pObject->Setdynamic(mpCBdynamic->currentText().toStdString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEhdg,"hdg",false))
|
|
|
+ {
|
|
|
+ pObject->Sethdg(mpLEhdg->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEname,"name",false))
|
|
|
+ {
|
|
|
+ pObject->Setname(mpLEname->text().toStdString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEpitch,"pitch",false))
|
|
|
+ {
|
|
|
+ pObject->Setpitch(mpLEpitch->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEroll,"roll",false))
|
|
|
+ {
|
|
|
+ pObject->Setroll(mpLEroll->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEheight,"height",false))
|
|
|
+ {
|
|
|
+ pObject->Setheight(mpLEheight->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLElength,"length",false))
|
|
|
+ {
|
|
|
+ pObject->Setlength(mpLElength->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEwidth,"width",false))
|
|
|
+ {
|
|
|
+ pObject->Setwidth(mpLEwidth->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CheckLE(mpLEradius,"radius",false))
|
|
|
+ {
|
|
|
+ pObject->Setradius(mpLEradius->text().toDouble());
|
|
|
+ }
|
|
|
+
|
|
|
+ QMessageBox::information(this,"Info","Change Object Successfull.",QMessageBox::YesAll);
|
|
|
}
|
|
|
+
|