ITSSELAMF.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /****************************************************************************
  2. * @source :
  3. * @description :
  4. ****************************************************************************
  5. * DATE AUTHOR DESCRIPTION
  6. * --------------------------------------------------------------------------
  7. * 2011/12/24 정승호 최초작성
  8. *
  9. ****************************************************************************/
  10. //---------------------------------------------------------------------------
  11. #include <vcl.h>
  12. #include "ITSSkinF.h"
  13. #include "ITSUtilF.h"
  14. #include "AppGlobalF.h"
  15. #include "CDSNodeF.h"
  16. #include "CDSLinkF.h"
  17. #include "CDSServiceLinkF.h"
  18. #include "XiMapUtilF.h"
  19. #pragma hdrstop
  20. #include "ITSSELAMF.h"
  21. //---------------------------------------------------------------------------
  22. #pragma package(smart_init)
  23. #pragma link "cxButtons"
  24. #pragma link "cxContainer"
  25. #pragma link "cxControls"
  26. #pragma link "cxEdit"
  27. #pragma link "cxGraphics"
  28. #pragma link "cxGroupBox"
  29. #pragma link "cxLookAndFeelPainters"
  30. #pragma link "cxLookAndFeels"
  31. #pragma link "cxPC"
  32. #pragma link "cxPCdxBarPopupMenu"
  33. #pragma link "cxSplitter"
  34. #pragma link "dxSkinBlack"
  35. #pragma link "dxSkinBlue"
  36. #pragma link "dxSkinCaramel"
  37. #pragma link "dxSkinCoffee"
  38. #pragma link "dxSkinDarkRoom"
  39. #pragma link "dxSkinDarkSide"
  40. #pragma link "dxSkinFoggy"
  41. #pragma link "dxSkinGlassOceans"
  42. #pragma link "dxSkiniMaginary"
  43. #pragma link "dxSkinLilian"
  44. #pragma link "dxSkinLiquidSky"
  45. #pragma link "dxSkinLondonLiquidSky"
  46. #pragma link "dxSkinMcSkin"
  47. #pragma link "dxSkinMoneyTwins"
  48. #pragma link "dxSkinOffice2007Black"
  49. #pragma link "dxSkinOffice2007Blue"
  50. #pragma link "dxSkinOffice2007Green"
  51. #pragma link "dxSkinOffice2007Pink"
  52. #pragma link "dxSkinOffice2007Silver"
  53. #pragma link "dxSkinOffice2010Black"
  54. #pragma link "dxSkinOffice2010Blue"
  55. #pragma link "dxSkinOffice2010Silver"
  56. #pragma link "dxSkinsCore"
  57. #pragma link "dxSkinscxPCPainter"
  58. #pragma link "dxSkinSeven"
  59. #pragma link "dxSkinSharp"
  60. #pragma link "dxSkinSilver"
  61. #pragma link "dxSkinStardust"
  62. #pragma link "FRAME_GisMapF"
  63. #pragma link "FRAME_LinkListF"
  64. #pragma link "FRAME_NodeListF"
  65. #pragma link "FRAME_RoadListF"
  66. #pragma link "FRAME_ServiceLinkListF"
  67. #pragma link "cxLabel"
  68. #pragma link "cxTextEdit"
  69. #pragma link "cxCalc"
  70. #pragma link "cxCalendar"
  71. #pragma link "cxClasses"
  72. #pragma link "cxCustomData"
  73. #pragma link "cxData"
  74. #pragma link "cxDataStorage"
  75. #pragma link "cxFilter"
  76. #pragma link "cxGrid"
  77. #pragma link "cxGridCustomTableView"
  78. #pragma link "cxGridCustomView"
  79. #pragma link "cxGridLevel"
  80. #pragma link "cxGridTableView"
  81. #pragma link "cxSpinEdit"
  82. #pragma link "cxStyles"
  83. #pragma resource "*.dfm"
  84. TITSSELAM *ITSSELAM = NULL;
  85. const String LEVEL1_LINK_LAYER_NAME = "GD_LINK_LV7.dvf";
  86. const String LEVEL2_LINK_LAYER_NAME = "GD_LINK_LV6.dvf";
  87. const String LEVEL3_LINK_LAYER_NAME = "GD_LINK_LV5.dvf";
  88. const String LEVEL1_NODE_LAYER_NAME = "GD_NODE_LV7.dvf";
  89. const String LEVEL2_NODE_LAYER_NAME = "GD_NODE_LV6.dvf";
  90. const String LEVEL3_NODE_LAYER_NAME = "GD_NODE_LV5.dvf";
  91. //---------------------------------------------------------------------------
  92. __fastcall TITSSELAM::TITSSELAM(TComponent* Owner)
  93. : TForm(Owner)
  94. {
  95. ITSSkin_Load(this);
  96. CMM_LoadForm(g_sFormsDir, this);
  97. FTitle = "구간 선택";
  98. FRefreshId = "";
  99. FSelPosX = "0";
  100. FSelPosY = "0";
  101. FLinkLevel = 1;
  102. FSelected = false;
  103. FMultiSelect = false;
  104. FLinkId = "";
  105. FPosX = FPosY = 0;
  106. FMouseDownPosX = FMouseDownPosY = 0;
  107. PgList->Properties->ActivePage = TabNode;
  108. TvList->OptionsView->NoDataToDisplayInfoText = "<선택구간목록>";
  109. FRAMENodeList1->PnlTop->Visible = false;
  110. //FRAMENodeList1->PnlBottom->Visible = false;
  111. FRAMELinkList1->PnlTop->Visible = false;
  112. //FRAMELinkList1->PnlBottom->Visible = false;
  113. FRAMEServiceLinkList1->PnlTop->Visible = false;
  114. //FRAMEServiceLinkList1->PnlBottom->Visible = false;
  115. FRAMERoadList1->PnlTop->Visible = false;
  116. //FRAMERoadList1->PnlBottom->Visible = false;
  117. }
  118. //---------------------------------------------------------------------------
  119. /*
  120. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  121. * Form과 DataModule class를 delete시킨다.
  122. * arguments
  123. *
  124. * return
  125. * void
  126. */
  127. void __fastcall TITSSELAM::CommClose()
  128. {
  129. try
  130. {
  131. CMM_SaveForm(g_sFormsDir, this);
  132. }
  133. catch(...)
  134. {
  135. }
  136. }
  137. //---------------------------------------------------------------------------
  138. /*
  139. * Form을 보여줄때 호출되는 event 메서드이다.
  140. * arguments
  141. * Sender : event handler 객체
  142. * return
  143. * void
  144. */
  145. void __fastcall TITSSELAM::FormShow(TObject *Sender)
  146. {
  147. Refresh();
  148. FormInit();
  149. TmrShow->Enabled = true;
  150. }
  151. //---------------------------------------------------------------------------
  152. void __fastcall TITSSELAM::SetLinkLevel(int ALinkLevel)
  153. {
  154. TabLink->Visible = false;
  155. TabLink->TabVisible = false;
  156. TabServiceLink->Visible = false;
  157. TabServiceLink->TabVisible = false;
  158. TabRoad->Visible = false;
  159. TabRoad->TabVisible = false;
  160. switch(ALinkLevel)
  161. {
  162. case 1:
  163. FRAMELinkList1->UpdateList();
  164. TabLink->Visible = true;
  165. TabLink->TabVisible = true;
  166. break;
  167. case 2:
  168. FRAMEServiceLinkList1->UpdateList();
  169. TabServiceLink->Visible = true;
  170. TabServiceLink->TabVisible = true;
  171. break;
  172. case 3:
  173. FRAMERoadList1->UpdateList();
  174. TabRoad->Visible = true;
  175. TabRoad->TabVisible = true;
  176. break;
  177. default: return;
  178. }
  179. FLinkLevel = ALinkLevel;
  180. FRAMEGisMap1->LinkLevel = ALinkLevel;
  181. }
  182. //---------------------------------------------------------------------------
  183. /*
  184. * form 초기화
  185. *
  186. * arguments
  187. *
  188. * return
  189. * void
  190. */
  191. void __fastcall TITSSELAM::FormInit()
  192. {
  193. FRAMENodeList1->UpdateList();
  194. }
  195. //---------------------------------------------------------------------------
  196. /*
  197. * Form이 Show되고 난 후 최초 1회 수행되는 타이머 이벤트
  198. * arguments
  199. * Sender : event handler 객체
  200. * return
  201. * void
  202. */
  203. void __fastcall TITSSELAM::TmrShowTimer(TObject *Sender)
  204. {
  205. TmrShow->Enabled = false;
  206. FRAMEGisMap1->LoadGisMap();
  207. BtnSearchClick((TObject*)BtnSearch);
  208. Application->ProcessMessages();
  209. RefreshId();
  210. }
  211. //---------------------------------------------------------------------------
  212. void __fastcall TITSSELAM::RefreshId()
  213. {
  214. if (FRefreshId.IsEmpty()) return;
  215. SelGisItem(FLinkLevel, FRefreshId);
  216. Application->ProcessMessages();
  217. }
  218. //---------------------------------------------------------------------------
  219. /*
  220. * Search 버튼 클릭 이벤트 핸들러
  221. * arguments
  222. * Sender : event handler 객체
  223. * return
  224. * void
  225. */
  226. void __fastcall TITSSELAM::BtnSearchClick(TObject *Sender)
  227. {
  228. RefreshData();
  229. }
  230. //---------------------------------------------------------------------------
  231. /*
  232. * Refresh Data Event Function
  233. * arguments
  234. *
  235. * return
  236. * void
  237. */
  238. void __fastcall TITSSELAM::RefreshData()
  239. {
  240. }
  241. //---------------------------------------------------------------------------
  242. void __fastcall TITSSELAM::SelListData()
  243. {
  244. }
  245. //---------------------------------------------------------------------------
  246. /*
  247. * Close 버튼 클릭 이벤트 핸들러
  248. * arguments
  249. * Sender : event handler 객체
  250. * return
  251. * void
  252. */
  253. void __fastcall TITSSELAM::BtnCloseClick(TObject *Sender)
  254. {
  255. Close();
  256. }
  257. //---------------------------------------------------------------------------
  258. void __fastcall TITSSELAM::FormClose(TObject *Sender, TCloseAction &Action)
  259. {
  260. CommClose();
  261. ITSSELAM = NULL;
  262. //Action = caFree;
  263. }
  264. //---------------------------------------------------------------------------
  265. void __fastcall TITSSELAM::FRAMENodeList1TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  266. TMouseButton AButton, TShiftState AShift, bool &AHandled)
  267. {
  268. int nIndex = Sender->DataController->FocusedRecordIndex;
  269. if (nIndex < 0) return;
  270. SelGisItem(0, Sender->DataController->Values[nIndex][FRAMENodeList1->Column01->Index]);
  271. }
  272. //---------------------------------------------------------------------------
  273. void __fastcall TITSSELAM::FRAMELinkList1TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  274. TMouseButton AButton, TShiftState AShift, bool &AHandled)
  275. {
  276. int nIndex = Sender->DataController->FocusedRecordIndex;
  277. if (nIndex < 0) return;
  278. SelGisItem(1, Sender->DataController->Values[nIndex][FRAMELinkList1->Column01->Index]);
  279. }
  280. //---------------------------------------------------------------------------
  281. void __fastcall TITSSELAM::FRAMEServiceLinkList1TvListCellClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  282. TMouseButton AButton, TShiftState AShift, bool &AHandled)
  283. {
  284. int nIndex = Sender->DataController->FocusedRecordIndex;
  285. if (nIndex < 0) return;
  286. SelGisItem(2, Sender->DataController->Values[nIndex][FRAMEServiceLinkList1->Column01->Index]);
  287. }
  288. //---------------------------------------------------------------------------
  289. void __fastcall TITSSELAM::FRAMERoadList1TvListCellClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  290. TMouseButton AButton, TShiftState AShift, bool &AHandled)
  291. {
  292. int nIndex = Sender->DataController->FocusedRecordIndex;
  293. if (nIndex < 0) return;
  294. SelGisItem(3, Sender->DataController->Values[nIndex][FRAMERoadList1->Column01->Index]);
  295. }
  296. //---------------------------------------------------------------------------
  297. void __fastcall TITSSELAM::BtnSelectClick(TObject *Sender)
  298. {
  299. if (TvList->DataController->RecordCount <= 0)
  300. {
  301. Application->MessageBox(L"구간이 선택되지 않았습니다.\r\n지도에서 구간을 선택하세요.",
  302. FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  303. return;
  304. }
  305. FLinkId = EdLinkId->Text.Trim();
  306. FSelected = true;
  307. Close();
  308. Application->ProcessMessages();
  309. }
  310. //---------------------------------------------------------------------------
  311. void __fastcall TITSSELAM::FRAMEGisMap1xclntMapMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
  312. {
  313. if (!FRAMEGisMap1->xclntMap->IsStart()) return;
  314. TDDPoint dptCurr = FRAMEGisMap1->xclntMap->ScreenToReal(Point(X, Y));
  315. try {
  316. String sMousePos = FormatFloat("##,##0.#####0", dptCurr.X) + " " + FormatFloat("##,##0.#####0", dptCurr.Y);
  317. StatusBar->Panels->Items[1]->Text = sMousePos;
  318. } catch(...) {}
  319. }
  320. //---------------------------------------------------------------------------
  321. void __fastcall TITSSELAM::FRAMEGisMap1xclntMapMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
  322. {
  323. if (Button != mbLeft) return;
  324. if (FRAMEGisMap1->xclntMap->MapOperation != OnSelect) return;
  325. FRAMEGisMap1->xclntMap->SetFocus();
  326. FMouseDownPosX = X;
  327. FMouseDownPosY = Y;
  328. TDDPoint dptCurr = FRAMEGisMap1->xclntMap->ScreenToReal(Point( X, Y));
  329. FPosX = dptCurr.X;
  330. FPosY = dptCurr.Y;
  331. try {
  332. String sMousePos = FormatFloat("##,##0.#####0", dptCurr.X) + "/" + FormatFloat("##,##0.#####0", dptCurr.Y);
  333. StatusBar->Panels->Items[1]->Text = sMousePos;
  334. EdPos->Text = sMousePos;
  335. } catch(...) {}
  336. if (FRAMEGisMap1->xclntMap->MouseTaget != 0)
  337. return;
  338. String sLinkId = "";
  339. if (GetLinkId(X, Y, sLinkId))
  340. {
  341. //DB에 존재하는지 체크하려면 여기서 하자.
  342. UpdateSelect(sLinkId, dptCurr.X, dptCurr.Y);
  343. #if 1
  344. if (!FMultiSelect)
  345. {
  346. FRAMEGisMap1->xclntMap->ClearAccEvent( true );
  347. FRAMEGisMap1->xclntMap->ADDAccEvent(dptCurr,
  348. "현재 선택 좌표",
  349. "선택 링크 및 좌표",
  350. AnsiString().sprintf( "현재 선택 좌표|X : %03.08f|Y : %02.08f", dptCurr.X, dptCurr.Y ).c_str(),
  351. -1, true, 1, 7);
  352. FRAMEGisMap1->xclntMap->ReDraw( );
  353. }
  354. #endif
  355. }
  356. }
  357. //---------------------------------------------------------------------------
  358. void __fastcall TITSSELAM::FRAMEGisMap1xclntMapMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
  359. {
  360. #if 0
  361. FLinkId = "";
  362. EdLinkId->Text = "";
  363. if (FMouseDownPosX == X && FMouseDownPosY == Y)
  364. {
  365. if (FRAMEGisMap1->xclntMap->MouseTaget != 0)
  366. return;
  367. int nLayerIdx = GetLayerIndex();
  368. if (nLayerIdx < 0) return;
  369. FRAMEGisMap1->xclntMap->ClearUserDrawPolyGon();
  370. TXiMapUtil::SelectLinkByPos(FRAMEGisMap1->xsrvrMap, FRAMEGisMap1->xclntMap, nLayerIdx, X, Y, FLinkId);
  371. EdLinkId->Text = FLinkId;
  372. FRAMEGisMap1->xclntMap->ReDraw();
  373. }
  374. #endif
  375. }
  376. //---------------------------------------------------------------------------
  377. int __fastcall TITSSELAM::GetLayerIndex()
  378. {
  379. int nLayerIdx = 0;
  380. int nLevel = FRAMEGisMap1->xclntMap->GetLevel();
  381. switch(FLinkLevel)
  382. {
  383. case 2: nLayerIdx = FRAMEGisMap1->xclntMap->GetLayerIndex(LEVEL2_LINK_LAYER_NAME); break;
  384. case 3: nLayerIdx = FRAMEGisMap1->xclntMap->GetLayerIndex(LEVEL3_LINK_LAYER_NAME); break;
  385. default:nLayerIdx = FRAMEGisMap1->xclntMap->GetLayerIndex(LEVEL1_LINK_LAYER_NAME); break;
  386. }
  387. return nLayerIdx;
  388. }
  389. //---------------------------------------------------------------------------
  390. void __fastcall TITSSELAM::SelGisItem(int AType, String AId)
  391. {
  392. try
  393. {
  394. switch(AType)
  395. {
  396. case 0: TXiMapUtil::MoveNode(FRAMEGisMap1->xclntMap, AId); break;
  397. case 1: TXiMapUtil::MoveLink(FRAMEGisMap1->xclntMap, AId); break;
  398. case 2: TXiMapUtil::MoveServiceLink(FRAMEGisMap1->xclntMap, AId); break;
  399. case 3: TXiMapUtil::MoveRoad(FRAMEGisMap1->xclntMap, AId); break;
  400. default: return;
  401. }
  402. }
  403. catch(...)
  404. {
  405. }
  406. }
  407. //---------------------------------------------------------------------------
  408. void __fastcall TITSSELAM::BtnDeleteClick(TObject *Sender)
  409. {
  410. try
  411. {
  412. TvList->BeginUpdate();
  413. try
  414. {
  415. TvList->Controller->DeleteSelection();
  416. }
  417. catch(...)
  418. {
  419. }
  420. }
  421. __finally
  422. {
  423. TvList->EndUpdate();
  424. }
  425. RefreshSelect();
  426. }
  427. //---------------------------------------------------------------------------
  428. bool __fastcall TITSSELAM::GetLinkId(int X, int Y, String &ALinkId)
  429. {
  430. ALinkId = "";
  431. int nLayerIdx = GetLayerIndex();
  432. if (nLayerIdx < 0) return false;
  433. TStringList *slFldName = NULL;
  434. TStringList *slFldValue = NULL;
  435. try
  436. {
  437. slFldName = new TStringList();
  438. slFldValue = new TStringList();
  439. try
  440. {
  441. //TDDPoint dptCurr = MapClient->ScreenToReal(Point(X, Y));
  442. // 링크에 대한 공간정보를 검색
  443. if (FRAMEGisMap1->xsrvrMap->ShpObjInfo(X, Y, nLayerIdx, slFldName, slFldValue, clWhite, true, false))
  444. {
  445. if (slFldName->Count != slFldValue->Count)
  446. {
  447. return false;
  448. }
  449. ALinkId = slFldValue->Strings[1];
  450. return true;
  451. }
  452. }
  453. catch(...)
  454. {
  455. }
  456. }
  457. __finally
  458. {
  459. if (slFldName) delete slFldName;
  460. if (slFldValue) delete slFldValue;
  461. }
  462. return false;
  463. }
  464. //---------------------------------------------------------------------------
  465. void __fastcall TITSSELAM::UpdateSelect(String ALinkId, double X, double Y)
  466. {
  467. try
  468. {
  469. int nRow;
  470. TcxDataController *pGDC = TvList->DataController;
  471. TvList->BeginUpdate();
  472. try
  473. {
  474. bool bAdd = true;
  475. if (!FMultiSelect)
  476. {
  477. CMM_ClearGridTableView(TvList);
  478. }
  479. else
  480. {
  481. for (int ii = 0; ii < pGDC->RecordCount; ii++)
  482. {
  483. String sTmpLinkId = pGDC->Values[ii][Column01->Index];
  484. if (sTmpLinkId == ALinkId)
  485. {
  486. pGDC->Values[ii][Column02->Index] = X;
  487. pGDC->Values[ii][Column03->Index] = Y;
  488. bAdd = false;
  489. break;
  490. }
  491. }
  492. }
  493. if (bAdd)
  494. {
  495. nRow = pGDC->AppendRecord();
  496. pGDC->Values[nRow][Column01->Index] = ALinkId;
  497. pGDC->Values[nRow][Column02->Index] = X;
  498. pGDC->Values[nRow][Column03->Index] = Y;
  499. }
  500. }
  501. catch(...)
  502. {
  503. }
  504. }
  505. __finally
  506. {
  507. TvList->EndUpdate();
  508. }
  509. RefreshSelect();
  510. }
  511. //---------------------------------------------------------------------------
  512. void __fastcall TITSSELAM::RefreshSelect()
  513. {
  514. FRAMEGisMap1->xclntMap->ClearPathInfo();
  515. FRAMEGisMap1->xclntMap->ReDraw();
  516. int nLayerIdx = GetLayerIndex();
  517. if (nLayerIdx < 0) return;
  518. try
  519. {
  520. int nRow;
  521. TcxDataController *pGDC = TvList->DataController;
  522. TvList->BeginUpdate();
  523. try
  524. {
  525. for (int ii = 0; ii < pGDC->RecordCount; ii++)
  526. {
  527. String sLinkId = pGDC->Values[ii][Column01->Index];
  528. TXiMapUtil::SelectLinkById(FRAMEGisMap1->xsrvrMap, FRAMEGisMap1->xclntMap, nLayerIdx, sLinkId);
  529. }
  530. }
  531. catch(...)
  532. {
  533. }
  534. }
  535. __finally
  536. {
  537. TvList->EndUpdate();
  538. }
  539. FRAMEGisMap1->xclntMap->ReDraw();
  540. }
  541. //---------------------------------------------------------------------------