Browse Source

添加TIPS

maoyehu 2 years ago
parent
commit
73061e87d8

+ 17 - 0
MFCApplication1/AssignWords.cpp

@@ -336,3 +336,20 @@ int AssignWordsFromTest(std::string pathName, std::vector<tuple< string, string>
 	}
 	return cout;
 }
+
+void GetPaperTips(std::string tipsPath, std::string& tips)
+{
+	if (_access(tipsPath.c_str(), 00) != -1)
+	{
+		std::ifstream fin(tipsPath.c_str(), std::ios::in);
+		char line[4096] = { 0 };
+		while (fin.getline(line, sizeof(line)))
+		{
+			std::string strTemp = line;
+			if (isUtf8((unsigned char*)strTemp.c_str(), strTemp.length()))
+				UTF8toANSI(strTemp);
+			tips.append(strTemp);
+			tips.append("\r\n\n");
+		}
+	}
+}

+ 12 - 0
MFCApplication1/AssignWords.h

@@ -20,3 +20,15 @@ using namespace std;
 /***********************************************************************/
 int AssignWordsFromTest(std::string pathName, std::vector<tuple< string, string>> &oneList, std::vector<tuple< string, string>> &twoList,
 	std::vector<tuple< string, string>> &errorList, std::vector<tuple< string, string>> &fourList,int &ret);
+
+
+/***********************************************************************/
+//函 数 名:GetPaperTips
+//功	能:从文件读取试卷提示信息
+//参    数:
+//        @tipsPath:提示信息配置文件路径
+//        @tips:读取到的提示信息
+//返 回 值:
+//		  void
+/***********************************************************************/
+void GetPaperTips(std::string tipsPath, std::string& tips);

+ 5 - 1
MFCApplication1/CvxText.cpp

@@ -368,7 +368,7 @@ std::string JsonToString(const Json::Value & root)
 	return stream.str();
 }
 
-int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool engShow, std::vector<tuple<string, string>>& vecLines, CString dir, std::string& strPngPath) {
+int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool engShow, std::vector<tuple<string, string>>& vecLines, CString dir, std::string& strPngPath, std::string tips) {
 	/* 这里要做一些栏数 和 vecLines的对应值确认 */
 	if (2 == cols && 14 * 2 == vecLines.size())
 		; // ok 
@@ -421,6 +421,10 @@ int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool
 	string strMesInfo = "1、请将各题结果书写于横线上,勿写到线下!\
 						\n\n2、请用黑色笔书写。☆\
 						\n\n3、如果本题书写有误,进行了涂抹修改等操作,请将题号前矩形框用任意笔进行填涂!☆☆\n";
+	if (tips.length() > 0)
+	{
+		strMesInfo = tips;
+	}
 	putTextZH(img, fSize, strMesInfo.c_str(), cv::Point(leftPos + 20, topPos + 20), Scalar(0), 25, "宋体");
 	int lineTop1 = topPos + 20 + fSize.height + 20;
 	cv::line(img, cv::Point(leftPos, lineTop1), cv::Point(rightPos + ptw - 300, topPos + 20 + fSize.height + 20), Scalar(0), 2, 8, 0);

+ 1 - 1
MFCApplication1/CvxText.h

@@ -48,7 +48,7 @@ int getLineStrWidth(string str, int fontSize, int ttBoxW, int tiSl, int backPix)
     *  @return   : 
     *  @author   :  qqm  2022/08/31 19:42
 *********************************************************/
-int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool engShow, std::vector<tuple<string, string>>& vecLines, CString dir, std::string& strPngPath);
+int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool engShow, std::vector<tuple<string, string>>& vecLines, CString dir, std::string& strPngPath, std::string tips);
 
 /********************************************************
 	*  @function :  ´ðÌ⿨Çиî

+ 5 - 1
MFCApplication1/MFCApplication1Dlg.cpp

@@ -150,6 +150,10 @@ DWORD WINAPI ProcessThread(void *param)
 	WCHAR wgray[10];
 	GetPrivateProfileString(L"USER", L"GrayPix", L"100", wgray, 10, strFilePath);
 	int nLineGrayPix = _wtoi(wgray);
+
+	CString strTipsPath = strFileDir + "\\tips.txt";
+	std::string strTips;
+	GetPaperTips(UnicodeToGB2312(strTipsPath), strTips);
 	
 	auto CovertPdfFunc = [&](std::vector<tuple<string, string>>&  vctFiles, int col, int& pageNum){
 		std::string strPage1;
@@ -160,7 +164,7 @@ DWORD WINAPI ProcessThread(void *param)
 			vecSmall.insert(vecSmall.begin(), vctFiles.begin() + i, vctFiles.begin() + last);
 
 			std::string strPagePath;
-			dataCollectionPaper(col, pageNum, 30, nLineGrayPix, false, vecSmall, pWnd->m_strPdfDir, strPagePath);
+			dataCollectionPaper(col, pageNum, 30, nLineGrayPix, false, vecSmall, pWnd->m_strPdfDir, strPagePath, strTips);
 			if (strPage1.length() == 0)
 			{
 				strPage1 = strPagePath;