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

📄 dlgmixing.cpp

📁 3D reconstruction, medical image processing from colons, using intel image processing for based clas
💻 CPP
字号:
// DlgMixing.cpp : implementation file//#include "stdafx.h"#include "fusion.h"#include "DlgMixing.h"#include "FusionGlobal.h"#include "Buttons.h"#include "SliderCtrl.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// RxDlgMixing dialogRxDlgMixing::RxDlgMixing(CWnd* pParent /*=NULL*/)	: RxDlgCommon(pParent){	m_strCaption		= "Mixing Rate";	m_pBtnClose			= NULL;	m_nRadioLevel		= -1;	m_pBtnILevel		= NULL;	m_pBtnALevel		= NULL;	m_nGripSize			= 30;	m_nMRateRangeMin	= 0;	m_nMRateRangeMax	= 100;	m_nMRatePo			= 50;	m_nMRatePi			= 0;	m_rcMRate			= CRect(0,0,0,0);	m_bSelected			= FALSE;	m_pBtnApply			= NULL;}BEGIN_MESSAGE_MAP(RxDlgMixing, RxDlgCommon)	//{{AFX_MSG_MAP(RxDlgMixing)	ON_WM_CREATE()	ON_WM_DESTROY()	ON_WM_LBUTTONDOWN()	//}}AFX_MSG_MAP	ON_COMMAND_RANGE(IDD_MIXING_BTN_ILEVEL,	IDD_MIXING_BTN_ALEVEL,	OnControls)END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// RxDlgMixing message handlersBOOL RxDlgMixing::OnInitDialog() {	RxDlgCommon::OnInitDialog();		m_pBtnClose->LoadBitmaps(IDB_BTN_CLOSE, CSize(14,14), BM_NORMAL|BM_SELECT);	m_pBtnILevel->SetFont(GetFont(), FALSE);	m_pBtnILevel->RecalcLayout();	m_pBtnILevel->m_crBkgnd		= RXCOLOR_510;	m_pBtnALevel->SetFont(GetFont(), FALSE);	m_pBtnALevel->RecalcLayout();	m_pBtnALevel->m_crBkgnd		= RXCOLOR_510;	m_pBtnApply->SetFont(GetFont());	SetRadioLevel(0);	SetMixingRate(50);	return TRUE;  // return TRUE unless you set the focus to a control	              // EXCEPTION: OCX Property Pages should return FALSE}int RxDlgMixing::OnCreate(LPCREATESTRUCT lpCreateStruct) {	if (RxDlgCommon::OnCreate(lpCreateStruct) == -1)		return -1;		CRect		rcClient(0, 0, 220, 110);	VERIFY(SetWindowPos(NULL, -1, -1, rcClient.Width(), rcClient.Height(), 						SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOACTIVATE));	UINT	nStyle = WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON;	m_pBtnClose			= new RxBitmapButton;	m_pBtnClose->Create		(NULL, nStyle, 									CRect(rcClient.right-22, rcClient.top+1, 0, 0), this, IDCANCEL);	nStyle	= WS_CHILD|BS_OWNERDRAW;	m_pBtnILevel		= new RxRadioButton;	m_pBtnILevel->Create	(_T("Image Level"),			nStyle, CRect( 23, 30,  0,  0), this, IDD_MIXING_BTN_ILEVEL);	m_pBtnALevel		= new RxRadioButton;	m_pBtnALevel->Create	(_T("Accumulation Level"),	nStyle, CRect( 23, 50,  0,  0), this, IDD_MIXING_BTN_ALEVEL);	m_rcMRate.SetRect( 23, 70,190, 80);	nStyle = WS_CHILD|BS_PUSHBUTTON;	m_pBtnApply			= new RxPushButton;	m_pBtnApply->Create		(_T("Apply"),				nStyle, CRect(  0,  0,  0,  0), this, IDD_MIXING_BTN_APPLY);	return 0;}void RxDlgMixing::OnDestroy() {	RxDlgCommon::OnDestroy();		if(m_pBtnClose)			delete m_pBtnClose;	if(m_pBtnILevel)		delete m_pBtnILevel;	if(m_pBtnALevel)		delete m_pBtnALevel;	if(m_pBtnApply)			delete m_pBtnApply;}void RxDlgMixing::OnDraw(CDC *pDC){	RxDlgCommon::OnDraw(pDC);	CFont		font, *pOldFont;	font.CreateFont(17, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS,					CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("Arial"));	pOldFont = pDC->SelectObject(&font);	pDC->SetBkMode(TRANSPARENT);	pDC->TextOut( 10, 25, _T("Float"));	pDC->TextOut(130, 25, _T("Reference"));	pDC->SelectObject(pOldFont);	font.DeleteObject();	DrawMRate(pDC);}void RxDlgMixing::DrawMRate(CDC *pDC){	CFont	*pOldFont = pDC->SelectObject(GetFont());	pDC->SetBkMode(TRANSPARENT);	CRect	rcSlider, rcGrip, rcTemp;	CSize	szText;	CString	strTemp;	rcSlider.SetRect(m_rcMRate.left-1, m_rcMRate.top-1, m_rcMRate.right+1, m_rcMRate.bottom+1);	pDC->Draw3dRect(rcSlider, RGB(0,0,0), RGB(0,0,0));	rcGrip.SetRect(m_nMRatePi, m_rcMRate.top, m_nMRatePi+m_nGripSize, m_rcMRate.bottom);	pDC->Draw3dRect(rcGrip, RGB(255,0,0), RGB(255,0,0));		rcTemp.SetRect(rcSlider.left, rcSlider.top-16, m_nMRatePi, rcSlider.top);	strTemp.Format(_T("%d"), m_nMRatePo);					strTemp += _T("%");	szText = pDC->GetTextExtent(strTemp);	pDC->TextOut(rcTemp.CenterPoint().x - (szText.cx/2), rcTemp.top, strTemp);	rcTemp.SetRect(m_nMRatePi+m_nGripSize, rcSlider.top-16, rcSlider.right, rcSlider.top);	strTemp.Format(_T("%d"), m_nMRateRangeMax-m_nMRatePo);	strTemp += _T("%");	szText = pDC->GetTextExtent(strTemp);	pDC->TextOut(rcTemp.CenterPoint().x - (szText.cx/2), rcTemp.top, strTemp);	rcTemp.SetRect(rcSlider.left, rcSlider.bottom+2, rcSlider.right, rcSlider.bottom+30);	strTemp.Format(_T("%d"), m_nMRateRangeMin);		strTemp += _T("%");	pDC->DrawText(strTemp, rcTemp, DT_SINGLELINE|DT_LEFT);	strTemp.Format(_T("%d"), m_nMRateRangeMax);		strTemp += _T("%");	pDC->DrawText(strTemp, rcTemp, DT_SINGLELINE|DT_RIGHT);	pDC->SelectObject(pOldFont);}/////////////////////////////////////////////////////////////////////////////int  RxDlgMixing::PoToPi(int nPos){	int		nReturn;	float	fRatio = (float)(m_rcMRate.Width() - m_nGripSize) /	(float)(m_nMRateRangeMax - m_nMRateRangeMin);	if(nPos >= m_nMRateRangeMax)		nReturn = m_rcMRate.right - m_nGripSize;	else if(nPos <= m_nMRateRangeMin)		nReturn = m_rcMRate.left;	else		nReturn = (int)((nPos - m_nMRateRangeMin) * fRatio + m_rcMRate.left + 0.5f);	return nReturn;}int  RxDlgMixing::PiToPo(int nPixel){	int		nReturn;	float	fRatio = (float)(m_nMRateRangeMax - m_nMRateRangeMin) /	(float)(m_rcMRate.Width() - m_nGripSize);	if(nPixel >= m_rcMRate.right - m_nGripSize)		nReturn = m_nMRateRangeMax;	else if(nPixel <= m_rcMRate.left)		nReturn = m_nMRateRangeMin;	else		nReturn = (int)((nPixel - m_rcMRate.left) * fRatio + m_nMRateRangeMin + 0.5f);	return nReturn;}void RxDlgMixing::OnLButtonDown(UINT nFlags, CPoint point) {	CRect	rcGrip;	rcGrip.SetRect(m_nMRatePi, m_rcMRate.top, m_nMRatePi+m_nGripSize, m_rcMRate.bottom);		if(!rcGrip.PtInRect(point))	{		RxDlgCommon::OnLButtonDown(nFlags, point);		return;	}	int		nDiff = point.x - m_nMRatePi;	int		nOldMRatePi;	CRect	rcMRate = m_rcMRate;	rcMRate.InflateRect(30,30,30,30);	InvalidateRect(rcMRate);	SetCapture();	for (;;)	{		MSG		msg;		VERIFY(::GetMessage(&msg, NULL, 0, 0));		ScreenToClient(&msg.pt);		switch (msg.message)		{			case WM_MOUSEMOVE :				nOldMRatePi = m_nMRatePi;				m_nMRatePi = msg.pt.x - nDiff;				if(m_nMRatePi < m_rcMRate.left)					m_nMRatePi = m_rcMRate.left;				if((m_nMRatePi+m_nGripSize) > m_rcMRate.right)					m_nMRatePi = m_rcMRate.right - m_nGripSize;				if(m_nMRatePi != nOldMRatePi)				{					m_nMRatePo = PiToPo(m_nMRatePi);					InvalidateRect(rcMRate);					UpdateWindow();					SendMessageToParent();				}				break;			case WM_LBUTTONUP :				goto EndLButtonDown;			default :	// just dispatch rest of the messages				DispatchMessage(&msg);				break;		}	}EndLButtonDown :	ReleaseCapture();	InvalidateRect(rcMRate);	SendMessageToParent();}void RxDlgMixing::SendMessageToParent(){	_NMDLG_MIXING			hdrMixing;	hdrMixing.hdr.hwndFrom	= m_pBtnApply->GetSafeHwnd();	hdrMixing.hdr.idFrom	= IDD_MIXING_BTN_APPLY;	hdrMixing.hdr.code		= NM_DLG_MIXING_APPLY;	hdrMixing.nLevelStyle	= m_nRadioLevel;	hdrMixing.nMixingRate	= m_nMRatePo;	if (m_pParentWnd)		m_pParentWnd->SendMessage(WM_NOTIFY, hdrMixing.hdr.idFrom, (LPARAM)&hdrMixing);}void RxDlgMixing::OnControls(UINT nID){	switch(nID)	{		case IDD_MIXING_BTN_ILEVEL :		case IDD_MIXING_BTN_ALEVEL :		{			int		nIndex = nID - IDD_MIXING_BTN_ILEVEL;			if(m_nRadioLevel != nIndex)			{				SetRadioLevel(nID - IDD_MIXING_BTN_ILEVEL);				SendMessageToParent();			}			break;		}	}}void RxDlgMixing::OnCancel(){	RxDlgCommon::OnCancel();	NMHDR			hdr;	hdr.hwndFrom	= m_pBtnApply->GetSafeHwnd();	hdr.idFrom		= IDD_MIXING_BTN_APPLY;	hdr.code		= NM_DLG_MIXING_CANCEL;	if (m_pParentWnd)		m_pParentWnd->SendMessage(WM_NOTIFY, hdr.idFrom, (LPARAM)&hdr);}void RxDlgMixing::SetRadioLevel(int nIndex){	if(m_pBtnILevel->GetCheck())		m_pBtnILevel->SetCheck(0);	else if(m_pBtnALevel->GetCheck())	m_pBtnALevel->SetCheck(0);	m_nRadioLevel = nIndex;	switch(nIndex)	{		case	0 :			m_pBtnILevel->SetCheck(1);			break;		case	1 :			m_pBtnALevel->SetCheck(1);			break;		default :			m_nRadioLevel = -1;			break;	}}int	 RxDlgMixing::GetRadioLevel(){	return m_nRadioLevel;}void RxDlgMixing::SetMixingRate(int nRate){	m_nMRatePo = nRate;	m_nMRatePi = PoToPi(nRate);	CRect	rcMRate = m_rcMRate;	rcMRate.InflateRect(30,30,30,30);	InvalidateRect(rcMRate);}int	 RxDlgMixing::GetMixingRate(){	return m_nMRatePo;}

⌨️ 快捷键说明

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