|
@@ -75,6 +75,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|
// mpaDecition = iv::modulecomm::RegisterRecvPlus("decition",fundecition);
|
|
// mpaDecition = iv::modulecomm::RegisterRecvPlus("decition",fundecition);
|
|
mpaDecition = iv::modulecomm::RegisterRecvPlus("deciton",fundecition);
|
|
mpaDecition = iv::modulecomm::RegisterRecvPlus("deciton",fundecition);
|
|
|
|
|
|
|
|
+ setWindowTitle(tr("Simple Planning Simulator"));
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -101,10 +103,10 @@ void MainWindow::CreateTab1View(QTabWidget * p)
|
|
QGroupBox * pGroup = new QGroupBox();
|
|
QGroupBox * pGroup = new QGroupBox();
|
|
pGroup->setGeometry(0,0,mnFontHeight * 21,mnFontHeight * 160);
|
|
pGroup->setGeometry(0,0,mnFontHeight * 21,mnFontHeight * 160);
|
|
|
|
|
|
- QLabel * pLabel;
|
|
|
|
|
|
+ // QLabel * pLabel;
|
|
QLineEdit * pLE;
|
|
QLineEdit * pLE;
|
|
QPushButton * pPB;
|
|
QPushButton * pPB;
|
|
- QSlider * pSlider;
|
|
|
|
|
|
+ // QSlider * pSlider;
|
|
QComboBox * pCB;
|
|
QComboBox * pCB;
|
|
QCheckBox * pCheck;
|
|
QCheckBox * pCheck;
|
|
|
|
|
|
@@ -113,7 +115,7 @@ void MainWindow::CreateTab1View(QTabWidget * p)
|
|
int nXPos = 10;
|
|
int nXPos = 10;
|
|
int nYPos = 30;
|
|
int nYPos = 30;
|
|
|
|
|
|
- int i;
|
|
|
|
|
|
+ // int i;
|
|
|
|
|
|
int nSpace = mnFontHeight * 65/10;
|
|
int nSpace = mnFontHeight * 65/10;
|
|
int nLEWidth = mnFontHeight * 6;
|
|
int nLEWidth = mnFontHeight * 6;
|
|
@@ -129,7 +131,7 @@ void MainWindow::CreateTab1View(QTabWidget * p)
|
|
pLE->setText("");
|
|
pLE->setText("");
|
|
pLE->setGeometry(nXPos,nYPos,nLEWidth,nLEHeight);
|
|
pLE->setGeometry(nXPos,nYPos,nLEWidth,nLEHeight);
|
|
mpLE_SelY = pLE;
|
|
mpLE_SelY = pLE;
|
|
- nXPos = nXPos + nSpace;
|
|
|
|
|
|
+ // nXPos = nXPos + nSpace;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -246,10 +248,6 @@ void MainWindow::CreateTab1View(QTabWidget * p)
|
|
mpCBSim = pCheck;
|
|
mpCBSim = pCheck;
|
|
connect(mpCBSim,SIGNAL(stateChanged(int)),this,SLOT(onSimStateChanged(int)));
|
|
connect(mpCBSim,SIGNAL(stateChanged(int)),this,SLOT(onSimStateChanged(int)));
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
QScrollArea * pScroll = new QScrollArea();
|
|
QScrollArea * pScroll = new QScrollArea();
|
|
pScroll->setWidget(pGroup);
|
|
pScroll->setWidget(pGroup);
|
|
|
|
|
|
@@ -356,7 +354,7 @@ void MainWindow::on_actionLoad_triggered()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-#include <QtGui>
|
|
|
|
|
|
+//#include <QtGui>
|
|
|
|
|
|
void MainWindow::UpdateScene()
|
|
void MainWindow::UpdateScene()
|
|
{
|
|
{
|
|
@@ -649,6 +647,7 @@ void MainWindow::AddCarObj(double x,double y, double fhdg)
|
|
|
|
|
|
void MainWindow::AddCustomObj(double x,double y, double z,double fhdg,double flen,double fwidth,double fheight)
|
|
void MainWindow::AddCustomObj(double x,double y, double z,double fhdg,double flen,double fwidth,double fheight)
|
|
{
|
|
{
|
|
|
|
+ (void)z;
|
|
double fcustomwidth = fwidth;
|
|
double fcustomwidth = fwidth;
|
|
double fcustomlen = flen;
|
|
double fcustomlen = flen;
|
|
double fcustomheight = fheight;
|
|
double fcustomheight = fheight;
|
|
@@ -700,6 +699,9 @@ void MainWindow::AddObjToVector(double x,double y, double z,double fhdg,double f
|
|
mvectorsimobj.push_back(xsimobj);
|
|
mvectorsimobj.push_back(xsimobj);
|
|
mpCBObj->addItem(QString("Obj")+ QString::number(xsimobj.nshowid));
|
|
mpCBObj->addItem(QString("Obj")+ QString::number(xsimobj.nshowid));
|
|
mpCBObj->setCurrentIndex(mvectorsimobj.size() -1);
|
|
mpCBObj->setCurrentIndex(mvectorsimobj.size() -1);
|
|
|
|
+
|
|
|
|
+ mpsimmodel->AddSimobj(xsimobj);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::DelObjFromVector(unsigned int index)
|
|
void MainWindow::DelObjFromVector(unsigned int index)
|
|
@@ -709,6 +711,8 @@ void MainWindow::DelObjFromVector(unsigned int index)
|
|
mpscene->removeItem(xsimobj.mpobjitem);
|
|
mpscene->removeItem(xsimobj.mpobjitem);
|
|
delete xsimobj.mpobjitem;
|
|
delete xsimobj.mpobjitem;
|
|
mvectorsimobj.erase(mvectorsimobj.begin() + index);
|
|
mvectorsimobj.erase(mvectorsimobj.begin() + index);
|
|
|
|
+
|
|
|
|
+ mpsimmodel->DelSimobj(index);
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::onClickDelObj()
|
|
void MainWindow::onClickDelObj()
|
|
@@ -787,10 +791,12 @@ void MainWindow::onSimStateChanged(int nState)
|
|
{
|
|
{
|
|
if(nState == Qt::Checked)
|
|
if(nState == Qt::Checked)
|
|
{
|
|
{
|
|
|
|
+ mbSimulate = true;
|
|
mpCBShift->setEnabled(false);
|
|
mpCBShift->setEnabled(false);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ mbSimulate = false;
|
|
mpCBShift->setEnabled(true);
|
|
mpCBShift->setEnabled(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -819,7 +825,9 @@ void MainWindow::onTimerUpdateCarPos()
|
|
|
|
|
|
void MainWindow::UpdateDecition(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
void MainWindow::UpdateDecition(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ (void)index;
|
|
|
|
+ (void)dt;
|
|
|
|
+ (void)strmemname;
|
|
iv::brain::decition xdecition;
|
|
iv::brain::decition xdecition;
|
|
if(!xdecition.ParseFromArray(strdata,nSize))
|
|
if(!xdecition.ParseFromArray(strdata,nSize))
|
|
{
|
|
{
|
|
@@ -828,6 +836,92 @@ void MainWindow::UpdateDecition(const char * strdata,const unsigned int nSize,co
|
|
}
|
|
}
|
|
//ServiceCarStatus.mfAcc = xdecition.accelerator(); //
|
|
//ServiceCarStatus.mfAcc = xdecition.accelerator(); //
|
|
|
|
|
|
- mpsimmodel->SetCMD(xdecition.accelerator(),xdecition.torque(),xdecition.brake(),xdecition.wheelangle());
|
|
|
|
|
|
+ if(mbSimulate)
|
|
|
|
+ mpsimmodel->SetCMD(xdecition.accelerator(),xdecition.torque(),xdecition.brake(),xdecition.wheelangle());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void MainWindow::on_actionSaveObject_triggered()
|
|
|
|
+{
|
|
|
|
+ QString str = QFileDialog::getSaveFileName(this,"Save Object",".","*.xml");
|
|
|
|
+ if(str.isEmpty())return;
|
|
|
|
+
|
|
|
|
+ if(str.right(4) != ".xml")str.append(".xml");
|
|
|
|
+
|
|
|
|
+ TiXmlDocument doc;
|
|
|
|
+
|
|
|
|
+ TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
|
|
|
|
+ doc.LinkEndChild( decl );
|
|
|
|
+
|
|
|
|
+ TiXmlElement *rootNode = new TiXmlElement("Objects");
|
|
|
|
+ doc.LinkEndChild(rootNode);
|
|
|
|
+
|
|
|
|
+ // Write objects
|
|
|
|
+ unsigned int nobjsize = mvectorsimobj.size();
|
|
|
|
+ for(unsigned int i=0; i<nobjsize; i++)
|
|
|
|
+ {
|
|
|
|
+ iv::simobj xsimobj = mvectorsimobj[i];
|
|
|
|
+ TiXmlElement *nodeObj = new TiXmlElement("Object");
|
|
|
|
+ rootNode->LinkEndChild(nodeObj);
|
|
|
|
+
|
|
|
|
+ nodeObj->SetDoubleAttribute("x",xsimobj.mfx);
|
|
|
|
+ nodeObj->SetDoubleAttribute("y",xsimobj.mfy);
|
|
|
|
+ nodeObj->SetDoubleAttribute("z",xsimobj.mfz);
|
|
|
|
+ nodeObj->SetDoubleAttribute("hdg",xsimobj.mfhdg);
|
|
|
|
+ nodeObj->SetDoubleAttribute("length",xsimobj.mflen);
|
|
|
|
+ nodeObj->SetDoubleAttribute("width",xsimobj.mfwidth);
|
|
|
|
+ nodeObj->SetDoubleAttribute("height",xsimobj.mfheight);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ doc.SaveFile( str.toStdString() );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void MainWindow::on_actionLoadObject_triggered()
|
|
|
|
+{
|
|
|
|
+ QString str = QFileDialog::getOpenFileName(this,"Save Object",".","*.xml");
|
|
|
|
+ if(str.isEmpty())return;
|
|
|
|
+
|
|
|
|
+ std::vector<iv::simobj> xvectorsimobj;
|
|
|
|
+
|
|
|
|
+ TiXmlDocument doc( str.toStdString() );
|
|
|
|
+ bool loadOkay = doc.LoadFile();
|
|
|
|
+ if (loadOkay)
|
|
|
|
+ {
|
|
|
|
+ TiXmlElement *rootNode=doc.FirstChildElement();
|
|
|
|
+
|
|
|
|
+ TiXmlElement *node = rootNode->FirstChildElement("Object");
|
|
|
|
+ while (node!=0)
|
|
|
|
+ {
|
|
|
|
+ int checker=TIXML_SUCCESS;
|
|
|
|
+ iv::simobj xsimobj;
|
|
|
|
+ checker+=node->QueryDoubleAttribute("x",&xsimobj.mfx);
|
|
|
|
+ checker+=node->QueryDoubleAttribute("y",&xsimobj.mfy);
|
|
|
|
+ checker+=node->QueryDoubleAttribute("z",&xsimobj.mfz);
|
|
|
|
+ checker+=node->QueryDoubleAttribute("hdg",&xsimobj.mfhdg);
|
|
|
|
+ checker+=node->QueryDoubleAttribute("length",&xsimobj.mflen);
|
|
|
|
+ checker+=node->QueryDoubleAttribute("width",&xsimobj.mfwidth);
|
|
|
|
+ checker+=node->QueryDoubleAttribute("height",&xsimobj.mfheight);
|
|
|
|
+
|
|
|
|
+ if(checker == TIXML_SUCCESS)
|
|
|
|
+ {
|
|
|
|
+ xvectorsimobj.push_back(xsimobj);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ node=node->NextSiblingElement("Object");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(xvectorsimobj.size() > 0)
|
|
|
|
+ {
|
|
|
|
+ while(mvectorsimobj.size()>0)DelObjFromVector(0);
|
|
|
|
+ unsigned int i;
|
|
|
|
+ unsigned int nObjSize = xvectorsimobj.size();
|
|
|
|
+ for(i=0;i<nObjSize;i++)
|
|
|
|
+ {
|
|
|
|
+ AddCustomObj(xvectorsimobj[i].mfx,xvectorsimobj[i].mfy,xvectorsimobj[i].mfz,xvectorsimobj[i].mfhdg,xvectorsimobj[i].mflen,xvectorsimobj[i].mfwidth,
|
|
|
|
+ xvectorsimobj[i].mfheight);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|