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

📄 wholemapdialog.cpp

📁 可调节自适应滤波器-代码.rar
💻 CPP
字号:
// WholeMapDialog.cpp : implementation file
//

#include "stdafx.h"
#include "Rader.h"
#include "RaderDoc.h"
#include "RaderView.h"
#include "WholeMapDialog.h"
#include "MainFrm.h"

#include <math.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define MAXCOLOR		256
/////////////////////////////////////////////////////////////////////////////
// CWholeMapDialog dialog

CWholeMapDialog::CWholeMapDialog(CView* pParent /*=NULL*/)
	: CDialog(CWholeMapDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CWholeMapDialog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_pView = pParent;
	m_bSelect = FALSE;

	m_pDisplayData = NULL;
	m_pData = NULL;
}

CWholeMapDialog::~CWholeMapDialog()
{
	if(m_pData != NULL)
		delete[] m_pData;
	if(m_pDisplayData!=NULL)
		delete[] m_pDisplayData;
}
void CWholeMapDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CWholeMapDialog)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CWholeMapDialog, CDialog)
	//{{AFX_MSG_MAP(CWholeMapDialog)
	ON_WM_LBUTTONDOWN()
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONUP()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWholeMapDialog message handlers

void CWholeMapDialog::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(point.x>m_NewRect.left&&
	 point.x<m_NewRect.right&&
	 point.y>m_NewRect.top&&
	 point.y<m_NewRect.bottom)
	{
		m_bSelect = TRUE;
		SetCapture();
		m_nDeltaX = point.x-m_NewRect.left;
		m_nDeltaY = point.y-m_NewRect.top;
	}
	
	CDialog::OnLButtonDown(nFlags, point);
}

void CWholeMapDialog::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(!m_bSelect)
	{
		if(point.x>m_NewRect.left&&
			point.x<m_NewRect.right&&
			point.y>m_NewRect.top&&
			point.y<m_NewRect.bottom)
			::SetCursor( AfxGetApp()->LoadCursor(IDC_MOVECURSOR) );
		else
			::SetCursor( AfxGetApp()->LoadStandardCursor(IDC_ARROW) );
	}
	else
	{
		::SetCursor( AfxGetApp()->LoadCursor(IDC_MOVECURSOR) );

		RECT TheRect;
		CRect rect;
		GetClientRect(rect);

		TheRect.left = point.x-m_nDeltaX;
		if( TheRect.left < 0 )
			TheRect.left = 0;
		else if(TheRect.left + m_OldRect.Width() > rect.Width())
			TheRect.left = rect.Width() - m_OldRect.Width();

		TheRect.top = point.y-m_nDeltaY;
		if( TheRect.top < 0 )
			TheRect.top = 0;
		else if(TheRect.top + m_OldRect.Height() > rect.Height())
			TheRect.top = rect.Height() - m_OldRect.Height();

		TheRect.right = TheRect.left + m_OldRect.Width();
		TheRect.bottom = TheRect.top + m_OldRect.Height();
		m_NewRect = TheRect;
		CClientDC *dc=new CClientDC(this);
		dc->SetROP2(R2_NOT);
		dc->MoveTo(m_OldRect.left,m_OldRect.top);
		dc->LineTo(m_OldRect.right,m_OldRect.top);
		dc->LineTo(m_OldRect.right,m_OldRect.bottom);
		dc->LineTo(m_OldRect.left,m_OldRect.bottom);
		dc->LineTo(m_OldRect.left,m_OldRect.top);

		dc->MoveTo(m_NewRect.left,m_NewRect.top);
		dc->LineTo(m_NewRect.right,m_NewRect.top);
		dc->LineTo(m_NewRect.right,m_NewRect.bottom);
		dc->LineTo(m_NewRect.left,m_NewRect.bottom);
		dc->LineTo(m_NewRect.left,m_NewRect.top);
		delete dc;
		m_OldRect = m_NewRect;
	}
	CDialog::OnMouseMove(nFlags, point);
}

