From aef69faaca3401fa1224884e686bce36b0c88acb Mon Sep 17 00:00:00 2001
From: LYW <leeyeanwoo@diteam.co.kr>
Date: 화, 26 10월 2021 16:57:35 +0900
Subject: [PATCH] Ongoing80 #3684 CF AOI Review 전설비 Review History Defect이미지 클릭시 Offset 자동 계산 기능 추가

---
 ReviewHistory/ReveiwHistory/resource.h            |    4 
 ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp  |  349 +++++++++++++++++++++++
 ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h    |   58 +++
 ReviewSystem/ReviewSystem/DlgReviewOffSetTool.cpp |   13 
 ReviewHistory/bin/no-image.png                    |    0 
 ReviewHistory/include/MacroFile.h                 |  421 ++++++++++++++++++++++++++++
 ReviewSystem/ReviewSystem/ReviewSystem.rc         |    3 
 ReviewSystem/ReviewSystem/resource.h              |    7 
 ReviewHistory/bin/Config/PathSetting.ini          |    2 
 ReviewHistory/ReveiwHistory/ReveiwHistory.rc      |    0 
 ReviewSystem/ReviewSystem/DlgReviewOffSetTool.h   |    3 
 ReviewHistory/bin/ReviewHistroy.exe               |    0 
 12 files changed, 851 insertions(+), 9 deletions(-)

diff --git a/ReviewHistory/ReveiwHistory/ReveiwHistory.rc b/ReviewHistory/ReveiwHistory/ReveiwHistory.rc
index fa929be..3a41ab0 100644
--- a/ReviewHistory/ReveiwHistory/ReveiwHistory.rc
+++ b/ReviewHistory/ReveiwHistory/ReveiwHistory.rc
Binary files differ
diff --git a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp
index d58cbe4..0f820c7 100644
--- a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp
+++ b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp
@@ -12,6 +12,7 @@
 #include "akGridCtrl/GridCellCheck.h"
 #include "akImageView.h"
 #include <algorithm>
+#include "MacroFile.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -137,6 +138,8 @@
 	ON_BN_CLICKED(IDC_CHK_SINGLE, &CReveiwHistoryDlg::OnClickedChkSingle)
 	ON_EN_CHANGE(IDC_EDIT_FILE_COUNT, &CReveiwHistoryDlg::OnChangeEditFileCount)
 	ON_WM_KEYDOWN()
+	ON_BN_CLICKED(IDC_BUTTON_OFFSET_APPLY, &CReveiwHistoryDlg::OnBnClickedButtonOffsetApply)
+	ON_BN_CLICKED(IDC_BUTTON_OFFSET_SAVE, &CReveiwHistoryDlg::OnBnClickedButtonOffsetSave)
 END_MESSAGE_MAP()
 
 // CReveiwHistoryDlg 硫붿떆吏� 泥섎━湲�
@@ -209,6 +212,13 @@
 	InitGridReviewLIst(&m_gridReviewList, IDC_STATIC_GRID_GLASS);
 	InitGridDefectLIst(&m_gridDefectInfo, IDC_STATIC_GRID_DEFECT);
 	InitGridGlassLIst(&m_gridGlassInfo, IDC_STATIC_GRID_GLASS_INFO);
+
+	/*< LYW 20211025 - #3684 ADD Start >*/
+	CString strPath = _T("");
+	InitDataInfo();
+	strPath.Format(_T("%s%s"), REVIEW_OFFSET_CONFIGFILE_PATH, REVIEW_OFFSET_CONFIGFILE_NAME);
+	LoadOffset(strPath);
+	/*< LYW 20211025 - #3684 ADD End >*/
 
 	OnViewReviewdefect();
 
@@ -894,6 +904,7 @@
 					_akDefect* pDefectInfo = &m_Formation.m_vecDefects[pDispInfo->item.row - 1];
 
 					m_FormationMap.setSelectDefect(pDefectInfo->m_nDefectID);
