Browse Source

“S”型打印路径修改为单向打印

Zhou Jinlun 2 years ago
parent
commit
0ae801c697
1 changed files with 138 additions and 32 deletions
  1. 138 32
      PrintThread.cpp

+ 138 - 32
PrintThread.cpp

@@ -55,6 +55,7 @@ void PrintThread::run()
 }
 
 
+// 从左向右单方向打印
 void PrintThread::Print()
 {
 	PRINTSTOP = FALSE;
@@ -89,12 +90,13 @@ void PrintThread::Print()
 		QCoreApplication::processEvents();
 	}
 
-	 // 开始打印任务
-	int LL, CC, KK;
+	// 开始打印任务
+	int LL, CC;
 	string Format = ".bmp";
 	string sep = "/";
 	string Filename, PrintFullname;
 	string midl, midr;
+	OffsetX = PrintCSpacing;
 	OffsetY = PrintLSpacing;
 	for (LL = 1; LL <= PrintLine; LL++)
 	{
@@ -102,30 +104,12 @@ void PrintThread::Print()
 
 		for (CC = 1; CC <= PrintColumn; CC++)
 		{
-			if (LL % 2 == 1)
-			{
-				KK = CC;
-				midr = numberToString(KK);
-			}
-			else
-			{
-				KK = PrintColumn - CC + 1;
-				midr = numberToString(KK);
-			}
+			midr = numberToString(CC);
 
 			Filename = PrintPrefix + midl + midr + Format;
 			PrintFullname = PrintResource + sep + Filename;
 
-			if (LL % 2 == 1)
-			{
-				OffsetX = PrintCSpacing;
-				PI_MVR(Devices[0], sAxis.c_str(), &OffsetX);
-			}
-			else
-			{
-				OffsetX = -1 * PrintCSpacing;
-				PI_MVR(Devices[0], sAxis.c_str(), &OffsetX);
-			}
+			PI_MVR(Devices[0], sAxis.c_str(), &OffsetX);
 
 			isMoving_sAxisX = TRUE;
 			isMoving_sAxisY = TRUE;
@@ -153,16 +137,8 @@ void PrintThread::Print()
 				break;
 			}
 		}
-		if (LL % 2 == 1)
-		{
-			OffsetX = PrintCSpacing;
-			PI_MVR(Devices[0], sAxis.c_str(), &OffsetX);
-		}
-		else
-		{
-			OffsetX = -1 * PrintCSpacing;
-			PI_MVR(Devices[0], sAxis.c_str(), &OffsetX);
-		}
+
+		PI_MOV(Devices[0], sAxis.c_str(), &initPrintX);
 		PI_MVR(Devices[1], sAxis.c_str(), &OffsetY);
 
 		isMoving_sAxisX = TRUE;
@@ -180,3 +156,133 @@ void PrintThread::Print()
 		}
 	}
 }
