Forráskód Böngészése

change tool/map_lanetoxodr. add signal position lanevalid dialog.

yuchuli 4 éve
szülő
commit
61c5929cfb

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

@@ -299,3 +299,9 @@ void Header::SetXYValues(double north, double south, double east,double west)
 	mEast=east;
 	mWest=west;
 }
+
+void Header::GetLat0Lon0(double &lat0, double &lon0)
+{
+    lat0 = mLat0;
+    lon0 = mLon0;
+}

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

@@ -181,6 +181,9 @@ public:
 
     void SetAllParams(unsigned short int revMajor, unsigned short int revMinor, string name, float version, string date,
         double north, double south, double east,double west,double lat0,double lon0,double hdg0);
+
+
+    void GetLat0Lon0(double & lat0,double & lon0);
 };
 
 

+ 2 - 2
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlWriter.cpp

@@ -990,8 +990,8 @@ bool OpenDriveXmlWriter::WriteSignal_laneValidity(TiXmlElement *node, signal_lan
 
     node->LinkEndChild(nodelaneValidity);
 
-    nodelaneValidity->SetAttribute("x",pSignal_laneValidity->GetfromLane());
-    nodelaneValidity->SetAttribute("y",pSignal_laneValidity->GettoLane());
+    nodelaneValidity->SetAttribute("fromLane",pSignal_laneValidity->GetfromLane());
+    nodelaneValidity->SetAttribute("toLane",pSignal_laneValidity->GettoLane());
 
     return true;
 }

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

@@ -2639,6 +2639,9 @@ void MainWindow::onClickLoad()
         mxodr.GetJunctionVector()->push_back(pxodr->GetJunctionVector()->at(i));
     }
 
+    if((mxodr.GetRoadCount()>0)&&(mxodr.GetHeader() == 0))
+        mxodr.SetHeader(1,1,"adcmap",1.1,QDateTime::currentDateTime().toString("yyyy-MM-dd").toLatin1().data(),0,0,0,0,glat0,glon0,ghdg0);
+
     updateCBRoad();
     updateJunction();
 

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

@@ -33,6 +33,8 @@ SOURCES += \
         mainwindow.cpp \
     speeddialog.cpp \
     trafficlightdialog.cpp \
+    trafficlightlanevaliditydialog.cpp \
+    trafficlightpositiondialog.cpp \
     xodr.cpp \
     myview.cpp \
     linedata.cpp \
@@ -64,6 +66,8 @@ HEADERS += \
         mainwindow.h \
     speeddialog.h \
     trafficlightdialog.h \
+    trafficlightlanevaliditydialog.h \
+    trafficlightpositiondialog.h \
     xodr.h \
     myview.h \
     boost.h \
@@ -90,7 +94,9 @@ HEADERS += \
 FORMS += \
         mainwindow.ui \
         speeddialog.ui \
-        trafficlightdialog.ui
+        trafficlightdialog.ui \
+        trafficlightlanevaliditydialog.ui \
+        trafficlightpositiondialog.ui
 
 unix:LIBS += -lboost_thread -lboost_system -lboost_serialization -lprotobuf
 

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

@@ -1,6 +1,9 @@
 #include "trafficlightdialog.h"
 #include "ui_trafficlightdialog.h"
 
+#include "trafficlightlanevaliditydialog.h"
+#include "trafficlightpositiondialog.h"
+
 TrafficLightDialog::TrafficLightDialog(OpenDrive * pxodr,QWidget *parent) :
     QDialog(parent),
     ui(new Ui::TrafficLightDialog)
@@ -20,6 +23,8 @@ TrafficLightDialog::TrafficLightDialog(OpenDrive * pxodr,QWidget *parent) :
 
     }
 
+
+
     setWindowTitle("Edit Traffic Light");
 
 }
@@ -109,3 +114,35 @@ void TrafficLightDialog::on_comboBox_TrafficLIght_currentIndexChanged(int index)
     Signal * pSignal = pRoad->GetSignal(index);
     showsignal(pSignal);
 }
