Browse Source

change tool/map_lanetoxodr. for change editdialog use GraphcScene.

yuchuli 4 years ago
parent
commit
2698362010

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

@@ -33,6 +33,7 @@ SOURCES += \
         main.cpp \
         mainwindow.cpp \
     roadeditdialog.cpp \
+    roadviewitem.cpp \
     speeddialog.cpp \
     trafficlightdialog.cpp \
     trafficlightlanevaliditydialog.cpp \
@@ -62,6 +63,7 @@ SOURCES += \
     ../../include/msgtype/imu.pb.cc \
     geofit.cpp \
     circlefitting.cpp \
+    xodrfunc.cpp \
     xodrmake.cpp
 
 HEADERS += \
@@ -70,6 +72,7 @@ HEADERS += \
         mainwindow.h \
     rawtype.h \
     roadeditdialog.h \
+    roadviewitem.h \
     speeddialog.h \
     trafficlightdialog.h \
     trafficlightlanevaliditydialog.h \
@@ -96,6 +99,7 @@ HEADERS += \
     ../../include/msgtype/imu.pb.h \
     geofit.h \
     circlefitting.h \
+    xodrfunc.h \
     xodrmake.h
 
 FORMS += \

+ 56 - 3
src/tool/map_lanetoxodr/roadeditdialog.cpp

@@ -26,7 +26,11 @@ RoadEditDialog::RoadEditDialog(OpenDrive * pxodr,QWidget *parent) :
 
     painter->end();
 
-    scene = new QGraphicsScene;
+//    scene = new QGraphicsScene;
+
+    scene = new QGraphicsScene(-VIEW_WIDTH/2, -VIEW_HEIGHT/2, VIEW_WIDTH, VIEW_HEIGHT);
+    myview->setScene(scene);
+    scene->setBackgroundBrush(Qt::darkGreen);
 
     ui->comboBox_geotype->addItem("Line");
     ui->comboBox_geotype->addItem("Spiral");
@@ -284,6 +288,9 @@ void RoadEditDialog::ExecPainter()
 
 void RoadEditDialog::paintEvent(QPaintEvent * painter)
 {
+
+    scene->update();
+    return;
     if(mpCurRoad != 0)
     {
         ExecPainter();
@@ -310,13 +317,58 @@ void RoadEditDialog::on_comboBox_Road_currentIndexChanged(int index)
 
     mpCurRoad = pRoad;
 
+    int i;
+    int nsize = mvectorroadview.size();
+    for(i=0;i<nsize;i++)
+    {
+        scene->removeItem(mvectorroadview.at(i));
+        delete mvectorroadview.at(i);
+    }
+    mvectorroadview.clear();
+
+
+    double froad_xmin,froad_ymin,froad_xmax,froad_ymax;
+    ServiceXODRTool.GetRoadMaxMin(pRoad,froad_xmin,froad_ymin,froad_xmax,froad_ymax);
+    roadviewitem * prvw = new roadviewitem(pRoad);
+
+    int nfac;
+    int nkeep = 30;
+    double fac_x,fac_y;
+    fac_x = 100000;
+    fac_y = 100000;
+    if(froad_xmax > froad_xmin)
+    {
+        fac_x = (VIEW_WIDTH-nkeep*2)/(froad_xmax - froad_xmin);
+    }
+
+    if(froad_ymax > froad_ymin)
+    {
+        fac_y = (VIEW_HEIGHT - nkeep*2)/(froad_ymax - froad_ymin);
+    }
+
+    nfac = fac_x;
+    if(fac_y < nfac)nfac = fac_y;
+
+
+    mfViewMoveX = VIEW_WIDTH/2.0 ;
+    mfViewMoveY = VIEW_HEIGHT/2.0;
+
+    mfViewMoveX = 0 - froad_xmin - (froad_xmax - froad_xmin)/2.0;
+    mfViewMoveY = 0 + froad_ymin  + (froad_ymax-froad_ymin)/2.0;
+
+    prvw->setPos(mfViewMoveX,mfViewMoveY);
+ //       prvw->setPos((froad_xmax - froad_xmin)/2.0, (froad_ymax-froad_ymin)/2.0);
+    mvectorroadview.push_back(prvw);
+    prvw->setratio(1.0);
+    scene->addItem(prvw);
+
     mnSelGeo = -1;
 
     ui->lineEdit_roadlen->setText(QString::number(pRoad->GetRoadLength()));
 
     ui->comboBox_Geo->clear();
-    int nsize = pRoad->GetGeometryBlockCount();
-    int i;
+    nsize = pRoad->GetGeometryBlockCount();
+//    int i;
     for(i=0;i<nsize;i++)
     {
         ui->comboBox_Geo->addItem(QString("Geo ")+QString::number(i));
@@ -330,6 +382,7 @@ void RoadEditDialog::on_comboBox_Geo_currentIndexChanged(int index)
     if(mpCurRoad == 0 )return;
     if(index<0)return;
     mnSelGeo = index;
+
     if(index>= mpCurRoad->GetGeometryBlockCount())return;
     GeometryBlock * pgb = mpCurRoad->GetGeometryBlock(index);
     RoadGeometry * pg = pgb->GetGeometryAt(0);

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

@@ -8,6 +8,8 @@
 
 #include "ivxodrtool.h"
 
+#include "roadviewitem.h"
+
 namespace Ui {
 class RoadEditDialog;
 }
@@ -45,6 +47,11 @@ private:
     Road * mpCurRoad = 0;
 
     int mnSelGeo = -1;
+
+    std::vector<roadviewitem *> mvectorroadview;
+
+    double mfViewMoveX = 0;
+    double mfViewMoveY = 0;
 };
 
 #endif // ROADEDITDIALOG_H

+ 2 - 0
src/tool/map_lanetoxodr_graphscene/roadviewitem.cpp

@@ -16,6 +16,8 @@ roadviewitem::roadviewitem(Road * pRoad)
 
 QRectF roadviewitem::boundingRect() const
 {
+    return QRectF(mfxmin - 1000,mfymin-1000,mfxmax - mfxmin + 2000,
+                  mfymax - mfymin+2000);
     float fwidth = mfwidth * mfratio;
     return QRectF(mfxmin - fwidth - 15,mfymin-fwidth-15,mfxmax - mfxmin + 2.0*fwidth+30,mfymax - mfymin+2.0*fwidth+30);
 //    return QRectF(-10000,-10000,20000,20000);