#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;iaddItem(gstr_e_outlineFillType[i].data()); } mpCBfillType->addItem("NO"); for(i=0;iaddItem(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;isetCurrentIndex(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;isetCurrentIndex(index); } } } }