Browse Source

change adcxodrview2.

yuchuli 2 years ago
parent
commit
4660cd216a

BIN
doc/工具/简易OpenDrive高精度地图制作说明.pptx


+ 1 - 0
src/tool/map_lanetoxodr/view/myview.cpp

@@ -80,6 +80,7 @@ void MyView::zoomIn()
 
 //    qDebug("beishu is %f",beishu);
 
+ //   qDebug(" center x: %f y: %f ",centerx,centery);
     centerOn(centerx,centery);
 
     emit beishuchange(beishu);

+ 43 - 6
src/tool/map_lanetoxodr/xvmainwindow2.cpp

@@ -68,6 +68,7 @@ void XVMainWindow::resizeEvent(QResizeEvent *event)
 
 void XVMainWindow::on_actionLoad_triggered()
 {
+    static QString strLastSelectDir = ".";
 
     if(mxodr.GetRoadCount() > 0)
     {
@@ -87,11 +88,15 @@ void XVMainWindow::on_actionLoad_triggered()
 
 
 #ifndef ANDROID
-    QString strpath = QFileDialog::getOpenFileName(this,"Load XODR",".","*.xodr");
+    QString strpath = QFileDialog::getOpenFileName(this,"Load XODR",strLastSelectDir,"*.xodr");
     if(strpath.isEmpty())return;
+    QFileInfo xFI;
+    xFI.setFile(strpath);
+    strLastSelectDir =  xFI.dir().path();
     LoadXODR(strpath);
-    OpenDrive * pxodr = &mxodr;
+ //   OpenDrive * pxodr = &mxodr;
     UpdateScene();
+    on_actionFit_triggered();
 #else
 //    QMessageBox::warning(this,"warning","no file dialog.",QMessageBox::YesAll);
 //    QString strpath = "/storage/emulated/0/map.xodr";
@@ -114,6 +119,9 @@ void XVMainWindow::LoadXODR(QString strpath)
 
     mvectorRoadSample.clear();
 
+    mfViewMoveX = VIEW_WIDTH/2.0;
+    mfViewMoveY = (-1.0)*VIEW_HEIGHT/2.0;
+
     int nroadnum = static_cast<int>(pxodr->GetRoadCount()) ;
     int i;
     double froadlen = 0;
@@ -122,6 +130,7 @@ void XVMainWindow::LoadXODR(QString strpath)
     fxmax = std::numeric_limits<double>::max()*(-1.0);
     fymin = std::numeric_limits<double>::max() *(1.0);
     fymax = std::numeric_limits<double>::max()*(-1.0);
+    bool bSetMaxMin = false;
     for(i=0;i<nroadnum;i++)
     {
         Road * pRoad = pxodr->GetRoad(i);
@@ -139,19 +148,38 @@ void XVMainWindow::LoadXODR(QString strpath)
             iv::RoadSample xSample(pRoad);
             mvectorRoadSample.push_back(xSample);
 
+
             if(pRoad->GetGeometryBlockCount()>0)
             {
                 double fx,fy;
-                fx = pRoad->GetGeometryBlock(0)->GetGeometryAt(0)->GetX();
-                fy = pRoad->GetGeometryBlock(0)->GetGeometryAt(0)->GetY();
+//                fx = pRoad->GetGeometryBlock(0)->GetGeometryAt(0)->GetX();
+//                fy = pRoad->GetGeometryBlock(0)->GetGeometryAt(0)->GetY();
+                fx = xSample.GetXMax();
+                fy = xSample.GetYMax();
+                if(fx>fxmax)fxmax = fx;
+                if(fx<fxmin)fxmin = fx;
+                if(fy>fymax)fymax = fy;
+                if(fy<fymin)fymin = fy;
+                fx = xSample.GetXMin();
+                fy = xSample.GetYMin();
                 if(fx>fxmax)fxmax = fx;
                 if(fx<fxmin)fxmin = fx;
                 if(fy>fymax)fymax = fy;
                 if(fy<fymin)fymin = fy;
+
+                bSetMaxMin = true;
             }
         }
     }
 
+    if(bSetMaxMin)
+    {
+        mfXMax = fxmax;
+        mfXMin = fxmin;
+        mfYMax = fymax;
+        mfYMin = fymin;
+    }
+
     double fmovex = 0;
     double fmovey = 0;
     if(((fxmax>1000)&&(fxmin>1000))||((fxmax<-1000)&&(fxmin<-1000)))
@@ -318,7 +346,7 @@ void XVMainWindow::onClickXY(double x, double y)
 
             if(bFind == false)
             {
-                snprintf(strout,1000,"x:%7.3f y:%7.3f |Road:%s s:%f t:%f nlane:%d %s",
+                snprintf(strout,1000,"x:%7.3f y:%7.3f |Road:%s s:%6.3f t:%6.3f nlane:%d %s",
                          rel_x,rel_y,mvectorRoadSample[i].GetRoadID().data(),s,t,nlane,strlanetype.data());
      //       mpLabel_Status->setText(strout);
                 bFind = true;
@@ -326,7 +354,7 @@ void XVMainWindow::onClickXY(double x, double y)
             else
             {
                 char strtem[1000];
-                snprintf(strtem,1000,"| %s %d",mvectorRoadSample[i].GetRoadID().data(),nlane);
+                snprintf(strtem,1000,"| %s %6.3f %d",mvectorRoadSample[i].GetRoadID().data(),s,nlane);
                 strncat(strout,strtem,1000);
             }
         }
@@ -456,3 +484,12 @@ void XVMainWindow::onbeishuchange(double fbeishu)
 {
     mfbeishu = fbeishu;
 }
+
+void XVMainWindow::on_actionFit_triggered()
+{
+    std::cout<<" x max: "<<mfXMax<<" min:"<<mfXMin<<"  y max: "<<mfYMax<<" min: "<<mfYMin<<std::endl;
+    double fxcentermove = (mfXMax + mfXMin)/2.0 +  mfViewMoveX;
+    double fycentermove = -(mfYMax + mfYMin)/2.0  - mfViewMoveY;
+    myview->centerOn(fxcentermove,fycentermove);
+    myview->zoomone();
+}

+ 7 - 0
src/tool/map_lanetoxodr/xvmainwindow2.h

@@ -58,6 +58,8 @@ private slots:
 
      void on_actionHelp_triggered();
 
+     void on_actionFit_triggered();
+
 private:
      void LoadXODR(QString strpath);
      void UpdateScene();
@@ -76,6 +78,11 @@ private:
     double mfViewMoveX = 0;
     double mfViewMoveY = 0;
 
+    double mfXMax = 100.0;
+    double mfXMin = -100.0;
+    double mfYMax = 100.0;
+    double mfYMin = -100.0;
+
     double mfselx = 0;
     double mfsely = 0;
 

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

@@ -31,6 +31,7 @@
     <addaction name="actionZoom_In"/>
     <addaction name="actionZoom_Out"/>
     <addaction name="actionZoom_One"/>
+    <addaction name="actionFit"/>
     <addaction name="actionSet_Move"/>
     <addaction name="actionReset_Move"/>
     <addaction name="actionHelp"/>
@@ -73,6 +74,11 @@
     <string>Help</string>
    </property>
   </action>
+  <action name="actionFit">
+   <property name="text">
+    <string>Fit</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>