dialogroadobject_outlines.cpp 9.8 KB

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