+
+
+// “S”型路径打印
+//void PrintThread::Print()
+//{
+//	PRINTSTOP = FALSE;
+//
+//	// 主线程参数传递到子线程
+//	Devices = m_Printer->Get_Devices();
+//	sAxis = m_Printer->Get_sAxis();
+//	PrintLSpacing = m_Printer->Get_PrintLSpacing();
+//	PrintCSpacing = m_Printer->Get_PrintCSpacing();
+//	PrintLine = m_Printer->Get_PrintLine();
+//	PrintColumn = m_Printer->Get_PrintColumn();
+//	PrintPrefix = m_Printer->Get_PrintPrefix();
+//	PrintExpose = m_Printer->Get_PrintExpose();
+//	PrintQuiet = m_Printer->Get_PrintQuiet();
+//	PrintResource = m_Printer->Get_PrintResource();
+//
+//	// 平移台
+//	HoloLine = PrintLSpacing * PrintLine;
+//	HoloColumn = PrintCSpacing * PrintColumn;
+//	initPrintX = -(HoloColumn + PrintCSpacing) / 2;
+//	initPrintY = -(HoloLine - PrintLSpacing) / 2;
+//	PI_MOV(Devices[0], sAxis.c_str(), &initPrintX);
+//	PI_MOV(Devices[1], sAxis.c_str(), &initPrintY);
+//
+//	BOOL isMoving_sAxisX = TRUE;
+//	BOOL isMoving_sAxisY = TRUE;
+//	while (isMoving_sAxisX || isMoving_sAxisY)
+//	{
+//		PI_IsMoving(Devices[0], sAxis.c_str(), &isMoving_sAxisX);
+//		PI_IsMoving(Devices[1], sAxis.c_str(), &isMoving_sAxisY);
+//
+//		QCoreApplication::processEvents();
+//	}
+//
+//	 // 开始打印任务
+//	int LL, CC, KK;
+//	string Format = ".bmp";
+//	string sep = "/";
+//	string Filename, PrintFullname;
+//	string midl, midr;
+//	OffsetY = PrintLSpacing;
+//	for (LL = 1; LL <= PrintLine; LL++)
+//	{
+//		midl = numberToString(LL);
+//
+//		for (CC = 1; CC <= PrintColumn; CC++)
+//		{
+//			if (LL % 2 == 1)
+//			{
+//				KK = CC;
+//				midr = numberToString(KK);
+//			}
+//			else
+//			{
+//				KK = PrintColumn - CC + 1;
+//				midr = numberToString(KK);
+//			}
+//
+//			Filename = PrintPrefix + midl + midr + Format;
+//			PrintFullname = PrintResource + sep + Filename;
+//
+//			if (LL % 2 == 1)
+//			{
+//				OffsetX = PrintCSpacing;
+//				PI_MVR(Devices[0], sAxis.c_str(), &OffsetX);
+//			}
+//			else
+//			{
+//				OffsetX = -1 * PrintCSpacing;
+//				PI_MVR(Devices[0], sAxis.c_str(), &OffsetX);
+//			}
+//
+//			isMoving_sAxisX = TRUE;
+//			isMoving_sAxisY = TRUE;
+//			while (isMoving_sAxisX || isMoving_sAxisY)
+//			{
+//				PI_IsMoving(Devices[0], sAxis.c_str(), &isMoving_sAxisX);
+//				PI_IsMoving(Devices[1], sAxis.c_str(), &isMoving_sAxisY);
+//
+//				QCoreApplication::processEvents();
+//			}
+//
+//			emit TransCGH(QString::fromStdString(PrintFullname));
+//
+//			Sleep(PrintQuiet);// 静台
+//
+//			MyShutter->open();
+//			Sleep(PrintExpose);
+//			MyShutter->close();
+//
+//			emit TransPrintProgress(LL, CC);
+//
+//			PRINTSTOP = m_Printer->Get_PRINTSTOP();
+//			if (PRINTSTOP)
+//			{
+//				break;
+//			}
+//		}
+//		if (LL % 2 == 1)
+//		{
+//			OffsetX = PrintCSpacing;
+//			PI_MVR(Devices[0], sAxis.c_str(), &OffsetX);
+//		}
+//		else
+//		{
+//			OffsetX = -1 * PrintCSpacing;
+//			PI_MVR(Devices[0], sAxis.c_str(), &OffsetX);
+//		}
+//
+//
+//		PI_MVR(Devices[1], sAxis.c_str(), &OffsetY);
+//
+//		isMoving_sAxisX = TRUE;
+//		isMoving_sAxisY = TRUE;
+//		while (isMoving_sAxisX || isMoving_sAxisY)
+//		{
+//			PI_IsMoving(Devices[0], sAxis.c_str(), &isMoving_sAxisX);
+//			PI_IsMoving(Devices[1], sAxis.c_str(), &isMoving_sAxisY);
+//
+//			QCoreApplication::processEvents();
+//		}
+//		if (PRINTSTOP)
+//		{
+//			break;
+//		}
+//	}
+//}