//---------------------------------------------------------------------------

#ifndef ITS00MAPFH
#define ITS00MAPFH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <DB.hpp>
#include <DBClient.hpp>
#include <Provider.hpp>
#include <ADODB.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include <ImgList.hpp>
#include <Menus.hpp>
#include <pngimage.hpp>
#include <map.h>
#include <vector.h>
#include "ImageBtn.h"
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include "DataTypesF.h"
#include "WindowMsgF.h"
#include "cxCheckBox.hpp"
#include "cxContainer.hpp"
#include "cxControls.hpp"
#include "cxEdit.hpp"
#include "cxGraphics.hpp"
#include "cxGroupBox.hpp"
#include "cxLabel.hpp"
#include "cxLookAndFeelPainters.hpp"
#include "cxLookAndFeels.hpp"
#include "cxMaskEdit.hpp"
#include "cxProgressBar.hpp"
#include "cxSpinEdit.hpp"
#include "cxTextEdit.hpp"
#include "dxGDIPlusClasses.hpp"
#include "dxSkinBlack.hpp"
#include "dxSkinBlue.hpp"
#include "dxSkinsCore.hpp"
#include "GMClasses.hpp"
#include "GMLinkedComponents.hpp"
#include "GMMap.hpp"
#include "GMMapVCL.hpp"
#include "GMMarker.hpp"
#include "GMMarkerVCL.hpp"
#include "GMPolygonVCL.hpp"
#include "GMPolyline.hpp"
#include "GMPolylineVCL.hpp"

//---------------------------------------------------------------------------
/*
******************************************************************************
* Define constant
******************************************************************************
*/
/*
*  소통정보 레이어 최대갯수
*/
#define MAX_LAYERS              7

/*
*  이전/다음 구현을 위한 구조체 선언(정적 이중링크로 구현)
*/
#define D_EXT_QUEUE_SIZE        256 //512//1024/2048
#define D_EXT_QUEUE_MASK        (D_EXT_QUEUE_SIZE-1)

/*
*  레이어 Extent 정보
*/
enum TXiMapOperation { Nothing, OnZoomIn, OnZoomOut, OnPanSt, OnDistance, OnSelect, OnGeoQuery, OnEditting, OnCircle, OnShortPath, OnArea, OnInsert, OnFindEvent, OnNearFind, OnUserDefine };

struct TLinkTrfGrd
{

public:
	Graphics::TColor SpdCOLOR;
	int MinSpeed;
	int MaxSpeed;
};

struct TDBLinkColor
{

public:
	TLinkTrfGrd GDLOW;
	TLinkTrfGrd GDMID;
	TLinkTrfGrd GDHIG;
};

struct TUTISLinkGrade
{

public:
	TDBLinkColor road101;
	TDBLinkColor road102;
	TDBLinkColor road103;
	TDBLinkColor road104;
	TDBLinkColor road105;
	TDBLinkColor road106;
	TDBLinkColor road107;
};

struct TDDPoint
{

public:
	double X;
	double Y;
};
struct TDDRect
{

	union
	{
		struct
		{
			TDDPoint MinXY;
			TDDPoint MaxXY;

		};
		struct
		{
			double MinX;
			double MinY;
			double MaxX;
			double MaxY;

		};

	};
};

typedef struct
{
    bool    bExtent;
    short   userIdx;
    short   currIdx;
    TDDRect extent[D_EXT_QUEUE_SIZE+1];
} EXTENT_LIST_QUEUE;

typedef struct
{
    short   Zoom;
    double  Lat;
    double  Lng;
} TGisExtent;

typedef struct
{
    bool        Extent;
    short       TotCnt;
    short       CurIdx;
    TGisExtent  extent[D_EXT_QUEUE_SIZE+1];
} GIS_EXTENT_QUEUE;


