فهرست منبع

change tool/map_lanetoxodr. add object outline dialog.

yuchuli 3 سال پیش
والد
کامیت
0b75dbe023

+ 2 - 2
src/common/common/xodr/OpenDrive/ObjectSignal.cpp

@@ -36,7 +36,7 @@ int Object_outlines_outline::Getclosed(bool & closed)
     return 1;
 }
 
-int Object_outlines_outline::GetlaneType(string laneType)
+int Object_outlines_outline::GetlaneType(string & laneType)
 {
     if(mlaneType.size() == 0)return 0;
     laneType = mlaneType[0];
@@ -575,7 +575,7 @@ int Object::GetparkingSpace(Object_parkingSpace &parkingSpace)
 
 Object_outlines * Object::Getoutlines()
 {
-    if(mObject_outlines.size()<1)return 0;
+    if(mObject_outlines.size()<1)return NULL;
     return &(mObject_outlines[0]);
 }
 

+ 1 - 1
src/common/common/xodr/OpenDrive/ObjectSignal.h

@@ -23,7 +23,7 @@ public:
     int GetfillType(string & fillType);
     int Getouter(bool & outer);
     int Getclosed(bool & closed);
-    int GetlaneType(string laneType);
+    int GetlaneType(string & laneType);
 
     void Setid(int & id);
     void SetfillType(string & fillType);

+ 27 - 0
src/tool/map_lanetoxodr/dialogroadobject.cpp

@@ -121,6 +121,7 @@ void DialogRoadObject::CreateView()
     connect(mpPBrepeat,SIGNAL(clicked(bool)),this,SLOT(onClickRepeat()));
     connect(mpPBparkingspace,SIGNAL(clicked(bool)),this,SLOT(onClickParkingSpace()));
     connect(mpPBoutlines,SIGNAL(clicked(bool)),this,SLOT(onClickOutlines()));
+    connect(mpPBoutline,SIGNAL(clicked(bool)),this,SLOT(onClickOutline()));
 }
 
 
@@ -558,3 +559,29 @@ void DialogRoadObject::onClickOutlines()
     dlgoutlines.exec();
 }
 
+void DialogRoadObject::onClickOutline()
+{
+    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_outline dlgoutline(pObject);
+
+    dlgoutline.exec();
+}
+

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

@@ -15,6 +15,7 @@
 #include "dialogroadobject_repeat.h"
 #include "dialogroadobject_parkingspace.h"
 #include "dialogroadobject_outlines.h"
