www.pudn.com > DEM_TDS.rar > PointAttrib.cpp, change:2007-06-03,size:4218b


// PointAttrib.cpp : implementation file 
// 
#include "stdafx.h" 
#include "DEM.h" 
#include "PointAttrib.h" 
#include "DEMView.h" 
#include "MainFrm.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CPointAttrib dialog 
 
 
CPointAttrib::CPointAttrib(CWnd* pParent /*=NULL*/) 
	: CDialog(CPointAttrib::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CPointAttrib) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CPointAttrib::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CPointAttrib) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CPointAttrib, CDialog) 
	//{{AFX_MSG_MAP(CPointAttrib) 
	ON_WM_LBUTTONDOWN() 
	ON_WM_TIMER() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CPointAttrib message handlers 
 
void CPointAttrib::OnLButtonDown(UINT nFlags, CPoint point)  
{ 
	// TODO: Add your message handler code here and/or call default 
	 
	CDialog::OnLButtonDown(nFlags, point); 
} 
 
 
 
void CPointAttrib::UpdataPointAttrib(PointAttribData pointattrib, double Az,double El,ViewPort &viewport,DEMdata *demdata) 
{ 
	CString cs; 
	cs.Format("%.1lf",Az);	GetDlgItem(IDC_AZ)->SetWindowText(cs); 
	cs.Format("%.1lf",El);	GetDlgItem(IDC_EL)->SetWindowText(cs); 
	if(!demdata)return; 
	cs.Format("%d",pointattrib.Row);GetDlgItem(IDC_ROW)->SetWindowText(cs); 
	cs.Format("%d",pointattrib.Col);	GetDlgItem(IDC_COL)->SetWindowText(cs); 
	cs.Format("%d",pointattrib.ZoomH);	GetDlgItem(IDC_ZOOMH)->SetWindowText(cs); 
	cs.Format("%.3f",pointattrib.X);	GetDlgItem(IDC_X)->SetWindowText(cs); 
	cs.Format("%.3f",pointattrib.Y);	GetDlgItem(IDC_Y)->SetWindowText(cs); 
	cs.Format("%.3f",pointattrib.H);	GetDlgItem(IDC_H)->SetWindowText(cs); 
	cs.Format("%d",pointattrib.R);	GetDlgItem(IDC_R)->SetWindowText(cs); 
	cs.Format("%d",pointattrib.G);	GetDlgItem(IDC_G)->SetWindowText(cs); 
	cs.Format("%d",pointattrib.B);	GetDlgItem(IDC_B)->SetWindowText(cs); 
 
	cs.Format("%lf",viewport.eyex/100*demdata->Com_3D);GetDlgItem(IDC_EYEX)->SetWindowText(cs); 
	cs.Format("%lf",viewport.eyey/100*demdata->Com_3D);GetDlgItem(IDC_EYEY)->SetWindowText(cs); 
	cs.Format("%lf",viewport.eyez/100/demdata->s);	GetDlgItem(IDC_EYEZ)->SetWindowText(cs); 
	cs.Format("%lf",viewport.fosi/100/demdata->s);	GetDlgItem(IDC_FOSI)->SetWindowText(cs); 
 
	cs.Format("%.1lfm/s",viewport.speed/100/demdata->s*1000/30);GetDlgItem(IDC_SPEED)->SetWindowText(cs); 
	CClientDC dc(this); 
	CBrush brush(RGB(pointattrib.R,pointattrib.G,pointattrib.B)); 
	CRect rect(780,15,790,25); 
	dc.FillRect(rect,&brush); 
	ReleaseDC(&dc); 
} 
 
 
BOOL CPointAttrib::PreTranslateMessage(MSG* pMsg)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
       if (pMsg->message == WM_KEYDOWN) 
       { 
              NMHDR nm;    
              nm.hwndFrom = m_hWnd; 
              nm.idFrom = GetDlgCtrlID(); 
              nm.code = NM_RETURN; 
              switch (pMsg->wParam) 
              { 
              case VK_RETURN: 
                     //发送通知消息 
				  {  
					 CWnd *p=GetDlgItem(IDC_AZ); 
			         if(GetDlgItem(IDC_AZ)==GetFocus())UpDateView(); 
			         if(GetDlgItem(IDC_EL)==GetFocus())UpDateView(); 
                     GetOwner()->SendMessage(WM_NOTIFY, nm.idFrom, (LPARAM)&nm); 
                     return TRUE; 
				  } 
			  } 
		} 
	return CDialog::PreTranslateMessage(pMsg); 
} 
 
void CPointAttrib::UpDateView() 
{ 
	CMainFrame *pMainFrm=(CMainFrame *)AfxGetMainWnd(); 
	CMDIChildWnd *pChild =pMainFrm->MDIGetActive(); 
	CDEMView *pView=(CDEMView*)pChild->GetActiveView(); 
 
	double Az,El; 
	CString cs;	GetDlgItem(IDC_AZ)->GetWindowText(cs); 
	sscanf(cs,"%lf",&Az); 
	GetDlgItem(IDC_EL)->GetWindowText(cs); 
	sscanf(cs,"%lf",&El); 
 
	pView->Az=Az; 
	pView->El=El; 
	pView->InvalidateRect(NULL,FALSE); 
} 
 
void CPointAttrib::OnTimer(UINT nIDEvent)  
{ 
	// TODO: Add your message handler code here and/or call default 
	 
	CDialog::OnTimer(nIDEvent); 
}