//---------------------------------------------------------------------------
class TITS00MAP : public TForm
{
__published:	// IDE-managed Components
    TTimer *TmrShow;
    TPopupMenu *pmuCctv;
    TMenuItem *MnuCctvId;
    TMenuItem *N6;
    TMenuItem *mnuStopImage;
    TMenuItem *mnuCctvCam;
    TMenuItem *mnuCctvPingCtrl;
    TPopupMenu *pmuVms;
    TMenuItem *mnuVmsMsg;
    TMenuItem *mnuVmsCam;
    TMenuItem *mnuVmsPingCtrl;
    TPopupMenu *pmuRse;
    TMenuItem *pmuRsePing;
    TMenuItem *MnuVmsId;
    TMenuItem *N3;
    TMenuItem *MnuRseId;
    TMenuItem *N4;
    TMenuItem *NetworkPing1;
    TMenuItem *mnuCctvPingCapt;
    TMenuItem *mnuCctvPingEncd;
    TMenuItem *mnuCctvPingStrm;
    TMenuItem *NetworkPing2;
    TMenuItem *mnuVmsPingWeb;
    TPopupMenu *pmuWebCam;
    TMenuItem *MnuWebCamId;
    TMenuItem *MenuItem2;
    TMenuItem *MnuWebCam;
    TMenuItem *MenuItem5;
    TMenuItem *MnuWebCamPing;
    TPopupMenu *pmuVds;
    TMenuItem *MnuVdsId;
    TMenuItem *MenuItem3;
    TMenuItem *MenuItem4;
    TPopupMenu *pmuAvi;
    TMenuItem *MnuAviId;
    TMenuItem *MenuItem7;
    TMenuItem *MenuItem8;
    TPopupMenu *pmuDsrc;
    TMenuItem *MnuDsrcId;
    TMenuItem *MenuItem10;
    TMenuItem *MenuItem11;
    TTimer *TmrLblTraffic;
    TTimer *TmrRefresh;
    TPopupMenu *pmuSigDet;
    TMenuItem *MnuSigDetId;
    TMenuItem *MenuItem19;
    TMenuItem *mmuSigDetPing;
    TPopupMenu *pmuSig;
    TMenuItem *MnuSigId;
    TMenuItem *MenuItem20;
    TMenuItem *mmuSigPing;
    TPopupMenu *pmuBit;
    TMenuItem *MnuBitId;
    TMenuItem *MenuItem6;
    TMenuItem *mmuBitPing;
    TPopupMenu *pmuPis;
    TMenuItem *MnuPisId;
    TMenuItem *MenuItem13;
    TMenuItem *MenuItem21;
    TPopupMenu *pmuPcs;
    TMenuItem *MnuPcsId;
    TMenuItem *MenuItem26;
    TMenuItem *MenuItem27;
    TPanel *PnlMap;
    TPanel *PnlProgress;
    TcxProgressBar *PbLoadMap;
    TPanel *PnlBack;
    TPanel *Panel1;
    TcxCheckBox *ChkDrawBit;
    TcxCheckBox *ChkDrawSig;
    TcxCheckBox *ChkDrawPcs;
    TcxCheckBox *ChkDrawPis;
    TcxCheckBox *ChkDrawSigDet;
    TcxCheckBox *ChkWebCam;
    TPanel *PnlToolBarxxx;
    TGroupBox *GroupBox2;
    TcxCheckBox *ChkViewExample;
    TcxCheckBox *ChkGisSearch;
    TcxCheckBox *ChkToolTip;
    TGroupBox *GrpFacility;
    TcxCheckBox *ChkDrawCtv;
    TcxCheckBox *ChkDrawAvi;
    TcxCheckBox *ChkDrawDsrc;
    TcxCheckBox *ChkDrawPark;
    TcxCheckBox *ChkDrawEvent;
    TcxCheckBox *ChkDrawRse;
    TcxCheckBox *ChkDrawWthr;
    TGroupBox *GrpPos;
    TLabel *Label11;
    TLabel *Label12;
    TcxSpinEdit *SePosY;
    TcxSpinEdit *SePosX;
    TPanel *PnlMapInfo;
    TImage *ImgDesc27;
    TImage *ImgDesc37;
    TLabel *Label16;
    TLabel *Label3;
    TLabel *LblZoomLevel;
    TLabel *LblLinkLevel;
    TcxGroupBox *panRemark;
    TGroupBox *GrpRse;
    TImage *ImgRseN;
    TImage *ImgRseC;
    TImage *Image1;
    TcxLabel *cxLabel1;
    TcxLabel *cxLabel2;
    TcxLabel *cxLabel17;
    TGroupBox *GroupBox7;
    TImage *ImgInc01;
    TImage *ImgInc02;
    TImage *ImgInc03;
    TImage *ImgInc04;
    TcxLabel *cxLabel9;
    TcxLabel *cxLabel10;
    TcxLabel *cxLabel11;
    TcxLabel *cxLabel12;
    TGroupBox *GroupBox8;
    TPanel *PnlTrf01;
    TPanel *PnlTrf02;
    TPanel *PnlTrf03;
    TPanel *PnlTrf00;
    TcxLabel *cxLabel13;
    TcxLabel *cxLabel14;
    TcxLabel *cxLabel15;
    TcxLabel *cxLabel16;
    TGroupBox *GroupBox9;
    TImage *ImgCctvN;
    TImage *ImgCctvC;
    TImage *ImgCctvM;
    TcxLabel *cxLabel3;
    TcxLabel *cxLabel4;
    TcxLabel *cxLabel5;
    TGroupBox *GroupBox10;
    TImage *ImgVmsN;
    TImage *ImgVmsC;
    TImage *ImgVmsM;
    TcxLabel *cxLabel6;
    TcxLabel *cxLabel7;
    TcxLabel *cxLabel8;
    TGroupBox *GrpWeb;
    TImage *Image2;
    TImage *Image3;
    TImage *Image4;
    TcxLabel *cxLabel18;
    TcxLabel *cxLabel19;
    TcxLabel *cxLabel20;
    TGroupBox *GrpDsrc;
    TImage *Image5;
    TImage *Image6;
    TImage *Image7;
    TcxLabel *cxLabel21;
    TcxLabel *cxLabel22;
    TcxLabel *cxLabel23;
    TGroupBox *GrpAvi;
    TImage *Image8;
    TImage *Image9;
    TImage *Image10;
    TcxLabel *cxLabel24;
    TcxLabel *cxLabel25;
    TcxLabel *cxLabel26;
    TGroupBox *GrpVds;
    TImage *Image11;
    TImage *Image12;
    TImage *Image13;
    TcxLabel *cxLabel27;
    TcxLabel *cxLabel28;
    TcxLabel *cxLabel29;
    TGroupBox *GroupBox4;
    TImage *ImgCurrent;
    TcxLabel *LblCurrTemp;
    TGroupBox *GroupBox5;
    TImage *ImgForecast;
    TcxLabel *LblMaxFore;
    TcxLabel *LblMinFore;
    TcxLabel *lblStep1;
    TcxLabel *lblStep2;
    TPanel *PnlToolbar;
    TcxLabel *lblGap1;
    TPanel *PnlGisTool;
    TcxCheckBox *ChkDrawCenter;
    TcxCheckBox *ChkDrawVms;
    TcxCheckBox *ChkDrawIncident;
    TcxCheckBox *ChkDrawVds;
    TcxCheckBox *ChkTrafficLayer;
    TPanel *PnlLoading;
    TPanel *PnlZoom;
    TListBox *ListBox1;
    TcxLabel *LblTraffic;
    TLabel *Label1;
    TLabel *Label2;
    void __fastcall FormDestroy(TObject *Sender);
    void __fastcall FormShow(TObject *Sender);
    void __fastcall TmrShowTimer(TObject *Sender);
    void __fastcall ChkDrawGisClick(TObject *Sender);
    void __fastcall mnuStopImageClick(TObject *Sender);
    void __fastcall mnuFacilityPingClick(TObject *Sender);
    void __fastcall pmuFacilityPopup(TObject *Sender);
    void __fastcall mnuCctvCamClick(TObject *Sender);
    void __fastcall mnuVmsMsgClick(TObject *Sender);
    void __fastcall mnuVmsCamClick(TObject *Sender);
    void __fastcall ChkGisSearchClick(TObject *Sender);
    void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
    void __fastcall panRemarkMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y);
    void __fastcall ChkViewExamplePropertiesChange(TObject *Sender);
    void __fastcall MnuWebCamClick(TObject *Sender);
    void __fastcall TmrLblTrafficTimer(TObject *Sender);
    void __fastcall TmrRefreshTimer(TObject *Sender);
    void __fastcall PnlToolbarDblClick(TObject *Sender);
    void __fastcall ListBox1DblClick(TObject *Sender);


