// FrameImg.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù.
|
//
|
|
#include "stdafx.h"
|
#include "FrameImg.h"
|
#include <math.h>
|
#include "Mainfrm.h"
|
#include "PixelPtr.h"
|
#include "ENRIT.h"
|
|
const TCHAR *PANEL_SIDE_NAME[] = {_T("A_TOP"), _T("B_TOP"), _T("C_TOP"), _T("D_TOP"),_T("A_BOT"), _T("B_BOT"), _T("C_BOT"), _T("D_BOT")};
|
|
// CFrameImg
|
IMPLEMENT_DYNAMIC(CFrameImg, CStatic)
|
|
CFrameImg::CFrameImg()
|
{
|
m_pI2M = NULL;
|
m_pHardware = NULL;
|
m_pRecipe = NULL;
|
m_pGlassData = NULL;
|
m_bVCRDraw = TRUE;
|
m_Wnd_Event = NULL;
|
m_nCam = 0;
|
m_nSide = 0;
|
|
m_dZoom = 1;
|
|
m_pBuffer = NULL;
|
m_szTotBuffer = CSize(0,0);
|
m_szImg.cx = IMAGE_WIDTH;
|
m_szImg.cy = IMAGE_HEIGHT;
|
m_ptOrg.x = 0;
|
m_ptOrg.y = 0;
|
|
m_bModify = 0;
|
m_nModeTracker = 0;
|
|
m_szMark.cx = 50;
|
m_szMark.cy = 50;
|
|
|
m_pTracker = NULL;
|
m_pBmInfo = NULL;
|
m_ptMouseSaved.x = 0;
|
m_ptMouseSaved.y = 0;
|
ZeroMemory(&m_ManualMeausre,sizeof(MANUAL_MEASURE));
|
|
m_rcROI = CRect(0,0,m_szImg.cx,m_szImg.cy);
|
|
m_sideFont.CreateFont(25 , 15, 0, 0, 900 , FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN,_T("Arial"));
|
|
|
int x;
|
RGBQUAD ColorTable[256];
|
for(x=0; x<256; x++)
|
{
|
ColorTable[x].rgbBlue = ColorTable[x].rgbGreen = ColorTable[x].rgbRed = x;
|
}
|
m_ImageMagnify.Create(120,120,8);
|
m_ImageMagnify.SetColorTable(0,256,ColorTable);
|
|
m_bitModeDisplay.set(MODE_SHOW_MEASURE_LINE);
|
m_bitModeDisplay.set(MODE_SHOW_REF_LINE);
|
m_bitModeDisplay.set(MODE_SHOW_SUB_LINE);
|
|
m_refMark.rc = CRect(0,0,50,50);
|
|
m_pCompareArea = nullptr;
|
|
m_st_GdiItem.colorWhite = RGB(255, 255, 255);
|
m_st_GdiItem.colorRed = RGB(170, 0, 0);
|
m_st_GdiItem.colorGreen = RGB( 0, 150, 0);
|
m_st_GdiItem.colorBlue = RGB( 0, 0, 180);
|
m_st_GdiItem.colorBlack = RGB( 1, 1, 1);
|
m_st_GdiItem.colorViolet = RGB(150, 0, 150);
|
m_st_GdiItem.colorLightRed = RGB(230, 200, 200);
|
m_st_GdiItem.colorLightBlue = RGB(200, 200, 230);
|
m_st_GdiItem.colorLightGreen = RGB(200, 230, 230);
|
m_st_GdiItem.colorLightGray = RGB(210, 210, 210);
|
m_st_GdiItem.colorDarkGray = RGB( 80, 80, 80);
|
m_st_GdiItem.colorGray = RGB(110, 110, 110);
|
m_st_GdiItem.colorLightYellow = RGB(250, 250, 0);
|
m_st_GdiItem.colorYellow = RGB(180, 180, 0);
|
m_st_GdiItem.colorTitle = RGB(180, 180, 180);
|
m_st_GdiItem.colorOrange = RGB(250, 150, 0);
|
|
m_bMouseLDown = FALSE;
|
|
m_nBrushGray = 5;
|
}
|
|
CFrameImg::~CFrameImg()
|
{
|
if(m_pBmInfo)
|
free(m_pBmInfo);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CFrameImg, CStatic)
|
ON_WM_PAINT()
|
ON_WM_DESTROY()
|
ON_COMMAND(ID_PROFILE_CHECKALL , &CFrameImg::OnProfileCheckall)
|
ON_COMMAND(ID_PROFILE_CLEARALL , &CFrameImg::OnProfileClearall)
|
ON_COMMAND(ID_PROFILE_CURRENTX , &CFrameImg::OnProfileCurrentx)
|
ON_COMMAND(ID_PROFILE_CURRENTY , &CFrameImg::OnProfileCurrenty)
|
ON_COMMAND(ID_PROFILE_SAVEDX , &CFrameImg::OnProfileSavedx)
|
ON_COMMAND(ID_PROFILE_SAVEDY , &CFrameImg::OnProfileSavedy)
|
ON_COMMAND(ID_PROFILE_PROJECTIONX , &CFrameImg::OnProfileProjectionx)
|
ON_COMMAND(ID_PROFILE_PROJECTIONY , &CFrameImg::OnProfileProjectiony)
|
ON_WM_CONTEXTMENU()
|
ON_WM_MOUSEMOVE()
|
ON_COMMAND(ID_MEASURE_CHECKALL , &CFrameImg::OnMeasureCheckall)
|
ON_COMMAND(ID_MEASURE_CLEARALL , &CFrameImg::OnMeasureClearall)
|
ON_COMMAND(ID_MEASURE_DISTANCEX , &CFrameImg::OnMeasureDistancex)
|
ON_COMMAND(ID_MEASURE_DISTANCEY , &CFrameImg::OnMeasureDistancey)
|
|
ON_COMMAND(ID_VIEW_CHECKALL , &CFrameImg::OnViewCheckall)
|
ON_COMMAND(ID_VIEW_CLEARALL , &CFrameImg::OnViewClearall)
|
ON_COMMAND(ID_VIEW_SHOW_MEASURE_LINE, &CFrameImg::OnViewShowMeasureLine)
|
ON_COMMAND(ID_VIEW_SHOW_REF_LINE , &CFrameImg::OnViewShowRefLine)
|
ON_COMMAND(ID_IMGMODIFY_DRAWBRUSH , &CFrameImg::OnImgmodifyDrawbrush)
|
|
//ON_COMMAND(ID_IMAGE_MANIFY, &CFrameImg::OnImageManify)
|
|
|
|
|
ON_WM_CREATE()
|
ON_WM_LBUTTONDOWN()
|
ON_WM_LBUTTONUP()
|
ON_WM_MOUSEACTIVATE()
|
|
//ON_MESSAGE(WM_FILTER_ITEM_SELECT_CHANGE, OnSelectExeptionItem)
|
|
|
END_MESSAGE_MAP()
|
|
|
// CFrameImg ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù.
|
|
|
int CFrameImg::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
{
|
if (CWnd::OnCreate(lpCreateStruct) == -1)
|
return -1;
|
|
GetClientRect(m_WndRect);
|
|
|
/*
|
CDC *pDC = GetDC();
|
m_memDC.CreateCompatibleDC(pDC);
|
// m_Bitmap.CreateCompatibleBitmap(pDC,m_szImg.cx,m_szImg.cy);
|
|
ReleaseDC(pDC);
|
|
*/
|
return 0;
|
}
|
|
void CFrameImg::ChangeRect()
|
{
|
GetClientRect(m_WndRect);
|
}
|
|
CSize CFrameImg::GetScanBufSize(int iSide)
|
{
|
if(m_pHardware == NULL)
|
return CSize(0,0);
|
|
int iCam = m_pHardware->GetCameraIndexToDimension((DimensionDir)iSide);
|
if(iCam < 0)
|
return CSize(0,0);
|
|
CSize szImg(0,0);
|
|
szImg.cy = g_pBase->m_pMemFrameNo[iCam];
|
szImg.cx = g_pBase->m_pFrameWidth[iCam];
|
|
return szImg;
|
}
|
|
void CFrameImg::InitBitMap()
|
{
|
int i=0;
|
m_pBmInfo = (BITMAPINFO*)malloc(sizeof(BITMAPINFO)+256*sizeof(RGBQUAD));
|
m_pBmInfo->bmiHeader.biBitCount = 8;
|
m_pBmInfo->bmiHeader.biClrImportant = 256;
|
m_pBmInfo->bmiHeader.biClrUsed = 256;
|
m_pBmInfo->bmiHeader.biCompression = BI_RGB;
|
m_pBmInfo->bmiHeader.biHeight = -m_szImg.cy;
|
m_pBmInfo->bmiHeader.biPlanes = 1;
|
m_pBmInfo->bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
|
m_pBmInfo->bmiHeader.biSizeImage = m_szImg.cx * m_szImg.cy;
|
m_pBmInfo->bmiHeader.biWidth = m_szImg.cx;
|
m_pBmInfo->bmiHeader.biXPelsPerMeter=0;
|
m_pBmInfo->bmiHeader.biYPelsPerMeter=0;
|
for(i=0; i<256; i++) // Palette number is 256
|
{
|
m_pBmInfo->bmiColors[i].rgbRed= m_pBmInfo->bmiColors[i].rgbGreen = m_pBmInfo->bmiColors[i].rgbBlue = i;
|
m_pBmInfo->bmiColors[i].rgbReserved = 0;
|
}
|
|
}
|
|
void CFrameImg::OnDestroy()
|
{
|
CWnd::OnDestroy();
|
if(m_pBmInfo)
|
{
|
free(m_pBmInfo);
|
m_pBmInfo = NULL;
|
}
|
// m_memDC.DeleteDC();
|
// m_Bitmap.DeleteObject();
|
m_sideFont.DeleteObject();
|
}
|
|
|
void CFrameImg::SetMode(int nMode)
|
{
|
if(nMode == MODE_MARK_REG)
|
{
|
m_refMark.rc.left = m_ptOrg.x + m_WndRect.Width()/2 - 50;
|
m_refMark.rc.top = m_ptOrg.y + m_WndRect.Height()/2 - 50;
|
m_refMark.rc.right = m_refMark.rc.left + 50;
|
m_refMark.rc.bottom = m_refMark.rc.top + 50;
|
|
|
m_pTracker = &m_refMark;
|
}
|
else if((nMode == MODE_COMPARE_PANEL) || (nMode == MODE_USER_DEFECT_AREA))
|
{
|
if(m_pCompareArea == nullptr)
|
m_pCompareArea = new EXECPTION_AREA;
|
|
m_pCompareArea->rc.left = m_ptOrg.x + (m_WndRect.Width() / 2);
|
m_pCompareArea->rc.top = m_ptOrg.y + (m_WndRect.Height() / 2);
|
m_pCompareArea->rc.right = m_pCompareArea->rc.left + 100;
|
m_pCompareArea->rc.bottom = m_pCompareArea->rc.top + 100;
|
}
|
m_bitModeDisplay.set(nMode);
|
}
|
|
void CFrameImg::ResetMode(int nMode)
|
{
|
if(nMode == MODE_MARK_REG)
|
{
|
m_pTracker = NULL;
|
}
|
else if(((nMode == MODE_COMPARE_PANEL) || (nMode == MODE_USER_DEFECT_AREA)) && (m_pCompareArea != nullptr))
|
{
|
delete m_pCompareArea;
|
m_pCompareArea = nullptr;
|
}
|
|
m_bitModeDisplay.reset(nMode);
|
}
|
|
BOOL CFrameImg::GetMode(int nMode)
|
{
|
return m_bitModeDisplay[nMode];
|
}
|
|
void CFrameImg::OnProfileCheckall()
|
{
|
SetMode(MODE_PROFILE_X);
|
SetMode(MODE_PROFILE_Y);
|
SetMode(MODE_PROJECTION_X);
|
SetMode(MODE_PROJECTION_Y);
|
|
SetMode(MODE_SAVED_X);
|
SetMode(MODE_SAVED_Y);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnProfileClearall()
|
{
|
ResetMode(MODE_PROFILE_X);
|
ResetMode(MODE_PROFILE_Y);
|
ResetMode(MODE_PROJECTION_X);
|
ResetMode(MODE_PROJECTION_Y);
|
|
ResetMode(MODE_SAVED_X);
|
ResetMode(MODE_SAVED_Y);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnProfileCurrentx()
|
{
|
m_bitModeDisplay[MODE_PROFILE_X] ? ResetMode(MODE_PROFILE_X) : SetMode(MODE_PROFILE_X);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnProfileCurrenty()
|
{
|
m_bitModeDisplay[MODE_PROFILE_Y] ? ResetMode(MODE_PROFILE_Y) : SetMode(MODE_PROFILE_Y);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnProfileProjectionx()
|
{
|
m_bitModeDisplay[MODE_PROJECTION_X] ? ResetMode(MODE_PROJECTION_X) : SetMode(MODE_PROJECTION_X);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnProfileProjectiony()
|
{
|
m_bitModeDisplay[MODE_PROJECTION_Y] ? ResetMode(MODE_PROJECTION_Y) : SetMode(MODE_PROJECTION_Y);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnProfileSavedx()
|
{
|
m_bitModeDisplay[MODE_SAVED_X] ? ResetMode(MODE_SAVED_X) : SetMode(MODE_SAVED_X);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnProfileSavedy()
|
{
|
m_bitModeDisplay[MODE_SAVED_Y] ? ResetMode(MODE_SAVED_Y) : SetMode(MODE_SAVED_Y);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnMeasureCheckall()
|
{
|
SetMode(MODE_DISTANCE_X);
|
SetMode(MODE_DISTANCE_Y);
|
SetMode(MODE_DIAGONAL);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnMeasureClearall()
|
{
|
ResetMode(MODE_DISTANCE_X);
|
ResetMode(MODE_DISTANCE_Y);
|
ResetMode(MODE_DIAGONAL);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnMeasureDistancex()
|
{
|
m_bitModeDisplay[MODE_DISTANCE_X] ? ResetMode(MODE_DISTANCE_X) : SetMode(MODE_DISTANCE_X);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnMeasureDistancey()
|
{
|
m_bitModeDisplay[MODE_DISTANCE_Y] ? ResetMode(MODE_DISTANCE_Y) : SetMode(MODE_DISTANCE_Y);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnMeasureDiagonal()
|
{
|
m_bitModeDisplay[MODE_DIAGONAL] ? ResetMode(MODE_DIAGONAL) : SetMode(MODE_DIAGONAL);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnImageManify()
|
{
|
m_bitModeDisplay[MODE_MANIFY] ? ResetMode(MODE_MANIFY) : SetMode(MODE_MANIFY);
|
Invalidate(FALSE);
|
}
|
|
|
void CFrameImg::OnViewCheckall()
|
{
|
SetMode(MODE_SHOW_MEASURE_LINE);
|
SetMode(MODE_SHOW_REF_LINE);
|
SetMode(MODE_SHOW_SUB_LINE);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnViewClearall()
|
{
|
ResetMode(MODE_SHOW_MEASURE_LINE);
|
ResetMode(MODE_SHOW_REF_LINE);
|
ResetMode(MODE_SHOW_SUB_LINE);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnViewShowMeasureLine()
|
{
|
m_bitModeDisplay[MODE_SHOW_MEASURE_LINE] ? ResetMode(MODE_SHOW_MEASURE_LINE) : SetMode(MODE_SHOW_MEASURE_LINE);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnViewShowRefLine()
|
{
|
m_bitModeDisplay[MODE_SHOW_REF_LINE] ? ResetMode(MODE_SHOW_REF_LINE) : SetMode(MODE_SHOW_REF_LINE);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnViewShowSubLine()
|
{
|
m_bitModeDisplay[MODE_SHOW_SUB_LINE] ? ResetMode(MODE_SHOW_SUB_LINE) : SetMode(MODE_SHOW_SUB_LINE);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::OnImgmodifyDrawbrush()
|
{
|
m_bitModeDisplay[MODE_MODIFY_BRUSH] ? ResetMode(MODE_MODIFY_BRUSH) : SetMode(MODE_MODIFY_BRUSH);
|
Invalidate(FALSE);
|
}
|
|
void CFrameImg::DrawMagnify(CDC &dc)
|
{
|
CPoint pt;
|
|
|
pt.x = m_ptOrg.x + int(m_ptMouseCurrent.x / m_dZoom);
|
pt.y = int(m_ptMouseCurrent.y / m_dZoom);
|
|
if(pt.y < 8) pt.y = 8;
|
if(pt.x < 8) pt.x = 8;
|
|
if(pt.y > m_szImg.cy -50) pt.y = m_szImg.cy - 50;
|
if(pt.x > m_szImg.cx - 50) pt.x = m_szImg.cx - 50;
|
|
CPixelPtr des(m_ImageMagnify);
|
for( int i=pt.y-7; i<pt.y+8; i++ )
|
{
|
for( int j=pt.x-7; j<pt.x+8; j++ )
|
{
|
for( int k=0; k<8; k++ )
|
{
|
for( int l=0; l<8; l++ )
|
{
|
des[((i-(pt.y-7))<<3) +k][((j-(pt.x-7))<<3)+l] = m_pBuffer[i * m_szImg.cx+ j];
|
}
|
}
|
}
|
}
|
|
|
m_ImageMagnify.Draw(dc.GetSafeHdc(),m_ptMouseCurrent.x - 60,m_ptMouseCurrent.y - 60,120,120);
|
CString strTmp;
|
strTmp.Format(_T("%d[x:%d,y:%d]"),m_pBuffer[pt.y * m_szImg.cx + pt.x],pt.x + m_ptOrg.x,pt.y + m_ptOrg.y);
|
dc.TextOut(m_ptMouseCurrent.x - 60 ,m_ptMouseCurrent.y - 60,strTmp);
|
|
/*
|
grp.DrawLine(&m_penRef,pt.x - 60 ,m_ptCur.y ,pt.x + 60 ,m_ptCur.y);
|
grp.DrawLine(&m_penRef,m_ptCur.x ,pt.y - 60 ,m_ptCur.x ,pt.y + 60);
|
|
|
WCHAR wStr[MAX_PATH];
|
FontFamily fontFamily(L"±¼¸²Ã¼");
|
Font font(&fontFamily,11, FontStyleBold );
|
|
swprintf(wStr, L"%d[%d,%d]",m_Image.GetPixel(m_ptCur.x + m_nScrStartX,m_ptCur.y) & 0xff,m_ptCur.x + m_nScrStartX,m_ptCur.y);
|
|
if(m_ptCur.y -10 > 0)
|
grp.DrawString(wStr,-1,&font,PointF((REAL)m_ptCur.x ,(REAL)m_ptCur.y-10),&m_strBrush);
|
else
|
grp.DrawString(wStr,-1,&font,PointF((REAL)m_ptCur.x ,(REAL)m_ptCur.y),&m_strBrush);
|
*/
|
}
|
|
|
void CFrameImg::DrawProfileSaved(CDC &dc ,int nMode, CPoint pt)
|
{
|
int x, y;
|
|
CPen penX(PS_SOLID, 1, RGB(255,255,255));
|
CPen penY(PS_SOLID, 1, RGB(255,255,0));
|
CPen *pOldPen;
|
SIZE szROIProfile;
|
|
//dc.SetROP2(R2_NOTMERGEPEN);
|
pOldPen = (CPen*)dc.SelectObject(&penX);
|
int data1,data2;
|
int nProjectionCnt = 1;
|
|
|
if(nMode == 2 || nMode == 3)
|
{
|
nProjectionCnt = 64;
|
}
|
|
|
|
szROIProfile.cx = CHKMIN(int(m_WndRect.Width() / m_dZoom), m_szImg.cx);
|
szROIProfile.cy = int(m_WndRect.Height() / m_dZoom);
|
|
|
if(nMode == 0 || nMode == 2)
|
{
|
dc.MoveTo(0 ,pt.y);
|
dc.LineTo(m_WndRect.Width() ,pt.y);
|
|
for( x = m_ptOrg.x ; x < m_ptOrg.x + szROIProfile.cx;x++)
|
{
|
data1 = 0;
|
data2 = 0;
|
for( y = pt.y - m_ptOrg.y ; y < pt.y - m_ptOrg.y + nProjectionCnt;y++)
|
{
|
data1 += m_pBuffer[(y) * m_szImg.cx + x -1];
|
data2 += m_pBuffer[(y) * m_szImg.cx + x ];
|
}
|
data1 /= nProjectionCnt;
|
data2 /= nProjectionCnt;
|
|
dc.MoveTo(int((x-1 - m_ptOrg.x)* m_dZoom),data1);
|
dc.LineTo(int((x - m_ptOrg.x)* m_dZoom),data2);
|
}
|
}
|
else if(nMode == 1 || nMode == 3)
|
{
|
dc.SelectObject(&penY);
|
|
if(nMode == 3)
|
{
|
if(pt.x > m_szImg.cx -10)
|
{
|
pt.x = m_szImg.cx -10;
|
}
|
}
|
if(pt.x > 0 && pt.x < m_WndRect.Width())
|
{
|
dc.MoveTo(pt.x , 0);
|
dc.LineTo(pt.x , m_WndRect.Height());
|
|
int nMaxX = m_ptOrg.x + pt.x + nProjectionCnt;
|
for( y = 1 ; y < szROIProfile.cy;y++)
|
{
|
data1 = 0;
|
data2 = 0;
|
for( x = m_ptOrg.x + pt.x ; x < nMaxX ;x++)
|
{
|
data1 += m_pBuffer[int((y -1) * m_szImg.cx + (x / m_dZoom))];
|
data2 += m_pBuffer[int((y ) * m_szImg.cx + (x / m_dZoom))];
|
}
|
|
data1 /= nProjectionCnt;
|
data2 /= nProjectionCnt;
|
|
dc.MoveTo(data1 , int((y -1) * m_dZoom));
|
dc.LineTo(data2 , int(y * m_dZoom));
|
}// for
|
}//if
|
}
|
|
dc.SelectObject(pOldPen);
|
dc.SetROP2(R2_COPYPEN);
|
}
|
|
|
void CFrameImg::DrawProfile(CDC &dc ,int nMode, CPoint pt)
|
{
|
int x, y;
|
CPen penX(PS_SOLID, 1, RGB(0,255,255));
|
CPen penY(PS_SOLID, 1, RGB(255,255,0));
|
CPen *pOldPen;
|
SIZE szROIProfile;
|
|
dc.SetROP2(R2_NOTMERGEPEN);
|
pOldPen = (CPen*)dc.SelectObject(&penX);
|
int data1,data2;
|
int nProjectionCnt = 1;
|
|
|
if(nMode == 2 || nMode == 3)
|
{
|
nProjectionCnt = 64;
|
}
|
|
|
szROIProfile.cx = CHKMIN(int(m_WndRect.Width() / m_dZoom), m_szImg.cx);
|
szROIProfile.cy = int(m_WndRect.Height() / m_dZoom);
|
|
if(nMode == 0 || nMode == 2)
|
{
|
if(pt.y > 0 && pt.y < m_WndRect.Height())
|
{
|
|
dc.MoveTo(0 ,pt.y);
|
dc.LineTo(m_WndRect.Width() ,pt.y);
|
|
for( x = m_ptOrg.x ; x < m_ptOrg.x + szROIProfile.cx;x++)
|
{
|
data1 = 0;
|
data2 = 0;
|
for( y = pt.y ; y < pt.y + nProjectionCnt;y++)
|
{
|
data1 += m_pBuffer[int(y / m_dZoom + 0.5) * m_szImg.cx + x -1];
|
data2 += m_pBuffer[int(y / m_dZoom + 0.5) * m_szImg.cx + x ];
|
}
|
data1 /= nProjectionCnt;
|
data2 /= nProjectionCnt;
|
|
dc.MoveTo(int((x-1 - m_ptOrg.x)* m_dZoom +0.5),data1);
|
dc.LineTo(int((x - m_ptOrg.x)* m_dZoom +0.5),data2);
|
}
|
}
|
}
|
else if(nMode == 1 || nMode == 3)
|
{
|
dc.SelectObject(&penY);
|
|
if(nMode == 3)
|
{
|
if(pt.x > m_szImg.cx -10)
|
{
|
pt.x = m_szImg.cx -10;
|
}
|
}
|
if(pt.x > 0 && pt.x < m_WndRect.Width())
|
{
|
dc.MoveTo(pt.x , 0);
|
dc.LineTo(pt.x , m_WndRect.Height());
|
|
|
int nMaxX = m_ptOrg.x + pt.x + nProjectionCnt;
|
for( y = 1 ; y < szROIProfile.cy;y++)
|
{
|
|
|
data1 = 0;
|
data2 = 0;
|
for( x = m_ptOrg.x + pt.x ; x < nMaxX ;x++)
|
{
|
data1 += m_pBuffer[int((y -1) * m_szImg.cx + (x / m_dZoom))];
|
data2 += m_pBuffer[int((y ) * m_szImg.cx + (x / m_dZoom))];
|
}
|
|
data1 /= nProjectionCnt;
|
data2 /= nProjectionCnt;
|
|
dc.MoveTo(data1 , int((y -1) * m_dZoom));
|
dc.LineTo(data2 , int(y * m_dZoom));
|
}// for
|
}//if
|
}
|
|
dc.SelectObject(pOldPen);
|
dc.SetROP2(R2_COPYPEN);
|
}
|
|
CRect CFrameImg::GetCompareRect(void)
|
{
|
if(m_pCompareArea != nullptr)
|
return m_pCompareArea->rc;
|
else
|
return CRect(0,0,0,0);
|
}
|
|
void CFrameImg::ConvertOrgToScreen(CPoint pt,CPoint &det)
|
{
|
|
}
|
|
void CFrameImg::DrawManualMeasure(CDC &dc)
|
{
|
|
CPen penX(PS_SOLID, 1, RGB(0,255,255));
|
CPen penY(PS_SOLID, 1, RGB(255,255,0));
|
CPen *pOldPen;
|
CBrush *pOldBruh;
|
|
|
//dc.SetROP2(R2_NOT);
|
pOldPen = (CPen*)dc.SelectObject(&penX);
|
pOldBruh = (CBrush*)dc.SelectObject(&m_st_GdiItem.brushRed);
|
|
|
CPoint ptStart;
|
CPoint ptEnd;
|
|
ptStart.x = int((m_ManualMeausre.ptMeasureStart.x - m_ptOrg.x) * m_dZoom);
|
ptStart.y = int((m_ManualMeausre.ptMeasureStart.y - m_ptOrg.y) * m_dZoom);
|
|
ptEnd.x = int((m_ManualMeausre.ptMeasureEnd.x - m_ptOrg.x) * m_dZoom);
|
ptEnd.y = int((m_ManualMeausre.ptMeasureEnd.y - m_ptOrg.y) * m_dZoom);
|
|
dc.MoveTo(0 , ptStart.y);
|
dc.LineTo(m_WndRect.Width() , ptStart.y);
|
dc.MoveTo(ptStart.x , 0);
|
dc.LineTo(ptStart.x , m_WndRect.Height());
|
|
dc.MoveTo(0 , ptEnd.y);
|
dc.LineTo(m_WndRect.Width() , ptEnd.y);
|
dc.MoveTo(ptEnd.x , 0);
|
dc.LineTo(ptEnd.x , m_WndRect.Height());
|
|
|
(CPen*)dc.SelectObject(&penY);
|
dc.MoveTo(ptStart.x , ptStart.y);
|
dc.LineTo(ptEnd.x , ptEnd.y);
|
|
dc.MoveTo(ptStart.x - 5,
|
ptStart.y - 5);
|
|
dc.LineTo(ptStart.x + 5,
|
ptStart.y + 5);
|
|
dc.MoveTo(ptStart.x + 5,
|
ptStart.y - 5);
|
|
dc.LineTo(ptStart.x - 5,
|
ptStart.y + 5);
|
|
|
dc.MoveTo(ptEnd.x - 5,
|
ptEnd.y - 5);
|
|
dc.LineTo(ptEnd.x + 5,
|
ptEnd.y + 5);
|
|
|
dc.MoveTo(ptEnd.x + 5,
|
ptEnd.y - 5);
|
|
dc.LineTo(ptEnd.x - 5,
|
ptEnd.y + 5);
|
|
|
|
|
//dc.SetBkMode(OPAQUE);
|
CString strTmp;
|
int nTmp;
|
CRect rc;
|
double dPosX,dPosY;
|
|
rc.top = m_ManualMeausre.ptMeasureStart.y;
|
rc.bottom = m_ManualMeausre.ptMeasureStart.y + 20;
|
rc.left = m_ManualMeausre.ptMeasureStart.x;
|
rc.right = m_ManualMeausre.ptMeasureStart.x + 20;
|
|
if(m_ManualMeausre.bModifyStart)
|
m_ManualMeausre.nTextPos = 0;
|
else if(m_ManualMeausre.bModifyEnd || m_ManualMeausre.bStart)
|
m_ManualMeausre.nTextPos = 1;
|
else;
|
|
|
CPoint ptText;
|
const int TextsizeX = 150;
|
const int TextsizeY = 50;
|
|
|
|
|
if(m_ManualMeausre.nTextPos == 0)
|
{
|
if(ptStart.x > m_WndRect.Width()/2)
|
ptText.x = ptStart.x - TextsizeX;
|
else
|
ptText.x = ptStart.x + 5;
|
|
if(ptStart.y > m_WndRect.Height()/2)
|
ptText.y =ptStart.y - TextsizeY;
|
else
|
ptText.y = ptStart.y + 5;
|
|
}
|
else
|
{
|
if(ptEnd.x > m_WndRect.Width()/2)
|
ptText.x = ptEnd.x - TextsizeX;
|
else
|
ptText.x = ptEnd.x + 5;
|
|
if(ptEnd.y > m_WndRect.Height()/2)
|
ptText.y = ptEnd.y - TextsizeY;
|
else
|
ptText.y = ptEnd.y + 5;
|
}
|
|
dc.SetBkMode(TRANSPARENT);
|
dc.SetTextColor(RGB(255,0,0));
|
|
nTmp = abs(m_ManualMeausre.ptMeasureStart.x - m_ManualMeausre.ptMeasureEnd.x);
|
|
double dResH,dResV;
|
|
GetResolution(dResH,dResV);
|
|
dPosX = dResH * nTmp/1000.0;
|
strTmp.Format(_T("X : %4.3f mm [%d pixel]"), dPosX , nTmp);
|
dc.TextOut( ptText.x + 5, ptText.y,strTmp);
|
|
|
dc.SetTextColor(RGB(255,60,160));
|
nTmp = abs(m_ManualMeausre.ptMeasureStart.y - m_ManualMeausre.ptMeasureEnd.y);
|
|
|
dPosY = dResV * nTmp/1000.0;
|
strTmp.Format(_T("Y : %4.3f mm [%d pixel]"),dPosY, nTmp);
|
dc.TextOut( ptText.x + 5, ptText.y + 15 ,strTmp);
|
|
|
dc.SetTextColor(RGB(255,0,0));
|
dPosX = sqrtf(float(dPosX *dPosX + dPosY*dPosY));
|
strTmp.Format(_T("D : %4.3f mm "),dPosX);
|
dc.TextOut( ptText.x + 5, ptText.y + 30 ,strTmp);
|
|
dc.SelectObject(pOldBruh);
|
dc.SelectObject(pOldPen);
|
dc.SetROP2(R2_COPYPEN);
|
|
}
|
|
void CFrameImg::GetResolution(double &dH,double &dV)
|
{
|
dH = dV = 0.;
|
|
int nStageNo = g_pBase->m_nStageNo;
|
|
if(nStageNo < 0 || nStageNo > 1)
|
nStageNo = 0;
|
|
if(m_pHardware != NULL)
|
{
|
int iScan = m_pHardware->GetScanToDimension((DimensionDir)m_nSide);
|
CCameraSettings *pCamera = m_pHardware->GetCameraSettings(m_nCam,iScan);
|
if(pCamera != NULL)
|
{
|
dH = pCamera->m_dConvResolution[nStageNo];
|
dV = pCamera->m_dScanResolution[nStageNo];
|
}
|
}
|
|
if(dH <= 0)
|
dH = 1.;
|
if(dV <= 0)
|
dV = 1.;
|
}
|
|
|
void CFrameImg::ViewUpdate(int nOpt /*= 0*/)
|
{
|
if(!IsWindowVisible())
|
return;
|
|
CDC *pDC = GetDC();
|
CDC memDC;
|
CBitmap Bitmap,*pOldBitmap;
|
SIZE bitmapSize;
|
CFont *pOldFont = NULL;
|
|
memDC.CreateCompatibleDC(pDC);
|
Bitmap.CreateCompatibleBitmap(pDC,m_WndRect.Width(),m_WndRect.Height());
|
|
|
bitmapSize.cx = int(m_szImg.cx * m_dZoom);
|
bitmapSize.cy = m_szImg.cy;
|
|
|
|
|
m_pBmInfo->bmiHeader.biWidth = m_szImg.cx;
|
m_pBmInfo->bmiHeader.biHeight = -int(m_WndRect.Height() / m_dZoom);//(m_szImg.cy);
|
m_pBmInfo->bmiHeader.biSizeImage = m_pBmInfo->bmiHeader.biWidth * m_pBmInfo->bmiHeader.biHeight;//m_szImg.cx * (m_szImg.cy / m_dZoom);
|
|
|
|
|
|
memDC.SetStretchBltMode(COLORONCOLOR);
|
|
//Bitmap.CreateCompatibleBitmap(pDC,bitmapSize.cx,bitmapSize.cy);
|
//Bitmap.CreateCompatibleBitmap(pDC,m_WndRect.Width(),m_WndRect.Height());
|
pOldBitmap = (CBitmap*)memDC.SelectObject(&Bitmap);
|
if(m_pBuffer)
|
{
|
// StretchDIBits(m_memDC.m_hDC, 0 , 0, bitmapSize.cx , bitmapSize.cy,
|
// m_ptOrg.x,0,m_pBmInfo->bmiHeader.biWidth,abs(m_pBmInfo->bmiHeader.biHeight),
|
// m_pBuffer,(BITMAPINFO*)m_pBmInfo,DIB_RGB_COLORS,SRCCOPY);
|
|
|
StretchDIBits(memDC.m_hDC, 0 , 0, m_WndRect.Width(),m_WndRect.Height(),
|
m_ptOrg.x,0,int(m_WndRect.Width()/ m_dZoom),int(m_WndRect.Height()/ m_dZoom), //m_WndRect.Width(),m_WndRect.Height(),
|
m_pBuffer,(BITMAPINFO*)m_pBmInfo,DIB_RGB_COLORS,SRCCOPY);
|
}
|
|
if(nOpt == 0 && m_ptOrg.y >= 0)
|
{
|
if(m_bitModeDisplay[MODE_MANIFY])
|
DrawMagnify(memDC);
|
|
if(m_bitModeDisplay[MODE_PROFILE_X])
|
DrawProfile(memDC,0,m_ptMouseCurrent);
|
|
if(m_bitModeDisplay[MODE_PROFILE_Y])
|
DrawProfile(memDC,1,m_ptMouseCurrent);
|
|
if(m_bitModeDisplay[MODE_SAVED_X])
|
DrawProfileSaved(memDC,0,m_ptMouseSaved);
|
|
if(m_bitModeDisplay[MODE_SAVED_Y])
|
DrawProfile(memDC,1,m_ptMouseSaved);
|
|
if(m_bitModeDisplay[MODE_PROJECTION_X])
|
DrawProfile(memDC,2,m_ptMouseCurrent);
|
|
if(m_bitModeDisplay[MODE_PROJECTION_Y])
|
DrawProfile(memDC,3,m_ptMouseCurrent);
|
|
|
if(m_bitModeDisplay[MODE_DISTANCE_X]
|
|| m_bitModeDisplay[MODE_DISTANCE_Y]
|
|| m_bitModeDisplay[MODE_DIAGONAL])
|
DrawManualMeasure(memDC);
|
|
DrawTest(memDC);
|
DrawProcessData(memDC);
|
DrawExpectionAear(memDC);
|
DrawUserDefectArea(memDC);
|
DrawHoleArea(memDC);
|
|
if (m_bitModeDisplay[MODE_SHOW_REF_LINE]) {
|
UpdateView_VisionResult(memDC);
|
UpDateView_MouseDownPos(memDC);
|
}
|
|
|
if(m_bitModeDisplay[MODE_MARK_REG])
|
{
|
Draw_TrakerRect(m_refMark.rc,memDC);
|
}
|
else if(((m_bitModeDisplay[MODE_USER_DEFECT_AREA]) || (m_bitModeDisplay[MODE_COMPARE_PANEL] == true)) && (m_pCompareArea != nullptr))
|
{
|
Draw_CompareRect(m_pCompareArea->rc, memDC);
|
}
|
}
|
|
|
memDC.SetBkMode(TRANSPARENT);
|
memDC.SetTextColor(RGB(0,0,255));
|
//memDC.SetTextColor(RGB(45,200,45));
|
|
CString str;
|
str.Format(_T("%d"),m_ptOrg.y);
|
memDC.TextOut(m_WndRect.Width() - 50, 10, str);
|
|
int nTmp = int((m_ptMouseCurrent.y / m_dZoom) * m_szImg.cx + m_ptOrg.x + (m_ptMouseCurrent.x / m_dZoom));
|
|
int nMaxLine = MAX_LIMIT_LINE * IMAGE_WIDTH;
|
|
if(m_szTotBuffer.cy > 0)
|
{
|
nMaxLine = (m_szTotBuffer.cy-1) * IMAGE_HEIGHT * m_szTotBuffer.cx;
|
}
|
|
|
if(nTmp > -1 && nTmp < nMaxLine && m_ptOrg.y >= 0 && m_ptOrg.x >= 0 && m_pBuffer != NULL)
|
{
|
str.Format(_T("(%d / %d) [%d]"), m_ptOrg.x + int(m_ptMouseCurrent.x / m_dZoom) , m_ptOrg.y + int(m_ptMouseCurrent.y / m_dZoom)
|
, m_pBuffer[nTmp]);
|
memDC.TextOut(10, m_WndRect.Height() - 45, str);
|
|
if ((0 != m_ptMouseDown.x || 0 != m_ptMouseDown.y) && BlVision_GetVisionRecipe()->getVisionSetOpen()) { //Êó±ê¸Ä±ä
|
str.Format(_T("(%d / %d)"), m_ptMouseDown.x, m_ptMouseDown.y);
|
memDC.TextOut(10, m_WndRect.Height() - 25, str);
|
|
Point2I point, result, topResult, botResult;
|
point.x = m_ptMouseDown.x;
|
point.y = m_ptMouseDown.y;
|
if (BlVision_GetSoftVisionApp()->transformToStandard(m_nSide, point, result, topResult, botResult)) {
|
str.Format(_T("(%d / %d)"), result.x, result.y);
|
memDC.TextOut(110, m_WndRect.Height() - 25, str);
|
|
str.Format(_T("(%d / %d)"), topResult.x, topResult.y);
|
memDC.TextOut(210, m_WndRect.Height() - 25, str);
|
|
str.Format(_T("(%d / %d)"), botResult.x, botResult.y);
|
memDC.TextOut(310, m_WndRect.Height() - 25, str);
|
}
|
}
|
}
|
|
pOldFont = (CFont*)memDC.SelectObject(&m_sideFont);
|
memDC.SetTextColor(RGB(45, 200, 45));
|
memDC.TextOut(0,0,PANEL_SIDE_NAME[m_nSide]);
|
memDC.SetBkMode(OPAQUE);
|
|
|
pDC->BitBlt(0,0,m_WndRect.Width(),m_WndRect.Height(),&memDC,0,0,SRCCOPY);
|
|
if(pOldFont) memDC.SelectObject(pOldFont);
|
|
memDC.SelectObject(pOldBitmap);
|
Bitmap.DeleteObject();
|
ReleaseDC(&memDC);
|
|
ReleaseDC(pDC);
|
}
|
|
|
void CFrameImg::DrawTest(CDC &dc)
|
{
|
CPen penX(PS_SOLID, 1, RGB(0,255,255));
|
CPen penY(PS_SOLID, 1, RGB(255,255,0));
|
CPen *pOldPen;
|
|
pOldPen = (CPen*)dc.SelectObject(&penX);
|
|
|
|
dc.MoveTo(int((m_testMark.left - m_ptOrg.x) * m_dZoom),int((m_testMark.top) * m_dZoom));
|
dc.LineTo(int((m_testMark.right- m_ptOrg.x) * m_dZoom),int((m_testMark.top) * m_dZoom));
|
dc.LineTo(int((m_testMark.right- m_ptOrg.x) * m_dZoom),int((m_testMark.bottom) * m_dZoom));
|
dc.LineTo(int((m_testMark.left - m_ptOrg.x) * m_dZoom),int((m_testMark.bottom) * m_dZoom));
|
dc.LineTo(int((m_testMark.left - m_ptOrg.x) * m_dZoom),int((m_testMark.top) * m_dZoom));
|
|
dc.MoveTo(int((m_testMark.left - m_ptOrg.x + m_testMark.Width()/2) * m_dZoom),int((m_testMark.top) * m_dZoom));
|
dc.LineTo(int((m_testMark.left - m_ptOrg.x + m_testMark.Width()/2) * m_dZoom),int((m_testMark.bottom) * m_dZoom));
|
|
dc.MoveTo(int((m_testMark.left - m_ptOrg.x) * m_dZoom),int((m_testMark.top + m_testMark.Height()/2) * m_dZoom));
|
dc.LineTo(int((m_testMark.right- m_ptOrg.x) * m_dZoom),int((m_testMark.top + m_testMark.Height()/2) * m_dZoom));
|
|
|
dc.SelectObject(pOldPen);
|
dc.SetROP2(R2_COPYPEN);
|
}
|
|
|
|
void CFrameImg::OnPaint()
|
{
|
CPaintDC dc(this); // device context for painting
|
// TODO: ¿©±â¿¡ ¸Þ½ÃÁö 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù.
|
// ±×¸®±â ¸Þ½ÃÁö¿¡ ´ëÇØ¼´Â CStatic::OnPaint()À»(¸¦) È£ÃâÇÏÁö ¸¶½Ê½Ã¿À.
|
ViewUpdate();
|
}
|
|
|
|
|
|
void CFrameImg::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)
|
{
|
CPoint pt(m_ptMouseCurrent);
|
ClientToScreen(&pt);
|
CMenu muTemp, *pContextMenu;
|
|
muTemp.LoadMenu(IDR_MENU1);
|
pContextMenu = muTemp.GetSubMenu(0);
|
|
|
if(m_bitModeDisplay[MODE_PROFILE_X])
|
pContextMenu->CheckMenuItem(ID_PROFILE_CURRENTX,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_PROFILE_CURRENTX,MF_UNCHECKED);
|
|
if(m_bitModeDisplay[MODE_PROFILE_Y])
|
pContextMenu->CheckMenuItem(ID_PROFILE_CURRENTY,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_PROFILE_CURRENTY,MF_UNCHECKED);
|
|
if(m_bitModeDisplay[MODE_SAVED_X])
|
pContextMenu->CheckMenuItem(ID_PROFILE_SAVEDX,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_PROFILE_SAVEDX,MF_UNCHECKED);
|
|
if(m_bitModeDisplay[MODE_SAVED_Y])
|
pContextMenu->CheckMenuItem(ID_PROFILE_SAVEDY,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_PROFILE_SAVEDY,MF_UNCHECKED);
|
|
|
|
if(m_bitModeDisplay[MODE_PROJECTION_X])
|
pContextMenu->CheckMenuItem(ID_PROFILE_PROJECTIONX,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_PROFILE_PROJECTIONX,MF_UNCHECKED);
|
|
if(m_bitModeDisplay[MODE_PROJECTION_Y])
|
pContextMenu->CheckMenuItem(ID_PROFILE_PROJECTIONY,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_PROFILE_PROJECTIONY,MF_UNCHECKED);
|
|
if(m_bitModeDisplay[MODE_DISTANCE_X])
|
pContextMenu->CheckMenuItem(ID_MEASURE_DISTANCEX,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_MEASURE_DISTANCEX,MF_UNCHECKED);
|
|
if(m_bitModeDisplay[MODE_DISTANCE_Y])
|
pContextMenu->CheckMenuItem(ID_MEASURE_DISTANCEY,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_MEASURE_DISTANCEY,MF_UNCHECKED);
|
|
|
/*
|
if(m_bitModeDisplay[MODE_DIAGONAL))
|
pContextMenu->CheckMenuItem(ID_MEASURE_DIAGONAL,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_MEASURE_DIAGONAL,MF_UNCHECKED);
|
|
|
if(m_bitModeDisplay[MODE_MANIFY))
|
pContextMenu->CheckMenuItem(ID_IMAGE_MANIFY,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_IMAGE_MANIFY,MF_UNCHECKED);
|
*/
|
|
|
if(m_bitModeDisplay[MODE_SHOW_MEASURE_LINE])
|
pContextMenu->CheckMenuItem(ID_VIEW_SHOW_MEASURE_LINE,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_VIEW_SHOW_MEASURE_LINE,MF_UNCHECKED);
|
|
|
if(m_bitModeDisplay[MODE_SHOW_REF_LINE])
|
pContextMenu->CheckMenuItem(ID_VIEW_SHOW_REF_LINE,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_VIEW_SHOW_REF_LINE,MF_UNCHECKED);
|
|
|
/*
|
if(m_bitModeDisplay[MODE_SHOW_SUB_LINE))
|
pContextMenu->CheckMenuItem(ID_VIEW_SHOW_SUB_LINE,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_VIEW_SHOW_SUB_LINE,MF_UNCHECKED);
|
*/
|
|
|
if(m_bitModeDisplay[MODE_MODIFY_BRUSH])
|
pContextMenu->CheckMenuItem(ID_IMGMODIFY_DRAWBRUSH,MF_CHECKED);
|
else
|
pContextMenu->CheckMenuItem(ID_IMGMODIFY_DRAWBRUSH,MF_UNCHECKED);
|
|
|
pContextMenu->TrackPopupMenu(TPM_LEFTALIGN , pt.x, pt.y, this);
|
|
}
|
|
void CFrameImg::OnMouseMove(UINT nFlags, CPoint point)
|
{
|
m_ptMouseCurrent = point;
|
|
|
CString strTemp;
|
|
if(m_bMouseLDown == TRUE)
|
{
|
if(m_pTracker)
|
{
|
if(m_nModeTracker)
|
{
|
::SendMessage(m_Wnd_Event, WM_AREA_ITEM_MODIFY , 0, 0);
|
}
|
|
SetTrackerPos(m_nModeTracker,&m_pTracker->rc,point);
|
}
|
else if((m_pCompareArea != nullptr) && (m_nModeTracker))
|
{
|
::SendMessage(m_Wnd_Event, WM_AREA_ITEM_MODIFY , 0, 0);
|
SetTrackerPos(m_nModeTracker, &(m_pCompareArea->rc), point);
|
}
|
|
if(m_bitModeDisplay[MODE_MODIFY_BRUSH])
|
{
|
int x,y,k,l;
|
x = int(m_ptMouseCurrent.x / m_dZoom)+ m_ptOrg.x;
|
y = int(m_ptMouseCurrent.y / m_dZoom);
|
|
if (0 > m_nBrushGray || 255 < m_nBrushGray)
|
m_nBrushGray = 5;
|
|
for(k = y -20 ; k < y+20 ; k++)
|
{
|
for(l = x -8; l < x + 8 ; l++)
|
{
|
m_pBuffer[k * m_szImg.cx + l ] = m_nBrushGray;
|
}
|
}
|
}
|
}
|
// m_ptOldMouse = point;
|
|
|
if(m_ManualMeausre.bStart == TRUE || m_ManualMeausre.bModifyEnd == TRUE)
|
{
|
m_ManualMeausre.ptMeasureEnd.x = int(m_ptMouseCurrent.x / m_dZoom) + m_ptOrg.x;
|
m_ManualMeausre.ptMeasureEnd.y = int(m_ptMouseCurrent.y / m_dZoom) + m_ptOrg.y;
|
}
|
else if(m_ManualMeausre.bModifyStart == TRUE)
|
{
|
m_ManualMeausre.ptMeasureStart.x = int(m_ptMouseCurrent.x / m_dZoom) + m_ptOrg.x;
|
m_ManualMeausre.ptMeasureStart.y = int(m_ptMouseCurrent.y / m_dZoom) + m_ptOrg.y;
|
}
|
|
|
ViewUpdate();
|
CWnd::OnMouseMove(nFlags, point);
|
}
|
|
CRect CFrameImg::GetMartRect()
|
{
|
return m_refMark.rc;
|
}
|
|
void CFrameImg::SetMarkRect(CRect rc)
|
{
|
m_refMark.rc = rc;
|
}
|
|
|
|
void CFrameImg::OnLButtonDown(UINT nFlags, CPoint point)
|
{
|
|
|
m_ptMouseCurrent = point;
|
m_ptOldMouse = point;
|
m_bMouseLDown = TRUE;
|
|
if (m_bMouseLDown) {
|
m_ptMouseDown.x = m_ptOrg.x + int(m_ptMouseCurrent.x / m_dZoom);
|
m_ptMouseDown.y = m_ptOrg.y + int(m_ptMouseCurrent.y / m_dZoom);
|
}
|
|
if(m_bitModeDisplay[MODE_MARK_REG])
|
{
|
CPoint pt;
|
|
pt.x = int(point.x / m_dZoom + m_ptOrg.x);
|
pt.y = int(point.y/ m_dZoom + m_ptOrg.y);
|
|
if(m_pTracker != NULL)
|
m_nModeTracker = (ChkTrackerAear(m_pTracker->rc,pt));
|
}
|
else if(((m_bitModeDisplay[MODE_USER_DEFECT_AREA]) ||(m_bitModeDisplay[MODE_COMPARE_PANEL] == 1)) && (m_pCompareArea != nullptr))
|
{
|
CPoint pt;
|
|
pt.x = static_cast<long>(point.x / m_dZoom) + m_ptOrg.x;
|
pt.y = static_cast<long>(point.y / m_dZoom) + m_ptOrg.y;
|
|
m_nModeTracker = ChkTrackerAear(m_pCompareArea->rc, pt);
|
SetTrackerPos(m_nModeTracker, &(m_pCompareArea->rc), point, 1);
|
}
|
else
|
{
|
m_nModeTracker = ChkExpetionAear(point);
|
}
|
|
if(m_pTracker != NULL)
|
SetTrackerPos(m_nModeTracker,&m_pTracker->rc,point,1);
|
|
CPoint ptTmp = point;
|
|
ptTmp.x = int(point.x / m_dZoom);
|
ptTmp.y = int(point.y / m_dZoom);
|
|
#define PIT_INT_RANGE 30
|
|
if(m_ManualMeausre.bStart == FALSE)
|
{
|
if( m_ManualMeausre.ptMeasureStart.x > ptTmp.x + m_ptOrg.x - PIT_INT_RANGE
|
&& m_ManualMeausre.ptMeasureStart.x < ptTmp.x + m_ptOrg.x + PIT_INT_RANGE
|
&& m_ManualMeausre.ptMeasureStart.y > ptTmp.y + m_ptOrg.y - PIT_INT_RANGE
|
&& m_ManualMeausre.ptMeasureStart.y < ptTmp.y + m_ptOrg.y + PIT_INT_RANGE )
|
{
|
if(m_ManualMeausre.bModifyStart)
|
m_ManualMeausre.bModifyStart = FALSE;
|
else
|
m_ManualMeausre.bModifyStart = TRUE;
|
|
}
|
else if(m_ManualMeausre.ptMeasureEnd.x > ptTmp.x + m_ptOrg.x - PIT_INT_RANGE
|
&& m_ManualMeausre.ptMeasureEnd.x < ptTmp.x + m_ptOrg.x + PIT_INT_RANGE
|
&& m_ManualMeausre.ptMeasureEnd.y > ptTmp.y + m_ptOrg.y - PIT_INT_RANGE
|
&& m_ManualMeausre.ptMeasureEnd.y < ptTmp.y + m_ptOrg.y + PIT_INT_RANGE )
|
{
|
if(m_ManualMeausre.bModifyEnd)
|
m_ManualMeausre.bModifyEnd = FALSE;
|
else
|
m_ManualMeausre.bModifyEnd = TRUE;
|
}
|
else
|
{
|
m_ManualMeausre.bModifyStart = FALSE;
|
m_ManualMeausre.bModifyEnd = FALSE;
|
m_ManualMeausre.bStart = TRUE;
|
|
m_ManualMeausre.ptMeasureStart.x= ptTmp.x + m_ptOrg.x;
|
m_ManualMeausre.ptMeasureStart.y= ptTmp.y + m_ptOrg.y;
|
}
|
}
|
else
|
{
|
m_ManualMeausre.bStart = FALSE;
|
}
|
|
m_ptMouseSaved.x = point.x;
|
m_ptMouseSaved.y = int(point.y / m_dZoom) +m_ptOrg.y;
|
//m_ptMouseSaved = point;
|
|
ViewUpdate();
|
CWnd::OnLButtonDown(nFlags, point);
|
}
|
|
void CFrameImg::OnLButtonUp(UINT nFlags, CPoint point)
|
{
|
m_bMouseLDown = FALSE;
|
ViewUpdate();
|
CWnd::OnLButtonUp(nFlags, point);
|
}
|
|
|
|
void CFrameImg::TrackerInsert()
|
{
|
/*
|
EXECPTION_AREA *pTracker = new EXECPTION_AREA;
|
|
|
pTracker->szErrSize.cx = 300;
|
pTracker->szErrSize.cy = 300;
|
|
pTracker->nAppDefect = 1;
|
|
|
pTracker->rc.top = m_ptOrg.y + 100 - g_InsData[m_nLocalSide].ptMark[0].y;
|
pTracker->rc.bottom = m_ptOrg.y + 200 - g_InsData[m_nLocalSide].ptMark[0].y;
|
pTracker->rc.left = m_ptOrg.x + 100 - g_InsData[m_nLocalSide].ptMark[0].x;
|
pTracker->rc.right = m_ptOrg.x + 200 - g_InsData[m_nLocalSide].ptMark[0].x;
|
|
m_Exception[m_nLocalSide].push_back(pTracker);
|
|
SetAcitveTracker(pTracker);
|
*/
|
}
|
|
|
BOOL CFrameImg::SetAcitveTracker(EXECPTION_AREA *pTracker,BOOL bReDraw /*= TRUE*/)
|
{
|
// if(pTracker == NULL)
|
// return FALSE;
|
|
m_pTracker = pTracker;
|
|
if(bReDraw) ViewUpdate();
|
|
return TRUE;
|
}
|
|
void CFrameImg::SetTrackerPos(int nTrackerMode,CRect * pRc,CPoint pt, int nMode /*= 0*/)
|
{
|
if(m_pGlassData == NULL)
|
return;
|
|
INS_EDGE_RESULT_INFO *pResInfo = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
if(pResInfo == NULL)
|
return;
|
|
double dOffsetX = (pResInfo->ptMark[1].x - pResInfo->ptMark[0].x) / double(pResInfo->ptMark[1].y - pResInfo->ptMark[0].y);
|
|
pt.x = int(pt.x / m_dZoom);
|
pt.y = int(pt.y / m_dZoom);
|
|
if((m_bitModeDisplay[MODE_MARK_REG] == 1) || (m_bitModeDisplay[MODE_COMPARE_PANEL] == 1) || (m_bitModeDisplay[MODE_USER_DEFECT_AREA]))
|
{
|
pt.y = pt.y + m_ptOrg.y;// - m_pInsData->ptMark[0].y;
|
pt.x = pt.x + m_ptOrg.x;// - m_pInsData->ptMark[0].x - int(pt.y * m_pInsData->dOffsetX);
|
}
|
else
|
{
|
pt.y = int(pt.y + m_ptOrg.y - pResInfo->ptMark[0].y);
|
pt.x = int(pt.x + m_ptOrg.x - pResInfo->ptMark[0].x - int(pt.y * dOffsetX));
|
}
|
|
if(nMode == 1)
|
{
|
m_ptOldMouse = pt;
|
return;
|
}
|
|
const int nOffSet = 10;
|
|
switch(nTrackerMode)
|
{
|
case 1:
|
if(pRc->bottom - nOffSet < pt.y)
|
pRc->top = pRc->bottom - nOffSet;
|
else
|
pRc->top = pt.y;
|
|
if(pRc->right - nOffSet < pt.x)
|
pRc->right = pRc->right -nOffSet;
|
else
|
pRc->left = pt.x;
|
break;
|
|
case 2:
|
if(pRc->bottom - nOffSet < pt.y)
|
pRc->top = pRc->bottom - nOffSet;
|
else
|
pRc->top = pt.y;
|
|
if(pRc->left + nOffSet > pt.x)
|
pRc->right = pRc->left + nOffSet;
|
else
|
pRc->right = pt.x;
|
break;
|
|
case 3:
|
if(pRc->top + nOffSet > pt.y)
|
pRc->bottom = pRc->top + nOffSet;
|
else
|
pRc->bottom = pt.y;
|
|
if(pRc->right - nOffSet < pt.x)
|
pRc->right = pRc->right -nOffSet;
|
else
|
pRc->left = pt.x;
|
break;
|
|
case 4:
|
if(pRc->top + nOffSet > pt.y)
|
pRc->bottom = pRc->top + nOffSet;
|
else
|
pRc->bottom = pt.y;
|
|
if(pRc->left + nOffSet > pt.x)
|
pRc->right = pRc->left + nOffSet;
|
else
|
pRc->right = pt.x;
|
break;
|
|
case 5:
|
pRc->left += (pt.x - m_ptOldMouse.x);
|
pRc->right += (pt.x - m_ptOldMouse.x);
|
pRc->top += (pt.y - m_ptOldMouse.y);
|
pRc->bottom += (pt.y - m_ptOldMouse.y);
|
break;
|
}
|
m_ptOldMouse = pt;
|
}
|
|
void CFrameImg::SetRecipe(CHardwareSettings *pHW,CGlassRecipe *pRecipe)
|
{
|
m_pHardware = pHW;
|
m_pRecipe = pRecipe;
|
}
|
|
int CFrameImg::GetSideCamID(int nSide)
|
{
|
int nCam = 0;
|
|
if(m_pHardware != NULL)
|
{
|
nCam = m_pHardware->GetCameraIndexToDimension((DimensionDir)nSide);
|
}
|
|
return nCam;
|
}
|
|
int CFrameImg::GetSideScanIdx(int nSide)
|
{
|
int iScan = 0;
|
|
if(m_pHardware != NULL)
|
{
|
iScan = m_pHardware->GetScanToDimension((DimensionDir)nSide);
|
}
|
|
return iScan;
|
}
|
|
void CFrameImg::SetSide(int nSide)
|
{
|
m_nSide = nSide;
|
m_nCam = GetSideCamID(m_nSide);
|
}
|
|
void CFrameImg::Draw_TrakerRect(CRect rcTracker,CDC &dc)
|
{
|
CPen pen(PS_SOLID, 1, RGB(255,0,0));
|
CPen *pOldPen;
|
|
const int nWidth = 2;
|
dc.SetBkMode(TRANSPARENT);
|
pOldPen = (CPen*)dc.SelectObject(&pen);
|
|
//Draw_Rectangle(dc,m_rcTraker);
|
CPoint ptOrg;
|
|
ptOrg.x = int(m_ptOrg.x * m_dZoom);
|
ptOrg.y = int(m_ptOrg.y * m_dZoom);
|
|
rcTracker.left = int(rcTracker.left * m_dZoom);
|
rcTracker.right = int(rcTracker.right * m_dZoom);
|
rcTracker.top = int(rcTracker.top * m_dZoom);
|
rcTracker.bottom = int(rcTracker.bottom * m_dZoom);
|
|
dc.MoveTo(rcTracker.left + nWidth - ptOrg.x, rcTracker.top - ptOrg.y);
|
dc.LineTo(rcTracker.right - nWidth - ptOrg.x, rcTracker.top - ptOrg.y);
|
|
dc.MoveTo(rcTracker.right - ptOrg.x, rcTracker.top + nWidth - ptOrg.y);
|
dc.LineTo(rcTracker.right - ptOrg.x, rcTracker.bottom - nWidth - ptOrg.y);
|
|
dc.MoveTo(rcTracker.right - nWidth - ptOrg.x, rcTracker.bottom - ptOrg.y);
|
dc.LineTo(rcTracker.left + nWidth - ptOrg.x, rcTracker.bottom - ptOrg.y);
|
|
dc.MoveTo(rcTracker.left - ptOrg.x , rcTracker.bottom - nWidth- ptOrg.y);
|
dc.LineTo(rcTracker.left - ptOrg.x , rcTracker.top + nWidth - ptOrg.y);
|
|
|
CRect rc1;
|
|
rc1.top = rcTracker.top - nWidth - ptOrg.y;
|
rc1.bottom = rcTracker.top + nWidth - ptOrg.y;
|
rc1.left = rcTracker.left - nWidth - ptOrg.x;
|
rc1.right = rcTracker.left + nWidth - ptOrg.x;
|
|
Draw_Rectangle(dc,rc1);
|
|
rc1.top = rcTracker.top - nWidth - ptOrg.y;
|
rc1.bottom = rcTracker.top + nWidth - ptOrg.y;
|
rc1.left = rcTracker.right - nWidth - ptOrg.x;
|
rc1.right = rcTracker.right + nWidth - ptOrg.x;
|
|
Draw_Rectangle(dc,rc1);
|
|
rc1.top = rcTracker.bottom - nWidth - ptOrg.y;
|
rc1.bottom = rcTracker.bottom + nWidth - ptOrg.y;
|
rc1.left = rcTracker.left - nWidth - ptOrg.x;
|
rc1.right = rcTracker.left + nWidth - ptOrg.x;
|
|
Draw_Rectangle(dc,rc1);
|
|
rc1.top = rcTracker.bottom - nWidth - ptOrg.y;
|
rc1.bottom = rcTracker.bottom + nWidth - ptOrg.y;
|
rc1.left = rcTracker.right - nWidth - ptOrg.x;
|
rc1.right = rcTracker.right + nWidth - ptOrg.x;
|
|
Draw_Rectangle(dc,rc1);
|
dc.SelectObject(&pOldPen);
|
}
|
|
|
void CFrameImg::Draw_CompareRect(CRect rcCompareArea, CDC &dc)
|
{
|
CPen pen(PS_SOLID, 2, RGB(255,0,0));
|
CPen *pOldPen;
|
|
const int nWidth = 2;
|
dc.SetBkMode(TRANSPARENT);
|
dc.SetTextColor(m_st_GdiItem.colorOrange);
|
pOldPen = (CPen*)dc.SelectObject(&pen);
|
|
CPoint ptOrg;
|
ptOrg.x = static_cast<long>(m_ptOrg.x * m_dZoom);
|
ptOrg.y = static_cast<long>(m_ptOrg.y * m_dZoom);
|
|
rcCompareArea.left = static_cast<long>(rcCompareArea.left * m_dZoom);
|
rcCompareArea.right = static_cast<long>(rcCompareArea.right * m_dZoom);
|
rcCompareArea.top = static_cast<long>(rcCompareArea.top * m_dZoom);
|
rcCompareArea.bottom = static_cast<long>(rcCompareArea.bottom * m_dZoom);
|
|
dc.MoveTo(rcCompareArea.left + nWidth - ptOrg.x, rcCompareArea.top - ptOrg.y);
|
dc.LineTo(rcCompareArea.right - nWidth - ptOrg.x, rcCompareArea.top - ptOrg.y);
|
|
dc.MoveTo(rcCompareArea.right - ptOrg.x, rcCompareArea.top + nWidth - ptOrg.y);
|
dc.LineTo(rcCompareArea.right - ptOrg.x, rcCompareArea.bottom - nWidth - ptOrg.y);
|
|
dc.MoveTo(rcCompareArea.right- nWidth - ptOrg.x, rcCompareArea.bottom - ptOrg.y);
|
dc.LineTo(rcCompareArea.left + nWidth - ptOrg.x, rcCompareArea.bottom - ptOrg.y);
|
|
dc.MoveTo(rcCompareArea.left - ptOrg.x, rcCompareArea.bottom - nWidth- ptOrg.y);
|
dc.LineTo(rcCompareArea.left - ptOrg.x, rcCompareArea.top + nWidth - ptOrg.y);
|
|
CString strAreaText;
|
strAreaText.Format(_T("X:%ld, Y:%ld, W:%ld, H:%ld"),
|
rcCompareArea.left,
|
rcCompareArea.top,
|
(rcCompareArea.right-rcCompareArea.left),
|
(rcCompareArea.bottom-rcCompareArea.top));
|
dc.TextOut(rcCompareArea.left - ptOrg.x, rcCompareArea.top - ptOrg.y -20, strAreaText);
|
|
CRect rcPoint;
|
rcPoint.top = rcCompareArea.top - nWidth - ptOrg.y;
|
rcPoint.bottom = rcCompareArea.top + nWidth - ptOrg.y;
|
rcPoint.left = rcCompareArea.left - nWidth - ptOrg.x;
|
rcPoint.right = rcCompareArea.left + nWidth - ptOrg.x;
|
Draw_Rectangle(dc,rcPoint);
|
|
rcPoint.top = rcCompareArea.top - nWidth - ptOrg.y;
|
rcPoint.bottom = rcCompareArea.top + nWidth - ptOrg.y;
|
rcPoint.left = rcCompareArea.right - nWidth - ptOrg.x;
|
rcPoint.right = rcCompareArea.right + nWidth - ptOrg.x;
|
Draw_Rectangle(dc,rcPoint);
|
|
rcPoint.top = rcCompareArea.bottom - nWidth - ptOrg.y;
|
rcPoint.bottom = rcCompareArea.bottom + nWidth - ptOrg.y;
|
rcPoint.left = rcCompareArea.left - nWidth - ptOrg.x;
|
rcPoint.right = rcCompareArea.left + nWidth - ptOrg.x;
|
Draw_Rectangle(dc,rcPoint);
|
|
rcPoint.top = rcCompareArea.bottom - nWidth - ptOrg.y;
|
rcPoint.bottom = rcCompareArea.bottom + nWidth - ptOrg.y;
|
rcPoint.left = rcCompareArea.right - nWidth - ptOrg.x;
|
rcPoint.right = rcCompareArea.right + nWidth - ptOrg.x;
|
Draw_Rectangle(dc,rcPoint);
|
|
dc.SelectObject(&pOldPen);
|
}
|
|
void CFrameImg::Draw_Rectangle(CDC &dc,CRect rc, int nMode /*= 0*/)
|
{
|
|
dc.MoveTo(rc.left , rc.top);
|
dc.LineTo(rc.right , rc.top);
|
dc.LineTo(rc.right , rc.bottom);
|
dc.LineTo(rc.left , rc.bottom);
|
dc.LineTo(rc.left , rc.top);
|
|
if(nMode == 1)
|
{
|
dc.MoveTo(rc.left , rc.top + rc.Height()/2);
|
dc.LineTo(rc.right , rc.top + rc.Height()/2);
|
|
|
dc.MoveTo(rc.left + rc.Width()/2 , rc.top);
|
dc.LineTo(rc.left + rc.Width()/2 , rc.bottom);
|
}
|
}
|
|
|
|
|
int CFrameImg::ChkTrackerAear(CRect &rcTracker,CPoint pt)
|
{
|
int nMode = 0;
|
|
|
CRect rcTmp;
|
//pt.y = pt.y + m_ptOrg.y / m_dZoom;
|
//pt.x = pt.x + m_ptOrg.x / m_dZoom;
|
|
const int nOffset = 10;
|
|
rcTmp.top = rcTracker.top - nOffset;
|
rcTmp.bottom = rcTracker.top + nOffset;
|
rcTmp.left = rcTracker.left - nOffset;
|
rcTmp.right = rcTracker.left + nOffset;
|
|
if(rcTmp.PtInRect(pt))
|
{
|
nMode = 1;
|
}
|
|
rcTmp.top = rcTracker.top - nOffset;
|
rcTmp.bottom = rcTracker.top + nOffset;
|
rcTmp.left = rcTracker.right - nOffset;
|
rcTmp.right = rcTracker.right + nOffset;
|
|
if(rcTmp.PtInRect(pt))
|
{
|
nMode = 2;
|
}
|
|
|
rcTmp.top = rcTracker.bottom - nOffset;
|
rcTmp.bottom = rcTracker.bottom + nOffset;
|
rcTmp.left = rcTracker.left - nOffset;
|
rcTmp.right = rcTracker.left + nOffset;
|
|
if(rcTmp.PtInRect(pt))
|
{
|
nMode = 3;
|
}
|
|
rcTmp.top = rcTracker.bottom - nOffset;
|
rcTmp.bottom = rcTracker.bottom + nOffset;
|
rcTmp.left = rcTracker.right - nOffset;
|
rcTmp.right = rcTracker.right + nOffset;
|
|
if(rcTmp.PtInRect(pt))
|
{
|
nMode = 4;
|
}
|
|
if(rcTracker.PtInRect(pt))
|
{
|
nMode = 5;
|
}
|
|
return nMode;
|
}
|
|
|
|
int CFrameImg::ChkExpetionAear(CPoint pt)
|
{
|
if(m_pGlassData == NULL || m_pRecipe == NULL)
|
return 0;
|
|
int nMode = 0;
|
CRect rcTmp;
|
|
INS_EDGE_RESULT_INFO *pResInfo = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
if(pResInfo == NULL)
|
return 0;
|
|
double dOffsetX = (pResInfo->ptMark[1].x - pResInfo->ptMark[0].x) / double(pResInfo->ptMark[1].y - pResInfo->ptMark[0].y);
|
|
EXCEPTION_AREA_LIST *pExpList = m_pRecipe->GetExpAreaList((DimensionDir)m_nSide);
|
if(pExpList == NULL)
|
return 0;
|
|
pt.x = int(pt.x / m_dZoom);
|
pt.y = int(pt.y / m_dZoom);
|
|
|
pt.y = int((pt.y + m_ptOrg.y) - pResInfo->ptMark[0].y);
|
pt.x = int((pt.x + m_ptOrg.x) - pResInfo->ptMark[0].x - int(pt.y * dOffsetX));
|
|
itEXCEPTION_AREA_LIST it;
|
const int nOffset = 8;
|
for(it = pExpList->begin(); it != pExpList->end() ; it++)
|
{
|
|
nMode = ChkTrackerAear((*it)->rc,pt);
|
if(nMode)
|
break;
|
}
|
|
if(m_bModify == TRUE)
|
{
|
if(nMode)
|
{
|
if(m_pTracker != (*it))
|
{
|
SetAcitveTracker((*it));
|
::SendMessage(m_Wnd_Event , WM_AREA_ITEM_SELECT_CHANGE , 0, 0);
|
}
|
else
|
{
|
::SendMessage(m_Wnd_Event , WM_AREA_ITEM_MODIFY , 0, 0);
|
}
|
}
|
}
|
return nMode;
|
}
|
|
void CFrameImg::DrawCADRCutChamfertResult(CDC &dc,CvPoint2D32f *ptMark)
|
{
|
if(m_pGlassData == NULL || m_pRecipe == NULL)
|
return;
|
|
switch(m_nSide)
|
{
|
case DIMENSION_A_DN:
|
case DIMENSION_D_DN:
|
case DIMENSION_C:
|
case DIMENSION_C_DN:
|
return;
|
}
|
|
int nIndex[2],nSize[2];
|
CString str;
|
|
int nUpDn = 1;
|
int x,y,k;
|
int nOffset = (int)(3*m_dZoom);
|
CPoint ptTxt;
|
CString strDraw;
|
|
int nIndexCunt = 1;
|
|
if(m_pRecipe->m_GlassParm.m_bPanelReverse == FALSE)
|
{
|
switch(m_nSide)
|
{
|
case DIMENSION_A:
|
case DIMENSION_A_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(1,nIndex[0],nSize[0],strDraw) == FALSE) // A »óÃø ¿ª¹æÇâ, Q1(65) ~ Q4(69)
|
return;
|
if(m_pGlassData->GetProfileRCutInspectIndex(0,nIndex[1],nSize[1],strDraw) == FALSE) // A ÇÏÃø Á¤¹æÇâ, P1(60) ~ P4(64)
|
return;
|
nIndexCunt = 2;
|
break;
|
case DIMENSION_B:
|
case DIMENSION_B_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(2,nIndex[0],nSize[0],strDraw) == FALSE) // B ÇÏÃø Á¤¹æÇâ, N1(75) ~ N4(79)
|
return;
|
break;
|
case DIMENSION_D:
|
case DIMENSION_D_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(3,nIndex[0],nSize[0],strDraw) == FALSE) // D ÇÏÃø ¿ª¹æÇâ, Q1(70) ~ Q4(74)
|
return;
|
break;
|
default:
|
return;
|
}
|
}
|
else
|
{
|
switch(m_nSide)
|
{
|
case DIMENSION_A:
|
case DIMENSION_A_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(0,nIndex[0],nSize[0],strDraw) == FALSE) // A »óÃø Á¤¹æÇâ, P1(60) ~ P4(64)
|
return;
|
if(m_pGlassData->GetProfileRCutInspectIndex(1,nIndex[1],nSize[1],strDraw) == FALSE) // A ÇÏÃø ¿ª¹æÇâ, Q1(75) ~ Q4(79)
|
return;
|
nIndexCunt = 2;
|
break;
|
case DIMENSION_B:
|
case DIMENSION_B_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(3,nIndex[0],nSize[0],strDraw) == FALSE) // B ÇÏÃø ¿ª¹æÇâ, Q1(70) ~ Q4(74)
|
return;
|
break;
|
case DIMENSION_D:
|
case DIMENSION_D_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(2,nIndex[0],nSize[0],strDraw) == FALSE) // D ÇÏÃø Á¤¹æÇâ, N1(65) ~ N4(69)
|
return;
|
break;
|
}
|
}
|
|
CPen pen1(PS_SOLID, 1, RGB(255,255,0));
|
CPen pen2(PS_SOLID, 1, RGB(0,255,0));
|
CHAMFER_RESULT *pChamfer;
|
|
PROFILECHAMFER_RESULT_DATA *pProfileResult = m_pGlassData->GetProfileInspectData();
|
for(k=0;k<nIndexCunt;k++)
|
{
|
for(int i=nIndex[k];i<nIndex[k]+nSize[k];i++)
|
{
|
pChamfer = &pProfileResult->ResultChamfer[i][0];
|
|
dc.SelectObject(&pen2);
|
|
x = int((pChamfer->ptGlassLine.x - m_ptOrg.x) * m_dZoom);
|
y = int((pChamfer->ptGlassLine.y - m_ptOrg.y) * m_dZoom);
|
|
dc.MoveTo(x-nOffset,y-nOffset);
|
dc.LineTo(x + nOffset,y+nOffset);
|
dc.MoveTo(x-nOffset,y+nOffset);
|
dc.LineTo(x + nOffset,y-nOffset);
|
|
ptTxt = CPoint(x-60,y-8);
|
|
dc.SelectObject(&pen1);
|
|
x = int((pChamfer->ptChamferLine.x - m_ptOrg.x) * m_dZoom);
|
y = int((pChamfer->ptChamferLine.y - m_ptOrg.y) * m_dZoom);
|
|
dc.MoveTo(x-nOffset,y-nOffset);
|
dc.LineTo(x + nOffset,y+nOffset);
|
dc.MoveTo(x-nOffset,y+nOffset);
|
dc.LineTo(x + nOffset,y-nOffset);
|
|
dc.SetBkMode(TRANSPARENT);
|
//if(pProRes[i].bProfileJudge == TRUE && pProRes[i].stChamfer[nUpDn].bChamferJudge == TRUE)
|
dc.SetTextColor(m_st_GdiItem.colorBlue);
|
//else
|
// dc.SetTextColor(m_st_GdiItem.colorRed);
|
|
strDraw.Format(_T("R_%d"),pChamfer->iIndex+1);
|
dc.TextOut(ptTxt.x ,ptTxt.y,strDraw);
|
}
|
}
|
}
|
|
void CFrameImg::DrawCADRCutProfiletResult(CDC &dc,CvPoint2D32f *ptMark)
|
{
|
if(m_pGlassData == NULL || m_pRecipe == NULL)
|
return;
|
|
switch(m_nSide)
|
{
|
case DIMENSION_A:
|
case DIMENSION_B:
|
case DIMENSION_C:
|
case DIMENSION_C_DN:
|
return;
|
}
|
|
int nIndex[2],nSize[2];
|
CString str;
|
|
int nUpDn = 1;
|
int x,y,k;
|
int nOffset = (int)(5*m_dZoom);
|
CPoint ptTxt;
|
CString strDraw;
|
|
if(m_nSide < MAX_PANEL_SIDE)
|
nUpDn = 0;
|
|
CPen pen1(PS_SOLID, 1, RGB(128,255,255));
|
CPen pen2(PS_SOLID, 2, RGB(0,255,0));
|
CPen pen3(PS_SOLID, 1, RGB(255,255,0));
|
CPen pen4(PS_SOLID, 1, RGB(0,255,0));
|
CPen pen5(PS_DASH, 1,RGB(0,255,255));
|
|
int nIndexCunt = 1;
|
|
if(m_pRecipe->m_GlassParm.m_bPanelReverse == FALSE)
|
{
|
switch(m_nSide)
|
{
|
case DIMENSION_A:
|
case DIMENSION_A_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(1,nIndex[0],nSize[0],strDraw) == FALSE) // A »óÃø ¿ª¹æÇâ, Q1(65) ~ Q4(69)
|
return;
|
if(m_pGlassData->GetProfileRCutInspectIndex(0,nIndex[1],nSize[1],strDraw) == FALSE) // A ÇÏÃø Á¤¹æÇâ, P1(60) ~ P4(64)
|
return;
|
nIndexCunt = 2;
|
break;
|
case DIMENSION_B:
|
case DIMENSION_B_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(2,nIndex[0],nSize[0],strDraw) == FALSE) // B ÇÏÃø Á¤¹æÇâ, N1(75) ~ N4(79)
|
return;
|
break;
|
case DIMENSION_D:
|
case DIMENSION_D_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(3,nIndex[0],nSize[0],strDraw) == FALSE) // D ÇÏÃø ¿ª¹æÇâ, Q1(70) ~ Q4(74)
|
return;
|
break;
|
default:
|
return;
|
}
|
}
|
else
|
{
|
switch(m_nSide)
|
{
|
case DIMENSION_A:
|
case DIMENSION_A_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(0,nIndex[0],nSize[0],strDraw) == FALSE) // A »óÃø Á¤¹æÇâ, P1(60) ~ P4(64)
|
return;
|
if(m_pGlassData->GetProfileRCutInspectIndex(1,nIndex[1],nSize[1],strDraw) == FALSE) // A ÇÏÃø ¿ª¹æÇâ, Q1(75) ~ Q4(79)
|
return;
|
nIndexCunt = 2;
|
break;
|
case DIMENSION_B:
|
case DIMENSION_B_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(3,nIndex[0],nSize[0],strDraw) == FALSE) // B ÇÏÃø ¿ª¹æÇâ, Q1(70) ~ Q4(74)
|
return;
|
break;
|
case DIMENSION_D:
|
case DIMENSION_D_DN:
|
if(m_pGlassData->GetProfileRCutInspectIndex(2,nIndex[0],nSize[0],strDraw) == FALSE) // D ÇÏÃø Á¤¹æÇâ, N1(65) ~ N4(69)
|
return;
|
break;
|
}
|
}
|
|
for(k=0;k<nIndexCunt;k++)
|
{
|
PROFILECHAMFER_RESULT_DATA *pProfileResult = m_pGlassData->GetProfileInspectData();
|
|
PROFILE_RCUT_PROCESSDATA *pProRes = &pProfileResult->RCutProcessData[nIndex[k]];
|
|
dc.SelectObject(&pen2);
|
|
x = int((pProRes[0].dCenterX - m_ptOrg.x) * m_dZoom);
|
y = int((pProRes[0].dCenterY - m_ptOrg.y) * m_dZoom);
|
|
dc.MoveTo(x-nOffset*2,y);
|
dc.LineTo(x + nOffset*2,y);
|
dc.MoveTo(x,y+nOffset*2);
|
dc.LineTo(x,y-nOffset*2);
|
|
|
CPoint ptArc = CPoint((int)pProRes[0].dCenterX,(int)pProRes[0].dCenterY);
|
int nRadius = (int)(pProRes[0].dPixelRadius* m_dZoom);
|
|
ptArc.x = int((pProRes[0].dCenterX - m_ptOrg.x) * m_dZoom);
|
ptArc.y = int((pProRes[0].dCenterY - m_ptOrg.y) * m_dZoom);
|
|
/*
|
dc.SelectObject(&pen4);
|
dc.SetBkMode(TRANSPARENT);
|
|
dc.SelectObject(GetStockObject(NULL_BRUSH));
|
dc.Ellipse(ptArc.x-nRadius,ptArc.y-nRadius,ptArc.x+nRadius,ptArc.y+nRadius);
|
*/
|
|
for(int i=0;i<nSize[k];i++)
|
{
|
if(pProRes[i].dCenterX <= 0 || pProRes[i].dCenterY <= 0)
|
continue;
|
|
// dc.SelectObject(&pen1);
|
//
|
// x = int((pProRes[i].dCADLineX - m_ptOrg.x) * m_dZoom);
|
// y = int((pProRes[i].dCADLineY - m_ptOrg.y) * m_dZoom);
|
//
|
// ptTxt = CPoint(x-60,y-8);
|
//
|
// dc.MoveTo(x-nOffset,y-nOffset);
|
// dc.LineTo(x + nOffset,y+nOffset);
|
// dc.MoveTo(x-nOffset,y+nOffset);
|
// dc.LineTo(x + nOffset,y-nOffset);
|
|
dc.SelectObject(&pen3);
|
|
x = int((pProRes[i].ptGlass.x - m_ptOrg.x) * m_dZoom);
|
y = int((pProRes[i].ptGlass.y - m_ptOrg.y) * m_dZoom);
|
|
dc.MoveTo(x-nOffset,y-nOffset);
|
dc.LineTo(x + nOffset,y+nOffset);
|
dc.MoveTo(x-nOffset,y+nOffset);
|
dc.LineTo(x + nOffset,y-nOffset);
|
|
ptTxt = CPoint(x-100,y-8);
|
|
dc.SelectObject(&pen5);
|
dc.MoveTo(x,y);
|
dc.LineTo(ptArc.x,ptArc.y);
|
|
dc.SelectObject(&pen4);
|
|
x = int((pProRes[i].ptChamfer.x - m_ptOrg.x) * m_dZoom);
|
y = int((pProRes[i].ptChamfer.y - m_ptOrg.y) * m_dZoom);
|
|
dc.MoveTo(x-nOffset,y-nOffset);
|
dc.LineTo(x + nOffset,y+nOffset);
|
dc.MoveTo(x-nOffset,y+nOffset);
|
dc.LineTo(x + nOffset,y-nOffset);
|
|
|
dc.SetBkMode(TRANSPARENT);
|
//if(pProRes[i].bProfileJudge == TRUE && pProRes[i].stChamfer[nUpDn].bChamferJudge == TRUE)
|
dc.SetTextColor(m_st_GdiItem.colorBlue);
|
//else
|
// dc.SetTextColor(m_st_GdiItem.colorRed);
|
|
strDraw.Format(_T("R_%d"),pProRes[i].iIndex+1);
|
dc.TextOut(ptTxt.x ,ptTxt.y,strDraw);
|
}
|
}
|
}
|
|
void CFrameImg::DrawCADProfiletResult(CDC &dc,CvPoint2D32f *ptMark)
|
{
|
if(m_pGlassData == NULL || m_pRecipe == NULL)
|
return;
|
|
int nIndex,nSize;
|
CString str;
|
|
if(m_pGlassData->GetProfileInspectIndex(m_nSide,nIndex,nSize,str) == FALSE)
|
return;
|
|
PROFILECHAMFER_RESULT_DATA *pProfileResult = m_pGlassData->GetProfileInspectData();
|
|
PROFILE_RESULT *pProRes = NULL;
|
CHAMFER_RESULT *pChamferRes;
|
|
int nUpDn = 1;
|
int x,y,i;
|
int nOffset = (int)(3*m_dZoom);
|
CPoint ptTxt;
|
CString strDraw;
|
|
if(m_nSide < MAX_PANEL_SIDE)
|
nUpDn = 0;
|
|
CPen pen1(PS_SOLID, 1, RGB(128,255,255));
|
CPen pen2(PS_SOLID, 1, RGB(255,255,0));
|
CPen pen3(PS_SOLID, 1, RGB(0,255,0));
|
|
for(i=nIndex;i<nIndex+nSize;i++)
|
{
|
pProRes = &pProfileResult->ProfileData[i];
|
|
switch(m_nSide)
|
{
|
case DIMENSION_A_DN:
|
case DIMENSION_B_DN:
|
case DIMENSION_D_DN:
|
{
|
dc.SelectObject(&pen1);
|
|
x = int((pProRes->ptFullImg.x - m_ptOrg.x) * m_dZoom);
|
y = int((pProRes->ptFullImg.y - m_ptOrg.y) * m_dZoom);
|
|
if(x-nOffset > 0 && y-nOffset > 0)
|
{
|
dc.MoveTo(x-nOffset,y-nOffset);
|
dc.LineTo(x + nOffset,y+nOffset);
|
dc.MoveTo(x-nOffset,y+nOffset);
|
dc.LineTo(x + nOffset,y-nOffset);
|
}
|
}
|
break;
|
}
|
|
pChamferRes = &pProfileResult->ResultChamfer[i][nUpDn];
|
|
dc.SelectObject(&pen2);
|
|
x = int((pChamferRes->nGlassLeft - m_ptOrg.x) * m_dZoom);
|
y = int((pChamferRes->ptChamferLine.y - m_ptOrg.y) * m_dZoom);
|
|
ptTxt = CPoint(x-60,y-8);
|
|
dc.MoveTo(x-nOffset,y-nOffset);
|
dc.LineTo(x + nOffset,y+nOffset);
|
dc.MoveTo(x-nOffset,y+nOffset);
|
dc.LineTo(x + nOffset,y-nOffset);
|
|
dc.SelectObject(&pen3);
|
|
x = int((pChamferRes->ptChamferLine.x - m_ptOrg.x) * m_dZoom);
|
y = int((pChamferRes->ptChamferLine.y - m_ptOrg.y) * m_dZoom);
|
|
dc.MoveTo(x-nOffset,y-nOffset);
|
dc.LineTo(x + nOffset,y+nOffset);
|
dc.MoveTo(x-nOffset,y+nOffset);
|
dc.LineTo(x + nOffset,y-nOffset);
|
|
dc.SetBkMode(TRANSPARENT);
|
if(pProRes->bProfileJudge == TRUE && pChamferRes->bChamferJudge == TRUE)
|
dc.SetTextColor(m_st_GdiItem.colorBlue);
|
else
|
dc.SetTextColor(m_st_GdiItem.colorRed);
|
|
strDraw.Format(_T("%s_%d"),str,pChamferRes->iIndex+1);
|
dc.TextOut(ptTxt.x ,ptTxt.y,strDraw);
|
}
|
}
|
|
void CFrameImg::DrawCADProfiletLine(CDC &dc,CvPoint2D32f *ptMark)
|
{
|
if(m_pI2M == NULL)
|
return;
|
|
if(m_pGlassData == NULL || m_pRecipe == NULL)
|
return;
|
|
CSize szROI;
|
int y,yEnd;
|
|
szROI.cx = CHKMIN(int(m_WndRect.Width() / m_dZoom), m_szImg.cx);
|
szROI.cy = int(m_WndRect.Height() / m_dZoom);
|
|
y = int((m_ptOrg.y));
|
yEnd = y+szROI.cy;
|
|
std::multimap<int, CPoint *> *pMap = m_pI2M->IF2M_GetCADProfileLine(m_nSide,y,yEnd);
|
|
if(pMap == NULL || (int)pMap->size() <= 0)
|
return;
|
|
std::multimap<int, CPoint *>::iterator it,itEnd;
|
CPoint *pPoint,point;
|
|
it = pMap->lower_bound(y);
|
itEnd = pMap->upper_bound(yEnd);
|
|
if (it == pMap->end())
|
return;
|
|
while (it != itEnd)
|
{
|
if (it == pMap->end())
|
break;
|
|
pPoint = it->second;
|
if(pPoint == NULL)
|
{
|
it++;
|
continue;
|
}
|
point.x = int((pPoint->x - m_ptOrg.x) * m_dZoom);
|
point.y = int((pPoint->y - m_ptOrg.y) * m_dZoom);
|
|
if(point.y < 0 || point.x < 0)
|
{
|
it++;
|
continue;
|
}
|
dc.SetPixel(point,RGB(255,0,0));
|
it++;
|
}
|
}
|
|
void CFrameImg::DrawExpectionAear(CDC &dc)
|
{
|
if(m_pGlassData == NULL || m_pRecipe == NULL)
|
return;
|
|
EXCEPTION_AREA_LIST *pExpList = m_pRecipe->GetExpAreaList((DimensionDir)m_nSide);
|
if(pExpList == NULL)
|
return;
|
|
INS_EDGE_RESULT_INFO *pResInfo = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
if(pResInfo == NULL)
|
return;
|
|
if(pResInfo->ptMark[0].x < 1 || pResInfo->ptMark[0].y < 1)
|
return;
|
|
double dOffsetX = (pResInfo->ptMark[1].x - pResInfo->ptMark[0].x) / double(pResInfo->ptMark[1].y - pResInfo->ptMark[0].y);
|
|
itEXCEPTION_AREA_LIST it;
|
CPen penRed(PS_SOLID, 2, RGB(255,0,0)), *pOldPen;
|
CBrush hackBrush1,hackBrush2,*pOldBrush;
|
CRect rc,rc1;
|
hackBrush1.CreateHatchBrush(HS_BDIAGONAL, RGB(0,255,255));
|
hackBrush2.CreateHatchBrush(HS_DIAGCROSS, RGB(255,0,255));
|
|
pOldPen = dc.SelectObject(&penRed);
|
pOldBrush = dc.SelectObject(&hackBrush1);
|
|
if(!pExpList->empty())
|
{
|
dc.SetTextColor(RGB(0,0,255));
|
for(it = pExpList->begin(); it != pExpList->end() ; it++)
|
{
|
if((*it) != m_pTracker)
|
{
|
rc.top = (*it)->rc.top - m_ptOrg.y + (int)pResInfo->ptMark[0].y;
|
rc.bottom = (*it)->rc.bottom - m_ptOrg.y + (int)pResInfo->ptMark[0].y;
|
rc.left = (*it)->rc.left - m_ptOrg.x + (int)pResInfo->ptMark[0].x + int((*it)->rc.top * dOffsetX);
|
rc.right = (*it)->rc.right - m_ptOrg.x + (int)pResInfo->ptMark[0].x + int((*it)->rc.top * dOffsetX);
|
|
rc.top = int(rc.top * m_dZoom);
|
rc.bottom = int(rc.bottom * m_dZoom);
|
rc.left = int(rc.left * m_dZoom);
|
rc.right = int(rc.right * m_dZoom);
|
|
dc.SelectObject(&hackBrush1);
|
dc.Rectangle(rc);
|
|
|
switch((*it)->nAreaType)
|
{
|
case 0:
|
dc.TextOut(rc.left ,rc.top,_T("Defect Exception"));
|
break;
|
|
case 1:
|
dc.TextOut(rc.left ,rc.top,_T("Measure Area"));
|
break;
|
|
case 2:
|
dc.TextOut(rc.left ,rc.top,_T("VCR"));
|
break;
|
}
|
}
|
else
|
{
|
|
|
CRect rc2;
|
rc2 = (*it)->rc;
|
|
rc.top = (*it)->rc.top - m_ptOrg.y + (int)pResInfo->ptMark[0].y;
|
rc.bottom = (*it)->rc.bottom - m_ptOrg.y + (int)pResInfo->ptMark[0].y;
|
rc.left = (*it)->rc.left - m_ptOrg.x + (int)pResInfo->ptMark[0].x+ int((*it)->rc.top * dOffsetX);
|
rc.right = (*it)->rc.right - m_ptOrg.x + (int)pResInfo->ptMark[0].x+ int((*it)->rc.top * dOffsetX);
|
|
rc.top = int(rc.top * m_dZoom);
|
rc.bottom = int(rc.bottom * m_dZoom);
|
rc.left = int(rc.left * m_dZoom);
|
rc.right = int(rc.right * m_dZoom);
|
|
if(m_bModify == TRUE)
|
dc.SelectObject(&hackBrush2);
|
|
dc.Rectangle(rc);
|
|
if(m_bModify == TRUE)
|
{
|
rc1.top = rc.top - 5;
|
rc1.bottom = rc.top + 5;
|
rc1.left = rc.left - 5;
|
rc1.right = rc.left + 5;
|
|
dc.Rectangle(rc1);
|
|
rc1.top = rc.top - 5;
|
rc1.bottom = rc.top + 5;
|
rc1.left = rc.right - 5;
|
rc1.right = rc.right + 5;
|
|
dc.Rectangle(rc1);
|
|
rc1.top = rc.bottom - 5;
|
rc1.bottom = rc.bottom + 5;
|
rc1.left = rc.left - 5;
|
rc1.right = rc.left + 5;
|
|
dc.Rectangle(rc1);
|
|
rc1.top = rc.bottom - 5;
|
rc1.bottom = rc.bottom + 5;
|
rc1.left = rc.right - 5;
|
rc1.right = rc.right + 5;
|
|
dc.Rectangle(rc1);
|
}
|
|
switch((*it)->nAreaType)
|
{
|
case 0:
|
dc.TextOut(rc.left ,rc.top,_T("Defect Exception"));
|
break;
|
|
case 1:
|
dc.TextOut(rc.left ,rc.top,_T("Measure Area"));
|
break;
|
|
case 2:
|
dc.TextOut(rc.left ,rc.top,_T("VCR"));
|
break;
|
}
|
}
|
}
|
|
}
|
|
dc.SelectObject(pOldPen);
|
dc.SelectObject(pOldBrush);
|
|
hackBrush1.DeleteObject();
|
hackBrush2.DeleteObject();
|
}
|
|
|
|
void CFrameImg::DrawUserDefectArea(CDC &dc)
|
{
|
if(m_pGlassData == NULL || m_pRecipe == NULL)
|
return;
|
|
INS_EDGE_RESULT_INFO *pResInfo = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
USER_DEFECT_AREA_LIST *pList = m_pRecipe->GetUserDefectList((DimensionDir)m_nSide);
|
|
if(pList == NULL || pResInfo == NULL)
|
return;
|
|
if ((pList->empty() == false))// && (pResInfo->ptMark[0].x > 0) && (pResInfo->ptMark[0].y > 0))
|
{
|
CPen penRed(PS_SOLID, 2, RGB(255,165,0)), *pOldPen;
|
CRect rc,rc1;
|
|
pOldPen = dc.SelectObject(&penRed);
|
dc.SetTextColor(m_st_GdiItem.colorOrange);
|
|
unsigned int list_index = 0;
|
|
for (itUSER_DEFECT_AREA_LIST it = pList->begin(); it != pList->end(); ++it)
|
{
|
rc.left = it->x - m_ptOrg.x + (int)pResInfo->ptMark[0].x;
|
rc.top = it->y - m_ptOrg.y + (int)pResInfo->ptMark[0].y;
|
rc.right = rc.left + it->area_width;
|
rc.bottom = rc.top + it->area_height;
|
|
rc.top = int(rc.top * m_dZoom);
|
rc.bottom = int(rc.bottom * m_dZoom);
|
rc.left = int(rc.left * m_dZoom);
|
rc.right = int(rc.right * m_dZoom);
|
|
Draw_Rectangle(dc, rc);
|
|
CString strAreaText;
|
|
strAreaText.Format(_T("User Defect %d"), list_index);
|
|
dc.TextOut(rc.left, rc.top-20, strAreaText);
|
|
list_index++;
|
}
|
|
dc.SelectObject(pOldPen);
|
}
|
}
|
|
void CFrameImg::SetGlassData(CGlass_Data *pGlassData)
|
{
|
m_pGlassData = pGlassData;
|
}
|
|
void CFrameImg::DrawProcessData(CDC &dc)
|
{
|
if(m_pGlassData == NULL)
|
return;
|
|
CPen pen(PS_SOLID , 3,RGB(0,0,255));
|
CPen pen2(PS_SOLID , 1,RGB(0,255,255));
|
CPen pen8(PS_SOLID , 1,RGB(0,0,255));
|
|
CPen *pOldPen;
|
int x, y,k =0;
|
SIZE szROI;
|
CString strTmp;
|
int nRefSide = m_nSide %4;
|
int nUpDn = 0;
|
if(m_nSide < 4) nUpDn = 0;
|
else nUpDn = 1;
|
int nPos = 50;
|
double dResH,dResV;
|
|
GetResolution(dResH,dResV);
|
|
pOldPen = (CPen*)dc.SelectObject(&pen);
|
dc.SetROP2(R2_COPYPEN);
|
|
dc.SelectObject(&pen2);
|
dc.SetBkMode(TRANSPARENT);
|
dc.SetTextColor(RGB(0,0,255));
|
|
CINSPECT_JUDGEMENT_PARM *pJudge = NULL;
|
if(m_pRecipe != NULL)
|
{
|
pJudge = m_pRecipe->GetJudgePrm();
|
strTmp.Format(_T("Ref:[%d]"),pJudge->grind[nUpDn][nRefSide].nRefernce);
|
}
|
|
dc.TextOut(120,3,strTmp);
|
// TFT CF LineÀ» ±×¸°´Ù.
|
|
szROI.cx = CHKMIN(int(m_WndRect.Width() / m_dZoom), m_szImg.cx);
|
szROI.cy = int(m_WndRect.Height() / m_dZoom);
|
|
y = (m_ptOrg.y) %m_szImg.cy;
|
|
BOOL bMark[3];
|
CvPoint2D32f ptMark[3];
|
|
int nHafMarkW = (int)(20 * m_dZoom);
|
int nHafMarkH = (int)(15 * m_dZoom);
|
|
|
if(m_pRecipe != NULL)
|
{
|
CALIGNMARK_PARM *pAlignPrm = m_pRecipe->GetAlignMarkPrm((DimensionDir)m_nSide);
|
|
for(int i=0;i<MAX_POS_MARKER_COUNT;i++)
|
{
|
if(pAlignPrm->IpMarkImg[0][i])
|
{
|
nHafMarkW = (int)((pAlignPrm->IpMarkImg[0][i]->width /2) * m_dZoom);
|
nHafMarkH = (int)((pAlignPrm->IpMarkImg[0][i]->height/2) * m_dZoom);
|
break;
|
}
|
}
|
}
|
|
ZeroMemory(ptMark,sizeof(CvPoint2D32f)*3);
|
ZeroMemory(bMark,sizeof(BOOL)*3);
|
|
if(m_pGlassData != NULL)
|
{
|
INS_EDGE_RESULT_INFO *pResInfo = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
if(pResInfo != NULL)
|
{
|
ptMark[0] = pResInfo->ptMark[0];
|
ptMark[1] = pResInfo->ptMark[1];
|
ptMark[2] = pResInfo->ptMark[2];
|
bMark[0] = pResInfo->bMark[0];
|
bMark[1] = pResInfo->bMark[1];
|
bMark[2] = pResInfo->bMark[2];
|
}
|
}
|
|
DrawResultLine(dc,ptMark);
|
|
DrawReferenceLine(dc,ptMark,bMark,nHafMarkW,nHafMarkH);
|
|
double dMinCircle1Y = 64997;
|
double dMinCircle1X = 500;
|
double dMinCircle2Y = 85658;
|
double dMinCircle2X = 500;
|
|
x = int((ptMark[1].x + (dMinCircle1X/dResH) - m_ptOrg.x) * m_dZoom) ;
|
y = int((ptMark[1].y - (dMinCircle1Y/dResV)- m_ptOrg.y) * m_dZoom) ;
|
|
dc.SelectObject(&pen8);
|
|
dc.MoveTo(x-7,y);
|
dc.LineTo(x+7,y);
|
dc.MoveTo(x,y-7);
|
dc.LineTo(x,y+7);
|
x = int((ptMark[1].x + (dMinCircle2X/dResH) - m_ptOrg.x) * m_dZoom) ;
|
y = int((ptMark[1].y - (dMinCircle2Y/dResV)- m_ptOrg.y) * m_dZoom) ;
|
|
dc.MoveTo(x-7,y);
|
dc.LineTo(x+7,y);
|
dc.MoveTo(x,y-7);
|
dc.LineTo(x,y+7);
|
|
// Corner¸¦ ±×¸°´Ù.
|
DrawCorner(dc,ptMark);
|
|
//DefectÀ» ±×¸°´Ù.
|
DrawDefect(dc);
|
|
DrawMeasureLine(dc,ptMark);
|
|
DrawCADProfiletLine(dc,ptMark);
|
|
DrawCADProfiletResult(dc,ptMark);
|
|
DrawCADRCutProfiletResult(dc,ptMark);
|
|
DrawCADRCutChamfertResult(dc,ptMark);
|
|
dc.SelectObject(pOldPen);
|
}
|
|
|
|
void CFrameImg::DrawMeasureLine(CDC &dc,CvPoint2D32f *ptMark)
|
{
|
if(m_pGlassData == NULL || m_pRecipe == NULL)
|
return;
|
|
if(IsAutoMeasureMode())
|
{
|
CPen pen2(PS_SOLID , 1,RGB(0,255,255));
|
|
dc.SelectObject(&pen2);
|
|
dc.SetTextColor(m_st_GdiItem.colorRed);
|
|
double dRefLine = 0;
|
double dOffsetX = 0.;
|
double dResH,dResV;
|
int nFrameIndex = m_ptOrg.y /m_szImg.cy;
|
int nRefSide = m_nSide %4;
|
|
INS_EDGE_RESULT_INFO *pInsResult = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
if(pInsResult == NULL)
|
return;
|
|
CINSPECT_JUDGEMENT_PARM *pInsJudge = m_pRecipe->GetJudgePrm();
|
|
GetResolution(dResH,dResV);
|
|
if((ptMark[1].y - ptMark[0].y) != 0)
|
dOffsetX = (ptMark[1].x - ptMark[0].x) / double(ptMark[1].y - ptMark[0].y);
|
|
dRefLine = pInsResult->nCompRefFrame[nFrameIndex] - m_ptOrg.x;
|
|
int x = (int)(dRefLine + 0.5);
|
int y;
|
|
if(m_ptMouseCurrent.y > ((ptMark[0].y - m_ptOrg.y) * m_dZoom)
|
&& m_ptMouseCurrent.y < ((ptMark[1].y - m_ptOrg.y) * m_dZoom))
|
{
|
CString strTmp;
|
int nValue;
|
|
int nTx = (int)(x * m_dZoom) - 40;
|
if(m_nSide < 4) // »óºÎ
|
{
|
// CF LINE
|
dc.MoveTo((int)((pInsResult->nGrindframe[0][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y);
|
dc.LineTo((int)(x * m_dZoom) , m_ptMouseCurrent.y);
|
|
dc.MoveTo((int)((pInsResult->nGrindframe[0][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y - 20);
|
dc.LineTo((int)((pInsResult->nGrindframe[0][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y + 20);
|
|
dc.MoveTo((int)((pInsResult->nGrindframe[1][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y - 20);
|
dc.LineTo((int)((pInsResult->nGrindframe[1][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y + 20);
|
|
// Mark Line Pos
|
dc.MoveTo((int)(x * m_dZoom) , m_ptMouseCurrent.y - 20);
|
dc.LineTo((int)(x * m_dZoom) , m_ptMouseCurrent.y + 20);
|
|
|
nValue = int(abs(pInsResult->nGrindframe[0][nFrameIndex] - (x +m_ptOrg.x)) * dResH);
|
|
y = (int)((ptMark[0].x) * m_dZoom) + 5;
|
strTmp.Format(_T("CF : %d um"),nValue);
|
dc.TextOut( nTx ,m_ptMouseCurrent.y + 15,strTmp);
|
|
nValue = CHKMAX(pInsJudge->grind[0][nRefSide].nRefernce,pInsJudge->grind[0][nRefSide].nRefernce)
|
- (int)(fabs(pInsResult->nGrindframe[1][nFrameIndex] - (dRefLine + m_ptOrg.x)) * dResH);
|
|
strTmp.Format(_T("GRIND : %d um"),pInsResult->nGrindData[nFrameIndex]);
|
//strTmp.Format("GRIND : %d um",nValue);
|
dc.TextOut( nTx ,m_ptMouseCurrent.y + 30,strTmp);
|
}
|
else // ÇϺÎ
|
{
|
// TFT LINE
|
dc.MoveTo((int)((pInsResult->nGrindframe[0][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y);
|
dc.LineTo((int)(x * m_dZoom) , m_ptMouseCurrent.y);
|
|
dc.MoveTo((int)((pInsResult->nGrindframe[0][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y - 20);
|
dc.LineTo((int)((pInsResult->nGrindframe[0][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y + 20);
|
|
dc.MoveTo((int)((pInsResult->nGrindframe[1][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y - 20);
|
dc.LineTo((int)((pInsResult->nGrindframe[1][nFrameIndex]- m_ptOrg.x) * m_dZoom) , m_ptMouseCurrent.y + 20);
|
|
// Mark Line Pos
|
dc.MoveTo((int)(x * m_dZoom) , m_ptMouseCurrent.y - 20);
|
dc.LineTo((int)(x * m_dZoom) , m_ptMouseCurrent.y + 20);
|
|
nValue = int(fabs(pInsResult->nGrindframe[0][nFrameIndex] - (dRefLine +m_ptOrg.x)) * dResH);
|
|
y = (int)((ptMark[0].x) * m_dZoom);
|
strTmp.Format(_T("TFT : %d um"),nValue);
|
dc.TextOut(nTx ,m_ptMouseCurrent.y + 15,strTmp);
|
|
nValue = CHKMAX(pInsJudge->grind[0][nRefSide].nRefernce,pInsJudge->grind[0][nRefSide].nRefernce)
|
- (int)(fabs(pInsResult->nGrindframe[1][nFrameIndex] - (dRefLine + m_ptOrg.x)) * dResH);
|
|
//strTmp.Format("GRIND : %d um",nValue);
|
strTmp.Format(_T("GRIND : %d um"),pInsResult->nGrindData[nFrameIndex]);
|
dc.TextOut(nTx ,m_ptMouseCurrent.y + 30,strTmp);
|
}
|
}
|
}
|
}
|
|
void CFrameImg::DrawDefect(CDC &dc)
|
{
|
if(m_pGlassData == NULL)
|
return;
|
|
CPen pen5(PS_SOLID , 1,m_st_GdiItem.colorRed);
|
CPen pen_OK(PS_SOLID , 1,m_st_GdiItem.colorOrange);
|
|
double dResH,dResV;
|
int iDefect;
|
CRect rcTmp,rcOrg;
|
int nDefect = m_pGlassData->GetTotalDefectCount();
|
CInspectDefect *pDefect = NULL;
|
|
GetResolution(dResH,dResV);
|
|
dc.SelectObject(&pen5);
|
|
for(iDefect = 0; iDefect < nDefect; iDefect++)
|
{
|
pDefect = m_pGlassData->GetDefect(iDefect);
|
if(pDefect == NULL)
|
continue;
|
|
if(pDefect->m_nSideLoc != m_nSide)
|
continue;
|
|
if(pDefect->m_bJudgeDefect == TRUE) dc.SelectObject(&pen5);
|
else dc.SelectObject(&pen_OK);
|
|
rcOrg.left = (LONG)(pDefect->m_nPixelConv);
|
rcOrg.top = (LONG)(pDefect->m_nPixelScan);
|
rcOrg.right = rcOrg.left+pDefect->m_sPixelWidth;
|
rcOrg.bottom = rcOrg.top+pDefect->m_sPixelHeight;
|
|
rcTmp.left = int((rcOrg.left - m_ptOrg.x ) * m_dZoom);
|
rcTmp.right = int((rcOrg.right - m_ptOrg.x ) * m_dZoom);
|
rcTmp.top = int((rcOrg.top - m_ptOrg.y) * m_dZoom);
|
rcTmp.bottom = int((rcOrg.bottom - m_ptOrg.y) * m_dZoom);
|
|
if(rcTmp.top < 0 && rcTmp.bottom > 0
|
|| rcTmp.top > 0 && rcTmp.top < m_WndRect.bottom +1
|
|| rcTmp.bottom > 0 && rcTmp.bottom < m_WndRect.bottom +1)
|
{
|
dc.MoveTo(int((rcOrg.left - m_ptOrg.x ) * m_dZoom) , int((rcOrg.top - m_ptOrg.y) * m_dZoom));
|
dc.LineTo(int((rcOrg.right - m_ptOrg.x ) * m_dZoom) , int((rcOrg.top - m_ptOrg.y) * m_dZoom));
|
dc.LineTo(int((rcOrg.right - m_ptOrg.x ) * m_dZoom) , int((rcOrg.bottom - m_ptOrg.y) * m_dZoom));
|
dc.LineTo(int((rcOrg.left - m_ptOrg.x ) * m_dZoom) , int((rcOrg.bottom - m_ptOrg.y) * m_dZoom));
|
dc.LineTo(int((rcOrg.left - m_ptOrg.x ) * m_dZoom) , int((rcOrg.top - m_ptOrg.y) * m_dZoom));
|
}
|
}
|
}
|
|
void CFrameImg::DrawResultLine(CDC &dc,CvPoint2D32f *ptMark)
|
{
|
if(m_nSide < 0 || m_nSide >= MAX_DIMENSION_COUNT)
|
return;
|
|
if(m_bitModeDisplay[MODE_SHOW_MEASURE_LINE])
|
{
|
CPen pen(PS_SOLID , 3,RGB(0,0,255));
|
CPen pen6(PS_SOLID , 1,RGB(0, 255, 128));
|
CPen pen7(PS_SOLID , 1,RGB(255, 255, 128));
|
|
int y;
|
SIZE szROI;
|
CString strTmp;
|
int nFrameIndex = m_ptOrg.y /m_szImg.cy;
|
|
INS_EDGE_RESULT_INFO *pResInfo = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
if(pResInfo == NULL)
|
return;
|
|
int nGlassStart = pResInfo->nGlassStartLine;
|
int nGlassEnd = pResInfo->nGlassEndLine;
|
|
if(nGlassStart <= 0 || nGlassEnd <= 0)
|
return;
|
|
CINSPECT_JUDGEMENT_PARM *pJudge = NULL;
|
if(m_pRecipe != NULL)
|
{
|
pJudge = m_pRecipe->GetJudgePrm();
|
}
|
|
szROI.cx = CHKMIN(int(m_WndRect.Width() / m_dZoom), m_szImg.cx);
|
szROI.cy = int(m_WndRect.Height() / m_dZoom);
|
|
y = (m_ptOrg.y) %m_szImg.cy;
|
|
(CPen*)dc.SelectObject(&pen);
|
if(nGlassStart > 0 )
|
{
|
y = int((pResInfo->nGlassStartLine - m_ptOrg.y) * m_dZoom);
|
|
if( y > -1 && y < szROI.cy)
|
{
|
dc.MoveTo(0,y);
|
dc.LineTo(m_WndRect.Width(),y);
|
|
strTmp.Format(_T("1.First Area"));
|
dc.TextOut(10,y+10,strTmp);
|
}
|
}
|
|
if(nGlassEnd > 0 )
|
{
|
y = int((pResInfo->nGlassEndLine - m_ptOrg.y) * m_dZoom);
|
|
if( y > -1 && y < szROI.cy)
|
{
|
dc.MoveTo(0,y);
|
dc.LineTo(m_WndRect.Width(),y);
|
|
strTmp.Format(_T("3.Third Area"));
|
dc.TextOut(10,y-20,strTmp);
|
}
|
}
|
|
int RangeST = 0;
|
if(pJudge != NULL)
|
RangeST = pJudge->defect[m_nSide][1].nRangeStart;
|
|
if(RangeST >= 0 )
|
{
|
y = int((pResInfo->nGlassStartLine +RangeST - m_ptOrg.y) * m_dZoom);
|
if( y > -1 /* && y < szROI.cy*/)
|
{
|
dc.MoveTo(0,y);
|
dc.LineTo(m_WndRect.Width(),y);
|
|
strTmp.Format(_T("1.First Area"));
|
dc.TextOut(10,y-20,strTmp);
|
|
strTmp.Format(_T("2.Secound Area"));
|
dc.TextOut(10,y+10,strTmp);
|
}
|
}
|
|
int RangeED = 0;
|
if(pJudge != NULL)
|
pJudge->defect[m_nSide][1].nRangeEnd;
|
|
if(RangeED >= 0 )
|
{
|
y = int((pResInfo->nGlassStartLine +RangeED - m_ptOrg.y) * m_dZoom);
|
if( y > -1 /* && y < szROI.cy*/)
|
{
|
dc.MoveTo(0,y);
|
dc.LineTo(m_WndRect.Width(),y);
|
|
strTmp.Format(_T("2.Secound Area"));
|
dc.TextOut(10,y-20,strTmp);
|
|
strTmp.Format(_T("3.Third Area"));
|
dc.TextOut(10,y+10,strTmp);
|
}
|
}
|
|
dc.SelectObject(&pen7 );
|
dc.MoveTo(int((pResInfo->nGrindframe[0][nFrameIndex]- m_ptOrg.x) * m_dZoom),0);
|
// dc.MoveTo(int((pResInfo->nGrindframe[0][nFrameIndex]- m_ptOrg.x) * m_dZoom), int(CHKMAX(0 ,(pResInfo->nGlassStartLine - m_ptOrg.y)* m_dZoom )));
|
|
if(ptMark[1].y > 0)
|
{
|
dc.LineTo(int((pResInfo->nGrindframe[0][nFrameIndex]- m_ptOrg.x)* m_dZoom),m_WndRect.Height());
|
//dc.LineTo(int((pResInfo->nGrindframe[0][nFrameIndex]- m_ptOrg.x)* m_dZoom),CHKMIN(m_WndRect.Height(),int((pResInfo->nGlassEndLine - m_ptOrg.y) * m_dZoom )));
|
}
|
else
|
{
|
dc.LineTo(int((pResInfo->nGrindframe[0][nFrameIndex]- m_ptOrg.x) * m_dZoom),int(m_szImg.cy * m_dZoom));
|
|
if(m_dZoom < 1)
|
{
|
for(int i = 1 ; i < 5 ; i++)
|
{
|
if(m_szImg.cy * i * m_dZoom < m_WndRect.Height())
|
{
|
dc.MoveTo(int((pResInfo->nGrindframe[0][nFrameIndex+ i]- m_ptOrg.x) * m_dZoom),int(CHKMAX(m_szImg.cy *i * m_dZoom ,pResInfo->nGlassStartLine - m_ptOrg.y)* m_dZoom));
|
dc.LineTo(int((pResInfo->nGrindframe[0][nFrameIndex+ i]- m_ptOrg.x) * m_dZoom),int(m_szImg.cy* (i+1) * m_dZoom));
|
}
|
}
|
}
|
}
|
|
dc.SelectObject(&pen6);
|
//dc.MoveTo(int((pResInfo->nGrindframe[1][nFrameIndex]- m_ptOrg.x) * m_dZoom),int(CHKMAX(0 ,(pResInfo->nGlassStartLine - m_ptOrg.y)* m_dZoom )));
|
dc.MoveTo(int((pResInfo->nGrindframe[1][nFrameIndex]- m_ptOrg.x) * m_dZoom),0);
|
|
if(ptMark[1].y)
|
dc.LineTo(int((pResInfo->nGrindframe[1][nFrameIndex]- m_ptOrg.x)* m_dZoom),m_WndRect.Height());
|
//dc.LineTo(int((pResInfo->nGrindframe[1][nFrameIndex]- m_ptOrg.x)* m_dZoom),CHKMIN(m_WndRect.Height(),int((pResInfo->nGlassEndLine - m_ptOrg.y) * m_dZoom)) );
|
else
|
{
|
dc.LineTo(int((pResInfo->nGrindframe[1][nFrameIndex]- m_ptOrg.x) * m_dZoom) ,int(m_szImg.cy * m_dZoom));
|
|
for(int i = 1 ; i < 5 ; i++)
|
{
|
if(m_szImg.cy * i * m_dZoom < m_WndRect.Height()+1)
|
{
|
dc.MoveTo(int((pResInfo->nGrindframe[1][nFrameIndex+ i]- m_ptOrg.x) * m_dZoom),int(CHKMAX(m_szImg.cy *i * m_dZoom ,pResInfo->nGlassStartLine )* m_dZoom - m_ptOrg.y));
|
dc.LineTo(int((pResInfo->nGrindframe[1][nFrameIndex+ i]- m_ptOrg.x) * m_dZoom),int(m_szImg.cy* (i+1) * m_dZoom));
|
}
|
}
|
}
|
}
|
}
|
|
void CFrameImg::DrawReferenceLine(CDC &dc,CvPoint2D32f *ptMark,BOOL *bMark,int nHafMarkW,int nHafMarkH)
|
{
|
if(m_bitModeDisplay[MODE_SHOW_REF_LINE])
|
{
|
CPen pen2(PS_SOLID , 1,RGB(0,255,255));
|
CPen pen5(PS_SOLID , 1,m_st_GdiItem.colorRed);
|
CPen pen3(PS_DASH , 1,RGB(255,0,255));
|
|
INS_EDGE_RESULT_INFO *pResInfo = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
if(pResInfo == NULL)
|
return;
|
|
int nFrameIndex = m_ptOrg.y /m_szImg.cy; //(m_ptOrg.y - (m_szImg.cy - m_WndRect.Height()))/m_szImg.cy;
|
int nRefSide = m_nSide %4;
|
int nUpDn = 0;
|
if(m_nSide < 4) nUpDn = 0;
|
else nUpDn = 1;
|
int x,y;
|
double dResH,dResV;
|
|
GetResolution(dResH,dResV);
|
|
// ¸¶Å©¸¦ ±×¸°´Ù.
|
dc.SelectObject(&pen2);
|
|
if(bMark[0])
|
{
|
dc.SelectObject(&pen2);
|
x = int((ptMark[0].x - m_ptOrg.x) * m_dZoom) - nHafMarkW;
|
y = int((ptMark[0].y - m_ptOrg.y) * m_dZoom) - nHafMarkH;
|
|
dc.MoveTo(x,y);
|
dc.LineTo(x + nHafMarkW *2,y);
|
dc.LineTo(x + nHafMarkW *2,y + nHafMarkH*2);
|
dc.LineTo(x ,y + nHafMarkH*2);
|
dc.LineTo(x ,y);
|
|
dc.MoveTo(x ,y + nHafMarkH);
|
dc.LineTo(x + nHafMarkW *2 ,y + nHafMarkH);
|
}
|
else
|
{
|
dc.SelectObject(&pen5);
|
x = int((ptMark[0].x - m_ptOrg.x) * m_dZoom) - nHafMarkW;
|
y = int((ptMark[0].y - m_ptOrg.y) * m_dZoom) - nHafMarkH;
|
|
dc.MoveTo(x,y);
|
dc.LineTo(x + nHafMarkW *2,y);
|
dc.LineTo(x + nHafMarkW *2,y + nHafMarkH*2);
|
dc.LineTo(x ,y + nHafMarkH*2);
|
dc.LineTo(x ,y);
|
|
dc.MoveTo(x ,y + nHafMarkH);
|
dc.LineTo(x + nHafMarkW *2 ,y + nHafMarkH);
|
}
|
|
if(bMark[1])
|
{
|
dc.SelectObject(&pen2);
|
x = int((ptMark[1].x - m_ptOrg.x) * m_dZoom) - nHafMarkW;
|
y = int((ptMark[1].y - m_ptOrg.y) * m_dZoom) - nHafMarkH;
|
|
dc.MoveTo(x,y);
|
dc.LineTo(x + nHafMarkW *2,y);
|
dc.LineTo(x + nHafMarkW *2,y + nHafMarkH*2);
|
dc.LineTo(x ,y + nHafMarkH*2);
|
dc.LineTo(x ,y);
|
|
dc.MoveTo(x ,y + nHafMarkH);
|
dc.LineTo(x + nHafMarkW *2 ,y + nHafMarkH);
|
}
|
else
|
{
|
dc.SelectObject(&pen5);
|
x = int((ptMark[1].x - m_ptOrg.x) * m_dZoom) - nHafMarkW;
|
y = int((ptMark[1].y - m_ptOrg.y) * m_dZoom) - nHafMarkH;
|
|
dc.MoveTo(x,y);
|
dc.LineTo(x + nHafMarkW *2,y);
|
dc.LineTo(x + nHafMarkW *2,y + nHafMarkH*2);
|
dc.LineTo(x ,y + nHafMarkH*2);
|
dc.LineTo(x ,y);
|
|
dc.MoveTo(x ,y + nHafMarkH);
|
dc.LineTo(x + nHafMarkW *2 ,y + nHafMarkH);
|
}
|
|
if(bMark[2])
|
{
|
dc.SelectObject(&pen2);
|
x = int((ptMark[2].x - m_ptOrg.x) * m_dZoom) - nHafMarkW;
|
y = int((ptMark[2].y - m_ptOrg.y) * m_dZoom) - nHafMarkH;
|
|
dc.MoveTo(x,y);
|
dc.LineTo(x + nHafMarkW *2,y);
|
dc.LineTo(x + nHafMarkW *2,y + nHafMarkH*2);
|
dc.LineTo(x ,y + nHafMarkH*2);
|
dc.LineTo(x ,y);
|
|
dc.MoveTo(x ,y + nHafMarkH);
|
dc.LineTo(x + nHafMarkW *2 ,y + nHafMarkH);
|
}
|
else
|
{
|
dc.SelectObject(&pen5);
|
x = int((ptMark[2].x - m_ptOrg.x) * m_dZoom) - nHafMarkW;
|
y = int((ptMark[2].y - m_ptOrg.y) * m_dZoom) - nHafMarkH;
|
|
dc.MoveTo(x,y);
|
dc.LineTo(x + nHafMarkW *2,y);
|
dc.LineTo(x + nHafMarkW *2,y + nHafMarkH*2);
|
dc.LineTo(x ,y + nHafMarkH*2);
|
dc.LineTo(x ,y);
|
|
dc.MoveTo(x ,y + nHafMarkH);
|
dc.LineTo(x + nHafMarkW *2 ,y + nHafMarkH);
|
}
|
|
dc.SelectObject(&pen2);
|
dc.SetBkMode(TRANSPARENT);
|
|
x = int((ptMark[0].x - pResInfo->nMarkToEdge_X[0] - m_ptOrg.x) * m_dZoom);
|
y = int((ptMark[0].y - m_ptOrg.y - pResInfo->nMarkToEdge_Y[0]) * m_dZoom);
|
|
|
dc.MoveTo(x -20 ,y);
|
dc.LineTo(x - 5 ,y);
|
dc.MoveTo(x -10 ,y -5);
|
dc.LineTo(x - 5 ,y);
|
dc.LineTo(x -10 ,y +5);
|
|
|
x = int((ptMark[0].x - pResInfo->nMarkToEdge_X[0]- m_ptOrg.x) * m_dZoom);
|
y = int((ptMark[0].y - m_ptOrg.y - pResInfo->nMarkToEdge_Y[0]) * m_dZoom);
|
|
|
dc.MoveTo(x -20 ,y);
|
dc.LineTo(x - 5 ,y);
|
dc.MoveTo(x -10 ,y -5);
|
dc.LineTo(x - 5 ,y);
|
dc.LineTo(x -10 ,y +5);
|
|
|
x = int((ptMark[1].x - pResInfo->nMarkToEdge_X[1]- m_ptOrg.x) * m_dZoom);
|
y = int((ptMark[1].y - m_ptOrg.y + pResInfo->nMarkToEdge_Y[1]) * m_dZoom);
|
|
dc.MoveTo(x -20 ,y);
|
dc.LineTo(x - 5 ,y);
|
dc.MoveTo(x -10 ,y -5);
|
dc.LineTo(x - 5 ,y);
|
dc.LineTo(x -10 ,y +5);
|
|
x = int((ptMark[1].x - pResInfo->nMarkToEdge_X[0]- m_ptOrg.x) * m_dZoom);
|
y = int((ptMark[1].y - m_ptOrg.y + pResInfo->nMarkToEdge_Y[1]) * m_dZoom);
|
|
dc.MoveTo(x -20 ,y);
|
dc.LineTo(x - 5 ,y);
|
dc.MoveTo(x -10 ,y -5);
|
dc.LineTo(x - 5 ,y);
|
dc.LineTo(x -10 ,y +5);
|
|
// Mark Line
|
dc.SelectObject(&pen3);
|
x = int((ptMark[0].x - m_ptOrg.x) * m_dZoom) ;
|
y = int((ptMark[0].y - m_ptOrg.y) * m_dZoom) ;
|
dc.MoveTo(x,y);
|
x = int((ptMark[1].x - m_ptOrg.x) * m_dZoom) ;
|
y = int((ptMark[1].y - m_ptOrg.y) * m_dZoom) ;
|
dc.LineTo(x ,y);
|
|
// if(m_pRecipe != NULL)
|
// {
|
// CINSPECT_JUDGEMENT_PARM *pJuge = m_pRecipe->GetJudgePrm();
|
// x = int((ptMark[0].x - m_ptOrg.x - int(pJuge->cutting[nUpDn][nRefSide].nRefernce / dResH)) * m_dZoom) ;
|
// y = int((ptMark[0].y - m_ptOrg.y ) * m_dZoom ) ;
|
// dc.MoveTo(x,y);
|
// x = int((ptMark[1].x - m_ptOrg.x - int(pJuge->cutting[nUpDn][nRefSide].nRefernce / dResH)) * m_dZoom) ;
|
// y = int((ptMark[1].y - m_ptOrg.y ) * m_dZoom) ;
|
// dc.LineTo(x ,y);
|
// }
|
|
double dD = 0.0010245;
|
DWORD data = long(dD * 1000);
|
|
}
|
}
|
|
void CFrameImg::DrawCorner(CDC &dc,CvPoint2D32f *ptMark)
|
{
|
if(ptMark[0].x > 0)
|
{
|
CPen pen3(PS_DASH , 1,RGB(255,0,255));
|
CPen pen7(PS_SOLID , 1,m_st_GdiItem.colorYellow);
|
|
int i=0,j=0;
|
int x,y;
|
|
INS_EDGE_RESULT_INFO *pResInfo = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
if(pResInfo == NULL)
|
return;
|
|
dc.SelectObject(&pen3);
|
x = int((pResInfo->rcCorner[0].left - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].top - m_ptOrg.y- 20) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
x = int((pResInfo->rcCorner[0].left - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].top - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
x = int((pResInfo->rcCorner[0].right - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].top - m_ptOrg.y -20) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
x = int((pResInfo->rcCorner[0].right - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].top - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
x = int((pResInfo->rcCorner[0].left - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].top - m_ptOrg.y -10) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
x = int((pResInfo->rcCorner[0].right - m_ptOrg.x ) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].top - m_ptOrg.y -10) * m_dZoom);
|
dc.LineTo(x,y);
|
|
x = int((pResInfo->rcCorner[0].left - m_ptOrg.x-20) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].top - m_ptOrg.y ) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
|
x = int((pResInfo->rcCorner[0].left - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].top - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
x = int((pResInfo->rcCorner[0].left - m_ptOrg.x - 20) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].bottom - m_ptOrg.y ) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
|
x = int((pResInfo->rcCorner[0].left - m_ptOrg.x ) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].bottom - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
|
|
x = int((pResInfo->rcCorner[0].left - m_ptOrg.x - 10) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].top - m_ptOrg.y ) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
|
x = int((pResInfo->rcCorner[0].left - m_ptOrg.x -10) * m_dZoom);
|
y = int((pResInfo->rcCorner[0].bottom - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
//===================================================
|
|
x = int((pResInfo->rcCorner[1].left - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].bottom - m_ptOrg.y+ 20) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
|
x = int((pResInfo->rcCorner[1].left - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].bottom - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
|
|
x = int((pResInfo->rcCorner[1].right - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].bottom - m_ptOrg.y +20) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
|
x = int((pResInfo->rcCorner[1].right - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].bottom - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
|
|
x = int((pResInfo->rcCorner[1].left - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].bottom - m_ptOrg.y +10) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
x = int((pResInfo->rcCorner[1].right - m_ptOrg.x ) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].bottom - m_ptOrg.y +10) * m_dZoom);
|
dc.LineTo(x,y);
|
|
x = int((pResInfo->rcCorner[1].left - m_ptOrg.x-20) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].top - m_ptOrg.y ) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
|
x = int((pResInfo->rcCorner[1].left - m_ptOrg.x) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].top - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
x = int((pResInfo->rcCorner[1].left - m_ptOrg.x - 20) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].bottom - m_ptOrg.y ) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
|
x = int((pResInfo->rcCorner[1].left - m_ptOrg.x ) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].bottom - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
|
|
x = int((pResInfo->rcCorner[1].left - m_ptOrg.x - 10) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].top - m_ptOrg.y ) * m_dZoom);
|
dc.MoveTo(x,y);
|
|
|
x = int((pResInfo->rcCorner[1].left - m_ptOrg.x -10) * m_dZoom);
|
y = int((pResInfo->rcCorner[1].bottom - m_ptOrg.y ) * m_dZoom);
|
dc.LineTo(x,y);
|
|
dc.SelectObject(&pen7);
|
}
|
}
|
|
void CFrameImg::DrawHoleArea(CDC &dc)
|
{
|
if(m_pRecipe == NULL)
|
return;
|
|
CHOLEINSPECT_PARM* pHoleInsParm = &m_pRecipe->m_HoleInspectParm;
|
|
if(pHoleInsParm == NULL || pHoleInsParm->m_vecHoleInsParam.empty())
|
return;
|
|
if(m_pGlassData == NULL)
|
return;
|
|
INS_EDGE_RESULT_INFO *pResInfo = m_pGlassData->GetEdgeResultInfo((DimensionDir)m_nSide);
|
if(pResInfo->ptMark[0].x < 1 || pResInfo->ptMark[0].y < 1)
|
return;
|
|
double dOffsetX = (pResInfo->ptMark[1].x - pResInfo->ptMark[0].x) / double(pResInfo->ptMark[1].y - pResInfo->ptMark[0].y);
|
|
|
itEXCEPTION_AREA_LIST it;
|
CPen penRed(PS_SOLID, 2, RGB(255,0,0)), *pOldPen;
|
CBrush hackBrush1,hackBrush2,*pOldBrush;
|
CRect rc,rc1;
|
hackBrush1.CreateHatchBrush(HS_BDIAGONAL, RGB(50,255,255));
|
hackBrush2.CreateHatchBrush(HS_DIAGCROSS, RGB(255,0,255));
|
|
pOldPen = dc.SelectObject(&penRed);
|
pOldBrush = dc.SelectObject(&hackBrush1);
|
|
CString strHole;
|
|
for(int i=0; i<pHoleInsParm->m_vecHoleInsParam.size(); i++)
|
{
|
if(pHoleInsParm->m_vecHoleInsParam[i].m_nSideIdx != m_nSide)
|
continue;
|
|
dc.SetTextColor(RGB(255,255,0));
|
|
CRect rtArea = pHoleInsParm->m_vecHoleInsParam[i].m_rtArea;
|
|
rc.top = rtArea.top - m_ptOrg.y + (int)pResInfo->ptMark[0].y;
|
rc.bottom = rtArea.bottom - m_ptOrg.y + (int)pResInfo->ptMark[0].y;
|
rc.left = rtArea.left - m_ptOrg.x + (int)pResInfo->ptMark[0].x + int(rtArea.top * dOffsetX);
|
rc.right = rtArea.right - m_ptOrg.x + (int)pResInfo->ptMark[0].x + int(rtArea.top * dOffsetX);
|
|
rc.top = int(rc.top * m_dZoom);
|
rc.bottom = int(rc.bottom * m_dZoom);
|
rc.left = int(rc.left * m_dZoom);
|
rc.right = int(rc.right * m_dZoom);
|
|
dc.SelectObject(&hackBrush1);
|
dc.Rectangle(rc);
|
|
strHole.Format(_T("Hole Inspect Area [%d]"), i+1);
|
dc.TextOut(rc.left ,rc.top, strHole);
|
}
|
|
dc.SelectObject(pOldPen);
|
dc.SelectObject(pOldBrush);
|
|
hackBrush1.DeleteObject();
|
hackBrush2.DeleteObject();
|
}
|
|
void CFrameImg::UpdataVisionResult(void) {
|
/* code */
|
if (!IsWindowVisible())
|
return;
|
|
CDC *pDC = GetDC();
|
CDC memDC;
|
CBitmap Bitmap, *pOldBitmap;
|
SIZE bitmapSize;
|
CFont *pOldFont = NULL;
|
|
memDC.CreateCompatibleDC(pDC);
|
Bitmap.CreateCompatibleBitmap(pDC, m_WndRect.Width(), m_WndRect.Height());
|
|
bitmapSize.cx = int(m_szImg.cx * m_dZoom);
|
bitmapSize.cy = m_szImg.cy;
|
|
m_pBmInfo->bmiHeader.biWidth = m_szImg.cx;
|
m_pBmInfo->bmiHeader.biHeight = -int(m_WndRect.Height() / m_dZoom);//(m_szImg.cy);
|
m_pBmInfo->bmiHeader.biSizeImage = m_pBmInfo->bmiHeader.biWidth * m_pBmInfo->bmiHeader.biHeight;//m_szImg.cx * (m_szImg.cy / m_dZoom);
|
|
memDC.SetStretchBltMode(COLORONCOLOR);
|
|
//Bitmap.CreateCompatibleBitmap(pDC,bitmapSize.cx,bitmapSize.cy);
|
//Bitmap.CreateCompatibleBitmap(pDC,m_WndRect.Width(),m_WndRect.Height());
|
pOldBitmap = (CBitmap*)memDC.SelectObject(&Bitmap);
|
if (m_pBuffer)
|
{
|
// StretchDIBits(m_memDC.m_hDC, 0 , 0, bitmapSize.cx , bitmapSize.cy,
|
// m_ptOrg.x,0,m_pBmInfo->bmiHeader.biWidth,abs(m_pBmInfo->bmiHeader.biHeight),
|
// m_pBuffer,(BITMAPINFO*)m_pBmInfo,DIB_RGB_COLORS,SRCCOPY);
|
|
|
StretchDIBits(memDC.m_hDC, 0, 0, m_WndRect.Width(), m_WndRect.Height(),
|
m_ptOrg.x, 0, int(m_WndRect.Width() / m_dZoom), int(m_WndRect.Height() / m_dZoom), //m_WndRect.Width(),m_WndRect.Height(),
|
m_pBuffer, (BITMAPINFO*)m_pBmInfo, DIB_RGB_COLORS, SRCCOPY);
|
}
|
|
memDC.SetBkMode(TRANSPARENT);
|
memDC.SetTextColor(RGB(0, 0, 255));
|
//memDC.SetTextColor(RGB(45,200,45));
|
CString str;
|
str.Format(_T("%d"), m_ptOrg.y);
|
memDC.TextOut(m_WndRect.Width() - 50, 10, str);
|
|
int nTmp = int((m_ptMouseCurrent.y / m_dZoom) * m_szImg.cx + m_ptOrg.x + (m_ptMouseCurrent.x / m_dZoom));
|
|
int nMaxLine = MAX_LIMIT_LINE * IMAGE_WIDTH;
|
|
if (m_szTotBuffer.cy > 0)
|
{
|
nMaxLine = (m_szTotBuffer.cy - 1) * IMAGE_HEIGHT * m_szTotBuffer.cx;
|
}
|
|
if (nTmp > -1 && nTmp < nMaxLine && m_ptOrg.y >= 0 && m_ptOrg.x >= 0 && m_pBuffer != NULL)
|
{
|
str.Format(_T("(%d / %d) [%d]"), m_ptOrg.x + int(m_ptMouseCurrent.x / m_dZoom), m_ptOrg.y + int(m_ptMouseCurrent.y / m_dZoom)
|
, m_pBuffer[nTmp]);
|
|
memDC.TextOut(10, m_WndRect.Height() - 40, str);
|
}
|
|
pOldFont = (CFont*)memDC.SelectObject(&m_sideFont);
|
memDC.SetTextColor(RGB(45, 200, 45));
|
memDC.TextOut(0, 0, PANEL_SIDE_NAME[m_nSide]);
|
memDC.SetBkMode(OPAQUE);
|
|
UpdateView_VisionResult(memDC);
|
|
|
pDC->BitBlt(0, 0, m_WndRect.Width(), m_WndRect.Height(), &memDC, 0, 0, SRCCOPY);
|
|
if (pOldFont) memDC.SelectObject(pOldFont);
|
|
memDC.SelectObject(pOldBitmap);
|
Bitmap.DeleteObject();
|
ReleaseDC(&memDC);
|
|
ReleaseDC(pDC);
|
}
|
|
void CFrameImg::UpDateView_MouseDownPos(CDC &dc) {
|
/* code */
|
if (m_pGlassData == NULL)
|
return;
|
|
if (!BlVision_GetVisionRecipe()->getVisionSetOpen())
|
return;
|
|
CPen pen(PS_SOLID, 1, RGB(255, 0, 255));
|
CBrush brush_Null;
|
brush_Null.CreateStockObject(NULL_BRUSH);
|
|
CPen* pOldPen = dc.SelectObject(&pen);
|
CBrush* pOldBrush = (CBrush*)dc.SelectObject(&brush_Null);
|
|
double dResH, dResV;
|
CRect rcTmp, rcOrg;
|
|
GetResolution(dResH, dResV);
|
|
dc.SelectObject(&pen);
|
|
dc.SelectObject(&pen);
|
CPoint ptMarkPos_wnd;
|
ptMarkPos_wnd.x = (int)((m_ptMouseDown.x - m_ptOrg.x) * m_dZoom);
|
ptMarkPos_wnd.y = (int)((m_ptMouseDown.y - m_ptOrg.y) * m_dZoom);
|
if (ptMarkPos_wnd.x > 0 && ptMarkPos_wnd.x < m_WndRect.right && ptMarkPos_wnd.y > 0 && ptMarkPos_wnd.y < m_WndRect.bottom) {
|
dc.MoveTo(ptMarkPos_wnd.x - 12, ptMarkPos_wnd.y - 12);
|
dc.LineTo(ptMarkPos_wnd.x + 12, ptMarkPos_wnd.y + 12);
|
dc.MoveTo(ptMarkPos_wnd.x + 12, ptMarkPos_wnd.y - 12);
|
dc.LineTo(ptMarkPos_wnd.x - 12, ptMarkPos_wnd.y + 12);
|
}
|
|
dc.SelectObject(pOldPen);
|
dc.SelectObject(pOldBrush);
|
brush_Null.DeleteObject();
|
}
|
|
void CFrameImg::UpdateView_VisionResult(CDC &dc) {
|
/* code */
|
DimensionDir eDir = (DimensionDir)(m_nSide);
|
CBlSideData *pSideData = BlVision_GetVisionRecipe()->getSideData(eDir);
|
if (NULL == pSideData) return;
|
|
int nCount = (int)(pSideData->m_vDispVisionResult.size());
|
if (nCount < 1) return;
|
|
if (m_pGlassData == NULL)
|
return;
|
|
CPen pen(PS_SOLID, 1, RGB(255, 0, 0));
|
CPen pen_SearchArea(PS_DASH, 1, RGB(255, 0, 255));
|
CPen pen_Line(PS_DASH, 1, RGB(0, 255, 255));
|
CPen roiPen(PS_SOLID, 1, RGB(0, 255, 255));
|
|
CBrush brush_Null;
|
brush_Null.CreateStockObject(NULL_BRUSH);
|
|
CPen* pOldPen = dc.SelectObject(&pen);
|
CBrush* pOldBrush = (CBrush*)dc.SelectObject(&brush_Null);
|
|
double dResH, dResV;
|
CRect rcTmp, rcOrg;
|
|
GetResolution(dResH, dResV);
|
|
dc.SelectObject(&pen);
|
|
for (int iDefect = 0; iDefect < nCount; iDefect++) {
|
DispVisionResult inf = pSideData->m_vDispVisionResult[iDefect];
|
int nType = inf.nType;
|
if (0 == nType) { //µã
|
dc.SelectObject(&pen);
|
CPoint ptMarkPos_wnd;
|
ptMarkPos_wnd.x = (int)((inf.pointX - m_ptOrg.x) * m_dZoom);
|
ptMarkPos_wnd.y = (int)((inf.pointY - m_ptOrg.y) * m_dZoom);
|
if (ptMarkPos_wnd.x > 0 && ptMarkPos_wnd.x < m_WndRect.right && ptMarkPos_wnd.y > 0 && ptMarkPos_wnd.y < m_WndRect.bottom) {
|
dc.MoveTo(ptMarkPos_wnd.x - 5, ptMarkPos_wnd.y - 5);
|
dc.LineTo(ptMarkPos_wnd.x + 5, ptMarkPos_wnd.y + 5);
|
dc.MoveTo(ptMarkPos_wnd.x + 5, ptMarkPos_wnd.y - 5);
|
dc.LineTo(ptMarkPos_wnd.x - 5, ptMarkPos_wnd.y + 5);
|
}
|
}
|
else if (1 == nType) { //¾ØÐÎ
|
if (1 == inf.showROI) {
|
dc.SelectObject(&roiPen);
|
}
|
else {
|
if (4 == inf.eVision) {
|
dc.SelectObject(&pen);
|
}
|
else {
|
dc.SelectObject(&pen_SearchArea);
|
}
|
}
|
CPoint pt0, pt1, pt;
|
pt0.x = (int)((inf.rectX1 - m_ptOrg.x) * m_dZoom);
|
pt0.y = (int)((inf.rectY1 - m_ptOrg.y) * m_dZoom);
|
pt1.x = (int)((inf.rectX2 - m_ptOrg.x) * m_dZoom);
|
pt1.y = (int)((inf.rectY2 - m_ptOrg.y) * m_dZoom);
|
pt.x = (int)(0.5 * (pt0.x + pt1.x));
|
pt.y = (int)(0.5 * (pt0.y + pt1.y));
|
if (pt.x > 0 && pt.x < m_WndRect.right && pt.y > 0 && pt.y < m_WndRect.bottom) {
|
CRect rtMarkSearchPos_wnd = CRect(pt0.x, pt0.y, pt1.x, pt1.y);
|
dc.Rectangle(rtMarkSearchPos_wnd);
|
}
|
}
|
else if (2 == nType) { //Ô²
|
dc.SelectObject(&pen);
|
CPoint pt;
|
pt.x = (int)((inf.circleX - m_ptOrg.x) * m_dZoom);
|
pt.y = (int)((inf.circleY - m_ptOrg.y) * m_dZoom);
|
int radius = (int)(inf.circleRadius * m_dZoom);
|
CPoint pt0, pt1;
|
pt0.x = pt.x - radius;
|
pt0.y = pt.y - radius;
|
pt1.x = pt.x + radius;
|
pt1.y = pt.y + radius;
|
if (pt.x > 0 && pt.x < m_WndRect.right && pt.y > 0 && pt.y < m_WndRect.bottom) {
|
CRect rtMarkSearchPos_wnd = CRect(pt0.x, pt0.y, pt1.x, pt1.y);
|
dc.Ellipse(rtMarkSearchPos_wnd);
|
}
|
}
|
else if (3 == nType) { //Ö±Ïß
|
dc.SelectObject(&pen_Line);
|
CPoint pt0, pt1, pt;
|
pt0.x = (int)((inf.rectX1 - m_ptOrg.x) * m_dZoom);
|
pt0.y = (int)((inf.rectY1 - m_ptOrg.y) * m_dZoom);
|
pt1.x = (int)((inf.rectX2 - m_ptOrg.x) * m_dZoom);
|
pt1.y = (int)((inf.rectY2 - m_ptOrg.y) * m_dZoom);
|
pt.x = (int)(0.5 * (pt0.x + pt1.x));
|
pt.y = (int)(0.5 * (pt0.y + pt1.y));
|
if (pt.x > 0 && pt.x < m_WndRect.right && pt.y > 0 && pt.y < m_WndRect.bottom) {
|
dc.MoveTo(pt0.x, pt0.y);
|
dc.LineTo(pt1.x, pt1.y);
|
}
|
}
|
else if (4 == nType) { //Îı¾
|
dc.SetBkMode(TRANSPARENT);
|
dc.SetTextColor(RGB(0, 0, 255));
|
CPoint pt;
|
pt.x = (int)((inf.pointX - m_ptOrg.x) * m_dZoom);
|
pt.y = (int)((inf.pointY - m_ptOrg.y) * m_dZoom);
|
dc.TextOut(pt.x - 80, pt.y, inf.strName);
|
}
|
}
|
|
dc.SelectObject(pOldPen);
|
dc.SelectObject(pOldBrush);
|
brush_Null.DeleteObject();
|
}
|