Przeglądaj źródła

change map_lanetoxodr. add lane edit dialog.

yuchuli 3 lat temu
rodzic
commit
791da353d2

+ 144 - 0
src/tool/map_lanetoxodr/dialogeditlane.cpp

@@ -0,0 +1,144 @@
+#include "dialogeditlane.h"
+#include "ui_dialogeditlane.h"
+
+DialogEditLane::DialogEditLane(Road * pRoad,QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogEditLane)
+{
+    mpRoad = pRoad;
+    ui->setupUi(this);
+
+    ui->comboBox_LaneType->addItem("shoulder");
+    ui->comboBox_LaneType->addItem("border");
+    ui->comboBox_LaneType->addItem("driving");
+    ui->comboBox_LaneType->addItem("stop");
+    ui->comboBox_LaneType->addItem("none");
+    ui->comboBox_LaneType->addItem("parking");
+    ui->comboBox_LaneType->addItem("biking");
+    ui->comboBox_LaneType->addItem("sidewalk");
+    ui->comboBox_LaneType->addItem("median");
+
+
+
+    int nsection = pRoad->GetLaneSectionCount();
+    int i;
+    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);
+
+}
+
+DialogEditLane::~DialogEditLane()
+{
+    delete ui;
+}
+
+void DialogEditLane::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 DialogEditLane::on_comboBox_Lane_currentIndexChanged(int index)
+{
+    if(mpCurLS == 0)return;
+    Lane * pLane = mpCurLS->GetLane(index);
+    ui->comboBox_Width->clear();
+    if(pLane == 0)return;
+    int nWidthCount = pLane->GetLaneWidthCount();
+    int i;
+    for(i=0;i<nWidthCount;i++)
+    {
+        LaneWidth * pLaneWidth = pLane->GetLaneWidth(i);
+        QString stritemname = QString("sOffset=") + QString::number(pLaneWidth->GetS());
+        ui->comboBox_Width->addItem(stritemname);
+    }
+    mpCurLane = pLane;
+    if(nWidthCount > 0)on_comboBox_Width_currentIndexChanged(0);
+    else
+    {
+        ui->lineEdit_sOffset->setText("");
+        ui->lineEdit_a->setText("");
+        ui->lineEdit_b->setText("");
+        ui->lineEdit_c->setText("");
+        ui->lineEdit_d->setText("");
+    }
+
+    std::string strlanetype  = pLane->GetType();
+
+    ui->comboBox_LaneType->setCurrentIndex(4);
+    if(strlanetype == "shoulder")ui->comboBox_LaneType->setCurrentIndex(0);
+    if(strlanetype == "border")ui->comboBox_LaneType->setCurrentIndex(1);
+    if(strlanetype == "driving")ui->comboBox_LaneType->setCurrentIndex(2);
+    if(strlanetype == "stop")ui->comboBox_LaneType->setCurrentIndex(3);
+    if(strlanetype == "none")ui->comboBox_LaneType->setCurrentIndex(4);
+    if(strlanetype == "parking")ui->comboBox_LaneType->setCurrentIndex(5);
+    if(strlanetype == "biking")ui->comboBox_LaneType->setCurrentIndex(6);
+    if(strlanetype == "sidewalk")ui->comboBox_LaneType->setCurrentIndex(7);
+    if(strlanetype == "median")ui->comboBox_LaneType->setCurrentIndex(8);
+
+}
+
+void DialogEditLane::on_comboBox_Width_currentIndexChanged(int index)
+{
+    if(mpCurLane == 0)return;
+    LaneWidth * pLaneWidth = mpCurLane->GetLaneWidth(index);
+    if(pLaneWidth == 0)return;
+    ui->lineEdit_sOffset->setText(QString::number(pLaneWidth->GetS()));
+    ui->lineEdit_a->setText(QString::number(pLaneWidth->GetA()));
+    ui->lineEdit_b->setText(QString::number(pLaneWidth->GetB()));
+    ui->lineEdit_c->setText(QString::number(pLaneWidth->GetC()));
+    ui->lineEdit_d->setText(QString::number(pLaneWidth->GetD()));
+}
+
+void DialogEditLane::on_pushButton_AddLeftLane_clicked()
+{
+    if(mpCurLS == 0)return;
+ //   mpCurLS->AddLane()
+}
+
+void DialogEditLane::on_pushButton_AddRIghtLane_clicked()
+{
+
+}
+
+void DialogEditLane::on_pushButton_DeleteLane_clicked()
+{
+
+}
+
+void DialogEditLane::on_pushButton_AddLaneWidth_clicked()
+{
+
+}
+
+void DialogEditLane::on_pushButton_ChangeLaneWidth_clicked()
+{
+
+}
+
+void DialogEditLane::on_pushButton_DeleteLaneWidth_clicked()
+{
+
+}

