123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- #include "dialogeditroadmark.h"
- #include "ui_dialogeditroadmark.h"
- const std::string roadcolorchoice[] = {"standard","blue","green","red","white","yellow","orange"};
- const std::string lanechangechoice[] = {"both","none","increase","decrease"};
- const std::string marktypechoice[] = {"none","solid","broken","solid solid","solid broken",
- "broken solid","broken broken"};
- DialogEditRoadMark::DialogEditRoadMark(Road * pRoad,QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DialogEditRoadMark)
- {
- mpRoad = pRoad;
- ui->setupUi(this);
- int i;
- for(i=0;i<7;i++)ui->comboBox_color->addItem(QString(roadcolorchoice[i].data()));
- for(i=0;i<4;i++)ui->comboBox_laneChange->addItem(QString(lanechangechoice[i].data()));
- for(i=0;i<7;i++)ui->comboBox_MarkType->addItem(QString(marktypechoice[i].data()));
- ui->comboBox_MarkType->setCurrentIndex(1);
- ui->comboBox_weight->addItem("standard");
- ui->comboBox_weight->addItem("bold");
- int nsection = pRoad->GetLaneSectionCount();
- for(i=0;i<nsection;i++)
- {
- LaneSection * pLS = pRoad->GetLaneSection(i);
- QString stritemname = QString("s=") + QString::number(pLS->GetS());
- ui->comboBox_LaneSection->addItem(stritemname);
- }
- if(nsection > 0)on_comboBox_LaneSection_currentIndexChanged(0);
- setWindowTitle(tr("Edit RoadMark"));
- }
- DialogEditRoadMark::~DialogEditRoadMark()
- {
- delete ui;
- }
- void DialogEditRoadMark::on_comboBox_LaneSection_currentIndexChanged(int index)
- {
- if(mpRoad == 0)return;
- LaneSection * pLS = mpRoad->GetLaneSection(index);
- ui->comboBox_Lane->clear();
- mpCurLS = pLS;
- if(pLS == 0)return;
- int nLaneCount = pLS->GetLaneCount();
- int i;
- for(i=0;i<nLaneCount;i++)
- {
- Lane * pLane = pLS->GetLane(i);
- QString stritemname = QString::number(pLane->GetId());
- ui->comboBox_Lane->addItem(stritemname);
- }
- if(nLaneCount > 0)on_comboBox_Lane_currentIndexChanged(0);
- }
- void DialogEditRoadMark::on_comboBox_Lane_currentIndexChanged(int index)
- {
- if(mpCurLS == 0)return;
- Lane * pLane = mpCurLS->GetLane(index);
- ui->comboBox_Mark->clear();
- mpCurLane = pLane;
- if(pLane == 0)return;
- ui->comboBox_Mark->clear();
- int nRoadMarkCount = pLane->GetLaneRoadMarkCount();
- if(nRoadMarkCount == 0)
- {
- ui->lineEdit_sOffset->setText("");
- ui->lineEdit_width->setText("");
- return;
- }
- int i;
- for(i=0;i<nRoadMarkCount;i++)
- {
- ui->comboBox_Mark->addItem(QString("s=")+QString::number(pLane->GetLaneRoadMark(i)->GetS()));
- }
- on_comboBox_Mark_currentIndexChanged(0);
- }
- void DialogEditRoadMark::on_comboBox_Mark_currentIndexChanged(int index)
- {
- if(mpCurLane == 0)return;
- LaneRoadMark * pLaneRoadMark = mpCurLane->GetLaneRoadMark(index);
- if(pLaneRoadMark == 0)return;
- ui->comboBox_MarkType->setCurrentIndex(1);
- std::string strmarktype = pLaneRoadMark->GetType();
- int i;
- const int typechoicecount = 7;
- for(i=0;i<typechoicecount;i++)
- {
- if(strmarktype == marktypechoice[i])break;
- }
- if(i<typechoicecount)ui->comboBox_MarkType->setCurrentIndex(i);
- else ui->comboBox_MarkType->setCurrentIndex(1);
- std::string strlanechange = pLaneRoadMark->GetLaneChange();
- const int lanechagnechoicecount = 4;
- for(i=0;i<lanechagnechoicecount;i++)
- {
- if(strlanechange == lanechangechoice[i])break;
- }
- if(i<lanechagnechoicecount)ui->comboBox_laneChange->setCurrentIndex(i);
- else ui->comboBox_laneChange->setCurrentIndex(0);
- std::string strweight = pLaneRoadMark->GetWeight();
- if(strweight == "bold")ui->comboBox_weight->setCurrentIndex(1);
- else ui->comboBox_weight->setCurrentIndex(0);
- std::string strcolor = pLaneRoadMark->GetColor();
- const int lanemarkcolorcount = 7;
- for(i=0;i<lanemarkcolorcount;i++)
- {
- if(strcolor == roadcolorchoice[i])break;
- }
- if(i<lanemarkcolorcount)ui->comboBox_color->setCurrentIndex(i);
- else ui->comboBox_color->setCurrentIndex(0);
- ui->lineEdit_sOffset->setText(QString::number(pLaneRoadMark->GetS()));
- ui->lineEdit_width->setText(QString::number(pLaneRoadMark->GetWidth()));
- }
- void DialogEditRoadMark::on_pushButton_AddLaneRoadMark_clicked()
- {
- if(mpCurLS == 0)return;
- Lane * pLane = mpCurLS->GetLane(ui->comboBox_Lane->currentIndex());
- if(pLane != 0)
- {
- double soffset = ui->lineEdit_sOffset->text().toDouble();
- double fwidth = ui->lineEdit_width->text().toDouble();
- if(fwidth<=0)fwidth = 0.15;
- std::string strcolor = ui->comboBox_color->currentText().toStdString();
- std::string strlanechagne = ui->comboBox_laneChange->currentText().toStdString();
- std::string strmarktype = ui->comboBox_MarkType->currentText().toStdString();
- std::string strweight = ui->comboBox_weight->currentText().toStdString();
- pLane->AddRoadMarkRecord(soffset,strmarktype,strweight,strcolor,fwidth,strlanechagne);
- }
- on_comboBox_Lane_currentIndexChanged(ui->comboBox_Lane->currentIndex());
- }
- void DialogEditRoadMark::on_pushButton_ChangeLaneRoadMark_clicked()
- {
- if(mpCurLS == 0)return;
- Lane * pLane = mpCurLS->GetLane(ui->comboBox_Lane->currentIndex());
- if(pLane != 0)
- {
- LaneRoadMark * pLaneRoadMark = pLane->GetLaneRoadMark(ui->comboBox_Mark->currentIndex());
- if(pLaneRoadMark != 0)
- {
- pLaneRoadMark->SetColor(ui->comboBox_color->currentText().toStdString());
- pLaneRoadMark->SetLaneChange(ui->comboBox_laneChange->currentText().toStdString());
- pLaneRoadMark->SetS(ui->lineEdit_sOffset->text().toDouble());
- double fwidth = ui->lineEdit_width->text().toDouble();
- if(fwidth<=0)fwidth = 0.15;
- pLaneRoadMark->SetWidth(fwidth);
- pLaneRoadMark->SetType(ui->comboBox_MarkType->currentText().toStdString());
- pLaneRoadMark->SetWeight(ui->comboBox_weight->currentText().toStdString());
- }
- }
- // on_comboBox_Width_currentIndexChanged(ui->comboBox_Width->currentIndex());
- }
- void DialogEditRoadMark::on_pushButton_DeleteLaneRoadMark_clicked()
- {
- if(mpCurLS == 0)return;
- Lane * pLane = mpCurLS->GetLane(ui->comboBox_Lane->currentIndex());
- if(pLane != 0)
- {
- LaneRoadMark * pLaneRoadMark = pLane->GetLaneRoadMark(ui->comboBox_Mark->currentIndex());
- if(pLaneRoadMark != 0)
- {
- pLane->DeleteLaneRoadMark(ui->comboBox_Mark->currentIndex());
- }
- }
- on_comboBox_Lane_currentIndexChanged(ui->comboBox_Lane->currentIndex());
- }
|