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

---
 ReviewHistory/ReveiwHistory/PathSettingDlg.h     |    3 +
 ReviewHistory/ReveiwHistory/resource.h           |    9 ++
 ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp |   77 +++++++++++++++++++++++++
 ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h   |   14 ++++
 ReviewHistory/ReveiwHistory/akImageView.cpp      |   23 ++++++-
 ReviewHistory/ReveiwHistory/akImageView.h        |   11 +++
 ReviewHistory/bin/Config/PathSetting.ini         |    2 
 ReviewHistory/ReveiwHistory/ReveiwHistory.rc     |    0 
 ReviewHistory/ReveiwHistory/PathSettingDlg.cpp   |   41 +++++++++++++
 ReviewHistory/bin/ReviewHistroy.exe              |    0 
 10 files changed, 174 insertions(+), 6 deletions(-)

diff --git a/ReviewHistory/ReveiwHistory/PathSettingDlg.cpp b/ReviewHistory/ReveiwHistory/PathSettingDlg.cpp
index d5f7424..73c9669 100644
--- a/ReviewHistory/ReveiwHistory/PathSettingDlg.cpp
+++ b/ReviewHistory/ReveiwHistory/PathSettingDlg.cpp
@@ -27,6 +27,8 @@
 void CPathSettingDlg::DoDataExchange(CDataExchange* pDX)
 {
 	CDialogEx::DoDataExchange(pDX);
+	DDX_Control(pDX, IDC_COMBO_OFFSET_DIRECTION_X, m_comboDirectionX);
+	DDX_Control(pDX, IDC_COMBO_OFFSET_DIRECTION_Y, m_comboDirectionY);
 }
 
 
@@ -44,6 +46,8 @@
 BOOL CPathSettingDlg::Create(CWnd* pParentWnd)
 {
 	return CDialogEx::Create(IDD, pParentWnd);
+
+
 }
 
 BOOL CPathSettingDlg::PreTranslateMessage(MSG* pMsg)
@@ -218,6 +222,15 @@
 	INIWriteStr("Path", "Inspector", m_strInspectorPath, strFilePath);
 	GetDlgItemText(IDC_EDIT_REVIEW_PATH, m_strReviewPath);
 	INIWriteStr("Path", "Review", m_strReviewPath, strFilePath);
+	/*< LYW 20211018 - #3684 ADD Start >*/
+	CString strTemp;
+	strTemp.Format(_T("%d"), m_comboDirectionX.GetCurSel());
+	INIWriteStr("Path", "DirectionX", strTemp, strFilePath);
+	strTemp.Format(_T("%d"), m_comboDirectionY.GetCurSel());
+	INIWriteStr("Path", "DirectionY", strTemp, strFilePath);
+	
+	/*< LYW 20211018 - #3684 ADD End >*/
+	
 
 	AfxMessageBox(_T("���옣 �릺�뿀�뒿�땲�떎"), MB_OK | MB_ICONWARNING);
 
@@ -271,6 +284,12 @@
 	m_strInspectorPath = INIReadStr(strAppName, _T("Inspector"), strFilePath);
 	m_strReviewPath = INIReadStr(strAppName, _T("Review"), strFilePath);
 