+					
 					//ImageShow(pDefectInfo->m_nDefectID);
 					if (!m_bDefectAll)
 					{
@@ -1262,13 +1273,14 @@
 	{
 		m_nEditCamIdx = pDefect->m_nCameraID;
 		m_nEditScanIdx = pDefect->m_nScanIdx;
-		if (pDefect->m_nModelIdx == 0)
+		m_nCurModelIdx = pDefect->m_nModelIdx;
+		if (m_nCurModelIdx == 0)
 		{
 			m_strGantryIdx = _T("Left");
 			m_dEditOffsetX = (double)(dOffsetDrectionX * (Point.x / 5)) / 1000;
 			m_dEditOffsetY = (double)-(dOffsetDrectionY * (Point.y / 5)) / 1000;
 		}
-		else if (pDefect->m_nModelIdx == 1)
+		else if (m_nCurModelIdx == 1)
 		{
 			m_strGantryIdx = _T("Right");
 			m_dEditOffsetX = (double)-(dOffsetDrectionX * (Point.x / 5)) / 1000;
@@ -3914,3 +3926,336 @@
 
 	CDialogEx::OnKeyDown(nChar, nRepCnt, nFlags);
 }
+
+/*< LYW 20211025 - #3684 ADD Start >*/
+void CReveiwHistoryDlg::OnBnClickedButtonOffsetApply()
+{
+	// TODO: �뿬湲곗뿉 而⑦듃濡� �븣由� 泥섎━湲� 肄붾뱶瑜� 異붽��빀�땲�떎.
+	ApplyOffset(m_nCurModelIdx, m_nEditCamIdx, m_nEditScanIdx, m_dEditOffsetX, m_dEditOffsetY);
+}
+
+
+void CReveiwHistoryDlg::OnBnClickedButtonOffsetSave()
+{
+	// TODO: �뿬湲곗뿉 而⑦듃濡� �븣由� 泥섎━湲� 肄붾뱶瑜� 異붽��빀�땲�떎.
+	SaveOffset();
+}
+
+BOOL CReveiwHistoryDlg::LoadOffset(CString strFilePath)
+{
+	//dBarValue = 0;
+	CMacroFile macroFile;
+
+	if (!macroFile.Read(strFilePath))
+		return FALSE;
+
+	macroFile.GetItem(_T("CAMERA_COUNT"), m_nCameraCount, 0);
+	macroFile.GetItem(_T("SCAN_COUNT"), m_nScanCount, 0);
+	macroFile.GetItem(_T("XPOS_COUNT"), m_XposCount, 0);
+	CString strItem = _T("");
+	double dXoffset = 0;
+	double dYoffset = 0;
+	double dXMin = 0;
+	double dXMAX = 0;
+
+	double dValue = 0;
+	dValue = 2 * CAM_MAX_COUNT*SCAN_MAX_COUNT;
+	dValue = 1600 / dValue;
+
+	for (int nModuleidx = 0; nModuleidx < 2; nModuleidx++)
+	{
+		for (int nCamidx = 0; nCamidx < CAM_MAX_COUNT; nCamidx++)
+		{
+			for (int nScanidx = 0; nScanidx < SCAN_MAX_COUNT; nScanidx++)
+			{
+
+				for (int nXposIndex = 0; nXposIndex < XPOS_MAX_COUNT; nXposIndex++)
+				{
+
+					strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_OFFSET_X"), nModuleidx, nCamidx, nScanidx, nXposIndex);
+					macroFile.GetItem(strItem, dXoffset);
+
+
+					strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_OFFSET_Y"), nModuleidx, nCamidx, nScanidx, nXposIndex);
+					macroFile.GetItem(strItem, dYoffset);
+
+					strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_XPOS_X_MIN"), nModuleidx, nCamidx, nScanidx, nXposIndex);
+					macroFile.GetItem(strItem, dXMin);
+
+					strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_XPOS_X_MAN"), nModuleidx, nCamidx, nScanidx, nXposIndex);
+					macroFile.GetItem(strItem, dXMAX);
+
+					SetInputOffSet(nModuleidx, nCamidx, nScanidx, nXposIndex, dXoffset, dYoffset, dXMin, dXMAX);
+
+				}
+				//IncressProcessBar(dValue);
+			}
+		}
+	}
+
+	return TRUE;
+
+}
+
+BOOL CReveiwHistoryDlg::SaveOffset()
+{
+	//dBarValue = 0;
+
+	CString strForderPath;
+	CString strFileName;
+	CTime time = CTime::GetCurrentTime();
+	strFileName.Format(_T("ReviewOffSet_%04d%02d%02d%02d%02d%02d.cfg"), time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond());
+	strForderPath.Format(_T("%s%s"), REVIEW_OFFSET_BACKUP_FORDER_PATH, strFileName);
+
+	CopyFile(REVIEW_OFFSET_CONFIGFILE_FULL_PATHNAME, strForderPath, FALSE);
+
+	BOOL bReturn = FALSE;
+	CString strTemp;
+	int nTemp;
+	double dTemp;
+
+	CMacroFile macroFile;
+	macroFile.Clear();
+
+	CString strItem = _T("");
+
+
+	strItem.Format(_T("CAMERA_COUNT"));
+	macroFile.SetItem(strItem, m_nCameraCount);
+
+	strItem.Format(_T("SCAN_COUNT"));
+	macroFile.SetItem(strItem, m_nScanCount);
+
+	strItem.Format(_T("XPOS_COUNT"));
+	macroFile.SetItem(strItem, m_XposCount);
+
+
+	CString strData;
+	double dData = 0;
+	for (int nModuleidx = 0; nModuleidx < 2; nModuleidx++)
+	{
+		for (int nCamidx = 0; nCamidx < CAM_MAX_COUNT; nCamidx++)
+		{
+			for (int nScanidx = 0; nScanidx < SCAN_MAX_COUNT; nScanidx++)
+			{
+
+				for (int nXposIndex = 0; nXposIndex < XPOS_MAX_COUNT; nXposIndex++)
+				{
+
+					OffSetInfo pOffSet = GetOffSetInfo(nModuleidx, nCamidx, nScanidx, nXposIndex);
+
+					strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_OFFSET_X"), nModuleidx, nCamidx, nScanidx);
+					dData = pOffSet.dXoffSetValue;
+					macroFile.SetItem(strItem, dData);
+
+					strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_OFFSET_Y"), nModuleidx, nCamidx, nScanidx);
+					dData = pOffSet.dYoffSetValue;
+					macroFile.SetItem(strItem, dData);
+
+					strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_XPOS_X_MIN"), nModuleidx, nCamidx, nScanidx);
+					dData = pOffSet.dXposMin;
+					macroFile.SetItem(strItem, dData);
+
+					strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_XPOS_X_MAN"), nModuleidx, nCamidx, nScanidx);
+					dData = pOffSet.dXposMax;
+					macroFile.SetItem(strItem, dData);
+				}
+				//IncressProcessBar(5);
+			}
+		}
+	}
+
+	CString strFilePath;
+	strFilePath.Format(_T("%s%s"), REVIEW_OFFSET_CONFIGFILE_PATH, REVIEW_OFFSET_CONFIGFILE_NAME);
+
+	bReturn = macroFile.Write(strFilePath);
+
+	if (bReturn) AfxMessageBox(_T("OFFSET SAVE SUCCESS"), MB_OK | MB_ICONASTERISK);
+	else AfxMessageBox(_T("OFFSET SAVE FAIL"), MB_OK | MB_ICONASTERISK);
+
+	return bReturn;
+}
+
+BOOL CReveiwHistoryDlg::ApplyOffset(int nModuleidx, int nCamIndex, int ScanIndex, double dXOffsetValue, double dYOffsetValue)
+{
+	if (nCamIndex > CAM_MAX_COUNT || nCamIndex < 0)
+	{
+		return FALSE;
+	}
+
+	if (ScanIndex > SCAN_MAX_COUNT || ScanIndex < 0)
+	{
+		return FALSE;
+	}
+
+
+	if (nModuleidx == 0)
+	{
+		VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo[nCamIndex];
+		VecOffSetData* pData = &pScandata->at(ScanIndex);
+		OffSetInfo* pOffSetData = &pData->at(0);
+		if (pOffSetData->bCheckSave == TRUE)
+		{
+			AfxMessageBox(_T("�씠誘� ���옣�븳 OFFSET �엯�땲�떎. �떎�떆 �뀑�똿�쓣 �썝�븯�떆硫� �봽濡쒓렇�옩�쓣 �옱�떆�옉 �빐二쇱꽭�슂"), MB_OK | MB_ICONWARNING);
+			return FALSE;
+		}
+		else
+		{
+			pOffSetData->dXoffSetValue += dXOffsetValue;
+			pOffSetData->dYoffSetValue += dYOffsetValue;
+			pOffSetData->bCheckSave = TRUE;
+		}
+	}
+	else if (nModuleidx == 1)
+	{
+		VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo2[nCamIndex];
+		VecOffSetData* pData = &pScandata->at(ScanIndex);
+		OffSetInfo* pOffSetData = &pData->at(0);
+		if (pOffSetData->bCheckSave == TRUE)
+		{
+			AfxMessageBox(_T("�씠誘� ���옣�븳 OFFSET �엯�땲�떎. �떎�떆 �뀑�똿�쓣 �썝�븯�떆硫� �봽濡쒓렇�옩�쓣 �옱�떆�옉 �빐二쇱꽭�슂"), MB_OK | MB_ICONWARNING);
+			return FALSE;
+		}
+		else
+		{
+			pOffSetData->dXoffSetValue += dXOffsetValue;
+			pOffSetData->dYoffSetValue += dYOffsetValue;
+			pOffSetData->bCheckSave = TRUE;
+		}
+	}
+	else
+	{
+		return FALSE;
+	}
+}
+
+BOOL CReveiwHistoryDlg::SetInputOffSet(int nModuleidx, int nCamIndex, int ScanIndex, int nXposIndex, double dXOffsetValue, double dYOffsetValue, double dXposMin, double dXposMax, BOOL bCheckSave/* = 0*/)
+{
+	if (nCamIndex > CAM_MAX_COUNT || nCamIndex < 0)
+	{
+		return FALSE;
+	}
+
+	if (ScanIndex > SCAN_MAX_COUNT || ScanIndex < 0)
+	{
+		return FALSE;
+	}
+
+
+	if (nModuleidx == 0)
+	{
+		VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo[nCamIndex];
+		VecOffSetData* pData = &pScandata->at(ScanIndex);
+		OffSetInfo* pOffSetData = &pData->at(nXposIndex);
+		pOffSetData->dXoffSetValue = dXOffsetValue;
+		pOffSetData->dYoffSetValue = dYOffsetValue;
+		pOffSetData->dXposMin = dXposMin;
+		pOffSetData->dXposMax = dXposMax;
+		pOffSetData->bCheckSave = bCheckSave;
+
+	}
+	else if (nModuleidx == 1)
+	{
+		VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo2[nCamIndex];
+		VecOffSetData* pData = &pScandata->at(ScanIndex);
+		OffSetInfo* pOffSetData = &pData->at(nXposIndex);
+		pOffSetData->dXoffSetValue = dXOffsetValue;
+		pOffSetData->dYoffSetValue = dYOffsetValue;
+		pOffSetData->dXposMin = dXposMin;
+		pOffSetData->dXposMax = dXposMax;
+		pOffSetData->bCheckSave = bCheckSave;
+	}
+	else
+	{
+		return FALSE;
+	}
+}
+
+void CReveiwHistoryDlg::InitDataInfo()
+{
+	//誘몃━ 怨듦컙 �븷�떦
+	for (int nCamidx = 0; nCamidx < CAM_MAX_COUNT; nCamidx++)
+	{
+
+		VecOffSetScanData pVecScanData;
+		for (int nScanidx = 0; nScanidx < SCAN_MAX_COUNT; nScanidx++)
+		{
+			VecOffSetData     pVecData;
+			for (int nXposIndex = 0; nXposIndex < XPOS_MAX_COUNT; nXposIndex++)
+			{
+
+				OffSetInfo pInfo;
+				pInfo.nXposIndex = nXposIndex;
+				pInfo.nScanIndex = nScanidx;
+				pInfo.nCamIndex = nCamidx;
+				pVecData.push_back(pInfo);
+
+			}
+			pVecScanData.push_back(pVecData);
+
+		}
+
+		m_vecOffSetCameraInfo.push_back(pVecScanData);
+	}
+
+	for (int nCamidx = 0; nCamidx < CAM_MAX_COUNT; nCamidx++)
+	{
+
+		VecOffSetScanData pVecScanData;
+		for (int nScanidx = 0; nScanidx < SCAN_MAX_COUNT; nScanidx++)
+		{
+			VecOffSetData     pVecData;
+			for (int nXposIndex = 0; nXposIndex < XPOS_MAX_COUNT; nXposIndex++)
+			{
+
+				OffSetInfo pInfo;
+				pInfo.nXposIndex = nXposIndex;
+				pInfo.nScanIndex = nScanidx;
+				pInfo.nCamIndex = nCamidx;
+				pVecData.push_back(pInfo);
+
+			}
+			pVecScanData.push_back(pVecData);
+
+		}
+
+		m_vecOffSetCameraInfo2.push_back(pVecScanData);
+	}
+
+}
+
+OffSetInfo CReveiwHistoryDlg::GetOffSetInfo(int nModuleidx, int nCamIndex, int ScanIndex, int nXposIndex)
+{
+	OffSetInfo pOFF;
+	if (nCamIndex > CAM_MAX_COUNT || nCamIndex < 0)
+	{
+		return pOFF;
+	}
+
+	if (ScanIndex > SCAN_MAX_COUNT || ScanIndex < 0)
+	{
+		return pOFF;
+	}
+
+
+	if (nModuleidx == 0)
+	{
+		VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo[nCamIndex];
+		VecOffSetData* pData = &pScandata->at(ScanIndex);
+		OffSetInfo* pOffSetData = &pData->at(nXposIndex);
+
+		return *pOffSetData;
+	}
+	else if (nModuleidx == 1)
+	{
+		VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo2[nCamIndex];
+		VecOffSetData* pData = &pScandata->at(ScanIndex);
+		OffSetInfo* pOffSetData = &pData->at(nXposIndex);
+		return *pOffSetData;
+	}
+	else
+	{
+		return pOFF;
+	}
+}
+/*< LYW 20211025 - #3684 ADD End >*/
diff --git a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h
index b3d4ea5..420f3fb 100644
--- a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h
+++ b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h
@@ -19,6 +19,17 @@
 
 
 #define MAX_COUNT	100
+/*< LYW 20211025 - #3684 ADD Start >*/
+enum OFFSETCOUNT {
+	CAM_MAX_COUNT = 20, XPOS_MAX_COUNT = 10, SCAN_MAX_COUNT = 10, PROGRESS_BAR_MAX = 2000
+};
+
+#define	REVIEW_OFFSET_CONFIGFILE_PATH _T("D:\\DIT_Review\\ReviewServerConfig\\") //210805
+#define	REVIEW_OFFSET_CONFIGFILE_NAME _T("ReviewOffSet.cfg")
+#define REVIEW_OFFSET_CONFIGFILE_FULL_PATHNAME _T("D:\\DIT_Review\\ReviewServerConfig\\ReviewOffSet.cfg")
+#define	REVIEW_OFFSET_BACKUP_FORDER_NAME _T("OffsetBackup")
+#define	REVIEW_OFFSET_BACKUP_FORDER_PATH _T("D:\\DIT_Review\\ReviewServerConfig\\OffsetBackup\\")
+/*< LYW 20211025 - #3684 ADD End >*/
 
 struct _DefectList
 {
@@ -31,6 +42,26 @@
 	int				m_nAllCount;
 	CString			m_strJudge;
 };
+
+/*< LYW 20211025 - #3684 ADD Start >*/
+struct OffSetInfo
+{
+	int nXposIndex;
+	int nScanIndex;
+	int nCamIndex;
+	double dXposMax;
+	double dXposMin;
+	double dYposMax;
+	double dYposMin;
+	double dXoffSetValue;
+	double dYoffSetValue;
+	BOOL bCheckSave;
+
+};
+typedef std::vector<OffSetInfo> VecOffSetData;
+typedef std::vector<VecOffSetData> VecOffSetScanData;
+typedef std::vector<VecOffSetScanData> VecOffSetCameraInfo;
+/*< LYW 20211025 - #3684 ADD End >*/
 
 // CReveiwHistoryDlg ���솕 �긽�옄
 class CReveiwHistoryDlg : public CDialogEx
@@ -242,7 +273,32 @@
 	void BinFileOpen(int nCount);
 	void OnCbnSelchangeComboRawtype();
 
-	
+	/*< LYW 20211025 - #3684 ADD Start >*/
+	afx_msg void OnBnClickedButtonOffsetApply();
+	afx_msg void OnBnClickedButtonOffsetSave();
+	BOOL LoadOffset(CString strFilePath);
+	BOOL SaveOffset();
+	BOOL ApplyOffset(int nModuleidx, int nCamIndex, int ScanIndex, double dXOffsetValue, double dYOffsetValue);
+	BOOL SetInputOffSet(int nModuleidx, int nCamIndex, int ScanIndex, int nXposIndex, double dXOffsetValue, double dYOffsetValue, double dXposMin, double dXposMax, BOOL bCheckSave = 0);
+	void InitDataInfo();
+	OffSetInfo GetOffSetInfo(int nMoudleidx, int nCamIndex, int ScanIndex, int nXposIndex);
+
+	int m_nCameraCount;
+	int m_nScanCount;
+	int m_XposCount;
+	int m_nCurModelIdx;
+
+	/*< LYW 20211025 - #3684 ADD End >*/
+
+	//Xpos �쐞移섎퀎 �떎�젣 Offset Data 瑜� 媛�吏�怨� �엳�뒗 Vector
+	VecOffSetData  m_vecOffSetData;
+	//Scan Index瑜� �넻�븳 OffSet Data 瑜� 愿�由ы븯湲곗쐞�븳 Vector
+	VecOffSetScanData m_vecOffSetScanData;
+	//CamIndex瑜� �넻�븳 愿�由щ�� �쐞�븳 Vector  module 0
+	VecOffSetCameraInfo  m_vecOffSetCameraInfo;
+	//CamIndex瑜� �넻�븳 愿�由щ�� �쐞�븳 Vector  module 1
+	VecOffSetCameraInfo  m_vecOffSetCameraInfo2;
+
 	void ShowProgressBar();
 	void setDefectShow(int nDefectID, BOOL bEnsureVisible);
 	void ImageShow(int nDefectID);
diff --git a/ReviewHistory/ReveiwHistory/resource.h b/ReviewHistory/ReveiwHistory/resource.h
index 085e375..267fb35 100644
--- a/ReviewHistory/ReveiwHistory/resource.h
+++ b/ReviewHistory/ReveiwHistory/resource.h
@@ -91,6 +91,8 @@
 #define IDC_COMBO_OFFSET_DIRECTION_Y    1056
 #define IDC_EDIT_OFFSET_X               1057
 #define IDC_EDIT_OFFSET_Y               1058
+#define IDC_BUTTON_OFFSET_SAVE          1059
+#define IDC_BUTTON_OFFSET_APPLY         1060
 #define ID_OPTION_PATHSETTING           32771
 #define ID_VIEW_ALLDEFECT               32772
 #define ID_VIEW_REVIEWDEFECT            32773
@@ -103,7 +105,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        150
 #define _APS_NEXT_COMMAND_VALUE         32776
-#define _APS_NEXT_CONTROL_VALUE         1057
+#define _APS_NEXT_CONTROL_VALUE         1061
 #define _APS_NEXT_SYMED_VALUE           104
 #endif
 #endif
diff --git a/ReviewHistory/bin/Config/PathSetting.ini b/ReviewHistory/bin/Config/PathSetting.ini
index 6f46929..a0447d5 100644
--- a/ReviewHistory/bin/Config/PathSetting.ini
+++ b/ReviewHistory/bin/Config/PathSetting.ini
@@ -1,7 +1,7 @@
 [Path]
 Align=D:\ResultData\Align\
 Bin=D:\DIT_ResultData\RawBin\
-Inspector=\\126.100.100.1\d\Image\Defect
+Inspector=D:\Defect
 Review=D:\ResultData\UploadImage\
 DirectionX=0
 DirectionY=0
diff --git a/ReviewHistory/bin/ReviewHistroy.exe b/ReviewHistory/bin/ReviewHistroy.exe
index ff64eb3..4e7d312 100644
--- a/ReviewHistory/bin/ReviewHistroy.exe
+++ b/ReviewHistory/bin/ReviewHistroy.exe
Binary files differ
diff --git a/ReviewHistory/bin/no-image.png b/ReviewHistory/bin/no-image.png
index b38fee1..d99c210 100644
--- a/ReviewHistory/bin/no-image.png
+++ b/ReviewHistory/bin/no-image.png
Binary files differ
diff --git a/ReviewHistory/include/MacroFile.h b/ReviewHistory/include/MacroFile.h
new file mode 100644
index 0000000..2f68021
--- /dev/null
+++ b/ReviewHistory/include/MacroFile.h
@@ -0,0 +1,421 @@
+#pragma once
+#include "stdafx.h"
+
+class CMacroFile  
+{
+public:
+	CMacroFile()	{ Clear(); }
+	~CMacroFile()	{ Clear(); }
+
+	void Clear()
+	{
+		m_arTiltleLine.RemoveAll();
+		m_arValueLine.RemoveAll();
+	}
+
+	BOOL Read(const TCHAR* lpstrFilePath)
+	{
+		CStdioFile file;
+		CFileException ex;
+
+		if ( !file.Open(lpstrFilePath, CFile::modeRead, &ex))
+		{
+
+#ifdef _DEBUG
+			TCHAR   szCause[255] = {0};
+			ex.GetErrorMessage(szCause, 255);
+			TRACE(szCause);
+#endif
+			return FALSE;
+		}
+
+		CString strLine;
+		CString strTiltle, strValue;
+		int p = 0;
+
+		while(file.ReadString(strLine))
+		{
+			strTiltle = _T("");
+			strValue = _T("");
+
+
+			if ( -1 == (p = strLine.Find(_T('='), 0))) continue;
+
+			strTiltle = strLine.Left(p);
+			strValue = strLine.Right(strLine.GetLength() - p - 1);		
+
+			m_arTiltleLine.Add(strTiltle);
+			m_arValueLine.Add(strValue);
+
+
+		}
+
+		file.Close();
+
+		return TRUE;
+	}
+
+	BOOL Write(const TCHAR* lpstrFilePath)
+	{
+		CStdioFile file;
+		CFileException ex;
+
+		if ( !file.Open(lpstrFilePath, CFile::modeCreate | CFile::modeWrite, &ex))
+		{
+#ifdef _DEBUG
+			TCHAR   szCause[255] = {0};
+			ex.GetErrorMessage(szCause, 255);
+			TRACE(szCause);
+#endif
+			return FALSE;
+		}
+
+		CString strLine = _T("");
+		CString strTiltle, strValue;
+
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strTiltle = _T("");
+			strValue = _T("");
+
+			strTiltle = m_arTiltleLine.GetAt(nIndex);
+			strValue = m_arValueLine.GetAt(nIndex);
+
+			strLine.Format(_T("%s=%s"), strTiltle, strValue);
+
+			file.WriteString(CString(strLine)+_T("\n"));
+
+		}
+
+		file.Close();
+
+		return TRUE;
+	}
+
+	void GetItem(const TCHAR* lpstrTitle, short& sValue, short sDefault=0)
+	{
+		CString strText = _T("");
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+			if(strText.Compare(lpstrTitle)==0)
+			{
+				strText = m_arValueLine.GetAt(nIndex);
+				sValue = ::_ttoi((LPCTSTR)strText);
+				return;
+			}
+		}
+		sValue = sDefault;
+	}
+
+	void GetItem(const TCHAR* lpstrTitle, int& nValue, int nDefault=0)
+	{
+		CString strText = _T("");
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+			if(strText.Compare(lpstrTitle)==0)
+			{
+				strText = m_arValueLine.GetAt(nIndex);
+				strText.Remove('`');
+				nValue = ::_ttoi((LPCTSTR)strText);
+				return;
+			}
+		}
+		nValue = nDefault;
+	}
+
+	void GetItem(const TCHAR* lpstrTitle, UINT& unValue, UINT unDefault=0)
+	{
+		CString strText = _T("");
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+			if(strText.Compare(lpstrTitle)==0)
+			{
+				strText = m_arValueLine.GetAt(nIndex);
+				unValue = ::_ttoi((LPCTSTR)strText);
+				return;
+			}
+		}
+		unValue = unDefault;
+	}
+
+	void GetItem(const TCHAR* lpstrTitle, long& lValue, long lDefault=0)
+	{
+		CString strText = _T("");
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+			if(strText.Compare(lpstrTitle) == 0)
+			{
+				strText = m_arValueLine.GetAt(nIndex);
+				lValue = ::_ttoi((LPCTSTR)strText);
+				return;
+			}
+		}
+		lValue = lDefault;
+	}
+
+	void GetItem(const TCHAR* lpstrTitle, float& fValue, float fDefault=0.0f)
+	{
+		CString strText = _T("");
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+			if(strText.Compare(lpstrTitle) == 0)
+			{
+				strText = m_arValueLine.GetAt(nIndex);
+				//strText.Replace('\'','');
+				strText.Remove('`');
+				fValue =  float(_tstof((LPCTSTR)strText));
+				return;
+			}
+		}
+		fValue = fDefault;
+	}
+
+	void GetItem(const TCHAR* lpstrTitle, double& dValue, double dDefault=0.0)
+	{
+		CString strText = _T("");
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+			if(strText.Compare(lpstrTitle) == 0)
+			{
+				strText = m_arValueLine.GetAt(nIndex);
+				dValue =  _tcstod((LPCTSTR)strText, NULL);
+				return;
+			}
+		}
+		dValue = dDefault;
+	}
+
+	void GetItem(const TCHAR* lpstrTitle, TCHAR &cValue, TCHAR cDefault=_T(' '))
+	{
+		CString strText = _T("");
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+			if(strText.Compare(lpstrTitle) == 0)
+			{
+				strText = m_arValueLine.GetAt(nIndex);
+				cValue = (m_arValueLine.GetAt(nIndex)).GetAt(0);
+				return;
+			}
+		}
+		cValue = cDefault;
+	}
+
+	void GetItem(const TCHAR* lpstrTitle, CString& strValue, CString strDefault=_T(""))
+	{
+		CString strText = _T("");
+
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+
+			if(strText.Compare(lpstrTitle) == 0)
+			{
+				strValue = m_arValueLine.GetAt(nIndex);
+				return;
+			}
+		}
+		strValue = strDefault;
+	}
+
+
+	void SetItem(const TCHAR* lpstrTitle, const short& sValue)
+	{
+		TCHAR szValue[256];
+		_stprintf_s(szValue, _T("%d"), sValue);
+
+		SetItem(lpstrTitle, szValue);
+	}
+
+	void SetItem(const TCHAR* lpstrTitle,const int& nValue)
+	{
+		TCHAR szValue[256];
+		_stprintf_s(szValue, _T("%d"), nValue);
+
+		SetItem(lpstrTitle, szValue);
+	}
+
+	void SetItem(const TCHAR* lpstrTitle, const UINT& unValue)
+	{
+		TCHAR szValue[256];
+		_stprintf_s(szValue, _T("%d"), unValue);
+
+		SetItem(lpstrTitle, szValue);
+	}
+
+	void SetItem(const TCHAR* lpstrTitle, const long& lValue)
+	{
+		TCHAR szValue[256];
+		_stprintf_s(szValue, _T("%d"), lValue);
+
+		SetItem(lpstrTitle, szValue);
+	}
+
+	void SetItem(const TCHAR* lpstrTitle, const float& fValue)
+	{
+		TCHAR szValue[256];
+		_stprintf_s(szValue, _T("%.8f"), fValue);
+
+		SetItem(lpstrTitle, szValue);
+	}
+
+	void SetItem(const TCHAR* lpstrTitle, const double& dValue)
+	{
+		TCHAR szValue[256];
+		_stprintf_s(szValue, _T("%.8lf"), dValue);
+
+		SetItem(lpstrTitle, szValue);
+	}
+
+	void SetItem(const TCHAR* lpstrTitle, const TCHAR &cValue)
+	{
+		TCHAR szValue[256];
+		_stprintf_s(szValue, _T("%c"), cValue);
+
+		SetItem(lpstrTitle, szValue);
+	}
+
+	void SetItem(const TCHAR* lpstrTitle, const CString& strValue)
+	{
+		SetItem(lpstrTitle, (LPCTSTR)strValue);
+	}
+
+	void SetItem(const TCHAR* lpstrTitle, const TCHAR* lpstrValue)
+	{
+		BOOL bNewItem = TRUE;
+		CString strText = _T("");
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+			if(strText.Compare(lpstrTitle) == 0)
+			{
+				m_arValueLine.SetAt(nIndex, lpstrValue);
+				bNewItem = FALSE;
+			}
+		}
+
+		if(bNewItem)
+		{
+			m_arTiltleLine.Add(lpstrTitle);
+			m_arValueLine.Add(lpstrValue);
+		}
+	}
+
+	void GetItem(const TCHAR* lpstrTitle, TCHAR* lpBuffer, const int nMaxLength)
+	{
+		ASSERT(lpBuffer);
+		ASSERT(nMaxLength > 0);
+
+		ZeroMemory(lpBuffer, sizeof(char)*nMaxLength);
+
+		CString strText = _T("");
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strText = m_arTiltleLine.GetAt(nIndex);
+			if(strText.Compare(lpstrTitle) == 0)
+			{
+				strText = m_arValueLine.GetAt(nIndex);
+				_tcscpy_s(lpBuffer, strText.GetLength(), (LPCTSTR)strText);
+				break;
+			}
+		}
+	}
+
+
+	void GetItem(const TCHAR* lpstrStartChar, const TCHAR* lpstrEndChar, TCHAR* lpBuffer, const int nMaxLength)
+	{
+		ASSERT(lpBuffer);
+		ASSERT(nMaxLength > 0);
+
+		ZeroMemory(lpBuffer, sizeof(char)*nMaxLength);
+
+		CString strTitle , strValue ;
+
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strTitle = _T("");
+			strValue = _T("");
+
+			strTitle = m_arTiltleLine.GetAt(nIndex);
+			strValue = m_arValueLine.GetAt(nIndex);
+
+			if (strTitle.IsEmpty()) continue;
+
+			if( strTitle.GetAt(0) == _T('!') && strValue.Compare(lpstrStartChar) == 0)
+			{
+				for(int n2thIndex = nIndex+1; m_arTiltleLine.GetSize(); n2thIndex++)
+				{
+					strTitle = _T("");
+					strValue = _T("");
+
+					strTitle = m_arTiltleLine.GetAt(n2thIndex);
+					strValue = m_arValueLine.GetAt(n2thIndex);
+
+					if (strTitle.IsEmpty()) continue;
+
+					if( strTitle.GetAt(0) == _T('!') && strValue.Compare(lpstrEndChar) == 0) 
+						break;
+
+					if ( int((_tcslen(lpBuffer) + strValue.GetLength()+1)) > nMaxLength)
+						break;
+
+					_tcscat_s(lpBuffer, strValue.GetLength(), (LPCTSTR)strValue);
+					_tcscat_s(lpBuffer, 1, _T("\n"));
+				}
+			}
+		}
+	}
+
+	void SetItem(const TCHAR* lpstrStartChar, const TCHAR* lpstrEndChar, const TCHAR* lpstrMacroFormat, ...)
+	{
+		va_list list;
+		TCHAR strText[2000] = {0};
+
+		va_start(list, lpstrMacroFormat);
+		_vstprintf_s(strText, lpstrMacroFormat, list);
+		va_end(list);
+
+		CString strTitle , strValue ;
+
+		BOOL bNewItem = TRUE;
+
+		for(int nIndex=0; nIndex<m_arTiltleLine.GetSize(); nIndex++)
+		{
+			strTitle = m_arTiltleLine.GetAt(nIndex);
+			strValue =	m_arValueLine.GetAt(nIndex);
+
+			if (strTitle.IsEmpty()) continue;
+
+			if( strTitle.GetAt(0) == _T('!') && strValue.Compare(lpstrEndChar) == 0)
+			{
+				m_arTiltleLine.InsertAt(nIndex, _T("!"), 1);
+				m_arValueLine.InsertAt(nIndex, strText, 1);
+				bNewItem = FALSE;
+				break;
+			}
+		}
+
+		if (bNewItem)
+		{
+			m_arTiltleLine.Add(_T("!"));
+			m_arValueLine.Add(lpstrStartChar);
+
+			m_arTiltleLine.Add(_T("!"));
+			m_arValueLine.Add(strText);
+
+			m_arTiltleLine.Add(_T("!"));
+			m_arValueLine.Add(lpstrEndChar);
+
+		}
+	}
+
+protected:
+	CStringArray m_arTiltleLine;
+	CStringArray m_arValueLine;
+};
diff --git a/ReviewSystem/ReviewSystem/DlgReviewOffSetTool.cpp b/ReviewSystem/ReviewSystem/DlgReviewOffSetTool.cpp
index a192434..7092656 100644
--- a/ReviewSystem/ReviewSystem/DlgReviewOffSetTool.cpp
+++ b/ReviewSystem/ReviewSystem/DlgReviewOffSetTool.cpp
@@ -90,6 +90,7 @@
 	ON_MESSAGE(WM_OFFSETTOOL_MESSAGE2, OnUpdatedata)
 	ON_BN_CLICKED(IDC_BUTTON_SAVE_SETTING_FILE, &DlgReviewOffSetTool::OnBnClickedButtonSaveSettingFile)
 	ON_BN_CLICKED(IDC_CHECK_OFFSET_MODE, &DlgReviewOffSetTool::OnBnClickedCheckOffsetMode)
