|
@@ -1,7 +1,16 @@
|
|
|
#include "mainwindow.h"
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
-#include "sideparkcalc.h"
|
|
|
+
|
|
|
+
|
|
|
+#define VIEW_WIDTH 1300
|
|
|
+#define VIEW_HEIGHT 800
|
|
|
+
|
|
|
+#define RATIO 50
|
|
|
+
|
|
|
+#define X_MOVE 2
|
|
|
+#define Y_MOVE 6
|
|
|
+
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
: QMainWindow(parent)
|
|
@@ -13,6 +22,22 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
ui->lineEdit_NowY->setText("3.0");
|
|
|
ui->lineEdit_NowHdg->setText("0.0");
|
|
|
|
|
|
+ myview = new MyView(this);
|
|
|
+ myview->setObjectName(QStringLiteral("graphicsView"));
|
|
|
+ myview->setGeometry(QRect(400, 100,1350, 830));
|
|
|
+
|
|
|
+
|
|
|
+ mpscene = new QGraphicsScene(0,0,VIEW_WIDTH,VIEW_HEIGHT);
|
|
|
+ mpscene->setBackgroundBrush(Qt::white);
|
|
|
+ myview->setScene(mpscene);
|
|
|
+
|
|
|
+ myview->centerOn(VIEW_WIDTH/2,VIEW_HEIGHT/2);
|
|
|
+
|
|
|
+ QGraphicsLineItem * plinex = new QGraphicsLineItem(0,RATIO * Y_MOVE,VIEW_WIDTH,RATIO * Y_MOVE);
|
|
|
+ mpscene->addItem(plinex);
|
|
|
+ QGraphicsLineItem * pliney = new QGraphicsLineItem(RATIO * X_MOVE,0,RATIO * X_MOVE,VIEW_HEIGHT);
|
|
|
+ mpscene->addItem(pliney);
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -28,6 +53,42 @@ void MainWindow::on_pushButton_Calc_clicked()
|
|
|
double y = ui->lineEdit_NowY->text().toDouble();
|
|
|
double hdg = ui->lineEdit_NowHdg->text().toDouble();
|
|
|
|
|
|
+ if(mvectoritem.size()>0)
|
|
|
+ {
|
|
|
+ int i;
|
|
|
+ int nsize = static_cast<int>(mvectoritem.size());
|
|
|
+ for(i=0;i<nsize;i++)
|
|
|
+ {
|
|
|
+ mpscene->removeItem(mvectoritem[i]);
|
|
|
+ delete mvectoritem[i];
|
|
|
+ }
|
|
|
+ mvectoritem.clear();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ QGraphicsEllipseItem * pmainitem;
|
|
|
+ pmainitem = new QGraphicsEllipseItem(0-mfMainSize/2.0,0*(-1)-mfMainSize/2.0,mfMainSize,mfMainSize);
|
|
|
+ pmainitem->setBrush(Qt::green);
|
|
|
+ pmainitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = x * RATIO;
|
|
|
+ double y_main = y * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ pmainitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ pmainitem->setScale(fscale);
|
|
|
+ mpscene->addItem(pmainitem);
|
|
|
+ mvectoritem.push_back(pmainitem);
|
|
|
+
|
|
|
+ pmainitem = new QGraphicsEllipseItem(0-mfMainSize/2.0,0*(-1)-mfMainSize/2.0,mfMainSize,mfMainSize);
|
|
|
+ pmainitem->setBrush(Qt::green);
|
|
|
+ pmainitem->setPen(Qt::NoPen);
|
|
|
+ x_main = 0;
|
|
|
+ y_main = 0;
|
|
|
+ fscale = 1.0;
|
|
|
+ pmainitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ pmainitem->setScale(fscale);
|
|
|
+ mpscene->addItem(pmainitem);
|
|
|
+ mvectoritem.push_back(pmainitem);
|
|
|
+
|
|
|
SideParkCalc xPark(x,y,hdg);
|
|
|
xPark.CalcPark();
|
|
|
|
|
@@ -55,7 +116,183 @@ void MainWindow::on_pushButton_Calc_clicked()
|
|
|
snprintf(strtemp,1000,"Point %d x:%6.3f y:%6.3f hdg:%6.3f \n",
|
|
|
i,xvectorsideparkpoint[i].mx,xvectorsideparkpoint[i].my,xvectorsideparkpoint[i].mhdg);
|
|
|
strncat(strout,strtemp,3000);
|
|
|
+
|
|
|
+
|
|
|
+ QGraphicsEllipseItem * pmainitem;
|
|
|
+ pmainitem = new QGraphicsEllipseItem(0-mfMainSize/2.0,0*(-1)-mfMainSize/2.0,mfMainSize,mfMainSize);
|
|
|
+ pmainitem->setBrush(Qt::red);
|
|
|
+ pmainitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = xvectorsideparkpoint[i].mx * RATIO;
|
|
|
+ double y_main = xvectorsideparkpoint[i].my * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ pmainitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ pmainitem->setScale(fscale);
|
|
|
+ mpscene->addItem(pmainitem);
|
|
|
+ mvectoritem.push_back(pmainitem);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(xvectorlen[0]>0)
|
|
|
+ {
|
|
|
+ double x_point,y_point;
|
|
|
+ double fs;
|
|
|
+ fs =0.01;
|
|
|
+ while(fs<xvectorlen[0])
|
|
|
+ {
|
|
|
+ x_point = x + cos(hdg+M_PI)*fs;
|
|
|
+ y_point = y + sin(hdg+M_PI)*fs;
|
|
|
+ fs = fs+ 0.01;
|
|
|
+ QGraphicsEllipseItem * ppointitem;
|
|
|
+ ppointitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
|
|
|
+ ppointitem->setBrush(Qt::green);
|
|
|
+ ppointitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = x_point * RATIO;
|
|
|
+ double y_main = y_point * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ ppointitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ ppointitem->setScale(fscale);
|
|
|
+ mpscene->addItem(ppointitem);
|
|
|
+ mvectoritem.push_back(ppointitem);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ if(xvectorlen[1]>0)
|
|
|
+ {
|
|
|
+ double x_point,y_point;
|
|
|
+ double fs;
|
|
|
+ fs =0.01;
|
|
|
+ double x_center,y_center;
|
|
|
+ if(xvectorwheel[1]>0)
|
|
|
+ {
|
|
|
+ x_center = xvectorsideparkpoint[0].mx + mfRadius * cos(xvectorsideparkpoint[0].mhdg + M_PI/2.0);
|
|
|
+ y_center = xvectorsideparkpoint[0].my + mfRadius * sin(xvectorsideparkpoint[0].mhdg + M_PI/2.0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x_center = xvectorsideparkpoint[0].mx + mfRadius * cos(xvectorsideparkpoint[0].mhdg - M_PI/2.0);
|
|
|
+ y_center = xvectorsideparkpoint[0].my + mfRadius * sin(xvectorsideparkpoint[0].mhdg - M_PI/2.0);
|
|
|
+ }
|
|
|
+ while(fs<xvectorlen[1])
|
|
|
+ {
|
|
|
+ double alpha = xvectorsideparkpoint[0].mhdg + M_PI/2.0 + fs/mfRadius;
|
|
|
+ if(xvectorwheel[1] >0)
|
|
|
+ {
|
|
|
+ alpha = xvectorsideparkpoint[0].mhdg - M_PI/2.0 - fs/mfRadius;
|
|
|
+ }
|
|
|
+
|
|
|
+ x_point = x_center + cos(alpha)*mfRadius;
|
|
|
+ y_point = y_center + sin(alpha)*mfRadius;
|
|
|
+ fs = fs+ 0.01;
|
|
|
+
|
|
|
+ QGraphicsEllipseItem * ppointitem;
|
|
|
+ ppointitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
|
|
|
+ ppointitem->setBrush(Qt::blue);
|
|
|
+ ppointitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = x_point * RATIO;
|
|
|
+ double y_main = y_point * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ ppointitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ ppointitem->setScale(fscale);
|
|
|
+ mpscene->addItem(ppointitem);
|
|
|
+ mvectoritem.push_back(ppointitem);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(xvectorlen[2]>0)
|
|
|
+ {
|
|
|
+ double x_point,y_point;
|
|
|
+ double fs;
|
|
|
+ fs =0.01;
|
|
|
+ while(fs<xvectorlen[2])
|
|
|
+ {
|
|
|
+ x_point = xvectorsideparkpoint[1].mx + cos(xvectorsideparkpoint[1].mhdg+M_PI)*fs;
|
|
|
+ y_point = xvectorsideparkpoint[1].my + sin(xvectorsideparkpoint[1].mhdg+M_PI)*fs;
|
|
|
+ fs = fs+ 0.01;
|
|
|
+ QGraphicsEllipseItem * ppointitem;
|
|
|
+ ppointitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
|
|
|
+ ppointitem->setBrush(Qt::green);
|
|
|
+ ppointitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = x_point * RATIO;
|
|
|
+ double y_main = y_point * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ ppointitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ ppointitem->setScale(fscale);
|
|
|
+ mpscene->addItem(ppointitem);
|
|
|
+ mvectoritem.push_back(ppointitem);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(xvectorlen[3]>0)
|
|
|
+ {
|
|
|
+ double x_point,y_point;
|
|
|
+ double fs;
|
|
|
+ fs =0.01;
|
|
|
+ double x_center,y_center;
|
|
|
+ if(xvectorwheel[3]>0)
|
|
|
+ {
|
|
|
+ x_center = xvectorsideparkpoint[2].mx + mfRadius * cos(xvectorsideparkpoint[2].mhdg + M_PI/2.0);
|
|
|
+ y_center = xvectorsideparkpoint[2].my + mfRadius * sin(xvectorsideparkpoint[2].mhdg + M_PI/2.0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x_center = xvectorsideparkpoint[2].mx + mfRadius * cos(xvectorsideparkpoint[2].mhdg - M_PI/2.0);
|
|
|
+ y_center = xvectorsideparkpoint[2].my + mfRadius * sin(xvectorsideparkpoint[2].mhdg - M_PI/2.0);
|
|
|
+ }
|
|
|
+ while(fs<xvectorlen[3])
|
|
|
+ {
|
|
|
+ double alpha = xvectorsideparkpoint[2].mhdg + M_PI/2.0 + fs/mfRadius;
|
|
|
+ if(xvectorwheel[3] >0)
|
|
|
+ {
|
|
|
+ alpha = xvectorsideparkpoint[2].mhdg - M_PI/2.0 - fs/mfRadius;
|
|
|
+ }
|
|
|
+
|
|
|
+ x_point = x_center + cos(alpha)*mfRadius;
|
|
|
+ y_point = y_center + sin(alpha)*mfRadius;
|
|
|
+ fs = fs+ 0.01;
|
|
|
+
|
|
|
+ QGraphicsEllipseItem * ppointitem;
|
|
|
+ ppointitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
|
|
|
+ ppointitem->setBrush(Qt::blue);
|
|
|
+ ppointitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = x_point * RATIO;
|
|
|
+ double y_main = y_point * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ ppointitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ ppointitem->setScale(fscale);
|
|
|
+ mpscene->addItem(ppointitem);
|
|
|
+ mvectoritem.push_back(ppointitem);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(xvectorlen[4]>0)
|
|
|
+ {
|
|
|
+ double x_point,y_point;
|
|
|
+ double fs;
|
|
|
+ fs =0.01;
|
|
|
+ while(fs<xvectorlen[4])
|
|
|
+ {
|
|
|
+ x_point = xvectorsideparkpoint[3].mx + cos(xvectorsideparkpoint[3].mhdg+M_PI)*fs;
|
|
|
+ y_point = xvectorsideparkpoint[3].my + sin(xvectorsideparkpoint[3].mhdg+M_PI)*fs;
|
|
|
+ fs = fs+ 0.01;
|
|
|
+ QGraphicsEllipseItem * ppointitem;
|
|
|
+ ppointitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
|
|
|
+ ppointitem->setBrush(Qt::green);
|
|
|
+ ppointitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = x_point * RATIO;
|
|
|
+ double y_main = y_point * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ ppointitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ ppointitem->setScale(fscale);
|
|
|
+ mpscene->addItem(ppointitem);
|
|
|
+ mvectoritem.push_back(ppointitem);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
snprintf(strtemp,1000,"\nWheel & Len:\n");strncat(strout,strtemp,3000);
|
|
|
for(i=0;i<5;i++)
|
|
|
{
|
|
@@ -65,6 +302,9 @@ void MainWindow::on_pushButton_Calc_clicked()
|
|
|
}
|
|
|
snprintf(strtemp,1000,"\nTotal Length:%6.3f\n",fTotalLen);strncat(strout,strtemp,3000);
|
|
|
ui->plainTextEdit->setPlainText(strout);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if(xtype == SideParkType::TwoStep)
|
|
@@ -80,6 +320,18 @@ void MainWindow::on_pushButton_Calc_clicked()
|
|
|
snprintf(strtemp,1000,"Point %d x:%6.3f y:%6.3f hdg:%6.3f \n",
|
|
|
i,xvectorsideparkpoint[i].mx,xvectorsideparkpoint[i].my,xvectorsideparkpoint[i].mhdg);
|
|
|
strncat(strout,strtemp,3000);
|
|
|
+
|
|
|
+ QGraphicsEllipseItem * pmainitem;
|
|
|
+ pmainitem = new QGraphicsEllipseItem(0-mfMainSize/2.0,0*(-1)-mfMainSize/2.0,mfMainSize,mfMainSize);
|
|
|
+ pmainitem->setBrush(Qt::red);
|
|
|
+ pmainitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = xvectorsideparkpoint[i].mx * RATIO;
|
|
|
+ double y_main = xvectorsideparkpoint[i].my * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ pmainitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ pmainitem->setScale(fscale);
|
|
|
+ mpscene->addItem(pmainitem);
|
|
|
+ mvectoritem.push_back(pmainitem);
|
|
|
}
|
|
|
snprintf(strtemp,1000,"\nWheel & Len:\n");strncat(strout,strtemp,3000);
|
|
|
for(i=0;i<2;i++)
|
|
@@ -90,6 +342,84 @@ void MainWindow::on_pushButton_Calc_clicked()
|
|
|
}
|
|
|
snprintf(strtemp,1000,"\nTotal Length:%6.3f\n",fTotalLen);strncat(strout,strtemp,3000);
|
|
|
ui->plainTextEdit->setPlainText(strout);
|
|
|
+
|
|
|
+
|
|
|
+ if(xvectorlen[0]>0)
|
|
|
+ {
|
|
|
+ double x_point,y_point;
|
|
|
+ double fs;
|
|
|
+ fs =0.01;
|
|
|
+ double x_center,y_center;
|
|
|
+ double fRadius = 1000.0;
|
|
|
+ if(xvectorwheel[0] != 0)
|
|
|
+ fRadius = mfRadius * mfMaxWheel / fabs(xvectorwheel[0]);
|
|
|
+ if(xvectorwheel[0]>0)
|
|
|
+ {
|
|
|
+ x_center = x + fRadius * cos(hdg + M_PI/2.0);
|
|
|
+ y_center = y + fRadius * sin(hdg + M_PI/2.0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x_center = x + fRadius * cos(hdg - M_PI/2.0);
|
|
|
+ y_center = y + fRadius * sin(hdg - M_PI/2.0);
|
|
|
+ }
|
|
|
+ while(fs<xvectorlen[0])
|
|
|
+ {
|
|
|
+ double alpha = hdg + M_PI/2.0 + fs/fRadius;
|
|
|
+ if(xvectorwheel[0] >0)
|
|
|
+ {
|
|
|
+ alpha = hdg - M_PI/2.0 - fs/fRadius;
|
|
|
+ }
|
|
|
+
|
|
|
+ x_point = x_center + cos(alpha)*fRadius;
|
|
|
+ y_point = y_center + sin(alpha)*fRadius;
|
|
|
+ fs = fs+ 0.01;
|
|
|
+
|
|
|
+ QGraphicsEllipseItem * ppointitem;
|
|
|
+ ppointitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
|
|
|
+ ppointitem->setBrush(Qt::blue);
|
|
|
+ ppointitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = x_point * RATIO;
|
|
|
+ double y_main = y_point * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ ppointitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ ppointitem->setScale(fscale);
|
|
|
+ mpscene->addItem(ppointitem);
|
|
|
+ mvectoritem.push_back(ppointitem);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(xvectorlen[1]>0)
|
|
|
+ {
|
|
|
+ double x_point,y_point;
|
|
|
+ double fs;
|
|
|
+ fs =0.01;
|
|
|
+ while(fs<xvectorlen[1])
|
|
|
+ {
|
|
|
+ x_point = xvectorsideparkpoint[0].mx + cos(xvectorsideparkpoint[0].mhdg+M_PI)*fs;
|
|
|
+ y_point = xvectorsideparkpoint[0].my + sin(xvectorsideparkpoint[0].mhdg+M_PI)*fs;
|
|
|
+ fs = fs+ 0.01;
|
|
|
+ QGraphicsEllipseItem * ppointitem;
|
|
|
+ ppointitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
|
|
|
+ ppointitem->setBrush(Qt::green);
|
|
|
+ ppointitem->setPen(Qt::NoPen);
|
|
|
+ double x_main = x_point * RATIO;
|
|
|
+ double y_main = y_point * RATIO;
|
|
|
+ double fscale = 1.0;
|
|
|
+ ppointitem->setPos(X_MOVE * RATIO + x_main,Y_MOVE *RATIO -y_main);
|
|
|
+ ppointitem->setScale(fscale);
|
|
|
+ mpscene->addItem(ppointitem);
|
|
|
+ mvectoritem.push_back(ppointitem);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ mtype = xtype;
|
|
|
+ mvectorlen = xvectorlen;
|
|
|
+ mvectorsideparkpoint = xvectorsideparkpoint;
|
|
|
+ mvectorwheel = xvectorwheel;
|
|
|
}
|
|
|
|