+ 48 - 0
src/tool/map_lanetoxodr/dialogeditlane.h

@@ -0,0 +1,48 @@
+#ifndef DIALOGEDITLANE_H
+#define DIALOGEDITLANE_H
+
+#include <QDialog>
+
+#include "OpenDrive/OpenDrive.h"
+
+namespace Ui {
+class DialogEditLane;
+}
+
+class DialogEditLane : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogEditLane(Road * pRoad,QWidget *parent = nullptr);
+    ~DialogEditLane();
+
+private slots:
+    void on_comboBox_LaneSection_currentIndexChanged(int index);
+
+    void on_comboBox_Lane_currentIndexChanged(int index);
+
+    void on_comboBox_Width_currentIndexChanged(int index);
+
+    void on_pushButton_AddLeftLane_clicked();
+
+    void on_pushButton_AddRIghtLane_clicked();
+
+    void on_pushButton_DeleteLane_clicked();
+
+    void on_pushButton_AddLaneWidth_clicked();
+
+    void on_pushButton_ChangeLaneWidth_clicked();
+
+    void on_pushButton_DeleteLaneWidth_clicked();
+
+private:
+    Ui::DialogEditLane *ui;
+
+    Road * mpRoad;
+    LaneSection * mpCurLS = 0;
+    Lane * mpCurLane = 0;
+    LaneWidth * mpCurLaneWidth = 0;
+};
+
+#endif // DIALOGEDITLANE_H

+ 304 - 0
src/tool/map_lanetoxodr/dialogeditlane.ui

@@ -0,0 +1,304 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogEditLane</class>
+ <widget class="QDialog" name="DialogEditLane">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>721</width>
+    <height>442</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>30</y>
+     <width>151</width>
+     <height>21</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Lane Section</string>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_LaneSection">
+   <property name="geometry">
+    <rect>
+     <x>160</x>
+     <y>20</y>
+     <width>221</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>90</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Lane</string>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_Lane">
+   <property name="geometry">
+    <rect>
+     <x>160</x>
+     <y>80</y>
+     <width>221</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_AddLaneWidth">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>380</y>
+     <width>181</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Add Lane Width</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_ChangeLaneWidth">
+   <property name="geometry">
+    <rect>
+     <x>280</x>
+     <y>380</y>
+     <width>171</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Change Lane Width</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_DeleteLaneWidth">
+   <property name="geometry">
+    <rect>
+     <x>513</x>
+     <y>380</y>
+     <width>181</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Delete Lane Width</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_3">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>150</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Width</string>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_Width">
+   <property name="geometry">
+    <rect>
+     <x>160</x>
+     <y>140</y>
+     <width>221</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_sOffset">
+   <property name="geometry">
+    <rect>
+     <x>120</x>
+     <y>200</y>
+     <width>111</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_a">
+   <property name="geometry">
+    <rect>
+     <x>350</x>
+     <y>200</y>
+     <width>111</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_b">
+   <property name="geometry">
+    <rect>
+     <x>570</x>
+     <y>200</y>
+     <width>111</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_c">
+   <property name="geometry">
+    <rect>
+     <x>120</x>
+     <y>250</y>
+     <width>111</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_d">
+   <property name="geometry">
+    <rect>
+     <x>350</x>
+     <y>250</y>
+     <width>111</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_4">
+   <property name="geometry">
+    <rect>
+     <x>33</x>
+     <y>207</y>
+     <width>91</width>
+     <height>21</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>sOffset</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_5">
+   <property name="geometry">
+    <rect>
+     <x>310</x>
+     <y>204</y>
+     <width>31</width>
+     <height>21</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>a</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_6">
+   <property name="geometry">
+    <rect>
+     <x>529</x>
+     <y>206</y>
+     <width>41</width>
+     <height>21</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>b</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_7">
+   <property name="geometry">
+    <rect>
+     <x>80</x>
+     <y>258</y>
+     <width>31</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>c</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_8">
+   <property name="geometry">
+    <rect>
+     <x>309</x>
+     <y>257</y>
+     <width>31</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>d</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_AddLeftLane">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>320</y>
+     <width>181</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Add Left Lane</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_AddRIghtLane">
+   <property name="geometry">
+    <rect>
+     <x>280</x>
+     <y>320</y>
+     <width>171</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Add Right Lane</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_DeleteLane">
+   <property name="geometry">
+    <rect>
+     <x>513</x>
+     <y>320</y>
+     <width>181</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Delete Lane</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_9">
+   <property name="geometry">
+    <rect>
+     <x>420</x>
+     <y>90</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Type</string>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_LaneType">
+   <property name="geometry">
+    <rect>
+     <x>480</x>
+     <y>80</y>
+     <width>221</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 3 - 0
src/tool/map_lanetoxodr/map_lanetoxodr.pro

