Procházet zdrojové kódy

change tool/map_lanetoxodr. now add parking space show.

yuchuli před 3 roky
rodič
revize
6668218195

+ 14 - 0
src/tool/map_lanetoxodr/dialogparkingspaceedit.cpp

@@ -0,0 +1,14 @@
+#include "dialogparkingspaceedit.h"
+#include "ui_dialogparkingspaceedit.h"
+
+DialogParkingSpaceEdit::DialogParkingSpaceEdit(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogParkingSpaceEdit)
+{
+    ui->setupUi(this);
+}
+
+DialogParkingSpaceEdit::~DialogParkingSpaceEdit()
+{
+    delete ui;
+}

+ 22 - 0
src/tool/map_lanetoxodr/dialogparkingspaceedit.h

@@ -0,0 +1,22 @@
+#ifndef DIALOGPARKINGSPACEEDIT_H
+#define DIALOGPARKINGSPACEEDIT_H
+
+#include <QDialog>
+
+namespace Ui {
+class DialogParkingSpaceEdit;
+}
+
+class DialogParkingSpaceEdit : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogParkingSpaceEdit(QWidget *parent = nullptr);
+    ~DialogParkingSpaceEdit();
+
+private:
+    Ui::DialogParkingSpaceEdit *ui;
+};
+
+#endif // DIALOGPARKINGSPACEEDIT_H

+ 242 - 0
src/tool/map_lanetoxodr/dialogparkingspaceedit.ui

@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogParkingSpaceEdit</class>
+ <widget class="QDialog" name="DialogParkingSpaceEdit">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>742</width>
+    <height>570</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QComboBox" name="comboBox_Road">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>30</y>
+     <width>231</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_3">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>150</y>
+     <width>101</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Parking Space</string>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_Borrow">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>140</y>
+     <width>171</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>172</x>
+     <y>80</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>80</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>40</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Road</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_s">
+   <property name="geometry">
+    <rect>
+     <x>120</x>
+     <y>220</y>
+     <width>121</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_4">
+   <property name="geometry">
+    <rect>
+     <x>37</x>
+     <y>226</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>s</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_t">
+   <property name="geometry">
+    <rect>
+     <x>430</x>
+     <y>221</y>
+     <width>121</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_5">
+   <property name="geometry">
+    <rect>
+     <x>352</x>
+     <y>230</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>t</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_width">
+   <property name="geometry">
+    <rect>
+     <x>120</x>
+     <y>280</y>
+     <width>121</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_length">
+   <property name="geometry">
+    <rect>
+     <x>430</x>
+     <y>280</y>
+     <width>121</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_6">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>290</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Width</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_7">
+   <property name="geometry">
+    <rect>
+     <x>350</x>
+     <y>290</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Length</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_hdg">
+   <property name="geometry">
+    <rect>
+     <x>120</x>
+     <y>340</y>
+     <width>121</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_8">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>350</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Hdg</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_add">
+   <property name="geometry">
+    <rect>
+     <x>380</x>
+     <y>140</y>
+     <width>91</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Add</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_delete">
+   <property name="geometry">
+    <rect>
+     <x>500</x>
+     <y>140</y>
+     <width>81</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Delete</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_change">
+   <property name="geometry">
+    <rect>
+     <x>610</x>
+     <y>140</y>
+     <width>81</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Change</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

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

@@ -5308,6 +5308,20 @@ void MainWindow::UpdateScene()
             mvectorviewitem.push_back(pitem);
             mvectorviewitem.push_back(pitem);
         }
         }
     }
     }
+
+    for(i=0;i<nsize;i++)
+    {
+        std::vector<QGraphicsPathItem *> xvectorparkpath = xodrscenfunc::GetRoadParkingItem(&(xvectorrd[i]));
+        int j;
+        int ncount = xvectorparkpath.size();
+        for(j=0;j<ncount;j++)
+        {
+            QGraphicsPathItem * pitem = xvectorparkpath[j];
+            pitem->setPos(mfViewMoveX +VIEW_WIDTH/2,-mfViewMoveY+VIEW_HEIGHT/2);
+            mpscene->addItem(pitem);
+            mvectorviewitem.push_back(pitem);
+        }
+    }
     mbRefresh = false;
     mbRefresh = false;
 }
 }
 
 

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

@@ -35,6 +35,7 @@ SOURCES += \
     dialogeditroadmark.cpp \
     dialogeditroadmark.cpp \
     dialoglanefromrtk.cpp \
     dialoglanefromrtk.cpp \
     dialoglaneoffset.cpp \
     dialoglaneoffset.cpp \
