|
@@ -63,10 +63,24 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
connect(mpTimerShowSelObj,SIGNAL(timeout()),this,SLOT(onTimerShowSelObj()));
|
|
|
mpTimerShowSelObj->start(100);
|
|
|
|
|
|
+ mpsimmodel = new simmodel_shenlan();
|
|
|
+ mpsimmodel->SetLon0Lat0(glon0,glat0);
|
|
|
+
|
|
|
+ mpTimerUpdateCarPos = new QTimer(this);
|
|
|
+ connect(mpTimerUpdateCarPos,SIGNAL(timeout()),this,SLOT(onTimerUpdateCarPos()));
|
|
|
+ mpTimerUpdateCarPos->start(50);
|
|
|
+
|
|
|
+ ModuleFun fundecition =std::bind(&MainWindow::UpdateDecition,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
+
|
|
|
+ // mpaDecition = iv::modulecomm::RegisterRecvPlus("decition",fundecition);
|
|
|
+ mpaDecition = iv::modulecomm::RegisterRecvPlus("deciton",fundecition);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
{
|
|
|
+ delete mpsimmodel;
|
|
|
delete ui;
|
|
|
}
|
|
|
|
|
@@ -92,6 +106,7 @@ void MainWindow::CreateTab1View(QTabWidget * p)
|
|
|
QPushButton * pPB;
|
|
|
QSlider * pSlider;
|
|
|
QComboBox * pCB;
|
|
|
+ QCheckBox * pCheck;
|
|
|
|
|
|
|
|
|
|
|
@@ -208,6 +223,33 @@ void MainWindow::CreateTab1View(QTabWidget * p)
|
|
|
|
|
|
connect(mpPBDelObj,SIGNAL(clicked(bool)),this,SLOT(onClickDelObj()));
|
|
|
|
|
|
+ nYPos = nYPos + mnFontHeight * 2;
|
|
|
+
|
|
|
+ nXPos = 10;
|
|
|
+ nYPos = nYPos + mnFontHeight * 2;
|
|
|
+
|
|
|
+ pCB = new QComboBox(pGroup);
|
|
|
+ pCB->setGeometry(nXPos,nYPos,nLEWidth,nLEHeight*3/2);
|
|
|
+ mpCBShift = pCB;
|
|
|
+ pCB->addItem("Park");
|
|
|
+ pCB->addItem("Reverse");
|
|
|
+ pCB->addItem("Drive");
|
|
|
+ connect(mpCBShift,SIGNAL(currentIndexChanged(int)),this,SLOT(onCurrentShiftChanged(int)));
|
|
|
+ pCB->setEnabled(true);
|
|
|
+
|
|
|
+ nXPos = nXPos + nSpace * 2;
|
|
|
+
|
|
|
+ pCheck = new QCheckBox(pGroup);
|
|
|
+ pCheck->setGeometry(nXPos,nYPos,nLEWidth,nLEHeight*3/2);
|
|
|
+ pCheck->setChecked(false);
|
|
|
+ pCheck->setText("Simulate");
|
|
|
+ mpCBSim = pCheck;
|
|
|
+ connect(mpCBSim,SIGNAL(stateChanged(int)),this,SLOT(onSimStateChanged(int)));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
QScrollArea * pScroll = new QScrollArea();
|
|
|
pScroll->setWidget(pGroup);
|
|
|
|
|
@@ -228,6 +270,9 @@ void MainWindow::onClickXY(double x,double y)
|
|
|
(void)x;
|
|
|
(void)y;
|
|
|
|
|
|
+ static double fx_dis1,fy_dis1,fx_dis2,fy_dis2;
|
|
|
+
|
|
|
+
|
|
|
mfClickX = x - mfMoveX;
|
|
|
mfClickY = y - mfMoveY;
|
|
|
|
|
@@ -237,6 +282,27 @@ void MainWindow::onClickXY(double x,double y)
|
|
|
selx = mfClickX;
|
|
|
sely = mfClickY * (-1);
|
|
|
|
|
|
+ if(mnMeasure == 1)
|
|
|
+ {
|
|
|
+ mnMeasure = 2;
|
|
|
+ fx_dis1 = selx;
|
|
|
+ fy_dis1 = sely;
|
|
|
+ ui->statusbar->showMessage(tr("请选择第二个点"),3000);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mnMeasure == 2)
|
|
|
+ {
|
|
|
+ mnMeasure = 0;
|
|
|
+ fx_dis2 = selx;
|
|
|
+ fy_dis2 = sely;
|
|
|
+ double fdis = sqrt(pow(fx_dis2 - fx_dis1,2)+pow(fy_dis2 - fy_dis1,2));
|
|
|
+ char strout[100];
|
|
|
+ snprintf(strout,100,"Distance: %6.3f",fdis);
|
|
|
+ ui->statusbar->showMessage(strout,10000);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
mpLE_SelX->setText(QString::number(selx,'f',3));
|
|
|
mpLE_SelY->setText(QString::number(sely,'f',3));
|
|
|
|
|
@@ -282,6 +348,8 @@ void MainWindow::on_actionLoad_triggered()
|
|
|
glat0 = lat0;
|
|
|
glon0 = lon0;
|
|
|
|
|
|
+ mpsimmodel->SetLon0Lat0(glon0,glat0);
|
|
|
+
|
|
|
mxodr = *pxodr;
|
|
|
|
|
|
UpdateScene();
|
|
@@ -423,20 +491,12 @@ void MainWindow::CreateCar()
|
|
|
|
|
|
void MainWindow::SetCarPos(double x,double y, double fhdg)
|
|
|
{
|
|
|
- double fhead = fhdg * 180.0/M_PI *(-1.0);
|
|
|
-
|
|
|
- double x0,y0;
|
|
|
- x0 = mfvehlen/2.0;
|
|
|
- y0 = mfvehwidth/2.0 *(-1.0);
|
|
|
- double x1,y1;
|
|
|
- double hdgrt = fhdg;//法 fhead *M_PI/180.0;
|
|
|
- x1 = x0 * cos(hdgrt) - y0 * sin(hdgrt);
|
|
|
- y1 = x0 * sin(hdgrt) + y0 * cos(hdgrt);
|
|
|
|
|
|
- mppixcar->setRotation(fhead);
|
|
|
+ mpsimmodel->SetX(x);
|
|
|
+ mpsimmodel->SetY(y);
|
|
|
+ mpsimmodel->Sethdg(fhdg);
|
|
|
|
|
|
|
|
|
- mppixcar->setPos(mfViewMoveX +VIEW_WIDTH/2.0 + x - x1 ,-mfViewMoveY+VIEW_HEIGHT/2.0 - y + y1);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -695,3 +755,79 @@ void MainWindow::normalhdg(double & fhdg)
|
|
|
while(fhdg > (2.0*M_PI))fhdg = fhdg - 2.0*M_PI;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+void MainWindow::on_actionMeasuring_Distance_triggered()
|
|
|
+{
|
|
|
+ ui->statusbar->showMessage(tr("选择第一个点"),3000);
|
|
|
+ mnMeasure = 1;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onCurrentShiftChanged(int index)
|
|
|
+{
|
|
|
+ switch(index)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ mpsimmodel->SetShift(simmodel::SHIFT_GEER::PARK);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ mpsimmodel->SetShift(simmodel::SHIFT_GEER::REVERSE);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ mpsimmodel->SetShift(simmodel::SHIFT_GEER::DRIVE);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ mpsimmodel->SetShift(simmodel::SHIFT_GEER::PARK);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onSimStateChanged(int nState)
|
|
|
+{
|
|
|
+ if(nState == Qt::Checked)
|
|
|
+ {
|
|
|
+ mpCBShift->setEnabled(false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mpCBShift->setEnabled(true);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onTimerUpdateCarPos()
|
|
|
+{
|
|
|
+ double x,y,fhdg;
|
|
|
+ x = mpsimmodel->GetX();
|
|
|
+ y = mpsimmodel->GetY();
|
|
|
+ fhdg = mpsimmodel->Gethdg();
|
|
|
+ double fhead = fhdg * 180.0/M_PI *(-1.0);
|
|
|
+
|
|
|
+ double x0,y0;
|
|
|
+ x0 = mfvehlen/2.0;
|
|
|
+ y0 = mfvehwidth/2.0 *(-1.0);
|
|
|
+ double x1,y1;
|
|
|
+ double hdgrt = fhdg;// fhead *M_PI/180.0;
|
|
|
+ x1 = x0 * cos(hdgrt) - y0 * sin(hdgrt);
|
|
|
+ y1 = x0 * sin(hdgrt) + y0 * cos(hdgrt);
|
|
|
+
|
|
|
+ mppixcar->setRotation(fhead);
|
|
|
+
|
|
|
+
|
|
|
+ mppixcar->setPos(mfViewMoveX +VIEW_WIDTH/2.0 + x - x1 ,-mfViewMoveY+VIEW_HEIGHT/2.0 - y + y1);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::UpdateDecition(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+
|
|
|
+ iv::brain::decition xdecition;
|
|
|
+ if(!xdecition.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ std::cout<<"MainWindow::UpdateDecition parse errror. nSize is %d"<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //ServiceCarStatus.mfAcc = xdecition.accelerator(); //
|
|
|
+
|
|
|
+ mpsimmodel->SetCMD(xdecition.accelerator(),xdecition.torque(),xdecition.brake(),xdecition.wheelangle());
|
|
|
+}
|
|
|
+
|