123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 |
- /****************************************************************************
- * @source :
- * @description :
- ****************************************************************************
- * DATE AUTHOR DESCRIPTION
- * --------------------------------------------------------------------------
- * 2011/12/24 정승호 최초작성
- *
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "AppGlobalF.h"
- #include "CDSNodeF.h"
- #include "CDSLinkF.h"
- #include "CDSServiceLinkF.h"
- #include "XiMapUtilF.h"
- #pragma hdrstop
- #include "ITSSELAMF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxGroupBox"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxPC"
- #pragma link "cxPCdxBarPopupMenu"
- #pragma link "cxSplitter"
- #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 "dxSkinscxPCPainter"
- #pragma link "dxSkinSeven"
- #pragma link "dxSkinSharp"
- #pragma link "dxSkinSilver"
- #pragma link "dxSkinStardust"
- #pragma link "FRAME_GisMapF"
- #pragma link "FRAME_LinkListF"
- #pragma link "FRAME_NodeListF"
- #pragma link "FRAME_RoadListF"
- #pragma link "FRAME_ServiceLinkListF"
- #pragma link "cxLabel"
- #pragma link "cxTextEdit"
- #pragma link "cxCalc"
- #pragma link "cxCalendar"
- #pragma link "cxClasses"
- #pragma link "cxCustomData"
- #pragma link "cxData"
- #pragma link "cxDataStorage"
- #pragma link "cxFilter"
- #pragma link "cxGrid"
- #pragma link "cxGridCustomTableView"
- #pragma link "cxGridCustomView"
- #pragma link "cxGridLevel"
- #pragma link "cxGridTableView"
- #pragma link "cxSpinEdit"
- #pragma link "cxStyles"
- #pragma resource "*.dfm"
- TITSSELAM *ITSSELAM = NULL;
- 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";
- const String LEVEL1_NODE_LAYER_NAME = "GD_NODE_LV7.dvf";
- const String LEVEL2_NODE_LAYER_NAME = "GD_NODE_LV6.dvf";
- const String LEVEL3_NODE_LAYER_NAME = "GD_NODE_LV5.dvf";
- //---------------------------------------------------------------------------
- __fastcall TITSSELAM::TITSSELAM(TComponent* Owner)
- : TForm(Owner)
- {
- ITSSkin_Load(this);
- CMM_LoadForm(g_sFormsDir, this);
- FTitle = "구간 선택";
- FRefreshId = "";
- FSelPosX = "0";
- FSelPosY = "0";
- FLinkLevel = 1;
- FSelected = false;
- FMultiSelect = false;
- FLinkId = "";
- FPosX = FPosY = 0;
- FMouseDownPosX = FMouseDownPosY = 0;
- PgList->Properties->ActivePage = TabNode;
- TvList->OptionsView->NoDataToDisplayInfoText = "<선택구간목록>";
- 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;
- }
- //---------------------------------------------------------------------------
- /*
- * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
- * Form과 DataModule class를 delete시킨다.
- * arguments
- *
- * return
- * void
- */
- void __fastcall TITSSELAM::CommClose()
- {
- try
- {
- CMM_SaveForm(g_sFormsDir, this);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- /*
- * 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;
- break;
- case 2:
- FRAMEServiceLinkList1->UpdateList();
- TabServiceLink->Visible = true;
- TabServiceLink->TabVisible = true;
- break;
- case 3:
- FRAMERoadList1->UpdateList();
- TabRoad->Visible = true;
- TabRoad->TabVisible = true;
- break;
- default: return;
- }
- FLinkLevel = ALinkLevel;
- FRAMEGisMap1->LinkLevel = ALinkLevel;
- }
- //---------------------------------------------------------------------------
- /*
- * form 초기화
- *
- * arguments
- *
- * return
- * void
- */
- void __fastcall TITSSELAM::FormInit()
- {
- FRAMENodeList1->UpdateList();
- }
- //---------------------------------------------------------------------------
- /*
- * Form이 Show되고 난 후 최초 1회 수행되는 타이머 이벤트
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TITSSELAM::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- FRAMEGisMap1->LoadGisMap();
- BtnSearchClick((TObject*)BtnSearch);
- Application->ProcessMessages();
- RefreshId();
- }
- //---------------------------------------------------------------------------
- void __fastcall TITSSELAM::RefreshId()
- {
- if (FRefreshId.IsEmpty()) return;
- SelGisItem(FLinkLevel, FRefreshId);
- Application->ProcessMessages();
- }
- //---------------------------------------------------------------------------
- /*
- * Search 버튼 클릭 이벤트 핸들러
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TITSSELAM::BtnSearchClick(TObject *Sender)
- {
- 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)
- {
- int nIndex = Sender->DataController->FocusedRecordIndex;
- if (nIndex < 0) return;
- SelGisItem(0, Sender->DataController->Values[nIndex][FRAMENodeList1->Column01->Index]);
- }
- //---------------------------------------------------------------------------
- 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(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::FRAMEGisMap1xclntMapMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
- {
- if (!FRAMEGisMap1->xclntMap->IsStart()) return;
- TDDPoint dptCurr = FRAMEGisMap1->xclntMap->ScreenToReal(Point(X, Y));
- try {
- String sMousePos = FormatFloat("##,##0.#####0", dptCurr.X) + " " + FormatFloat("##,##0.#####0", dptCurr.Y);
- StatusBar->Panels->Items[1]->Text = sMousePos;
- } catch(...) {}
- }
- //---------------------------------------------------------------------------
- void __fastcall TITSSELAM::FRAMEGisMap1xclntMapMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- if (Button != mbLeft) return;
- if (FRAMEGisMap1->xclntMap->MapOperation != OnSelect) return;
- FRAMEGisMap1->xclntMap->SetFocus();
- FMouseDownPosX = X;
- FMouseDownPosY = Y;
- TDDPoint dptCurr = FRAMEGisMap1->xclntMap->ScreenToReal(Point( X, Y));
- FPosX = dptCurr.X;
- FPosY = dptCurr.Y;
- try {
- String sMousePos = FormatFloat("##,##0.#####0", dptCurr.X) + "/" + FormatFloat("##,##0.#####0", dptCurr.Y);
- StatusBar->Panels->Items[1]->Text = sMousePos;
- EdPos->Text = sMousePos;
- } catch(...) {}
- if (FRAMEGisMap1->xclntMap->MouseTaget != 0)
- return;
- String sLinkId = "";
- if (GetLinkId(X, Y, sLinkId))
- {
- //DB에 존재하는지 체크하려면 여기서 하자.
- UpdateSelect(sLinkId, dptCurr.X, dptCurr.Y);
- #if 1
- if (!FMultiSelect)
- {
- FRAMEGisMap1->xclntMap->ClearAccEvent( true );
- FRAMEGisMap1->xclntMap->ADDAccEvent(dptCurr,
- "현재 선택 좌표",
- "선택 링크 및 좌표",
- AnsiString().sprintf( "현재 선택 좌표|X : %03.08f|Y : %02.08f", dptCurr.X, dptCurr.Y ).c_str(),
- -1, true, 1, 7);
- FRAMEGisMap1->xclntMap->ReDraw( );
- }
- #endif
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TITSSELAM::FRAMEGisMap1xclntMapMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- #if 0
- FLinkId = "";
- EdLinkId->Text = "";
- if (FMouseDownPosX == X && FMouseDownPosY == Y)
- {
- if (FRAMEGisMap1->xclntMap->MouseTaget != 0)
- return;
- int nLayerIdx = GetLayerIndex();
- if (nLayerIdx < 0) return;
- FRAMEGisMap1->xclntMap->ClearUserDrawPolyGon();
- TXiMapUtil::SelectLinkByPos(FRAMEGisMap1->xsrvrMap, FRAMEGisMap1->xclntMap, nLayerIdx, X, Y, FLinkId);
- EdLinkId->Text = FLinkId;
- FRAMEGisMap1->xclntMap->ReDraw();
- }
- #endif
- }
- //---------------------------------------------------------------------------
- int __fastcall TITSSELAM::GetLayerIndex()
- {
- int nLayerIdx = 0;
- int nLevel = FRAMEGisMap1->xclntMap->GetLevel();
- switch(FLinkLevel)
- {
- case 2: nLayerIdx = FRAMEGisMap1->xclntMap->GetLayerIndex(LEVEL2_LINK_LAYER_NAME); break;
- case 3: nLayerIdx = FRAMEGisMap1->xclntMap->GetLayerIndex(LEVEL3_LINK_LAYER_NAME); break;
- default:nLayerIdx = FRAMEGisMap1->xclntMap->GetLayerIndex(LEVEL1_LINK_LAYER_NAME); break;
- }
- return nLayerIdx;
- }
- //---------------------------------------------------------------------------
- void __fastcall TITSSELAM::SelGisItem(int AType, String AId)
- {
- try
- {
- switch(AType)
- {
- case 0: TXiMapUtil::MoveNode(FRAMEGisMap1->xclntMap, AId); break;
- case 1: TXiMapUtil::MoveLink(FRAMEGisMap1->xclntMap, AId); break;
- case 2: TXiMapUtil::MoveServiceLink(FRAMEGisMap1->xclntMap, AId); break;
- case 3: TXiMapUtil::MoveRoad(FRAMEGisMap1->xclntMap, AId); break;
- default: return;
- }
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TITSSELAM::BtnDeleteClick(TObject *Sender)
- {
- try
- {
- TvList->BeginUpdate();
- try
- {
- TvList->Controller->DeleteSelection();
- }
- catch(...)
- {
- }
- }
- __finally
- {
- TvList->EndUpdate();
- }
- RefreshSelect();
- }
- //---------------------------------------------------------------------------
- bool __fastcall TITSSELAM::GetLinkId(int X, int Y, String &ALinkId)
- {
- ALinkId = "";
- int nLayerIdx = GetLayerIndex();
- if (nLayerIdx < 0) return false;
- TStringList *slFldName = NULL;
- TStringList *slFldValue = NULL;
- try
- {
- slFldName = new TStringList();
- slFldValue = new TStringList();
- try
- {
- //TDDPoint dptCurr = MapClient->ScreenToReal(Point(X, Y));
- // 링크에 대한 공간정보를 검색
- if (FRAMEGisMap1->xsrvrMap->ShpObjInfo(X, Y, nLayerIdx, slFldName, slFldValue, clWhite, true, false))
- {
- if (slFldName->Count != slFldValue->Count)
- {
- return false;
- }
- ALinkId = slFldValue->Strings[1];
- return true;
- }
- }
- catch(...)
- {
- }
- }
- __finally
- {
- if (slFldName) delete slFldName;
- if (slFldValue) delete slFldValue;
- }
- return false;
- }
- //---------------------------------------------------------------------------
- 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)
- {
- 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::RefreshSelect()
- {
- FRAMEGisMap1->xclntMap->ClearPathInfo();
- FRAMEGisMap1->xclntMap->ReDraw();
- int nLayerIdx = GetLayerIndex();
- if (nLayerIdx < 0) 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];
- TXiMapUtil::SelectLinkById(FRAMEGisMap1->xsrvrMap, FRAMEGisMap1->xclntMap, nLayerIdx, sLinkId);
- }
- }
- catch(...)
- {
- }
- }
- __finally
- {
- TvList->EndUpdate();
- }
- FRAMEGisMap1->xclntMap->ReDraw();
- }
- //---------------------------------------------------------------------------
|