+#include "dialogroadobject_outline.h"
 
 namespace Ui {
 class DialogRoadObject;
@@ -41,6 +42,7 @@ private slots:
     void onClickRepeat();
     void onClickParkingSpace();
     void onClickOutlines();
+    void onClickOutline();
 
 private:
     Ui::DialogRoadObject *ui;

+ 342 - 0
src/tool/map_lanetoxodr/dialogroadobject_outline.cpp

@@ -0,0 +1,342 @@
+#include "dialogroadobject_outline.h"
+#include "ui_dialogroadobject_outline.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_outline::DialogRoadObject_outline(Object * pObject,QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogRoadObject_outline)
+{
+    ui->setupUi(this);
+
+    mpObject = pObject;
+    CreateView();
+
+    int i;
+    for(i=0;i<goutlineFillTypeCount;i++)
+    {
+        mpCBfillType->addItem(gstr_e_outlineFillType[i].data());
+    }
+    mpCBfillType->addItem("NO");
+
+    for(i=0;i<glaneTypeCount;i++)
+    {
+        mpCBlaneType->addItem(gstr_e_laneType[i].data());
+    }
+    mpCBlaneType->addItem("NO");
+    mpCBouter->addItem("true");
+    mpCBouter->addItem("false");
+    mpCBouter->addItem("NO");
+    mpCBclosed->addItem("true");
+    mpCBclosed->addItem("false");
+    mpCBclosed->addItem("NO");
+
+    UpdateCB();
+    setWindowTitle("Edit Road Object Outline");
+}
+
+DialogRoadObject_outline::~DialogRoadObject_outline()
+{
+    delete ui;
+}
+
+void DialogRoadObject_outline::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;
+
+    mpCBOutline = ViewCreate::CreateCB(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"outline",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;
+    mpPBAdd = ViewCreate::CreatePB(startpos_x+0*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Add",this);
+    mpPBDelete = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Delete",this);
+    mpPBChange = ViewCreate::CreatePB(startpos_x+2*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Change",this);
+
+
+    connect(mpCBOutline,SIGNAL(currentIndexChanged(int)),this,SLOT(CurrentOutline(int)));
+    connect(mpPBAdd,SIGNAL(clicked(bool)),this,SLOT(onClickAdd()));
+    connect(mpPBDelete,SIGNAL(clicked(bool)),this,SLOT(onClickDelete()));
+    connect(mpPBChange,SIGNAL(clicked(bool)),this,SLOT(onClickChange()));
+}
+
+void DialogRoadObject_outline::UpdateCB()
+{
+    mpCBOutline->clear();
+    int i;
+    if(mpObject == 0)return;
+    Object * pObject = mpObject;
+
+    int nOutlineCount = pObject->GetObjectoutlineCount();
+    for(i=0;i<nOutlineCount;i++)
+    {
+        mpCBOutline->addItem(QString("Outline ")+ QString::number(i));
+    }
+}
+
+void DialogRoadObject_outline::CurrentOutline(int index)
+{
+    if(index == -1)return;
+    if(mpObject == 0)return;
+
+    Object_outlines_outline * poutline = mpObject->GetObjectoutline(index);
+
+    if(poutline == 0)
+    {
+        return;
+    }
+
+
+    int id;
+    int i;
+    if(poutline->Getid(id) == 1)
+    {
+        mpLEid->setText(QString::number(id));
+    }
+    else
+    {
+        mpLEid->setText("");
+    }
+    std::string strfillType;
+    if(poutline->GetfillType(strfillType) == 1)
+    {
+        int index = goutlineFillTypeCount;
+        for(i=0;i<goutlineFillTypeCount;i++)
+        {
+            if(strfillType == gstr_e_outlineFillType[i])
+            {
+                index = i;
+                break;
+            }
+        }
+        mpCBfillType->setCurrentIndex(index);
+    }
+    else
+    {
+        mpCBfillType->setCurrentIndex(goutlineFillTypeCount);
+    }
+
+    bool outer;
+    if(poutline->Getouter(outer) == 1)
+    {
+        if(outer)mpCBouter->setCurrentIndex(0);
+        else mpCBouter->setCurrentIndex(1);
+    }
+    else
+    {
+        mpCBouter->setCurrentIndex(2);
+    }
+
+    bool closed;
+    if(poutline->Getclosed(closed) == 1)
+    {
+        if(closed)mpCBclosed->setCurrentIndex(0);
+        else    mpCBclosed->setCurrentIndex(1);
+    }
+    else
+    {
+        mpCBclosed->setCurrentIndex(2);
+    }
+
+    std::string strlaneType;
+    if(poutline->GetlaneType(strlaneType) == 1)
+    {
+        int index = glaneTypeCount;
+        for(i=0;i<glaneTypeCount;i++)
+        {
+            if(strlaneType == gstr_e_laneType[i])
+            {
+                index = i;
+                break;
+            }
+        }
+        mpCBlaneType->setCurrentIndex(index);
+    }
+
+}
+
+void DialogRoadObject_outline::onClickAdd()
+{
+    Object * pObject = mpObject;
+
+    if(mpObject == 0)return;
+
+    pObject->AddObjectoutline();
+
+    Object_outlines_outline * poutline = pObject->GetLastAddedObjectoutline();
+
+    if(poutline == NULL)return;
+
+    if(ViewCreate::CheckLE(mpLEid,"id",false,this) == true)
+    {
+        int id = mpLEid->text().toInt();
+        poutline->Setid(id);
+    }
+
+    std::string strFillType;
+    if(mpCBfillType->currentIndex() != goutlineFillTypeCount)
+    {
+        strFillType = mpCBfillType->currentText().toStdString();
+        poutline->SetfillType(strFillType);
+    }
+
+    bool outer;
+    if(mpCBouter->currentIndex() == 0)
+    {
+        outer = true;
+        poutline->Setouter(outer);
+    }
+    else
+    {
+        if(mpCBouter->currentIndex() == 1)
+        {
+            outer = false;
+            poutline->Setouter(outer);
+        }
+    }
+
+
+    bool closed;
+    if(mpCBclosed->currentIndex() == 0)
+    {
+        closed = true;
+        poutline->Setclosed(closed);
+    }
+    else
+    {
+        if(mpCBclosed->currentIndex() == 1)
+        {
+            closed = false;
+            poutline->Setclosed(closed);
+        }
+    }
+
+    std::string strlaneType;
+    if(mpCBlaneType->currentIndex() != glaneTypeCount)
+    {
+        strlaneType = mpCBlaneType->currentText().toStdString();
+        poutline->SetlaneType(strlaneType);
+    }
+
+    UpdateCB();
+}
+
+void DialogRoadObject_outline::onClickDelete()
+{
+    Object * pObject = mpObject;
+
+    if(mpObject == 0)return;
+
+    if(pObject->GetObjectoutlineCount() == 0)
+    {
+        QMessageBox::warning(this,"Warning","No Outline",QMessageBox::YesAll);
+        return;
+    }
+
+    int index = mpCBOutline->currentIndex();
+    pObject->DeleteObjectoutline(index);
+
+    UpdateCB();
+}
+
+void DialogRoadObject_outline::onClickChange()
+{
+    Object * pObject = mpObject;
+
+    if(mpObject == 0)return;
+
+    if(pObject->GetObjectoutlineCount() == 0)
+    {
+        QMessageBox::warning(this,"Warning","No Outline",QMessageBox::YesAll);
+        return;
+    }
+
+    Object_outlines_outline * poutline = pObject->GetObjectoutline(mpCBOutline->currentIndex());
+
+    if(poutline == NULL)return;
+
+    if(ViewCreate::CheckLE(mpLEid,"id",false,this) == true)
+    {
+        int id = mpLEid->text().toInt();
+        poutline->Setid(id);
+    }
+
+    std::string strFillType;
+    if(mpCBfillType->currentIndex() != goutlineFillTypeCount)
+    {
+        strFillType = mpCBfillType->currentText().toStdString();
+        poutline->SetfillType(strFillType);
+    }
+
+    bool outer;
+    if(mpCBouter->currentIndex() == 0)
+    {
+        outer = true;
+        poutline->Setouter(outer);
+    }
+    else
+    {
+        if(mpCBouter->currentIndex() == 1)
+        {
+            outer = false;
+            poutline->Setouter(outer);
+        }
+    }
+
+
+    bool closed;
+    if(mpCBclosed->currentIndex() == 0)
+    {
+        closed = true;
+        poutline->Setclosed(closed);
+    }
+    else
+    {
+        if(mpCBclosed->currentIndex() == 1)
+        {
+            closed = false;
+            poutline->Setclosed(closed);
+        }
+    }
+
+    std::string strlaneType;
+    if(mpCBlaneType->currentIndex() != glaneTypeCount)
+    {
+        strlaneType = mpCBlaneType->currentText().toStdString();
+        poutline->SetlaneType(strlaneType);
+    }
+
+    UpdateCB();
+    QMessageBox::information(this,"Info","Change outline successfully.",QMessageBox::YesAll);
+}
+

+ 52 - 0
src/tool/map_lanetoxodr/dialogroadobject_outline.h

@@ -0,0 +1,52 @@
+#ifndef DIALOGROADOBJECT_OUTLINE_H
+#define DIALOGROADOBJECT_OUTLINE_H
+
+#include <QDialog>
+
+#include "viewcreate.h"
+
+#include <OpenDrive/OpenDrive.h>
+
+namespace Ui {
+class DialogRoadObject_outline;
+}
+
+class DialogRoadObject_outline : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogRoadObject_outline(Object * pObject,QWidget *parent = nullptr);
+    ~DialogRoadObject_outline();
+
+private:
+    Ui::DialogRoadObject_outline *ui;
+
+    Object * mpObject = 0;
+
+    void CreateView();
+
+private slots:
+    void CurrentOutline(int index);
+    void onClickAdd();
+    void onClickDelete();
+    void onClickChange();
+
+private:
+    QComboBox * mpCBOutline;
+    QLineEdit * mpLEid;
+    QComboBox * mpCBfillType;
+    QComboBox * mpCBouter;
+    QComboBox * mpCBclosed;
+    QComboBox * mpCBlaneType;
+
+    QPushButton * mpPBAdd;
+    QPushButton * mpPBDelete;
+    QPushButton * mpPBChange;
+
+private:
+    void UpdateCB();
+
+};
+
+#endif // DIALOGROADOBJECT_OUTLINE_H

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

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogRoadObject_outline</class>
+ <widget class="QDialog" name="DialogRoadObject_outline">
+  <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>

+ 108 - 19
src/tool/map_lanetoxodr/dialogroadobject_outlines.cpp

@@ -30,17 +30,24 @@ DialogRoadObject_Outlines::DialogRoadObject_Outlines(Object * pObject,QWidget *p
     {
         mpCBfillType->addItem(gstr_e_outlineFillType[i].data());
     }
+    mpCBfillType->addItem("NO");
 
     for(i=0;i<glaneTypeCount;i++)
     {
         mpCBlaneType->addItem(gstr_e_laneType[i].data());
     }
+    mpCBlaneType->addItem("NO");
 
     mpCBouter->addItem("true");
     mpCBouter->addItem("false");
+    mpCBouter->addItem("NO");
 
     mpCBclosed->addItem("true");
     mpCBclosed->addItem("false");
+    mpCBclosed->addItem("NO");
+
+    UpdateStatus();
+
 
     setWindowTitle("Edit Road Object Outlines");
 }
@@ -102,34 +109,56 @@ void DialogRoadObject_Outlines::onClickSet()
         xoutline.Setid(id);
     }
 
-//    xoutline.SetfillType(mpCBfillType->currentText().toStdString());
+    std::string strFillType;
+    if(mpCBfillType->currentIndex() != goutlineFillTypeCount)
+    {
+        strFillType = mpCBfillType->currentText().toStdString();
+        xoutline.SetfillType(strFillType);
+    }
 
-//    if(mpCBouter->currentIndex() == 0)
-//    {
+    bool outer;
+    if(mpCBouter->currentIndex() == 0)
+    {
+        outer = true;
+        xoutline.Setouter(outer);
+    }
+    else
+    {
+        if(mpCBouter->currentIndex() == 1)
+        {
+            outer = false;
+            xoutline.Setouter(outer);
+        }
+    }
 
-//        xoutline.Setouter(true);
-//    }
-//    else
-//    {
-//        xoutline.Setouter(false);
-//    }
 
-//    if(mpCBclosed->currentIndex() == 0)
-//    {
-//        xoutline.Setclosed(true);
-//    }
-//    else
-//    {
-//        xoutline.Setclosed(false);
-//    }
+    bool closed;
+    if(mpCBclosed->currentIndex() == 0)
+    {
+        closed = true;
+        xoutline.Setclosed(closed);
+    }
+    else
+    {
+        if(mpCBclosed->currentIndex() == 1)
+        {
+            closed = false;
+            xoutline.Setclosed(closed);
+        }
+    }
 
-    xoutline.SetlaneType(mpCBlaneType->currentText().toStdString());
+    std::string strlaneType;
+    if(mpCBlaneType->currentIndex() != glaneTypeCount)
+    {
+        strlaneType = mpCBlaneType->currentText().toStdString();
+        xoutline.SetlaneType(strlaneType);
+    }
 
     xoutlines.SetObject_outlines_outline(xoutline);
 
     pObject->Setoutlines(xoutlines);
 
-
+    UpdateStatus();
 
 }
 
