//--------------------------------------------------------------------------- #include #include "ITSSkinF.h" #include "ITSUtilF.h" #include "AppGlobalF.h" #include "CDSNodeF.h" #include "CDSLinkF.h" #include "CDSIfscF.h" #include "CDSRoadF.h" #include "ITSLangTransF.h" #pragma hdrstop #include "ITSSELAMF.h" #include "CommFlashF.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "cxButtons" #pragma link "cxCalc" #pragma link "cxClasses" #pragma link "cxContainer" #pragma link "cxControls" #pragma link "cxCustomData" #pragma link "cxData" #pragma link "cxDataStorage" #pragma link "cxEdit" #pragma link "cxFilter" #pragma link "cxGraphics" #pragma link "cxGrid" #pragma link "cxGridCustomTableView" #pragma link "cxGridCustomView" #pragma link "cxGridLevel" #pragma link "cxGridTableView" #pragma link "cxGroupBox" #pragma link "cxLabel" #pragma link "cxLookAndFeelPainters" #pragma link "cxLookAndFeels" #pragma link "cxPC" #pragma link "cxPCdxBarPopupMenu" #pragma link "cxSplitter" #pragma link "cxStyles" #pragma link "cxTextEdit" #pragma link "dxSkinBlack" #pragma link "dxSkinBlue" #pragma link "dxSkinsCore" #pragma link "dxSkinscxPCPainter" #pragma link "FRAME_GoogleMapF" #pragma link "FRAME_LinkListF" #pragma link "FRAME_NodeListF" #pragma link "FRAME_RoadListF" #pragma link "FRAME_ServiceLinkListF" #pragma link "GMClasses" #pragma link "GMLinkedComponents" #pragma link "GMMap" #pragma link "GMPolyline" #pragma link "GMPolylineVCL" #pragma link "GMMarker" #pragma link "GMMarkerVCL" #pragma resource "*.dfm" TITSSELAM *ITSSELAM = NULL; //--------------------------------------------------------------------------- __fastcall TITSSELAM::TITSSELAM(TComponent* Owner, int ALinkLevel/*=1*/) : TForm(Owner) { LangTrans->Translate(this, ITSDb_GetConnection()); ITSSkin_Load(this); CMM_LoadForm(g_sFormsDir, this); LoadLocalSkin(); FTitle = Caption;//"±¸°£ ¼±ÅÃ"; MapStart = false; FRefreshId = ""; FSelPosX = "0"; FSelPosY = "0"; FSelected = false; FMultiSelect = false; FLinkId = ""; FPosX = FPosY = 0; FMouseDownPosX = FMouseDownPosY = 0; FSelManager = new TSelManager(); FSelLink = NULL; PgList->Properties->ActivePage = TabNode; TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<¼±Åñ¸°£¸ñ·Ï>"; FRAMENodeList1->PnlTop->Visible = false; FRAMENodeList1->PnlBottom->Visible = false; FRAMELinkList1->PnlTop->Visible = false; FRAMELinkList1->PnlBottom->Visible = false; FRAMEServiceLinkList1->PnlTop->Visible = false; FRAMEServiceLinkList1->PnlBottom->Visible = false; FRAMERoadList1->PnlTop->Visible = false; FRAMERoadList1->PnlBottom->Visible = false; FLinkLevel = ALinkLevel; FRAMEGoogleMap1->BtnIconSelect->Visible = true; FRAMEGoogleMap1->BtnIconSelect->Enabled = true; FRAMEGoogleMap1->FOnZoomChanged = FRAMEGoogleMapOnZoomChange; OpenMap(); } //--------------------------------------------------------------------------- /* * ´Ý±â¹öư À̳ª x¹öư Ŭ¸¯½Ã °øÅëÀ¸·Î ó¸®ÇÏ´Â ·ÎÁ÷À̵é¾î°£´Ù.. * Form°ú DataModule class¸¦ delete½ÃŲ´Ù. * arguments * * return * void */ void __fastcall TITSSELAM::CommClose() { try { CMM_SaveForm(g_sFormsDir, this); CloseMap(); if (FSelManager) { delete FSelManager; FSelManager = NULL; } } catch(...) { } } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::LoadLocalSkin() { } //--------------------------------------------------------------------------- /* * FormÀ» º¸¿©ÁÙ¶§ È£ÃâµÇ´Â event ¸Þ¼­µåÀÌ´Ù. * arguments * Sender : event handler °´Ã¼ * return * void */ void __fastcall TITSSELAM::FormShow(TObject *Sender) { Refresh(); FormInit(); TmrShow->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::SetLinkLevel(int ALinkLevel) { TabLink->Visible = false; TabLink->TabVisible = false; TabServiceLink->Visible = false; TabServiceLink->TabVisible = false; TabRoad->Visible = false; TabRoad->TabVisible = false; switch(ALinkLevel) { case 1: FRAMELinkList1->UpdateList(); TabLink->Visible = true; TabLink->TabVisible = true; TabServiceLink->Visible = false; TabServiceLink->TabVisible = false; TabRoad->Visible = false; TabRoad->TabVisible = false; break; case 2: FRAMEServiceLinkList1->UpdateList(); TabLink->Visible = false; TabLink->TabVisible = false; TabServiceLink->Visible = true; TabServiceLink->TabVisible = true; TabRoad->Visible = false; TabRoad->TabVisible = false; break; case 3: FRAMERoadList1->UpdateList(); TabLink->Visible = false; TabLink->TabVisible = false; TabServiceLink->Visible = false; TabServiceLink->TabVisible = false; TabRoad->Visible = true; TabRoad->TabVisible = true; break; default: return; } FLinkLevel = ALinkLevel; } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::FormInit() { FRAMENodeList1->UpdateList(); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::TmrShowTimer(TObject *Sender) { TmrShow->Enabled = false; BtnSearchClick((TObject*)BtnSearch); Application->ProcessMessages(); cxGroupBox1->Caption = cxGroupBox1->Caption + " - Level: " + String(LinkLevel); DrawLink(); MapStart = true; RefreshId(); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::DrawLink() { TGMPolyline *pLink = GMPolyLink; TPolyline *pLn = NULL; if (FLinkLevel == 1) { pLink = GMPolyLink; try { ItsLinkManager->FLists.Lock(); FOR_STL(TItsLink*, pObj, ItsLinkManager->FLists) { if (pObj->Coords.Size() < 2) continue; pLn = pLink->Add(); if (!pLn) continue; pLn->Tag = (int)pObj; pLn->FObject = (TObject*)&pObj->bounds; pLn->Text = pObj->LINK_ID; FOR_STL(TItsCoord*, pCoord, pObj->Coords) { pLn->AddLinePoint(pCoord->Y, pCoord->X); } pLn->StrokeColor = clBlue; pLn->StrokeWeight = 4; pLn->StrokeOpacity = 1; pLn->AutoUpdatePath = true; pLn->Visible = true; pLn->Clickable = true; FSelManager->FLists.Push(pLn->Text, pLn); } } __finally { ItsLinkManager->FLists.UnLock(); pLink->Map = FRAMEGoogleMap1->GMMap1; } } else if (FLinkLevel == 2) { pLink = GMPolyLink; try { ItsIfscManager->FLists.Lock(); FOR_STL(TItsIfsc*, pObj, ItsIfscManager->FLists) { if (pObj->Coords.Size() < 2) continue; pLn = pLink->Add(); if (!pLn) continue; pLn->Tag = (int)pObj; pLn->FObject = (TObject*)&pObj->bounds; pLn->Text = pObj->IFSC_ID; FOR_STL(TItsCoord*, pCoord, pObj->Coords) { pLn->AddLinePoint(pCoord->Y, pCoord->X); } pLn->StrokeColor = clBlue; pLn->StrokeWeight = 4; pLn->StrokeOpacity = 1; pLn->AutoUpdatePath = true; pLn->Visible = true; pLn->Clickable = true; FSelManager->FLists.Push(pLn->Text, pLn); } } __finally { ItsIfscManager->FLists.UnLock(); pLink->Map = FRAMEGoogleMap1->GMMap1; } } else if (FLinkLevel == 3) { pLink = GMPolyLink; try { ItsRoadManager->FLists.Lock(); FOR_STL(TItsRoad*, pObj, ItsRoadManager->FLists) { if (pObj->Coords.Size() < 2) continue; pLn = pLink->Add(); if (!pLn) continue; pLn->Tag = (int)pObj; pLn->FObject = (TObject*)&pObj->bounds; pLn->Text = pObj->ROAD_ID; FOR_STL(TItsCoord*, pCoord, pObj->Coords) { pLn->AddLinePoint(pCoord->Y, pCoord->X); } pLn->StrokeColor = clBlue; pLn->StrokeWeight = 4; pLn->StrokeOpacity = 1; pLn->AutoUpdatePath = true; pLn->Visible = true; pLn->Clickable = true; FSelManager->FLists.Push(pLn->Text, pLn); } } __finally { ItsRoadManager->FLists.UnLock(); pLink->Map = FRAMEGoogleMap1->GMMap1; } } GMMarkerPos->Map = FRAMEGoogleMap1->GMMap1; } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::RefreshId() { if (FRefreshId.IsEmpty()) return; Application->ProcessMessages(); SelGisItem(FLinkLevel, FRefreshId); Application->ProcessMessages(); } //--------------------------------------------------------------------------- /* * Search ¹öư Ŭ¸¯ À̺¥Æ® Çڵ鷯 * arguments * Sender : event handler °´Ã¼ * return * void */ void __fastcall TITSSELAM::BtnSearchClick(TObject *Sender) { Application->ProcessMessages(); TSqlCursor sqlCrs((TControl*)BtnSearch); RefreshData(); } //--------------------------------------------------------------------------- /* * Refresh Data Event Function * arguments * * return * void */ void __fastcall TITSSELAM::RefreshData() { } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::SelListData() { } //--------------------------------------------------------------------------- /* * Close ¹öư Ŭ¸¯ À̺¥Æ® Çڵ鷯 * arguments * Sender : event handler °´Ã¼ * return * void */ void __fastcall TITSSELAM::BtnCloseClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::FormClose(TObject *Sender, TCloseAction &Action) { CommClose(); ITSSELAM = NULL; //Action = caFree; } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::FRAMENodeList1TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo, TMouseButton AButton, TShiftState AShift, bool &AHandled) { if (!MapStart) return; int nIndex = Sender->DataController->FocusedRecordIndex; if (nIndex < 0) return; String sX = Sender->DataController->Values[nIndex][FRAMENodeList1->Column06->Index]; String sY = Sender->DataController->Values[nIndex][FRAMENodeList1->Column07->Index]; TMarker *pMarker = GMMarkerPos->Items[0]; if (pMarker == NULL) pMarker = GMMarkerPos->Items[0]; if (!pMarker) return; TmrPosClear->Enabled = false; pMarker->Visible = false; pMarker->Position->Lat = sY.ToDouble(); // dLat; pMarker->Position->Lng = sX.ToDouble(); // dLng; pMarker->CenterMapTo(); pMarker->CenterMapToMarker(); pMarker->Animation->OnDrop = false; pMarker->Animation->OnDrop = true; pMarker->Visible = true; TmrPosClear->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::FRAMELinkList1TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo, TMouseButton AButton, TShiftState AShift, bool &AHandled) { int nIndex = Sender->DataController->FocusedRecordIndex; if (nIndex < 0) return; SelGisItem(1, Sender->DataController->Values[nIndex][FRAMELinkList1->Column01->Index]); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::FRAMEServiceLinkList1TvListCellClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo, TMouseButton AButton, TShiftState AShift, bool &AHandled) { int nIndex = Sender->DataController->FocusedRecordIndex; if (nIndex < 0) return; SelGisItem(2, Sender->DataController->Values[nIndex][FRAMEServiceLinkList1->Column01->Index]); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::FRAMERoadList1TvListCellClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo, TMouseButton AButton, TShiftState AShift, bool &AHandled) { int nIndex = Sender->DataController->FocusedRecordIndex; if (nIndex < 0) return; SelGisItem(3, Sender->DataController->Values[nIndex][FRAMERoadList1->Column01->Index]); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::BtnSelectClick(TObject *Sender) { if (TvList->DataController->RecordCount <= 0) { Application->MessageBox(lblText1->Caption.c_str(),//L"±¸°£ÀÌ ¼±ÅõÇÁö ¾Ê¾Ò½À´Ï´Ù.\r\nÁöµµ¿¡¼­ ±¸°£À» ¼±ÅÃÇϼ¼¿ä.", FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL); return; } FLinkId = EdLinkId->Text.Trim(); FSelected = true; Close(); Application->ProcessMessages(); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::SelGisItem(int AType, String AId) { if (!MapStart) return; if (AType == 0) return; //³ëµå TmrClearTimer(NULL); TPolyline* pLn = FSelManager->FLists.Find(AId); if (pLn) { FSelLink = pLn; FSelColor= pLn->StrokeColor; pLn->StrokeColor = clGreen; pLn->ZoomToPoints(); TmrClear->Enabled = true; } } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::TmrClearTimer(TObject *Sender) { TmrClear->Enabled = false; if (FSelLink) { FSelLink->StrokeColor = FSelColor; } FSelLink = NULL; } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::BtnDeleteClick(TObject *Sender) { try { TcxDataController *pGDC = TvList->DataController; TvList->BeginUpdate(); try { for (int ii = 0; ii < pGDC->RecordCount; ii++) { String sLinkId = pGDC->Values[ii][Column01->Index]; DeleteSelect(sLinkId); } TvList->Controller->DeleteSelection(); } catch(...) { } } __finally { TvList->EndUpdate(); } RefreshSelect(); } //--------------------------------------------------------------------------- bool __fastcall TITSSELAM::GetLinkId(int X, int Y, String &ALinkId) { return true; } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::UpdateSelect(String ALinkId, double X, double Y) { try { int nRow; TcxDataController *pGDC = TvList->DataController; TvList->BeginUpdate(); try { bool bAdd = true; if (!FMultiSelect) { for (int ii = 0; ii < pGDC->RecordCount; ii++) { String sLinkId = pGDC->Values[ii][Column01->Index]; DeleteSelect(sLinkId); } CMM_ClearGridTableView(TvList); } else { for (int ii = 0; ii < pGDC->RecordCount; ii++) { String sTmpLinkId = pGDC->Values[ii][Column01->Index]; if (sTmpLinkId == ALinkId) { pGDC->Values[ii][Column02->Index] = X; pGDC->Values[ii][Column03->Index] = Y; bAdd = false; break; } } } if (bAdd) { nRow = pGDC->AppendRecord(); pGDC->Values[nRow][Column01->Index] = ALinkId; pGDC->Values[nRow][Column02->Index] = X; pGDC->Values[nRow][Column03->Index] = Y; } } catch(...) { } } __finally { TvList->EndUpdate(); } RefreshSelect(); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::DeleteSelect(String ALinkId) { TPolyline* pLn = FSelManager->FLists.Find(ALinkId); if (pLn) { pLn->StrokeColor = clBlue; } } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::FRAMEGoogleMapOnZoomChange(TObject *Sender) { int nStrokeWeight = 4; if (FRAMEGoogleMap1->FMapZoom >= 14) { nStrokeWeight = 8; } FOR_STL(TPolyline*, pLn, FSelManager->FLists) { pLn->StrokeWeight = nStrokeWeight; } } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::RefreshSelect() { if (!MapStart) return; try { int nRow; TcxDataController *pGDC = TvList->DataController; TvList->BeginUpdate(); try { for (int ii = 0; ii < pGDC->RecordCount; ii++) { String sLinkId = pGDC->Values[ii][Column01->Index]; TPolyline* pLn = FSelManager->FLists.Find(sLinkId); if (pLn) { pLn->StrokeColor = clRed; } } } catch(...) { } } __finally { TvList->EndUpdate(); } } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::OpenMap() { TMarker *pMarker = GMMarkerPos->Items[0]; if (pMarker == NULL) pMarker = GMMarkerPos->Items[0]; if (pMarker) { pMarker->Icon = g_sImageDir + "pos.png"; } FRAMEGoogleMap1->LinkLevel = LinkLevel; FRAMEGoogleMap1->LoadGisMap(); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::CloseMap() { FRAMEGoogleMap1->GMMap1->Active = false; } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo, TMouseButton AButton, TShiftState AShift, bool &AHandled) { if (!MapStart) return; int nIndex = Sender->DataController->FocusedRecordIndex; if (nIndex < 0) return; String sX = Sender->DataController->Values[nIndex][Column02->Index]; String sY = Sender->DataController->Values[nIndex][Column03->Index]; TMarker *pMarker = GMMarkerPos->Items[0]; if (pMarker == NULL) pMarker = GMMarkerPos->Items[0]; if (!pMarker) return; TmrPosClear->Enabled = false; pMarker->Visible = false; pMarker->Position->Lat = sY.ToDouble(); // dLat; pMarker->Position->Lng = sX.ToDouble(); // dLng; pMarker->CenterMapTo(); pMarker->CenterMapToMarker(); pMarker->Animation->OnDrop = false; pMarker->Animation->OnDrop = true; pMarker->Visible = true; TmrPosClear->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::GMPolyLinkClick(TObject *Sender, TLatLng *LatLng, int Index, TLinkedComponent *LinkedComponent) { TGMPolyline* pGrpLink = (TGMPolyline*)Sender; TPolyline* pLink = pGrpLink->Items[Index]; if (FRAMEGoogleMap1->BtnIconSelect->SpeedButtonOptions->Down) { UpdateSelect(pLink->Text, LatLng->Lng, LatLng->Lat); } } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::FRAMEGoogleMap1GMMap1Click(TObject *Sender, TLatLng *LatLng, double X, double Y) { StatusBar->Panels->Items[1]->Text = "Click: " + LatLng->LngToStr(FRAMEGoogleMap1->GMMap1->Precision) + "," + LatLng->LatToStr(FRAMEGoogleMap1->GMMap1->Precision); } //--------------------------------------------------------------------------- void __fastcall TITSSELAM::TmrPosClearTimer(TObject *Sender) { TmrPosClear->Enabled = false; TMarker *pMarker = GMMarkerPos->Items[0]; if (pMarker == NULL) pMarker = GMMarkerPos->Items[0]; if (pMarker) { pMarker->Visible = false; } } //---------------------------------------------------------------------------