From c08fcb0ca69c8893d64504e082608ad8fb82eb40 Mon Sep 17 00:00:00 2001
From: LYW <leeyeanwoo@diteam.co.kr>
Date: 월, 25 10월 2021 08:58:31 +0900
Subject: [PATCH] 프로그램 시작시 백업 기능 삭제(네트워크 딜레이로 인한 프로그램 지연)

---
 ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp |  160 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 155 insertions(+), 5 deletions(-)

diff --git a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp
index 81b16e1..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)
@@ -121,6 +136,7 @@
 	ON_BN_CLICKED(IDC_CHK_REVIEW_DEFECT, &CReveiwHistoryDlg::OnClickedChkReviewDefect)
 	ON_BN_CLICKED(IDC_CHK_SINGLE, &CReveiwHistoryDlg::OnClickedChkSingle)
 	ON_EN_CHANGE(IDC_EDIT_FILE_COUNT, &CReveiwHistoryDlg::OnChangeEditFileCount)
+	ON_WM_KEYDOWN()
 END_MESSAGE_MAP()
 
 // CReveiwHistoryDlg 硫붿떆吏� 泥섎━湲�
@@ -279,7 +295,15 @@
 // 			// 洹몃┝�쓣 Picture Control �겕湲곕줈 �솕硫댁뿉 異쒕젰�븳�떎.
 // 			m_ReviewImage.Draw(dc, m_picture_rect);
 // 		}
-		if (!m_DefectImage.IsNull())
+		//LYW 20210825 #3486 ADD START
+		if (!m_DefectRotateImage.IsNull())
+		{
+			dc.SetStretchBltMode(COLORONCOLOR);
+			// 洹몃┝�쓣 Picture Control �겕湲곕줈 �솕硫댁뿉 異쒕젰�븳�떎.
+			m_DefectRotateImage.Draw(dc, m_picture_rect2);
+		}
+		//LYW 20210825 #3486 ADD END
+		else if (!m_DefectImage.IsNull())
 		{
 			dc.SetStretchBltMode(COLORONCOLOR);
 			// 洹몃┝�쓣 Picture Control �겕湲곕줈 �솕硫댁뿉 異쒕젰�븳�떎.
@@ -730,7 +754,7 @@
 
 			return TRUE;
 		}
