From 4ed7fc8447d202e21ef9907e2aac63ef6fcbf301 Mon Sep 17 00:00:00 2001
From: zxd <zxdvslxy@gmail.com>
Date: 星期二, 17 十月 2023 12:33:23 +0800
Subject: [PATCH] 提交图码转换部分修改: 1.基本图形转换 2.ANS\ORS\PSHS\POPS命令的处理 3.重构了转换方法,命名为CMTerm1View::ScanLDSCells2();同时将翻译单独提出为方法CMTerm1View::Translate2Prog() 4.快捷键的添加绑定 5.其他相关方法修改,Insert,Delete,FocusChg…… 6.其他关联修改

---
 MTerm1/MTerm1View.cpp |  974 +++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 567 insertions(+), 407 deletions(-)

diff --git a/MTerm1/MTerm1View.cpp b/MTerm1/MTerm1View.cpp
index 4abbea4..8a0bc34 100644
--- a/MTerm1/MTerm1View.cpp
+++ b/MTerm1/MTerm1View.cpp
@@ -1155,6 +1155,7 @@
 				nCol = 0; 
 			}
 		}
+		CellFocusChg(nRow, nCol);
 	}
 	if (nChar == VK_RIGHT) {
 		nCol += 1;
@@ -1167,15 +1168,17 @@
 				nCol = m_CellPerLine - 1;
 			}
 		}
+		CellFocusChg(nRow, nCol);
 	}
 	if (nChar == VK_UP) {
 		nRow -= 1;
 		if (nRow < 0) { nRow = 0; }
+		CellFocusChg(nRow, nCol);
 	}
 	if (nChar == VK_DOWN) {
 		nRow += 1;
 		if (nRow >= m_nTotalRow + nLinesinView) { nRow = m_nTotalRow + nLinesinView -1; }
-
+		CellFocusChg(nRow, nCol);
 	}
 	m_FocusRow = nRow;
 	m_FocusCol = nCol;
@@ -1485,16 +1488,16 @@
 void CMTerm1View::OnProgConvert()
 {
 	//杞崲鍓嶅厛瀵筁DS鐨勮鍒欒繘琛屾楠岋紙妫�楠岃鍒欎笌杩斿洖鍙傛暟骞舵湭瀹屽叏纭畾
- 	std::pair<int,CString> result = LDSCheckRule();
-	if (result.first == 111)
-	{
-		DbgLog(result.second);
-		return;
-	}
+ //	std::pair<int,CString> result = LDSCheckRule();
+	//if (result.first == 111)
+	//{
+	//	DbgLog(result.second);
+	//	return;
+	//}
 
 	CString s1;
 	s1.Format(_T("Prog Convert"));
-	SysLog(s1);
+ 	SysLog(s1);
 	int r = TransLDSToProg();
 	s1.Format(_T("LDS To Prog result %d"), r);
 	SysLog(s1);
@@ -1591,6 +1594,12 @@
 /// <param name="cell1"></param>
 void CMTerm1View::SetCellToView(stCell cell1, int flag)               //**************************************************************************************************//
 {
+	bool changeVLine = false;
+	if ((Cells[m_FocusRow][m_FocusCol].bLeftLineDn != cell1.bLeftLineDn) 
+		|| (Cells[m_FocusRow][m_FocusCol].bLeftLineUp != cell1.bLeftLineUp))
+	{
+		changeVLine = true;
+	}
 	Cells[m_FocusRow][m_FocusCol] = cell1;
 	m_bModified = 1;
 	needReDraw = 1;
@@ -1614,6 +1623,7 @@
 		}
 		//娣诲姞绾电嚎鏃跺悓姝ユ坊鍔犱笂涓�琛�
 		Cells[m_FocusRow - 1][m_FocusCol].bLeftLineDn = 1;
+
 	}break;
 	case 2:
 	{
@@ -1625,13 +1635,18 @@
 		}
 		//鍒犻櫎绾电嚎鏃跺悓姝ュ垹闄や笂涓�琛�
 		Cells[m_FocusRow - 1][m_FocusCol].bLeftLineDn = 0;
+
 	}break;
 	default:
 		break;
 	}
-
-	//鍗曞厓鏍间綅缃悗绉�
-	m_FocusCol += 1;
+	//濡傛灉鍙樺寲鐨勬槸绔栫嚎锛岀劍鐐逛笉鍚庣Щ
+	if (!changeVLine)
+	{
+		//鍗曞厓鏍间綅缃悗绉�
+		m_FocusCol += 1;
+	}
+	
 	if (m_FocusCol >= 16) 
 	{ 
 		m_FocusCol = 0;
@@ -1951,6 +1966,9 @@
 	POINT StPts[100];
 	//	StPts[0] = POINT{ 0, 0 };
 	POINT EndPt[100];
+
+	POINT StrPt[100];
+	int nStrPts = 0;
 	int nEndPts = 0;
 	nSts = 0;
 	int nCurLine = 0;
@@ -2048,9 +2066,16 @@
 					}
 					else if (nPairOp == 0) 
 					{
-						nCurLine = maxy + 1; //鍙﹁捣涓�琛�
-						maxy = nCurLine;
-						cx = 0; cy = nCurLine;
+						if (i > 0 && nOp == pDoc->Progs[i-1].nOpType1)//濡傛灉鍓嶉潰涔熸槸ST锛岄偅灏变笉鎹㈣
+						{
+
+						}
+						else
+						{
+							nCurLine = ++maxy;
+							cx = 0;
+							cy = nCurLine;
+						}
 					}
 				}
 				stpos[nSts] = i;
@@ -2306,57 +2331,73 @@
 				cx++;
 				break;
 			case OP_ANS:
+				//ANS璇存槑鏄湁鐜矾锛屾暣琛岃繘琛岀Щ鍔紙鍚戝彸锛変粠鍚庡悜鍓嶈繘琛岀Щ鍔�
+				EndPt[nEndPts].y;
+				for (int i = EndPt[nEndPts-1].x ; i > 0; i--)
+				{
+					for (int j = EndPt[nEndPts].x; j >= 0; j--)
+					{
+						if (j > 0
+							&& Cells[cy + 1][j-1].nType == typeNone 
+							|| Cells[cy + 1][j - 1].nType == typeLine1 
+							|| Cells[cy + 1][j - 1].nType == typeLine2)
+						{
+							continue;						
+						}
+
+						Cells[cy + 1][j] = Cells[cy + 1][j - 1];
+					}
+				}
+
+				Cells[EndPt[nEndPts].y][EndPt[nEndPts-1].x].bLeftLineDn = 1;
+				Cells[EndPt[nEndPts].y+1][EndPt[nEndPts-1].x].bLeftLineUp = 1;
+
 				nSts--;
 				nEndPts--;
 
 				break;
 			case OP_ORS:
