Browse Source

change tool/map_lanetoxodr. add object outlines dialog, but not complete.

yuchuli 3 years ago
parent
commit
3bb233469e

+ 76 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlWriter.cpp

@@ -1244,6 +1244,20 @@ bool OpenDriveXmlWriter::WriteObject(TiXmlElement *node, Object *pObject)
         WriteObjectMaterial(nodeObject,pObject_material);
     }
 
+    Object_outlines * pObject_outlines =  pObject->Getoutlines();
+
+    if(pObject_outlines != NULL)
+    {
+        WriteObjectOutlines(nodeObject,pObject_outlines);
+    }
+
+    unsigned noutlinecount = pObject->GetObjectoutlineCount();
+    for(i=0;i<noutlinecount;i++)
+    {
+        Object_outlines_outline * pObject_outlines_outline = pObject->GetObjectoutline(i);
+        WriteObjectOutlinesOutline(nodeObject,pObject_outlines_outline);
+    }
+
     return true;
 }
 //--------------
@@ -1350,6 +1364,68 @@ bool OpenDriveXmlWriter::WriteObjectParkingSpace(TiXmlElement *node, Object_park
     }
     return true;
 }
+//--------------
+bool OpenDriveXmlWriter::WriteObjectOutlines(TiXmlElement *node, Object_outlines *pObject_outlines)
+{
+    Object_outlines_outline xoutlines_outline;
+    if(pObject_outlines->GetObject_outlines_outline(xoutlines_outline) == 1)
+    {
+        TiXmlElement * nodeObjectOutlines = new TiXmlElement("outlines");
+        node->LinkEndChild(nodeObjectOutlines);
+        WriteObjectOutlinesOutline(nodeObjectOutlines,&xoutlines_outline);
+        return true;
+    }
+    std::cout<<"outlines not have outline."<<std::endl;
+    return false;
+}
+//--------------
+
+bool OpenDriveXmlWriter::WriteObjectOutlinesOutline(TiXmlElement *node, Object_outlines_outline *pObject_outlines_outline)
+{
+    TiXmlElement * nodeObjectOutlinesOutline = new TiXmlElement("outline");
+    node->LinkEndChild(nodeObjectOutlinesOutline);
+    int id;
+    string fillType,strouter,strclosed,laneType;
+    bool outer,closed;
+    if(pObject_outlines_outline->Getid(id) == 1)
+    {
+        nodeObjectOutlinesOutline->SetAttribute("id",id);
+    }
+    if(pObject_outlines_outline->GetfillType(fillType) == 1)
+    {
+        nodeObjectOutlinesOutline->SetAttribute("fillType",fillType);
+    }
+    if(pObject_outlines_outline->Getouter(outer) == 1)
+    {
+        if(outer)
+        {
+            strouter = "true";
+        }
+        else
+        {
+            strouter = "false";
+        }
+        nodeObjectOutlinesOutline->SetAttribute("outer",strouter);
+    }
+    if(pObject_outlines_outline->Getclosed(closed) == 1)
+    {
+        if(closed)
+        {
+            strclosed = "true";
+        }
+        else
+        {
+            strclosed = "false";
+        }
+        nodeObjectOutlinesOutline->SetAttribute("closed",strclosed);
+    }
+    if(pObject_outlines_outline->GetlaneType(laneType) == 1)
+    {
+        nodeObjectOutlinesOutline->SetAttribute("laneType",laneType);
+    }
+    return true;
+}
+
 //--------------
 
 bool OpenDriveXmlWriter::WriteRoadBorrow(TiXmlElement *node, RoadBorrow *pRoadBorrow)

+ 2 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlWriter.h

@@ -74,6 +74,8 @@ public:
     bool WriteObjectParkingSpace(TiXmlElement * node,Object_parkingSpace * pObject_parkingSpace);
     bool WriteObjectrepeat(TiXmlElement * node,Object_repeat * pObject_repeat);
     bool WriteObjectMaterial(TiXmlElement * node,Object_material * pObject_material);
