Selaa lähdekoodia

change map_lanetoxodr.

yuchuli 2 vuotta sitten
vanhempi
commit
00e478a322

+ 116 - 38
src/tool/map_lanetoxodr/dialogaddroadfromcda.cpp

@@ -5,6 +5,8 @@
 #include <iostream>
 #include <QMessageBox>
 
+std::string cda_lanetype_sel[9] = {"shoulder","border","driving","stop","none","parking","biking","sidewalk",
+                               "median"};
 
 DialogAddRoadFromCDA::DialogAddRoadFromCDA(OpenDrive * pxodr, QWidget *parent) :
     QDialog(parent),
@@ -12,9 +14,20 @@ DialogAddRoadFromCDA::DialogAddRoadFromCDA(OpenDrive * pxodr, QWidget *parent) :
 {
     ui->setupUi(this);
     mpxodr = pxodr;
-    ui->comboBox_Type->addItem(tr("直路"));
-    ui->comboBox_Type->addItem(tr("弯路"));
-    ui->comboBox_Type->addItem(tr("路口"));
+
+    ui->comboBox_RoadClass->addItem(tr("高速公路"));
+    ui->comboBox_RoadClass->addItem(tr("城市"));
+    ui->comboBox_RoadClass->addItem(tr("乡村"));
+
+    ui->comboBox_Ele->addItem(tr("平路"));
+    ui->comboBox_Ele->addItem(tr("缓上坡"));
+    ui->comboBox_Ele->addItem(tr("上坡"));
+    ui->comboBox_Ele->addItem(tr("缓下坡"));
+    ui->comboBox_Ele->addItem(tr("下坡"));
+
+    ui->comboBox_geoType->addItem(tr("直路"));
+    ui->comboBox_geoType->addItem(tr("弯路"));
+    ui->comboBox_geoType->addItem(tr("路口"));
 
     ui->comboBox_lanecolor->addItem(tr("白色"));
     ui->comboBox_lanecolor->addItem(tr("黄色"));
@@ -22,11 +35,22 @@ DialogAddRoadFromCDA::DialogAddRoadFromCDA(OpenDrive * pxodr, QWidget *parent) :
     ui->comboBox_lanemarktype->addItem(tr("虚线"));
     ui->comboBox_lanemarktype->addItem(tr("实线"));
 
-    ui->comboBox_Type->setCurrentIndex(0);
+    int i;
+    for(i=0;i<9;i++)ui->comboBox_lanetype->addItem(cda_lanetype_sel[i].data());
+
+    ui->comboBox_geoType->setCurrentIndex(0);
     ui->comboBox_lanecolor->setCurrentIndex(0);
     ui->comboBox_lanemarktype->setCurrentIndex(0);
 
-    setWindowTitle(tr("Draw Road From CDA"));
+    ui->comboBox_Ele->setCurrentIndex(0);
+
+
+    ui->lineEdit_roadlanecount->setReadOnly(true);
+    ui->lineEdit_roadlen->setReadOnly(true);
+
+    UpdateView();
+
+    setWindowTitle(tr("Draw Road From Label"));
 
 }
 