@@ -141,17 +170,26 @@ void DialogRoadObject_Outlines::onClickReset()
 
     pObject->Resetoutlines();
 
+    UpdateStatus();
 
 }
 
 void DialogRoadObject_Outlines::onClickChange()
 {
+    if(mpObject == 0)return;
+
+    if(mpObject->Getoutlines() == NULL)
+    {
+        QMessageBox::warning(this,"Warning","No outlines need change.Please Set.",QMessageBox::YesAll);
+        return;
+    }
     onClickSet();
     QMessageBox::information(this,"Info","Change outlines succefully.",QMessageBox::YesAll);
 }
 
 void DialogRoadObject_Outlines::UpdateStatus()
 {
+    int i;
     if(mpObject == 0)return;
     Object * pObject = mpObject;
 
@@ -159,6 +197,10 @@ void DialogRoadObject_Outlines::UpdateStatus()
     if(pObject_outlines == NULL)
     {
         mpLEid->setText("");
+        mpCBfillType->setCurrentIndex(goutlineFillTypeCount);
+        mpCBouter->setCurrentIndex(2);
+        mpCBclosed->setCurrentIndex(2);
+        mpCBlaneType->setCurrentIndex(glaneTypeCount);
         mpLEstatus->setText("NO outlines");
     }
     else
@@ -179,12 +221,59 @@ void DialogRoadObject_Outlines::UpdateStatus()
             std::string strfillType;
             if(xoutline.GetfillType(strfillType) == 1)
             {
+                int index = goutlineFillTypeCount;
+                for(i=0;i<goutlineFillTypeCount;i++)
+                {
+                    if(strfillType == gstr_e_outlineFillType[i])
+                    {
+                        index = i;
+                        break;
+                    }
+                }
+                mpCBfillType->setCurrentIndex(index);
+            }
+            else
+            {
+                mpCBfillType->setCurrentIndex(goutlineFillTypeCount);
+            }
+
+            bool outer;
+            if(xoutline.Getouter(outer) == 1)
+            {
+                if(outer)mpCBouter->setCurrentIndex(0);
+                else mpCBouter->setCurrentIndex(1);
+            }
+            else
+            {
+                mpCBouter->setCurrentIndex(2);
+            }
 
+            bool closed;
+            if(xoutline.Getclosed(closed) == 1)
+            {
+                if(closed)mpCBclosed->setCurrentIndex(0);
+                else    mpCBclosed->setCurrentIndex(1);
             }
             else
             {
+                mpCBclosed->setCurrentIndex(2);
+            }
 
+            std::string strlaneType;
+            if(xoutline.GetlaneType(strlaneType) == 1)
+            {
+                int index = glaneTypeCount;
+                for(i=0;i<glaneTypeCount;i++)
+                {
+                    if(strlaneType == gstr_e_laneType[i])
+                    {
+                        index = i;
+                        break;
+                    }
+                }
+                mpCBlaneType->setCurrentIndex(index);
             }
+
         }
     }
 }

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

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