|
@@ -0,0 +1,242 @@
|
|
|
+#include "dialogroadtype.h"
|
|
|
+#include "ui_dialogroadtype.h"
|
|
|
+
|
|
|
+static std::string strroadtypelist[] = {"unknown","rural","motorway","town","lowSpeed","pedestrian","bicycle","townExpressway",
|
|
|
+ "townCollector","townArterial","townPrivate","townLocal","townPlayStreet"};
|
|
|
+static const int strroadtypecount = 13;
|
|
|
+
|
|
|
+DialogRoadType::DialogRoadType(Road * pCurRoad,QWidget *parent) :
|
|
|
+ QDialog(parent),
|
|
|
+ ui(new Ui::DialogRoadType)
|
|
|
+{
|
|
|
+ ui->setupUi(this);
|
|
|
+ mpRoad = pCurRoad;
|
|
|
+
|
|
|
+ unsigned int i;
|
|
|
+ for(i=0;i<strroadtypecount;i++)
|
|
|
+ {
|
|
|
+ ui->comboBox_Type->addItem(strroadtypelist[i].data());
|
|
|
+ }
|
|
|
+ ui->comboBox_Type->setCurrentIndex(3);
|
|
|
+
|
|
|
+ UpdateCombo();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+DialogRoadType::~DialogRoadType()
|
|
|
+{
|
|
|
+ delete ui;
|
|
|
+}
|
|
|
+
|
|
|
+void DialogRoadType::UpdateCombo()
|
|
|
+{
|
|
|
+ ui->comboBox_RoadTypeList->clear();
|
|
|
+
|
|
|
+ if(mpRoad == 0)return;
|
|
|
+
|
|
|
+ Road * pRoad = mpRoad;
|
|
|
+ unsigned int lRoadTypeCount = pRoad->GetRoadTypeCount();
|
|
|
+ unsigned int i;
|
|
|
+ for(i=0;i<lRoadTypeCount;i++)
|
|
|
+ {
|
|
|
+ RoadType * pRoadType = pRoad->GetRoadType(i);
|
|
|
+ ui->comboBox_RoadTypeList->addItem("s = "+ QString::number(pRoadType->GetS()));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void DialogRoadType::on_pushButton_Add_clicked()
|
|
|
+{
|
|
|
+ if(mpRoad == 0)return;
|
|
|
+
|
|
|
+ if(ui->lineEdit_s->text() == "")
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","s is not set.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ double s = ui->lineEdit_s->text().toDouble();
|
|
|
+ string type = ui->comboBox_Type->currentText().toStdString();
|
|
|
+ mpRoad->AddRoadType(s,type);
|
|
|
+
|
|
|
+ UpdateCombo();
|
|
|
+}
|
|
|
+
|
|
|
+void DialogRoadType::on_comboBox_RoadTypeList_currentIndexChanged(int index)
|
|
|
+{
|
|
|
+ ui->lineEdit_s->setText("");
|
|
|
+ ui->lineEdit_SpeedMax->setText("");
|
|
|
+
|
|
|
+ if(index == -1)return;
|
|
|
+
|
|
|
+ if((index<0) ||((int)index >= mpRoad->GetRoadTypeCount()))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ RoadType * pRoadType = mpRoad->GetRoadType(index);
|
|
|
+ ui->lineEdit_s->setText(QString::number(pRoadType->GetS()));
|
|
|
+
|
|
|
+ int ntypeindex = 0;
|
|
|
+ int i;
|
|
|
+ for(i=0;i<strroadtypecount;i++)
|
|
|
+ {
|
|
|
+ if(strroadtypelist[i] == pRoadType->GetType())
|
|
|
+ {
|
|
|
+ ntypeindex = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ui->comboBox_Type->setCurrentIndex(ntypeindex);
|
|
|
+
|
|
|
+ if(pRoadType->GetRoadTypeSpeedCount()>0)
|
|
|
+ {
|
|
|
+ RoadTypeSpeed * pRoadTypeSpeed = pRoadType->GetRoadTypeSpeed(0);
|
|
|
+ double fratio = 1.0;
|
|
|
+ string strunit = pRoadTypeSpeed->Getunit();
|
|
|
+ if(strunit == "km/h")fratio = fratio/3.6;
|
|
|
+ if(strunit == "mph")fratio = fratio*1.609344 /3.6;
|
|
|
+ double fspeedmax = pRoadTypeSpeed->GetmaxSpeed() * fratio;
|
|
|
+ ui->lineEdit_SpeedMax->setText(QString::number(fspeedmax,'f',3));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ui->lineEdit_SpeedMax->setText("");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void DialogRoadType::on_pushButton_ClearSpeed_clicked()
|
|
|
+{
|
|
|
+ if(mpRoad == 0)return;
|
|
|
+
|
|
|
+ if(mpRoad->GetRoadTypeCount() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","No RoadType",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ RoadType * pRoadType = mpRoad->GetRoadType(ui->comboBox_RoadTypeList->currentIndex());
|
|
|
+
|
|
|
+ if(pRoadType == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","Can't Get RoadType",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(pRoadType->GetRoadTypeSpeedCount() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::information(this,"Info","This RoadType Don't have Road Type Speed.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ pRoadType->GetRoadTypeSpeedVector()->clear();
|
|
|
+
|
|
|
+ QMessageBox::information(this,"Info","Clear Road Type Speed Successfully.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void DialogRoadType::on_pushButton_ChangeSpeed_clicked()
|
|
|
+{
|
|
|
+ if(mpRoad == 0)return;
|
|
|
+
|
|
|
+ if(mpRoad->GetRoadTypeCount() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","No RoadType",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ RoadType * pRoadType = mpRoad->GetRoadType(ui->comboBox_RoadTypeList->currentIndex());
|
|
|
+
|
|
|
+ if(pRoadType == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","Can't Get RoadType",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(pRoadType->GetRoadTypeSpeedCount() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Info","This RoadType Don't have Road Type Speed.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double fratio = 1.0;
|
|
|
+ RoadTypeSpeed * pRoadTypeSpeed = pRoadType->GetRoadTypeSpeed(0);
|
|
|
+ string strunit = pRoadTypeSpeed->Getunit();
|
|
|
+ if(strunit == "km/h")fratio = fratio/3.6;
|
|
|
+ if(strunit == "mph")fratio = fratio*1.609344 /3.6;
|
|
|
+ pRoadTypeSpeed->SetmaxSpeed(ui->lineEdit_SpeedMax->text().toDouble()/fratio);
|
|
|
+
|
|
|
+ QMessageBox::information(this,"Info","Change Road Type Speed Successfully.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void DialogRoadType::on_pushButton_SetSpeed_clicked()
|
|
|
+{
|
|
|
+ if(ui->lineEdit_SpeedMax->text() == "")
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","Speed Not Set",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mpRoad == 0)return;
|
|
|
+
|
|
|
+ if(mpRoad->GetRoadTypeCount() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","No RoadType",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ RoadType * pRoadType = mpRoad->GetRoadType(ui->comboBox_RoadTypeList->currentIndex());
|
|
|
+
|
|
|
+ if(pRoadType == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","Can't Get RoadType",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ while(pRoadType->GetRoadTypeSpeedCount()>0)pRoadType->DeleteRoadTypeSpeed(0);
|
|
|
+
|
|
|
+ pRoadType->AddRoadTypeSpeed(ui->lineEdit_SpeedMax->text().toDouble(),"m/s");
|
|
|
+ QMessageBox::information(this,"Info","Add Road Type Speed Successfully.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void DialogRoadType::on_pushButton_Delete_clicked()
|
|
|
+{
|
|
|
+ if(mpRoad == 0)return;
|
|
|
+
|
|
|
+ if(mpRoad->GetRoadTypeCount() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","No Road Type.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mpRoad->DeleteRoadType(ui->comboBox_RoadTypeList->currentIndex());
|
|
|
+
|
|
|
+ QMessageBox::information(this,"Info","Delete Road Type Successfully,",QMessageBox::YesAll);
|
|
|
+ UpdateCombo();
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void DialogRoadType::on_pushButton_Change_clicked()
|
|
|
+{
|
|
|
+ if(mpRoad == 0)return;
|
|
|
+
|
|
|
+ if(mpRoad->GetRoadTypeCount() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","No Road Type.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ RoadType * pRoadType = mpRoad->GetRoadType(ui->comboBox_RoadTypeList->currentIndex());
|
|
|
+
|
|
|
+ if(pRoadType == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","Can't Get RoadType",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ pRoadType->SetS(ui->lineEdit_s->text().toDouble());
|
|
|
+ pRoadType->SetType(ui->comboBox_Type->currentText().toStdString());
|
|
|
+
|
|
|
+ QMessageBox::information(this,"Info","Change Road Type Successfully,",QMessageBox::YesAll);
|
|
|
+ UpdateCombo();
|
|
|
+ return;
|
|
|
+}
|