+	CString strTemp;
+	strTemp = INIReadStr(strAppName, _T("DirectionX"), strFilePath);
+	m_comboDirectionX.SetCurSel(_ttoi(strTemp));
+	strTemp = INIReadStr(strAppName, _T("DirectionY"), strFilePath);
+	m_comboDirectionY.SetCurSel(_ttoi(strTemp));
+
 	if (m_strAlignPath == "")
 	{
 		m_strAlignPath.Format(_T("D:\\ResultData\\Align\\"));
@@ -294,4 +313,24 @@
 	SetDlgItemText(IDC_EDIT_REVIEW_PATH, m_strReviewPath);
 
 	LOG(Dbg, _T("[PathSetting] Start Review Path Setting Load"));
-}
\ No newline at end of file
+}
+
+
+/*< LYW 20211018 - #3684 ADD Start >*/
+BOOL CPathSettingDlg::OnInitDialog()
+{
+	__super::OnInitDialog();
+
+	// TODO:  �뿬湲곗뿉 異붽� 珥덇린�솕 �옉�뾽�쓣 異붽��빀�땲�떎.
+	m_comboDirectionX.AddString(_T("Nomal"));
+	m_comboDirectionX.AddString(_T("Reverse"));
+	m_comboDirectionY.AddString(_T("Nomal"));
+	m_comboDirectionY.AddString(_T("Reverse"));
+
+	m_comboDirectionX.SetCurSel(0);
+	m_comboDirectionY.SetCurSel(0);
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+				  // �삁�쇅: OCX �냽�꽦 �럹�씠吏��뒗 FALSE瑜� 諛섑솚�빐�빞 �빀�땲�떎.
+}
+/*< LYW 20211018 - #3684 ADD End >*/
diff --git a/ReviewHistory/ReveiwHistory/PathSettingDlg.h b/ReviewHistory/ReveiwHistory/PathSettingDlg.h
index f502ff2..01aec2e 100644
--- a/ReviewHistory/ReveiwHistory/PathSettingDlg.h
+++ b/ReviewHistory/ReveiwHistory/PathSettingDlg.h
@@ -44,4 +44,7 @@
 	CString GetInspectorPath() { return m_strInspectorPath; }
 	CString GetReviewPath() { return m_strReviewPath; }
 	CString GetAlignPath() { return m_strAlignPath; }
+	CComboBox m_comboDirectionX;
+	CComboBox m_comboDirectionY;
+	virtual BOOL OnInitDialog();
 };
diff --git a/ReviewHistory/ReveiwHistory/ReveiwHistory.rc b/ReviewHistory/ReveiwHistory/ReveiwHistory.rc
index 905b134..fa929be 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 b607bc7..d58cbe4 100644
--- a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp
+++ b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp
@@ -54,6 +54,11 @@
 CReveiwHistoryDlg::CReveiwHistoryDlg(CWnd* pParent /*=nullptr*/)
 	: CDialogEx(IDD_DLG_REVIEWHISTORY, pParent)
 	, m_nFileCount(0)
+	, m_nEditCamIdx(0)
+	, m_nEditScanIdx(0)
+	, m_dEditOffsetX(0)
+	, m_dEditOffsetY(0)
+	, m_strGantryIdx(_T(""))
 {
 	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
 
@@ -73,6 +78,10 @@
 	m_nImageCount = 0;
 	m_nCellCount = 0;
 	m_bAsending = FALSE;
+	/*< LYW 20211018 - #3684 ADD Start >*/
+	m_dCurDefectIdx = 0;
+	m_dCurDefectID = 0;
+	/*< LYW 20211018 - #3684 ADD End >*/
 
 	for (int i = 0; i < 105; i++)
 	{
@@ -97,6 +106,11 @@
 	DDX_Text(pDX, IDC_EDIT_FILE_COUNT, m_nFileCount);
 	DDX_Control(pDX, IDC_EDIT_FILE_COUNT, m_ctlFileCount);
 	DDX_Control(pDX, IDC_PROGRESS_LOAD, m_ctlProgress);
+	DDX_Text(pDX, IDC_EDIT_OFFSET_CAM_IDX, m_nEditCamIdx);
+	DDX_Text(pDX, IDC_EDIT_OFFSET_SCAN_IDX, m_nEditScanIdx);
+	DDX_Text(pDX, IDC_EDIT_OFFSET_X, m_dEditOffsetX);
+	DDX_Text(pDX, IDC_EDIT_OFFSET_Y, m_dEditOffsetY);
+	DDX_Text(pDX, IDC_EDIT_DFFSET_GANTRY_IDX, m_strGantryIdx);
 }
 
 BEGIN_MESSAGE_MAP(CReveiwHistoryDlg, CDialogEx)
@@ -109,6 +123,7 @@
 	ON_BN_CLICKED(IDC_BUTTON_MAPVIEW_FIT, &CReveiwHistoryDlg::OnBnClickedButtonMapviewFit)
 	ON_MESSAGE(UM_FORMMAP_DEFECTSELECT, OnMapDefectSelected)
 	ON_MESSAGE(UM_FORMMAP_DEFECTMOUSEOVER, OnMapDefectMouseOver)
+	ON_MESSAGE(UM_FORMMAP_IMAGEMOUSECLICK, OnImageClick)
 	ON_COMMAND(ID_OPTION_PATHSETTING, &CReveiwHistoryDlg::OnOptionPathsetting)
 	ON_COMMAND(ID_VIEW_ALLDEFECT, &CReveiwHistoryDlg::OnViewAlldefect)
 	ON_COMMAND(ID_VIEW_REVIEWDEFECT, &CReveiwHistoryDlg::OnViewReviewdefect)
@@ -1220,6 +1235,61 @@
 	return 0;
 }
 
