dialogroadobject_outlines.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. #include "dialogroadobject_outlines.h"
  2. #include "ui_dialogroadobject_outlines.h"
  3. static std::string gstr_e_outlineFillType[] ={"grass","concrete","cobble","asphalt",
  4. "pavement","gravel","soil"};
  5. static const int goutlineFillTypeCount = 7;
  6. static std::string gstr_e_laneType[] = {"shoulder","border","driving","stop","none",
  7. "restricted","parking","median","biking","sidewalk",
  8. "curb","exit","entry","onRamp","offRamp",
  9. "connectingRamp","bidirectional","special1","special2","special3",
  10. "roadWorks","tram","rail","bus","taxi",
  11. "HOV","mwyEntry","mwyExit"};
  12. static const int glaneTypeCount = 33;
  13. DialogRoadObject_Outlines::DialogRoadObject_Outlines(Object * pObject,QWidget *parent) :
  14. QDialog(parent),
  15. ui(new Ui::DialogRoadObject_Outlines)
  16. {
  17. ui->setupUi(this);
  18. mpObject = pObject;
  19. CreateView();
  20. int i;
  21. for(i=0;i<goutlineFillTypeCount;i++)
  22. {
  23. mpCBfillType->addItem(gstr_e_outlineFillType[i].data());
  24. }
  25. mpCBfillType->addItem("NO");
  26. for(i=0;i<glaneTypeCount;i++)
  27. {
  28. mpCBlaneType->addItem(gstr_e_laneType[i].data());
  29. }
  30. mpCBlaneType->addItem("NO");
  31. mpCBouter->addItem("true");
  32. mpCBouter->addItem("false");
  33. mpCBouter->addItem("NO");
  34. mpCBclosed->addItem("true");
  35. mpCBclosed->addItem("false");
  36. mpCBclosed->addItem("NO");
  37. UpdateStatus();
  38. setWindowTitle("Edit Road Object Outlines");
  39. }
  40. DialogRoadObject_Outlines::~DialogRoadObject_Outlines()
  41. {
  42. delete ui;
  43. }
  44. void DialogRoadObject_Outlines::CreateView()
  45. {
  46. int startpos_x = 30;
  47. int startpos_y = 30;
  48. int nSpace = 260;
  49. int nLabelWidth = 80;
  50. int nLEWidth = 150;
  51. int nHeight = 35;
  52. int nVSpace = 60;
  53. int nVIndex = 0;
  54. mpLEstatus = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"status",this);
  55. nVIndex++;
  56. mpLEid = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"id",this);
  57. mpCBfillType = ViewCreate::CreateCB(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"fillType",this);
  58. nVIndex++;
  59. mpCBouter = ViewCreate::CreateCB(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"outer",this);
  60. mpCBclosed = ViewCreate::CreateCB(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"closed",this);
  61. nVIndex++;
  62. mpCBlaneType = ViewCreate::CreateCB(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"laneType",this);
  63. nVIndex++;
  64. int nPBSpace = 150;
  65. int nPBWidth = 100;
  66. mpPBSet = ViewCreate::CreatePB(startpos_x+0*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Set",this);
  67. mpPBReset = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Reset",this);
  68. mpPBChange = ViewCreate::CreatePB(startpos_x+2*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Change",this);
  69. connect(mpPBSet,SIGNAL(clicked(bool)),this,SLOT(onClickSet()));
  70. connect(mpPBReset,SIGNAL(clicked(bool)),this,SLOT(onClickReset()));
  71. connect(mpPBChange,SIGNAL(clicked(bool)),this,SLOT(onClickChange()));
  72. }
  73. void DialogRoadObject_Outlines::onClickSet()
  74. {
  75. Object_outlines xoutlines;
  76. Object * pObject = mpObject;
  77. if(mpObject == 0)return;
  78. Object_outlines_outline xoutline;
  79. if(ViewCreate::CheckLE(mpLEid,"id",false,this) == true)
  80. {
  81. int id = mpLEid->text().toInt();
  82. xoutline.Setid(id);
  83. }
  84. std::string strFillType;
  85. if(mpCBfillType->currentIndex() != goutlineFillTypeCount)
  86. {
  87. strFillType = mpCBfillType->currentText().toStdString();
  88. xoutline.SetfillType(strFillType);
  89. }
  90. bool outer;
  91. if(mpCBouter->currentIndex() == 0)
  92. {
  93. outer = true;
  94. xoutline.Setouter(outer);
  95. }
  96. else
  97. {
  98. if(mpCBouter->currentIndex() == 1)
  99. {
  100. outer = false;
  101. xoutline.Setouter(outer);
  102. }
  103. }
  104. bool closed;
  105. if(mpCBclosed->currentIndex() == 0)
  106. {
  107. closed = true;
  108. xoutline.Setclosed(closed);
  109. }
  110. else
  111. {
  112. if(mpCBclosed->currentIndex() == 1)
  113. {
  114. closed = false;
  115. xoutline.Setclosed(closed);
  116. }
  117. }
  118. std::string strlaneType;
  119. if(mpCBlaneType->currentIndex() != glaneTypeCount)
  120. {
  121. strlaneType = mpCBlaneType->currentText().toStdString();
  122. xoutline.SetlaneType(strlaneType);
  123. }
  124. xoutlines.SetObject_outlines_outline(xoutline);
  125. pObject->Setoutlines(xoutlines);
  126. UpdateStatus();
  127. }
  128. void DialogRoadObject_Outlines::onClickReset()
  129. {
  130. if(mpObject == 0)return;
  131. Object * pObject = mpObject;
  132. pObject->Resetoutlines();
  133. UpdateStatus();
  134. }
  135. void DialogRoadObject_Outlines::onClickChange()
  136. {
  137. if(mpObject == 0)return;
  138. if(mpObject->Getoutlines() == NULL)
  139. {
  140. QMessageBox::warning(this,"Warning","No outlines need change.Please Set.",QMessageBox::YesAll);
  141. return;
  142. }
  143. onClickSet();
  144. QMessageBox::information(this,"Info","Change outlines succefully.",QMessageBox::YesAll);
  145. }
  146. void DialogRoadObject_Outlines::UpdateStatus()
  147. {
  148. int i;
  149. if(mpObject == 0)return;
  150. Object * pObject = mpObject;
  151. Object_outlines * pObject_outlines = pObject->Getoutlines();
  152. if(pObject_outlines == NULL)
  153. {
  154. mpLEid->setText("");
  155. mpCBfillType->setCurrentIndex(goutlineFillTypeCount);
  156. mpCBouter->setCurrentIndex(2);
  157. mpCBclosed->setCurrentIndex(2);
  158. mpCBlaneType->setCurrentIndex(glaneTypeCount);
  159. mpLEstatus->setText("NO outlines");
  160. }
  161. else
  162. {
  163. mpLEstatus->setText("HAVE outlines");
  164. Object_outlines_outline xoutline;
  165. if(pObject_outlines->GetObject_outlines_outline(xoutline) == 1)
  166. {
  167. int id;
  168. if(xoutline.Getid(id) == 1)
  169. {
  170. mpLEid->setText(QString::number(id));
  171. }
  172. else
  173. {
  174. mpLEid->setText("");
  175. }
  176. std::string strfillType;
  177. if(xoutline.GetfillType(strfillType) == 1)
  178. {
  179. int index = goutlineFillTypeCount;
  180. for(i=0;i<goutlineFillTypeCount;i++)
  181. {
  182. if(strfillType == gstr_e_outlineFillType[i])
  183. {
  184. index = i;
  185. break;
  186. }
  187. }
  188. mpCBfillType->setCurrentIndex(index);
  189. }
  190. else
  191. {
  192. mpCBfillType->setCurrentIndex(goutlineFillTypeCount);
  193. }
  194. bool outer;
  195. if(xoutline.Getouter(outer) == 1)
  196. {
  197. if(outer)mpCBouter->setCurrentIndex(0);
  198. else mpCBouter->setCurrentIndex(1);
  199. }
  200. else
  201. {
  202. mpCBouter->setCurrentIndex(2);
  203. }
  204. bool closed;
  205. if(xoutline.Getclosed(closed) == 1)
  206. {
  207. if(closed)mpCBclosed->setCurrentIndex(0);
  208. else mpCBclosed->setCurrentIndex(1);
  209. }
  210. else
  211. {
  212. mpCBclosed->setCurrentIndex(2);
  213. }
  214. std::string strlaneType;
  215. if(xoutline.GetlaneType(strlaneType) == 1)
  216. {
  217. int index = glaneTypeCount;
  218. for(i=0;i<glaneTypeCount;i++)
  219. {
  220. if(strlaneType == gstr_e_laneType[i])
  221. {
  222. index = i;
  223. break;
  224. }
  225. }
  226. mpCBlaneType->setCurrentIndex(index);
  227. }
  228. }
  229. }
  230. }