+    dialogparkingspaceedit.cpp \
     dialogroadborrow.cpp \
     dialogroadborrow.cpp \
     dialogroadmerge.cpp \
     dialogroadmerge.cpp \
     dialogroadmirror.cpp \
     dialogroadmirror.cpp \
@@ -80,6 +81,7 @@ HEADERS += \
     dialogeditroadmark.h \
     dialogeditroadmark.h \
     dialoglanefromrtk.h \
     dialoglanefromrtk.h \
     dialoglaneoffset.h \
     dialoglaneoffset.h \
+    dialogparkingspaceedit.h \
     dialogroadborrow.h \
     dialogroadborrow.h \
     dialogroadmerge.h \
     dialogroadmerge.h \
     dialogroadmirror.h \
     dialogroadmirror.h \
@@ -120,6 +122,7 @@ FORMS += \
         dialogeditroadmark.ui \
         dialogeditroadmark.ui \
         dialoglanefromrtk.ui \
         dialoglanefromrtk.ui \
         dialoglaneoffset.ui \
         dialoglaneoffset.ui \
+        dialogparkingspaceedit.ui \
         dialogroadborrow.ui \
         dialogroadborrow.ui \
         dialogroadmerge.ui \
         dialogroadmerge.ui \
         dialogroadmirror.ui \
         dialogroadmirror.ui \

+ 52 - 0
src/tool/map_lanetoxodr/roaddigit.cpp

@@ -15,11 +15,17 @@ std::vector<iv::RoadDigitUnit> * RoadDigit::GetRDU()
     return &mvectorRDU;
     return &mvectorRDU;
 }
 }
 
 
+std::vector<iv::ParkingPoint> * RoadDigit::GetParkingPoint()
+{
+    return &mvectorParkingPoint;
+}
+
 void RoadDigit::UpdateSpace(double fspace)
 void RoadDigit::UpdateSpace(double fspace)
 {
 {
     if(mpRoad == 0)return;
     if(mpRoad == 0)return;
     CalcLine(fspace);
     CalcLine(fspace);
     CalcLane();
     CalcLane();
+    CalcParkingPoint();
 }
 }
 
 
 int RoadDigit::GetSectionIndex(Road *pRoad, double s)
 int RoadDigit::GetSectionIndex(Road *pRoad, double s)
@@ -368,4 +374,50 @@ void RoadDigit::CalcLane()
     }
     }
 }
 }
 
 
+void RoadDigit::CalcParkingPoint()
+{
+    unsigned int lObjectSize = mpRoad->GetObjectCount();
+    unsigned int i;
+    for(i=0;i<lObjectSize;i++)
+    {
+        Object * pObject = mpRoad->GetObject(i);
+        if(pObject->Gettype() == "parkingSpace")
+        {
+            double s = pObject->Gets();
+            double t = pObject->Gett();
+            double length,width,hdg;
+            if((pObject->Getwidth(width) == 1)&&(pObject->Getlength(length)==1)&&(pObject->Gethdg(hdg)== 1))
+            {
+                double roadx,roady,roadhdg;
+                mpRoad->GetGeometryCoords(s,roadx,roady,roadhdg);
+                double centerx,centery;
+                centerx = roadx + t*cos(roadhdg + M_PI/2.0);
+                centery = roady + t*sin(roadhdg + M_PI/2.0);
+                double hdgpark = hdg + roadhdg;
+                double x1,x2,x3,x4,y1,y2,y3,y4;
+                double xtem,ytem;
+                xtem = centerx + 0.5*width * cos(hdgpark);
+                ytem = centery + 0.5*width * sin(hdgpark);
+                x1 = xtem + 0.5*length * cos(hdgpark + M_PI/2.0);
+                y1 = ytem + 0.5*length * sin(hdgpark + M_PI/2.0);
+                x4 = xtem + 0.5*length * cos(hdgpark - M_PI/2.0);
+                y4 = ytem + 0.5*length * sin(hdgpark - M_PI/2.0);
+                xtem = centerx + 0.5*width * cos(hdgpark+M_PI);
+                ytem = centery + 0.5*width * sin(hdgpark+M_PI);
+                x2 = xtem + 0.5*length * cos(hdgpark + M_PI/2.0);
+                y2 = ytem + 0.5*length * sin(hdgpark + M_PI/2.0);
+                x3 = xtem + 0.5*length * cos(hdgpark - M_PI/2.0);
+                y3 = ytem + 0.5*length * sin(hdgpark - M_PI/2.0);
+                iv::ParkingXY xP;
+                iv::ParkingPoint xPP;
+                xP.mX = x1;xP.mY = y1;xPP.mParkingXY.push_back(xP);
+                xP.mX = x2;xP.mY = y2;xPP.mParkingXY.push_back(xP);
+                xP.mX = x3;xP.mY = y3;xPP.mParkingXY.push_back(xP);
+                xP.mX = x4;xP.mY = y4;xPP.mParkingXY.push_back(xP);
+                mvectorParkingPoint.push_back(xPP);
+            }
+        }
+    }
+}
+
 
 

