|
@@ -84,9 +84,17 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
|
|
|
mTabMain = p;
|
|
|
|
|
|
+ mpTabVehState = new QTabWidget(ui->centralwidget);
|
|
|
+ mpTabCmd = new QTabWidget(ui->centralwidget);
|
|
|
+
|
|
|
CreateCar();
|
|
|
CreateSP();
|
|
|
CreateEP();
|
|
|
+ CreateSteer();
|
|
|
+ CreateStateItem();
|
|
|
+ CreateCMDItem();
|
|
|
+
|
|
|
+ connect(myview,SIGNAL(moveorscale()),this,SLOT(onMyViewMoveOrScale()));
|
|
|
|
|
|
mpTimerShowSelObj = new QTimer(this);
|
|
|
connect(mpTimerShowSelObj,SIGNAL(timeout()),this,SLOT(onTimerShowSelObj()));
|
|
@@ -122,8 +130,15 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
|
|
(void)event;
|
|
|
QSize sizemain = ui->centralwidget->size();
|
|
|
myview->setGeometry(0,30,sizemain.width()-mnFontHeight * 22 - 30,sizemain.height());
|
|
|
- mTabMain->setGeometry(sizemain.width()-mnFontHeight * 22,30,mnFontHeight * 22,sizemain.height()-50);
|
|
|
-
|
|
|
+ int nkeep = 110;
|
|
|
+ int nbase = sizemain.height() - nkeep;
|
|
|
+ if(nbase < 0) nbase = 30;
|
|
|
+ double fratio1 = 0.65;
|
|
|
+ double fratio2 = 0.25;
|
|
|
+ double fratio3 = 0.10;
|
|
|
+ mTabMain->setGeometry(sizemain.width()-mnFontHeight * 22,30,mnFontHeight * 22,nbase * fratio1);
|
|
|
+ mpTabVehState->setGeometry(sizemain.width()-mnFontHeight * 22,60 + nbase * fratio1,mnFontHeight * 22,nbase * fratio2);
|
|
|
+ mpTabCmd->setGeometry(sizemain.width()-mnFontHeight * 22,90 + nbase * (fratio1 + fratio2),mnFontHeight * 22, nbase * fratio3);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -290,10 +305,49 @@ void MainWindow::CreateTab1View(QTabWidget * p)
|
|
|
|
|
|
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::CreateTabStateView(QTabWidget * p)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::CreateTabCmdView(QTabWidget *p)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void MainWindow::onMyViewMoveOrScale()
|
|
|
+{
|
|
|
+ double fViewSize = mfsteerviewsize;
|
|
|
+ double fscale = fViewSize/mppixsteer->boundingRect().height();
|
|
|
+ double beishu = myview->Getbeishu();
|
|
|
+ if(beishu>0)
|
|
|
+ {
|
|
|
+ fscale = fscale/beishu;
|
|
|
+ }
|
|
|
+ // mppixsteer->setRotation(0);
|
|
|
+ mppixsteer->setScale(fscale);
|
|
|
+ double pos_x,pos_y;
|
|
|
+ pos_x = 10;
|
|
|
+ pos_y = 10;
|
|
|
+ double view_x,view_y;
|
|
|
+ myview->GetPosXY(pos_x,pos_y,view_x,view_y);
|
|
|
+ std::cout<<"view x: "<<view_x<<" view y: "<<view_y<<std::endl;
|
|
|
+ mppixsteer->setPos(view_x ,view_y );
|
|
|
+
|
|
|
+ if(beishu == 0.0)return;
|
|
|
+ mpitemstate->setScale(1.0/beishu);
|
|
|
+ mpitemstate->setPos(view_x + fViewSize /beishu,view_y);
|
|
|
+ mpitemcmd->setScale(1.0/beishu);
|
|
|
+ mpitemcmd->setPos(view_x + fViewSize /beishu,view_y + (mnFontSize*1.5)/beishu);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void MainWindow::paintEvent(QPaintEvent *)
|
|
|
{
|
|
|
+
|
|
|
myview->setScene(mpscene);
|
|
|
myview->show();
|
|
|
}
|
|
@@ -574,6 +628,65 @@ void MainWindow::CreateEP()
|
|
|
mppixep->setVisible(false);
|
|
|
}
|
|
|
|
|
|
+void MainWindow::CreateSteer()
|
|
|
+{
|
|
|
+ QGraphicsPixmapItem * ppix;
|
|
|
+ ppix = new QGraphicsPixmapItem();
|
|
|
+ ppix->setPixmap(QPixmap(":/steer.png"));
|
|
|
+ QRectF xr = ppix->boundingRect();
|
|
|
+
|
|
|
+ double fViewSize = mfsteerviewsize;
|
|
|
+ double fscale = fViewSize/xr.height();
|
|
|
+ double beishu = myview->Getbeishu();
|
|
|
+ if(beishu>0)
|
|
|
+ {
|
|
|
+ fscale = fscale/beishu;
|
|
|
+ }
|
|
|
+ ppix->setRotation(0);
|
|
|
+ ppix->setScale(fscale);
|
|
|
+ double pos_x,pos_y;
|
|
|
+ pos_x = 10;
|
|
|
+ pos_y = 10;
|
|
|
+ double view_x,view_y;
|
|
|
+ myview->GetPosXY(view_x,view_y,pos_x,pos_y);
|
|
|
+ ppix->setPos(view_x,view_y);
|
|
|
+ mpscene->addItem(ppix);
|
|
|
+ ppix->setZValue(101.0);
|
|
|
+ mppixsteer = ppix;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::CreateStateItem()
|
|
|
+{
|
|
|
+ QGraphicsSimpleTextItem * pState;
|
|
|
+ pState = new QGraphicsSimpleTextItem();
|
|
|
+ pState->setPos(130,0);
|
|
|
+ pState->setText("Vehicle State acc: brake: steer: ");
|
|
|
+ QFont font = pState->font();
|
|
|
+ font.setPixelSize(mnFontSize); // 像素大小
|
|
|
+ font.setItalic(true); // 斜体
|
|
|
+ font.setUnderline(true); // 下划线
|
|
|
+ pState->setFont(font);
|
|
|
+ pState->setBrush(QBrush(QColor(0, 160, 230)));
|
|
|
+ mpscene->addItem(pState);
|
|
|
+ mpitemstate = pState;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::CreateCMDItem()
|
|
|
+{
|
|
|
+ QGraphicsSimpleTextItem * pState;
|
|
|
+ pState = new QGraphicsSimpleTextItem();
|
|
|
+ pState->setPos(130,30);
|
|
|
+ pState->setText("CMD acc: brake: steer: ");
|
|
|
+ QFont font = pState->font();
|
|
|
+ font.setPixelSize(mnFontSize); // 像素大小
|
|
|
+ font.setItalic(true); // 斜体
|
|
|
+ font.setUnderline(true); // 下划线
|
|
|
+ pState->setFont(font);
|
|
|
+ pState->setBrush(QBrush(QColor(0, 160, 230)));
|
|
|
+ mpscene->addItem(pState);
|
|
|
+ mpitemcmd = pState;
|
|
|
+}
|
|
|
+
|
|
|
void MainWindow::SetCarPos(double x,double y, double fhdg)
|
|
|
{
|
|
|
|