123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #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;i<nroadcount;i++)
- {
- const char * strname = mpxodr->GetRoad(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;i<nlanecount;i++)
- {
- char strout[255];
- Lane * pLane = pLS->GetLane(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;i<nspeedcount;i++)
- {
- LaneSpeed * pSpeed = pLane->GetLaneSpeed(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());
- }
|