+	ON_BN_CLICKED(IDC_OFFSET_LOAD, &DlgReviewOffSetTool::OnBnClickedOffsetLoad)
 END_MESSAGE_MAP()
 
 
@@ -1098,3 +1099,15 @@
 	 
 	
 }
+
+/*< LYW 20211025 - #3684 ADD Start >*/
+void DlgReviewOffSetTool::OnBnClickedOffsetLoad()
+{
+
+	// TODO: �뿬湲곗뿉 而⑦듃濡� �븣由� 泥섎━湲� 肄붾뱶瑜� 異붽��빀�땲�떎.
+	ReadConfigFile();
+	UpdateGridcontrol();
+	UpdateData(TRUE);
+	Invalidate(FALSE);
+}
+/*< LYW 20211025 - #3684 ADD End >*/
\ No newline at end of file
diff --git a/ReviewSystem/ReviewSystem/DlgReviewOffSetTool.h b/ReviewSystem/ReviewSystem/DlgReviewOffSetTool.h
index e90011f..703909f 100644
--- a/ReviewSystem/ReviewSystem/DlgReviewOffSetTool.h
+++ b/ReviewSystem/ReviewSystem/DlgReviewOffSetTool.h
@@ -184,4 +184,7 @@
 	double m_editGlassOffSetmodeXpos;
 	double m_editGlassOffSetmodeYpos;
 	afx_msg void OnBnClickedCheckOffsetMode();