+/*< LYW 20211018 - #3684 ADD Start >*/
+LRESULT CReveiwHistoryDlg::OnImageClick(WPARAM wParam, LPARAM lParam)
+{
+	CPathSettingDlg* lpDlg = CPathSettingDlg::GetMgr();
+	if (lpDlg == NULL) return 0;
+	
+	_akDefect			*pDefect;
+ 	pDefect = &m_Formation.m_vecDefects[m_dCurDefectIdx];
+	if (pDefect == NULL) return 0;
+
+	CPoint Point;
+	Point.x = GET_X_LPARAM(lParam);
+	Point.y = GET_Y_LPARAM(lParam);
+
+	int dOffsetDrectionX;
+	int dOffsetDrectionY;
+
+	if (lpDlg->m_comboDirectionX.GetCurSel() == 1) dOffsetDrectionX = -1;
+	else dOffsetDrectionX = 1;
+
+	if (lpDlg->m_comboDirectionY.GetCurSel() == 1) dOffsetDrectionY = -1;
+	else dOffsetDrectionY = 1;
+
+	if (pDefect->m_nDefectID == m_dCurDefectID)
+	{
+		m_nEditCamIdx = pDefect->m_nCameraID;
+		m_nEditScanIdx = pDefect->m_nScanIdx;
+		if (pDefect->m_nModelIdx == 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)
+		{
+			m_strGantryIdx = _T("Right");
+			m_dEditOffsetX = (double)-(dOffsetDrectionX * (Point.x / 5)) / 1000;
+			m_dEditOffsetY = (double)-(dOffsetDrectionY * (Point.y / 5)) / 1000;
+		}
+		else AfxMessageBox(_T("寃먰듃由� �씤�뜳�뒪媛� 鍮꾩젙�긽 �엯�땲�떎."), MB_OK | MB_ICONWARNING);
+	}
+
+	else
+	{
+		if (IDOK == AfxMessageBox(_T("�씠誘몄� �씤�뜳�뒪媛� �씪移섑븯吏� �븡�뒿�땲�떎."), MB_OK | MB_ICONWARNING))
+		{
+			return 0;
+		}
+	}
+
+	UpdateData(FALSE);
+	return 0;
+}
+/*< LYW 20211018 - #3684 ADD End >*/
+
 LRESULT CReveiwHistoryDlg::OnMapDefectMouseOver(WPARAM wParam, LPARAM lParam)
 {
 	int nSelectDefect = static_cast<int>(wParam);
@@ -2022,6 +2092,13 @@
 		}
 	}
 	_akReviewList* pImageInfo = &m_Formation.m_vecImage[nIndex];