+    bool WriteObjectOutlines(TiXmlElement * node,Object_outlines * pObject_outlines);
+    bool WriteObjectOutlinesOutline(TiXmlElement * node,Object_outlines_outline * pObject_outlines_outline);
 	bool WriteSignals (TiXmlElement *node, Road* road);
     bool WriteSignal(TiXmlElement * node, Signal * pSignal);
     bool WriteSignal_positionInertial(TiXmlElement * node, signal_positionInertial * pSignal_positionInertial);

+ 44 - 11
src/tool/map_lanetoxodr/dialogroadobject.cpp

@@ -50,6 +50,8 @@ DialogRoadObject::DialogRoadObject(Road * pRoad,QWidget *parent) :
     mpCBorientation->addItem("undefined");
     mpCBorientation->setCurrentIndex(3);
 
+    if(pRoad != 0)
+    {
 
     int nobjectcount = pRoad->GetObjectCount();
     for(i=0;i<nobjectcount;i++)
@@ -58,6 +60,8 @@ DialogRoadObject::DialogRoadObject(Road * pRoad,QWidget *parent) :
         ui->comboBox_Object->addItem("Object s:"+QString::number(pObject->Gets()));
     }
 
+    }
+
     setWindowTitle("Edit Road Object");
 }
 
@@ -116,6 +120,7 @@ void DialogRoadObject::CreateView()
     connect(mpPBmaterial,SIGNAL(clicked(bool)),this,SLOT(onClickMaterial()));
     connect(mpPBrepeat,SIGNAL(clicked(bool)),this,SLOT(onClickRepeat()));
     connect(mpPBparkingspace,SIGNAL(clicked(bool)),this,SLOT(onClickParkingSpace()));
+    connect(mpPBoutlines,SIGNAL(clicked(bool)),this,SLOT(onClickOutlines()));
 }
 
 