@@ -38,49 +62,103 @@ DialogAddRoadFromCDA::~DialogAddRoadFromCDA()
 void DialogAddRoadFromCDA::on_pushButton_Create_clicked()
 {
     OpenDrive * pxodr = mpxodr;
-    std::string strtype = ui->comboBox_Type->currentText().toStdString();
-    std::string strradius = ui->lineEdit_radius->text().toStdString();
-    std::string strlen = ui->lineEdit_len->text().toStdString();
-    std::string strlanewidth = ui->lineEdit_lanewidth->text().toStdString();
-    std::string strlanecount = ui->lineEdit_lanecount->text().toStdString();
-    std::string strlanecolor = ui->comboBox_lanecolor->currentText().toStdString();
-    std::string strlanemarktype = ui->comboBox_lanemarktype->currentText().toStdString();
-
-    if(atof(strradius.data())<0.0000000001)
-    {
-        if(ui->comboBox_Type->currentIndex() == 1)
-        {
-            QMessageBox::warning(this,tr("Warning"),tr("Radius is 0"),QMessageBox::YesAll);
-            return;
-        }
-    }
+//    std::string strtype = ui->comboBox_Type->currentText().toStdString();
+//    std::string strradius = ui->lineEdit_radius->text().toStdString();
+//    std::string strlen = ui->lineEdit_len->text().toStdString();
+//    std::string strlanewidth = ui->lineEdit_lanewidth->text().toStdString();
+//    std::string strlanecount = ui->lineEdit_lanecount->text().toStdString();
+//    std::string strlanecolor = ui->comboBox_lanecolor->currentText().toStdString();
+//    std::string strlanemarktype = ui->comboBox_lanemarktype->currentText().toStdString();
+
+//    if(atof(strradius.data())<0.0000000001)
+//    {
+//        if(ui->comboBox_Type->currentIndex() == 1)
+//        {
+//            QMessageBox::warning(this,tr("Warning"),tr("Radius is 0"),QMessageBox::YesAll);
+//            return;
+//        }
+//    }
+
+//    if(atof(strlen.data())<0.0000000001)
+//    {
+//        QMessageBox::warning(this,tr("Warning"),tr("Length is 0"),QMessageBox::YesAll);
+//        return;
+//    }
+
+//    if(atof(strlanewidth.data())<0.0000000001)
+//    {
+//        QMessageBox::warning(this,tr("Warning"),tr("Lane Width is 0"),QMessageBox::YesAll);
+//        return;
+//    }
+
+//    if(atoi(strlanecount.data())<1)
+//    {
+//        QMessageBox::warning(this,tr("Warning"),tr("Lane Count is 0"),QMessageBox::YesAll);
+//        return;
+//    }
+
+//    int nrtn = CDAProc::ProcRoad(pxodr,strtype,strradius,strlen,strlanewidth,strlanecount," ",strlanecolor,strlanemarktype);
+
+//    if(nrtn == 0)
+//    {
+//        this->accept();
+//    }
+//    else
+//    {
+//        QMessageBox::warning(this,tr("Warning"),tr("CDAProc ProcRoad Fail."),QMessageBox::YesAll);
+//    }
+}
 
-    if(atof(strlen.data())<0.0000000001)
+void DialogAddRoadFromCDA::UpdateView()
+{
+    iv::cdaroad * pcdaroad = &mcdaroad;
+    ui->comboBox_RoadClass->setCurrentIndex(pcdaroad->mnclass);
+    int nlanecount = static_cast<int>(pcdaroad->mvectorlane.size());
+    ui->lineEdit_roadlanecount->setText(QString::number(nlanecount));
+    double fRoadLen = 0;
+    int i;
+    int ngeosize = static_cast<int>(pcdaroad->mvectorgeo.size());
+    ui->comboBox_geo->clear();
+    for(i=0;i<ngeosize;i++)
     {
-        QMessageBox::warning(this,tr("Warning"),tr("Length is 0"),QMessageBox::YesAll);
-        return;
+        ui->comboBox_geo->addItem(QString(tr("路段"))+QString::number(i+1));
+        fRoadLen = fRoadLen + pcdaroad->mvectorgeo[i].mflen;
     }
-
-    if(atof(strlanewidth.data())<0.0000000001)
+    ui->comboBox_Lane->clear();
+    for(i=0;i<nlanecount;i++)
     {
-        QMessageBox::warning(this,tr("Warning"),tr("Lane Width is 0"),QMessageBox::YesAll);
-        return;
+        ui->comboBox_Lane->addItem(QString(tr("车道"))+QString::number(i+1));
     }
+    ui->lineEdit_roadlen->setText(QString::number(fRoadLen));
+}
 
-    if(atoi(strlanecount.data())<1)
+void DialogAddRoadFromCDA::on_comboBox_Lane_currentIndexChanged(int index)
+{
+    iv::cdaroad * pcdaroad = &mcdaroad;
+    if(index<0)return;
+    if(index>=pcdaroad->mvectorlane.size())
     {
-        QMessageBox::warning(this,tr("Warning"),tr("Lane Count is 0"),QMessageBox::YesAll);
+        std::cout<<" index big than lane size."<<std::endl;
         return;
     }
+    iv::cdalane * plane = &pcdaroad->mvectorlane[index];
+    ui->comboBox_lanecolor->setCurrentIndex(plane->mnlanemarkcolor);
+    ui->comboBox_lanemarktype->setCurrentIndex(plane->mnlanemarktype);
+    ui->lineEdit_lanewidth->setText(QString::number(plane->mflanewidth,'f',2));
+    ui->comboBox_lanetype->setCurrentIndex(plane->mnlanetype);
+}
 
