|
@@ -4,6 +4,8 @@
|
|
#include "trafficlightlanevaliditydialog.h"
|
|
#include "trafficlightlanevaliditydialog.h"
|
|
#include "trafficlightpositiondialog.h"
|
|
#include "trafficlightpositiondialog.h"
|
|
|
|
|
|
|
|
+#include <QMessageBox>
|
|
|
|
+
|
|
TrafficLightDialog::TrafficLightDialog(OpenDrive * pxodr,QWidget *parent) :
|
|
TrafficLightDialog::TrafficLightDialog(OpenDrive * pxodr,QWidget *parent) :
|
|
QDialog(parent),
|
|
QDialog(parent),
|
|
ui(new Ui::TrafficLightDialog)
|
|
ui(new Ui::TrafficLightDialog)
|
|
@@ -14,6 +16,8 @@ TrafficLightDialog::TrafficLightDialog(OpenDrive * pxodr,QWidget *parent) :
|
|
ui->comboBox_dynamic->addItem("yes");
|
|
ui->comboBox_dynamic->addItem("yes");
|
|
ui->comboBox_dynamic->addItem("no");
|
|
ui->comboBox_dynamic->addItem("no");
|
|
|
|
|
|
|
|
+ ui->lineEdit_id->setReadOnly(true);
|
|
|
|
+
|
|
int i;
|
|
int i;
|
|
int nroadcount = mpxodr->GetRoadCount();
|
|
int nroadcount = mpxodr->GetRoadCount();
|
|
for(i=0;i<nroadcount;i++)
|
|
for(i=0;i<nroadcount;i++)
|
|
@@ -146,3 +150,156 @@ void TrafficLightDialog::on_pushButton_EditlaneValidity_clicked()
|
|
int res = td.exec();
|
|
int res = td.exec();
|
|
(void)&res;
|
|
(void)&res;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+void TrafficLightDialog::on_pushButton_Add_clicked()
|
|
|
|
+{
|
|
|
|
+ Road * pRoad =mpxodr->GetRoad(ui->comboBox_Road->currentIndex());
|
|
|
|
+ if(pRoad == 0)return;
|
|
|
|
+
|
|
|
|
+ double s;
|
|
|
|
+ double t;
|
|
|
|
+ string id;
|
|
|
|
+ string name;
|
|
|
|
+ bool dynamic;
|
|
|
|
+ string orientation;
|
|
|
|
+ double zOffset;
|
|
|
|
+ string type;
|
|
|
|
+ string country;
|
|
|
|
+ string countryRevision;
|
|
|
|
+ string subtype;
|
|
|
|
+ double hOffset;
|
|
|
|
+ double pitch;
|
|
|
|
+ double roll;
|
|
|
|
+ double height;
|
|
|
|
+ double width;
|
|
|
|
+
|
|
|
|
+ int nid = getnewsignalid();
|
|
|
|
+ string strid = QString::number(nid).toStdString();
|
|
|
|
+
|
|
|
|
+ geteditvalue(s,t,name,dynamic,orientation,zOffset,type,country,countryRevision,
|
|
|
|
+ subtype,hOffset,pitch,roll,height,width);
|
|
|
|
+
|
|
|
|
+ pRoad->AddSignal(s,t,strid,name,dynamic,orientation,zOffset,type,country,countryRevision,
|
|
|
|
+ subtype,hOffset,pitch,roll,height,width);
|
|
|
|
+
|
|
|
|
+ on_comboBox_Road_currentIndexChanged(ui->comboBox_Road->currentIndex());
|
|
|
|
+ ui->comboBox_TrafficLIght->setCurrentIndex(pRoad->GetSignalCount()-1);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void TrafficLightDialog::on_pushButton_Delete_clicked()
|
|
|
|
+{
|
|
|
|
+ Road * pRoad =mpxodr->GetRoad(ui->comboBox_Road->currentIndex());
|
|
|
|
+ if(pRoad == 0)return;
|
|
|
|
+
|
|
|
|
+ if(pRoad->GetSignalCount() == 0)
|
|
|
|
+ {
|
|
|
|
+ QMessageBox::warning(this,"warning","No Signal Delete.");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pRoad->DeleteSignal(ui->comboBox_TrafficLIght->currentIndex());
|
|
|
|
+
|
|
|
|
+ on_comboBox_Road_currentIndexChanged(ui->comboBox_Road->currentIndex());
|
|
|
|
+ ui->comboBox_TrafficLIght->setCurrentIndex(pRoad->GetSignalCount()-1);
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void TrafficLightDialog::on_pushButton_Update_clicked()
|
|
|
|
+{
|
|
|
|
+ Road * pRoad =mpxodr->GetRoad(ui->comboBox_Road->currentIndex());
|
|
|
|
+ if(pRoad == 0)return;
|
|
|
|
+
|
|
|
|
+ if(pRoad->GetSignalCount() == 0)return;
|
|
|
|
+ Signal * pSignal =pRoad->GetSignal(ui->comboBox_TrafficLIght->currentIndex());
|
|
|
|
+ if(pSignal == 0)return;
|
|
|
|
+
|
|
|
|
+ double s;
|
|
|
|
+ double t;
|
|
|
|
+ string name;
|
|
|
|
+ bool dynamic;
|
|
|
|
+ string orientation;
|
|
|
|
+ double zOffset;
|
|
|
|
+ string type;
|
|
|
|
+ string country;
|
|
|
|
+ string countryRevision;
|
|
|
|
+ string subtype;
|
|
|
|
+ double hOffset;
|
|
|
|
+ double pitch;
|
|
|
|
+ double roll;
|
|
|
|
+ double height;
|
|
|
|
+ double width;
|
|
|
|
+
|
|
|
|
+ geteditvalue(s,t,name,dynamic,orientation,zOffset,type,country,countryRevision,
|
|
|
|
+ subtype,hOffset,pitch,roll,height,width);
|
|
|
|
+
|
|
|
|
+ pSignal->Sets(s);
|
|
|
|
+ pSignal->Sett(t);
|
|
|
|
+ pSignal->Setname(name);
|
|
|
|
+ pSignal->Setdynamic(dynamic);
|
|
|
|
+ pSignal->Setorientation(orientation);
|
|
|
|
+ pSignal->SetzOffset(zOffset);
|
|
|
|
+ pSignal->Settype(type);
|
|
|
|
+ pSignal->Setcountry(country);
|
|
|
|
+ pSignal->SetcountryRevision(countryRevision);
|
|
|
|
+ pSignal->Setsubtype(subtype);
|
|
|
|
+ pSignal->SethOffset(hOffset);
|
|
|
|
+ pSignal->Setpitch(pitch);
|
|
|
|
+ pSignal->Setroll(roll);
|
|
|
|
+ pSignal->Setheight(height);
|
|
|
|
+ pSignal->Setwidth(width);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int TrafficLightDialog::geteditvalue(double &s, double &t, std::string &name, bool &dynamic,
|
|
|
|
+ std::string &orientation, double &zOffset, std::string &type,
|
|
|
|
+ std::string &country, std::string &countryRevision, std::string &subtype,
|
|
|
|
+ double &hOffset, double &pitch, double &roll, double &height, double &width)
|
|
|
|
+{
|
|
|
|
+ s = ui->lineEdit_s->text().toDouble();
|
|
|
|
+ t = ui->lineEdit_t->text().toDouble();
|
|
|
|
+ name = ui->lineEdit_name->text().toStdString();
|
|
|
|
+ if(ui->comboBox_dynamic->currentIndex() == 0)dynamic = true;
|
|
|
|
+ else dynamic = false;
|
|
|
|
+ orientation = ui->lineEdit_orientation->text().toStdString();
|
|
|
|
+ zOffset = ui->lineEdit_zOffset->text().toDouble();
|
|
|
|
+ type = ui->lineEdit_type->text().toStdString();
|
|
|
|
+ country = ui->lineEdit_country->text().toStdString();
|
|
|
|
+ countryRevision = ui->lineEdit_countryRevision->text().toStdString();
|
|
|
|
+ subtype = ui->lineEdit_subtype->text().toStdString();
|
|
|
|
+ hOffset = ui->lineEdit_hOffset->text().toDouble();
|
|
|
|
+ pitch = ui->lineEdit_pitch->text().toDouble();
|
|
|
|
+ roll = ui->lineEdit_roll->text().toDouble();
|
|
|
|
+ height = ui->lineEdit_height->text().toDouble();
|
|
|
|
+ width = ui->lineEdit_width->text().toDouble();
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int TrafficLightDialog::getnewsignalid()
|
|
|
|
+{
|
|
|
|
+ int id = -1;
|
|
|
|
+ bool bHaveExist = false;
|
|
|
|
+ do
|
|
|
|
+ {
|
|
|
|
+ bHaveExist = false;
|
|
|
|
+ id = id + 1;
|
|
|
|
+ int nroadcount = mpxodr->GetRoadCount();
|
|
|
|
+ int i,j;
|
|
|
|
+ for(i=0;i<nroadcount;i++)
|
|
|
|
+ {
|
|
|
|
+ Road * pRoad = mpxodr->GetRoad(i);
|
|
|
|
+ int nsignalcount = pRoad->GetSignalCount();
|
|
|
|
+ for(j=0;j<nsignalcount;j++)
|
|
|
|
+ {
|
|
|
|
+ if(id == atoi(pRoad->GetSignal(j)->Getid().data()))
|
|
|
|
+ {
|
|
|
|
+ bHaveExist = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(bHaveExist)break;
|
|
|
|
+ }
|
|
|
|
+ }while(bHaveExist == true);
|
|
|
|
+ return id;
|
|
|
|
+}
|