@@ -123,6 +128,8 @@ void DialogRoadObject::CreateView()
 void DialogRoadObject::on_pushButton_add_clicked()
 {
     Road * pRoad = mpRoad;
+    if(pRoad == 0)return;
+
     if(ViewCreate::CheckLE(mpLEid,"id",true,this) == false)return;
     string id = mpLEid->text().toStdString();
 
@@ -139,7 +146,7 @@ void DialogRoadObject::on_pushButton_add_clicked()
     if(mpCBtype->currentText() == "parkingSpace")
     {
         if(ViewCreate::CheckLE(mpLElength,"length",true,this) == false)return;
-        length = mpLElength->text().toDouble();
+//        length = mpLElength->text().toDouble();
 
         if(ViewCreate::CheckLE(mpLEwidth,"width",true,this) == false)return;
         width = mpLEwidth->text().toDouble();
@@ -223,7 +230,7 @@ void DialogRoadObject::on_comboBox_Object_currentIndexChanged(int index)
     Road * pRoad = mpRoad;
     if(pRoad == 0)return;
     if(index < 0)return;
-    if(index >= mpRoad->GetObjectCount())
+    if(index >= (int)mpRoad->GetObjectCount())
     {
         return;
     }
@@ -324,7 +331,7 @@ void DialogRoadObject::on_pushButton_delete_clicked()
 
     int index = ui->comboBox_Object->currentIndex();
     if(index<0)return;
-    if(index >= mpRoad->GetObjectCount())return;
+    if(index >= (int)mpRoad->GetObjectCount())return;
 
     pRoad->DeleteObject(index);
     ui->comboBox_Object->removeItem(index);
@@ -342,7 +349,7 @@ void DialogRoadObject::on_pushButton_change_clicked()
 
     int index = ui->comboBox_Object->currentIndex();
     if(index<0)return;
-    if(index >= mpRoad->GetObjectCount())return;
+    if(index >= (int)mpRoad->GetObjectCount())return;
 
     Object * pObject = mpRoad->GetObject(index);
     if(pObject == 0)
@@ -364,17 +371,17 @@ void DialogRoadObject::on_pushButton_change_clicked()
     double zOffset = mpLEzOffset->text().toDouble();
 
 
-    double length,width,hdg;
+//    double length,width,hdg;
     if(mpCBtype->currentText() == "parkingSpace")
     {
         if(ViewCreate::CheckLE(mpLElength,"length",true,this) == false)return;
-        length = mpLElength->text().toDouble();
+//        length = mpLElength->text().toDouble();
 
         if(ViewCreate::CheckLE(mpLEwidth,"width",true,this) == false)return;
-        width = mpLEwidth->text().toDouble();
+//        width = mpLEwidth->text().toDouble();
 
         if(ViewCreate::CheckLE(mpLEhdg,"hdg",true,this) == false)return;
-        hdg = mpLEhdg->text().toDouble();
+ //       hdg = mpLEhdg->text().toDouble();
     }
 
     pObject->Setid(id);
@@ -459,7 +466,7 @@ void DialogRoadObject::onClickMaterial()
 
     int index = ui->comboBox_Object->currentIndex();
     if(index<0)return;
-    if(index >= mpRoad->GetObjectCount())return;
+    if(index >= (int)mpRoad->GetObjectCount())return;
 
     Object * pObject = mpRoad->GetObject(index);
     if(pObject == 0)
@@ -485,7 +492,7 @@ void DialogRoadObject::onClickRepeat()
 
     int index = ui->comboBox_Object->currentIndex();
     if(index<0)return;
-    if(index >= mpRoad->GetObjectCount())return;
+    if(index >= (int)mpRoad->GetObjectCount())return;
 
     Object * pObject = mpRoad->GetObject(index);
     if(pObject == 0)
@@ -511,7 +518,7 @@ void DialogRoadObject::onClickParkingSpace()
 
     int index = ui->comboBox_Object->currentIndex();
     if(index<0)return;
-    if(index >= mpRoad->GetObjectCount())return;
+    if(index >= (int)mpRoad->GetObjectCount())return;
 
     Object * pObject = mpRoad->GetObject(index);
     if(pObject == 0)
@@ -525,3 +532,29 @@ void DialogRoadObject::onClickParkingSpace()
     dlgparkingspace.exec();
 }
 
+void DialogRoadObject::onClickOutlines()
+{
+    if(mpRoad == 0)return;
+    Road * pRoad = mpRoad;
+    if(pRoad->GetObjectCount() == 0)
+    {
+        QMessageBox::warning(this,"Warning","No Object.",QMessageBox::YesAll);
+        return;
+    }
+
+    int index = ui->comboBox_Object->currentIndex();
+    if(index<0)return;
+    if(index >= (int)mpRoad->GetObjectCount())return;
+
+    Object * pObject = mpRoad->GetObject(index);
+    if(pObject == 0)
+    {
+        QMessageBox::warning(this,"Warning","Can't found Object.",QMessageBox::YesAll);
+        return;
+    }
+
+    DialogRoadObject_Outlines dlgoutlines(pObject);
+
+    dlgoutlines.exec();
+}
+

+ 2 - 0
src/tool/map_lanetoxodr/dialogroadobject.h

@@ -14,6 +14,7 @@
 #include "dialogroadobject_material.h"
 #include "dialogroadobject_repeat.h"
 #include "dialogroadobject_parkingspace.h"
+#include "dialogroadobject_outlines.h"
 
 namespace Ui {
 class DialogRoadObject;
@@ -39,6 +40,7 @@ private slots:
     void onClickMaterial();
     void onClickRepeat();
     void onClickParkingSpace();
+    void onClickOutlines();
 
 private:
     Ui::DialogRoadObject *ui;

+ 190 - 0
src/tool/map_lanetoxodr/dialogroadobject_outlines.cpp

@@ -0,0 +1,190 @@
+#include "dialogroadobject_outlines.h"
+#include "ui_dialogroadobject_outlines.h"
+
+static std::string gstr_e_outlineFillType[] ={"grass","concrete","cobble","asphalt",
+                                             "pavement","gravel","soil"};
+
+static const int goutlineFillTypeCount = 7;
+
+static std::string gstr_e_laneType[] = {"shoulder","border","driving","stop","none",
+                                       "restricted","parking","median","biking","sidewalk",
+                                       "curb","exit","entry","onRamp","offRamp",
+                                       "connectingRamp","bidirectional","special1","special2","special3",
+                                       "roadWorks","tram","rail","bus","taxi",
+                                       "HOV","mwyEntry","mwyExit"};
+
+static const int glaneTypeCount = 33;
+
+DialogRoadObject_Outlines::DialogRoadObject_Outlines(Object * pObject,QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogRoadObject_Outlines)
+{
+    ui->setupUi(this);
+
+    mpObject = pObject;
+
+    CreateView();
+
+    int i;
+    for(i=0;i<goutlineFillTypeCount;i++)
+    {
+        mpCBfillType->addItem(gstr_e_outlineFillType[i].data());
+    }
+
+    for(i=0;i<glaneTypeCount;i++)
+    {
+        mpCBlaneType->addItem(gstr_e_laneType[i].data());
+    }
+
+    mpCBouter->addItem("true");
+    mpCBouter->addItem("false");
+
+    mpCBclosed->addItem("true");
+    mpCBclosed->addItem("false");
+
+    setWindowTitle("Edit Road Object Outlines");
+}
+
+DialogRoadObject_Outlines::~DialogRoadObject_Outlines()
+{
+    delete ui;
+}
+
+void DialogRoadObject_Outlines::CreateView()
+{
+    int startpos_x = 30;
+    int startpos_y = 30;
+    int nSpace = 260;
+    int nLabelWidth = 80;
+    int nLEWidth = 150;
+    int nHeight = 35;
+    int nVSpace = 60;
+    int nVIndex = 0;
+
+    mpLEstatus = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"status",this);
+    nVIndex++;
+
+    mpLEid = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"id",this);
+    mpCBfillType = ViewCreate::CreateCB(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"fillType",this);
+
+    nVIndex++;
+    mpCBouter = ViewCreate::CreateCB(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"outer",this);
+    mpCBclosed = ViewCreate::CreateCB(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"closed",this);
+
+    nVIndex++;
+    mpCBlaneType = ViewCreate::CreateCB(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"laneType",this);
+
+    nVIndex++;
+    int nPBSpace = 150;
+    int nPBWidth = 100;
+    mpPBSet = ViewCreate::CreatePB(startpos_x+0*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Set",this);
+    mpPBReset = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Reset",this);
+    mpPBChange = ViewCreate::CreatePB(startpos_x+2*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Change",this);
+
+    connect(mpPBSet,SIGNAL(clicked(bool)),this,SLOT(onClickSet()));
+    connect(mpPBReset,SIGNAL(clicked(bool)),this,SLOT(onClickReset()));
+    connect(mpPBChange,SIGNAL(clicked(bool)),this,SLOT(onClickChange()));
+}
+
+void DialogRoadObject_Outlines::onClickSet()
+{
+    Object_outlines xoutlines;
+
+    Object * pObject = mpObject;
+
+    if(mpObject == 0)return;
+
+    Object_outlines_outline xoutline;
+
+    if(ViewCreate::CheckLE(mpLEid,"id",false,this) == true)
+    {
+        int id = mpLEid->text().toInt();
+        xoutline.Setid(id);
+    }
+
+//    xoutline.SetfillType(mpCBfillType->currentText().toStdString());
+
+//    if(mpCBouter->currentIndex() == 0)
+//    {
+
+//        xoutline.Setouter(true);
+//    }
+//    else
+//    {
+//        xoutline.Setouter(false);
+//    }
+
+//    if(mpCBclosed->currentIndex() == 0)
+//    {
+//        xoutline.Setclosed(true);
+//    }
+//    else
+//    {
+//        xoutline.Setclosed(false);
+//    }
+
+    xoutline.SetlaneType(mpCBlaneType->currentText().toStdString());
+
+    xoutlines.SetObject_outlines_outline(xoutline);
+
+    pObject->Setoutlines(xoutlines);
+
+
+
+}
+
+void DialogRoadObject_Outlines::onClickReset()
+{
+    if(mpObject == 0)return;
+
+    Object * pObject = mpObject;
+
+    pObject->Resetoutlines();
+
+
+}
+
+void DialogRoadObject_Outlines::onClickChange()
+{
+    onClickSet();
+    QMessageBox::information(this,"Info","Change outlines succefully.",QMessageBox::YesAll);
+}
+
+void DialogRoadObject_Outlines::UpdateStatus()
+{
+    if(mpObject == 0)return;
+    Object * pObject = mpObject;
+
+    Object_outlines * pObject_outlines = pObject->Getoutlines();
+    if(pObject_outlines == NULL)
+    {
+        mpLEid->setText("");
+        mpLEstatus->setText("NO outlines");
+    }
+    else
+    {
+        mpLEstatus->setText("HAVE outlines");
+        Object_outlines_outline xoutline;
+        if(pObject_outlines->GetObject_outlines_outline(xoutline) == 1)
+        {
+            int id;
+            if(xoutline.Getid(id) == 1)
+            {
+                mpLEid->setText(QString::number(id));
+            }
+            else
+            {
+                mpLEid->setText("");
+            }
+            std::string strfillType;
+            if(xoutline.GetfillType(strfillType) == 1)
+            {
+
+            }
+            else
+            {
+
+            }
+        }
+    }
+}

+ 57 - 0
src/tool/map_lanetoxodr/dialogroadobject_outlines.h

@@ -0,0 +1,57 @@
+#ifndef DIALOGROADOBJECT_OUTLINES_H
+#define DIALOGROADOBJECT_OUTLINES_H
+
+#include <QDialog>
+
+#include <QDialog>
+#include <QLineEdit>
+#include <QLabel>
+#include <QComboBox>
+#include <QPushButton>
+
+#include "viewcreate.h"
+
+#include <OpenDrive/OpenDrive.h>
+
+
+
+namespace Ui {
+class DialogRoadObject_Outlines;
+}
+
+class DialogRoadObject_Outlines : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogRoadObject_Outlines(Object * pObject,QWidget *parent = nullptr);
+    ~DialogRoadObject_Outlines();
+
+private:
+    Ui::DialogRoadObject_Outlines *ui;
+
+    Object * mpObject = 0;
+
+    void CreateView();
+
+    void UpdateStatus();
+
+private slots:
+    void onClickSet();
+    void onClickReset();
+    void onClickChange();
+
+private:
+    QLineEdit * mpLEstatus;
+    QLineEdit * mpLEid;
+    QComboBox * mpCBfillType;
+    QComboBox * mpCBouter;
+    QComboBox * mpCBclosed;
+    QComboBox * mpCBlaneType;
+
+    QPushButton * mpPBSet;
+    QPushButton * mpPBReset;
+    QPushButton * mpPBChange;
+};
+
+#endif // DIALOGROADOBJECT_OUTLINES_H

+ 19 - 0
src/tool/map_lanetoxodr/dialogroadobject_outlines.ui

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogRoadObject_Outlines</class>
+ <widget class="QDialog" name="DialogRoadObject_Outlines">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>600</width>
+    <height>395</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

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

@@ -45,6 +45,7 @@ SOURCES += \
     dialogroadmove.cpp \
     dialogroadobject.cpp \
     dialogroadobject_material.cpp \
+    dialogroadobject_outlines.cpp \
     dialogroadobject_parkingspace.cpp \
     dialogroadobject_repeat.cpp \
     dialogroadoptimize.cpp \
@@ -100,6 +101,7 @@ HEADERS += \
     dialogroadmove.h \
     dialogroadobject.h \
     dialogroadobject_material.h \
+    dialogroadobject_outlines.h \
     dialogroadobject_parkingspace.h \
     dialogroadobject_repeat.h \
     dialogroadoptimize.h \
@@ -149,6 +151,7 @@ FORMS += \
         dialogroadmove.ui \
         dialogroadobject.ui \
         dialogroadobject_material.ui \
+        dialogroadobject_outlines.ui \
         dialogroadobject_parkingspace.ui \
         dialogroadobject_repeat.ui \
         dialogroadoptimize.ui \