//--------------------------------------------------------------------------- #include #include "ITSSkinF.h" #include "ITSUtilF.h" #include "XiMapUtilF.h" #include "AppGlobalF.h" #pragma hdrstop #include "FRAME_GisMapF.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "XiClient" #pragma link "XiServer" #pragma link "ImageBtn" #pragma link "cxContainer" #pragma link "cxControls" #pragma link "cxEdit" #pragma link "cxGraphics" #pragma link "cxGroupBox" #pragma link "cxLookAndFeelPainters" #pragma link "cxLookAndFeels" #pragma link "dxSkinBlack" #pragma link "dxSkinBlue" #pragma link "dxSkinCaramel" #pragma link "dxSkinCoffee" #pragma link "dxSkinDarkRoom" #pragma link "dxSkinDarkSide" #pragma link "dxSkinFoggy" #pragma link "dxSkinGlassOceans" #pragma link "dxSkiniMaginary" #pragma link "dxSkinLilian" #pragma link "dxSkinLiquidSky" #pragma link "dxSkinLondonLiquidSky" #pragma link "dxSkinMcSkin" #pragma link "dxSkinMoneyTwins" #pragma link "dxSkinOffice2007Black" #pragma link "dxSkinOffice2007Blue" #pragma link "dxSkinOffice2007Green" #pragma link "dxSkinOffice2007Pink" #pragma link "dxSkinOffice2007Silver" #pragma link "dxSkinOffice2010Black" #pragma link "dxSkinOffice2010Blue" #pragma link "dxSkinOffice2010Silver" #pragma link "dxSkinsCore" #pragma link "dxSkinSeven" #pragma link "dxSkinSharp" #pragma link "dxSkinSilver" #pragma link "dxSkinStardust" #pragma resource "*.dfm" TFRAMEGisMap *FRAMEGisMap; const String LEVEL1_LINK_LAYER_NAME = "GD_LINK_LV7.dvf"; const String LEVEL2_LINK_LAYER_NAME = "GD_LINK_LV6.dvf"; const String LEVEL3_LINK_LAYER_NAME = "GD_LINK_LV5.dvf"; //--------------------------------------------------------------------------- __fastcall TFRAMEGisMap::TFRAMEGisMap(TComponent* Owner) : TFrame(Owner) { LoadLocalSkin(); FLinkLevel = 1; m_slLinkFldName = new TStringList(); m_slLinkFldValue = new TStringList(); } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::LoadLocalSkin() { /* * GIS Command button skin */ try { ImgPan->NormalPicture->Assign(ImgPan_c->Picture); ImgPan->Picture->Assign(ImgPan_c->Picture); ImgPan->TogglePicture->Assign(ImgPan_n->Picture); ImgPan->ClickedPicture->Assign(ImgPan_c->Picture); ImgZoomIn->NormalPicture->Assign(ImgZoomIn_n->Picture); ImgZoomIn->Picture->Assign(ImgZoomIn_n->Picture); ImgZoomIn->TogglePicture->Assign(ImgZoomIn_c->Picture); ImgZoomIn->ClickedPicture->Assign(ImgZoomIn_n->Picture); ImgZoomOut->NormalPicture->Assign(ImgZoomOut_n->Picture); ImgZoomOut->Picture->Assign(ImgZoomOut_n->Picture); ImgZoomOut->TogglePicture->Assign(ImgZoomOut_c->Picture); ImgZoomOut->ClickedPicture->Assign(ImgZoomOut_n->Picture); ImgSel->NormalPicture->Assign(ImgSel_n->Picture); ImgSel->Picture->Assign(ImgSel_n->Picture); ImgSel->TogglePicture->Assign(ImgSel_c->Picture); ImgSel->ClickedPicture->Assign(ImgSel_n->Picture); ImgStnd->NormalPicture->Assign(ImgStnd_n->Picture); ImgStnd->Picture->Assign(ImgStnd_n->Picture); ImgStnd->TogglePicture->Assign(ImgStnd_c->Picture); ImgStnd->ClickedPicture->Assign(ImgStnd_n->Picture); ImgRefresh->NormalPicture->Assign(ImgRefresh_n->Picture); ImgRefresh->Picture->Assign(ImgRefresh_n->Picture); ImgRefresh->TogglePicture->Assign(ImgRefresh_c->Picture); ImgRefresh->ClickedPicture->Assign(ImgRefresh_n->Picture); } catch(...) { } } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::LoadGisMap() { String sMapFile; switch(FLinkLevel) { case 1: sMapFile = g_GisInfo.sMapFileNameL1; break; case 2: sMapFile = g_GisInfo.sMapFileNameL2; break; case 3: sMapFile = g_GisInfo.sMapFileNameL3; break; default: return; } try { xsrvrMap->Active = false; xclntMap->Active = false; } catch (...) { } if (!g_GisInfo.bLoadL1) return; try { // start server xsrvrMap->DVAFileName = sMapFile; xsrvrMap->ShowLoadBar = true; xsrvrMap->UseMem = true; xsrvrMap->Active = true; xsrvrMap->AutoSave = true; xsrvrMap->SaveLayerInfo(); if (!xsrvrMap->Active) { ShowMessage("Xr Server Start Failed..."); return; } TXiMapBufferSize LineBuffer; LineBuffer = xsrvrMap->GetLineBufferSize(); LineBuffer.Level1 = 3; LineBuffer.Level2 = 3; LineBuffer.Level3 = 3; LineBuffer.Level4 = 3; LineBuffer.Level5 = 3; LineBuffer.Level6 = 4; LineBuffer.Level7 = 4; xsrvrMap->SetLineBufferSize(LineBuffer); xclntMap->DoubleBuffered = true; xclntMap->Start(DDRect(g_GisInfo.dRightBottomX, g_GisInfo.dLeftTopX, g_GisInfo.dRightBottomY, g_GisInfo.dLeftTopY)); xclntMap->MapPanMode = PMDynamic; xclntMap->MaxZoomValue = 0.001; xclntMap->BoolIconScale = true; xclntMap->Show(); OnGisOperationClick((TObject*)ImgPan); // ÀüÀÚÁöµµ ¸¶¿ì½ºÀ̺¥Æ®¸¦ À̵¿À¸·Î ¼³Á¤ } catch (...) { } } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::SetLinkLevel(int ALinkLevel) { switch(ALinkLevel) { case 1: break; case 2: break; case 3: break; default: return; } FLinkLevel = ALinkLevel; } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::OnGisOperationClick(TObject *Sender) { if (!xclntMap->Active) return; TImageBtn *pMenu = (TImageBtn*)Sender; xclntMap->MapOperation = (TXiMapOperation)pMenu->Tag; if (xclntMap->MapOperation == Nothing) { //xclntMap->ClearUserDrawPolyGon(); //xclntMap->ReDraw(); TXiMapUtil::ClearPath(xclntMap); } } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::ImgStndClick(TObject *Sender) { if (xclntMap->Active) { xclntMap->ExtentDraw(DDRect(g_GisInfo.dRightBottomX, g_GisInfo.dLeftTopX, g_GisInfo.dRightBottomY, g_GisInfo.dLeftTopY)); } } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::ImgRefreshClick(TObject *Sender) { TXiMapUtil::ClearPath(xclntMap); } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::ShowHideTrafficLayer(bool AShow) { TDVAInfo DVAInfo; int nLyrIdx = -1; try { nLyrIdx = xsrvrMap->GetLayerIndex(LEVEL1_LINK_LAYER_NAME); if (nLyrIdx >= 0) { xsrvrMap->GetDVAInfo(nLyrIdx, DVAInfo); DVAInfo.pDVAinfo.FVisible = AShow; xsrvrMap->SetDVAInfo(nLyrIdx, DVAInfo); } nLyrIdx = xsrvrMap->GetLayerIndex(LEVEL2_LINK_LAYER_NAME); if (nLyrIdx >= 0) { xsrvrMap->GetDVAInfo(nLyrIdx, DVAInfo); DVAInfo.pDVAinfo.FVisible = AShow; xsrvrMap->SetDVAInfo(nLyrIdx, DVAInfo); } nLyrIdx = xsrvrMap->GetLayerIndex(LEVEL3_LINK_LAYER_NAME); if (nLyrIdx >= 0) { xsrvrMap->GetDVAInfo(nLyrIdx, DVAInfo); DVAInfo.pDVAinfo.FVisible = AShow; xsrvrMap->SetDVAInfo(nLyrIdx, DVAInfo); } xclntMap->FullReDraw(); Application->ProcessMessages(); } catch (...) { } } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::SelectObjectByPos(double dPosX, double dPosY, bool bArrow/*=false*/) { if (!xclntMap->IsStart()) return; TDDPoint ptCoord; ptCoord.X = dPosX; ptCoord.Y = dPosY; xclntMap->MoveExtentDraw(ptCoord); xclntMap->LevelView(6); m_ptSelect.X = dPosX; m_ptSelect.Y = dPosY; if (bArrow) SelectObjectByPos(); } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::SelectObjectByPos() { TPoint ptTmp; ImgSelect->Parent = xclntMap; ImgSelect->Visible = false; TmrSelect->Enabled = false; TmrSelect->Interval = 3000; ptTmp = xclntMap->RealToScreen(m_ptSelect); ImgSelect->Left = ptTmp.x - (ImgSelect->Width/2); ImgSelect->Top = ptTmp.y - (ImgSelect->Height)-10; TmrSelect->Enabled = true; ImgSelect->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::TmrSelectTimer(TObject *Sender) { TmrSelect->Enabled = false; ImgSelect->Visible = false; } //--------------------------------------------------------------------------- bool __fastcall TFRAMEGisMap::SelectLinkByPos(int X, int Y, String &ALinkId) { TDVAInfo DVAInfo; int nMapLevel = xclntMap->GetLevel(); if (LinkLevel == 1) { int nLayerIdx1 = xclntMap->GetLayerIndex(LEVEL1_LINK_LAYER_NAME); if (nLayerIdx1 >= 0) { xsrvrMap->GetDVAInfo(nLayerIdx1, DVAInfo); if (nMapLevel >= DVAInfo.pDVAinfo.FSLevel && nMapLevel <= DVAInfo.pDVAinfo.FELevel) { if (GetLevelLinkId(1, ALinkId, X, Y)) { return true; } } } } else if (LinkLevel == 2) { int nLayerIdx2 = xclntMap->GetLayerIndex(LEVEL2_LINK_LAYER_NAME); if (nLayerIdx2 >= 0) { xsrvrMap->GetDVAInfo(nLayerIdx2, DVAInfo); if (nMapLevel >= DVAInfo.pDVAinfo.FSLevel && nMapLevel <= DVAInfo.pDVAinfo.FELevel) { if (GetLevelLinkId(2, ALinkId, X, Y)) { return true; } } } } else if (LinkLevel == 3) { int nLayerIdx3 = xclntMap->GetLayerIndex(LEVEL3_LINK_LAYER_NAME); if (nLayerIdx3 >= 0) { xsrvrMap->GetDVAInfo(nLayerIdx3, DVAInfo); if (nMapLevel >= DVAInfo.pDVAinfo.FSLevel && nMapLevel <= DVAInfo.pDVAinfo.FELevel) { if (GetLevelLinkId(3, ALinkId, X, Y)) { return true; } } } } return false; } //--------------------------------------------------------------------------- /* * ¸µÅ©·¹ÀÌ¾î µµ¿ò¸» Ç¥Ãâ * arguments * return * void */ bool __fastcall TFRAMEGisMap::GetLevelLinkId(int ALinkLevel, String &sLinkId, int X, int Y) { String sLinkLyrName = ""; int nLyrIndex = -1; sLinkId = ""; switch(ALinkLevel) { case 1: sLinkLyrName = LEVEL1_LINK_LAYER_NAME; break; case 2: sLinkLyrName = LEVEL2_LINK_LAYER_NAME; break; case 3: sLinkLyrName = LEVEL3_LINK_LAYER_NAME; break; default: return false; } nLyrIndex = xclntMap->GetLayerIndex(sLinkLyrName); if (nLyrIndex < 0) return false; try { if (xsrvrMap->ShpObjInfo(X, Y, nLyrIndex, m_slLinkFldName, m_slLinkFldValue, clWhite, true, false)) { if (m_slLinkFldName->Count != m_slLinkFldValue->Count) { return false; } sLinkId = m_slLinkFldValue->Strings[1]; return true; } } catch(...) { } return false; } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::OnCloseQuery(bool &CanClose) { if (m_slLinkFldName != NULL) delete m_slLinkFldName; if (m_slLinkFldValue != NULL) delete m_slLinkFldValue; m_slLinkFldName = NULL; m_slLinkFldValue = NULL; } //--------------------------------------------------------------------------- int __fastcall TFRAMEGisMap::GetLayerIndex() { int nLayerIdx = 0; int nLevel = xclntMap->GetLevel(); switch(FLinkLevel) { case 2: nLayerIdx = xclntMap->GetLayerIndex(LEVEL2_LINK_LAYER_NAME); break; case 3: nLayerIdx = xclntMap->GetLayerIndex(LEVEL3_LINK_LAYER_NAME); break; default:nLayerIdx = xclntMap->GetLayerIndex(LEVEL1_LINK_LAYER_NAME); break; } return nLayerIdx; } //--------------------------------------------------------------------------- void __fastcall TFRAMEGisMap::SelGisItem(int AType, String AId) { try { switch(AType) { case 0: TXiMapUtil::MoveNode(xclntMap, AId); break; case 1: TXiMapUtil::MoveLink(xclntMap, AId); break; case 2: TXiMapUtil::MoveServiceLink(xclntMap, AId); break; case 3: TXiMapUtil::MoveRoad(xclntMap, AId); break; default: return; } } catch(...) { } } //---------------------------------------------------------------------------