dialogeditroadmark.cpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #include "dialogeditroadmark.h"
  2. #include "ui_dialogeditroadmark.h"
  3. const std::string roadcolorchoice[] = {"standard","blue","green","red","white","yellow","orange"};
  4. const std::string lanechangechoice[] = {"both","none","increase","decrease"};
  5. const std::string marktypechoice[] = {"none","solid","broken","solid solid","solid broken",
  6. "broken solid","broken broken"};
  7. DialogEditRoadMark::DialogEditRoadMark(Road * pRoad,QWidget *parent) :
  8. QDialog(parent),
  9. ui(new Ui::DialogEditRoadMark)
  10. {
  11. mpRoad = pRoad;
  12. ui->setupUi(this);
  13. int i;
  14. for(i=0;i<7;i++)ui->comboBox_color->addItem(QString(roadcolorchoice[i].data()));
  15. for(i=0;i<4;i++)ui->comboBox_laneChange->addItem(QString(lanechangechoice[i].data()));
  16. for(i=0;i<7;i++)ui->comboBox_MarkType->addItem(QString(marktypechoice[i].data()));
  17. ui->comboBox_MarkType->setCurrentIndex(1);
  18. ui->comboBox_weight->addItem("standard");
  19. ui->comboBox_weight->addItem("bold");
  20. int nsection = pRoad->GetLaneSectionCount();
  21. for(i=0;i<nsection;i++)
  22. {
  23. LaneSection * pLS = pRoad->GetLaneSection(i);
  24. QString stritemname = QString("s=") + QString::number(pLS->GetS());
  25. ui->comboBox_LaneSection->addItem(stritemname);
  26. }
  27. if(nsection > 0)on_comboBox_LaneSection_currentIndexChanged(0);
  28. setWindowTitle(tr("Edit RoadMark"));
  29. }
  30. DialogEditRoadMark::~DialogEditRoadMark()
  31. {
  32. delete ui;
  33. }
  34. void DialogEditRoadMark::on_comboBox_LaneSection_currentIndexChanged(int index)
  35. {
  36. if(mpRoad == 0)return;
  37. LaneSection * pLS = mpRoad->GetLaneSection(index);
  38. ui->comboBox_Lane->clear();
  39. mpCurLS = pLS;
  40. if(pLS == 0)return;
  41. int nLaneCount = pLS->GetLaneCount();
  42. int i;
  43. for(i=0;i<nLaneCount;i++)
  44. {
  45. Lane * pLane = pLS->GetLane(i);
  46. QString stritemname = QString::number(pLane->GetId());
  47. ui->comboBox_Lane->addItem(stritemname);
  48. }
  49. if(nLaneCount > 0)on_comboBox_Lane_currentIndexChanged(0);
  50. }
  51. void DialogEditRoadMark::on_comboBox_Lane_currentIndexChanged(int index)
  52. {
  53. if(mpCurLS == 0)return;
  54. Lane * pLane = mpCurLS->GetLane(index);
  55. ui->comboBox_Mark->clear();
  56. mpCurLane = pLane;
  57. if(pLane == 0)return;
  58. ui->comboBox_Mark->clear();
  59. int nRoadMarkCount = pLane->GetLaneRoadMarkCount();
  60. if(nRoadMarkCount == 0)
  61. {
  62. ui->lineEdit_sOffset->setText("");
  63. ui->lineEdit_width->setText("");
  64. return;
  65. }
  66. int i;
  67. for(i=0;i<nRoadMarkCount;i++)
  68. {
  69. ui->comboBox_Mark->addItem(QString("s=")+QString::number(pLane->GetLaneRoadMark(i)->GetS()));
  70. }
  71. on_comboBox_Mark_currentIndexChanged(0);
  72. }
  73. void DialogEditRoadMark::on_comboBox_Mark_currentIndexChanged(int index)
  74. {
  75. if(mpCurLane == 0)return;
  76. LaneRoadMark * pLaneRoadMark = mpCurLane->GetLaneRoadMark(index);
  77. if(pLaneRoadMark == 0)return;
  78. ui->comboBox_MarkType->setCurrentIndex(1);
  79. std::string strmarktype = pLaneRoadMark->GetType();
  80. int i;
  81. const int typechoicecount = 7;
  82. for(i=0;i<typechoicecount;i++)
  83. {
  84. if(strmarktype == marktypechoice[i])break;
  85. }
  86. if(i<typechoicecount)ui->comboBox_MarkType->setCurrentIndex(i);
  87. else ui->comboBox_MarkType->setCurrentIndex(1);
  88. std::string strlanechange = pLaneRoadMark->GetLaneChange();
  89. const int lanechagnechoicecount = 4;
  90. for(i=0;i<lanechagnechoicecount;i++)
  91. {
  92. if(strlanechange == lanechangechoice[i])break;
  93. }
  94. if(i<lanechagnechoicecount)ui->comboBox_laneChange->setCurrentIndex(i);
  95. else ui->comboBox_laneChange->setCurrentIndex(0);
  96. std::string strweight = pLaneRoadMark->GetWeight();
  97. if(strweight == "bold")ui->comboBox_weight->setCurrentIndex(1);
  98. else ui->comboBox_weight->setCurrentIndex(0);
  99. std::string strcolor = pLaneRoadMark->GetColor();
  100. const int lanemarkcolorcount = 7;
  101. for(i=0;i<lanemarkcolorcount;i++)
  102. {
  103. if(strcolor == roadcolorchoice[i])break;
  104. }
  105. if(i<lanemarkcolorcount)ui->comboBox_color->setCurrentIndex(i);
  106. else ui->comboBox_color->setCurrentIndex(0);
  107. ui->lineEdit_sOffset->setText(QString::number(pLaneRoadMark->GetS()));
  108. ui->lineEdit_width->setText(QString::number(pLaneRoadMark->GetWidth()));
  109. }
  110. void DialogEditRoadMark::on_pushButton_AddLaneRoadMark_clicked()
  111. {
  112. if(mpCurLS == 0)return;
  113. Lane * pLane = mpCurLS->GetLane(ui->comboBox_Lane->currentIndex());
  114. if(pLane != 0)
  115. {
  116. double soffset = ui->lineEdit_sOffset->text().toDouble();
  117. double fwidth = ui->lineEdit_width->text().toDouble();
  118. if(fwidth<=0)fwidth = 0.15;
  119. std::string strcolor = ui->comboBox_color->currentText().toStdString();
  120. std::string strlanechagne = ui->comboBox_laneChange->currentText().toStdString();
  121. std::string strmarktype = ui->comboBox_MarkType->currentText().toStdString();
  122. std::string strweight = ui->comboBox_weight->currentText().toStdString();
  123. pLane->AddRoadMarkRecord(soffset,strmarktype,strweight,strcolor,fwidth,strlanechagne);
  124. }
  125. on_comboBox_Lane_currentIndexChanged(ui->comboBox_Lane->currentIndex());
  126. }
  127. void DialogEditRoadMark::on_pushButton_ChangeLaneRoadMark_clicked()
  128. {
  129. if(mpCurLS == 0)return;
  130. Lane * pLane = mpCurLS->GetLane(ui->comboBox_Lane->currentIndex());
  131. if(pLane != 0)
  132. {
  133. LaneRoadMark * pLaneRoadMark = pLane->GetLaneRoadMark(ui->comboBox_Mark->currentIndex());
  134. if(pLaneRoadMark != 0)
  135. {
  136. pLaneRoadMark->SetColor(ui->comboBox_color->currentText().toStdString());
  137. pLaneRoadMark->SetLaneChange(ui->comboBox_laneChange->currentText().toStdString());
  138. pLaneRoadMark->SetS(ui->lineEdit_sOffset->text().toDouble());
  139. double fwidth = ui->lineEdit_width->text().toDouble();
  140. if(fwidth<=0)fwidth = 0.15;
  141. pLaneRoadMark->SetWidth(fwidth);
  142. pLaneRoadMark->SetType(ui->comboBox_MarkType->currentText().toStdString());
  143. pLaneRoadMark->SetWeight(ui->comboBox_weight->currentText().toStdString());
  144. }
  145. }
  146. // on_comboBox_Width_currentIndexChanged(ui->comboBox_Width->currentIndex());
  147. }
  148. void DialogEditRoadMark::on_pushButton_DeleteLaneRoadMark_clicked()
  149. {
  150. if(mpCurLS == 0)return;
  151. Lane * pLane = mpCurLS->GetLane(ui->comboBox_Lane->currentIndex());
  152. if(pLane != 0)
  153. {
  154. LaneRoadMark * pLaneRoadMark = pLane->GetLaneRoadMark(ui->comboBox_Mark->currentIndex());
  155. if(pLaneRoadMark != 0)
  156. {
  157. pLane->DeleteLaneRoadMark(ui->comboBox_Mark->currentIndex());
  158. }
  159. }
  160. on_comboBox_Lane_currentIndexChanged(ui->comboBox_Lane->currentIndex());
  161. }