@@ -29,6 +29,7 @@ QMAKE_LFLAGS += -no-pie
 
 SOURCES += \
     autoconnect.cpp \
+    dialogeditlane.cpp \
     ivxodrtool.cpp \
         main.cpp \
         mainwindow.cpp \
@@ -68,6 +69,7 @@ SOURCES += \
 
 HEADERS += \
     autoconnect.h \
+    dialogeditlane.h \
     ivxodrtool.h \
         mainwindow.h \
     rawtype.h \
@@ -103,6 +105,7 @@ HEADERS += \
     xodrmake.h
 
 FORMS += \
+        dialogeditlane.ui \
         mainwindow.ui \
         roadeditdialog.ui \
         speeddialog.ui \

+ 2 - 2
src/tool/map_lanetoxodr/myview.cpp

@@ -53,7 +53,7 @@ void MyView::zoomIn()
     QScrollBar * psH = horizontalScrollBar();
 
 
-    qDebug("%d %d ",width,hgt);
+//    qDebug("%d %d ",width,hgt);
 
 
     int centery = (psV->value() + psV->size().height()/2)/beishu;
@@ -65,7 +65,7 @@ void MyView::zoomIn()
 
 
 
-    qDebug("beishu is %f",beishu);
+//    qDebug("beishu is %f",beishu);
 
     centerOn(centerx,centery);
 

+ 13 - 2
src/tool/map_lanetoxodr/roadeditdialog.cpp

@@ -4,7 +4,7 @@
 #include "math.h"
 
 #define VIEW_WIDTH 850
-#define VIEW_HEIGHT 350
+#define VIEW_HEIGHT 450
 
 RoadEditDialog::RoadEditDialog(OpenDrive * pxodr,QWidget *parent) :
     QDialog(parent),
@@ -15,7 +15,7 @@ RoadEditDialog::RoadEditDialog(OpenDrive * pxodr,QWidget *parent) :
 
     myview = new MyView(this);
     myview->setObjectName(QStringLiteral("graphicsView"));
-    myview->setGeometry(QRect(30, 400, 900, 400));
+    myview->setGeometry(QRect(30, 300, 900, 500));
 
     connect(myview,SIGNAL(dbclickxy(double,double)),this,SLOT(onClickXY(double,double)));
 
@@ -396,3 +396,14 @@ void RoadEditDialog::on_comboBox_Geo_currentIndexChanged(int index)
         ui->comboBox_geotype->setCurrentIndex(pg->GetGeomType());
     }
 }
+
+void RoadEditDialog::on_pushButton_EditLane_clicked()
+{
+    if(mpCurRoad == 0)
+    {
+        QMessageBox::warning(this,"Warning","Not Select Road");
+        return;
+    }
+    DialogEditLane laned(mpCurRoad,this);
+    int res = laned.exec();
+}

+ 5 - 0
src/tool/map_lanetoxodr/roadeditdialog.h

@@ -2,6 +2,7 @@
 #define ROADEDITDIALOG_H
 
 #include <QDialog>
+#include <QMessageBox>
 
 #include "myview.h"
 #include "OpenDrive/OpenDrive.h"
@@ -10,6 +11,8 @@
 
 #include "roadviewitem.h"
 
+#include "dialogeditlane.h"
+
 namespace Ui {
 class RoadEditDialog;
 }
@@ -34,6 +37,8 @@ private slots:
 
     void on_comboBox_Geo_currentIndexChanged(int index);
 
+    void on_pushButton_EditLane_clicked();
+
 private:
     Ui::RoadEditDialog *ui;
     OpenDrive * mpxodr;

+ 13 - 0
src/tool/map_lanetoxodr/roadeditdialog.ui

@@ -220,6 +220,19 @@
     </rect>
    </property>
   </widget>
+  <widget class="QPushButton" name="pushButton_EditLane">
+   <property name="geometry">
+    <rect>
+     <x>100</x>
+     <y>210</y>
+     <width>181</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Edit Lane</string>
+   </property>
+  </widget>
  </widget>
  <resources/>
  <connections/>