+
+void TrafficLightDialog::on_pushButton_EditinertialPosition_clicked()
+{
+    Road * pRoad =mpxodr->GetRoad(ui->comboBox_Road->currentIndex());
+    if(pRoad == 0)return;
+
+    if(pRoad->GetSignalCount() == 0)return;
+
+    Signal * pSignal =pRoad->GetSignal(ui->comboBox_TrafficLIght->currentIndex());
+    if(pSignal == 0)return;
+
+    double lon0,lat0;
+    mpxodr->GetHeader()->GetLat0Lon0(lat0,lon0);
+    TrafficLightpositionDialog td(pSignal,lon0,lat0,this);
+    int res = td.exec();
+    (void)&res;
+}
+
+void TrafficLightDialog::on_pushButton_EditlaneValidity_clicked()
+{
+    Road * pRoad =mpxodr->GetRoad(ui->comboBox_Road->currentIndex());
+    if(pRoad == 0)return;
+
+    if(pRoad->GetSignalCount() == 0)return;
+
+    Signal * pSignal =pRoad->GetSignal(ui->comboBox_TrafficLIght->currentIndex());
+    if(pSignal == 0)return;
+
+    TrafficLightlaneValidityDialog td(pSignal,this);
+    int res = td.exec();
+    (void)&res;
+}

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

@@ -21,6 +21,10 @@ private slots:
 
     void on_comboBox_TrafficLIght_currentIndexChanged(int index);
 
+    void on_pushButton_EditinertialPosition_clicked();
+
+    void on_pushButton_EditlaneValidity_clicked();
+
 private:
     Ui::TrafficLightDialog *ui;
     OpenDrive * mpxodr;

+ 4 - 4
src/tool/map_lanetoxodr/trafficlightdialog.ui

@@ -489,7 +489,7 @@
     <string>Update</string>
    </property>
   </widget>
-  <widget class="QPushButton" name="pushButton_4">
+  <widget class="QPushButton" name="pushButton_EditlaneValidity">
    <property name="geometry">
     <rect>
      <x>170</x>
@@ -499,10 +499,10 @@
     </rect>
    </property>
    <property name="text">
-    <string>Set Lane Validity</string>
+    <string>Edit Lane Validity</string>
    </property>
   </widget>
-  <widget class="QPushButton" name="pushButton_5">
+  <widget class="QPushButton" name="pushButton_EditinertialPosition">
    <property name="geometry">
     <rect>
      <x>460</x>
@@ -512,7 +512,7 @@
     </rect>
    </property>
    <property name="text">
-    <string>Set InertialPosition</string>
+    <string>Edit InertialPosition</string>
    </property>
   </widget>
  </widget>

+ 40 - 0
src/tool/map_lanetoxodr/trafficlightlanevaliditydialog.cpp

@@ -0,0 +1,40 @@
+#include "trafficlightlanevaliditydialog.h"
+#include "ui_trafficlightlanevaliditydialog.h"
+
+#include <QMessageBox>
+
+TrafficLightlaneValidityDialog::TrafficLightlaneValidityDialog(Signal * pSignal,QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::TrafficLightlaneValidityDialog)
+{
+    ui->setupUi(this);
+    mpSignal = pSignal;
+
+    signal_laneValidity * psignal_laneValidity = mpSignal->GetlaneValidity();
+
+    if(psignal_laneValidity != 0)
+    {
+        ui->lineEdit_fromLane->setText(QString::number(psignal_laneValidity->GetfromLane()));
+        ui->lineEdit_toLane->setText(QString::number(psignal_laneValidity->GettoLane()));
+    }
+
+}
+
+TrafficLightlaneValidityDialog::~TrafficLightlaneValidityDialog()
+{
+    delete ui;
+}
+
+void TrafficLightlaneValidityDialog::on_pushButton_clicked()
+{
+    if((ui->lineEdit_fromLane->text().length()== 0)||(ui->lineEdit_toLane->text().length() == 0))
+    {
+        QMessageBox::warning(this,"warning","value is empty.");
+        return;
+    }
+
+    int fromLane = ui->lineEdit_fromLane->text().toInt();
+    int toLane = ui->lineEdit_toLane->text().toInt();
+
+    mpSignal->SetlaneValidity(fromLane,toLane);
+}

