|
@@ -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();
|
|
|
+}
|