www.pudn.com > JingXiang-Design-Jeff.rar > DesignView.cpp
// DesignView.cpp : implementation of the CDesignView class
//
#include "stdafx.h"
#include "Design.h"
#include "DesignDoc.h"
#include "DesignView.h"
#include "mainfrm.h"
#include "ImageInfo.h"
#include "ForLancet.h"
#include "BrightAdjust.h"
#include "ForStrongBorder.h"
#include "Image_Identify.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define TIMER_FOR_SHOW 1000
#define IN_RECT(Rect,x,y) ((x)>=(Rect).left&&(x)<=(Rect).right&&(y)>=(Rect).top&&(y)<=(Rect).bottom)
/////////////////////////////////////////////////////////////////////////////
// CDesignView
IMPLEMENT_DYNCREATE(CDesignView, CScrollView)
BEGIN_MESSAGE_MAP(CDesignView, CScrollView)
//{{AFX_MSG_MAP(CDesignView)
ON_COMMAND(ID_FUNC_LARGER, OnFuncLarger)
ON_COMMAND(ID_FUNC_SMALL, OnFuncSmall)
ON_COMMAND(ID_FUNC_CHANGE_TO_COLOR, OnFuncChangeToColor)
ON_COMMAND(ID_FUNC_CHANGE_TO_GRAY, OnFuncChangeToGray)
ON_COMMAND(ID_FUNC_REVERT, OnFuncRevert)
ON_COMMAND(ID_VIEW_SHOW_HISTOGRAM, OnViewShowHistogram)
ON_UPDATE_COMMAND_UI(ID_VIEW_SHOW_HISTOGRAM, OnUpdateViewShowHistogram)
ON_UPDATE_COMMAND_UI(ID_FUNC_CHANGE_TO_COLOR, OnUpdateFuncChangeToColor)
ON_UPDATE_COMMAND_UI(ID_FUNC_CHANGE_TO_GRAY, OnUpdateFuncChangeToGray)
ON_UPDATE_COMMAND_UI(ID_FUNC_LARGER, OnUpdateFuncLarger)
ON_UPDATE_COMMAND_UI(ID_FUNC_REVERT, OnUpdateFuncRevert)
ON_UPDATE_COMMAND_UI(ID_FUNC_SMALL, OnUpdateFuncSmall)
ON_COMMAND(ID_FUNC_SELECT_AREA, OnFuncSelectArea)
ON_UPDATE_COMMAND_UI(ID_FUNC_SELECT_AREA, OnUpdateFuncSelectArea)
ON_WM_SETCURSOR()
ON_WM_LBUTTONDOWN()
ON_COMMAND(ID_VIEW_IMAGE_INFO, OnViewImageInfo)
ON_UPDATE_COMMAND_UI(ID_VIEW_IMAGE_INFO, OnUpdateViewImageInfo)
ON_WM_MOUSEMOVE()
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_TIMER()
ON_COMMAND(ID_FUNC_AREA_LOCKED, OnFuncAreaLocked)
ON_UPDATE_COMMAND_UI(ID_FUNC_AREA_LOCKED, OnUpdateFuncAreaLocked)
ON_COMMAND(ID_FUNC_FLASH_SELECTED_AREA, OnFuncFlashSelectedArea)
ON_UPDATE_COMMAND_UI(ID_FUNC_FLASH_SELECTED_AREA, OnUpdateFuncFlashSelectedArea)
ON_COMMAND(ID_PICTUREPROCESS_LANCET, OnPictureprocessLancet)
ON_UPDATE_COMMAND_UI(ID_PICTUREPROCESS_LANCET, OnUpdatePictureprocessLancet)
ON_UPDATE_COMMAND_UI(ID_PICTUREPROCESS_CANCEL_LANCET, OnUpdatePictureprocessCancelLancet)
ON_COMMAND(ID_PICTUREPROCESS_CANCEL_LANCET, OnPictureprocessCancelLancet)
ON_COMMAND(ID_PICTUREPROCESS_PRE_MEDIANFILTER, OnPictureprocessPreMedianfilter)
ON_UPDATE_COMMAND_UI(ID_PICTUREPROCESS_PRE_MEDIANFILTER, OnUpdatePictureprocessPreMedianfilter)
ON_COMMAND(ID_FUNC_RELOAD_GRAY, OnFuncReloadGray)
ON_UPDATE_COMMAND_UI(ID_FUNC_RELOAD_GRAY, OnUpdateFuncReloadGray)
ON_COMMAND(ID_PICTUREPROCESS_PRE_STRONG_BORDER, OnPictureprocessPreStrongBorder)
ON_UPDATE_COMMAND_UI(ID_PICTUREPROCESS_PRE_STRONG_BORDER, OnUpdatePictureprocessPreStrongBorder)
ON_COMMAND(ID_PICTUREPROCESS_CONFIRM_LANCET, OnPictureprocessConfirmLancet)
ON_UPDATE_COMMAND_UI(ID_PICTUREPROCESS_CONFIRM_LANCET, OnUpdatePictureprocessConfirmLancet)
ON_COMMAND(ID_PICTUREPROCESS_PRE_DETECT_BORDER, OnPictureprocessPreDetectBorder)
ON_UPDATE_COMMAND_UI(ID_PICTUREPROCESS_PRE_DETECT_BORDER, OnUpdatePictureprocessPreDetectBorder)
ON_COMMAND(ID_FUNC_FLASH_SCREEN, OnFuncFlashScreen)
ON_UPDATE_COMMAND_UI(ID_FUNC_FLASH_SCREEN, OnUpdateFuncFlashScreen)
ON_WM_RBUTTONUP()
ON_COMMAND(ID_CRYSTAL_ANALYSE_DETECT_PARAMETER, OnCrystalAnalyseDetectParameter)
ON_UPDATE_COMMAND_UI(ID_CRYSTAL_ANALYSE_DETECT_PARAMETER, OnUpdateCrystalAnalyseDetectParameter)
ON_COMMAND(ID_PICTUREPROCESS_PRE_INSERVE_IMAGE, OnPictureprocessPreInserveImage)
ON_UPDATE_COMMAND_UI(ID_PICTUREPROCESS_PRE_INSERVE_IMAGE, OnUpdatePictureprocessPreInserveImage)
ON_COMMAND(ID_IMAGE_IDENTIFY_AREA_DETECT, OnImageIdentifyAreaDetect)
ON_UPDATE_COMMAND_UI(ID_IMAGE_IDENTIFY_AREA_DETECT, OnUpdateImageIdentifyAreaDetect)
ON_COMMAND(ID_PICTUREPROCESS_PRE_BRIGHT_ADJUST, OnPictureprocessPreBrightAdjust)
ON_UPDATE_COMMAND_UI(ID_PICTUREPROCESS_PRE_BRIGHT_ADJUST, OnUpdatePictureprocessPreBrightAdjust)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDesignView construction/destruction
BOOL CDesignView::ConvertFromSelectedRectToReallyRect(void)
{
// CString StrTmp;// Just For Debug
OrgPoint=GetScrollPosition();
/*///For Debug
StrTmp.Format("top=%d,left=%d,bottom=%d,right=%d,OrgX=%d,OrgY=%d",
pNowDoc->RectTmp.top,
pNowDoc->RectTmp.left,
pNowDoc->RectTmp.bottom,
pNowDoc->RectTmp.right,
OrgPoint.x,OrgPoint.y);
::AfxMessageBox(StrTmp);
//End*/
//pNowDoc->BitMap.ReallyRectOfBMP=RectTmp; //For Debug
//return FALSE; //For Debug
/* pNowDoc->RectTmp.left+=OrgPoint.x;
pNowDoc->RectTmp.right+=OrgPoint.x;
pNowDoc->RectTmp.top+=OrgPoint.y;
pNowDoc->RectTmp.bottom+=OrgPoint.y;
*/
RectTmp=pNowDoc->BitMap.SelectedRect;
/////////////////
RectForShow=RectTmp;
RectTmp.left+=OrgPoint.x;
RectTmp.right+=OrgPoint.x;
RectTmp.top+=OrgPoint.y;
RectTmp.bottom+=OrgPoint.y;
if(mNowRatio==1||mNowRatio==-1)
{
pNowDoc->BitMap.ReallyRectOfBMP=RectTmp;
/*///For Debug
StrTmp.Format("top=%d,left=%d,bottom=%d,right=%d,OrgX=%d,OrgY=%d",
pNowDoc->BitMap.SelectedRect.top,
pNowDoc->BitMap.SelectedRect.left,
pNowDoc->BitMap.SelectedRect.bottom,
pNowDoc->BitMap.SelectedRect.right,
OrgPoint.x,OrgPoint.y);
::AfxMessageBox(StrTmp);
//End*/
return TRUE;
}
if(mNowRatio>0)
{
pNowDoc->BitMap.ReallyRectOfBMP.left=RectTmp.left/mNowRatio;
pNowDoc->BitMap.ReallyRectOfBMP.top=RectTmp.top/mNowRatio;
pNowDoc->BitMap.ReallyRectOfBMP.right=RectTmp.right/mNowRatio;
pNowDoc->BitMap.ReallyRectOfBMP.bottom=RectTmp.bottom/mNowRatio;
}
else
{
pNowDoc->BitMap.ReallyRectOfBMP.left=RectTmp.left*(-mNowRatio);
pNowDoc->BitMap.ReallyRectOfBMP.top=RectTmp.top*(-mNowRatio);
pNowDoc->BitMap.ReallyRectOfBMP.right=RectTmp.right*(-mNowRatio);
pNowDoc->BitMap.ReallyRectOfBMP.bottom=RectTmp.bottom*(-mNowRatio);
}
if(pNowDoc->BitMap.ReallyRectOfBMP.left>pNowDoc->BitMap.ReallyRectOfBMP.right)
{
pNowDoc->BitMap.ReallyRectOfBMP.right=pNowDoc->BitMap.ReallyRectOfBMP.left;
/*if(pNowDoc->BitMap.ReallyRectOfBMP.left<(int)pNowDoc->BitMap.BmpInfoHeader.biWidth)
pNowDoc->BitMap.ReallyRectOfBMP.right=pNowDoc->BitMap.ReallyRectOfBMP.left+1;
else
pNowDoc->BitMap.ReallyRectOfBMP.left=pNowDoc->BitMap.ReallyRectOfBMP.right-1;
*/
}
if(pNowDoc->BitMap.ReallyRectOfBMP.top>pNowDoc->BitMap.ReallyRectOfBMP.bottom)
{
pNowDoc->BitMap.ReallyRectOfBMP.bottom=pNowDoc->BitMap.ReallyRectOfBMP.left;
/*if(pNowDoc->BitMap.ReallyRectOfBMP.top<(int)pNowDoc->BitMap.BmpInfoHeader.biHeight)
pNowDoc->BitMap.ReallyRectOfBMP.bottom=pNowDoc->BitMap.ReallyRectOfBMP.top+1;
else
pNowDoc->BitMap.ReallyRectOfBMP.top=pNowDoc->BitMap.ReallyRectOfBMP.bottom-1;
*/
}
/*
//For Debug Below
StrTmp.Format("top=%d,left=%d,bottom=%d,right=%d",
pNowDoc->BitMap.ReallyRectOfBMP.top,
pNowDoc->BitMap.ReallyRectOfBMP.left,
pNowDoc->BitMap.ReallyRectOfBMP.bottom,
pNowDoc->BitMap.ReallyRectOfBMP.right);
::AfxMessageBox(StrTmp);
*/
/////End
return TRUE;
}
CDesignView::CDesignView()
{
Is_Valid_OF_RBN_UP=1;
FlashedEnabled=TRUE;
IsFlashed=FALSE;
IsAreaLocked=FALSE;
IsFlashRectShowed=1;
CountForColor=0;
this->CursorForBMPSelected=::AfxGetApp()->LoadCursor(IDC_CURSORFORBMPSELECTED);
this->NormalCursor=::LoadCursor(NULL,IDC_ARROW);
mNowRatio=1;
IsHistogramShowed=FALSE;
}
CDesignView::~CDesignView()
{
//KillTimer(TIMER_FOR_SHOW);
//pHiShow->DestroyWindow();
// delete pHiShow;
}
BOOL CDesignView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDesignView drawing
void CDesignView::OnDraw(CDC* pDC)
{
CDesignDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CPoint TmpPoint;
ASSERT_VALID(pDoc);
if(!pDoc->BitMap.GetBmpStatus())
return;
// pDoc->BitMap.ShowBitMap(pDC,mNowRatio);
pDoc->BitMap.SpeedShowBitMap(pDC,mNowRatio);
if(pDoc->BitMap.BMPSelectEnabled&&pDoc->BitMap.RectSelected)
{
this->DrawSelectedRect(pDC,RectTmp);
}
this->TrueRatio=mNowRatio>=0?mNowRatio:(float)(-1.0/(float)mNowRatio);
return;
}
void CDesignView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
/*pHiShow=new HistogramShow(AfxGetApp()->GetMainWnd ());// Init The Histogram Dialog
this->pHiShow->Create(IDD_HISTOGRAM,pHiShow->pTheParent);
pHiShow->CenterWindow(pHiShow->pTheParent);
pHiShow->GetSelfClientRect();*/
CSize sizeTotal;
CDesignDoc *pDoc=GetDocument();
pNowDoc= (CDesignDoc*)GetDocument();
if(!(pDoc->BitMap.GetBmpStatus()))
{
sizeTotal.cx=400;
sizeTotal.cy=300;
SetScrollSizes(MM_TEXT,sizeTotal);
return;
}
return;
}
/////////////////////////////////////////////////////////////////////////////
// CDesignView printing
BOOL CDesignView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDesignView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDesignView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDesignView diagnostics
#ifdef _DEBUG
void CDesignView::AssertValid() const
{
CScrollView::AssertValid();
}
void CDesignView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CDesignDoc* CDesignView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDesignDoc)));
return (CDesignDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDesignView message handlers
void CDesignView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
pHiShow=new HistogramShow(AfxGetApp()->GetMainWnd ());// Init The Histogram Dialog
this->pHiShow->Create(IDD_HISTOGRAM,pHiShow->pTheParent);
//?????????
//pHiShow->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME),FALSE);
pHiShow->CenterWindow(pHiShow->pTheParent);
pHiShow->GetSelfClientRect();
////// Init The Parameter Detect Dialog
this->pPara_Detect=new Para_Detect(AfxGetApp()->GetMainWnd());
this->pPara_Detect->Create(IDD_DETECT_PARAMETER,pHiShow->pTheParent);
pPara_Detect->CenterWindow(pPara_Detect->pTheParent);
return;
}
void CDesignView::OnFuncLarger()
{
CWaitCursor WaitCursor;//Show A Waiting Mouse Cursor
DisableSelect();
CDesignDoc *pDoc=GetDocument();
if(!pDoc->BitMap.GetBmpStatus())return;
if(mNowRatio>=8) return;
if(mNowRatio==-1||mNowRatio==0) mNowRatio=1;
mNowRatio++;
if(mNowRatio==-1) mNowRatio=1;
int Tmp=mNowRatio;
if(Tmp<0)
{
Tmp=-Tmp;
pDoc->BitMap.mNowWidth=pDoc->BitMap.BmpInfoHeader.biWidth/Tmp;
pDoc->BitMap.mNowHeight=pDoc->BitMap.BmpInfoHeader.biHeight/Tmp;
}
else
{
pDoc->BitMap.mNowWidth=pDoc->BitMap.BmpInfoHeader.biWidth*Tmp;
pDoc->BitMap.mNowHeight=pDoc->BitMap.BmpInfoHeader.biHeight*Tmp;
}
CSize sizeTotal;
sizeTotal.cx = pDoc->BitMap.mNowWidth;
sizeTotal.cy = pDoc->BitMap.mNowHeight;
SetScrollSizes(MM_TEXT, sizeTotal);
::AfxGetApp()->GetMainWnd()->Invalidate(TRUE);// ReDraw Window
pPara_Detect->m_ShiTuBeiLv=this->mNowRatio>0?this->mNowRatio:(float)-1.0/this->mNowRatio;// Update The Para_Detect Dialog
if(this->pPara_Detect->IsShowed)
pPara_Detect->UpdateData(FALSE);
return;
}
void CDesignView::OnFuncSmall()
{
CWaitCursor WaitCursor;//Show A Waiting Mouse Cursor
DisableSelect();
CDesignDoc *pDoc=GetDocument();
if(!pDoc->BitMap.GetBmpStatus())return;
if(mNowRatio<=-8) return;
if(mNowRatio==1||mNowRatio==0) mNowRatio=-1;
mNowRatio--;
if(mNowRatio==1) mNowRatio=-1;
int Tmp=mNowRatio;
if(Tmp<0)
{
Tmp=-Tmp;
pDoc->BitMap.mNowWidth=pDoc->BitMap.BmpInfoHeader.biWidth/Tmp;
pDoc->BitMap.mNowHeight=pDoc->BitMap.BmpInfoHeader.biHeight/Tmp;
}
else
{
pDoc->BitMap.mNowWidth=pDoc->BitMap.BmpInfoHeader.biWidth*Tmp;
pDoc->BitMap.mNowHeight=pDoc->BitMap.BmpInfoHeader.biHeight*Tmp;
}
CSize sizeTotal;
sizeTotal.cx = pDoc->BitMap.mNowWidth;
sizeTotal.cy = pDoc->BitMap.mNowHeight;
SetScrollSizes(MM_TEXT, sizeTotal);
::AfxGetApp()->GetMainWnd()->Invalidate(TRUE);// ReDraw Window
pPara_Detect->m_ShiTuBeiLv=this->mNowRatio>0?this->mNowRatio:(float)-1.0/this->mNowRatio;// Update The Para_Detect Dialog
if(this->pPara_Detect->IsShowed)
pPara_Detect->UpdateData(FALSE);
return;
}
void CDesignView::OnFuncChangeToColor()
{
int i=0;
if(!pNowDoc->BitMap.GetBmpStatus()) // if BMP Get Some Error,Return;
return;
if(!(pNowDoc->BitMap.GetIsGray())) // If is Gray already,Return;
return;
// if(!pNowDoc->BitMap.IsLancet) // If For A Lancet To ReLoad,Skip this
if(this->MessageBox("还原后灰度信息将丢失,所有分析处理过程将被终止!真的要还原为彩色图吗?","还原为彩色图",MB_YESNO|MB_ICONWARNING)==IDNO) return;
CWaitCursor WaitCursor;//Show A Waiting Mouse Cursor
pNowDoc->BitMap.IsLancet=0;
IsFlashed=FALSE;
CMainFrame *pMFrame=(CMainFrame *)(AfxGetApp()->m_pMainWnd);
if(pNowDoc->BitMap.BMPSelectEnabled)// If Area Select Enable ,Disable It!
pMFrame->SendMessage(WM_COMMAND,ID_FUNC_SELECT_AREA,0);
pNowDoc->BitMap.GetBmpFile(pNowDoc->BitMap.BMPFileName);
pNowDoc->BitMap.SetIsGray(FALSE);
//if(!pNowDoc->BitMap.IsLancet)// If For A Lancet To ReLoad,Skip this
::AfxGetApp()->GetMainWnd()->Invalidate(TRUE);
if(pHiShow->Showed_Ok)
this->pHiShow->Invalidate();
return;
}
void CDesignView::OnFuncChangeToGray()
{
CWaitCursor WaitCursor;//Show A Waiting Mouse Cursor
int i=0;
unsigned long Line=0,Col=0,k=0;
BYTE *pTmp=NULL;
if(!pNowDoc->BitMap.GetBmpStatus()) // if BMP Get Some Error,Return;
return;
if(pNowDoc->BitMap.GetIsGray()) // If is Gray already,Return;
return;
/* switch(pNowDoc->BitMap.BmpInfoHeader.biBitCount)
{
case 1:
case 4:
case 8:
for(i=0;iBitMap.NumOfColor;i++)
{
TmpGray=GET_GRAY(pNowDoc->BitMap.pRgbQuad[i].rgbRed,pNowDoc->BitMap.pRgbQuad[i].rgbGreen, pNowDoc->BitMap.pRgbQuad[i].rgbBlue);
pNowDoc->BitMap.pRgbQuad[i].rgbRed=pNowDoc->BitMap.pRgbQuad[i].rgbGreen=pNowDoc->BitMap.pRgbQuad[i].rgbBlue=(BYTE)TmpGray;
}
break;
case 24:
for(Line=0;LineBitMap.BmpInfoHeader.biHeight;Line++)
{
pTmp=pNowDoc->BitMap.pBMPData+Line*(int)(pNowDoc->BitMap.NonCompressLineSize);
for(k=0,Col=0;ColBitMap.BmpInfoHeader.biWidth;Col++,k+=3)
{
//TmpGray=GET_GRAY(pTmp[k+2],pTmp[k+1],pTmp[k]);
TmpGray=GET_GRAY(pTmp[k+2],pTmp[k+1],pTmp[k]);
pTmp[k]=pTmp[k+1]=pTmp[k+2]=(BYTE)TmpGray;
}
}
break;
default:
return;
}
pNowDoc->BitMap.CopyGrayToShow(pNowDoc->BitMap.pRgbQuad,pNowDoc->BitMap.pBMPData);
pNowDoc->BitMap.SetIsGray(TRUE);*/
pNowDoc->BitMap.ChangeToGray();
pNowDoc->BitMap.GetGrayRatio();
pNowDoc->BitMap.CopyImageDataAsNonCompressionDataToMemForShow();
///////// Check Ratio
////////////
//if(!pNowDoc->BitMap.IsLancet) // If For A Lancet To ReLoad,Skip this
::AfxGetApp()->GetMainWnd()->Invalidate(TRUE);
if(IsHistogramShowed)
pHiShow->Invalidate(TRUE);
return;
}
void CDesignView::OnFuncRevert()
{
CWaitCursor WaitCursor;//Show A Waiting Mouse Cursor
DisableSelect();
CDesignDoc *pDoc=GetDocument();
if(!pDoc->BitMap.GetBmpStatus())return;
mNowRatio=1;
pDoc->BitMap.mNowWidth=pDoc->BitMap.BmpInfoHeader.biWidth;
pDoc->BitMap.mNowHeight=pDoc->BitMap.BmpInfoHeader.biHeight;
CSize sizeTotal;
sizeTotal.cx = pDoc->BitMap.mNowWidth;
sizeTotal.cy = pDoc->BitMap.mNowHeight;
SetScrollSizes(MM_TEXT, sizeTotal);
::AfxGetApp()->GetMainWnd()->Invalidate(TRUE);// ReDraw Window
pPara_Detect->m_ShiTuBeiLv=this->mNowRatio>0?this->mNowRatio:(float)-1.0/this->mNowRatio;// Update The Para_Detect Dialog
if(this->pPara_Detect->IsShowed)
pPara_Detect->UpdateData(FALSE);
return;
}
void CDesignView::OnViewShowHistogram()
{
IsHistogramShowed=((IsHistogramShowed)?0:1);
CWaitCursor WaitCursor;//Show A Waiting Mouse Cursor
CDesignDoc *pDesignDoc;
CMainFrame* pMFrame=(CMainFrame*)(AfxGetApp()->m_pMainWnd);
pDesignDoc=(CDesignDoc*)pMFrame->GetActiveDocument();
if(IsHistogramShowed)
{
if(!pDesignDoc->BitMap.RectSelected)
pNowDoc->BitMap.GetGrayRatio();
else
pNowDoc->BitMap.GetRectGrayRatio(pNowDoc->BitMap.ReallyRectOfBMP);
pHiShow->ShowWindow(SW_SHOW);
}
else
pHiShow->ShowWindow(SW_HIDE);
// Do Something Here
return;
}
void CDesignView::OnUpdateViewShowHistogram(CCmdUI* pCmdUI)
{
pCmdUI->Enable(((CDesignDoc*)GetDocument())->BitMap.GetBmpStatus());
pCmdUI->SetCheck(IsHistogramShowed);
}
void CDesignView::OnUpdateFuncChangeToColor(CCmdUI* pCmdUI)
{
pCmdUI->Enable(((CDesignDoc*)GetDocument())->BitMap.GetIsGray()&&((CDesignDoc*)GetDocument())->BitMap.GetBmpStatus()&&!IsAreaLocked);
}
void CDesignView::OnUpdateFuncChangeToGray(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!(((CDesignDoc*)GetDocument())->BitMap.GetIsGray())&&((CDesignDoc*)GetDocument())->BitMap.GetBmpStatus());
}
void CDesignView::OnUpdateFuncLarger(CCmdUI* pCmdUI)
{
pCmdUI->Enable(mNowRatio<8&&((CDesignDoc*)GetDocument())->BitMap.GetBmpStatus()&&!IsAreaLocked);
}
void CDesignView::OnUpdateFuncRevert(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!(mNowRatio==1||mNowRatio==-1)&&((CDesignDoc*)GetDocument())->BitMap.GetBmpStatus()&&!IsAreaLocked);
}
void CDesignView::OnUpdateFuncSmall(CCmdUI* pCmdUI)
{
pCmdUI->Enable(mNowRatio>-8&&((CDesignDoc*)GetDocument())->BitMap.GetBmpStatus()&&!IsAreaLocked);
}
void CDesignView::OnFuncSelectArea()
{
if(IsAreaLocked) return;
//&&pNowDoc->BitMap.RectSelected) return;
if(pNowDoc->BitMap.BMPSelectEnabled)
DisableSelect();
pNowDoc->BitMap.BMPSelectEnabled=pNowDoc->BitMap.BMPSelectEnabled?0:1;
//pNowDoc->BitMap.RectSelected=FALSE; //Have Run At Fun'DisableSelect()'
//do something at Below
}
void CDesignView::OnUpdateFuncSelectArea(CCmdUI* pCmdUI)
{
pCmdUI->Enable(pNowDoc->BitMap.GetBmpStatus()&&pNowDoc->BitMap.GetIsGray());
pCmdUI->SetCheck(pNowDoc->BitMap.BMPSelectEnabled);
}
BOOL CDesignView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if( nHitTest == HTCLIENT)
{
if(pNowDoc->BitMap.GetBmpStatus() )
if(pNowDoc->BitMap.BMPSelectEnabled)
::SetCursor(CursorForBMPSelected);
// ::SetCursor(NormalCursor);
else
::SetCursor(NormalCursor);
else
::SetCursor(NormalCursor);
return TRUE;
}
return CScrollView::OnSetCursor(pWnd, nHitTest, message);
}
void CDesignView::OnLButtonDown(UINT nFlags, CPoint point)
{
/////////////
pNowDoc=GetDocument();
if(!pNowDoc->BitMap.BMPSelectEnabled) return;
if(IsAreaLocked) return;
FlashedEnabled=FALSE;
CClientDC DcTmp(this);
if(pNowDoc->BitMap.RectSelected)
//DrawSelectedRect(&DcTmp);
this->Invalidate(FALSE);
pNowDoc->BitMap.RectSelected=FALSE;
//Invalidate();
CRectTracker RectTracker;
if (RectTracker.TrackRubberBand(this, point))
{
CWaitCursor wait;
//Disable Flashing Selected Area
//ensure the rectangle is the right way up
if (RectTracker.m_rect.left > RectTracker.m_rect.right)
{
int t = RectTracker.m_rect.left;
RectTracker.m_rect.left = RectTracker.m_rect.right;
RectTracker.m_rect.right = t;
}
//ensure the rectangle is the right way up
if (RectTracker.m_rect.top > RectTracker.m_rect.bottom)
{
int t = RectTracker.m_rect.top;
RectTracker.m_rect.top = RectTracker.m_rect.bottom;
RectTracker.m_rect.bottom = t;
}
//clip the selection to the maximum size of the window
OrgPoint=GetScrollPosition();
CSize size(GetTotalSize());
if (RectTracker.m_rect.left <0)
RectTracker.m_rect.left =0;
if (RectTracker.m_rect.top < 0)
RectTracker.m_rect.top = 0;
if (RectTracker.m_rect.right > size.cx-OrgPoint.x-1)
RectTracker.m_rect.right = size.cx-OrgPoint.x-1;
if (RectTracker.m_rect.bottom > size.cy-OrgPoint.y-1)
RectTracker.m_rect.bottom = size.cy-OrgPoint.y-1;
/*
// For Debug
CString StrTmp;
StrTmp.Format("size.cx=%d,size.cy=%d,top=%d,left=%d,bottom=%d,right=%d",size.cx,size.cy,RectTracker.m_rect.top,RectTracker.m_rect.left,RectTracker.m_rect.bottom,RectTracker.m_rect.right);
AfxMessageBox(StrTmp);
//End
*/
/*
if(RectTracker.m_rect.top==RectTracker.m_rect.bottom||RectTracker.m_rect.left==RectTracker.m_rect.right)
return;
*/
// determine if it is out of the BMP
int ShowWidth,ShowHeight;
if(mNowRatio>=0)
{
ShowWidth=pNowDoc->BitMap.BmpInfoHeader.biWidth*mNowRatio-1;
ShowHeight=pNowDoc->BitMap.BmpInfoHeader.biHeight*mNowRatio-1;
}
else
{
ShowWidth=(int)(pNowDoc->BitMap.BmpInfoHeader.biWidth/-mNowRatio-1);
ShowHeight=(int)(pNowDoc->BitMap.BmpInfoHeader.biHeight/-mNowRatio-1);
}
if(ShowWidthBitMap.GetGrayRatio();
if(IsHistogramShowed) //UpDate the Histogram View
//pHiShow->Invalidate(TRUE);
pHiShow->SendMessage(WM_COMMAND,IDC_BESTVIEW,0); //Set Best View Always At First
MessageBeep(0);
if(pPara_Detect->IsShowed)// Update the Para_Detect Calss Dialog
{
pPara_Detect->m_CaiYangFanWei=pPara_Detect->CaiYangFanWei_Txt[pNowDoc->BitMap.RectSelected];
pPara_Detect->UpdateData(FALSE);
}
FlashedEnabled =TRUE;//Enable The Flashing
return;
}
if(RectTracker.m_rect.right>ShowWidth) RectTracker.m_rect.right=ShowWidth;
if(RectTracker.m_rect.bottom>ShowHeight) RectTracker.m_rect.bottom=ShowHeight;
//store The Selected Rect
pNowDoc->BitMap.SelectedRect.left=RectTracker.m_rect.left;
pNowDoc->BitMap.SelectedRect.right=RectTracker.m_rect.right;
pNowDoc->BitMap.SelectedRect.top=RectTracker.m_rect.top;
pNowDoc->BitMap.SelectedRect.bottom=RectTracker.m_rect.bottom;
// Covert To Really Rect Of Bmp
ConvertFromSelectedRectToReallyRect();// Marked With 2
//Drawing The Selected Rect
// Attention: Following Function Marked 1 And 2, 1 Must run Before 2,Or Some Error Appear
DrawSelectedRect(&DcTmp,pNowDoc->BitMap.SelectedRect);// Marked With 1
// Set The SelectedRect Flag,And Show It
pNowDoc->BitMap.RectSelected=TRUE;
// Get SelectRect's Gray Ratio
pNowDoc->BitMap.GetRectGrayRatio(pNowDoc->BitMap.ReallyRectOfBMP);
if(IsHistogramShowed) //UpDate the Histogram View
//pHiShow->Invalidate(TRUE);
pHiShow->SendMessage(WM_COMMAND,IDC_BESTVIEW,0); //Set Best View Always At First
}
else
{
pNowDoc->BitMap.GetGrayRatio();
if(IsHistogramShowed) //UpDate the Histogram View
//pHiShow->Invalidate(TRUE);
pHiShow->SendMessage(WM_COMMAND,IDC_BESTVIEW,0); //Set Best View Always At First
MessageBeep(0);
}
FlashedEnabled =TRUE;//Enable The Flashing
if(pPara_Detect->IsShowed)// Update the Para_Detect Calss Dialog
{
pPara_Detect->m_CaiYangFanWei=pPara_Detect->CaiYangFanWei_Txt[pNowDoc->BitMap.RectSelected];
pPara_Detect->UpdateData(FALSE);
}
return;
//CScrollView::OnLButtonDown(nFlags, point);
}
BOOL CDesignView::DrawSelectedRect(CDC* pDc,RECT TheRect,COLORREF PenColor)
{
//ConvertFromSelectedRectToReallyRect();
//RectTmp=pNowDoc->BitMap.SelectedRect;
//OrgPoint=GetScrollPosition();
CPen newPen(/*PS_DASHDOTDOT*/PS_DOT,1,PenColor);
CPen *pOldPen=pDc->SelectObject(&newPen);
/*RectTmp.left-=OrgPoint.x;
RectTmp.right-=OrgPoint.x;
RectTmp.top-=OrgPoint.y;
RectTmp.bottom-=OrgPoint.y;*/
int OldPOR2_Mode=pDc->SetROP2(R2_XORPEN);//R2_MASKPENNOT);
//pDc->Rectangle(&(pNowDoc->BitMap.SelectedRect));
pDc->MoveTo(TheRect.left,TheRect.top);
pDc->LineTo(TheRect.left, TheRect.bottom);
pDc->LineTo(TheRect.right,TheRect.bottom);
pDc->LineTo(TheRect.right,TheRect.top);
pDc->LineTo(TheRect.left, TheRect.top);
//pDc->Rectangle(RectTmp.left,RectTmp.right,RectTmp.top,RectTmp.bottom);
pDc->SetROP2(OldPOR2_Mode);
pDc->SelectObject(pOldPen);
return TRUE;
}
BOOL CDesignView::DisableSelect()
{
CClientDC TmpDc(this);
if(pNowDoc->BitMap.RectSelected)
Invalidate(FALSE);
pNowDoc->BitMap.RectSelected=FALSE;
return TRUE;
}
void CDesignView::OnViewImageInfo()
{
ImageInfo Info;
Info.DoModal();
return;
}
void CDesignView::OnUpdateViewImageInfo(CCmdUI* pCmdUI)
{
pCmdUI->Enable(pNowDoc->BitMap.GetBmpStatus());
return;
}
BOOL CDesignView::GetCurrentPointGray(int x,int y)
{
if(!pNowDoc->BitMap.GetBmpStatus()||!pNowDoc->BitMap.GetIsGray()) return FALSE;
//if(x>(int)pNowDoc->BitMap.mNowWidth-1||y>(int)pNowDoc->BitMap.mNowHeight-1) return FALSE;
if(!IsHistogramShowed) return FALSE;
if(mNowRatio==1||mNowRatio==-1)
pHiShow->m_CurrentGray=pNowDoc->BitMap.GetPointGray(x,y);
else
{
if(mNowRatio>0)
pHiShow->m_CurrentGray=pNowDoc->BitMap.GetPointGray(x/mNowRatio,y/mNowRatio);
else
pHiShow->m_CurrentGray=pNowDoc->BitMap.GetPointGray(x*(-mNowRatio),y*(-mNowRatio));
}
pHiShow->UpdateData(FALSE);
return TRUE;
}
void CDesignView::OnMouseMove(UINT nFlags, CPoint point)
{
// TRACE("X=%d,Y=%d\n",point.x,point.y);
OrgPoint=GetScrollPosition();
if(IsHistogramShowed)
{
pHiShow->m_Current_x=point.x+OrgPoint.x;
pHiShow->m_Current_y=point.y+OrgPoint.y;
pHiShow->UpdateData(FALSE);
}
this->GetCurrentPointGray(point.x+OrgPoint.x,point.y+OrgPoint.y);
CScrollView::OnMouseMove(nFlags, point);
}
int CDesignView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CScrollView::OnCreate(lpCreateStruct) == -1)
return -1;
SetTimer( TIMER_FOR_SHOW, 300, NULL );
pForPopUp=new CMenu();
if(! pForPopUp->LoadMenu(IDR_POPUP)) return -1; // If Load Pop Menu Error ,Exit!
return 0;
}
void CDesignView::OnDestroy()
{
KillTimer(TIMER_FOR_SHOW);
pForPopUp->DestroyMenu();
CScrollView::OnDestroy();
return;
}
void CDesignView::OnTimer(UINT nIDEvent)
{
switch(nIDEvent)
{
case TIMER_FOR_SHOW:
if(IsFlashed&&FlashedEnabled)
{
CClientDC DcTmp(this);
OnPrepareDC(&DcTmp);
DrawSelectedRect(&DcTmp,RectForShow,RGB(CountForColor,CountForColor,CountForColor));
CountForColor+=50;
//DrawSelectedRect(&DcTmp,RectForShow,RGB(CountForColor,CountForColor,CountForColor));
}
/*if(pNowDoc->BitMap.RectSelected)
{
CountForColor=0;
CClientDC DcTmp(this);
DrawSelectedRect(&DcTmp,RGB(CountForColor,CountForColor,CountForColor));
IsFlashRectShowed=IsFlashRectShowed?0:1;
//CountForColor?0:0;
// this->Invalidate(FALSE);
//DrawSelectedRect(&DcTmp,RGB(CountForColor,CountForColor,CountForColor));
}*/
break;
default:break;
}
CScrollView::OnTimer(nIDEvent);
return;
}
BOOL CDesignView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
//OrgPoint=GetScrollPosition();
// Invalidate(FALSE);
return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
}
BOOL CDesignView::OnScrollBy(CSize sizeScroll, BOOL bDoScroll)
{
/* pNowDoc->BitMap.RectSelected=FALSE;*/
//bDoScroll=FALSE;
//Invalidate(FALSE);
/*
CClientDC DcTmp(this);
if(IsFlashRectShowed)
{
DrawSelectedRect(&DcTmp,RGB(CountForColor,CountForColor,CountForColor));
IsFlashRectShowed=FALSE;
}*/
/* RectForShow.left-=sizeScroll.cx;
RectForShow.right-=sizeScroll.cx;
RectForShow.top-=sizeScroll.cy;
RectForShow.bottom-=sizeScroll.cy;
*/
/*
DrawSelectedRect(&DcTmp,RGB(CountForColor,CountForColor,CountForColor));
IsFlashRectShowed=TRUE;
pNowDoc->BitMap.RectSelected=TRUE;*/
return CScrollView::OnScrollBy(sizeScroll, bDoScroll);
}
void CDesignView::OnFuncAreaLocked()
{
IsAreaLocked=IsAreaLocked?FALSE:TRUE;
return;
}
void CDesignView::OnUpdateFuncAreaLocked(CCmdUI* pCmdUI)
{
pCmdUI->Enable(pNowDoc->BitMap.BMPSelectEnabled);
if(!pNowDoc->BitMap.BMPSelectEnabled) IsAreaLocked=FALSE;
pCmdUI->SetCheck(IsAreaLocked);
}
void CDesignView::OnFuncFlashSelectedArea()
{
CClientDC DcTmp(this);
switch(IsFlashed)
{
case TRUE:
IsFlashed=FALSE;
Invalidate(FALSE);
CountForColor=0;
DrawSelectedRect(&DcTmp,RectForShow,RGB(CountForColor,CountForColor,CountForColor));
break;
case FALSE:
Invalidate(FALSE);
IsFlashed=TRUE;
break;
default:break;
}
return;
}
void CDesignView::OnUpdateFuncFlashSelectedArea(CCmdUI* pCmdUI)
{
pCmdUI->Enable(pNowDoc->BitMap.RectSelected);
if(!pNowDoc->BitMap.RectSelected)
IsFlashed=FALSE;
pCmdUI->SetCheck(IsFlashed);
}
void CDesignView::OnPictureprocessLancet()
{
BOOL Flag=FlashedEnabled;
FlashedEnabled=FALSE;
ForLancet Lancet_Parameter;
if(Lancet_Parameter.DoModal()==IDCANCEL){FlashedEnabled=Flag; return;}
FlashedEnabled=Flag;//Enable Flash
return ;
}
void CDesignView::OnUpdatePictureprocessLancet(CCmdUI* pCmdUI)
{
BOOL Condition1=pNowDoc->BitMap.GetIsGray();
BOOL Condition2=pNowDoc->BitMap.GetBmpStatus();
pCmdUI->Enable(Condition1&&Condition2);
if(!Condition1||!Condition2)
pNowDoc->BitMap.IsLancet=FALSE;
}
void CDesignView::OnUpdatePictureprocessCancelLancet(CCmdUI* pCmdUI)
{
pCmdUI->Enable(pNowDoc->BitMap.IsLancet);
}
void CDesignView::OnPictureprocessCancelLancet()
{
BOOL Flag=FlashedEnabled;
if(!pNowDoc->BitMap.IsLancet) return;
if(this->MessageBox("取消后锐化信息将丢失,继续吗?","取消二值锐化",MB_YESNO|MB_ICONWARNING)==IDNO) return;
CWaitCursor WaitCursor;
FlashedEnabled=FALSE;
pNowDoc->BitMap.SetIsGray(TRUE);
memcpy(pNowDoc->BitMap.pBMPData,pNowDoc->BitMap.pPublicBuffer,pNowDoc->BitMap.BmpInfoHeader.biSizeImage);
pNowDoc->BitMap.CopyImageDataAsNonCompressionDataToMemForShow();
pNowDoc->BitMap.IsLancet=FALSE;
this->Invalidate(TRUE);
if(IsHistogramShowed)
{
pHiShow->SendMessage(WM_COMMAND,IDC_REFRESH);
}
FlashedEnabled=Flag;//Enable Flash
return;
}
BOOL CDesignView::LancetFromSwitch(int Switch,RECT *pInput)
{
////////////
BOOL Flag=FlashedEnabled;
FlashedEnabled=FALSE;
CWaitCursor WaitCursor;
pNowDoc->BitMap.SwitchForLancet=Switch;
/*
// For Debug
CString tmp;
tmp.Format("Switch For Lancet =%d!,Ratio=%d",Lancet_Parameter.m_Lancet,Lancet_Parameter.m_RangeOfArea);
AfxMessageBox( tmp);
*/
//// Do something Later
if(!pNowDoc->BitMap.IsLancet)
{
pNowDoc->BitMap.GetLancet(pNowDoc->BitMap.SwitchForLancet,pInput);
pNowDoc->BitMap.IsLancet=TRUE;
}
else
{
pNowDoc->BitMap.SetIsGray(TRUE);
memcpy(pNowDoc->BitMap.pBMPData,pNowDoc->BitMap.pPublicBuffer,pNowDoc->BitMap.BmpInfoHeader.biSizeImage);
pNowDoc->BitMap.GetLancet(pNowDoc->BitMap.SwitchForLancet,pInput);
pNowDoc->BitMap.IsLancet=TRUE;
}
FlashedEnabled=Flag;//Enable Flash
return TRUE;
}
void CDesignView::OnPictureprocessPreMedianfilter()
{
CDesignDoc *pDoc=GetDocument();
CWaitCursor WaitCursor;
if(pDoc->BitMap.RectSelected)
pDoc->BitMap.MedianFilter(&(pDoc->BitMap.ReallyRectOfBMP));
else
pDoc->BitMap.MedianFilter();
pDoc->BitMap.CopyImageDataAsNonCompressionDataToMemForShow();
this->Invalidate();
return;
// TODO: Add your command handler code here
}
void CDesignView::OnUpdatePictureprocessPreMedianfilter(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocument()->BitMap.GetIsGray());
}
void CDesignView::OnFuncReloadGray()
{
CDesignDoc* pNowDoc=GetDocument();
if(this->MessageBox("还原成初始的灰度图,已处理信息将丢失,继续吗?","还原成初始的灰度图",MB_YESNO|MB_ICONWARNING)==IDNO) return;
CWaitCursor WaitCursor;
pNowDoc->BitMap.GetBmpFile(pNowDoc->BitMap.BMPFileName,0);
pNowDoc->BitMap.ChangeToGray();
pNowDoc->BitMap.CopyImageDataAsNonCompressionDataToMemForShow();
pNowDoc->BitMap.IsLancet=FALSE;
this->Invalidate();
return ;
}
void CDesignView::OnUpdateFuncReloadGray(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocument()->BitMap.GetIsGray());
}
void CDesignView::OnPictureprocessPreStrongBorder()
{
CDesignDoc *pDoc=GetDocument();
::MessageBeep(0);
ForStrongBorder BorderDlg(this);
if(BorderDlg.DoModal()==IDCANCEL) return;
CWaitCursor WaitCursor;
if(pDoc->BitMap.RectSelected)
pDoc->BitMap.StrongBorder(pDoc->BitMap.StrongBorderMethod,&(pDoc->BitMap.ReallyRectOfBMP));
else
pDoc->BitMap.StrongBorder(pDoc->BitMap.StrongBorderMethod);
pDoc->BitMap.CopyImageDataAsNonCompressionDataToMemForShow();
this->Invalidate();
return;
return;
}
void CDesignView::OnUpdatePictureprocessPreStrongBorder(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocument()->BitMap.GetIsGray());
return;
}
void CDesignView::OnPictureprocessConfirmLancet()
{
if(this->MessageBox("确认后,下次锐化时将以此为基础进行锐化,继续吗?","确认锐化",MB_YESNO|MB_ICONWARNING)==IDNO) return;
pNowDoc->BitMap.IsLancet=FALSE;
return;
}
void CDesignView::OnUpdatePictureprocessConfirmLancet(CCmdUI* pCmdUI)
{
pCmdUI->Enable(pNowDoc->BitMap.GetIsGray()&&pNowDoc->BitMap.IsLancet);
return;
}
void CDesignView::OnPictureprocessPreDetectBorder()
{
CDesignDoc *pDoc=GetDocument();
CWaitCursor WaitCursor;
if(pDoc->BitMap.RectSelected)
pDoc->BitMap.DetectBorder(&(pDoc->BitMap.ReallyRectOfBMP));
else
pDoc->BitMap.DetectBorder();
pDoc->BitMap.CopyImageDataAsNonCompressionDataToMemForShow();
this->Invalidate();
return;
}
void CDesignView::OnUpdatePictureprocessPreDetectBorder(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocument()->BitMap.GetIsGray());
return;
}
void CDesignView::OnFuncFlashScreen()
{
this->Invalidate(TRUE);
return ;
}
void CDesignView::OnUpdateFuncFlashScreen(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocument()->BitMap.GetBmpStatus());
}
void CDesignView::OnRButtonUp(UINT nFlags, CPoint point)
{
/*
if(mNowRatio>0)
{
Current.x/=mNowRatio;
Current.y/=mNowRatio;
}
else
{
Current.x*=-mNowRatio;
Current.y*=-mNowRatio;
} */
if(!this->Is_Valid_OF_RBN_UP)// Used By Detect TiJiFenShu Button
{
CPoint OrgPoint;
OrgPoint=GetScrollPosition();
CPoint Current;
Current.x=point.x+OrgPoint.x;
Current.y=point.y+OrgPoint.y;
if(mNowRatio>0){Current.x/=mNowRatio;Current.y/=mNowRatio;}
else {Current.x*=-mNowRatio;Current.y*=-mNowRatio;}
//GetCurrentPointGray(Current.x,Current.y);
pPara_Detect->WhichGray=GetDocument()->BitMap.GetPointGray(Current.x,Current.y);
if(pPara_Detect->WhichGray==-1||(pNowDoc->BitMap.RectSelected&&!IN_RECT(pNowDoc->BitMap.ReallyRectOfBMP,Current.x,Current.y)))
{
MessageBox("选取越界,请重新选取!","对象选取错误",MB_OK|MB_ICONERROR);
return;
}
pPara_Detect->IsSelected_Ok=TRUE;
return;
}
ClientToScreen(&point);
/* For Debug
Tmp.Format("In Screen X=%d,Y=%d",point.x,point.y);
this->MessageBox(Tmp);
*/
CMenu *pPopUp=pForPopUp->GetSubMenu(0);
pPopUp->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,(CMainFrame*)AfxGetApp()->m_pMainWnd );//this);
CScrollView::OnRButtonUp(nFlags, point);
//delete pPopUp;
}
void CDesignView::OnCrystalAnalyseDetectParameter()
{
if(pPara_Detect->IsDetectBegin) return;
pPara_Detect->IsShowed=pPara_Detect->IsShowed?0:1;
// InSert Code Later
if(pPara_Detect->IsShowed)
{
pPara_Detect->FlashingData();
pPara_Detect->UpdateData(FALSE);
pPara_Detect->ShowWindow(SW_SHOWNORMAL);
}
else
pPara_Detect->ShowWindow(SW_HIDE);
return;
}
void CDesignView::OnUpdateCrystalAnalyseDetectParameter(CCmdUI* pCmdUI)
{
BOOL Condition=pNowDoc->BitMap.GetIsGray();
BOOL Condition2=pNowDoc->BitMap.IsLancet;
pCmdUI->Enable(Condition&&Condition2);
if(!Condition2)
{
if(pPara_Detect->IsShowed)
{
pPara_Detect->ShowWindow(SW_HIDE);
pPara_Detect->IsShowed=0;
}
}
if(!Condition)
{pPara_Detect->IsShowed=0;pPara_Detect->FlashingData();pPara_Detect->UpdateData(FALSE);}
pCmdUI->SetCheck(pPara_Detect->IsShowed);
return;
}
void CDesignView::OnPictureprocessPreInserveImage()
{
if(pNowDoc->BitMap.RectSelected)
pNowDoc->BitMap.InverseImage(&pNowDoc->BitMap.ReallyRectOfBMP);
else
pNowDoc->BitMap.InverseImage();
pNowDoc->BitMap.CopyImageDataAsNonCompressionDataToMemForShow();
this->Invalidate();
if(IsHistogramShowed)
{
pHiShow->SendMessage(WM_COMMAND,IDC_REFRESH);
}
return;
}
void CDesignView::OnUpdatePictureprocessPreInserveImage(CCmdUI* pCmdUI)
{
pCmdUI->Enable(pNowDoc->BitMap.GetIsGray());
}
void CDesignView::OnImageIdentifyAreaDetect()
{
int FlagTmp=0;
::memcpy(pNowDoc->BitMap.pBMPDataForGray,pNowDoc->BitMap.pBMPData,pNowDoc->BitMap.BmpInfoHeader.biSizeImage);
Image_Identify I_detect;
I_detect.GetNormalInfo(pNowDoc->BitMap.BmpInfoHeader,pNowDoc->BitMap.pBMPDataForGray);
I_detect.BorderDetect(&pNowDoc->BitMap.ReallyRectOfBMP,0);
// For Debug
CString StrTmp;
StrTmp.Format("可识别的区域数为:%d!",I_detect.ObjectNum);
MessageBox(StrTmp,"区域个数",MB_OK|MB_ICONINFORMATION);
//End
return;
}
void CDesignView::OnUpdateImageIdentifyAreaDetect(CCmdUI* pCmdUI)
{
BOOL Condition2=pNowDoc->BitMap.IsLancet;
pCmdUI->Enable(pNowDoc->BitMap.GetIsGray()&&pNowDoc->BitMap.RectSelected&&Condition2);
return ;
}
void CDesignView::OnPictureprocessPreBrightAdjust()
{
BrightAdjust BADlg(AfxGetApp()->m_pMainWnd);
BADlg.DoModal();
return;
}
void CDesignView::OnUpdatePictureprocessPreBrightAdjust(CCmdUI* pCmdUI)
{
pCmdUI->Enable(pNowDoc->BitMap.GetIsGray());
return;
}