+ 27 - 0
src/tool/map_lanetoxodr/trafficlightlanevaliditydialog.h

@@ -0,0 +1,27 @@
+#ifndef TRAFFICLIGHTLANEVALIDITYDIALOG_H
+#define TRAFFICLIGHTLANEVALIDITYDIALOG_H
+
+#include <QDialog>
+#include "OpenDrive/OpenDrive.h"
+
+namespace Ui {
+class TrafficLightlaneValidityDialog;
+}
+
+class TrafficLightlaneValidityDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit TrafficLightlaneValidityDialog(Signal * pSignal,QWidget *parent = nullptr);
+    ~TrafficLightlaneValidityDialog();
+
+private slots:
+    void on_pushButton_clicked();
+
+private:
+    Ui::TrafficLightlaneValidityDialog *ui;
+    Signal * mpSignal;
+};
+
+#endif // TRAFFICLIGHTLANEVALIDITYDIALOG_H

+ 78 - 0
src/tool/map_lanetoxodr/trafficlightlanevaliditydialog.ui

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TrafficLightlaneValidityDialog</class>
+ <widget class="QDialog" name="TrafficLightlaneValidityDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>592</width>
+    <height>172</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QLineEdit" name="lineEdit_fromLane">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>40</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_toLane">
+   <property name="geometry">
+    <rect>
+     <x>430</x>
+     <y>40</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>260</x>
+     <y>100</y>
+     <width>89</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Update</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>62</x>
+     <y>43</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>fromLane</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>331</x>
+     <y>42</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>toLane</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 76 - 0
src/tool/map_lanetoxodr/trafficlightpositiondialog.cpp

@@ -0,0 +1,76 @@
+#include "trafficlightpositiondialog.h"
+#include "ui_trafficlightpositiondialog.h"
+
+#include <QMessageBox>
+
+#include <gnss_coordinate_convert.h>
+
+
+TrafficLightpositionDialog::TrafficLightpositionDialog(Signal * pSignal,double lon0,double lat0,QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::TrafficLightpositionDialog)
+{
+    ui->setupUi(this);
+    mpSignal = pSignal;
+    mlon0 = lon0;
+    mlat0 = lat0;
+
+    signal_positionInertial * pSignal_positionInertial;
+    pSignal_positionInertial = mpSignal->GetpositionInertial();
+    if(pSignal_positionInertial != 0)
+    {
+        double x, y;
+        double x0,y0;
+        double lon,lat;
+        GaussProjCal(mlon0,mlat0,&x0,&y0);
+        x = pSignal_positionInertial->Getx();
+        y = pSignal_positionInertial->Gety();
+        GaussProjInvCal((x+x0),(y+y0),&lon,&lat);
+        double hdg = pSignal_positionInertial->Gethdg();
+        double head0 = (M_PI/2.0 - hdg)*180.0/M_PI;
+        if(head0<0)head0 = head0 + 360.0;
+        double z = pSignal_positionInertial->Getz();
+        double pitch = pSignal_positionInertial->Getpitch();
+        double roll = pSignal_positionInertial->Getroll();
+        ui->lineEdit_Lon->setText(QString::number(lon,'f',7));
+        ui->lineEdit_Lat->setText(QString::number(lat,'f',7));
+        ui->lineEdit_Height->setText(QString::number(z,'f',2));
+        ui->lineEdit_hdg->setText(QString::number(head0));
+        ui->lineEdit_pitch->setText(QString::number(pitch));
+        ui->lineEdit_roll->setText(QString::number(roll));
+    }
+
+}
+
+TrafficLightpositionDialog::~TrafficLightpositionDialog()
+{
+    delete ui;
+}
+
+void TrafficLightpositionDialog::on_pushButton_Update_clicked()
+{
+    if(mpSignal == 0)return;
+    double lon,lat,z,head,pitch,roll;
+    if((ui->lineEdit_Lon->text().length() == 0)||(ui->lineEdit_Lat->text().length() == 0))
+    {
+        QMessageBox::warning(this,"warning","Value is Empty.");
+        return;
+    }
+    lon = ui->lineEdit_Lon->text().toDouble();
+    lat = ui->lineEdit_Lat->text().toDouble();
+    z = ui->lineEdit_Height->text().toDouble();
+    head = ui->lineEdit_hdg->text().toDouble();
+    pitch = ui->lineEdit_pitch->text().toDouble();
+    roll = ui->lineEdit_roll->text().toDouble();
+
+    double x, y;
+    double x0,y0;
+
+    GaussProjCal(mlon0,mlat0,&x0,&y0);
+    GaussProjCal(lon,lat,&x,&y);
+    double hdg = (90-head)*M_PI/180.0;
+    if(hdg<0)hdg = hdg +M_PI*2.0;
+    mpSignal->SetpositionInertial(x-x0,y-y0,z,hdg,pitch,roll);
+
+
+}

