|
@@ -8,6 +8,8 @@
|
|
|
#include "google/protobuf/io/zero_copy_stream_impl.h"
|
|
|
#include "google/protobuf/text_format.h"
|
|
|
|
|
|
+#include <QFileDialog>
|
|
|
+
|
|
|
|
|
|
|
|
|
#define VIEW_WIDTH 6000
|
|
@@ -39,6 +41,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|
|
mpdkp = new DialogKickPoint(&msissunmap, this);
|
|
|
|
|
|
connect(mmyview,SIGNAL(dbclickxy(double,double)),this,SLOT(ondbclick(double,double)));
|
|
|
+
|
|
|
+ ui->actionSelect_None->setChecked(true);
|
|
|
+ ui->actionSelect_Kick->setChecked(false);
|
|
|
+ ui->actionSelect_Point->setChecked(false);
|
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
@@ -102,9 +108,12 @@ void MainWindow::on_actionInsert_Kick_Point_triggered()
|
|
|
|
|
|
void MainWindow::on_actionSave_triggered()
|
|
|
{
|
|
|
+ // QString strfilepath = "/home/yuchuli/testsia.txt";
|
|
|
|
|
|
+ QString str = QFileDialog::getSaveFileName(this,tr("Save Data"),".","*.txt");
|
|
|
+ if(str.isEmpty())return;
|
|
|
+ QString strfilepath = str;
|
|
|
|
|
|
- QString strfilepath = "/home/yuchuli/testsia.txt";
|
|
|
using google::protobuf::TextFormat;
|
|
|
using google::protobuf::io::FileOutputStream;
|
|
|
using google::protobuf::io::ZeroCopyOutputStream;
|
|
@@ -130,7 +139,11 @@ void MainWindow::on_actionSave_triggered()
|
|
|
|
|
|
void MainWindow::on_actionLoad_triggered()
|
|
|
{
|
|
|
- QString strfilepath = "/home/yuchuli/testsia.txt";
|
|
|
+// QString strfilepath = "/home/yuchuli/testsia.txt";
|
|
|
+
|
|
|
+ QString str = QFileDialog::getOpenFileName(this,tr("Load Data"),".","*.txt");
|
|
|
+ if(str.isEmpty())return;
|
|
|
+ QString strfilepath = str;
|
|
|
|
|
|
QFile xFile;
|
|
|
xFile.setFileName(strfilepath);
|
|
@@ -172,11 +185,40 @@ void MainWindow::on_actionLoad_triggered()
|
|
|
}
|
|
|
|
|
|
iv::siasun::kickpointarray * pkickarray = msissunmap.mutable_mkickarray();
|
|
|
+ iv::siasun::waypointarray * pwayarray = msissunmap.mutable_mwayarray();
|
|
|
|
|
|
int i;
|
|
|
mlon0 = pkickarray->mutable_mkick(0)->mflon();
|
|
|
mlat0 = pkickarray->mutable_mkick(0)->mflat();
|
|
|
|
|
|
+ if(mpSelectMapPointItem != NULL)
|
|
|
+ {
|
|
|
+ mpscene->removeItem(mpSelectMapPointItem);
|
|
|
+ delete mpSelectMapPointItem;
|
|
|
+ mpSelectMapPointItem = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mpSelectPointItem != NULL)
|
|
|
+ {
|
|
|
+ mpscene->removeItem(mpSelectPointItem);
|
|
|
+ delete mpSelectPointItem;
|
|
|
+ mpSelectPointItem = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ for(i=0;i<(int)mvectorPickPointItem.size();i++)
|
|
|
+ {
|
|
|
+ mpscene->removeItem(mvectorPickPointItem[i]);
|
|
|
+ delete mvectorPickPointItem[i];
|
|
|
+ }
|
|
|
+ mvectorPickPointItem.clear();
|
|
|
+
|
|
|
+ for(i=0;i<(int)mvectorMapPointItem.size();i++)
|
|
|
+ {
|
|
|
+ mpscene->removeItem(mvectorMapPointItem[i]);
|
|
|
+ delete mvectorMapPointItem[i];
|
|
|
+ }
|
|
|
+ mvectorMapPointItem.clear();
|
|
|
+
|
|
|
for(i=0;i<pkickarray->mkick_size();i++)
|
|
|
{
|
|
|
iv::siasun::kickpoint * ppoint = pkickarray->mutable_mkick(i);
|
|
@@ -199,6 +241,29 @@ void MainWindow::on_actionLoad_triggered()
|
|
|
mvectorPickPointItem.push_back(pmainitem);
|
|
|
}
|
|
|
|
|
|
+ if(pwayarray == NULL)return;
|
|
|
+
|
|
|
+ for(i=0;i<pwayarray->mwaypoint_size();i++)
|
|
|
+ {
|
|
|
+ iv::siasun::waypoint * ppoint = pwayarray->mutable_mwaypoint(i);
|
|
|
+ double x0,y0;
|
|
|
+ double x,y;
|
|
|
+ GaussProjCal(ppoint->mflon(),ppoint->mflat(),&x,&y);
|
|
|
+ GaussProjCal(mlon0,mlat0,&x0,&y0);
|
|
|
+ x = x - x0;
|
|
|
+ y = y - y0;
|
|
|
+
|
|
|
+ double ratio = mmyview->getbeishu();
|
|
|
+ double fscale = 1.0/ratio;
|
|
|
+ QGraphicsEllipseItem * pmainitem;
|
|
|
+ pmainitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
|
|
|
+ pmainitem->setBrush(Qt::green);
|
|
|
+ pmainitem->setPen(Qt::NoPen);
|
|
|
+ pmainitem->setPos(VIEW_WIDTH/2 + x,VIEW_HEIGHT/2 -y);
|
|
|
+ pmainitem->setScale(fscale);
|
|
|
+ mpscene->addItem(pmainitem);
|
|
|
+ mvectorMapPointItem.push_back(pmainitem);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -255,7 +320,7 @@ void MainWindow::ondbclick(double x,double y)
|
|
|
pmainitem->setScale(fscale);
|
|
|
|
|
|
mpscene->addItem(pmainitem);
|
|
|
- mvectorPickPointItem.push_back(pmainitem);
|
|
|
+ mvectorMapPointItem.push_back(pmainitem);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -314,6 +379,63 @@ void MainWindow::ondbclick(double x,double y)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(mnSelectMode == 2)
|
|
|
+ {
|
|
|
+ double fx,fy;
|
|
|
+ fx = x - VIEW_WIDTH/2;
|
|
|
+ fy = VIEW_HEIGHT/2 - y;
|
|
|
+ double x0,y0;
|
|
|
+ GaussProjCal(mlon0,mlat0,&x0,&y0);
|
|
|
+ double flonx,flaty;
|
|
|
+ flonx = fx + x0;
|
|
|
+ flaty = fy + y0;
|
|
|
+ double fdismin = 1000000.0;
|
|
|
+ int index = -1;
|
|
|
+ int i;
|
|
|
+ double xv,yv;
|
|
|
+ iv::siasun::waypointarray * parray = msissunmap.mutable_mwayarray();
|
|
|
+ for(i=0;i<parray->mwaypoint_size();i++)
|
|
|
+ {
|
|
|
+ iv::siasun::waypoint * p = parray->mutable_mwaypoint(i);
|
|
|
+ double p1x,p1y;
|
|
|
+ GaussProjCal(p->mflon(),p->mflat(),&p1x,&p1y);
|
|
|
+ double fdis = sqrt(pow(p1x-flonx,2)+pow(p1y-flaty,2));
|
|
|
+ if(fdis<fdismin)
|
|
|
+ {
|
|
|
+ fdismin = fdis;
|
|
|
+ index = i;
|
|
|
+ xv = p1x;
|
|
|
+ yv = p1y;
|
|
|
+
|
|
|
+ }
|
|
|
+ std::cout<<" fdis: "<<fdismin<<std::endl;
|
|
|
+ }
|
|
|
+ if(fdismin < mfNearDisLimit)
|
|
|
+ {
|
|
|
+ mnIndexSelectWayPoint = index;
|
|
|
+ double ratio = mmyview->getbeishu();
|
|
|
+ double fscale = 1.0/ratio;
|
|
|
+ if(mpSelectMapPointItem == NULL)
|
|
|
+ {
|
|
|
+
|
|
|
+ QGraphicsEllipseItem * pmainitem;
|
|
|
+ pmainitem = new QGraphicsEllipseItem(0-mfPointSize*2.0/2.0,0*(-1)-mfPointSize*2.0/2.0,mfPointSize*2.0,mfPointSize*2.0);
|
|
|
+ pmainitem->setBrush(Qt::red);
|
|
|
+ pmainitem->setPen(Qt::NoPen);
|
|
|
+ pmainitem->setPos(VIEW_WIDTH/2 + xv-x0,VIEW_HEIGHT/2 -(yv-y0));
|
|
|
+ pmainitem->setScale(fscale);
|
|
|
+ mpscene->addItem(pmainitem);
|
|
|
+ mpSelectMapPointItem = pmainitem;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mpSelectMapPointItem->setPos(VIEW_WIDTH/2 + xv-x0,VIEW_HEIGHT/2 -(yv-y0));
|
|
|
+ mpSelectMapPointItem->setScale(fscale);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -365,6 +487,9 @@ void MainWindow::on_actionCreate_Map_triggered()
|
|
|
void MainWindow::on_actionSelect_None_triggered()
|
|
|
{
|
|
|
mnSelectMode = 0;
|
|
|
+ ui->actionSelect_None->setChecked(true);
|
|
|
+ ui->actionSelect_Kick->setChecked(false);
|
|
|
+ ui->actionSelect_Point->setChecked(false);
|
|
|
if(mpSelectPointItem != NULL)
|
|
|
{
|
|
|
mpscene->removeItem(mpSelectPointItem);
|
|
@@ -374,10 +499,113 @@ void MainWindow::on_actionSelect_None_triggered()
|
|
|
|
|
|
void MainWindow::on_actionSelect_Kick_triggered()
|
|
|
{
|
|
|
+ ui->actionSelect_None->setChecked(false);
|
|
|
+ ui->actionSelect_Kick->setChecked(true);
|
|
|
+ ui->actionSelect_Point->setChecked(false);
|
|
|
mnSelectMode = 1;
|
|
|
+ mbInsertMapPoint = false;
|
|
|
+ ui->actionInsert_Map_Point->setText(tr("Start Insert Map Point"));
|
|
|
}
|
|
|
|
|
|
void MainWindow::on_actionSelect_Point_triggered()
|
|
|
{
|
|
|
+ ui->actionSelect_None->setChecked(false);
|
|
|
+ ui->actionSelect_Kick->setChecked(false);
|
|
|
+ ui->actionSelect_Point->setChecked(true);
|
|
|
mnSelectMode = 2;
|
|
|
+ mbInsertMapPoint = false;
|
|
|
+ ui->actionInsert_Map_Point->setText(tr("Start Insert Map Point"));
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_actionDelete_Map_Point_triggered()
|
|
|
+{
|
|
|
+ if(mnIndexSelectWayPoint == -1)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ iv::siasun::waypointarray xarray;
|
|
|
+// xarray.CopyFrom(msissunmap.mwayarray());
|
|
|
+
|
|
|
+ int i;
|
|
|
+ for(i=0;i<msissunmap.mutable_mwayarray()->mwaypoint_size();i++)
|
|
|
+ {
|
|
|
+ if(i != mnIndexSelectWayPoint)
|
|
|
+ {
|
|
|
+ iv::siasun::waypoint * p = xarray.add_mwaypoint();
|
|
|
+ p->CopyFrom(msissunmap.mutable_mwayarray()->mwaypoint(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ msissunmap.mutable_mwayarray()->clear_mwaypoint();
|
|
|
+ msissunmap.mutable_mwayarray()->CopyFrom(xarray);
|
|
|
+
|
|
|
+ mpscene->removeItem(mvectorMapPointItem[(unsigned int)mnIndexSelectWayPoint]);
|
|
|
+
|
|
|
+ mvectorMapPointItem.erase(mvectorMapPointItem.begin()+mnIndexSelectWayPoint);
|
|
|
+
|
|
|
+
|
|
|
+ mnIndexSelectWayPoint = -1;
|
|
|
+ mpscene->removeItem(mpSelectMapPointItem);
|
|
|
+ mpSelectMapPointItem = NULL;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_actionDistance_triggered()
|
|
|
+{
|
|
|
+ if(mvectorlinemap.size() == 0 )
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,tr("Warning"),tr("No Map"),QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mvectorPickPointItem.size() == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,tr("Warning"),tr("No Kick Point"),QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int nindexkick,nindexline;
|
|
|
+ sissunmap xsis;
|
|
|
+ double fdis = xsis.GetDisTance(mvectorlinemap,&msissunmap,nindexkick,nindexline);
|
|
|
+
|
|
|
+ if(nindexkick != -1)
|
|
|
+ {
|
|
|
+ QString strmsg = tr("Distance from kickpoint 2 line: ")+QString::number(fdis,'f',3);
|
|
|
+ QMessageBox::information(this,tr("Information"),strmsg,QMessageBox::YesAll);
|
|
|
+
|
|
|
+ iv::siasun::kickpoint * p = msissunmap.mutable_mkickarray()->mutable_mkick(nindexkick);
|
|
|
+ double p1x,p1y;
|
|
|
+ GaussProjCal(p->mflon(),p->mflat(),&p1x,&p1y);
|
|
|
+
|
|
|
+ double xv,yv;
|
|
|
+ double x0,y0;
|
|
|
+ GaussProjCal(mlon0,mlat0,&x0,&y0);
|
|
|
+ xv = p1x ;
|
|
|
+ yv = p1y ;
|
|
|
+
|
|
|
+ mnIndexSelectKick = nindexkick;
|
|
|
+ double ratio = mmyview->getbeishu();
|
|
|
+ double fscale = 1.0/ratio;
|
|
|
+ if(mpSelectPointItem == NULL)
|
|
|
+ {
|
|
|
+
|
|
|
+ QGraphicsEllipseItem * pmainitem;
|
|
|
+ pmainitem = new QGraphicsEllipseItem(0-mfPointSize*2.0/2.0,0*(-1)-mfPointSize*2.0/2.0,mfPointSize*2.0,mfPointSize*2.0);
|
|
|
+ pmainitem->setBrush(Qt::red);
|
|
|
+ pmainitem->setPen(Qt::NoPen);
|
|
|
+ pmainitem->setPos(VIEW_WIDTH/2 + xv-x0,VIEW_HEIGHT/2 -(yv-y0));
|
|
|
+ pmainitem->setScale(fscale);
|
|
|
+ mpscene->addItem(pmainitem);
|
|
|
+ mpSelectPointItem = pmainitem;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mpSelectPointItem->setPos(VIEW_WIDTH/2 + xv-x0,VIEW_HEIGHT/2 -(yv-y0));
|
|
|
+ mpSelectPointItem->setScale(fscale);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,tr("Warning"),tr("Get Distance Fail."),QMessageBox::YesAll);
|
|
|
+ }
|
|
|
+
|
|
|
}
|