FrmGisSearchF.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "WindowMsgF.h"
  8. #include "CDSCodeF.h"
  9. #include "CDSNodeF.h"
  10. #include "CDSLinkF.h"
  11. #include "CDSServiceLinkF.h"
  12. #include "CDSRoadF.h"
  13. #pragma hdrstop
  14. #include "FrmGisSearchF.h"
  15. #include "ITS00MAPF.h"
  16. //---------------------------------------------------------------------------
  17. #pragma package(smart_init)
  18. #pragma link "cxButtons"
  19. #pragma link "cxCalc"
  20. #pragma link "cxClasses"
  21. #pragma link "cxContainer"
  22. #pragma link "cxControls"
  23. #pragma link "cxCustomData"
  24. #pragma link "cxData"
  25. #pragma link "cxDataStorage"
  26. #pragma link "cxDropDownEdit"
  27. #pragma link "cxEdit"
  28. #pragma link "cxFilter"
  29. #pragma link "cxGraphics"
  30. #pragma link "cxGrid"
  31. #pragma link "cxGridCustomTableView"
  32. #pragma link "cxGridCustomView"
  33. #pragma link "cxGridLevel"
  34. #pragma link "cxGridTableView"
  35. #pragma link "cxLabel"
  36. #pragma link "cxLookAndFeelPainters"
  37. #pragma link "cxLookAndFeels"
  38. #pragma link "cxMaskEdit"
  39. #pragma link "cxStyles"
  40. #pragma link "cxTextEdit"
  41. #pragma link "dxSkinBlack"
  42. #pragma link "dxSkinBlue"
  43. #pragma link "dxSkinsCore"
  44. #pragma link "dxSkinscxPCPainter"
  45. #pragma resource "*.dfm"
  46. TFrmGisSearch *FrmGisSearch = NULL;
  47. //---------------------------------------------------------------------------
  48. __fastcall TFrmGisSearch::TFrmGisSearch(TComponent* Owner)
  49. : TForm(Owner)
  50. {
  51. ITSSkin_Load(this);
  52. CMM_LoadForm(g_sFormsDir, this);
  53. m_pGDC = TvList->DataController;
  54. m_bClose = false;
  55. }
  56. //---------------------------------------------------------------------------
  57. void __fastcall TFrmGisSearch::FormClose(TObject *Sender, TCloseAction &Action)
  58. {
  59. m_bClose = true;
  60. try
  61. {
  62. if (TmrClear->Enabled == true)
  63. {
  64. TmrClear->Enabled = false;
  65. //ITS00MAP->xclntMap->ClearPathInfo();
  66. //ITS00MAP->xclntMap->ReDraw();
  67. }
  68. //if (m_bClose == false)
  69. {
  70. if (ITS00MAP) ITS00MAP->ChkGisSearch->Checked = false;
  71. }
  72. }
  73. catch(...)
  74. {
  75. }
  76. CMM_SaveForm(g_sFormsDir, this);
  77. Action = caFree;
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TFrmGisSearch::FormDestroy(TObject *Sender)
  81. {
  82. FrmGisSearch = NULL;
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TFrmGisSearch::TmrShowTimer(TObject *Sender)
  86. {
  87. Enabled = true;
  88. EdSearch->Enabled = true;
  89. EdSearch->BringToFront();
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TFrmGisSearch::BtnSearchClick(TObject *Sender)
  93. {
  94. Application->ProcessMessages();
  95. TSqlCursor sqlCrs((TControl*)BtnSearch);
  96. SelList();
  97. }
  98. //---------------------------------------------------------------------------
  99. void __fastcall TFrmGisSearch::EdSearchKeyPress(TObject *Sender, wchar_t &Key)
  100. {
  101. if (Key == VK_RETURN)
  102. {
  103. Key = 0;
  104. BtnSearchClick(NULL);
  105. }
  106. }
  107. //---------------------------------------------------------------------------
  108. void __fastcall TFrmGisSearch::SelList()
  109. {
  110. TSqlCursor crs;
  111. String sParam = "";
  112. m_nType = CbType->ItemIndex;
  113. sParam = EdSearch->Text.Trim();
  114. switch(m_nType)
  115. {
  116. case 0: SelNode(sParam); break;
  117. case 1: SelLink(sParam); break;
  118. case 2: SelServiceLink(sParam); break;
  119. case 3: SelRoad(sParam); break;
  120. }
  121. TvList->ApplyBestFit(NULL, false, false);
  122. }
  123. //---------------------------------------------------------------------------
  124. void __fastcall TFrmGisSearch::SelNode(String AParam)
  125. {
  126. Column01->Caption = "노드ID";
  127. Column02->Caption = "노드명";
  128. Column03->Caption = "노드유형";
  129. Column04->Visible = false;
  130. Column05->Visible = false;
  131. Column06->Visible = false;
  132. Column07->Visible = false;
  133. TItsSubCode *pSubCode;
  134. TItsCode *FCodeNodeT = ItsCodeManager->FLists.Find("NDT"); //노드유형
  135. CMM_ClearGridTableView(TvList);
  136. int nRow = 0;
  137. try
  138. {
  139. TvList->BeginUpdate();
  140. try
  141. {
  142. ItsNodeManager->FLists.Lock();
  143. FOR_STL(TItsNode *, pNode, ItsNodeManager->FLists)
  144. {
  145. if (AParam == "" || pNode->NODE_ID.Pos(AParam) ||
  146. pNode->NODE_NAME.Pos(AParam) )
  147. {
  148. nRow = m_pGDC->AppendRecord();
  149. m_pGDC->Values[nRow][Column01->Index] = pNode->NODE_ID; //노드ID
  150. m_pGDC->Values[nRow][Column02->Index] = pNode->NODE_NAME; //교차로명칭
  151. String sNodeType = "[" + pNode->NODE_TYPE + "] ";
  152. if (FCodeNodeT)
  153. {
  154. pSubCode = FCodeNodeT->FSubLists.Find(pNode->NODE_TYPE);
  155. if (pSubCode) sNodeType = sNodeType + pSubCode->CMMN_CD_KOR_NM;
  156. }
  157. m_pGDC->Values[nRow][Column03->Index] = sNodeType; //노드유형
  158. m_pGDC->Values[nRow][Column04->Index] = pNode->X_CRDN; //X 좌표
  159. m_pGDC->Values[nRow][Column05->Index] = pNode->Y_CRDN; //Y 좌표
  160. m_pGDC->Values[nRow][Column99->Index] = (int)pNode;
  161. }
  162. }
  163. }
  164. __finally
  165. {
  166. ItsNodeManager->FLists.UnLock();
  167. }
  168. }
  169. __finally
  170. {
  171. TvList->EndUpdate();
  172. TvList->DataController->GotoFirst();
  173. TvList->DataController->FocusedRecordIndex = 0;
  174. CxList->SetFocus();
  175. }
  176. }
  177. //---------------------------------------------------------------------------
  178. void __fastcall TFrmGisSearch::SelLink(String AParam)
  179. {
  180. Column01->Caption = "링크ID";
  181. Column02->Caption = "도로명";
  182. Column03->Caption = "시작노드";
  183. Column04->Caption = "종료노드";
  184. Column04->Visible = true;
  185. Column05->Visible = false;
  186. Column06->Visible = false;
  187. Column07->Visible = false;
  188. TItsNode *pNode;
  189. CMM_ClearGridTableView(TvList);
  190. int nRow = 0;
  191. try
  192. {
  193. TvList->BeginUpdate();
  194. try
  195. {
  196. ItsLinkManager->FLists.Lock();
  197. FOR_STL(TItsLink*, pLink, ItsLinkManager->FLists)
  198. {
  199. if (AParam == "" || pLink->LINK_ID.Pos(AParam) ||
  200. pLink->ROAD_NAME.Pos(AParam) )
  201. {
  202. nRow = m_pGDC->AppendRecord();
  203. m_pGDC->Values[nRow][Column01->Index] = pLink->LINK_ID;
  204. m_pGDC->Values[nRow][Column02->Index] = pLink->ROAD_NAME; //'도로명';
  205. String sFNodeName = "[" + pLink->F_NODEID + "] ";
  206. pNode = ItsNodeManager->FLists.Find(pLink->F_NODEID);
  207. if (pNode)
  208. sFNodeName = sFNodeName + pNode->NODE_NAME;
  209. m_pGDC->Values[nRow][Column03->Index] = sFNodeName; //'시작노드ID';
  210. String sTNodeName = "[" + pLink->T_NODEID + "] ";
  211. pNode = ItsNodeManager->FLists.Find(pLink->T_NODEID);
  212. if (pNode)
  213. sTNodeName = sTNodeName + pNode->NODE_NAME;
  214. m_pGDC->Values[nRow][Column04->Index] = sTNodeName; //'종료노드ID';
  215. m_pGDC->Values[nRow][Column99->Index] = (int)pLink;
  216. }
  217. }
  218. }
  219. __finally
  220. {
  221. ItsLinkManager->FLists.UnLock();
  222. }
  223. }
  224. __finally
  225. {
  226. TvList->EndUpdate();
  227. TvList->DataController->GotoFirst();
  228. TvList->DataController->FocusedRecordIndex = 0;
  229. CxList->SetFocus();
  230. }
  231. }
  232. //---------------------------------------------------------------------------
  233. void __fastcall TFrmGisSearch::SelServiceLink(String AParam)
  234. {
  235. Column01->Caption = "ID";
  236. Column02->Caption = "명칭";
  237. Column03->Caption = "방향";
  238. Column04->Caption = "시점명";
  239. Column05->Caption = "종점명";
  240. Column04->Visible = true;
  241. Column05->Visible = true;
  242. Column06->Visible = false;
  243. Column07->Visible = false;
  244. TItsSubCode *pSubCode;
  245. TItsCode *FCodeIFD = ItsCodeManager->FLists.Find("IFD"); // 방향코드
  246. CMM_ClearGridTableView(TvList);
  247. int nRow = 0;
  248. try
  249. {
  250. TvList->BeginUpdate();
  251. try
  252. {
  253. ItsServiceLinkManager->FLists.Lock();
  254. FOR_STL(TItsServiceLink*, pServiceLink, ItsServiceLinkManager->FLists)
  255. {
  256. if (AParam == "" || pServiceLink->IFSC_ID.Pos(AParam) ||
  257. pServiceLink->IFSC_NM.Pos(AParam) )
  258. {
  259. nRow = m_pGDC->AppendRecord();
  260. m_pGDC->Values[nRow][Column01->Index] = pServiceLink->IFSC_ID; //'정보제공구간 ID'
  261. m_pGDC->Values[nRow][Column02->Index] = pServiceLink->IFSC_NM; //'정보제공구간 명'
  262. String sIFD = "[" + pServiceLink->DRCT_CD + "] ";
  263. pSubCode = FCodeIFD->FSubLists.Find(pServiceLink->DRCT_CD); // 방향코드
  264. if (pSubCode) sIFD = sIFD + pSubCode->CMMN_CD_KOR_NM;
  265. m_pGDC->Values[nRow][Column03->Index] = sIFD; //'방향 코드'
  266. m_pGDC->Values[nRow][Column04->Index] = pServiceLink->STRT_NM; //'시점 명'
  267. m_pGDC->Values[nRow][Column05->Index] = pServiceLink->END_NM; //'종점 명'
  268. m_pGDC->Values[nRow][Column99->Index] = (int)pServiceLink;
  269. }
  270. }
  271. }
  272. __finally
  273. {
  274. ItsServiceLinkManager->FLists.UnLock();
  275. }
  276. }
  277. __finally
  278. {
  279. TvList->EndUpdate();
  280. TvList->DataController->GotoFirst();
  281. TvList->DataController->FocusedRecordIndex = 0;
  282. CxList->SetFocus();
  283. }
  284. }
  285. //---------------------------------------------------------------------------
  286. void __fastcall TFrmGisSearch::SelRoad(String AParam)
  287. {
  288. Column01->Caption = "ID";
  289. Column02->Caption = "명칭";
  290. Column03->Caption = "방향";
  291. Column04->Caption = "시점명";
  292. Column05->Caption = "종점명";
  293. Column04->Visible = true;
  294. Column05->Visible = true;
  295. Column06->Visible = false;
  296. Column07->Visible = false;
  297. TItsSubCode *pSubCode;
  298. TItsCode *FCodeIFD = ItsCodeManager->FLists.Find("IFD"); // 방향코드
  299. CMM_ClearGridTableView(TvList);
  300. int nRow = 0;
  301. try
  302. {
  303. TvList->BeginUpdate();
  304. try
  305. {
  306. ItsRoadManager->FLists.Lock();
  307. FOR_STL(TItsRoad*, pRoad, ItsRoadManager->FLists)
  308. {
  309. if (AParam == "" || pRoad->ROAD_ID.Pos(AParam) ||
  310. pRoad->ROAD_NAME.Pos(AParam) )
  311. {
  312. nRow = m_pGDC->AppendRecord();
  313. m_pGDC->Values[nRow][Column01->Index] = pRoad->ROAD_ID; //'도로 ID'
  314. m_pGDC->Values[nRow][Column02->Index] = pRoad->ROAD_NAME; //'도로명'
  315. String sIFD = "[" + pRoad->DRCT_CD + "] ";
  316. pSubCode = FCodeIFD->FSubLists.Find(pRoad->DRCT_CD); // 방향코드
  317. if (pSubCode) sIFD = sIFD + pSubCode->CMMN_CD_KOR_NM;
  318. m_pGDC->Values[nRow][Column03->Index] = sIFD; //'방향 코드'
  319. m_pGDC->Values[nRow][Column04->Index] = pRoad->STRT_NM; //'시점 명'
  320. m_pGDC->Values[nRow][Column05->Index] = pRoad->END_NM; //'종점 명'
  321. m_pGDC->Values[nRow][Column99->Index] = (int)pRoad;
  322. }
  323. }
  324. }
  325. __finally
  326. {
  327. ItsRoadManager->FLists.UnLock();
  328. }
  329. }
  330. __finally
  331. {
  332. TvList->EndUpdate();
  333. TvList->DataController->GotoFirst();
  334. TvList->DataController->FocusedRecordIndex = 0;
  335. CxList->SetFocus();
  336. }
  337. }
  338. //---------------------------------------------------------------------------
  339. void __fastcall TFrmGisSearch::SelGisItem()
  340. {
  341. try
  342. {
  343. int nIndex = m_pGDC->FocusedRecordIndex;
  344. if (nIndex < 0) return;
  345. String sId = VarToStr(m_pGDC->Values[nIndex][Column01->Index]);
  346. TmrClear->Enabled = false;
  347. ITS00MAP->SelGisItem(m_nType, sId);
  348. TmrClear->Enabled = true;
  349. }
  350. catch(...)
  351. {
  352. }
  353. }
  354. //---------------------------------------------------------------------------
  355. void __fastcall TFrmGisSearch::TmrClearTimer(TObject *Sender)
  356. {
  357. try {
  358. //TXiMapUtil::ClearPath(ITS00MAP->xclntMap);
  359. } catch(...) {}
  360. }
  361. //---------------------------------------------------------------------------
  362. void __fastcall TFrmGisSearch::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  363. TMouseButton AButton, TShiftState AShift, bool &AHandled)
  364. {
  365. if (ACellViewInfo)
  366. {
  367. SelGisItem();
  368. }
  369. }
  370. //---------------------------------------------------------------------------
  371. void __fastcall TFrmGisSearch::TvListDataControllerFilterChanged(TObject *Sender)
  372. {
  373. CMM_SetFilterLike(TvList);
  374. }
  375. //---------------------------------------------------------------------------