+	m_dCurDefectID = pImageInfo->m_nDefectID;
+ 	m_dCurDefectIdx = nIndex;
+// 	_akDefect			*pDefect;
+// 	pDefect = &m_Formation.m_vecDefects[nIndex];
+// 	m_dCurDefectCam = pDefect->m_nCameraID;
+// 	m_dCurDefectModuleIdx = pDefect->m_nModelIdx;
+// 	m_dCurDefectScan = pDefect->m_nScanIdx;
 	//紐� 踰덉㎏ �씤吏� �뜕吏꾨떎.
 
 	CString wekfjlwe = pImageInfo->m_strReviewImageName;
diff --git a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h
index 94a0566..b3d4ea5 100644
--- a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h
+++ b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.h
@@ -113,6 +113,12 @@
 
 	CakGridCtrl m_ctrlGridGlassList;
 
+	/*< LYW 20211018 - #3684 ADD Start >*/
+	//CurrentDefect, Offset 怨꾩궛 �궗�슜
+	int m_dCurDefectIdx;
+	int m_dCurDefectID;
+	/*< LYW 20211018 - #3684 ADD End >*/
+
 	// tracker
 	BOOL			m_bDrawTracker;
 	CPoint			m_ptTrackerStart;
@@ -208,6 +214,9 @@
 	afx_msg LRESULT OnMapDefectSelected(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnMapDefectMouseOver(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnListDefectSelected(WPARAM wParam, LPARAM lParam);
+	/*< LYW 20211018 - #3684 ADD Start >*/
+	afx_msg LRESULT OnImageClick(WPARAM wParam, LPARAM lParam);
+	/*< LYW 20211018 - #3684 ADD End >*/
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 
 	afx_msg void OnOptionPathsetting();
@@ -280,4 +289,9 @@
 	int	GetCellCount() { return m_nCellCount; }
 
 	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
+	int m_nEditCamIdx;
+	int m_nEditScanIdx;
+	double m_dEditOffsetX;
+	double m_dEditOffsetY;
+	CString m_strGantryIdx;
 };
diff --git a/ReviewHistory/ReveiwHistory/akImageView.cpp b/ReviewHistory/ReveiwHistory/akImageView.cpp
index d8f6e8f..cd95e60 100644
--- a/ReviewHistory/ReveiwHistory/akImageView.cpp
+++ b/ReviewHistory/ReveiwHistory/akImageView.cpp
@@ -183,8 +183,13 @@
 
 		pOldBitmap = BitmapDC.SelectObject(&pImageData->m_Bitmap);
 
-		double dOnePixelX = (double)m_rectData.Width() / m_AxisX.GetRangeValue();
-		double dOnePixelY = (double)m_rectData.Height() / m_AxisY.GetRangeValue();
+		/*< LYW 20211018 - #3684 MOD Start >*/
+		m_dOnePixelX =  m_AxisX.GetRangeValue() / (double)m_rectData.Width();
+		m_dOnePixelY =  m_AxisY.GetRangeValue() / (double)m_rectData.Height();
+		/*< LYW 20211018 - #3684 MOD End >*/
+		/*< Origin Code >*/
+		//double dOnePixelX = (double)m_rectData.Width() / m_AxisX.GetRangeValue();
+		//double dOnePixelY = (double)m_rectData.Height() / m_AxisY.GetRangeValue();
 
 		if (1)//dOnePixelX > 2 && dOnePixelY > 2)
 		{
@@ -312,9 +317,19 @@
 
 		CRect rect;
 		this->GetClientRect(rect);
+		
+		/*< LYW 20211018 - #3684 ADD Start >*/
+		CPoint Center;
+		Center.x = rect.Width() / 2;
+		Center.y = rect.Height() / 2;
+		/*< LYW 20211018 - #3684 ADD End >*/
 
-		point.x += m_nHScroll;
-		point.y += m_nVScroll;
+		/*< LYW 20211018 - #3684 MOD Start >*/
+		point.x = (point.x - Center.x) * m_dOnePixelX;
+		point.y = (point.y - Center.y) * m_dOnePixelY;
+		/*< LYW 20211018 - #3684 MOD End >*/
+		/*< Origin Code >*/
+		GetParent()->PostMessage(UM_FORMMAP_IMAGEMOUSECLICK, static_cast<WPARAM>(0), MAKELPARAM(point.x, point.y));
 		/*m_pParentWnd->SendMessage(WM_LBUTTONDOWN, static_cast<WPARAM>(nFlags), MAKELPARAM(point.x, point.y));*/
 	}
 	break;
diff --git a/ReviewHistory/ReveiwHistory/akImageView.h b/ReviewHistory/ReveiwHistory/akImageView.h
index a0d266a..8b6d050 100644
--- a/ReviewHistory/ReveiwHistory/akImageView.h
+++ b/ReviewHistory/ReveiwHistory/akImageView.h
@@ -3,6 +3,10 @@
 #include "akGraph/akGraphBasic3.h"
 #include <vector>
 
+/*< LYW 20211018 - #3684 ADD Start >*/
+#define UM_FORMMAP_IMAGEMOUSECLICK WM_USER+0x2003
+/*< LYW 20211018 - #3684 ADD End >*/
+
 struct SPixelInfo
 {
 	SPixelInfo()
@@ -80,6 +84,13 @@
 	// Max Scroll Pos
 	int			m_nMaxVScroll;
 	int			m_nMaxHScroll;
+	/*< LYW 20211018 - #3684 ADD Start >*/
+	// OnePixel
+	double		m_dOnePixelX;
+	double		m_dOnePixelY;
+	/*< LYW 20211018 - #3684 ADD End >*/
+
+
 };
 
 class CakImageView : public CakGraphBasic3, public CakDataImage2
diff --git a/ReviewHistory/ReveiwHistory/resource.h b/ReviewHistory/ReveiwHistory/resource.h
index a06eef9..085e375 100644
--- a/ReviewHistory/ReveiwHistory/resource.h
+++ b/ReviewHistory/ReveiwHistory/resource.h
@@ -84,6 +84,13 @@
 #define IDC_PROGRESS_FILE               1047
 #define IDC_PROGRESS1                   1048
 #define IDC_PROGRESS_LOAD               1048
+#define IDC_EDIT_DFFSET_GANTRY_IDX      1054
+#define IDC_EDIT_OFFSET_CAM_IDX         1055
+#define IDC_COMBO_OFFSET_DIRECTION_X    1055
+#define IDC_EDIT_OFFSET_SCAN_IDX        1056
+#define IDC_COMBO_OFFSET_DIRECTION_Y    1056
+#define IDC_EDIT_OFFSET_X               1057
+#define IDC_EDIT_OFFSET_Y               1058
 #define ID_OPTION_PATHSETTING           32771
 #define ID_VIEW_ALLDEFECT               32772
 #define ID_VIEW_REVIEWDEFECT            32773
@@ -96,7 +103,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        150
 #define _APS_NEXT_COMMAND_VALUE         32776
-#define _APS_NEXT_CONTROL_VALUE         1054
+#define _APS_NEXT_CONTROL_VALUE         1057
 #define _APS_NEXT_SYMED_VALUE           104
 #endif
 #endif
diff --git a/ReviewHistory/bin/Config/PathSetting.ini b/ReviewHistory/bin/Config/PathSetting.ini
index f334552..6f46929 100644
--- a/ReviewHistory/bin/Config/PathSetting.ini
+++ b/ReviewHistory/bin/Config/PathSetting.ini
@@ -3,3 +3,5 @@
 Bin=D:\DIT_ResultData\RawBin\
 Inspector=\\126.100.100.1\d\Image\Defect
 Review=D:\ResultData\UploadImage\
+DirectionX=0
+DirectionY=0
diff --git a/ReviewHistory/bin/ReviewHistroy.exe b/ReviewHistory/bin/ReviewHistroy.exe
index 452fb44..ff64eb3 100644
--- a/ReviewHistory/bin/ReviewHistroy.exe
+++ b/ReviewHistory/bin/ReviewHistroy.exe
Binary files differ

--
Gitblit v1.9.3