-				//褰撳墠搴忓垪涓庡墠闈㈢殑搴忓垪鍚堝苟銆�
-				//褰撳墠搴忓垪鐨勫紑濮嬬粨鏉熶綅缃�
-				//EndPt[nEndPts] = POINT{ cx,cy };
-				//nEndPts++;
-				//StPts[nSts - 1]; EndPt[nEndPts - 1];
-				//鍓嶄竴搴忓垪鐨勫紑濮嬬粨鏉熶綅缃�
-				StPts[nSts - 1]; 
-				EndPt[nEndPts - 1];
+
 				if (nEndPts <= 0)
 				{
 					break;
 				}
 
-				////鍒ゆ柇浜岃�呴暱搴�
-				//if (cx < EndPt[nEndPts - 1].x)
-				//{	
-				//	//鏈琛ラ綈
-				//	for (int j = cx; j < EndPt[nEndPts - 1].x; j++)
-				//	{
-				//		Cells[cy][j].nType = typeLine1;
-				//	}
-				//	cx = EndPt[nEndPts - 1].x;
-				//}
-				//else 
-				//{
-				//	//鍓嶄竴琛岃ˉ榻�
-				//	for (int j = EndPt[nEndPts - 1].x; j < cx; j++)
-				//	{
-				//		Cells[EndPt[nEndPts - 1].y][j].nType = typeLine1;
-				//	}
-				//}
-				////杩炴帴涓婁笅绾�
-				//for (int j = EndPt[nEndPts - 1].y; j < cy; j++)
-				//{
-				//	Cells[j][cx].bLeftLineDn = 1;
-				//	Cells[j + 1][cx].bLeftLineUp = 1;
-				//}
-				////鍏夋爣浣嶇疆, 鍓嶄竴缁撴潫鐐逛綅缃�
-				//cy = EndPt[nEndPts - 1].y;
+				//鍒ゆ柇浜岃�呴暱搴�
+				if (cx < EndPt[nEndPts - 1].x)
+				{	
+					//鏈琛ラ綈
+					for (int j = cx; j < EndPt[nEndPts - 1].x; j++)
+					{
+						Cells[cy][j].nType = typeLine1;
+					}
+					cx = EndPt[nEndPts - 1].x;
+				}
+				else 
+				{
+					//鍓嶄竴琛岃ˉ榻�
+					for (int j = EndPt[nEndPts - 1].x; j < cx; j++)
+					{
+						if (Cells[EndPt[nEndPts - 1].y][j].nType == typeNone)
+						{
+							Cells[EndPt[nEndPts - 1].y][j].nType = typeLine1;
+						}
+					}
+				}
+				//杩炴帴涓婁笅绾�
+
+				Cells[cy][cx].bLeftLineUp = 1;
+				Cells[cy-1][cx].bLeftLineDn = 1;
+
+				//鍏夋爣浣嶇疆, 鍓嶄竴缁撴潫鐐逛綅缃�
 				nSts--;
 				nEndPts--;
-
+				cy = EndPt[nEndPts].y;
+				cx = EndPt[nEndPts].x;
 				break;
 			case OP_PSHS:
-				EndPt[nEndPts] = POINT{ cx,cy };
-				nEndPts++;
+				StrPt[nStrPts] = POINT{ EndPt[nEndPts].x,EndPt[nEndPts].y+1 };
+				nStrPts++;
 				break;
 			case OP_RDS:
 				cx = EndPt[nEndPts - 1].x;
@@ -2373,20 +2414,9 @@
 				}
 				break;
 			case OP_POPS:
-				cx = EndPt[nEndPts - 1].x;
-				for (int j = cx; j < m_CellPerLine; j++) {
-					if (Cells[cy][j].nType != 0)
-					{
-						cy++; j = cx - 1; break;
-					}
-				}
-				for (int j = EndPt[nEndPts - 1].y; j < cy; j++)
-				{
-					Cells[j][cx].bLeftLineDn = 1;
-					Cells[j + 1][cx].bLeftLineUp = 1;
-				}
-				nEndPts--;
-
+				nStrPts--;
+				cy = StrPt[nStrPts].y;
+				cx = StrPt[nStrPts].x;
 				break;
 			case OP_OUT:
 			case OP_SET:
@@ -2528,7 +2558,7 @@
 	return 0;
 }
 bool firstCoil = true;//鏈绗竴涓崟鍏冩牸
-
+bool isPops = false;
 /// <summary>
 /// 姊舰鍥捐浆Prog
 /// </summary>
@@ -2586,7 +2616,7 @@
 		{
 			nStartLine = 0; 
 			nEndLine = Divs[i]; 
-		}
+ 		}
 		else 
 		{
 			nStartLine = Divs[i - 1]+1;
@@ -2665,13 +2695,21 @@
 			{
 				firstCoil = true;
 				//寰幆閬嶅巻鍗曞厓鏍�(杞崲鐨勯�昏緫鍦ㄨ繖涓嚱鏁�)
-				ScanLDSCells(nStartLine, nEndLine, nCurPosY, nCurPosX, 0, thisprogsec, sProgSec, nSteps);
+				//ScanLDSCells(nStartLine, nEndLine, nCurPosY, nCurPosX, 0, thisprogsec, sProgSec, nSteps);
+				//ScanLDSCells2(nStartLine, nEndLine, nCurPosY, nCurPosX, 0, thisprogsec, sProgSec, nSteps);
 			}
-			sProg += sProgSec;
- 			nAllSteps += nSteps;
-			Progsec += thisprogsec;
+			//sProg += sProgSec;
+ 		//	nAllSteps += nSteps;
+			//Progsec += thisprogsec;
 		}
-
+		CString sProgSec;
+		int nSteps = 0;;
+		nCurPosY = i;
+		stProgSection thisprogsec;
+		ScanLDSCells2(nStartLine, nEndLine, nCurPosY, nCurPosX, 16,0, thisprogsec, sProgSec, nSteps);
+		sProg += sProgSec;
+		nAllSteps += nSteps;
+		Progsec += thisprogsec;
 		DbgLog(_T("\r\n")+ sProg);
 		int n = int(Progsec.Progs.size());
 		s1.Format(_T("绋嬪簭娈垫鏁帮細 %d "), n);