+ 15 - 0
src/tool/map_lanetoxodr/roaddigit.h

@@ -33,6 +33,17 @@ struct RoadDigitUnit
     std::vector<iv::LanePoint> mvectorLanePoint;
     std::vector<iv::LanePoint> mvectorLanePoint;
 };
 };
 
 
+struct ParkingXY
+{
+    double mX;
+    double mY;
+};
+
+struct ParkingPoint
+{
+    vector<ParkingXY> mParkingXY;
+};
+
 }
 }
 
 
 class RoadDigit
 class RoadDigit
@@ -43,15 +54,19 @@ public:
 private:
 private:
     std::vector<iv::RoadDigitUnit> mvectorRDU;
     std::vector<iv::RoadDigitUnit> mvectorRDU;
     Road * mpRoad = 0;
     Road * mpRoad = 0;
+    std::vector<iv::ParkingPoint> mvectorParkingPoint;
 
 
 private:
 private:
     void CalcLine(double fspace);
     void CalcLine(double fspace);
     void CalcLane();
     void CalcLane();
+    void CalcParkingPoint();
 
 
 public:
 public:
     std::vector<iv::RoadDigitUnit> * GetRDU();
     std::vector<iv::RoadDigitUnit> * GetRDU();
     void UpdateSpace(double fspace);
     void UpdateSpace(double fspace);
 
 
+    std::vector<iv::ParkingPoint> * GetParkingPoint();
+
 private:
 private:
     int GetSectionIndex(Road * pRoad,double s);
     int GetSectionIndex(Road * pRoad,double s);
 };
 };

+ 26 - 0
src/tool/map_lanetoxodr/xodrscenfunc.cpp

@@ -5,6 +5,32 @@ xodrscenfunc::xodrscenfunc()
 
 
 }
 }
 
 
+std::vector<QGraphicsPathItem *> xodrscenfunc::GetRoadParkingItem(RoadDigit *prd)
+{
+    std::vector<QGraphicsPathItem *> xvectorgrapath;
+    std::vector<iv::ParkingPoint> * pvectorpark = prd->GetParkingPoint();
+    unsigned int lsize = pvectorpark->size();
+    unsigned int i;
+    for(i=0;i<lsize;i++)
+    {
+        std::vector<iv::ParkingXY> xvectorxy = pvectorpark->at(i).mParkingXY;
+        QPainterPath xpath;
+        xpath.moveTo(xvectorxy[0].mX,xvectorxy[0].mY*(-1));
+        xpath.lineTo(xvectorxy[1].mX,xvectorxy[1].mY*(-1));
+        xpath.lineTo(xvectorxy[2].mX,xvectorxy[2].mY*(-1));
+        xpath.lineTo(xvectorxy[3].mX,xvectorxy[3].mY*(-1));
+        xpath.closeSubpath();
+        QGraphicsPathItem * pitem = new QGraphicsPathItem;
+        pitem->setPath(xpath);
+        pitem->setBrush(Qt::darkGray);
+        pitem->setPen(QPen(Qt::darkGray,0.001));
+        xvectorgrapath.push_back(pitem);
+
+
+    }
+    return xvectorgrapath;
+}
+
 std::vector<QGraphicsPathItem *> xodrscenfunc::GetRoadLaneItem(RoadDigit *prd)
 std::vector<QGraphicsPathItem *> xodrscenfunc::GetRoadLaneItem(RoadDigit *prd)
 {
 {
     std::vector<QGraphicsPathItem *> xvectorgrapath;
     std::vector<QGraphicsPathItem *> xvectorgrapath;

+ 1 - 0
src/tool/map_lanetoxodr/xodrscenfunc.h

@@ -18,6 +18,7 @@ public:
 public:
 public:
     static std::vector<QGraphicsPathItem *> GetRoadLaneItem(RoadDigit * prd);
     static std::vector<QGraphicsPathItem *> GetRoadLaneItem(RoadDigit * prd);
     static std::vector<QGraphicsPathItem *> GetRoadMarkItem(RoadDigit * prd);
     static std::vector<QGraphicsPathItem *> GetRoadMarkItem(RoadDigit * prd);
+    static std::vector<QGraphicsPathItem *> GetRoadParkingItem(RoadDigit * prd);
 
 
 public:
 public:
     static bool IsDrawMark(double s);
     static bool IsDrawMark(double s);