Browse Source

change map_lanetoxodr. add edit traffic light dialog, but not complete.

yuchuli 4 years ago
parent
commit
e8fd58ea16

+ 6 - 0
src/tool/map_lanetoxodr/mainwindow.cpp

@@ -4772,3 +4772,9 @@ void MainWindow::closeEvent(QCloseEvent *event)
         event->accept(); // 接受退出信号,程序退出
     }
 }
+
+void MainWindow::on_actionSet_Traffic_Light_triggered()
+{
+    TrafficLightDialog td(&mxodr,this);
+    int res = td.exec();
+}

+ 3 - 0
src/tool/map_lanetoxodr/mainwindow.h

@@ -41,6 +41,7 @@
 #include "geofit.h"
 #include "autoconnect.h"
 #include "speeddialog.h"
+#include "trafficlightdialog.h"
 
 #include <iostream>
 #include <map>
@@ -234,6 +235,8 @@ private slots:
 
     void closeEvent(QCloseEvent * event);
 
+    void on_actionSet_Traffic_Light_triggered();
+
 private:
 
 

+ 6 - 0
src/tool/map_lanetoxodr/mainwindow.ui

@@ -40,6 +40,7 @@
     </property>
     <addaction name="actionAutoConnect"/>
     <addaction name="actionSet_Speed"/>
+    <addaction name="actionSet_Traffic_Light"/>
    </widget>
    <addaction name="menuFile"/>
    <addaction name="menuFunction"/>
@@ -79,6 +80,11 @@
     <string>Set Speed</string>
    </property>
   </action>
+  <action name="actionSet_Traffic_Light">
+   <property name="text">
+    <string>Edit Traffic Light</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources>

+ 4 - 1
src/tool/map_lanetoxodr/map_lanetoxodr.pro

@@ -32,6 +32,7 @@ SOURCES += \
         main.cpp \
         mainwindow.cpp \
     speeddialog.cpp \
+    trafficlightdialog.cpp \
     xodr.cpp \
     myview.cpp \
     linedata.cpp \
@@ -62,6 +63,7 @@ HEADERS += \
     autoconnect.h \
         mainwindow.h \
     speeddialog.h \
+    trafficlightdialog.h \
     xodr.h \
     myview.h \
     boost.h \
@@ -87,7 +89,8 @@ HEADERS += \
 
 FORMS += \
         mainwindow.ui \
-        speeddialog.ui
+        speeddialog.ui \
+        trafficlightdialog.ui
 
 unix:LIBS += -lboost_thread -lboost_system -lboost_serialization -lprotobuf
 

+ 111 - 0
src/tool/map_lanetoxodr/trafficlightdialog.cpp