private:	// User declarations
public:
    void __fastcall InitMap();

    // For Map
    int             FMapLinkLevel;

public:

public:		// User declarations
    __fastcall TITS00MAP(TComponent* Owner, TForm *ParentForm);

    void __fastcall ShowLayerEditForm();

    void __fastcall LoadLocalSkin();
    void __fastcall CommClose();
    bool __fastcall FormInit();

    void __fastcall LoadGisMap();
    void __fastcall GetGisTrafficColor(TUTISLinkGrade &pUtisLinkColor);
    void __fastcall SetGisTrafficColor();

    void __fastcall RefreshMapTraffic();

    // Object Select
    TDDPoint        m_ptSelect;
    void __fastcall SelectObjectByPos(double dPosX, double dPosY, bool bArrow=false);

    void __fastcall RefreshGisLink();
    bool __fastcall SelectLinkById(int ALinkLevel, String AId, bool AHide=false);

    void __fastcall ShowCctvStopImage(String AId, TPoint pt);
    void __fastcall ShowCctvCamera(String AId, TPoint pt);
    void __fastcall ShowVmsMessage(String AId, TPoint pt);
    void __fastcall ShowVmsCamera(String AId, TPoint pt);
    void __fastcall ShowWebCamera(String AId, TPoint pt);

    void __fastcall ShowLinkDetailInfo(String sLinkId, int nLinkLevel);

    void __fastcall UpdateFacilityStatus();
    void __fastcall UpdateEventStatus();    //남양주 블랙박스 이벤트 상태
    String  FSelId;

    void __fastcall ShowHideFacility(TObject *Sender);
    void __fastcall ShowHideTraffic();

    void __fastcall OnMapPopupMenu(String AType, String AId, String APosX, String APosY, String AInfo);
    void __fastcall SelGisItem(int AType, String AId);

    void __fastcall InitGisRegion();
    void __fastcall InitGisTraffic();
    void __fastcall UpdateGisVms();
    void __fastcall UpdateGisVds();
    void __fastcall UpdateGisIncident();

    void __fastcall DebugList(String AMsg);
};
//---------------------------------------------------------------------------
extern PACKAGE TITS00MAP *ITS00MAP;
//---------------------------------------------------------------------------
#endif