-    int nrtn = CDAProc::ProcRoad(pxodr,strtype,strradius,strlen,strlanewidth,strlanecount," ",strlanecolor,strlanemarktype);
-
-    if(nrtn == 0)
-    {
-        this->accept();
-    }
-    else
+void DialogAddRoadFromCDA::on_comboBox_geo_currentIndexChanged(int index)
+{
+    iv::cdaroad * pcdaroad = &mcdaroad;
+    if(index<0)return;
+    if(index>=pcdaroad->mvectorgeo.size())
     {
-        QMessageBox::warning(this,tr("Warning"),tr("CDAProc ProcRoad Fail."),QMessageBox::YesAll);
+        std::cout<<" index big than geo size."<<std::endl;
+        return;
     }
+    iv::cdageo * pgeo = &pcdaroad->mvectorgeo[index];
+    ui->comboBox_geo->setCurrentIndex(pgeo->mngeotype);
+    ui->lineEdit_georadius->setText(QString::number(pgeo->mfradius));
+    ui->lineEdit_geolen->setText(QString::number(pgeo->mflen));
 }

+ 9 - 0
src/tool/map_lanetoxodr/dialogaddroadfromcda.h

@@ -21,9 +21,18 @@ public:
 private slots:
     void on_pushButton_Create_clicked();
 
+    void on_comboBox_Lane_currentIndexChanged(int index);
+
+    void on_comboBox_geo_currentIndexChanged(int index);
+
 private:
     Ui::DialogAddRoadFromCDA *ui;
     OpenDrive * mpxodr;
+
+    iv::cdaroad mcdaroad;
+
+private:
+    void UpdateView();
 };
 
 #endif // DIALOGADDROADFROMCDA_H

+ 338 - 96
src/tool/map_lanetoxodr/dialogaddroadfromcda.ui

@@ -6,185 +6,427 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>802</width>
-    <height>515</height>
+    <width>900</width>
+    <height>650</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Dialog</string>
   </property>
-  <widget class="QComboBox" name="comboBox_Type">
-   <property name="geometry">
-    <rect>
-     <x>180</x>
-     <y>60</y>
-     <width>161</width>
-     <height>41</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label">
-   <property name="geometry">
-    <rect>
-     <x>60</x>
-     <y>60</y>
-     <width>141</width>
-     <height>41</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>道路类型:</string>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_2">
+  <widget class="QLabel" name="label_3">
    <property name="geometry">
     <rect>
-     <x>60</x>
-     <y>150</y>
+     <x>100</x>
+     <y>80</y>
      <width>101</width>
      <height>41</height>
     </rect>
    </property>
    <property name="text">
-    <string>半径:</string>
+    <string>道路长度:</string>
    </property>
   </widget>
-  <widget class="QLineEdit" name="lineEdit_radius">
+  <widget class="QLineEdit" name="lineEdit_roadlen">
    <property name="geometry">
     <rect>
-     <x>180</x>
-     <y>150</y>
+     <x>230</x>
+     <y>80</y>
      <width>161</width>
      <height>41</height>
     </rect>
    </property>
   </widget>
-  <widget class="QLabel" name="label_3">
+  <widget class="QPushButton" name="pushButton_Create">
    <property name="geometry">
     <rect>
-     <x>440</x>
-     <y>150</y>
-     <width>101</width>
-     <height>41</height>
+     <x>358</x>
+     <y>560</y>
+     <width>161</width>
+     <height>51</height>
     </rect>
    </property>
    <property name="text">
-    <string>长度:</string>
+    <string>创建</string>
    </property>
   </widget>
-  <widget class="QLineEdit" name="lineEdit_len">
+  <widget class="QComboBox" name="comboBox_RoadClass">
    <property name="geometry">
     <rect>
-     <x>560</x>
-     <y>150</y>
+     <x>230</x>
+     <y>20</y>
      <width>161</width>
      <height>41</height>
     </rect>
    </property>
   </widget>