@@ -0,0 +1,111 @@
+#include "trafficlightdialog.h"
+#include "ui_trafficlightdialog.h"
+
+TrafficLightDialog::TrafficLightDialog(OpenDrive * pxodr,QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::TrafficLightDialog)
+{
+    ui->setupUi(this);
+    mpxodr = pxodr;
+
+    ui->comboBox_dynamic->addItem("yes");
+    ui->comboBox_dynamic->addItem("no");
+
+    int i;
+    int nroadcount = mpxodr->GetRoadCount();
+    for(i=0;i<nroadcount;i++)
+    {
+        const char * strname = mpxodr->GetRoad(i)->GetRoadId().data();
+        ui->comboBox_Road->addItem(strname);
+
+    }
+
+    setWindowTitle("Edit Traffic Light");
+
+}
+
+TrafficLightDialog::~TrafficLightDialog()
+{
+    delete ui;
+}
+
+void TrafficLightDialog::on_comboBox_Road_currentIndexChanged(int index)
+{
+    Road * pRoad = mpxodr->GetRoad(index);
+    if(pRoad == 0)
+    {
+ //       QMessageBox::warning(this,"WARN","MainWindow::onClickCBRoadChange road is NULL");
+        return;
+    }
+
+    ui->lineEdit_RoadLen->setText(QString::number(pRoad->GetRoadLength(),'f',3));
+
+    ui->comboBox_TrafficLIght->clear();
+    int nsigcount = pRoad->GetSignalCount();
+    if(nsigcount == 0)
+    {
+        initlineedit();
+        return;
+    }
+
+    int i;
+    for(i=0;i<nsigcount;i++)
+    {
+        Signal * pSignal = pRoad->GetSignal(i);
+        ui->comboBox_TrafficLIght->addItem(pSignal->Getid().data());
+    }
+}
+
+void TrafficLightDialog::initlineedit()
+{
+    ui->lineEdit_name->setText("");
+    ui->lineEdit_id->setText("");
+    ui->lineEdit_s->setText("0.0");
+    ui->lineEdit_t->setText("0.0");
+//    ui->comboBox_dynamic->setText("");
+    ui->lineEdit_orientation->setText("-");
+    ui->lineEdit_zOffset->setText("0.0");
+    ui->lineEdit_type->setText("1000001");
+    ui->lineEdit_country->setText("OpenDrive");
+    ui->lineEdit_countryRevision->setText("2013");
+    ui->lineEdit_subtype->setText("-1");
+    ui->lineEdit_hOffset->setText("0.1");
+    ui->lineEdit_pitch->setText("0");
+    ui->lineEdit_roll->setText("0");
+    ui->lineEdit_height->setText("0.1");
+    ui->lineEdit_width->setText("0.1");
+}
+
+void TrafficLightDialog::showsignal(Signal *pSignal)
+{
+    ui->lineEdit_name->setText(pSignal->Getname().data());
+    ui->lineEdit_id->setText(pSignal->Getid().data());
+    ui->lineEdit_s->setText(QString::number(pSignal->Gets()));
+    ui->lineEdit_t->setText(QString::number(pSignal->Gett()));
+    if(pSignal->Getdynamic())ui->comboBox_dynamic->setCurrentIndex(0);
+    else ui->comboBox_dynamic->setCurrentIndex(1);
+//    ui->comboBox_dynamic->setText("");
+    ui->lineEdit_orientation->setText(pSignal->Getorientation().data());
+    ui->lineEdit_zOffset->setText(QString::number(pSignal->GetzOffset()));
+    ui->lineEdit_type->setText(pSignal->Gettype().data());
+    ui->lineEdit_country->setText(pSignal->Getcountry().data());
+    ui->lineEdit_countryRevision->setText(pSignal->GetcountryRevision().data());
+    ui->lineEdit_subtype->setText(pSignal->Getsubtype().data());
+    ui->lineEdit_hOffset->setText(QString::number(pSignal->GethOffset()));
+    ui->lineEdit_pitch->setText(QString::number(pSignal->Getpitch()));
+    ui->lineEdit_roll->setText(QString::number(pSignal->Getroll()));
+    ui->lineEdit_height->setText(QString::number(pSignal->Getheight()));
+    ui->lineEdit_width->setText(QString::number(pSignal->Getwidth()));
+}
+
+void TrafficLightDialog::on_comboBox_TrafficLIght_currentIndexChanged(int index)
+{
+    Road * pRoad =mpxodr->GetRoad(ui->comboBox_Road->currentIndex());
+    if(pRoad == 0)return;
+
+    if(pRoad->GetSignalCount() == 0)return;
+
+    if(index >= pRoad->GetSignalCount())return;
+    Signal * pSignal = pRoad->GetSignal(index);
+    showsignal(pSignal);
+}

+ 32 - 0
src/tool/map_lanetoxodr/trafficlightdialog.h

@@ -0,0 +1,32 @@
+#ifndef TRAFFICLIGHTDIALOG_H
+#define TRAFFICLIGHTDIALOG_H
+
+#include <QDialog>
+#include "OpenDrive/OpenDrive.h"
+
+namespace Ui {
+class TrafficLightDialog;
+}
+
+class TrafficLightDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit TrafficLightDialog(OpenDrive * pxodr,QWidget *parent = nullptr);
+    ~TrafficLightDialog();
+
+private slots:
+    void on_comboBox_Road_currentIndexChanged(int index);
+
+    void on_comboBox_TrafficLIght_currentIndexChanged(int index);
+
+private:
+    Ui::TrafficLightDialog *ui;
+    OpenDrive * mpxodr;
+
+    void initlineedit();
+    void showsignal(Signal * pSignal);
+};
+
+#endif // TRAFFICLIGHTDIALOG_H