void CWholeMapDialog::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if(!m_bSelect)
		return;
	m_bSelect = FALSE;
	ReleaseCapture();
	float Ratio = (float)m_dwWidth/m_dwThisWidth;

	CRect rect;
	GetClientRect(rect);
	m_NewRect.left = point.x-m_nDeltaX;
	if( m_NewRect.left < 0 )
		m_NewRect.left = 0;
	else if(m_NewRect.left + m_OldRect.Width() > rect.Width())
		m_NewRect.left = rect.Width() - m_OldRect.Width();

	m_NewRect.top = point.y-m_nDeltaY;
	if( m_NewRect.top < 0 ) 
		m_NewRect.top = 0;
	else if(m_NewRect.top + m_OldRect.Height() > rect.Height())
		m_NewRect.top = rect.Height() - m_OldRect.Height();
	
	m_NewRect.right = m_NewRect.left + m_OldRect.Width();
	m_NewRect.bottom = m_NewRect.top + m_OldRect.Height();
	m_OldRect = m_NewRect;
	m_Rect.left = (int)(m_NewRect.left*Ratio);
	m_Rect.top = (int)(m_NewRect.top*Ratio);

	m_pView->PostMessage(WM_COMMAND,ID_SCROLLWINDOW,0L);

	CDialog::OnLButtonUp(nFlags, point);
}
BOOL CWholeMapDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	ASSERT(m_pData == NULL);
	CRaderDoc* pDoc = (CRaderDoc*)m_pView->GetDocument();
	ASSERT_VALID(pDoc);

	return TRUE;
}
void CWholeMapDialog::DrawImage(CDC* pDC)
{
	DWORD	i, j;
	BYTE	r;
	ASSERT(m_pData != NULL);

	for(i=0; i < m_dwThisHeight; i++)
	{
		for(j=0; j < m_dwThisWidth; j++)
		{
			r = m_pData[i * m_dwThisWidth + j];
			pDC->SetPixel(j, i, RGB(r, r, r));
		}
	}
}
void CWholeMapDialog::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
/*
	BITMAPINFO  *bmpinfo;
	bmpinfo = new BITMAPINFO;
	BITMAPINFOHEADER   bmpheader;

	bmpheader.biSize = sizeof(BITMAPINFOHEADER);
	bmpheader.biWidth = m_dwThisWidth;
	bmpheader.biHeight = m_dwThisHeight;
	bmpheader.biSizeImage = m_dwThisWidth * m_dwThisHeight * sizeof(UNDATA); 
	bmpheader.biPlanes = 1;
	bmpheader.biBitCount = 8;
	bmpheader.biCompression = BI_RGB;
	bmpheader.biSizeImage = 0L;
	bmpheader.biXPelsPerMeter = 0;
	bmpheader.biYPelsPerMeter = 0;
	bmpheader.biClrUsed = 0;
	bmpheader.biClrImportant = 0;

	bmpinfo->bmiHeader = bmpheader;

	RGBQUAD  Brgb[MAXCOLOR];
	for(int i=0;i<MAXCOLOR;i++)
	{
		Brgb[i].rgbRed=GetRValue(m_pPal[i]);
		Brgb[i].rgbGreen=GetGValue(m_pPal[i]);
		Brgb[i].rgbBlue=GetBValue(m_pPal[i]);
		Brgb[i].rgbReserved=0;
	}
	memcpy(bmpinfo->bmiColors,Brgb,MAXCOLOR*sizeof(RGBQUAD));
	
//	::StretchDIBits(dc.GetSafeHdc(),0,0,m_dwThisWidth,m_dwThisHeight,0,0,
//		  bmpheader.biWidth,bmpheader.biHeight,m_pDisplayData,bmpinfo,DIB_RGB_COLORS,SRCCOPY);
*/
	LPBYTE	pTemp = new BYTE[ sizeof( BITMAPINFOHEADER ) + 256 * sizeof( RGBQUAD ) ] ;
	for(DWORD i = 0; i < 256; i++)
	{
		pTemp[i * sizeof( RGBQUAD ) + sizeof( BITMAPINFOHEADER )] = (BYTE)i;
		pTemp[i * sizeof( RGBQUAD ) + sizeof( BITMAPINFOHEADER ) + 1] = (BYTE)i;
		pTemp[i * sizeof( RGBQUAD ) + sizeof( BITMAPINFOHEADER ) + 2] = (BYTE)i;
		pTemp[i * sizeof( RGBQUAD ) + sizeof( BITMAPINFOHEADER ) + 3] = 0;
	}
	LPBITMAPINFO	pBmi;
	pBmi = ( LPBITMAPINFO )pTemp;
	pBmi->bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
	pBmi->bmiHeader.biBitCount = 8;
	pBmi->bmiHeader.biPlanes = 1; 
	pBmi->bmiHeader.biCompression = 0; 
	pBmi->bmiHeader.biXPelsPerMeter = 0; 
	pBmi->bmiHeader.biYPelsPerMeter = 0; 
	pBmi->bmiHeader.biClrUsed = 0; 
	pBmi->bmiHeader.biClrImportant = 0; 
	pBmi->bmiHeader.biWidth = m_dwThisWidth;
	pBmi->bmiHeader.biHeight = m_dwThisHeight;
	pBmi->bmiHeader.biSizeImage = m_dwThisWidth * m_dwThisHeight * sizeof(UNDATA); 

	::StretchDIBits(dc.GetSafeHdc(),0,0,m_dwThisWidth,m_dwThisHeight,0,0,
		  pBmi->bmiHeader.biWidth,pBmi->bmiHeader.biHeight,m_pDisplayData,pBmi,DIB_RGB_COLORS,SRCCOPY);

	delete[] pTemp;

	dc.SetROP2(R2_NOT);
	dc.MoveTo(m_NewRect.left,m_NewRect.top);
	dc.LineTo(m_NewRect.right,m_NewRect.top);
	dc.LineTo(m_NewRect.right,m_NewRect.bottom);
	dc.LineTo(m_NewRect.left,m_NewRect.bottom);
	dc.LineTo(m_NewRect.left,m_NewRect.top);
}

void CWholeMapDialog::OnCancel()
{
}
void CWholeMapDialog::OnOK()
{
}
void CWholeMapDialog::Update()
{
	CClientDC *dc = new CClientDC(this);
	dc->SetROP2(R2_NOT);
	dc->MoveTo(m_OldRect.left,m_OldRect.top);
	dc->LineTo(m_OldRect.right,m_OldRect.top);
	dc->LineTo(m_OldRect.right,m_OldRect.bottom);
	dc->LineTo(m_OldRect.left,m_OldRect.bottom);
	dc->LineTo(m_OldRect.left,m_OldRect.top);

	dc->MoveTo(m_NewRect.left,m_NewRect.top);
	dc->LineTo(m_NewRect.right,m_NewRect.top);
	dc->LineTo(m_NewRect.right,m_NewRect.bottom);
	dc->LineTo(m_NewRect.left,m_NewRect.bottom);
	dc->LineTo(m_NewRect.left,m_NewRect.top);
	delete dc;
	m_OldRect = m_NewRect;
}

BOOL CWholeMapDialog::Create() 
{
	// TODO: Add your specialized code here and/or call the base class
	return CDialog::Create(CWholeMapDialog::IDD,m_pView);
}

⌨️ 快捷键说明

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