+ 30 - 0
src/tool/map_lanetoxodr/trafficlightpositiondialog.h

@@ -0,0 +1,30 @@
+#ifndef TRAFFICLIGHTPOSITIONDIALOG_H
+#define TRAFFICLIGHTPOSITIONDIALOG_H
+
+#include <QDialog>
+#include "OpenDrive/OpenDrive.h"
+
+namespace Ui {
+class TrafficLightpositionDialog;
+}
+
+class TrafficLightpositionDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit TrafficLightpositionDialog(Signal * pSignal, double lon0,double lat0,QWidget *parent = nullptr);
+    ~TrafficLightpositionDialog();
+
+private slots:
+    void on_pushButton_Update_clicked();
+
+private:
+    Ui::TrafficLightpositionDialog *ui;
+
+    Signal * mpSignal;
+    double mlon0;
+    double mlat0;
+};
+
+#endif // TRAFFICLIGHTPOSITIONDIALOG_H

+ 170 - 0
src/tool/map_lanetoxodr/trafficlightpositiondialog.ui

@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TrafficLightpositionDialog</class>
+ <widget class="QDialog" name="TrafficLightpositionDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>579</width>
+    <height>298</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QPushButton" name="pushButton_Update">
+   <property name="geometry">
+    <rect>
+     <x>220</x>
+     <y>230</y>
+     <width>89</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Update</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Lon">
+   <property name="geometry">
+    <rect>
+     <x>160</x>
+     <y>50</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Lat">
+   <property name="geometry">
+    <rect>
+     <x>430</x>
+     <y>50</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Height">
+   <property name="geometry">
+    <rect>
+     <x>160</x>
+     <y>110</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_hdg">
+   <property name="geometry">
+    <rect>
+     <x>430</x>
+     <y>110</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_pitch">
+   <property name="geometry">
+    <rect>
+     <x>160</x>
+     <y>170</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_roll">
+   <property name="geometry">
+    <rect>
+     <x>430</x>
+     <y>170</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>23</x>
+     <y>53</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Lon</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>310</x>
+     <y>54</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Lat</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_3">
+   <property name="geometry">
+    <rect>
+     <x>22</x>
+     <y>115</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>height</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_4">
+   <property name="geometry">
+    <rect>
+     <x>309</x>
+     <y>113</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>hdg</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_5">
+   <property name="geometry">
+    <rect>
+     <x>21</x>
+     <y>176</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>pitch</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_6">
+   <property name="geometry">
+    <rect>
+     <x>313</x>
+     <y>171</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>roll</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>