⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imagecamview.cpp

📁 《数字图象工程案例》原码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		CimageCAMDoc* pDoc = GetDocument();
		MergeFloatDib();
		pDoc->WriteTmpFile();
		m_pDib->HighPass(FD.m_nStreng, FILTER3);
		pDoc->SetModifiedFlag(TRUE);
		OnRealizePal((WPARAM)m_hWnd,0);  // realize the new palette
		pDoc->UpdateAllViews(NULL);
	}
}

void CimageCAMView::OnUpdateHf3(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnHf2() 
{
	// TODO: Add your command handler code here
	CConvoluteDlg FD(1,10,3,this);
	if (FD.DoModal() == IDOK)
	{
		CimageCAMDoc* pDoc = GetDocument();
		MergeFloatDib();
		pDoc->WriteTmpFile();
		m_pDib->HighPass(FD.m_nStreng, FILTER2);
		pDoc->SetModifiedFlag(TRUE);
		OnRealizePal((WPARAM)m_hWnd,0);  // realize the new palette
		pDoc->UpdateAllViews(NULL);
	}
}

void CimageCAMView::OnUpdateHf2(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnHf1() 
{
	// TODO: Add your command handler code here
	CConvoluteDlg FD(1,10,3,this);
	if (FD.DoModal() == IDOK)
	{
		CimageCAMDoc* pDoc = GetDocument();
		MergeFloatDib();
		pDoc->WriteTmpFile();
		m_pDib->HighPass(FD.m_nStreng, FILTER1);
		pDoc->SetModifiedFlag(TRUE);
		OnRealizePal((WPARAM)m_hWnd,0);  // realize the new palette
		pDoc->UpdateAllViews(NULL);
	}
}

void CimageCAMView::OnUpdateHf1(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnGray() 
{
	// TODO: Add your command handler code here
	CimageCAMDoc* pDoc = GetDocument();
	
	CGrayDlg grayDlg(this);
	
	if (grayDlg.DoModal() == IDOK)
	{
		MergeFloatDib();
		pDoc->WriteTmpFile();
		m_pDib->ChangeToGrayscale(grayDlg.m_nMethod, 
			grayDlg.m_fWeightR, 
			grayDlg.m_fWeightG, 
			grayDlg.m_fWeightB);
		pDoc->SetModifiedFlag(TRUE);
		OnRealizePal((WPARAM)m_hWnd,0);  // realize the new palette
		pDoc->UpdateAllViews(NULL);
	}
}


void CimageCAMView::OnUpdateGray(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CimageCAMView::OnCrop() 
{
	// TODO: Add your command handler code here
	CimageCAMDoc* pDoc = GetDocument();
	MergeFloatDib();
	pDoc->WriteTmpFile();
	Crop();
	
	
	CSize sizeTotal(m_pDib->GetWidth(), m_pDib->GetHeight());
	SetScrollSizes(MM_TEXT, sizeTotal);
	pDoc->SetModifiedFlag(TRUE);
	pDoc->UpdateAllViews(NULL);
}

void CimageCAMView::OnUpdateCrop(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty() && ! m_rcClip.IsRectEmpty());
}

void CimageCAMView::OnColorbits() 
{
	// TODO: Add your command handler code here
	CimageCAMDoc* pDoc = GetDocument();
	
	
	CColorBitsDlg colorBitsDlg((int)m_pDib->GetBitCount(), this);
	
	if (colorBitsDlg.DoModal() == IDOK)
	{  MergeFloatDib();
	pDoc->WriteTmpFile();
	m_pDib->ColorQuantize(colorBitsDlg.m_nColorBits);
	
	pDoc->SetModifiedFlag(TRUE);
	OnRealizePal((WPARAM)m_hWnd,0);  // realize the new palette
	pDoc->UpdateAllViews(NULL);
	}
}

void CimageCAMView::OnCanvassize() 
{
	// TODO: Add your command handler code here
	CimageCAMDoc* pDoc = GetDocument();
	CCanvasSize canvasDlg((int)m_pDib->GetWidth(), (int)m_pDib->GetHeight(), this);
	
	if (canvasDlg.DoModal() == IDOK)
	{
		MergeFloatDib();
		pDoc->WriteTmpFile();
		ChangeCanvasSize(canvasDlg.m_nWidth, canvasDlg.m_nHeight, canvasDlg.m_nPosition);
		
		CSize sizeTotal(m_pDib->GetWidth(), m_pDib->GetHeight());
		SetScrollSizes(MM_TEXT, sizeTotal);
		pDoc->SetModifiedFlag(TRUE);
		pDoc->UpdateAllViews(NULL);
	}	
}

void CimageCAMView::OnUpdateCanvassize(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CimageCAMView::OnBc() 
{
	CBCDlg bcDlg(this);
	
	if (bcDlg.DoModal() == IDOK)
	{ 
		CimageCAMDoc* pDoc = GetDocument();
		MergeFloatDib();
        pDoc->WriteTmpFile();
		m_pDib->AdjustBrightness(bcDlg.m_nValue1);
		m_pDib->AdjustContrast(bcDlg.m_nValue2);
		pDoc->SetModifiedFlag(TRUE);
		OnRealizePal((WPARAM)m_hWnd,0);  // realize the new palette
		pDoc->UpdateAllViews(NULL);
	}	
}

void CimageCAMView::OnUpdateBc(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CimageCAMView::OnAdjustcolor() 
{
	// TODO: Add your command handler code here
	
	CAdjustColorDlg colorDlg(this);
	
	if (colorDlg.DoModal() == IDOK)
	{      CimageCAMDoc* pDoc = GetDocument();
	MergeFloatDib();
	pDoc->WriteTmpFile();
	m_pDib->AdjustColor(colorDlg.m_nColorModel, 
		colorDlg.m_nValue1, 
		colorDlg.m_nValue2, 
		colorDlg.m_nValue3); 
	pDoc->SetModifiedFlag(TRUE);
	OnRealizePal((WPARAM)m_hWnd,0);  // realize the new palette
	pDoc->UpdateAllViews(NULL);
	}
}

void CimageCAMView::OnUpdateAdjustcolor(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}


//void CimageCAMView::OnCarve() 
//{
// TODO: Add your command handler code here

//}

void CimageCAMView::OnScale() 
{
	// TODO: Add your command handler code here
	
	CScale scaleDlg(m_pDib->GetWidth(), m_pDib->GetHeight(), this);
	
	if (scaleDlg.DoModal() == IDOK)
	{
		CimageCAMDoc* pDoc = GetDocument();
		MergeFloatDib();
		pDoc->WriteTmpFile();
		ChangeImageSize(scaleDlg.m_nWidth, scaleDlg.m_nHeight);
		CSize sizeTotal(m_pDib->GetWidth(), m_pDib->GetHeight());
		SetScrollSizes(MM_TEXT, sizeTotal);
		pDoc->SetModifiedFlag(TRUE);
		pDoc->UpdateAllViews(NULL);
	}
}
void CimageCAMView::OnUpdateScale(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CimageCAMView::OnRuler() 
{
	// TODO: Add your command handler code here
	
}

void CimageCAMView::OnUpdateRuler(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CimageCAMView::OnVmirror() 
{
	// TODO: Add your command handler code here
	CimageCAMDoc* pDoc = GetDocument();
	Flip(MD_VERT);
	MergeFloatDib();
	pDoc->WriteTmpFile();
	
	CSize sizeTotal(m_pDib->GetWidth(), m_pDib->GetHeight());
	SetScrollSizes(MM_TEXT, sizeTotal);
	pDoc->SetModifiedFlag(TRUE);
	pDoc->UpdateAllViews(NULL);
}

void CimageCAMView::OnUpdateVmirror(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnSelectpaste() 
{
	// TODO: Add your command handler code here
	CSelectPaste spDlg(this);
	
	if (spDlg.DoModal() == IDOK)
	{
		SelectPaste(spDlg.m_nCF);
	}
}

void CimageCAMView::OnUpdateSelectpaste(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(::IsClipboardFormatAvailable(CF_DIB) ||
		::IsClipboardFormatAvailable(CF_BITMAP) ||
		::IsClipboardFormatAvailable(CF_PALETTE));
}

void CimageCAMView::OnPixel() 
{
	// TODO: Add your command handler code here
	SetLengthUnit(MM_TEXT);
}

void CimageCAMView::OnUpdatePixel(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}


void CimageCAMView::OnImageThin() 
{
	CimageCAMDoc* pDoc = GetDocument();
	CString s1=" 请确定是二值图象!二值图象请按YES,不是请按NO退出加工";
	if(AfxMessageBox(s1,MB_YESNO,0 )==IDYES)
	{ 
		//调用封装在CDib的Thining函数
		if (!m_pDib->Thining(m_pDib->m_hDib))
			AfxMessageBox(" 细化失败!!");
		m_pDib->UpdateInternal();
		pDoc->SetModifiedFlag(TRUE);
		OnRealizePal((WPARAM)m_hWnd,0);  // realize the new palette
		pDoc->UpdateAllViews(NULL);
	}	
}

void CimageCAMView::OnImageFtreat() 
{
	// TODO: Add your command handler code here
	CimageCAMDoc* pDoc = GetDocument();
	CFollowingDlg Follwingdlg(this);
	if(Follwingdlg.DoModal()==IDOK)
	{
		if (!m_pDib->Followingtreatment(Follwingdlg.m_munber,m_pDib->m_hDib))
			AfxMessageBox("后续处理失败!!");
		m_pDib->UpdateInternal();
		pDoc->SetModifiedFlag(TRUE);
		pDoc->UpdateAllViews(NULL);	
	}
}

void CimageCAMView::OnImageOutput() 
{
	CimageCAMDoc* pDoc = GetDocument();
    CString str = "必须在细化或后续处理后使用本选项!要继续吗?";
	if(AfxMessageBox(str,MB_YESNO,0 )==IDNO)
		return;
    str.Empty();
	CSelectparDlg    dlg1(this);
	double xy=(double)m_pDib->GetHeight()/(double)m_pDib->GetWidth();
	dlg1.m_outputx=30.0000;
	dlg1.m_outputy=30.0000*xy;
    dlg1.xyr=xy;
    if(dlg1.DoModal()==IDOK)
    {
		CString HeadInfo;
		if(dlg1.m_outputx<0.0001)
		{
			AfxMessageBox("无效的加工参数,请重试并确定图象加工实际尺寸为有效值");
			return;
		}
		str.Format("没有指定刀具\n");		
		HeadInfo=str+"    G92 X0.0 Y0.0 Z0.0;\n    G90 S10000 M03 F150 T01;\n    G00 X0.000 Y0.000 Z1.000;\n";		
		if(!CalculateGraphics(dlg1.m_outputx,dlg1.m_depth,1,HeadInfo))
			AfxMessageBox("出现错误,不能产生可用的文件");
	}
}



void CimageCAMView::OnVert() 
{
	// TODO: Add your command handler code here
	EdgeEnhance(VERT);
}

void CimageCAMView::OnUpdateVert(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnVerthorz() 
{
	// TODO: Add your command handler code here
	EdgeEnhance(VERTHORZ);
}

void CimageCAMView::OnUpdateVerthorz(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnEast() 
{
	// TODO: Add your command handler code here
	EdgeEnhance(EAST);
}

void CimageCAMView::OnUpdateEast(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnSoutheast() 
{
	// TODO: Add your command handler code here
	EdgeEnhance(SOUTHEAST);
}

void CimageCAMView::OnUpdateSoutheast(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnSouth() 
{
	// TODO: Add your command handler code here
	EdgeEnhance(SOUTH);
}

void CimageCAMView::OnUpdateSouth(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnSouthwest() 
{
	// TODO: Add your command handler code here
	EdgeEnhance(SOUTHWEST);
}

void CimageCAMView::OnUpdateSouthwest(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnWest() 
{
	// TODO: Add your command handler code here
	EdgeEnhance(WEST);
}

void CimageCAMView::OnUpdateWest(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnSobel() 
{
	// TODO: Add your command handler code here
	EdgeEnhance(SOBEL);
}

void CimageCAMView::OnUpdateSobel(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnRotate() 
{
	// TODO: Add your command handler code here
	CimageCAMDoc* pDoc = GetDocument();
	MergeFloatDib();
	pDoc->WriteTmpFile();
	Rotate(90);
	
	
	CSize sizeTotal(m_pDib->GetWidth(), m_pDib->GetHeight());
	SetScrollSizes(MM_TEXT, sizeTotal);
	pDoc->SetModifiedFlag(TRUE);
	pDoc->UpdateAllViews(NULL);
}

void CimageCAMView::OnUpdateRotate(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnRotate180() 
{
	// TODO: Add your command handler code here
	CimageCAMDoc* pDoc = GetDocument();
	MergeFloatDib();
	pDoc->WriteTmpFile();
	Rotate(180);
	
	CSize sizeTotal(m_pDib->GetWidth(), m_pDib->GetHeight());
	SetScrollSizes(MM_TEXT, sizeTotal);
	pDoc->SetModifiedFlag(TRUE);
	pDoc->UpdateAllViews(NULL);
}

void CimageCAMView::OnUpdateRotate180(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnRotate270() 
{
	// TODO: Add your command handler code here
	CimageCAMDoc* pDoc = GetDocument();	
	Rotate(270);
    MergeFloatDib();
    pDoc->WriteTmpFile();
	CSize sizeTotal(m_pDib->GetWidth(), m_pDib->GetHeight());
	SetScrollSizes(MM_TEXT, sizeTotal);
	pDoc->SetModifiedFlag(TRUE);
	pDoc->UpdateAllViews(NULL);
}

void CimageCAMView::OnUpdateRotate270(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(! m_pDib->IsEmpty());
}

void CimageCAMView::OnRotateother() 
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -