#include "stdafx.h"
#include "GTZX.h"
#include "GlobalData.h"
//#include "XLdataBase.h"
#include "CalJXAndGD.h"
#include "DrawRoad.h"
#include "StationDataBase.h"
#include "Cshejicanshumdb.h"

extern vector<CBaseLine*> pJXGTZXArray;
extern StationDataBase DBSForDZ;
extern int incZX;
extern int global_lcbzdir;
extern Cshejicanshumdb GlobalSJYZ;
//统计数量的所有的框选范围
extern int isPingMianChuTu;
extern int Global_SJST;
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif

#define  sign(y, x)  { if ((x) == 0)        \
	y =0;             \
	else if ((x) > 0)    \
	y =1;             \
	else                 \
	y = -1;           \
}

#define streq(s,t) (_tcscmp((s),(t))==0)
#define AppName  /*MSG1*/"GUADS"
extern int G_ISSX;
//extern CMyDockControlBar *dockBar;	
//LDZDM lddm;
bool IfViewDmx = false;
ZCGTZX* pm_sta;
extern vector<ZCGTZX*> PGDArray;
extern int G_ErroColor;
//extern DockTypeHdmBar *TypeHdmBar;
extern vector<Road> RoadManage_INPUT;
extern vector<Rd_BX> RoadBXManage_INPUT;
extern int drawAddcir;
// 既有标注是否添加小括号
extern BOOL ssJYBZ;
// 预留标注加中括号
extern BOOL ssYLBZ;
extern int BackGroundFill;


void ZCGTZX::Judge_GDType(ZCGTZX* pGD, vector<vector<ZCGTZX*>>& pGDTypeArray)
{
	for (int i = 0; i < (int)pGDTypeArray.size(); i++)
	{
		if (pGDTypeArray[i].size() > 0)
		{
			if (pGDTypeArray[i][0]->XLType == pGD->XLType)
			{
				pGDTypeArray[i].push_back(pGD);
				return;
			}
		}
	}

	vector<ZCGTZX*> GDArray;
	GDArray.clear();
	GDArray.push_back(pGD);
	pGDTypeArray.push_back(GDArray);
	GDArray.clear();
}

void ZCGTZX::Sort_GD(vector<ZCGTZX*>& pGDArray)
{
	if (pGDArray.size() <= 1)
		return;

	BAS_DRAW_FUN BAS;
	ZCGTZX* pGTZX;
	ACHAR BH1[STR_LONG];
	ACHAR  BH2[STR_SHORT];
	for (int i = 1; i < (int)pGDArray.size(); i++)
	{
		for (int j = (int)pGDArray.size() - 1; j >= i; j--)
		{
			ChangeTextType(pGDArray[j]->DesignBianHao, 3, BH1);
			ChangeTextType(pGDArray[j - 1]->DesignBianHao, 3, BH2);
			if (mscmp2(BH1, BH2) < 0)
			{
				pGTZX = pGDArray[j - 1];
				pGDArray[j - 1] = pGDArray[j];
				pGDArray[j] = pGTZX;
			}
		}
	}
	int num1, num2;
	if (pGDArray[0]->XLType == 1)
	{
		for (int i = 0; i < (int)pGDArray.size() - 1; i++)
		{
			for (int j = i + 1; j < (int)pGDArray.size(); j++)
			{
				if (pGDArray[i]->XLType == 1 && pGDArray[j]->XLType == 1)
				{
					num1 = BAS.covertRoman2ALB(pGDArray[i]->DesignBianHao);
					num2 = BAS.covertRoman2ALB(pGDArray[j]->DesignBianHao);
					if (num1 > num2)
					{
						pGTZX = pGDArray[i];
						pGDArray[i] = pGDArray[j];
						pGDArray[j] = pGTZX;
					}
				}
			}
		}
	}
}

//传入一批股道，按类别分类
void ZCGTZX::Sort_GDTypeArray(vector<ZCGTZX*>& pGTZXArray)
{
	//对所有股道循环
	ZCGTZX* pGTZX = NULL;
	int num1 = 0, num2 = 0;
	//对股道排序
	for (int i = 0; i < (int)pGTZXArray.size(); i++)
	{
		for (int j = i + 1; j < (int)pGTZXArray.size(); j++)
		{
			num1 = pGTZXArray[i]->XLType;
			num2 = pGTZXArray[j]->XLType;
			if (num1 > num2)
			{
				pGTZX = pGTZXArray[i];
				pGTZXArray[i] = pGTZXArray[j];
				pGTZXArray[j] = pGTZX;
			}
		}
	}

	//分类
	vector<vector<ZCGTZX*>>pGDTypeArray;
	pGDTypeArray.clear();
	for (int i = 0; i < (int)pGTZXArray.size(); i++)
		Judge_GDType(pGTZXArray[i], pGDTypeArray);

	//每一类股道内部排序
	for (int i = 0; i < (int)pGDTypeArray.size(); i++)
		Sort_GD(pGDTypeArray[i]);

	//最后再整合
	int k = 0;
	for (int i = 0; i < (int)pGDTypeArray.size(); i++)
	{
		for (int j = 0; j < (int)pGDTypeArray[i].size(); j++)
		{
			pGTZXArray[k] = pGDTypeArray[i][j];
			k++;
		}
	}
}
void  ZCGTZX::setINIT(int nlc, int nh, int Chinese_Engbz, double Texth)
{
	//assertWriteEnabled();该函数是用来验证当前操作节点是否以写方式打开而进行操作的，其中每一个参数autoUndo就是标记调用这个接口的成员函数中，是不是会自动进行undo记录。
	NLC = nlc;
	NH = nh;
	texth = Texth;
}
void ZCGTZX::SetGDSX(Track TrackData)
{
	//	assertWriteEnabled();
	_tcscpy(DesignBianHao, TrackData.DesignBianHao);
	_tcscpy(DesignJYBianHao, TrackData.DesignJYBianHao);
	_tcscpy(DesignCZXBianHao, TrackData.DesignCZXBianHao);
	_tcscpy(BianHao, TrackData.BianHao);
	_tcscpy(BianHao, TrackData.BianHao);
	_tcscpy(CZXBianHao, TrackData.CZXBianHao);
	//	_tcscpy(TrackType,TrackData.TrackType);
	_tcscpy(JLType, TrackData.JLType);
	_tcscpy(JLDirection, TrackData.JLDirection);
	UpValidL = TrackData.UpValidL;
	DownValidL = TrackData.DownValidL;
	Span = TrackData.Span;
	TracklayingL = TrackData.TracklayingL;

	_tcscpy(SJST, TrackData.SJST);
	//_tcscpy(LCGH,TrackData.LCGH);

	ISHWCX = TrackData.ISHWCX;
	XLType = TrackData.XLType;

	LengthBeforeBZ = TrackData.LengthBeforeBZ;
	LengthAfterBZ = TrackData.LengthAfterBZ;
	isYanShen = TrackData.isYanShen;
	YanShenLength = TrackData.YanShenLength;
	LCcanzhao = TrackData.LCcanzhao;
	BPDLCdir = TrackData.BPDLCdir;
	isYLDoHDM = TrackData.isYLDoHdm;
	isDXGD = TrackData.isDXGD;
	IsJiSuanJiZhunXian = TrackData.IsJiSuanJiZhunXian;

	_tcscpy(SXYXCQDID, L"");
	_tcscpy(SXYXCZDID, L"");
	_tcscpy(XXYXCQDID, L"");
	_tcscpy(XXYXCZDID, L"");

	SXYXCQDType = 0;//1-信号机  2-警冲标 3-道岔a端 4-车挡  
	SXYXCZDType = 0;//1-信号机  2-警冲标 3-道岔a端 4-车挡  
	XXYXCQDType = 0;//1-信号机  2-警冲标 3-道岔a端 4-车挡  
	XXYXCZDType = 0;//1-信号机  2-警冲标 3-道岔a端 4-车挡  

	_tcscpy(SXYXCQDID_YL, L"");
	_tcscpy(SXYXCZDID_YL, L"");
	_tcscpy(XXYXCQDID_YL, L"");
	_tcscpy(XXYXCZDID_YL, L"");

	SXYXCQDType_YL = 0;//1-信号机  2-警冲标 3-道岔a端 4-车挡  
	SXYXCZDType_YL = 0;//1-信号机  2-警冲标 3-道岔a端 4-车挡  
	XXYXCQDType_YL = 0;//1-信号机  2-警冲标 3-道岔a端 4-车挡  
	XXYXCZDType_YL = 0;//1-信号机  2-警冲标 3-道岔a端 4-车挡  

	m_IfHasGF = TrackData.IfHasGF;
	StartCml = TrackData.startMileage;
}
void ZCGTZX::SetJDQXBHstr(ACHAR In_JDStrArray[MAXJDNUM][STR_SHORT], ACHAR In_QXBHStrArray[MAXJDNUM][STR_SHORT])
{
	for (int i = 0; i < NJD; i++)
	{
		_tcscpy(JDStrArray[i], In_JDStrArray[i]);
		_tcscpy(QXBHStrArray[i], In_QXBHStrArray[i]);
	}
}
//  设置断链数据
BOOL  ZCGTZX::setDLM(int iDL, double BLC, double DL, const ACHAR* BGH, const ACHAR* EGH, int mode)
{
	if (iDL >= 0 && iDL < NDL)
	{
		_tcscpy(DLB[iDL].BGH, BGH);
		_tcscpy(DLB[iDL].EGH, EGH);
		DLB[iDL].BLC = BLC;
		DLB[iDL].DL = DL;
		//起点
		if (iDL == 0)
			JDarray[0][3] = BLC + DL;
		return TRUE;
	}
	else
		return FALSE;
}

void ZCGTZX::SetGGLXArray(GGLXArray InGGLXArray, bool IsAdd)
{
	//	ACHAR GH[STR_MIN];
	if (IsAdd)
	{
		for (int i = 0; i < (int)InGGLXArray.size(); i++)
		{
			//			split_ckml(InGGLXArray[i].FDLC,&InGGLXArray[i].FDCML,GH);
			m_GGLXArray.push_back(InGGLXArray[i]);
		}

	}
	else
	{
		m_GGLXArray.clear();
		m_GGLXArray.resize((int)InGGLXArray.size());
		for (int i = 0; i < (int)InGGLXArray.size(); i++)
		{
			//		split_ckml(InGGLXArray[i].FDLC,&InGGLXArray[i].FDCML,GH);
			m_GGLXArray[i] = InGGLXArray[i];
		}
	}
	xlpoint PZ;
	for (int i = 0; i < (int)m_GGLXArray.size(); i++)
	{
		TrsCmltoNE(m_GGLXArray[i].FDCML, PZ);
		m_GGLXArray[i].N = PZ.x;
		m_GGLXArray[i].E = PZ.y;
	}
}
void ZCGTZX::SetDefaultGGLXArray()
{
	gglxinf gglxinfo;
	//计算现场里程
	double endcml;

	endcml = DLB[0].BLC + DLB[0].DL + xl_length;

	//	TrsCmltoCkml(endcml,gglxinfo.FDLC,3);
		//设置标准数据
	gglxinfo.FDCML = endcml;
	gglxinfo.YXGFlag = 0;//不加异型轨
	_tcscpy(gglxinfo.GGLX, L"50");
	CString xltype;
	xltype = ConvertXLTypeToCstring(XLType);
	for (int i = 0; i < (int)GlobalSJYZ.guidaobiaozhunArray.size(); i++)
	{
		if (GlobalSJYZ.guidaobiaozhunArray[i].ZxID == xltype)
		{
			_tcscpy(gglxinfo.GGLX, GlobalSJYZ.guidaobiaozhunArray[i].Gglx);
			break;
		}
	}
	_tcscpy(gglxinfo.DesignBianHao, DesignBianHao);
	_tcscpy(gglxinfo.BianHao, BianHao);
	xlpoint PZ;
	TrsCmltoNE(gglxinfo.FDCML, PZ);
	gglxinfo.N = PZ.x;
	gglxinfo.E = PZ.y;

	// 	vector<CBaseLine*>pBaseLineArray;
	// 	pBaseLineArray.clear();
	// 	CBaseLine* pBaseLine = NULL;
	// 	CalJXAndGD caljx;
	// 	caljx.GetBaseLineArrayFromLayer(pBaseLineArray);
	// 	AcGePoint3d Pt;
	// 	Pt.x = PZ.x;
	// 	Pt.y = PZ.y;
	// 	Pt.z = 0.0;
	// 	pBaseLine = CalJXAndGD::GetBaseLineFromPt(Pt,pBaseLineArray);

	// 	if (XLType==1)//正线
	// 		TrsCmltoCkml(endcml,gglxinfo.FDLC,3);
	// 	else//投影到基线上的里程
	// 		pBaseLine->TrsNEtoCkml(PZ.x,PZ.y,gglxinfo.FDLC);
		//节点加入m_DCBPArray
	m_GGLXArray.clear();
	m_GGLXArray.push_back(gglxinfo);
}
bool ZCGTZX::TrsCmltoNE(double Cml, xlpoint& PZ, int isprinttext) const
{
	PZ.lc = Cml;
	xlpoint_pz(array, tarray, &PZ, isprinttext);
	return true;
}
void ZCGTZX::SetDZLXArray(GZLCArray InDZLXArray, bool IsAdd)
{
	//	ACHAR GH[STR_MIN];
	if (IsAdd)
	{
		for (int i = 0; i < (int)InDZLXArray.size(); i++)
		{
			//split_ckml(InDZLXArray[i].FDLC,&InDZLXArray[i].FDCML,GH);
			m_GZLCArray.push_back(InDZLXArray[i]);
		}

	}
	else
	{
		m_GZLCArray.clear();
		m_GZLCArray = InDZLXArray;
	}
}
void ZCGTZX::SetHLGLXArray(HLGLXArray InHLGLXArray, bool IsAdd)
{
	//	ACHAR GH[STR_MIN];
	if (IsAdd)
	{
		for (int i = 0; i < (int)InHLGLXArray.size(); i++)
		{
			//split_ckml(InDZLXArray[i].FDLC,&InDZLXArray[i].FDCML,GH);
			m_HLGLXArray.push_back(InHLGLXArray[i]);
		}

	}
	else
	{
		m_HLGLXArray.clear();
		m_HLGLXArray = InHLGLXArray;
	}
}
void ZCGTZX::SetDefaultHLGLXArray()
{
	// 	hlglxinf hlglxinfo;
	// 	//设置标准数据
	// 	hlglxinfo.BianCe = 0;
	// 	hlglxinfo.StartFDCml = 0;
	// 	hlglxinfo.EndFDCml = DLB[0].BLC+DLB[0].DL+xl_length; 
	//  //	_tcscpy(hlglxinfo.EndFDLC,L"");
	//  //	_tcscpy(hlglxinfo.StartFDLC,L"");
	// 	
	// 	BAS_DRAW_FUN::xlpoint PZ;
	// 	TrsCmltoNE(hlglxinfo.EndFDCml,PZ);
	// 
	// 	_tcscpy(hlglxinfo.BianHao,BianHao);
	// 	_tcscpy(hlglxinfo.DesignBianHao,DesignBianHao);
		//节点加入m_DCBPArray
	m_HLGLXArray.clear();
	//	m_HLGLXArray.push_back(hlglxinfo);
}
void ZCGTZX::SetBPDArray(int NPD, vector<PDTAB>BPDArr, bool IsAdd)
{
	if (IsAdd)
	{
		for (int i = 0; i < NPD; i++)
			m_BPDArray.push_back(BPDArr[i]);
	}
	else
	{
		m_BPDArray.clear();
		m_BPDArray.resize(NPD);
		for (int i = 0; i < NPD; i++)
		{
			m_BPDArray[i] = BPDArr[i];
		}
	}
}
CString ZCGTZX::ConvertXLTypeIntToCstring(int xltype)
{
	CString XLtypeStr;
	if ((int)GlobalSJYZ.G_GTZXXltypeArray.size() == 0)
		return L"其它线路";
	if (xltype > 0 && xltype < (int)GlobalSJYZ.G_GTZXXltypeArray.size() + 1)
		return(GlobalSJYZ.G_GTZXXltypeArray[xltype - 1]);
	return L"到发线";
}
CString ZCGTZX::ConvertXLTypeToCstring(int xltype)
{
	CString XLtypeStr;
	// 	if (GlobalSJYZ.G_GTZXXltypeArray.size()==0)
	// 		return L"其它线路";
	// 	if (xltype>0&&xltype<GlobalSJYZ.G_GTZXXltypeArray.size()+1)
	// 		return(GlobalSJYZ.G_GTZXXltypeArray[xltype-1]);
	// 	return L"到发线";

	if (xltype == 1)
	{
		XLtypeStr = L"正线";
	}
	else if (xltype == 2)
	{
		XLtypeStr = L"到发线";
	}
	else /*if (xltype==3)*/
	{
		XLtypeStr = L"其他站线";
	}
	// 	else 
	// 	{
	// 		XLtypeStr=L"次要站线";
	// 	}
	return XLtypeStr;
}
void ZCGTZX::SetDZLCArray(DZLCArray InDZLCArray, bool IsAdd)
{
	//	ACHAR GH[STR_MIN];
	if (IsAdd)
	{
		for (int i = 0; i < (int)InDZLCArray.size(); i++)
		{
			//split_ckml(InDZLXArray[i].FDLC,&InDZLXArray[i].FDCML,GH);
			m_DZLCArray.push_back(InDZLCArray[i]);
		}

	}
	else
	{
		m_DZLCArray.clear();
		m_DZLCArray = InDZLCArray;
	}

}
void ZCGTZX::SetDefaultDZLXArray()
{
	gzlcinf dzlxinfo;
	//计算现场里程
	double endcml;
	endcml = DLB[0].BLC + DLB[0].DL + xl_length;
	//设置标准数据
	dzlxinfo.FDCML = endcml;
	_tcscpy(dzlxinfo.GZTYPE, L"新Ⅱ型混凝土枕");
	dzlxinfo.zmsl = 1520;
	CString xltype;
	xltype = ConvertXLTypeToCstring(XLType);
	for (int i = 0; i < (int)GlobalSJYZ.guidaobiaozhunArray.size(); i++)
	{
		if (GlobalSJYZ.guidaobiaozhunArray[i].ZxID == xltype)
		{
			dzlxinfo.zmsl = GlobalSJYZ.guidaobiaozhunArray[i].N_zhenmuperKm;
			_tcscpy(dzlxinfo.GZTYPE, GlobalSJYZ.guidaobiaozhunArray[i].GzType);
		}
	}

	xlpoint PZ;
	TrsCmltoNE(dzlxinfo.FDCML, PZ);

	// 	vector<CBaseLine*>pBaseLineArray;
	// 	pBaseLineArray.clear();
	// 	CBaseLine* pBaseLine = NULL;
	// 	CalJXAndGD caljx;
	// 	caljx.GetBaseLineArrayFromLayer(pBaseLineArray);
	// 	AcGePoint3d Pt;
	// 	Pt.x = PZ.x;
	// 	Pt.y = PZ.y;
	// 	Pt.z = 0.0;
	// 	pBaseLine = CalJXAndGD::GetBaseLineFromPt(Pt,pBaseLineArray);

	// 	if (XLType==1)//正线
	// 		TrsCmltoCkml(dzlxinfo.FDCML,dzlxinfo.FDLC,3);
	// 	else//投影到基线上的里程
	// 		pBaseLine->TrsNEtoCkml(PZ.x,PZ.y,dzlxinfo.FDLC);

	_tcscpy(dzlxinfo.BianHao, BianHao);
	_tcscpy(dzlxinfo.DesignBianHao, DesignBianHao);
	dzlxinfo.N = 0.0;
	dzlxinfo.E = 0.0;
	dzlxinfo.dml = 0.0;
	//节点加入m_DCBPArray
	m_GZLCArray.clear();
	m_GZLCArray.push_back(dzlxinfo);
}
void ZCGTZX::SetDefaultDHArray()
{
	m_DHArray.resize(1);
	m_DHArray[0].isDH = 1;
	m_DHArray[0].FDCML = DLB[0].BLC + DLB[0].DL + xl_length;
	_tcscpy(m_DHArray[0].BianHao, BianHao);
	_tcscpy(m_DHArray[0].DesignBianHao, DesignBianHao);
}
void ZCGTZX::SetDefaultDZLCArray()
{
	dzlcinf dzlcinfo;
	//计算现场里程
	double endcml;
	endcml = DLB[0].BLC + DLB[0].DL + xl_length;

	//设置标准数据
	dzlcinfo.FDCML = endcml;

	xlpoint PZ;
	TrsCmltoNE(dzlcinfo.FDCML, PZ);

	_tcscpy(dzlcinfo.BianHao, BianHao);
	_tcscpy(dzlcinfo.DesignBianHao, DesignBianHao);

	_tcscpy(dzlcinfo.DZTYPE, L"I级道砟");
	dzlcinfo.UpBottomkuan = 0;
	dzlcinfo.GDgaodu_DZhoudu = 0;
	dzlcinfo.polv = 0;

	CString xltype;
	xltype = ConvertXLTypeToCstring(XLType);
	for (int i = 0; i < (int)GlobalSJYZ.guidaobiaozhunArray.size(); i++)
	{
		if (GlobalSJYZ.guidaobiaozhunArray[i].ZxID == xltype)
		{
			_tcscpy(dzlcinfo.DZTYPE, GlobalSJYZ.guidaobiaozhunArray[i].daozhadengji);
			dzlcinfo.UpBottomkuan = GlobalSJYZ.guidaobiaozhunArray[i].DaocDk;
			dzlcinfo.GDgaodu_DZhoudu = GlobalSJYZ.guidaobiaozhunArray[i].DaocH;
			if (GlobalSJYZ.guidaobiaozhunArray[i].daozhadengji.Find(L"无砟") >= 0 || _tcscmp(GlobalSJYZ.guidaobiaozhunArray[i].daozhadengji, L"整体道床") == 0)
				dzlcinfo.GDgaodu_DZhoudu = GlobalSJYZ.guidaobiaozhunArray[i].WFguidao;
			dzlcinfo.polv = 1;
			break;
		}
	}
	m_DZLCArray.clear();
	m_DZLCArray.push_back(dzlcinfo);
}
void ZCGTZX::SetLYDArray(LYDArray InLYDArray, bool IsAdd)
{
	if (IsAdd)
	{
		for (int i = 0; i < (int)InLYDArray.size(); i++)
		{
			m_LYDArray.push_back(InLYDArray[i]);
		}

	}
	else
	{
		xlpoint PZtmp;
		m_LYDArray.clear();
		m_LYDArray.resize((int)InLYDArray.size());
		for (int i = 0; i < (int)InLYDArray.size(); i++)
			m_LYDArray[i] = InLYDArray[i];
		for (int i = 0; i < (int)m_LYDArray.size(); i++)
		{
			TrsCmltoNE(m_LYDArray[i].StartFDCml, PZtmp);
			m_LYDArray[i].StaPt.x = PZtmp.x;
			m_LYDArray[i].StaPt.y = PZtmp.y;

			TrsCmltoNE(m_LYDArray[i].EndFDCml, PZtmp);
			m_LYDArray[i].EndPt.x = PZtmp.x;
			m_LYDArray[i].EndPt.y = PZtmp.y;
		}
	}

}
void ZCGTZX::SetChaiChuArray(ChaiChuArray InChaiChuArray, bool IsAdd)
{
	if (IsAdd)
	{
		for (int i = 0; i < (int)InChaiChuArray.size(); i++)
		{
			m_ChaiChuArray.push_back(InChaiChuArray[i]);
		}

	}
	else
	{
		xlpoint PZtmp;
		m_ChaiChuArray.clear();
		m_ChaiChuArray.resize((int)InChaiChuArray.size());
		for (int i = 0; i < (int)InChaiChuArray.size(); i++)
			m_ChaiChuArray[i] = InChaiChuArray[i];
		for (int i = 0; i < (int)m_ChaiChuArray.size(); i++)
		{
			TrsCmltoNE(m_ChaiChuArray[i].StartFDCml, PZtmp);
			m_ChaiChuArray[i].StaPt.x = PZtmp.x;
			m_ChaiChuArray[i].StaPt.y = PZtmp.y;

			TrsCmltoNE(m_ChaiChuArray[i].EndFDCml, PZtmp);
			m_ChaiChuArray[i].EndPt.x = PZtmp.x;
			m_ChaiChuArray[i].EndPt.y = PZtmp.y;
		}
	}

}
//DCDKArray m_DCDKArray;//道床顶宽
void ZCGTZX::SetDCDKArray(DCDKArray InDCDKArray, bool IsAdd)
{
	//	ACHAR GH[STR_MIN];
	if (IsAdd)
	{
		for (int i = 0; i < (int)InDCDKArray.size(); i++)
		{
			/*split_ckml(InDCDKArray[i].FDLC,&InDCDKArray[i].FDCML,GH);*/
			m_DCDKArray.push_back(InDCDKArray[i]);
		}

	}
	else
	{
		m_DCDKArray.clear();
		m_DCDKArray = InDCDKArray;
	}
}
void ZCGTZX::SetDefaultDCDKArray()
{
	dcdkinf dcdkinfo;
	//计算现场里程
	double endcml;
	endcml = DLB[0].BLC + DLB[0].DL + xl_length;
	/*TrsCmltoCkml(endcml,dcdkinfo.FDLC,3);*/
	//设置标准数据
	dcdkinfo.FDCML = endcml;
	dcdkinfo.DCDK = 3.0;
	CString xltype;
	xltype = ConvertXLTypeToCstring(XLType);
	for (int i = 0; i < (int)GlobalSJYZ.guidaobiaozhunArray.size(); i++)
	{
		if (GlobalSJYZ.guidaobiaozhunArray[i].ZxID == xltype)
		{
			dcdkinfo.DCDK = GlobalSJYZ.guidaobiaozhunArray[i].DaocDk;
		}
	}
	_tcscpy(dcdkinfo.BianHao, BianHao);
	_tcscpy(dcdkinfo.DesignBianHao, DesignBianHao);
	//节点加入m_DCBPArray
	m_DCDKArray.clear();
	m_DCDKArray.push_back(dcdkinfo);
};
int ZCGTZX::GetSJST() const
{
	if (_tcscmp(SJST, L"新建") == 0)
		return 0;
	else if (_tcscmp(SJST, L"既有") == 0)
		return 1;
	else if (_tcscmp(SJST, L"在建") == 0)
		return 2;
	else if (_tcscmp(SJST, L"近期预留") == 0)
		return 3;
	else if (_tcscmp(SJST, L"远期预留") == 0)
		return 4;
	else if (_tcscmp(SJST, L"远景预留") == 0)
		return 5;
	else
		return 4;//为兼顾之前的预留状态，因此此处当查找不到时态时，默认返回远期预留
}
int ZCGTZX::ConvertXLTypeToInt(CString xltype)
{
	CString XianLuBieMing = L"";
	if (xltype == L"其他站线")
		XianLuBieMing = L"其它线路";
	CString XLtypeStr;
	if (GlobalSJYZ.G_GTZXXltypeArray.size() == 0)
		return 2;
	for (int i = 0; i < (int)GlobalSJYZ.G_GTZXXltypeArray.size(); i++)
	{
		if (GlobalSJYZ.G_GTZXXltypeArray[i] == xltype || GlobalSJYZ.G_GTZXXltypeArray[i] == XianLuBieMing)
			return i + 1;
	}

	return 2;
}
ZCGTZX::ZCGTZX()
{
	isHuiTouQuXian = 0;
}
ZCGTZX::ZCGTZX(onetrack& PTArray, CString style)
{
	int iNJD = PTArray.Trackpointnum;
	double iJDarray[MAXJDNUM][7];
	for (int i = 0; i < MAXJDNUM; i++)
		for (int j = 0; j < 7; j++)
			iJDarray[i][j] = 0.0;
	for (int trow = 0; trow < iNJD; trow++)
	{
		iJDarray[trow][0] = trow + 1;
		iJDarray[trow][1] = PTArray.pTrackpoint[trow].y;
		iJDarray[trow][2] = PTArray.pTrackpoint[trow].x;
		iJDarray[trow][3] = 0;
		iJDarray[trow][4] = PTArray.pTrackpoint[trow].z;
		iJDarray[trow][5] = 0;
	}


	XLType = 3;
	XLType = ConvertXLTypeToInt(style);
	IsDrawPDB = 0;

	CString DrawXLType;
	int STIndex = 0;
	//ACHAR DrawTuCeng[STR_SHORT];
	_tcscpy(SJST, L"新建");
	STIndex = GetSJST();
	int i = 0, j;
	ACHAR EGH[STR_MIN];
	ACHAR GH[STR_MIN];
	m_BZQXBHPt.resize(iNJD);
	m_BZQXYSPt.resize(iNJD);
	Angle4Lable.resize(iNJD);
	SXYXCQDType = 3;
	_tcscpy(SXYXCQDID, L"");
	SXYXCZDType = 3;
	_tcscpy(SXYXCZDID, L"");

	XXYXCQDType = 3;
	_tcscpy(XXYXCQDID, L"");
	XXYXCZDType = 3;
	_tcscpy(XXYXCZDID, L"");

	_tcscpy(GH, L"DK");
	_tcscpy(JDGH, L"J");
	for (i = 0; i < MAXJDNUM; i++)
	{
		for (j = 0; j < 7; j++)
			JDarray[i][j] = iJDarray[i][j];
		_stprintf(JDStrArray[i], L"%s%d", JDGH, (int)(JDarray[i][0] + 0.1));
	};

	NJD = iNJD;
	NDL = 1;
	setDLM(0, JDarray[0][3], 0.0, GH, GH);

	NDL = 2;
	_tcscpy(EGH, GH);
	setDLM(1, 900000, 0, GH, EGH);
	//  根据NJD个交点坐标(含起点、终点)JDarray[][]和曲线R L1、L2 计算线元array_pxy[][][]和曲线表QXB[][]
	CBaseLine data11;
	data11.getpxy_DATA();
	BZ_StartCml = StartCml;
	BZ_EndCml = EndCml;//ph2019-6-25

	/*
	 // 终点  作为一特殊断链点
	 NDL=NDL+1;
	 DLB[NDL-1].BLC= QXB[NJD-1][0] ;   DLB[0].DL=0.0;
	 strcpy(DLB[NDL-1].BGH,DLB[NDL-2].EGH);    strcpy(DLB[NDL-1].EGH,DLB[NDL-1].BGH );
	*/
	NDL = 2;
	//   setDLM(2,QXB[NJD-1][0],0.0,EGH,EGH ); 	
	setDLM(1, QXB[NJD - 1][0], 0.0, EGH, EGH);
	ISDrawDH = 0;
	ISDrawGGLXFD = 0;
	ISDrawPeiGui = 0;
	DangQianBanJing = 1000;
	isHuiTouQuXian = 0;
}
ZCGTZX::ZCGTZX(vector<DPoint3d>PTArray, CString style)
{

	int iNJD = (int)PTArray.size();
	double iJDarray[MAXJDNUM][7];
	for (int i = 0; i < MAXJDNUM; i++)
		for (int j = 0; j < 7; j++)
			iJDarray[i][j] = 0.0;
	for (int trow = 0; trow < iNJD; trow++)
	{
		iJDarray[trow][0] = trow + 1;
		iJDarray[trow][1] = PTArray[trow].y;
		iJDarray[trow][2] = PTArray[trow].x;
		iJDarray[trow][3] = 0;
		iJDarray[trow][4] = PTArray[trow].z;
		iJDarray[trow][5] = 0;
	}


	XLType = 3;
	XLType = ConvertXLTypeToInt(style);
	IsDrawPDB = 0;

	CString DrawXLType;
	int STIndex = 0;
	//ACHAR DrawTuCeng[STR_SHORT];
	_tcscpy(SJST, L"新建");
	STIndex = GetSJST();
	int i = 0, j;
	ACHAR EGH[STR_MIN];
	ACHAR GH[STR_MIN];
	m_BZQXBHPt.resize(iNJD);
	m_BZQXYSPt.resize(iNJD);
	Angle4Lable.resize(iNJD);

	SXYXCQDType = 3;
	_tcscpy(SXYXCQDID, L"");
	SXYXCZDType = 3;
	_tcscpy(SXYXCZDID, L"");

	XXYXCQDType = 3;
	_tcscpy(XXYXCQDID, L"");
	XXYXCZDType = 3;
	_tcscpy(XXYXCZDID, L"");

	_tcscpy(GH, L"DK");
	_tcscpy(JDGH, L"J");
	for (i = 0; i < MAXJDNUM; i++)
	{
		for (j = 0; j < 7; j++)
			JDarray[i][j] = iJDarray[i][j];
		_stprintf(JDStrArray[i], L"%s%d", JDGH, (int)(JDarray[i][0] + 0.1));
	};

	NJD = iNJD;
	NDL = 1;
	setDLM(0, JDarray[0][3], 0.0, GH, GH);

	NDL = 2;
	_tcscpy(EGH, GH);
	setDLM(1, 900000, 0, GH, EGH);
	//  根据NJD个交点坐标(含起点、终点)JDarray[][]和曲线R L1、L2 计算线元array_pxy[][][]和曲线表QXB[][]
	CBaseLine data11;
	data11.getpxy_DATA();
	BZ_StartCml = StartCml;
	BZ_EndCml = EndCml;//ph2019-6-25

	/*
	 // 终点  作为一特殊断链点
	 NDL=NDL+1;
	 DLB[NDL-1].BLC= QXB[NJD-1][0] ;   DLB[0].DL=0.0;
	 strcpy(DLB[NDL-1].BGH,DLB[NDL-2].EGH);    strcpy(DLB[NDL-1].EGH,DLB[NDL-1].BGH );
	*/
	NDL = 2;
	//   setDLM(2,QXB[NJD-1][0],0.0,EGH,EGH ); 	
	setDLM(1, QXB[NJD - 1][0], 0.0, EGH, EGH);
	ISDrawDH = 0;
	ISDrawGGLXFD = 0;
	ISDrawPeiGui = 0;
	isHuiTouQuXian = 0;
}
ZCGTZX::ZCGTZX(int iNJD, double iJDarray[MAXJDNUM][7], ACHAR iJDStrArray[MAXJDNUM][STR_SHORT], ACHAR* GH, ACHAR* JDchr)
{

	CString DrawXLType;
	int STIndex = 0;
	//ACHAR DrawTuCeng[STR_SHORT];
	STIndex = GetSJST();
	DrawXLType = ConvertXLTypeToCstring(XLType);
	//TransGDDirectionFromJX();
	int i = 0, j;
	ACHAR EGH[STR_MIN];

	_tcscpy(JDGH, JDchr);
	for (i = 0; i < iNJD; i++)
	{

		for (j = 0; j < 7; j++)
			JDarray[i][j] = iJDarray[i][j];

		_tcscpy(JDStrArray[i], iJDStrArray[i]);
		//_stprintf(JDStrArray[i],L"%s%d",JDGH,(int)(JDarray[i][0]+0.1));
		_stprintf(QXBHStrArray[i], L"V%d", (int)(JDarray[i][0] + 0.1));
	}
	JD0 = int(JDarray[0][0] + 0.1);
	NJD = iNJD;
	NDL = 1;
	setDLM(0, JDarray[0][3], 0.0, GH, GH);

	NDL = 2;
	_tcscpy(EGH, GH);//plh04.11.25
	setDLM(1, 950, 250, GH, GH);//plh04.11.25 	
	//  根据NJD个交点坐标(含起点、终点)JDarray[][]和曲线R L1、L2 计算线元array_pxy[][][]和曲线表QXB[][]
	CBaseLine data11;
	data11.getpxy_DATA();

	BZ_StartCml = StartCml;
	BZ_EndCml = EndCml;//ph2019-6-25,里程标注段落


	NDL = 2;
	setDLM(1, QXB[NJD - 1][0], 0.0, EGH, EGH); //plh04.11.25	
	isHuiTouQuXian = 0;


	m_BZQXBHPt.clear();
	m_BZQXBHPt.resize(NJD);
	for (int i1 = 0; i1 < (int)m_BZQXBHPt.size(); i1++)
	{
		m_BZQXBHPt[i].x = -99999.0;
		m_BZQXBHPt[i].y = -99999.0;
	}

	m_BZQXYSPt.clear();
	m_BZQXYSPt.resize(NJD);
	for (int i2 = 0; i2 < (int)m_BZQXYSPt.size(); i2++)
	{
		m_BZQXYSPt[i].x = -99999.0;
		m_BZQXYSPt[i].y = -99999.0;
	}
	Angle4Lable.clear();
	Angle4Lable.resize(NJD);
	for (int i3 = 0; i3 < (int)Angle4Lable.size(); i3++)
		Angle4Lable[i] = 0.0;
}
ZCGTZX::ZCGTZX(int iNJD, double iJDarray[MAXJDNUM][7], const ACHAR* GH, const ACHAR* JDchr)
{
	IsDrawPDB = 0;

	CString DrawXLType;
	int STIndex = 0;
	//ACHAR DrawTuCeng[STR_SHORT];
	STIndex = GetSJST();
	DrawXLType = ConvertXLTypeToCstring(XLType);
	int i = 0, j;
	ACHAR EGH[STR_MIN];
	//TransGDDirectionFromJX();

	_tcscpy(JDGH, JDchr);
	for (i = 0; i < MAXJDNUM; i++)
	{
		for (j = 0; j < 7; j++)
			JDarray[i][j] = iJDarray[i][j];

		_stprintf(QXBHStrArray[i], L"V%d", (int)(JDarray[i][0] + 0.1));
		_stprintf(JDStrArray[i], L"%s%d", JDGH, (int)(JDarray[i][0] + 0.1));
	};
	//	 for (i=0;i<100;i++)
	//	{  for ( j=0;j<3;j++) QXLRL[i][j]=iJDarray[i][3+j];	    };
	NJD = iNJD;
	NDL = 1;
	setDLM(0, JDarray[0][3], 0.0, GH, GH);


	NDL = 2;
	_tcscpy(EGH, GH);
	setDLM(1, 900000, 0, GH, EGH);
	//  根据NJD个交点坐标(含起点、终点)JDarray[][]和曲线R L1、L2 计算线元array_pxy[][][]和曲线表QXB[][]
	CBaseLine data11;
	data11.getpxy_DATA();

	BZ_StartCml = StartCml;
	BZ_EndCml = EndCml;//ph2019-6-25,里程标注段落

	/*
	 // 终点  作为一特殊断链点
	 NDL=NDL+1;
	 DLB[NDL-1].BLC= QXB[NJD-1][0] ;   DLB[0].DL=0.0;
	 strcpy(DLB[NDL-1].BGH,DLB[NDL-2].EGH);    strcpy(DLB[NDL-1].EGH,DLB[NDL-1].BGH );
	*/
	NDL = 2;
	//   setDLM(2,QXB[NJD-1][0],0.0,EGH,EGH ); 	
	setDLM(1, QXB[NJD - 1][0], 0.0, EGH, EGH);
	_tcscpy(LCGH, DLB[0].EGH);//里程冠号 

	m_BZQXBHPt.clear();
	m_BZQXBHPt.resize(NJD);
	for (int i4 = 0; i4 < (int)m_BZQXBHPt.size(); i4++)
	{
		m_BZQXBHPt[i].x = -99999.0;
		m_BZQXBHPt[i].y = -99999.0;
	}

	m_BZQXYSPt.clear();
	m_BZQXYSPt.resize(NJD);
	for (int i5 = 0; i5 < (int)m_BZQXYSPt.size(); i5++)
	{
		m_BZQXYSPt[i].x = -99999.0;
		m_BZQXYSPt[i].y = -99999.0;
	}
	Angle4Lable.clear();
	Angle4Lable.resize(NJD);
	for (int i6 = 0; i6 < (int)Angle4Lable.size(); i6++)
		Angle4Lable[i] = 0.0;

	isHuiTouQuXian = 0;
}
ZCGTZX::ZCGTZX(CString BIANHAO)
{
	StationDataBase DBS;
	BAS_DRAW_FUN ob;
	ob.ReadWorkdir();
	CString m_MdbName = Cworkdir + "\\data\\" + Pro + DBEXT;
	CString InquireString = L"[" + ENC("对象ID") + L"]=\"" + BIANHAO + L"\"";
	CalJXAndGD pCalJXAndGD;
	vector<CBaseLine*>In_pBaseLineArray;
	In_pBaseLineArray.clear();
	CBaseLine* pBaseLine;
	if (DBS.Read_StationDbs(m_MdbName, ENC("股道曲线表"), InquireString))
	{
		NJD = DBS.NJD;
		for (int i = 0; i < DBS.NJD; i++)
		{
			pBaseLine = pCalJXAndGD.GetBaseLineFromBianhao(DBS.CZJXStrArray[i], In_pBaseLineArray);
			if (pBaseLine == NULL)
				pBaseLine = pCalJXAndGD.GetBaseLineFromCkml(DBS.QXJDB[i].JDCKml, In_pBaseLineArray);
			pBaseLine->TrsCkmlPtToNE(DBS.QXJDB[i].JDCKml, DBS.QXJDB[i].DistToJX,
				DBS.JDarray[i][1], DBS.JDarray[i][2]);
			for (int j = 0; j < 7; j++)
			{
				JDarray[i][j] = DBS.JDarray[i][j];
			}
		}
	}
	else
	{
		return;
	}
	if (NJD < 2) return;



	if (_tcscmp(DBS.JDGH, L"") == 0)
		_tcscpy(JDGH, L"JD");
	else
		_tcscpy(JDGH, DBS.JDGH);

	CBaseLine data11;
	data11.getpxy_DATA();

	BZ_StartCml = StartCml;
	BZ_EndCml = EndCml;//ph2019-6-25,里程标注段落

	_tcscpy(BianHao, BIANHAO);

	if (DBS.Read_StationDbs(m_MdbName, ENC("股道断链表"), InquireString))//读断链表
	{
		NDL = DBS.NDL;
		for (int i = 0; i < NDL; i++)
			setDLM(i, DBS.DLB[i].BLC, DBS.DLB[i].DL, DBS.DLB[i].BGH, DBS.DLB[i].EGH);
	}
	else
	{
		return;
	}
	//isJX = DBS.IsBaseLine;
	isHuiTouQuXian = 0;
}