#include "speeddialog.h" #include "ui_speeddialog.h" SpeedDialog::SpeedDialog(OpenDrive * pxodr,QWidget *parent) : QDialog(parent), ui(new Ui::SpeedDialog) { ui->setupUi(this); mpxodr = pxodr; int i; int nroadcount = mpxodr->GetRoadCount(); for(i=0;iGetRoad(i)->GetRoadId().data(); ui->comboBox_Road->addItem(strname); } } SpeedDialog::~SpeedDialog() { delete ui; } void SpeedDialog::on_comboBox_Road_currentIndexChanged(int index) { Road * pRoad = mpxodr->GetRoad(index); if(pRoad == 0) { // QMessageBox::warning(this,"WARN","MainWindow::onClickCBRoadChange road is NULL"); return; } ui->lineEdit_RoadLen->setText(QString::number(pRoad->GetRoadLength(),'f',3)); int i; LaneSection * pLS = pRoad->GetLaneSection(0); if(pLS == 0)return; int nlanecount = pLS->GetLaneCount(); ui->comboBox_Lane->clear(); for(i=0;iGetLane(i); snprintf(strout,255,"%d",pLane->GetId()); ui->comboBox_Lane->addItem(strout); } } void SpeedDialog::on_comboBox_Lane_currentIndexChanged(int index) { Road * pRoad = mpxodr->GetRoad(ui->comboBox_Road->currentIndex()); if(pRoad == 0) { // QMessageBox::warning(this,"WARN","MainWindow::onClickCBRoadChange road is NULL"); return; } int i; LaneSection * pLS = pRoad->GetLaneSection(0); if(pLS == 0)return; Lane * pLane = pLS->GetLane(ui->comboBox_Lane->currentIndex()); ui->comboBox_Speed->clear(); if(pLane == 0)return; int nspeedcount = pLane->GetLaneSpeedCount(); for(i=0;iGetLaneSpeed(i); char strout[255]; snprintf(strout,255,"S:%f Speed:%f",pSpeed->GetS(),pSpeed->GetMax()); ui->comboBox_Speed->addItem(strout); } } void SpeedDialog::on_comboBox_Speed_currentIndexChanged(int index) { } void SpeedDialog::on_pushButton_add_clicked() { double s = ui->lineEdit_s->text().toDouble(); double speedlim = ui->lineEdit_speedlim->text().toDouble(); Road * pRoad = mpxodr->GetRoad(ui->comboBox_Road->currentIndex()); if(pRoad == 0) { // QMessageBox::warning(this,"WARN","MainWindow::onClickCBRoadChange road is NULL"); return; } int i; LaneSection * pLS = pRoad->GetLaneSection(0); if(pLS == 0)return; Lane * pLane = pLS->GetLane(ui->comboBox_Lane->currentIndex()); pLane->AddSpeedRecord(s,speedlim); on_comboBox_Lane_currentIndexChanged(ui->comboBox_Lane->currentIndex()); } void SpeedDialog::on_pushButton_del_clicked() { Road * pRoad = mpxodr->GetRoad(ui->comboBox_Road->currentIndex()); if(pRoad == 0) { // QMessageBox::warning(this,"WARN","MainWindow::onClickCBRoadChange road is NULL"); return; } int i; LaneSection * pLS = pRoad->GetLaneSection(0); if(pLS == 0)return; Lane * pLane = pLS->GetLane(ui->comboBox_Lane->currentIndex()); pLane->DeleteLaneSpeed(ui->comboBox_Speed->currentIndex()); on_comboBox_Lane_currentIndexChanged(ui->comboBox_Lane->currentIndex()); }