-		else if (NM_CLICK == pDispInfo->hdr.code)
+		else if (NM_CLICK == pDispInfo->hdr.code || LVN_ITEMCHANGING == pDispInfo->hdr.code)
 		{
 			if (pDispInfo->item.row == 0)
 			{
@@ -856,7 +880,7 @@
 
 			return TRUE;
 		}
-		else if (NM_CLICK == pDispInfo->hdr.code)
+		else if (NM_CLICK == pDispInfo->hdr.code || LVN_ITEMCHANGING == pDispInfo->hdr.code)
 		{
 			if (pDispInfo->item.row == 0)
 			{
@@ -1210,6 +1234,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)
 {
@@ -1968,6 +2047,9 @@
 
 	m_DefectImage.Destroy();
 	m_ReviewImage.Destroy();
+	//LYW 20210825 #3486 ADD START
+	m_DefectRotateImage.Destroy();
+	//LYW 20210825 #3486 ADD END
 
 	m_AlignFirst.Destroy();
 	m_AlignSecend.Destroy();
@@ -2010,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;
@@ -2055,7 +2144,7 @@
 	DeftectPath.Format(_T("%s\\%s\\%s"), strReviewPath, strReviewImagePath, strReviewImageName);
 	//DeftectPath2.Format(_T("%s\\%s"), strInspectorPath, strInspectorName);
 	if (strInspectorName == "*" || strInspectorName == "**" || strInspectorName == "***") strInspectorName = "";
-	DeftectPath2.Format(_T("%s\\%s\\%s"), strInspectorPath, pImageInfo->m_strGlassID, strReviewImageName);
+	DeftectPath2.Format(_T("%s\\%s\\%s"), strInspectorPath, pImageInfo->m_strGlassID, strInspectorName);
 
 	AlignPath.Format(_T("%s\\%s\\%s"), strAlignPath, pImageInfo->m_strGlassID, strAlignName);
 	AlignPath2.Format(_T("%s\\%s\\%s"), strAlignPath, pImageInfo->m_strGlassID, strAlignName2);
@@ -2096,13 +2185,21 @@
 	if (CFile::GetStatus(DeftectPath2, FileOn) && strInspectorName != "") //�뙆�씪�씠 �엳�쓣 �븣
 	{
 		m_DefectImage.Load(DeftectPath2);
+		//LYW 20210825 #3486 ADD START
+		m_DefectRotateImage.Create(m_DefectImage.GetWidth(), m_DefectImage.GetHeight(), m_DefectImage.GetBPP(), 0);
+		ImageRotate(m_DefectImage, m_DefectRotateImage);
+		//LYW 20210825 #3486 ADD END
 		HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), DeftectPath2,
 			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
 
 
 		InvalidateRect(m_picture_rect2, FALSE);
 		dc.SetStretchBltMode(COLORONCOLOR);
-		m_DefectImage.Draw(dc, m_picture_rect2);
+		//LYW 20210825 #3486 MOD START
+		m_DefectRotateImage.Draw(dc, m_picture_rect2);
+		//LYW 20210825 #3486 MOD END
+		//original
+		//m_DefectImage.Draw(dc, m_picture_rect2);
 	}
 	else
 	{
@@ -2490,6 +2587,9 @@
 
 //	m_ReviewImage.Destroy();
 	m_DefectImage.Destroy();
+	//LYW 20210825 #3486 ADD START
+	m_DefectRotateImage.Destroy();
+	//LYW 20210825 #3486 ADD END
 	m_AlignFirst.Destroy();
 	m_AlignSecend.Destroy();
 
@@ -2526,6 +2626,48 @@
 	m_AlignFirst.Draw(dc, m_Align_rect);
 	m_AlignSecend.Draw(dc, m_Align_rect2);
 }
+
+//LYW 20210825 #3486 ADD START
+void CReveiwHistoryDlg::ImageRotate(CImage & SrcImage, CImage & DstImage, double degree/* = 180.0 */)
+{
+	int Height = SrcImage.GetHeight(); // �꽭濡� 湲몄씠 ���옣
+	int Width = SrcImage.GetWidth(); // 媛�濡� 湲몄씠 ���옣
+	int new_x, new_y;
+	int R, G, B;
+	int center_x = (SrcImage.GetWidth() / 2); // �쉶�쟾 以묒떖�젏
+	int center_y = (SrcImage.GetHeight() / 2); // �쉶�쟾 以묒떖�젏
+
+	double seta = 3.14 / (180.0 / degree); // �씪�뵒�븞
+	double CosSeta = cos(seta);
+	double SinSeta = sin(seta);
+
+	for (int y = 0; y < Height; y++)
+	{
+		for (int x = 0; x < Width; x++)
+		{
+			new_x = (int)((x - center_x) * CosSeta - (y - center_y) * SinSeta + center_x);
+			new_y = (int)((x - center_x) * SinSeta + (y - center_y) * CosSeta + center_y);
+
+			if ((new_x < 0) || (new_x > Width) || (new_y < 0) || (new_y > Height))
+				//�씠誘몄� 踰붿쐞瑜� 踰쀬뼱�굹硫� 0 媛�
+			{
+				R = 0;
+				G = 0;
+				B = 0;
+			}
+			else
+			{
+				R = GetRValue(SrcImage.GetPixel(new_x, new_y));
+				G = GetGValue(SrcImage.GetPixel(new_x, new_y));
+				B = GetBValue(SrcImage.GetPixel(new_x, new_y));
+			}
+			DstImage.SetPixel((int)x, (int)y, RGB(R, G, B));
+			new_x = 0; new_y = 0;
+		}
+	}
+
+}
+//LYW 20210825 #3486 ADD END
 
 void CReveiwHistoryDlg::OnChangeEditFileCount()
 {
@@ -3764,3 +3906,11 @@
 	}
 	m_Formation.m_vecHeaderTemp.clear();
 }
+
+
+void CReveiwHistoryDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+	// TODO: �뿬湲곗뿉 硫붿떆吏� 泥섎━湲� 肄붾뱶瑜� 異붽� 諛�/�삉�뒗 湲곕낯媛믪쓣 �샇異쒗빀�땲�떎.
+
+	CDialogEx::OnKeyDown(nChar, nRepCnt, nFlags);
+}

--
Gitblit v1.9.3