123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- #include "dialogroadobject_outlines.h"
- #include "ui_dialogroadobject_outlines.h"
- static std::string gstr_e_outlineFillType[] ={"grass","concrete","cobble","asphalt",
- "pavement","gravel","soil"};
- static const int goutlineFillTypeCount = 7;
- static std::string gstr_e_laneType[] = {"shoulder","border","driving","stop","none",
- "restricted","parking","median","biking","sidewalk",
- "curb","exit","entry","onRamp","offRamp",
- "connectingRamp","bidirectional","special1","special2","special3",
- "roadWorks","tram","rail","bus","taxi",
- "HOV","mwyEntry","mwyExit"};
- static const int glaneTypeCount = 33;
- DialogRoadObject_Outlines::DialogRoadObject_Outlines(Object * pObject,QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DialogRoadObject_Outlines)
- {
- ui->setupUi(this);
- mpObject = pObject;
- CreateView();
- int i;
- for(i=0;i<goutlineFillTypeCount;i++)
- {
- mpCBfillType->addItem(gstr_e_outlineFillType[i].data());
- }
- mpCBfillType->addItem("NO");
- for(i=0;i<glaneTypeCount;i++)
- {
- mpCBlaneType->addItem(gstr_e_laneType[i].data());
- }
- mpCBlaneType->addItem("NO");
- mpCBouter->addItem("true");
- mpCBouter->addItem("false");
- mpCBouter->addItem("NO");
- mpCBclosed->addItem("true");
- mpCBclosed->addItem("false");
- mpCBclosed->addItem("NO");
- UpdateStatus();
- setWindowTitle("Edit Road Object Outlines");
- }
- DialogRoadObject_Outlines::~DialogRoadObject_Outlines()
- {
- delete ui;
- }
- void DialogRoadObject_Outlines::CreateView()
- {
- int startpos_x = 30;
- int startpos_y = 30;
- int nSpace = 260;
- int nLabelWidth = 80;
- int nLEWidth = 150;
- int nHeight = 35;
- int nVSpace = 60;
- int nVIndex = 0;
- mpLEstatus = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"status",this);
- nVIndex++;
- mpLEid = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"id",this);
- mpCBfillType = ViewCreate::CreateCB(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"fillType",this);
- nVIndex++;
- mpCBouter = ViewCreate::CreateCB(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"outer",this);
- mpCBclosed = ViewCreate::CreateCB(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"closed",this);
- nVIndex++;
- mpCBlaneType = ViewCreate::CreateCB(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"laneType",this);
- nVIndex++;
- int nPBSpace = 150;
- int nPBWidth = 100;
- mpPBSet = ViewCreate::CreatePB(startpos_x+0*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Set",this);
- mpPBReset = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Reset",this);
- mpPBChange = ViewCreate::CreatePB(startpos_x+2*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Change",this);
- connect(mpPBSet,SIGNAL(clicked(bool)),this,SLOT(onClickSet()));
- connect(mpPBReset,SIGNAL(clicked(bool)),this,SLOT(onClickReset()));
- connect(mpPBChange,SIGNAL(clicked(bool)),this,SLOT(onClickChange()));
- }
- void DialogRoadObject_Outlines::onClickSet()
- {
- Object_outlines xoutlines;
- Object * pObject = mpObject;
- if(mpObject == 0)return;
- Object_outlines_outline xoutline;
- if(ViewCreate::CheckLE(mpLEid,"id",false,this) == true)
- {
- int id = mpLEid->text().toInt();
- xoutline.Setid(id);
- }
- std::string strFillType;
- if(mpCBfillType->currentIndex() != goutlineFillTypeCount)
- {
- strFillType = mpCBfillType->currentText().toStdString();
- xoutline.SetfillType(strFillType);
- }
- bool outer;
- if(mpCBouter->currentIndex() == 0)
- {
- outer = true;
- xoutline.Setouter(outer);
- }
- else
- {
- if(mpCBouter->currentIndex() == 1)
- {
- outer = false;
- xoutline.Setouter(outer);
- }
- }
- bool closed;
- if(mpCBclosed->currentIndex() == 0)
- {
- closed = true;
- xoutline.Setclosed(closed);
- }
- else
- {
- if(mpCBclosed->currentIndex() == 1)
- {
- closed = false;
- xoutline.Setclosed(closed);
- }
- }
- std::string strlaneType;
- if(mpCBlaneType->currentIndex() != glaneTypeCount)
- {
- strlaneType = mpCBlaneType->currentText().toStdString();
- xoutline.SetlaneType(strlaneType);
- }
- xoutlines.SetObject_outlines_outline(xoutline);
- pObject->Setoutlines(xoutlines);
- UpdateStatus();
- }
- void DialogRoadObject_Outlines::onClickReset()
- {
- if(mpObject == 0)return;
- Object * pObject = mpObject;
- pObject->Resetoutlines();
- UpdateStatus();
- }
- void DialogRoadObject_Outlines::onClickChange()
- {
- if(mpObject == 0)return;
- if(mpObject->Getoutlines() == NULL)
- {
- QMessageBox::warning(this,"Warning","No outlines need change.Please Set.",QMessageBox::YesAll);
- return;
- }
- onClickSet();
- QMessageBox::information(this,"Info","Change outlines succefully.",QMessageBox::YesAll);
- }
- void DialogRoadObject_Outlines::UpdateStatus()
- {
- int i;
- if(mpObject == 0)return;
- Object * pObject = mpObject;
- Object_outlines * pObject_outlines = pObject->Getoutlines();
- if(pObject_outlines == NULL)
- {
- mpLEid->setText("");
- mpCBfillType->setCurrentIndex(goutlineFillTypeCount);
- mpCBouter->setCurrentIndex(2);
- mpCBclosed->setCurrentIndex(2);
- mpCBlaneType->setCurrentIndex(glaneTypeCount);
- mpLEstatus->setText("NO outlines");
- }
- else
- {
- mpLEstatus->setText("HAVE outlines");
- Object_outlines_outline xoutline;
- if(pObject_outlines->GetObject_outlines_outline(xoutline) == 1)
- {
- int id;
- if(xoutline.Getid(id) == 1)
- {
- mpLEid->setText(QString::number(id));
- }
- else
- {
- mpLEid->setText("");
- }
- std::string strfillType;
- if(xoutline.GetfillType(strfillType) == 1)
- {
- int index = goutlineFillTypeCount;
- for(i=0;i<goutlineFillTypeCount;i++)
- {
- if(strfillType == gstr_e_outlineFillType[i])
- {
- index = i;
- break;
- }
- }
- mpCBfillType->setCurrentIndex(index);
- }
- else
- {
- mpCBfillType->setCurrentIndex(goutlineFillTypeCount);
- }
- bool outer;
- if(xoutline.Getouter(outer) == 1)
- {
- if(outer)mpCBouter->setCurrentIndex(0);
- else mpCBouter->setCurrentIndex(1);
- }
- else
- {
- mpCBouter->setCurrentIndex(2);
- }
- bool closed;
- if(xoutline.Getclosed(closed) == 1)
- {
- if(closed)mpCBclosed->setCurrentIndex(0);
- else mpCBclosed->setCurrentIndex(1);
- }
- else
- {
- mpCBclosed->setCurrentIndex(2);
- }
- std::string strlaneType;
- if(xoutline.GetlaneType(strlaneType) == 1)
- {
- int index = glaneTypeCount;
- for(i=0;i<glaneTypeCount;i++)
- {
- if(strlaneType == gstr_e_laneType[i])
- {
- index = i;
- break;
- }
- }
- mpCBlaneType->setCurrentIndex(index);
- }
- }
- }
- }
|