-  <widget class="QLabel" name="label_4">
+  <widget class="QLabel" name="label_8">
    <property name="geometry">
     <rect>
-     <x>60</x>
-     <y>240</y>
-     <width>101</width>
+     <x>104</x>
+     <y>20</y>
+     <width>141</width>
      <height>41</height>
     </rect>
    </property>
    <property name="text">
-    <string>车道宽度:</string>
+    <string>道路等级:</string>
    </property>
   </widget>
-  <widget class="QLineEdit" name="lineEdit_lanewidth">
+  <widget class="QComboBox" name="comboBox_Ele">
    <property name="geometry">
     <rect>
-     <x>180</x>
-     <y>240</y>
+     <x>610</x>
+     <y>80</y>
      <width>161</width>
      <height>41</height>
     </rect>
    </property>
   </widget>
-  <widget class="QLineEdit" name="lineEdit_lanecount">
+  <widget class="QLabel" name="label_9">
    <property name="geometry">
     <rect>
-     <x>560</x>
-     <y>240</y>
-     <width>161</width>
-     <height>41</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_5">
-   <property name="geometry">
-    <rect>
-     <x>440</x>
-     <y>240</y>
-     <width>101</width>
+     <x>490</x>
+     <y>80</y>
+     <width>141</width>
      <height>41</height>
     </rect>
    </property>
    <property name="text">
-    <string>车道数量:</string>
+    <string>坡度:</string>
    </property>
   </widget>
-  <widget class="QLabel" name="label_6">
+  <widget class="QGroupBox" name="groupBox">
    <property name="geometry">
     <rect>
-     <x>60</x>
-     <y>330</y>
-     <width>121</width>
-     <height>41</height>
+     <x>63</x>
+     <y>123</y>
+     <width>781</width>
+     <height>201</height>
     </rect>
    </property>
-   <property name="text">
-    <string>车道线颜色:</string>
+   <property name="title">
+    <string>车道线设置</string>
    </property>
+   <widget class="QComboBox" name="comboBox_lanemarktype">
+    <property name="geometry">
+     <rect>
+      <x>531</x>
+      <y>84</y>
+      <width>161</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_7">
+    <property name="geometry">
+     <rect>
+      <x>410</x>
+      <y>85</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>车道线类型:</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_6">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>84</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>车道线颜色:</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_lanewidth">
+    <property name="geometry">
+     <rect>
+      <x>150</x>
+      <y>140</y>
+      <width>161</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QComboBox" name="comboBox_lanecolor">
+    <property name="geometry">
+     <rect>
+      <x>150</x>
+      <y>85</y>
+      <width>161</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_4">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>140</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>车道宽度:</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_12">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>30</y>
+      <width>141</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>车道:</string>
+    </property>
+   </widget>
+   <widget class="QComboBox" name="comboBox_Lane">
+    <property name="geometry">
+     <rect>
+      <x>150</x>
+      <y>30</y>
+      <width>161</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_laneadd">
+    <property name="geometry">
+     <rect>
+      <x>350</x>
+      <y>30</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>增加</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_lanedel">
+    <property name="geometry">
+     <rect>
+      <x>480</x>
+      <y>30</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>删除</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_lanechange">
+    <property name="geometry">
+     <rect>
+      <x>610</x>
+      <y>30</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>修改</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_13">
+    <property name="geometry">
+     <rect>
+      <x>410</x>
+      <y>140</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>车道类型:</string>
+    </property>
+   </widget>
+   <widget class="QComboBox" name="comboBox_lanetype">
+    <property name="geometry">
+     <rect>
+      <x>530</x>
+      <y>140</y>
+      <width>161</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
   </widget>
-  <widget class="QLabel" name="label_7">
+  <widget class="QGroupBox" name="groupBox_2">
    <property name="geometry">
     <rect>
-     <x>440</x>
-     <y>330</y>
-     <width>121</width>
-     <height>41</height>
+     <x>61</x>
+     <y>338</y>
+     <width>781</width>
+     <height>181</height>
     </rect>
    </property>
-   <property name="text">
-    <string>车道线类型:</string>
+   <property name="title">
+    <string>路段设置</string>
    </property>