+	/*< LYW 20211025 - #index ADD Start >*/
+	afx_msg void OnBnClickedOffsetLoad();
+	/*< LYW 20211025 - #index ADD End >*/
 };
diff --git a/ReviewSystem/ReviewSystem/ReviewSystem.rc b/ReviewSystem/ReviewSystem/ReviewSystem.rc
index 767a254..fe32c3b 100644
--- a/ReviewSystem/ReviewSystem/ReviewSystem.rc
+++ b/ReviewSystem/ReviewSystem/ReviewSystem.rc
@@ -867,7 +867,7 @@
     EDITTEXT        IDC_EDIT_SETTINGFILE_PATH,545,50,202,14,ES_AUTOHSCROLL | WS_DISABLED
     LTEXT           "X Pos Count",IDC_STATIC,621,32,40,8
     EDITTEXT        IDC_EDIT_XPOS_COUNT,662,28,40,14,ES_AUTOHSCROLL
-    PUSHBUTTON      "APPLY GRID DATA",IDC_BUTTON_APPLY_GRID_DATA,132,62,134,23
+    PUSHBUTTON      "APPLY GRID DATA",IDC_BUTTON_APPLY_GRID_DATA,209,62,65,23
     PUSHBUTTON      "APPLY",IDC_BUTTON_APPLT_OFFSET_PARAM,704,14,43,23
     CONTROL         "",IDC_PROGRESS_PROCESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,337,67,168,14
     PUSHBUTTON      "SAVE",IDC_BUTTON_SAVE_SETTING_FILE,279,64,56,20
