|
@@ -1,8 +1,16 @@
|
|
#include "mainwindow.h"
|
|
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
|
|
+#include <QInputDialog>
|
|
|
|
+#include <QMessageBox>
|
|
|
|
+#include <QFileDialog>
|
|
|
|
+
|
|
|
|
+#include <iostream>
|
|
|
|
+
|
|
#include "gnss_coordinate_convert.h"
|
|
#include "gnss_coordinate_convert.h"
|
|
|
|
|
|
|
|
+#include "commif.h"
|
|
|
|
+
|
|
MainWindow * gw;
|
|
MainWindow * gw;
|
|
|
|
|
|
#define VIEW_WIDTH 6000
|
|
#define VIEW_WIDTH 6000
|
|
@@ -18,7 +26,7 @@ void UpdateGPS(const char * strdata,const unsigned int nSize)
|
|
|
|
|
|
if(!xgpsimu_ptr->ParseFromArray(strdata,nSize))
|
|
if(!xgpsimu_ptr->ParseFromArray(strdata,nSize))
|
|
{
|
|
{
|
|
- qDebug("MainWindow::UpdateGPS Parse Error. nSize is ",nSize);
|
|
|
|
|
|
+ qDebug("MainWindow::UpdateGPS Parse Error. nSize is %d",nSize);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -31,12 +39,14 @@ MainWindow::MainWindow(QWidget *parent)
|
|
: QMainWindow(parent)
|
|
: QMainWindow(parent)
|
|
, ui(new Ui::MainWindow)
|
|
, ui(new Ui::MainWindow)
|
|
{
|
|
{
|
|
|
|
+ gw = this;
|
|
ui->setupUi(this);
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
ui->horizontalSlider_width->setRange(0,1000);
|
|
ui->horizontalSlider_width->setRange(0,1000);
|
|
ui->horizontalSlider_width->setValue(360);
|
|
ui->horizontalSlider_width->setValue(360);
|
|
ui->lineEdit->setText("3.6");
|
|
ui->lineEdit->setText("3.6");
|
|
|
|
+ ui->pushButton_Complete->setEnabled(false);
|
|
|
|
|
|
int i;
|
|
int i;
|
|
for(i=0;i<7;i++)
|
|
for(i=0;i<7;i++)
|
|
@@ -58,6 +68,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|
ui->lineEdit_DisLeft->setText("1.8");
|
|
ui->lineEdit_DisLeft->setText("1.8");
|
|
ui->lineEdit_DisRight->setText("1.8");
|
|
ui->lineEdit_DisRight->setText("1.8");
|
|
ui->lineEdit_DisRight->setEnabled(false);
|
|
ui->lineEdit_DisRight->setEnabled(false);
|
|
|
|
+ ui->lineEdit_RoadName->setEnabled(false);
|
|
|
|
|
|
ui->radioButton_Auto->setChecked(true);
|
|
ui->radioButton_Auto->setChecked(true);
|
|
ui->pushButton_ManualCollect->setEnabled(false);
|
|
ui->pushButton_ManualCollect->setEnabled(false);
|
|
@@ -82,19 +93,27 @@ MainWindow::MainWindow(QWidget *parent)
|
|
mpscene->addItem(ptext);
|
|
mpscene->addItem(ptext);
|
|
ptext->setPos(1000,1000);
|
|
ptext->setPos(1000,1000);
|
|
|
|
|
|
- LineItem * ptest = new LineItem(QPointF(100,100),QPointF(2000,100),1.0);
|
|
|
|
- mpscene->addItem(ptest);
|
|
|
|
- ptest->setPos(3000,3000);
|
|
|
|
- gt = ptest;
|
|
|
|
|
|
+ RegisterRecvGPS((char *)"hcp2_gpsimu",UpdateGPS);
|
|
|
|
+
|
|
|
|
+// LineItem * ptest = new LineItem(QPointF(100,100),QPointF(2000,100),1.0);
|
|
|
|
+// mpscene->addItem(ptest);
|
|
|
|
+// ptest->setPos(3000,3000);
|
|
|
|
+// gt = ptest;
|
|
|
|
+
|
|
|
|
+// QGraphicsEllipseItem * pe = new QGraphicsEllipseItem(-10.0,-10.0,20.0,20.0);
|
|
|
|
+// pe->setPos(3000,3000);
|
|
|
|
+// QBrush xBrush;
|
|
|
|
+// xBrush.setColor(Qt::blue);
|
|
|
|
+// pe->setBrush(Qt::green);
|
|
|
|
+// pe->setPen(Qt::NoPen);
|
|
|
|
+// mpscene->addItem(pe);
|
|
|
|
+// gpe = pe;
|
|
|
|
|
|
- QGraphicsEllipseItem * pe = new QGraphicsEllipseItem(-10.0,-10.0,20.0,20.0);
|
|
|
|
- pe->setPos(3000,3000);
|
|
|
|
- QBrush xBrush;
|
|
|
|
- xBrush.setColor(Qt::blue);
|
|
|
|
- pe->setBrush(Qt::green);
|
|
|
|
- pe->setPen(Qt::NoPen);
|
|
|
|
- mpscene->addItem(pe);
|
|
|
|
- gpe = pe;
|
|
|
|
|
|
+ mpNowPosItem = new QGraphicsEllipseItem(0-mfNowSize/2.0,0-mfNowSize/2.0,mfNowSize,mfNowSize);
|
|
|
|
+ mpNowPosItem->setBrush(Qt::green);
|
|
|
|
+ mpNowPosItem->setPen(Qt::NoPen);
|
|
|
|
+ mpNowPosItem->setPos(3000,3000);
|
|
|
|
+ mpscene->addItem(mpNowPosItem);
|
|
|
|
|
|
connect(this,SIGNAL(updategps()),this,SLOT(ongpsupdate()));
|
|
connect(this,SIGNAL(updategps()),this,SLOT(ongpsupdate()));
|
|
|
|
|
|
@@ -141,16 +160,66 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
|
|
|
|
|
void MainWindow::on_pushButton_NewRoad_clicked()
|
|
void MainWindow::on_pushButton_NewRoad_clicked()
|
|
{
|
|
{
|
|
|
|
+ bool ok;
|
|
|
|
+ QString text = QInputDialog::getText(this, tr("道路名称"),
|
|
|
|
+ tr("道路名称:"), QLineEdit::Normal,
|
|
|
|
+ tr("道路1"), &ok);
|
|
|
|
+
|
|
|
|
+ if(ok == false)return;
|
|
|
|
+ if(text.isEmpty())return;
|
|
|
|
+
|
|
|
|
+ int i;
|
|
|
|
+ for(i=0;i<mcollectveh.mroads_size();i++)
|
|
|
|
+ {
|
|
|
|
+ if(mcollectveh.mutable_mroads(i)->strroadname() == text.toStdString())
|
|
|
|
+ {
|
|
|
|
+ QMessageBox::warning(this,"Warning","Road Is Exist",QMessageBox::YesAll);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ iv::map::collectvehroad * proad = mcollectveh.add_mroads();
|
|
|
|
+ proad->set_strroadname(text.toStdString());
|
|
|
|
+ mpcurroad = proad;
|
|
|
|
+
|
|
|
|
+ ui->lineEdit_RoadName->setText(text);
|
|
|
|
+ mbStartCollect = true;
|
|
|
|
+ ui->pushButton_NewRoad->setEnabled(false);
|
|
|
|
+ ui->pushButton_Complete->setEnabled(true);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::paintEvent(QPaintEvent * event)
|
|
void MainWindow::paintEvent(QPaintEvent * event)
|
|
{
|
|
{
|
|
(void)event;
|
|
(void)event;
|
|
|
|
+ static double foldratio = 1.0;
|
|
|
|
|
|
double ratio = myview->getbeishu();
|
|
double ratio = myview->getbeishu();
|
|
- gt->setratio(ratio);
|
|
|
|
- gpe->setScale(1.0/ratio);
|
|
|
|
|
|
+ if(ratio != foldratio)
|
|
|
|
+ {
|
|
|
|
+ foldratio = ratio;
|
|
|
|
+ double fscale = 1.0/ratio;
|
|
|
|
+ mpNowPosItem->setScale(fscale);
|
|
|
|
+ unsigned int i;
|
|
|
|
+ for(i=0;i<mvectorCurLeftPointItem.size();i++)
|
|
|
|
+ {
|
|
|
|
+ mvectorCurLeftPointItem[i]->setScale(fscale);
|
|
|
|
+ }
|
|
|
|
+ for(i=0;i<mvectorCurMainPointItem.size();i++)
|
|
|
|
+ {
|
|
|
|
+ mvectorCurMainPointItem[i]->setScale(fscale);
|
|
|
|
+ }
|
|
|
|
+ for(i=0;i<mvectorCurRightPointItem.size();i++)
|
|
|
|
+ {
|
|
|
|
+ mvectorCurRightPointItem[i]->setScale(fscale);
|
|
|
|
+ }
|
|
|
|
+ // gt->setratio(ratio);
|
|
|
|
+ // gpe->setScale(1.0/ratio);
|
|
|
|
+// myview->setScene(mpscene);
|
|
|
|
+ }
|
|
|
|
+// mpNowPosItem->setScale(1.0/ratio);
|
|
|
|
+// gt->setratio(ratio);
|
|
|
|
+// gpe->setScale(1.0/ratio);
|
|
myview->setScene(mpscene);
|
|
myview->setScene(mpscene);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -173,23 +242,292 @@ void MainWindow::UpdateGPSIMU(std::shared_ptr<iv::gps::gpsimu> xgpsimu_ptr)
|
|
{
|
|
{
|
|
mMutex.lock();
|
|
mMutex.lock();
|
|
mgpsimu_ptr = xgpsimu_ptr;
|
|
mgpsimu_ptr = xgpsimu_ptr;
|
|
- mMutex.lock();
|
|
|
|
|
|
+ mMutex.unlock();
|
|
|
|
|
|
|
|
+ emit updategps();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::AddPoint(std::shared_ptr<iv::gps::gpsimu> xgpsimu_ptr)
|
|
|
|
+{
|
|
|
|
+ iv::map::collectvehroadpoint xpoint;
|
|
|
|
+ xpoint.set_mfdis_left( ui->lineEdit_DisLeft->text().toDouble());
|
|
|
|
+ xpoint.set_mflanewidth(ui->lineEdit->text().toDouble());
|
|
|
|
+ xpoint.set_mflat(xgpsimu_ptr->lat());
|
|
|
|
+ xpoint.set_mflon(xgpsimu_ptr->lon());
|
|
|
|
+ xpoint.set_mfheading(xgpsimu_ptr->heading());
|
|
|
|
+ if(ui->comboBox_ColorLeft->currentIndex() == 0)xpoint.set_mlanecolor_left(iv::map::collectvehroadpoint::LaneColor::collectvehroadpoint_LaneColor_WHITE);
|
|
|
|
+ else xpoint.set_mlanecolor_left(iv::map::collectvehroadpoint::LaneColor::collectvehroadpoint_LaneColor_YELLOW);
|
|
|
|
+ switch (ui->comboBox_TypeLeft->currentIndex()) {
|
|
|
|
+ case 0:
|
|
|
|
+ xpoint.set_mlanetype_left(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_NONE);
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ xpoint.set_mlanetype_left(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_SOLID);
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ xpoint.set_mlanetype_left(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_DASH);
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ xpoint.set_mlanetype_left(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_SOLID_SOLID);
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ xpoint.set_mlanetype_left(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_DASH_DASH);
|
|
|
|
+ break;
|
|
|
|
+ case 5:
|
|
|
|
+ xpoint.set_mlanetype_left(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_SOLID_DASH);
|
|
|
|
+ break;
|
|
|
|
+ case 6:
|
|
|
|
+ xpoint.set_mlanetype_left(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_DASH_SOLID);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ xpoint.set_mlanetype_left(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_NONE);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if(ui->comboBox_ColorRight->currentIndex() == 0)xpoint.set_mlanecolor_right(iv::map::collectvehroadpoint::LaneColor::collectvehroadpoint_LaneColor_WHITE);
|
|
|
|
+ else xpoint.set_mlanecolor_right(iv::map::collectvehroadpoint::LaneColor::collectvehroadpoint_LaneColor_YELLOW);
|
|
|
|
+ switch (ui->comboBox_TypeRIght->currentIndex()) {
|
|
|
|
+ case 0:
|
|
|
|
+ xpoint.set_mlanetype_right(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_NONE);
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ xpoint.set_mlanetype_right(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_SOLID);
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ xpoint.set_mlanetype_right(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_DASH);
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ xpoint.set_mlanetype_right(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_SOLID_SOLID);
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ xpoint.set_mlanetype_right(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_DASH_DASH);
|
|
|
|
+ break;
|
|
|
|
+ case 5:
|
|
|
|
+ xpoint.set_mlanetype_right(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_SOLID_DASH);
|
|
|
|
+ break;
|
|
|
|
+ case 6:
|
|
|
|
+ xpoint.set_mlanetype_right(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_DASH_SOLID);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ xpoint.set_mlanetype_right(iv::map::collectvehroadpoint::LaneType::collectvehroadpoint_LaneType_NONE);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ iv::map::collectvehroadpoint * ppoint = mpcurroad->add_mpoints();
|
|
|
|
+ ppoint->CopyFrom(xpoint);
|
|
|
|
+ mplastaddpoint = ppoint;
|
|
|
|
+
|
|
|
|
+ double x_left,y_left,x_main,y_main,x_right,y_right;
|
|
|
|
+ double x0,y0;
|
|
|
|
+ double fhdg = (90 - xgpsimu_ptr->heading())*M_PI/180.0;
|
|
|
|
+ GaussProjCal(xgpsimu_ptr->lon(),xgpsimu_ptr->lat(),&x_main,&y_main);
|
|
|
|
+ GaussProjCal(mlon0,mlat0,&x0,&y0);
|
|
|
|
+ x_main = x_main - x0;
|
|
|
|
+ y_main = y_main - y0;
|
|
|
|
+ x_left = x_main + xpoint.mfdis_left()*cos(fhdg + M_PI/2.0);
|
|
|
|
+ y_left = y_main + xpoint.mfdis_left()*sin(fhdg + M_PI/2.0);
|
|
|
|
+ x_right = x_main + (xpoint.mfdis_left() - xpoint.mflanewidth())*cos(fhdg + M_PI/2.0);
|
|
|
|
+ y_right = y_main + (xpoint.mfdis_left() - xpoint.mflanewidth())*sin(fhdg + M_PI/2.0);
|
|
|
|
+
|
|
|
|
+ double ratio = myview->getbeishu();
|
|
|
|
+ double fscale = 1.0/ratio;
|
|
|
|
+ QGraphicsEllipseItem * pmainitem,* pleftitem,*prightitem;
|
|
|
|
+ pmainitem = new QGraphicsEllipseItem(0-mfMainSize/2.0,0*(-1)-mfMainSize/2.0,mfMainSize,mfMainSize);
|
|
|
|
+ pmainitem->setBrush(Qt::red);
|
|
|
|
+ pmainitem->setPen(Qt::NoPen);
|
|
|
|
+ pmainitem->setPos(VIEW_WIDTH/2 + x_main,VIEW_HEIGHT/2 -y_main);
|
|
|
|
+ pmainitem->setScale(fscale);
|
|
|
|
+ mpscene->addItem(pmainitem);
|
|
|
|
+ pleftitem = new QGraphicsEllipseItem(0-mfLeftRightSize/2.0,0*(-1)-mfLeftRightSize/2.0,mfLeftRightSize,mfLeftRightSize);
|
|
|
|
+ pleftitem->setBrush(Qt::darkGray);
|
|
|
|
+ pleftitem->setPen(Qt::NoPen);
|
|
|
|
+ pleftitem->setPos(VIEW_WIDTH/2 + x_left,VIEW_HEIGHT/2 -y_left);
|
|
|
|
+ pleftitem->setScale(fscale);
|
|
|
|
+ mpscene->addItem(pleftitem);
|
|
|
|
+ prightitem = new QGraphicsEllipseItem(0-mfLeftRightSize/2.0,0*(-1)-mfLeftRightSize/2.0,mfLeftRightSize,mfLeftRightSize);
|
|
|
|
+ prightitem->setBrush(Qt::darkGray);
|
|
|
|
+ prightitem->setPen(Qt::NoPen);
|
|
|
|
+ prightitem->setPos(VIEW_WIDTH/2 + x_right,VIEW_HEIGHT/2 -y_right);
|
|
|
|
+ prightitem->setScale(fscale);
|
|
|
|
+ mpscene->addItem(prightitem);
|
|
|
|
+
|
|
|
|
+ mvectorCurLeftPointItem.push_back(pleftitem);
|
|
|
|
+ mvectorCurMainPointItem.push_back(pmainitem);
|
|
|
|
+ mvectorCurRightPointItem.push_back(prightitem);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::ongpsupdate()
|
|
|
|
+{
|
|
|
|
+ const double thresh_headingdiff = 1.0;
|
|
|
|
+ const double thresh_disdiff = 10.0;
|
|
|
|
+ std::shared_ptr<iv::gps::gpsimu> xgpsimu_ptr;
|
|
|
|
+ mMutex.lock();
|
|
|
|
+ xgpsimu_ptr = mgpsimu_ptr;
|
|
|
|
+ mMutex.unlock();
|
|
if(mbSetZero == false)
|
|
if(mbSetZero == false)
|
|
{
|
|
{
|
|
mlon0 = mgpsimu_ptr->lon();
|
|
mlon0 = mgpsimu_ptr->lon();
|
|
mlat0 = mgpsimu_ptr->lat();
|
|
mlat0 = mgpsimu_ptr->lat();
|
|
|
|
+ mcollectveh.set_mlon0(mlon0);
|
|
|
|
+ mcollectveh.set_mlat0(mlat0);
|
|
mbSetZero = true;
|
|
mbSetZero = true;
|
|
}
|
|
}
|
|
|
|
+ double xrelx,xrely,x0,y0,x1,y1;
|
|
|
|
+ if(mbSetZero)
|
|
|
|
+ {
|
|
|
|
+ GaussProjCal(mlon0,mlat0,&x0,&y0);
|
|
|
|
+ GaussProjCal(xgpsimu_ptr->lon(),xgpsimu_ptr->lat(),&x1,&y1);
|
|
|
|
+ xrelx = x1-x0;
|
|
|
|
+ xrely = y1-y0;
|
|
|
|
+ mpNowPosItem->setPos(xrelx + VIEW_WIDTH/2,xrely*(-1)+VIEW_HEIGHT/2);
|
|
|
|
+// mpNowPosItem->setRect(xrelx-mfNowSize/2.0,xrely*(-1) - mfNowSize/2.0,mfNowSize,mfNowSize);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if(mbStartCollect == false)return;
|
|
|
|
+
|
|
|
|
+ if(mpcurroad->mpoints_size() == 0)
|
|
|
|
+ {
|
|
|
|
+ AddPoint(xgpsimu_ptr);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ double foldlat,foldlon,foldx,foldy;
|
|
|
|
+ foldlon = mplastaddpoint->mflon();
|
|
|
|
+ foldlat = mplastaddpoint->mflat();
|
|
|
|
+ GaussProjCal(foldlon,foldlat,&foldx,&foldy);
|
|
|
|
+ double foldheading = mplastaddpoint->mfheading();
|
|
|
|
+
|
|
|
|
+ double fdis = sqrt(pow(x1-foldx,2)+pow(y1-foldy,2));
|
|
|
|
+
|
|
|
|
+ double fheadingdiff = xgpsimu_ptr->heading() - foldheading;
|
|
|
|
+ while(fheadingdiff<0)fheadingdiff = fheadingdiff + 360.0;
|
|
|
|
+ while(fheadingdiff>=360)fheadingdiff = fheadingdiff -360.0;
|
|
|
|
+
|
|
|
|
+ if((fheadingdiff>=thresh_headingdiff)&&(fheadingdiff<=(360.0 - thresh_headingdiff)))
|
|
|
|
+ {
|
|
|
|
+ AddPoint(xgpsimu_ptr);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if(fdis >= thresh_disdiff)
|
|
|
|
+ {
|
|
|
|
+ AddPoint(xgpsimu_ptr);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- emit updategps();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-void MainWindow::ongpsupdate()
|
|
|
|
|
|
+void MainWindow::on_actionReset_triggered()
|
|
{
|
|
{
|
|
- double xrelx,xrely,x0,y0,x1,y1;
|
|
|
|
- GaussProjCal(mlon0,mlat0,&x0,&y0);
|
|
|
|
- GaussProjCal(mgpsimu_ptr->lon(),mgpsimu_ptr->lat(),&x1,&y1);
|
|
|
|
- xrelx = x1-x0;
|
|
|
|
- xrely = y1-y0;
|
|
|
|
|
|
+ QMessageBox::StandardButton button;
|
|
|
|
+ button=QMessageBox::question(this,tr("重置采集"),QString(tr("是否重置采集")),QMessageBox::Yes|QMessageBox::No);
|
|
|
|
+ if(button==QMessageBox::No)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else if(button==QMessageBox::Yes)
|
|
|
|
+ {
|
|
|
|
+ mcollectveh.clear_mroads();
|
|
|
|
+ QMessageBox::information(this,"Info",tr("采集重置成功"),QMessageBox::YesAll);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mbSetZero = false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::on_actionSave_triggered()
|
|
|
|
+{
|
|
|
|
+// QString str;
|
|
|
|
+// str.clear();
|
|
|
|
+// QFileDialog filedialog;
|
|
|
|
+// filedialog.setAcceptMode(QFileDialog::AcceptSave);
|
|
|
|
+// filedialog.setViewMode(QFileDialog::List);
|
|
|
|
+// filedialog.setFileMode(QFileDialog::AnyFile);
|
|
|
|
+// filedialog.setWindowTitle(tr("标题"));
|
|
|
|
+// filedialog.setDefaultSuffix("cov");
|
|
|
|
+// filedialog.setOption(QFileDialog::DontUseNativeDialog);
|
|
|
|
+// if(filedialog.exec()== QDialog::Accepted )
|
|
|
|
+// {
|
|
|
|
+// QStringList filePaths = filedialog.selectedFiles();
|
|
|
|
+// str = filePaths[0];
|
|
|
|
+// int a ;
|
|
|
|
+// a = 1;
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ QString str = QFileDialog::getSaveFileName(this,"Save Collect",".","*.cov");
|
|
|
|
+ if(str.isEmpty())return;
|
|
|
|
+ if(str.right(4) != ".cov")
|
|
|
|
+ {
|
|
|
|
+ str = str + QString(".cov");
|
|
|
|
+ }
|
|
|
|
+ QFile xFile;
|
|
|
|
+ xFile.setFileName(str);
|
|
|
|
+ if(!xFile.open(QIODevice::ReadWrite))
|
|
|
|
+ {
|
|
|
|
+ QMessageBox::warning(this,"Warning","Open Save File Fail.",QMessageBox::YesAll);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ int nbytesize = mcollectveh.ByteSize();
|
|
|
|
+ std::cout<<" byte size : "<<nbytesize<<std::endl;
|
|
|
|
+ std::shared_ptr<char> pstr_data = std::shared_ptr<char>(new char[nbytesize]);
|
|
|
|
+ if(mcollectveh.SerializeToArray(pstr_data.get(),nbytesize))
|
|
|
|
+ {
|
|
|
|
+ xFile.write(pstr_data.get(),nbytesize);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ QMessageBox::warning(this,"Waring","Serialize Collect Data Fail.",QMessageBox::YesAll);
|
|
|
|
+ }
|
|
|
|
+ xFile.close();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::on_actionLoad_triggered()
|
|
|
|
+{
|
|
|
|
+ if(mcollectveh.mroads_size() > 0)
|
|
|
|
+ {
|
|
|
|
+ QMessageBox::StandardButton button;
|
|
|
|
+ button=QMessageBox::question(this,tr("加载数据"),QString(tr("当前已有采集,是否加载数据")),QMessageBox::Yes|QMessageBox::No);
|
|
|
|
+ if(button==QMessageBox::No)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ QString str = QFileDialog::getOpenFileName(this,"Load Collect",".","*.cov");
|
|
|
|
+ if(str.isEmpty())return;
|
|
|
|
+ QFile xFile;
|
|
|
|
+ xFile.setFileName(str);
|
|
|
|
+ if(!xFile.open(QIODevice::ReadOnly))
|
|
|
|
+ {
|
|
|
|
+ QMessageBox::warning(this,"Warning","Open File Fail.",QMessageBox::YesAll);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ QByteArray ba = xFile.readAll();
|
|
|
|
+ xFile.close();
|
|
|
|
+ mcollectveh.clear_mroads();
|
|
|
|
+ if(!mcollectveh.ParseFromArray(ba.data(),ba.size()))
|
|
|
|
+ {
|
|
|
|
+ QMessageBox::warning(this,"Warning","Parse File Data Fail.",QMessageBox::YesAll);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(mcollectveh.mroads_size() == 0)
|
|
|
|
+ {
|
|
|
|
+ mbSetZero = false;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ mbSetZero = true;
|
|
|
|
+ mlon0 = mcollectveh.mlon0();
|
|
|
|
+ mlat0 = mcollectveh.mlat0();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::on_pushButton_Complete_clicked()
|
|
|
|
+{
|
|
|
|
+ mbStartCollect = false;
|
|
|
|
+ ui->pushButton_Complete->setEnabled(false);
|
|
|
|
+ ui->pushButton_NewRoad->setEnabled(true);
|
|
}
|
|
}
|