@@ -2702,7 +2740,7 @@
 	for (int i = 0; i < n; i++)	
 	{
 		int optype=allprogs.Progs[i].nOpType1;
-		allprogs.Progs[i].PairTo = 0;
+		allprogs.Progs[i].PairTo = 0;//??????????
 		allprogs.Progs[i].nBinStep = i;
 		CStringA OpTxtA,OpShowTxtA;
 		CString OpTxt,OpShowTxt;
@@ -2736,7 +2774,7 @@
 {
 	CString s1;
 	int nCurPosX, nCurPosY;
-	int nNextX = 1;//姝ラ暱
+	int nNextX = 1;//姝ラ暱(涓嬩釜璧峰鐐圭Щ鍔ㄧ殑璺濈)
 	nCurPosY = nPosY;
 	nCurPosX = nPosX;
 	int nCoilType, CoilAddr;
@@ -2744,7 +2782,7 @@
 	for (int j = nPosX; j < m_CellPerLine; j += nNextX)
 	{
 		nCurPosX = j;
-		//鍏堝鐞嗗綋鍓嶅崟鍏�;
+		//鍏堝鐞嗗綋鍓嶅崟鍏冨熀鏈俊鎭�;
 		int nType = Cells[nCurPosY][nCurPosX].nType;
 		CString sCellName = Cells[nCurPosY][nCurPosX].sCoilName;
 		CMTerm1Doc::stProg theprog;
@@ -2761,30 +2799,28 @@
 			|| Cells[nCurPosY][j + nNextX].bLeftLineDn)
 		{
 
-			////鍏堢湅寰�涓婇潰鏈夋病鏈夎繛鎺�
-			//if (Cells[nCurPosY][j + nNextX].bLeftLineUp)
-			//{
-			//	// 寰�涓婇潰鏈夎繛鎺ヤ笖鏈夎Е鐐硅繛鎺ワ紝鎵嶄娇鐢∣RS
-			//	s1.Format(_T("%d %d ORS "), nCurPosY, nCurPosX);
-			//	DbgLog(s1);
-			//	theprog.nOpType1 = OP_ORS;
-			//	//theprog.nOpType1 = OP_ST;
-			//	//theprog.PairTo = OP_ORS;
-			//	progsec.Append(theprog);
-			//	sProgSec.AppendFormat(_T("ORS \r\n"));
-			//	firstCoil = false;
-			//	nSteps += 1;
-			//	nLevel -= 1;
-			//}
-			//宸︿笂鏄惁鏈夐摼鎺�
+			//鍏堢湅寰�涓婇潰鏈夋病鏈夎繛鎺�
+			if (Cells[nCurPosY][j + nNextX].bLeftLineUp)
+			{
+				// 寰�涓婇潰鏈夎繛鎺ヤ笖鏈夎Е鐐硅繛鎺ワ紝鎵嶄娇鐢∣RS
+				s1.Format(_T("%d %d ORS "), nCurPosY, nCurPosX);
+				DbgLog(s1);
+				theprog.nOpType1 = OP_ORS;
+				progsec.Append(theprog);
+				sProgSec.AppendFormat(_T("ORS \r\n"));
+				firstCoil = false;
+				nSteps += 1;
+				nLevel -= 1;
+			}
+			//鍙充晶涓�鏍肩殑宸︿笂鏄惁鏈夐摼鎺�
 			int nLeftUpCon = 0;
 			if (Cells[nCurPosY][j + nNextX].bLeftLineUp)
 			{
 				nLeftUpCon = 1;
 			}
-			//鍚戜笅鏌ユ壘锛岀湅鐪嬬珫绾跨殑宸︿晶涓嬮潰杩樻湁娌℃湁杩炴帴鍏朵粬涓滆タ
-			int nLeftDnCon = 0;//鍗曞厓鏍煎乏渚у悜涓嬭繛鎺ユ暟
-			for (int k = nCurPosY + 1; k <= nEndLine; k++)
+			//鍚戜笅鏌ユ壘锛岀湅鐪嬬珫绾跨殑鍙充晶涓�鏍肩殑宸︿晶涓嬮潰杩樻湁娌℃湁杩炴帴鍏朵粬涓滆タ
+			int nLeftDnCon = 0;//鍗曞厓鏍煎彸渚т竴鏍肩殑宸︿晶鍚戜笅杩炴帴鏁�
+			for (int k = nCurPosY; k <= nEndLine; k++)
 			{
 				if (Cells[k][j + nNextX].bLeftLineDn)
 				{
@@ -2802,12 +2838,12 @@
 			s1.Format(_T("LeftUp %d   LeftDn  %d"), nLeftUpCon, nLeftDnCon);
 			DbgLog(s1);
 
-			//宸︿晶涓嬮潰鏈夎繛鎺ワ紝閭d箞鎵弿鍒拌繖涓珫绾挎椂杩斿洖锛岀户缁壂鎻忓乏渚т笅闈㈢殑鍐呭銆�
+			//鍙充晶涓�鏍肩殑宸︿晶涓嬮潰鏈夎繛鎺ワ紝閭d箞鎵弿鍒拌繖涓珫绾挎椂杩斿洖锛岀户缁壂鎻忓乏渚т笅闈㈢殑鍐呭銆�
 			if (nLeftDnCon)
 			{
 				return 1;
 			}
-			// 宸︿晶涓嬮潰娌℃湁杩炴帴锛岄偅涔堣繖涓氨鏄乏闈㈡渶鍚庣殑鍗曞厓锛屽紑濮嬪鐞嗗彸闈㈢殑鍗曞厓銆�
+			//鍙充晶涓�鏍肩殑宸︿晶涓嬮潰娌℃湁杩炴帴锛岄偅涔堣繖涓氨鏄乏闈㈡渶鍚庣殑鍗曞厓锛屽紑濮嬪鐞嗗彸闈㈢殑鍗曞厓銆�
 			else
 			{
 				if (nLeftUpCon)
@@ -2854,13 +2890,13 @@
 
 				if (nRightCon == 1)
 				{
-					s1.Format(_T(">>>> Go %d : %d , level %d "), nLineTop, j + nNextX, nLevel);
+ 					s1.Format(_T(">>>> Go %d : %d , level %d "), nLineTop, j + nNextX, nLevel);
 					DbgLog(s1);
 					CString ProgSec;
 					int theSteps = 0;
 					stProgSection thisprogsec;
 
-					//
+					//杩欐湁闂锛屽簲璇ユ槸鍦ㄦ渶楂樼偣鐨勬椂鍊欙紝鍗曠嫭杩涜涓�娆¤浆鎹紵
 					int r = ScanLDSCells(nStartLine, nEndLine, nLineTop, j + nNextX, nLevel, thisprogsec, ProgSec, theSteps);
 
 					sProgSec += ProgSec;
@@ -2868,6 +2904,7 @@
 					progsec += thisprogsec;
 					s1.Format(_T("<<<< Re %d : %d , Result %d "), nLineTop, j + nNextX, 0);
 					DbgLog(s1);
+					continue;
 				}
 				else
 				{
@@ -2899,7 +2936,7 @@
 							DbgLog(s1);
 							if (nRightCount == 0)
 							{
-
+								//杩欓噷鏄笉鏄簲璇ュ仛鐐逛粈涔�
 							}
 							else if (res[nRightCount - 1] == 0)
 							{
@@ -2948,7 +2985,12 @@
 				}
 			}
 		}
-
+		//濡傛灉娌℃湁绔栫嚎鐩存帴缈昏瘧
+		else
+		{
+			Translate2Prog(nType, j + nNextX, nLevel, sCellName, progsec, sProgSec, nSteps);
+		}
+		/*
 		#pragma region  鏍规嵁鍗曞厓鏍肩被鍨嬭浆鎹负鎸囦护鍜宲rog
 
 		if (nType == typeNO)
@@ -3180,253 +3222,371 @@
 		}
 		
 		#pragma endregion
-
+		*/
 	}
 	return 0;
  }
- /*
- void CMTerm1View::chuansileitetoprog(int nStartLine, int nEndLine, int nPosY, int nPosX, int nLevel, stProgSection& progsec, CString& sProgSec, int& nSteps)
- {
-	 CString s1;
-	 int nCurPosX, nCurPosY;
-	 int nNextX = 1;//姝ラ暱
-	 nCurPosY = nPosY;
-	 nCurPosX = nPosX;
-	 int nCoilType, CoilAddr;
-	 CMTerm1Doc* pDoc = GetDocument();
-#pragma region  鏍规嵁鍗曞厓鏍肩被鍨嬭浆鎹负鎸囦护鍜宲rog
+//	璁板綍y,x
+std::pair<int, int> popsPoint[100];		int nPSHS = -1;
+int CMTerm1View::ScanLDSCells2(int nStartLine, int nEndLine, int nPosY, int nPosX, int nSizeX,
+	int nLevel, stProgSection& progsec, CString& sProgSec, int& nSteps)
+{
+	CString s1;
+	int nCurPosX, nCurPosY;
+	int nNextX = 0;//姝ラ暱锛堝埌涓嬩釜绾垮湀璧峰浣嶇疆搴旂Щ鍔ㄨ窛绂�
+	nCurPosY = nStartLine;
+	nCurPosX = nPosX;
+	int nCoilType, CoilAddr;
+	CMTerm1Doc* pDoc = GetDocument();
 
-	 if (nType == typeNO)
-	 {
-		 if (firstCoil && nType != typeLine1 && nType != typeLine2)
-		 {
-			 //鍏堢湅寰�涓婇潰鏈夋病鏈夎繛鎺�
-			 if (Cells[nCurPosY][j + nNextX].bLeftLineUp)
-			 {
-				 // 寰�涓婇潰鏈夎繛鎺ヤ笖鏈夎Е鐐硅繛鎺ワ紝鎵嶄娇鐢∣R
-				 s1.Format(_T("%d %d OR %s"), nCurPosY, nCurPosX, sCellName);
-				 sProgSec.AppendFormat(_T("OR %s\r\n"), sCellName);
-				   .nOpType1 = OP_OR;
-			 }
-			 else
-			 {
-				 s1.Format(_T("%d %d ST %s"), nCurPosY, nCurPosX, sCellName);
-				 sProgSec.AppendFormat(_T("ST %s\r\n"), sCellName);
-				 theprog.nOpType1 = OP_ST;
-			 }
-			 theprog.nParamCount = 1;
-			 pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
-			 theprog.Params[0].nParamType = nCoilType;
-			 theprog.Params[0].nParamAddr = CoilAddr;
-			 theprog.Params[0].sParamStr = sCellNameA;
-			 progsec.Append(theprog);
-			 firstCoil = false;
-		 }
-		 else
-		 {
-			 s1.Format(_T("%d %d AN %s"), nCurPosY, nCurPosX, sCellName);
-			 sProgSec.AppendFormat(_T("NO %s\r\n"), sCellName);
-			 theprog.nOpType1 = OP_AN;
-			 theprog.nParamCount = 1;
-			 pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
-			 theprog.Params[0].nParamType = nCoilType;
-			 theprog.Params[0].nParamAddr = CoilAddr;
-			 theprog.Params[0].sParamStr = sCellNameA;
-			 progsec.Append(theprog);
-		 }
-		 nSteps += 1;
-		 DbgLog(s1);
-		 nNextX = 1;
-	 }
-	 else if (nType == typeNC)
-	 {
-		 if (firstCoil && nType != typeLine1 && nType != typeLine2)
-		 {
-			 s1.Format(_T("%d %d ST/ %s"), nCurPosY, nCurPosX, sCellName);
-			 sProgSec.AppendFormat(_T("ST/ %s\r\n"), sCellName);
-			 theprog.nOpType1 = OP_ST_;
-			 theprog.nParamCount = 1;
-			 pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
-			 theprog.Params[0].nParamType = nCoilType;
-			 theprog.Params[0].nParamAddr = CoilAddr;
-			 theprog.Params[0].sParamStr = sCellNameA;
-			 progsec.Append(theprog);
-			 firstCoil = false;
-		 }
-		 else
-		 {
-			 s1.Format(_T("%d %d AN/ %s"), nCurPosY, nCurPosX, sCellName);
-			 sProgSec.AppendFormat(_T("AN/ %s\r\n"), sCellName);
-			 theprog.nOpType1 = OP_AN_;
-			 theprog.nParamCount = 1;
-			 pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
-			 theprog.Params[0].nParamType = nCoilType;
-			 theprog.Params[0].nParamAddr = CoilAddr;
-			 theprog.Params[0].sParamStr = sCellNameA;
-			 progsec.Append(theprog);
-		 }
-		 DbgLog(s1);
-		 nSteps += 1;
-		 nNextX = 1;
-	 }
-	 else if (nType == typePP)
-	 {
-		 s1.Format(_T("%d %d PP %s"), nCurPosY, nCurPosX, sCellName);
-		 DbgLog(s1);
-		 //progsec.Append(theprog);
-		 sProgSec.AppendFormat(_T("PP %s\r\n"), sCellName);
-		 nSteps += 1;
-		 nNextX = 1;
-	 }
-	 else if (nType == typePN)
-	 {
-		 s1.Format(_T("%d %d PN %s"), nCurPosY, nCurPosX, sCellName);
-		 DbgLog(s1);
-		 //progsec.Append(theprog);
-		 sProgSec.AppendFormat(_T("PN %s\r\n"), sCellName, sCellName);
-		 nSteps += 1;
-		 nNextX = 1;
-	 }
-	 else if (nType == typeNOT)
-	 {
-		 s1.Format(_T("%d %d NOT %s"), nCurPosY, nCurPosX, sCellName);
-		 DbgLog(s1);
-		 sProgSec.AppendFormat(_T("NOT %s\r\n"), sCellName);
-		 theprog.nOpType1 = OP_NOT;
-		 progsec.Append(theprog);
-		 nSteps += 1;
-		 nNextX = 1;
-	 }
-	 else if (nType == typeDF)
-	 {
-		 s1.Format(_T("%d %d DF %s"), nCurPosY, nCurPosX, sCellName);
-		 DbgLog(s1);
-		 sProgSec.AppendFormat(_T("DF %s\r\n"), sCellName);
-		 theprog.nOpType1 = OP_DF;
-		 progsec.Append(theprog);
-		 nSteps += 1;
-		 nNextX = 1;
-	 }
-	 else if (nType == typeDF_)
-	 {
-		 s1.Format(_T("%d %d DF/ %s"), nCurPosY, nCurPosX, sCellName);
-		 DbgLog(s1);
-		 sProgSec.AppendFormat(_T("DF/ %s\r\n"), sCellName);
-		 theprog.nOpType1 = OP_DF_;
-		 progsec.Append(theprog);
-		 nSteps += 1;
-		 nNextX = 1;
-	 }
-	 else if (nType == typeOUT)
-	 {
-		 s1.Format(_T("%d %d OUT %s"), nCurPosY, nCurPosX, sCellName);
-		 DbgLog(s1);
-		 sProgSec.AppendFormat(_T("OUT %s\r\n"), sCellName);
-		 theprog.nOpType1 = OP_OUT;
-		 theprog.nParamCount = 1;
-		 pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
-		 theprog.Params[0].nParamType = nCoilType;
-		 theprog.Params[0].nParamAddr = CoilAddr;
-		 theprog.Params[0].sParamStr = sCellNameA;
-		 progsec.Append(theprog);
-		 nSteps += 1;
-		 nNextX = 1;
-	 }
-	 else if (nType == typeSET)
-	 {
-		 s1.Format(_T("%d %d SET %s"), nCurPosY, nCurPosX, sCellName);
-		 DbgLog(s1);
-		 sProgSec.AppendFormat(_T("SET %s\r\n"), sCellName);
-		 theprog.nOpType1 = OP_SET;
-		 theprog.nParamCount = 1;
-		 pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
-		 theprog.Params[0].nParamType = nCoilType;
-		 theprog.Params[0].nParamAddr = CoilAddr;
-		 theprog.Params[0].sParamStr = sCellNameA;
-		 progsec.Append(theprog);
-		 nSteps += 1;
-		 nNextX = 1;
-	 }
-	 else if (nType == typeRESET)
-	 {
-		 s1.Format(_T("%d %d RESET %s"), nCurPosY, nCurPosX, sCellName);
-		 DbgLog(s1);
-		 sProgSec.AppendFormat(_T("RESET %s\r\n"), sCellName);
-		 theprog.nOpType1 = OP_RESET;
-		 theprog.nParamCount = 1;
-		 pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
-		 theprog.Params[0].nParamType = nCoilType;
-		 theprog.Params[0].nParamAddr = CoilAddr;
-		 theprog.Params[0].sParamStr = sCellNameA;
-		 progsec.Append(theprog);
-		 nSteps += 1;
-		 nNextX = 1;
-	 }
-	 else if (nType == typeCMP)
-	 {
-		 s1.Format(_T("%d %d CMP %s %s %s"), nCurPosY, nCurPosX, sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
-		 DbgLog(s1);
-		 theprog.nOpType1 = OP_ST_GT;
-		 theprog.nParamCount = 1;
-		 progsec.Append(theprog);
-		 sProgSec.AppendFormat(_T("CMP %s %s %s \r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
-		 nSteps += 1;
-		 nNextX = 3;
-	 }
-	 else if (nType == typeTM)
-	 {
-		 s1.Format(_T("%d %d TM %s %d %s"), nCurPosY, nCurPosX, sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
-		 DbgLog(s1);
-		 theprog.nOpType1 = OP_TMX;
-		 theprog.nParamCount = 1;
-		 pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
-		 theprog.Params[0].nParamType = nCoilType;
-		 theprog.Params[0].nParamAddr = CoilAddr;
-		 theprog.Params[0].sParamStr = sCellNameA;
-		 progsec.Append(theprog);
-		 sProgSec.AppendFormat(_T("TM %s %d %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
-		 nSteps += 1;
-		 nNextX = 3;
-	 }
-	 else if (nType == typeFN1)
-	 {
-		 s1.Format(_T("%d %d FN1 %s %s"), nCurPosY, nCurPosX, sCellName, Cells[nCurPosY][nCurPosX + 1].sParam);
-		 DbgLog(s1);
-		 theprog.nOpType1 = OP_INC;
-		 progsec.Append(theprog);
-		 sProgSec.AppendFormat(_T("FN1 %s %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam);
-		 nSteps += 1;
-		 nNextX = 2;
-	 }
-	 else if (nType == typeFN2)
-	 {
-		 s1.Format(_T("%d %d FN2 %s %s %s "), nCurPosY, nCurPosX, sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
-		 DbgLog(s1);
-		 theprog.nOpType1 = OP_MV;
-		 progsec.Append(theprog);
-		 sProgSec.AppendFormat(_T("FN2 %s %s %s \r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
-		 nSteps += 1;
-		 nNextX = 3;
-	 }
-	 else if (nType == typeFN3)
-	 {
-		 s1.Format(_T("%d %d FN3 %s %s %s %s"), nCurPosY, nCurPosX, sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam, Cells[nCurPosY][nCurPosX + 3].sParam);
-		 DbgLog(s1);
-		 theprog.nOpType1 = OP_ADD3;
-		 progsec.Append(theprog);
-		 sProgSec.AppendFormat(_T("FN3 %s %s %s %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam, Cells[nCurPosY][nCurPosX + 3].sParam);
-		 nSteps += 1;
-		 nNextX = 4;
-	 }
-	 else
-	 {
-		 nNextX = 1;
-		 //continue;
-	 }
+	for (int j = nPosX; j < nSizeX; j += nNextX)
+	{
+		nCurPosX = j;
+		//鍏堝鐞嗗綋鍓嶅崟鍏�;
+		int nType = Cells[nCurPosY][nCurPosX].nType;
+		CString sCellName = Cells[nCurPosY][nCurPosX].sCoilName;
+		CMTerm1Doc::stProg theprog;
+		CStringA sCellNameA;
+		sCellNameA = sCellName;
+		CString ProgSec;
+		int theSteps = 0;
 
-#pragma endregion
+		stProgSection thisprogsec;
+
+		//鍒ゆ柇瓒婄晫
+		if (j + nNextX >= m_CellPerLine)
+		{
+			continue;
+		}
+		//if (!firstCoil && Cells[nCurPosY][j].bLeftLineUp)
+		//{
+		//	break;
+		//}
+		if (Cells[nCurPosY][nCurPosX].nType == typeNone)
+		{
+			nNextX = 1;
+			continue;
+		}
+		//寮�濮嬬炕璇戝崟涓崟鍏冩牸锛屽苟杩斿洖涓嬩釜鍗曞厓鏍间綅缃�
+		nNextX = Translate2Prog(nType, nCurPosY, nCurPosX, sCellName, progsec, sProgSec, nSteps);
+		//1.鍒ゆ柇姝ゅ崟鍏冩牸鍙充晶涓�鏍兼槸鍚︽湁鍚戜笅鐨勭珫绾�
+		if (Cells[nCurPosY][j + nNextX].bLeftLineDn)
+		{
+			//1.1:鏈夊垎鏀紝鐩存帴寮�濮嬭鍙栦笅涓�琛�
+			if (Cells[nCurPosY +1][j].nType == typeNone)
+			{
+				if (Cells[nCurPosY + 1][j + nNextX].nType != typeNone)
+				{
+					firstCoil = true;
+				}
+				continue;
+			}
+
+			firstCoil = true;
+			ScanLDSCells2(nCurPosY + 1, nCurPosY + 1, nCurPosY + 1, 0, j + nNextX, ++nLevel, thisprogsec, ProgSec, theSteps);
+			
+			//鏈塐R鍏崇郴涓斾笉鍙竴涓妭鐐�
+			if (theSteps > 1 && nLevel > 0)
+			{
+				// 姝ユ暟澶т簬1锛屾槸澶嶅悎缁撴灉锛屾墠浣跨敤ORS
+				s1.Format(_T("%d %d ORS "), nCurPosY, nCurPosX);
+				DbgLog(s1);
+				theprog.nOpType1 = OP_ORS;
+				//progsec.Append(theprog);
+				//sProgSec.AppendFormat(_T("ORS \r\n"));
+				thisprogsec.Append(theprog);
+				ProgSec.AppendFormat(_T("ORS \r\n"));
+				firstCoil = false;
+				nSteps += 1;
+			}
+
+			//1.2:浠庡悗鍚戝墠鏌ユ壘涓嬩竴琛屾槸鍚﹁繕鏈夊悜涓婄殑绔栫嚎锛堝舰鎴愰棴鐜級锛圤RS銆丄NS锛�
+			for (int k = j; k >= 0; k--)
+			{
+				if (Cells[nCurPosY + 1][k].nType == typeNone)
+				{
+					//濡傛灉閬囧埌绌烘牸锛岃繕娌℃悳鍒帮紝灏辩粨鏉熸悳绱�
+					break;
+				}
+				if (Cells[nCurPosY+1][k].bLeftLineUp)
+				{
+					//濡傛灉鏈変竴鏉$珫绾匡紝璇存槑鏄舰鎴愪簡鐜紝瑕佺敤ANS
+					if (theSteps >= 1 && nLevel > 0)
+					{
+						//姝ユ暟澶т簬1锛屾槸澶嶅悎缁撴灉锛屼娇鐢ˋNS
+						s1.Format(_T("%d %d ANS "), nCurPosY, nCurPosX);
+						DbgLog(s1);
+						theprog.nOpType1 = OP_ANS;
+						//progsec.Append(theprog);
+						//sProgSec.AppendFormat(_T("ANS \r\n"));
+						thisprogsec.Append(theprog);
+						ProgSec.AppendFormat(_T("ANS \r\n"));
+						nSteps += 1;
+					}
+				}
+			}
+			
+			//灏嗚浆鎹㈠畬鎴愮殑閮ㄥ垎鍔犲叆鍒版�婚泦涓�
+			nSteps += theSteps;
+			progsec += thisprogsec;
+			sProgSec += ProgSec;
+			
+			//1.3:鏌ヨ姝ゅ垎鏀笅涓�绾ц繛鎺ョ偣宸﹀彸鍧囧瓨鍦ㄨ妭鐐癸紝瀛樺湪灏盤SHS
+			if (Cells[nCurPosY + 1][j].nType != typeNone 
+				&& Cells[nCurPosY + 1][j + 1].nType != typeNone)
+			{
+				++nPSHS;
+				CString push = _T("PSHS \r\n");
+				theprog.nOpType1 = OP_PSHS;
+				progsec.Append(theprog);
+				sProgSec.Append(push);
+				popsPoint[nPSHS] = std::make_pair(nCurPosY + 1, j + 1);
+			}
+		}//end  1.鍒ゆ柇姝ゅ崟鍏冩牸鍙充晶涓�鏍兼槸鍚︽湁鍚戜笅鐨勭珫绾�
+
+	}
+	nLevel--;
+	//宸插洖鍒拌捣濮嬪眰
+	if (nLevel == 0)
+	{
+		CMTerm1Doc::stProg theprog;
+		for (int i = nPSHS; i >= 0; i--)
+		{
+			//+POP
+			CString pop = _T("POPS \r\n");
+			theprog.nOpType1 = OP_POPS;
+			progsec.Append(theprog);
+			sProgSec.Append(pop);
+			//+fanyi
+			//寮�濮嬬炕璇戝崟涓崟鍏冩牸锛屽苟杩斿洖涓嬩釜鍗曞厓鏍间綅缃�
+			//firstCoil = true;
+			ScanLDSCells2(popsPoint[nPSHS].first, popsPoint[nPSHS].first, popsPoint[nPSHS].first, popsPoint[nPSHS].second, 16, nLevel, progsec, sProgSec, nSteps);
+			nPSHS--;
+
+		}
+		if (nPSHS == -1)
+		{
+			fill(popsPoint, popsPoint + 100, std::make_pair(0, 0));
+		}
+	}
+
+	return 0;
 }
-*/
+
+
+int CMTerm1View::Translate2Prog(
+	int nType, int nCurPosY, int nCurPosX, CString sCellName,
+	stProgSection& progsec, CString& sProgSec, int& nSteps)
+{
+	CString s1;
+	int nNextX = 1;//姝ラ暱
+	int nCoilType, CoilAddr;
+	CMTerm1Doc::stProg theprog;
+	CMTerm1Doc* pDoc = GetDocument();
+	CStringA sCellNameA;
+	sCellNameA = sCellName;
+	//if (nType == typeNone)
+	//{
+	//	return 0;
+	//}
+	if (nType == typeNO)
+	{
+		if (firstCoil && nType != typeLine1 && nType != typeLine2)
+		{
+			//鍏堢湅寰�涓婇潰鏈夋病鏈夎繛鎺�
+			if (Cells[nCurPosY][nCurPosX + nNextX].bLeftLineUp)
+			{
+				// 寰�涓婇潰鏈夎繛鎺ワ紝浣跨敤OR
+				sProgSec.AppendFormat(_T("OR %s\r\n"), sCellName);
+				theprog.nOpType1 = OP_OR;
+			}
+			else
+			{
+				sProgSec.AppendFormat(_T("ST %s\r\n"), sCellName);
+				theprog.nOpType1 = OP_ST;
+			}
+			theprog.nParamCount = 1;
+			pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
+			theprog.Params[0].nParamType = nCoilType;
+			theprog.Params[0].nParamAddr = CoilAddr;
+			theprog.Params[0].sParamStr = sCellNameA;
+			progsec.Append(theprog);
+			firstCoil = false;
+		}
+		else
+		{
+			sProgSec.AppendFormat(_T("AN %s\r\n"), sCellName);
+			theprog.nOpType1 = OP_AN;
+			theprog.nParamCount = 1;
+			pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
+			theprog.Params[0].nParamType = nCoilType;
+			theprog.Params[0].nParamAddr = CoilAddr;
+			theprog.Params[0].sParamStr = sCellNameA;
+			progsec.Append(theprog);
+		}
+
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typeNC)
+	{
+		if (firstCoil && nType != typeLine1 && nType != typeLine2)
+		{
+			sProgSec.AppendFormat(_T("ST/ %s\r\n"), sCellName);
+			theprog.nOpType1 = OP_ST_;
+			theprog.nParamCount = 1;
+			pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
+			theprog.Params[0].nParamType = nCoilType;
+			theprog.Params[0].nParamAddr = CoilAddr;
+			theprog.Params[0].sParamStr = sCellNameA;
+			progsec.Append(theprog);
+			firstCoil = false;
+		}
+		else
+		{
+			sProgSec.AppendFormat(_T("AN/ %s\r\n"), sCellName);
+			theprog.nOpType1 = OP_AN_;
+			theprog.nParamCount = 1;
+			pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
+			theprog.Params[0].nParamType = nCoilType;
+			theprog.Params[0].nParamAddr = CoilAddr;
+			theprog.Params[0].sParamStr = sCellNameA;
+			progsec.Append(theprog);
+		}
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typePP)
+	{
+		//progsec.Append(theprog);
+		sProgSec.AppendFormat(_T("PP %s\r\n"), sCellName);
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typePN)
+	{
+		//progsec.Append(theprog);
+		sProgSec.AppendFormat(_T("PN %s\r\n"), sCellName, sCellName);
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typeNOT)
+	{
+		sProgSec.AppendFormat(_T("NOT %s\r\n"), sCellName);
+		theprog.nOpType1 = OP_NOT;
+		progsec.Append(theprog);
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typeDF)
+	{
+		sProgSec.AppendFormat(_T("DF %s\r\n"), sCellName);
+		theprog.nOpType1 = OP_DF;
+		progsec.Append(theprog);
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typeDF_)
+	{
+		sProgSec.AppendFormat(_T("DF/ %s\r\n"), sCellName);
+		theprog.nOpType1 = OP_DF_;
+		progsec.Append(theprog);
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typeOUT)
+	{
+		sProgSec.AppendFormat(_T("OUT %s\r\n"), sCellName);
+		theprog.nOpType1 = OP_OUT;
+		theprog.nParamCount = 1;
+		pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
+		theprog.Params[0].nParamType = nCoilType;
+		theprog.Params[0].nParamAddr = CoilAddr;
+		theprog.Params[0].sParamStr = sCellNameA;
+		progsec.Append(theprog);
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typeSET)
+	{
+		sProgSec.AppendFormat(_T("SET %s\r\n"), sCellName);
+		theprog.nOpType1 = OP_SET;
+		theprog.nParamCount = 1;
+		pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
+		theprog.Params[0].nParamType = nCoilType;
+		theprog.Params[0].nParamAddr = CoilAddr;
+		theprog.Params[0].sParamStr = sCellNameA;
+		progsec.Append(theprog);
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typeRESET)
+	{
+		sProgSec.AppendFormat(_T("RESET %s\r\n"), sCellName);
+		theprog.nOpType1 = OP_RESET;
+		theprog.nParamCount = 1;
+		pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
+		theprog.Params[0].nParamType = nCoilType;
+		theprog.Params[0].nParamAddr = CoilAddr;
+		theprog.Params[0].sParamStr = sCellNameA;
+		progsec.Append(theprog);
+		nSteps += 1;
+		nNextX = 1;
+	}
+	else if (nType == typeCMP)
+	{
+		theprog.nOpType1 = OP_ST_GT;
+		theprog.nParamCount = 1;
+		progsec.Append(theprog);
+		sProgSec.AppendFormat(_T("CMP %s %s %s \r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
+		nSteps += 1;
+		nNextX = 3;
+	}
+	else if (nType == typeTM)
+	{
+		theprog.nOpType1 = OP_TMX;
+		theprog.nParamCount = 1;
+		pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
+		theprog.Params[0].nParamType = nCoilType;
+		theprog.Params[0].nParamAddr = CoilAddr;
+		theprog.Params[0].sParamStr = sCellNameA;
+		progsec.Append(theprog);
+		sProgSec.AppendFormat(_T("TM %s %d %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
+		nSteps += 1;
+		nNextX = 3;
+	}
+	else if (nType == typeFN1)
+	{
+		theprog.nOpType1 = OP_INC;
+		progsec.Append(theprog);
+		sProgSec.AppendFormat(_T("FN1 %s %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam);
+		nSteps += 1;
+		nNextX = 2;
+	}
+	else if (nType == typeFN2)
+	{
+		theprog.nOpType1 = OP_MV;
+		progsec.Append(theprog);
+		sProgSec.AppendFormat(_T("FN2 %s %s %s \r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
+		nSteps += 1;
+		nNextX = 3;
+	}
+	else if (nType == typeFN3)
+	{
+		theprog.nOpType1 = OP_ADD3;
+		progsec.Append(theprog);
+		sProgSec.AppendFormat(_T("FN3 %s %s %s %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam, Cells[nCurPosY][nCurPosX + 3].sParam);
+		nSteps += 1;
+		nNextX = 4;
+	}
+	else
+	{
+		nNextX = 1;
+		//continue;
+	}
+	return nNextX;
+}
+
 
 /// <summary>
 /// 鍏ㄩ儴鍥惧舰鏍¢獙
@@ -3436,75 +3596,75 @@
 /// 璁″垝鍦ㄧ涓�涓繑鍥炲�间腑浣跨敤涓嶅悓鐨勯敊璇唬鐮佷唬琛ㄤ笉鍚岀殑閿欒绫诲瀷锛�
 /// 骞跺湪绗簩涓繑鍥炲�间腑濉厖閿欒鎻愮ず淇℃伅
 /// </remark>
-std::pair<int, CString> CMTerm1View::LDSCheckRule()
-{
-	CString message;
-	int nDivCount = 0;
-	int Divs[100] = { 0 };
-	//浠ヨ涓哄崟浣嶄粠涓婂埌涓嬮亶鍘嗭紙琛岄亶鍘嗭級
-	for (int i = 0; i < m_nTotalRow; i++)	
-	{
-		int nRow = i;
-		int bConnected = 0;
-		bool checkFlag = false;//0鍒楁楠岀粨鏋�
+ std::pair<int, CString> CMTerm1View::LDSCheckRule()
+ {
+	 CString message;
+	 int nDivCount = 0;
+	 int Divs[100] = { 0 };
+	 //浠ヨ涓哄崟浣嶄粠涓婂埌涓嬮亶鍘嗭紙琛岄亶鍘嗭級
+	 for (int i = 0; i < m_nTotalRow; i++)
+	 {
+		 int nRow = i;
+		 int bConnected = 0;
+		 bool checkFlag = false;//0鍒楁楠岀粨鏋�
 
-		//鏈鐨�0鍒楁鏌�
-		if (Cells[nRow][0].nType == 0)
-		{
-			checkFlag = true;
-		}
+		 //鏈鐨�0鍒楁鏌�
+		 if (Cells[nRow][0].nType == 0)
+		 {
+			 checkFlag = true;
+		 }
 
-		//閬嶅巻姝よ鐨�1-15鍒楋紙纭畾鍗曞厓鏍硷級
-		for (int j = 1; j < m_CellPerLine; j++)
-		{
-			int nCol = j;
-			//濡傛灉0鍒椾负绌�
-			if (checkFlag)
-			{
-				//鏈夊乏渚т笂绔栫嚎
-				if (Cells[nRow][nCol].bLeftLineUp)
-				{
-					//濡傛灉涓婂眰涓虹┖鍗曞厓鏍硷紝鏃犳晥绔栫嚎锛岀洿鎺ュ垹闄�-----鍙互鍗曠嫭鍒ゆ柇
-					if (nRow - 1 >= 0 && Cells[nRow-1][nCol].nType == 0)
-					{
-						//娓呯悊鍗曞厓鏍�
-						Cells[nRow][nCol].clear();
-					}
-					//濡傛灉鏄痭one锛岄敊璇細鐭矾鎴栧洖璺�
-					else if (Cells[nRow][nCol].nType == 0)
-					{
-						message.Format(_T("((%d,%d) 闄勮繎浣嶇疆浜х敓瑙︾偣鐭矾鎴栧洖璺紒"),nRow,nCol);
-						return std::make_pair(111, message);
-					}
-					//濡傛灉涓嶄负none銆傚彲浠ヨ浆鎹紝浣嗘槸鎻愮ず锛氭棤娉曠粯鍒跺浘褰紙绋嬪簭涓嶅悎鐞嗭級
-					if (Cells[nRow][nCol].nType != 1)
-					{
-						message.Format(_T("((%d,%d) 鏃犳硶缁樺埗鍥惧舰锛堢▼搴忎笉鍚堢悊锛�"), nRow, nCol);
-						return std::make_pair(111, message);
-					}
+		 //閬嶅巻姝よ鐨�1-15鍒楋紙纭畾鍗曞厓鏍硷級
+		 for (int j = 1; j < m_CellPerLine; j++)
+		 {
+			 int nCol = j;
+			 //濡傛灉0鍒椾负绌�
+			 if (checkFlag)
+			 {
+				 //鏈夊乏渚т笂绔栫嚎
+				 if (Cells[nRow][nCol].bLeftLineUp)
+				 {
+					 //濡傛灉涓婂眰涓虹┖鍗曞厓鏍硷紝鏃犳晥绔栫嚎锛岀洿鎺ュ垹闄�-----鍙互鍗曠嫭鍒ゆ柇
+					 if (nRow - 1 >= 0 && Cells[nRow - 1][nCol].nType == 0)
+					 {
+						 //娓呯悊鍗曞厓鏍�
+						 Cells[nRow][nCol].clear();
+					 }
+					 //濡傛灉鏄痭one锛岄敊璇細鐭矾鎴栧洖璺�
+					 else if (Cells[nRow][nCol].nType == 0)
+					 {
+						 message.Format(_T("((%d,%d) 闄勮繎浣嶇疆浜х敓瑙︾偣鐭矾鎴栧洖璺紒"), nRow, nCol);
+						 return std::make_pair(111, message);
+					 }
+					 //濡傛灉涓嶄负none銆傚彲浠ヨ浆鎹紝浣嗘槸鎻愮ず锛氭棤娉曠粯鍒跺浘褰紙绋嬪簭涓嶅悎鐞嗭級
+					 if (Cells[nRow][nCol].nType != 1)
+					 {
+						 message.Format(_T("((%d,%d) 鏃犳硶缁樺埗鍥惧舰锛堢▼搴忎笉鍚堢悊锛�"), nRow, nCol);
+						 return std::make_pair(111, message);
+					 }
 
-				}
-				//娌℃湁宸︿晶涓婄珫绾匡紝涓旀鍗曞厓鏍肩被鍨� 涓嶄负绌烘垨绾�
-				else if (Cells[nRow][nCol].nType > 2)
-				{
-					//姝ゅ崟鍏冩牸涓哄崟鐙殑绾垮湀鎴栨寚浠ゅ崟鍏冿紝闇�瑕佽Е鐐硅緭鍏�
-					message.Format(_T("((%d,%d) 闇�瑕佽Е鐐硅緭鍏�"), nRow, nCol);
-					return std::make_pair(111, message);
-				}
-				//鏈夊乏渚т笅绔栫嚎锛屼笖姝ゅ崟鍏冩牸绫诲瀷涓虹┖
-				if (Cells[nRow][nCol].bLeftLineDn)
-				{
-					//涓嶆敮鎸佸洖璺�
-				}
-			}
-			//濡�0鍒楅潪绌�
-			else
-			{
+				 }
+				 //娌℃湁宸︿晶涓婄珫绾匡紝涓旀鍗曞厓鏍肩被鍨� 涓嶄负绌烘垨绾�
+				 else if (Cells[nRow][nCol].nType > 2)
+				 {
+					 //姝ゅ崟鍏冩牸涓哄崟鐙殑绾垮湀鎴栨寚浠ゅ崟鍏冿紝闇�瑕佽Е鐐硅緭鍏�
+					 message.Format(_T("((%d,%d) 闇�瑕佽Е鐐硅緭鍏�"), nRow, nCol);
+					 return std::make_pair(111, message);
+				 }
+				 //鏈夊乏渚т笅绔栫嚎锛屼笖姝ゅ崟鍏冩牸绫诲瀷涓虹┖
+				 if (Cells[nRow][nCol].bLeftLineDn)
+				 {
+					 //涓嶆敮鎸佸洖璺�
+				 }
+			 }
+			 //濡�0鍒楅潪绌�
+			 else
+			 {
 
-			}
-		}
+			 }
+		 }
 
 
-	}
-	return std::make_pair(0,message);
-}
+	 }
+	 return std::make_pair(0, message);
+ }

--
Gitblit v1.9.1