+ 521 - 0
src/tool/map_lanetoxodr/trafficlightdialog.ui

@@ -0,0 +1,521 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TrafficLightDialog</class>
+ <widget class="QDialog" name="TrafficLightDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1009</width>
+    <height>598</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QComboBox" name="comboBox_Road">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>20</y>
+     <width>231</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>30</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Road</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>172</x>
+     <y>70</y>
+     <width>70</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Length</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_RoadLen">
+   <property name="geometry">
+    <rect>
+     <x>270</x>
+     <y>70</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_TrafficLIght">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>130</y>
+     <width>261</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_3">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>140</y>
+     <width>101</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Traffic Light</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_4">
+   <property name="geometry">
+    <rect>
+     <x>32</x>
+     <y>220</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>s</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_s">
+   <property name="geometry">
+    <rect>
+     <x>120</x>
+     <y>220</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_t">
+   <property name="geometry">
+    <rect>
+     <x>350</x>
+     <y>220</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_id">
+   <property name="geometry">
+    <rect>
+     <x>570</x>
+     <y>220</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_name">
+   <property name="geometry">
+    <rect>
+     <x>800</x>
+     <y>220</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_zOffset">
+   <property name="geometry">
+    <rect>
+     <x>350</x>
+     <y>270</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_type">
+   <property name="geometry">
+    <rect>
+     <x>570</x>
+     <y>270</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_country">
+   <property name="geometry">
+    <rect>
+     <x>800</x>
+     <y>267</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_countryRevision">
+   <property name="geometry">
+    <rect>
+     <x>120</x>
+     <y>320</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_subtype">
+   <property name="geometry">
+    <rect>
+     <x>350</x>
+     <y>320</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_hOffset">
+   <property name="geometry">
+    <rect>
+     <x>570</x>
+     <y>320</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_orientation">
+   <property name="geometry">
+    <rect>
+     <x>800</x>
+     <y>319</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_pitch">
+   <property name="geometry">
+    <rect>
+     <x>120</x>
+     <y>370</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_roll">
+   <property name="geometry">
+    <rect>
+     <x>350</x>
+     <y>370</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_5">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>220</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>t</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_6">
+   <property name="geometry">
+    <rect>
+     <x>490</x>
+     <y>220</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>id</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_7">
+   <property name="geometry">
+    <rect>
+     <x>720</x>
+     <y>220</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>name</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_8">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>272</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>dynamic</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_9">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>270</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>zOffset</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_10">
+   <property name="geometry">
+    <rect>
+     <x>490</x>
+     <y>270</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>type</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_11">
+   <property name="geometry">
+    <rect>
+     <x>720</x>
+     <y>272</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>country</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_12">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>323</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Revision</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_13">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>320</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>subtype</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_14">
+   <property name="geometry">
+    <rect>
+     <x>490</x>
+     <y>320</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>hOffset</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_15">
+   <property name="geometry">
+    <rect>
+     <x>720</x>
+     <y>322</y>
+     <width>80</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>orientation</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_16">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>370</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>pitch</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_17">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>371</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>roll</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_height">
+   <property name="geometry">
+    <rect>
+     <x>570</x>
+     <y>370</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_width">
+   <property name="geometry">
+    <rect>
+     <x>800</x>
+     <y>370</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_18">
+   <property name="geometry">
+    <rect>
+     <x>490</x>
+     <y>372</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>height</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_19">
+   <property name="geometry">
+    <rect>
+     <x>720</x>
+     <y>372</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>width</string>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_dynamic">
+   <property name="geometry">
+    <rect>
+     <x>120</x>
+     <y>270</y>
+     <width>111</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>500</y>
+     <width>89</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Add</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_2">
+   <property name="geometry">
+    <rect>
+     <x>390</x>
+     <y>500</y>
+     <width>89</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Delete</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_3">
+   <property name="geometry">
+    <rect>
+     <x>630</x>
+     <y>500</y>
+     <width>89</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Update</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_4">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>430</y>
+     <width>191</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Set Lane Validity</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_5">
+   <property name="geometry">
+    <rect>
+     <x>460</x>
+     <y>430</y>
+     <width>221</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Set InertialPosition</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>