@@ -876,6 +876,7 @@
     EDITTEXT        IDC_EDIT_SCAN_INDEX,621,67,19,14,ES_AUTOHSCROLL
     EDITTEXT        IDC_EDIT_CAM_INDEX,600,67,19,14,ES_AUTOHSCROLL
     EDITTEXT        IDC_EDIT_MOTOR_YPOS,694,67,54,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "Offset Load",IDC_OFFSET_LOAD,139,63,62,22
 END
 
 IDD_DLG_REVIEW_HISTORY_TOOL DIALOGEX 0, 0, 961, 455
diff --git a/ReviewSystem/ReviewSystem/resource.h b/ReviewSystem/ReviewSystem/resource.h
index 7659a7c..61138ac 100644
--- a/ReviewSystem/ReviewSystem/resource.h
+++ b/ReviewSystem/ReviewSystem/resource.h
@@ -1,6 +1,6 @@
 //{{NO_DEPENDENCIES}}
-// Microsoft Visual C++에서 생성한 포함 파일입니다.
-// ReviewSystem.rc에서 사용되고 있습니다.
+// Microsoft Visual C++�뿉�꽌 �깮�꽦�븳 �룷�븿 �뙆�씪�엯�땲�떎.
+// ReviewSystem.rc�뿉�꽌 �궗�슜�릺怨� �엳�뒿�땲�떎.
 //
 #define IDCANCEL                        2
 #define IDD_ABOUTBOX                    100
@@ -432,6 +432,7 @@
 #define IDC_EDIT_WSI_HEIGHT12           1182
 #define IDC_EDIT_WSI_HEIGHT13           1183
 #define IDC_LIST_WSI_DIAGNOSIS_RESULT   1184
+#define IDC_OFFSET_LOAD                 1185
 #define ID_INS_HOOK                     32772
 #define ID_UNINS_HOOK                   32773
 
@@ -441,7 +442,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        381
 #define _APS_NEXT_COMMAND_VALUE         32775
-#define _APS_NEXT_CONTROL_VALUE         1185
+#define _APS_NEXT_CONTROL_VALUE         1186
 #define _APS_NEXT_SYMED_VALUE           346
 #endif
 #endif

--
Gitblit v1.9.3