|
@@ -4,10 +4,14 @@
|
|
|
#include <QLibrary>
|
|
|
#include <iostream>
|
|
|
#include <QMessageBox>
|
|
|
+#include <QFileDialog>
|
|
|
+
|
|
|
+#include "google/protobuf/io/zero_copy_stream_impl.h"
|
|
|
+#include "google/protobuf/text_format.h"
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
-std::string cda_lanetype_sel[9] = {"shoulder","border","driving","stop","none","parking","biking","sidewalk",
|
|
|
+static std::string cda_lanetype_sel[9] = {"shoulder","border","driving","stop","none","parking","biking","sidewalk",
|
|
|
"median"};
|
|
|
|
|
|
DialogAddRoadFromCDA::DialogAddRoadFromCDA(OpenDrive * pxodr, QWidget *parent) :
|
|
@@ -17,6 +21,20 @@ DialogAddRoadFromCDA::DialogAddRoadFromCDA(OpenDrive * pxodr, QWidget *parent) :
|
|
|
ui->setupUi(this);
|
|
|
mpxodr = pxodr;
|
|
|
|
|
|
+ iv::map::cdageo * pgeo = mcdadraw.add_mgeos();
|
|
|
+ pgeo->set_geotype(0);
|
|
|
+ pgeo->set_georadius(100.0);
|
|
|
+ pgeo->set_geolen(100.0);
|
|
|
+
|
|
|
+ iv::map::cdalane * plane = mcdadraw.add_mlanes();
|
|
|
+ plane->set_lanemarkcolor(0);
|
|
|
+ plane->set_lanemarktype(0);
|
|
|
+ plane->set_lanewidth(3.6);
|
|
|
+ plane->set_lanetype(2);
|
|
|
+
|
|
|
+ mcdadraw.set_mroadtype(0);
|
|
|
+ mcdadraw.set_mroadele(0);
|
|
|
+
|
|
|
ui->comboBox_RoadClass->addItem(tr("高速公路"));
|
|
|
ui->comboBox_RoadClass->addItem(tr("城市"));
|
|
|
ui->comboBox_RoadClass->addItem(tr("乡村"));
|
|
@@ -63,7 +81,7 @@ DialogAddRoadFromCDA::~DialogAddRoadFromCDA()
|
|
|
|
|
|
void DialogAddRoadFromCDA::on_pushButton_Create_clicked()
|
|
|
{
|
|
|
- OpenDrive * pxodr = mpxodr;
|
|
|
+// OpenDrive * pxodr = mpxodr;
|
|
|
// std::string strtype = ui->comboBox_Type->currentText().toStdString();
|
|
|
// std::string strradius = ui->lineEdit_radius->text().toStdString();
|
|
|
// std::string strlen = ui->lineEdit_len->text().toStdString();
|
|
@@ -113,18 +131,18 @@ void DialogAddRoadFromCDA::on_pushButton_Create_clicked()
|
|
|
|
|
|
void DialogAddRoadFromCDA::UpdateView()
|
|
|
{
|
|
|
- iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
- ui->comboBox_RoadClass->setCurrentIndex(pcdaroad->mnclass);
|
|
|
- int nlanecount = static_cast<int>(pcdaroad->mvectorlane.size());
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
+ ui->comboBox_RoadClass->setCurrentIndex(pcdadraw->mroadtype());
|
|
|
+ int nlanecount = static_cast<int>(pcdadraw->mlanes_size());
|
|
|
ui->lineEdit_roadlanecount->setText(QString::number(nlanecount));
|
|
|
double fRoadLen = 0;
|
|
|
int i;
|
|
|
- int ngeosize = static_cast<int>(pcdaroad->mvectorgeo.size());
|
|
|
+ int ngeosize = static_cast<int>(pcdadraw->mgeos_size());
|
|
|
ui->comboBox_geo->clear();
|
|
|
for(i=0;i<ngeosize;i++)
|
|
|
{
|
|
|
ui->comboBox_geo->addItem(QString(tr("路段"))+QString::number(i+1));
|
|
|
- fRoadLen = fRoadLen + pcdaroad->mvectorgeo[i].mflen;
|
|
|
+ fRoadLen = fRoadLen + pcdadraw->mgeos(i).geolen();
|
|
|
}
|
|
|
ui->comboBox_Lane->clear();
|
|
|
for(i=0;i<nlanecount;i++)
|
|
@@ -136,68 +154,84 @@ void DialogAddRoadFromCDA::UpdateView()
|
|
|
|
|
|
void DialogAddRoadFromCDA::on_comboBox_Lane_currentIndexChanged(int index)
|
|
|
{
|
|
|
- iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
+// iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
if(index<0)return;
|
|
|
- if(index>=pcdaroad->mvectorlane.size())
|
|
|
+ if(index>=pcdadraw->mlanes_size())
|
|
|
{
|
|
|
std::cout<<" index big than lane size."<<std::endl;
|
|
|
return;
|
|
|
}
|
|
|
- iv::cdalane * plane = &pcdaroad->mvectorlane[index];
|
|
|
- ui->comboBox_lanecolor->setCurrentIndex(plane->mnlanemarkcolor);
|
|
|
- ui->comboBox_lanemarktype->setCurrentIndex(plane->mnlanemarktype);
|
|
|
- ui->lineEdit_lanewidth->setText(QString::number(plane->mflanewidth,'f',2));
|
|
|
- ui->comboBox_lanetype->setCurrentIndex(plane->mnlanetype);
|
|
|
+ iv::map::cdalane * plane = mcdadraw.mutable_mlanes(index);
|
|
|
+ ui->comboBox_lanecolor->setCurrentIndex(plane->lanemarkcolor());
|
|
|
+ ui->comboBox_lanemarktype->setCurrentIndex(plane->lanemarktype());
|
|
|
+ ui->lineEdit_lanewidth->setText(QString::number(plane->lanewidth(),'f',2));
|
|
|
+ ui->comboBox_lanetype->setCurrentIndex(plane->lanetype());
|
|
|
}
|
|
|
|
|
|
void DialogAddRoadFromCDA::on_comboBox_geo_currentIndexChanged(int index)
|
|
|
{
|
|
|
- iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
if(index<0)return;
|
|
|
- if(index>=pcdaroad->mvectorgeo.size())
|
|
|
+ if(index>=pcdadraw->mgeos_size())
|
|
|
{
|
|
|
std::cout<<" index big than geo size."<<std::endl;
|
|
|
return;
|
|
|
}
|
|
|
- iv::cdageo * pgeo = &pcdaroad->mvectorgeo[index];
|
|
|
- ui->comboBox_geoType->setCurrentIndex(pgeo->mngeotype);
|
|
|
- ui->lineEdit_georadius->setText(QString::number(pgeo->mfradius));
|
|
|
- ui->lineEdit_geolen->setText(QString::number(pgeo->mflen));
|
|
|
+ iv::map::cdageo * pgeo = pcdadraw->mutable_mgeos(index);
|
|
|
+ ui->comboBox_geoType->setCurrentIndex(pgeo->geotype());
|
|
|
+ ui->lineEdit_georadius->setText(QString::number(pgeo->georadius()));
|
|
|
+ ui->lineEdit_geolen->setText(QString::number(pgeo->geolen()));
|
|
|
}
|
|
|
|
|
|
void DialogAddRoadFromCDA::on_pushButton_laneadd_clicked()
|
|
|
{
|
|
|
- iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
- iv::cdalane xlane;
|
|
|
- xlane.mflanewidth = ui->lineEdit_lanewidth->text().toDouble();
|
|
|
- if(xlane.mflanewidth<=0)
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
+ double flanewidth = ui->lineEdit_lanewidth->text().toDouble();
|
|
|
+ if(flanewidth<=0)
|
|
|
{
|
|
|
QMessageBox::warning(this,tr("Warning"),tr("Lane Width Error."),QMessageBox::YesAll);
|
|
|
return;
|
|
|
}
|
|
|
- xlane.mnlanemarkcolor = ui->comboBox_lanecolor->currentIndex();
|
|
|
- xlane.mnlanemarktype = ui->comboBox_lanemarktype->currentIndex();
|
|
|
- xlane.mnlanetype = ui->comboBox_lanetype->currentIndex();
|
|
|
- int nlanecount = static_cast<int>(pcdaroad->mvectorlane.size()) ;
|
|
|
- pcdaroad->mvectorlane.push_back(xlane);
|
|
|
- ui->comboBox_Lane->addItem(QString(tr("车道"))+QString::number(nlanecount+1));
|
|
|
- ui->comboBox_Lane->setCurrentIndex(nlanecount);
|
|
|
- ui->lineEdit_roadlanecount->setText(QString::number(nlanecount+1));
|
|
|
+ iv::map::cdalane * plane = pcdadraw->add_mlanes();
|
|
|
+ plane->set_lanemarkcolor(ui->comboBox_lanecolor->currentIndex());
|
|
|
+ plane->set_lanemarktype(ui->comboBox_lanemarktype->currentIndex());
|
|
|
+ plane->set_lanewidth(flanewidth);
|
|
|
+ plane->set_lanetype(ui->comboBox_lanetype->currentIndex());
|
|
|
+
|
|
|
+ int nlanecount = static_cast<int>(pcdadraw->mlanes_size()) ;
|
|
|
+ ui->comboBox_Lane->addItem(QString(tr("车道"))+QString::number(nlanecount));
|
|
|
+ ui->comboBox_Lane->setCurrentIndex(nlanecount-1);
|
|
|
+ ui->lineEdit_roadlanecount->setText(QString::number(nlanecount));
|
|
|
}
|
|
|
|
|
|
void DialogAddRoadFromCDA::on_pushButton_lanedel_clicked()
|
|
|
{
|
|
|
- iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
- if(pcdaroad->mvectorlane.size() == 0)
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
+ if(pcdadraw->mlanes_size() == 0)
|
|
|
{
|
|
|
QMessageBox::warning(this,tr("Warning"),tr("No Lane."),QMessageBox::YesAll);
|
|
|
return;
|
|
|
}
|
|
|
int index = ui->comboBox_Lane->currentIndex();
|
|
|
- pcdaroad->mvectorlane.erase(pcdaroad->mvectorlane.begin() + index);
|
|
|
|
|
|
- int nlanecount = static_cast<int>(pcdaroad->mvectorlane.size());
|
|
|
int i;
|
|
|
+ iv::map::cdadraw xtemp;
|
|
|
+ for(i=0;i<pcdadraw->mlanes_size();i++)
|
|
|
+ {
|
|
|
+ if(i == index)continue;
|
|
|
+ iv::map::cdalane * plane = xtemp.add_mlanes();
|
|
|
+ plane->CopyFrom(pcdadraw->mlanes(i));
|
|
|
+ }
|
|
|
+ pcdadraw->clear_mlanes();
|
|
|
+ for(i=0;i<xtemp.mlanes_size();i++)
|
|
|
+ {
|
|
|
+ iv::map::cdalane * plane = pcdadraw->add_mlanes();
|
|
|
+ plane->CopyFrom(xtemp.mlanes(i));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int nlanecount = static_cast<int>(pcdadraw->mlanes_size());
|
|
|
ui->comboBox_Lane->clear();
|
|
|
for(i=0;i<nlanecount;i++)
|
|
|
{
|
|
@@ -217,8 +251,8 @@ void DialogAddRoadFromCDA::on_pushButton_lanedel_clicked()
|
|
|
|
|
|
void DialogAddRoadFromCDA::on_pushButton_lanechange_clicked()
|
|
|
{
|
|
|
- iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
- if(pcdaroad->mvectorlane.size() == 0)
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
+ if(pcdadraw->mlanes_size() == 0)
|
|
|
{
|
|
|
QMessageBox::warning(this,tr("Warning"),tr("No Lane."),QMessageBox::YesAll);
|
|
|
return;
|
|
@@ -231,48 +265,51 @@ void DialogAddRoadFromCDA::on_pushButton_lanechange_clicked()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- iv::cdalane * plane = &pcdaroad->mvectorlane[index];
|
|
|
- plane->mflanewidth = flanewidth;
|
|
|
- plane->mnlanemarkcolor = ui->comboBox_lanecolor->currentIndex();
|
|
|
- plane->mnlanemarktype = ui->comboBox_lanemarktype->currentIndex();
|
|
|
- plane->mnlanetype = ui->comboBox_lanetype->currentIndex();
|
|
|
+ iv::map::cdalane * plane = pcdadraw->mutable_mlanes(index);
|
|
|
+ plane->set_lanemarkcolor(ui->comboBox_lanecolor->currentIndex());
|
|
|
+ plane->set_lanemarktype(ui->comboBox_lanemarktype->currentIndex());
|
|
|
+ plane->set_lanewidth(flanewidth);
|
|
|
+ plane->set_lanetype(ui->comboBox_lanetype->currentIndex());
|
|
|
ui->comboBox_Lane->setCurrentIndex(index);
|
|
|
QMessageBox::information(this,tr("Info"),tr("Change Lane Successfully."),QMessageBox::YesAll);
|
|
|
}
|
|
|
|
|
|
void DialogAddRoadFromCDA::on_pushButton_geoadd_clicked()
|
|
|
{
|
|
|
- iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
- iv::cdageo xgeo;
|
|
|
- xgeo.mflen = ui->lineEdit_geolen->text().toDouble();
|
|
|
- if(xgeo.mflen <=0)
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
+ double flen = ui->lineEdit_geolen->text().toDouble();
|
|
|
+ if(flen <=0)
|
|
|
{
|
|
|
QMessageBox::warning(this,tr("Warning"),tr("Geo Length Error."),QMessageBox::YesAll);
|
|
|
return;
|
|
|
}
|
|
|
- xgeo.mfradius = ui->lineEdit_georadius->text().toDouble();
|
|
|
- xgeo.mngeotype = ui->comboBox_geoType->currentIndex();
|
|
|
- if((xgeo.mngeotype == 1) &&(fabs(xgeo.mfradius)<1))
|
|
|
+
|
|
|
+ double fradius = ui->lineEdit_georadius->text().toDouble();
|
|
|
+ int ngeotype = ui->comboBox_geoType->currentIndex();
|
|
|
+ if((ngeotype == 1) &&(fabs(fradius)<1))
|
|
|
{
|
|
|
QMessageBox::warning(this,tr("Warning"),tr("Radius Error."),QMessageBox::YesAll);
|
|
|
return;
|
|
|
}
|
|
|
- if(xgeo.mflen <= 0)
|
|
|
+ if(flen <= 0)
|
|
|
{
|
|
|
QMessageBox::warning(this,tr("Warning"),tr("geo Length Error."),QMessageBox::YesAll);
|
|
|
return;
|
|
|
}
|
|
|
- int ngeocount = static_cast<int>(pcdaroad->mvectorgeo.size()) ;
|
|
|
- pcdaroad->mvectorgeo.push_back(xgeo);
|
|
|
- ui->comboBox_geo->addItem(QString(tr("路段"))+QString::number(ngeocount+1));
|
|
|
- ui->comboBox_geo->setCurrentIndex(ngeocount);
|
|
|
-
|
|
|
- int ngeosize = static_cast<int>(pcdaroad->mvectorgeo.size());
|
|
|
+ iv::map::cdageo * pgeo = pcdadraw->add_mgeos();
|
|
|
+ pgeo->set_geolen(flen);
|
|
|
+ pgeo->set_georadius(fradius);
|
|
|
+ pgeo->set_geotype(ngeotype);
|
|
|
+ int ngeocount = static_cast<int>(pcdadraw->mgeos_size()) ;
|
|
|
+ ui->comboBox_geo->addItem(QString(tr("路段"))+QString::number(ngeocount));
|
|
|
+ ui->comboBox_geo->setCurrentIndex(ngeocount-1);
|
|
|
+
|
|
|
+ int ngeosize = static_cast<int>(pcdadraw->mgeos_size());
|
|
|
int i;
|
|
|
double fRoadLen = 0;
|
|
|
for(i=0;i<ngeosize;i++)
|
|
|
{
|
|
|
- fRoadLen = fRoadLen + pcdaroad->mvectorgeo[i].mflen;
|
|
|
+ fRoadLen = fRoadLen + pcdadraw->mutable_mgeos(i)->geolen();
|
|
|
}
|
|
|
ui->lineEdit_roadlen->setText(QString::number(fRoadLen));
|
|
|
|
|
@@ -280,17 +317,32 @@ void DialogAddRoadFromCDA::on_pushButton_geoadd_clicked()
|
|
|
|
|
|
void DialogAddRoadFromCDA::on_pushButton_geodel_clicked()
|
|
|
{
|
|
|
- iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
- if(pcdaroad->mvectorgeo.size() == 0)
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
+ if(pcdadraw->mgeos_size() == 0)
|
|
|
{
|
|
|
QMessageBox::warning(this,tr("Warning"),tr("No Geo."),QMessageBox::YesAll);
|
|
|
return;
|
|
|
}
|
|
|
int index = ui->comboBox_geo->currentIndex();
|
|
|
- pcdaroad->mvectorgeo.erase(pcdaroad->mvectorgeo.begin() + index);
|
|
|
|
|
|
- int nGeocount = static_cast<int>(pcdaroad->mvectorgeo.size());
|
|
|
+
|
|
|
int i;
|
|
|
+ iv::map::cdadraw xtemp;
|
|
|
+ for(i=0;i<pcdadraw->mgeos_size();i++)
|
|
|
+ {
|
|
|
+ if(i == index)continue;
|
|
|
+ iv::map::cdageo * pgeo = xtemp.add_mgeos();
|
|
|
+ pgeo->CopyFrom(pcdadraw->mgeos(i));
|
|
|
+ }
|
|
|
+ pcdadraw->clear_mgeos();
|
|
|
+ for(i=0;i<xtemp.mgeos_size();i++)
|
|
|
+ {
|
|
|
+ iv::map::cdageo * pgeo = pcdadraw->add_mgeos();
|
|
|
+ pgeo->CopyFrom(xtemp.mgeos(i));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int nGeocount = static_cast<int>(pcdadraw->mgeos_size());
|
|
|
ui->comboBox_geo->clear();
|
|
|
for(i=0;i<nGeocount;i++)
|
|
|
{
|
|
@@ -303,22 +355,22 @@ void DialogAddRoadFromCDA::on_pushButton_geodel_clicked()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ui->comboBox_Lane->setCurrentIndex((nGeocount-1));
|
|
|
+ ui->comboBox_geo->setCurrentIndex((nGeocount-1));
|
|
|
}
|
|
|
|
|
|
- int ngeosize = static_cast<int>(pcdaroad->mvectorgeo.size());
|
|
|
+ int ngeosize = static_cast<int>(pcdadraw->mgeos_size());
|
|
|
double fRoadLen = 0;
|
|
|
for(i=0;i<ngeosize;i++)
|
|
|
{
|
|
|
- fRoadLen = fRoadLen + pcdaroad->mvectorgeo[i].mflen;
|
|
|
+ fRoadLen = fRoadLen + pcdadraw->mutable_mgeos(i)->geolen();
|
|
|
}
|
|
|
ui->lineEdit_roadlen->setText(QString::number(fRoadLen));
|
|
|
}
|
|
|
|
|
|
void DialogAddRoadFromCDA::on_pushButton_geochange_clicked()
|
|
|
{
|
|
|
- iv::cdaroad * pcdaroad = &mcdaroad;
|
|
|
- if(pcdaroad->mvectorgeo.size() == 0)
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
+ if(pcdadraw->mgeos_size() == 0)
|
|
|
{
|
|
|
QMessageBox::warning(this,tr("Warning"),tr("No Geo."),QMessageBox::YesAll);
|
|
|
return;
|
|
@@ -338,20 +390,107 @@ void DialogAddRoadFromCDA::on_pushButton_geochange_clicked()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- iv::cdageo * pgeo = &pcdaroad->mvectorgeo[index];
|
|
|
- pgeo->mflen = flen;
|
|
|
- pgeo->mfradius = fRadius;
|
|
|
- pgeo->mngeotype = ui->comboBox_geoType->currentIndex();
|
|
|
+ iv::map::cdageo * pgeo = pcdadraw->mutable_mgeos(index);
|
|
|
+ pgeo->set_geolen(flen);
|
|
|
+ pgeo->set_georadius(fRadius);
|
|
|
+ pgeo->set_geotype(ui->comboBox_geoType->currentIndex());
|
|
|
ui->comboBox_geo->setCurrentIndex(index);
|
|
|
|
|
|
- int ngeosize = static_cast<int>(pcdaroad->mvectorgeo.size());
|
|
|
+ int ngeosize = static_cast<int>(pcdadraw->mgeos_size());
|
|
|
double fRoadLen = 0;
|
|
|
int i;
|
|
|
for(i=0;i<ngeosize;i++)
|
|
|
{
|
|
|
- fRoadLen = fRoadLen + pcdaroad->mvectorgeo[i].mflen;
|
|
|
+ fRoadLen = fRoadLen + pcdadraw->mutable_mgeos(i)->geolen();
|
|
|
}
|
|
|
ui->lineEdit_roadlen->setText(QString::number(fRoadLen));
|
|
|
|
|
|
QMessageBox::information(this,tr("Info"),tr("Change Lane Successfully."),QMessageBox::YesAll);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void DialogAddRoadFromCDA::on_pushButton_Save_clicked()
|
|
|
+{
|
|
|
+ iv::map::cdadraw * pcdadraw = &mcdadraw;
|
|
|
+ if(pcdadraw->mlanes_size() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,tr("Warning"),tr("No Lanes."),QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(pcdadraw->mgeos_size() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,tr("Waring"),tr("No Geos."),QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QString str = QFileDialog::getSaveFileName(this,tr("Save Data"),".","*.cda");
|
|
|
+ if(str.isEmpty())return;
|
|
|
+ QString strfilepath = str;
|
|
|
+
|
|
|
+ if(strfilepath.right(4) != ".cda")
|
|
|
+ {
|
|
|
+ strfilepath = strfilepath + ".cda";
|
|
|
+ }
|
|
|
+
|
|
|
+ using google::protobuf::TextFormat;
|
|
|
+ using google::protobuf::io::FileOutputStream;
|
|
|
+ using google::protobuf::io::ZeroCopyOutputStream;
|
|
|
+ std::string strout;
|
|
|
+ ZeroCopyOutputStream *output = new google::protobuf::io::StringOutputStream(&strout);//new FileOutputStream(file_descriptor);
|
|
|
+
|
|
|
+ bool success = TextFormat::Print(mcdadraw, output);
|
|
|
+ if(success)
|
|
|
+ {
|
|
|
+ QFile xFile;
|
|
|
+ xFile.setFileName(strfilepath);
|
|
|
+ if(xFile.open(QIODevice::ReadWrite))
|
|
|
+ {
|
|
|
+ xFile.write(strout.data(), static_cast<qint64>(strout.size()));
|
|
|
+ xFile.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delete output;
|
|
|
+}
|
|
|
+
|
|
|
+void DialogAddRoadFromCDA::on_pushButton_Load_clicked()
|
|
|
+{
|
|
|
+ QString str = QFileDialog::getOpenFileName(this,tr("Load Data"),".","*.cda");
|
|
|
+ if(str.isEmpty())return;
|
|
|
+ QString strfilepath = str;
|
|
|
+
|
|
|
+ QFile xFile;
|
|
|
+ xFile.setFileName(strfilepath);
|
|
|
+ QByteArray ba;
|
|
|
+ if(xFile.open(QIODevice::ReadOnly))
|
|
|
+ {
|
|
|
+ ba = xFile.readAll();
|
|
|
+ xFile.close();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,tr("Warning"),tr("Open File Fail."),QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ using google::protobuf::TextFormat;
|
|
|
+ using google::protobuf::io::FileInputStream;
|
|
|
+ using google::protobuf::io::ZeroCopyInputStream;
|
|
|
+ std::string strout;
|
|
|
+ ZeroCopyInputStream *input = new google::protobuf::io::ArrayInputStream(ba.data(),ba.size());//new FileOutputStream(file_descriptor);
|
|
|
+
|
|
|
+ iv::map::cdadraw xcdadraw;
|
|
|
+ bool success = TextFormat::Parse(input,&xcdadraw);
|
|
|
+ if(success)
|
|
|
+ {
|
|
|
+ mcdadraw.CopyFrom(xcdadraw);
|
|
|
+ UpdateView();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,tr("Warning"),tr("Load map fail."),QMessageBox::YesAll);
|
|
|
+ delete input;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ delete input;
|
|
|
+}
|