+   <widget class="QLineEdit" name="lineEdit_georadius">
+    <property name="geometry">
+     <rect>
+      <x>540</x>
+      <y>80</y>
+      <width>161</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_2">
+    <property name="geometry">
+     <rect>
+      <x>420</x>
+      <y>80</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>半径:</string>
+    </property>
+   </widget>
+   <widget class="QComboBox" name="comboBox_geoType">
+    <property name="geometry">
+     <rect>
+      <x>160</x>
+      <y>80</y>
+      <width>161</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>80</y>
+      <width>141</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>路段类型:</string>
+    </property>
+   </widget>
+   <widget class="QComboBox" name="comboBox_geo">
+    <property name="geometry">
+     <rect>
+      <x>160</x>
+      <y>30</y>
+      <width>161</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_10">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>30</y>
+      <width>141</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>路段:</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_5">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>130</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>长度:</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_geolen">
+    <property name="geometry">
+     <rect>
+      <x>160</x>
+      <y>130</y>
+      <width>161</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_geodel">
+    <property name="geometry">
+     <rect>
+      <x>490</x>
+      <y>30</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>删除</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_geoadd">
+    <property name="geometry">
+     <rect>
+      <x>360</x>
+      <y>30</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>增加</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_geochange">
+    <property name="geometry">
+     <rect>
+      <x>620</x>
+      <y>30</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>修改</string>
+    </property>
+   </widget>
   </widget>
-  <widget class="QComboBox" name="comboBox_lanecolor">
+  <widget class="QLineEdit" name="lineEdit_roadlanecount">
    <property name="geometry">
     <rect>
-     <x>180</x>
-     <y>330</y>
+     <x>610</x>
+     <y>20</y>
      <width>161</width>
      <height>41</height>
     </rect>
    </property>
   </widget>
-  <widget class="QComboBox" name="comboBox_lanemarktype">
+  <widget class="QLabel" name="label_11">
    <property name="geometry">
     <rect>
-     <x>560</x>
-     <y>330</y>
-     <width>161</width>
+     <x>490</x>
+     <y>20</y>
+     <width>101</width>
      <height>41</height>
     </rect>
    </property>
-  </widget>
-  <widget class="QPushButton" name="pushButton_Create">
-   <property name="geometry">
-    <rect>
-     <x>320</x>
-     <y>430</y>
-     <width>161</width>
-     <height>51</height>
-    </rect>
-   </property>
    <property name="text">
-    <string>创建</string>
+    <string>车道数量:</string>
    </property>
   </widget>
  </widget>

+ 49 - 0
src/tool/map_lanetoxodr/function/cdaproc.h

@@ -2,10 +2,59 @@
 #define CDAPROC_H
 
 #include <string>
+#include <vector>
 #include "excelapi.h"
 
 #include <OpenDrive/OpenDrive.h>
 
+
+
+
+namespace iv
+{
+struct cdalane
+{
+    int mnlanetype;  // 0 driving  1 ...
+    double mflanewidth;
+    int mnlanemarkcolor;  //0 白色 1 黄色
+    int mnlanemarktype;    //0 虚线 1 实线 2 双虚线  3 双实线  4 虚实线 5 实虚线  6 无
+};
+
+struct cdageo
+{
+    int mngeotype;  //直路  弯路  路口
+    double mfradius;  //半径
+    double mflen;   //长度
+};
+
+class cdaroad
+{
+public:
+  int mnclass;  //0 高速公路  1 城市  2 乡村
+  int mnEle;   //0 平路  1 缓上坡  2 上坡  3 缓下坡 4 下坡
+  std::vector<cdageo> mvectorgeo;
+  std::vector<cdalane> mvectorlane;
+
+public:
+  cdaroad()
+  {
+      mnclass = 0;
+      mnEle = 0;
+      cdageo xgeo;
+      xgeo.mflen = 100.0;
+      xgeo.mfradius = 100;
+      xgeo.mngeotype = 0;
+      mvectorgeo.push_back(xgeo);
+      cdalane xlane;
+      xlane.mnlanetype = 2;
+      xlane.mflanewidth = 3.75;
+      xlane.mnlanemarkcolor = 0;
+      xlane.mnlanemarktype = 0;
+      mvectorlane.push_back(xlane);
+  }
+};
+}
+
 class CDAProc
 {
 public: