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

📄 microwavedlg.cpp

📁 电磁场的演示程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_2,500,NULL);
	time=0;
	
	
}

void CMicroWaveDlg::OnRadio10() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_10,500,NULL);
	time=0;

	
}

void CMicroWaveDlg::OnRadio11() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_11,500,NULL);
	time=0;
	
}

void CMicroWaveDlg::OnRadio12() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_12,500,NULL);
	time=0;
	
}

void CMicroWaveDlg::OnRadio13() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}
	
}

void CMicroWaveDlg::OnRadio3() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_3,500,NULL);
	time=0;
	
}

void CMicroWaveDlg::OnRadio4() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_4,500,NULL);
	time=0;
	
}

void CMicroWaveDlg::OnRadio5() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_5,500,NULL);
	time=0;
	
}

void CMicroWaveDlg::OnRadio6() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_6,500,NULL);
	time=0;
	
}

void CMicroWaveDlg::OnRadio7() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_7,500,NULL);
	time=0;
	
}

void CMicroWaveDlg::OnRadio8() 
{
	// TODO: Add your control notification handler code here

	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_8,500,NULL);
	time=0;
	
}

void CMicroWaveDlg::OnRadio9() 
{
	// TODO: Add your control notification handler code here
	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_9,500,NULL);
	time=0;

	
}

void CMicroWaveDlg::OnRadio14() 
{
	// TODO: Add your control notification handler code here
	Invalidate();
	for(int i=ID_TIME_1;i<=ID_TIME_14;i++)
	{
		KillTimer(i);
	}

	SetTimer(ID_TIME_14,50,NULL);
	time=0;

	angle=19;
	interval=15;
	step=3;

	angle=angle/360*2*PI;
	interval=interval/360*2*PI;
	step=step/360*2*PI;

/*			char str[80];
		sprintf(str,"angle=%f  interval=%f",angle,interval);
		MessageBox(str);
*/
	
}

void CMicroWaveDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CClientDC dc(this);
	CRect rc1;
	CString r_x,gamma_theta;
	GetClientRect(&rc1);
	rc1.right-=OFFSET;
	dc.SetMapMode(MM_ANISOTROPIC);
	dc.SetWindowExt(2300,-2300);
	if(b_Mark2)
	{
		rc1.bottom=rc1.bottom*2/3-50;
	}

	dc.SetViewportExt((rc1.Width()<=rc1.Height())*rc1.Width()+(rc1.Width()>rc1.Height())*rc1.Height(),(rc1.Width()<=rc1.Height())*rc1.Width()+(rc1.Width()>rc1.Height())*rc1.Height());
	dc.SetViewportOrg(rc1.right/2,rc1.bottom/2);

	dc.DPtoLP(&point);
	float r,x,gamma_u,gamma_v,gamma,theta;
	CWnd* pWnd = GetDlgItem(IDC_R_X);
	CWnd* pWnd2=GetDlgItem(IDC_GAMMA_THETA);
//	pWnd->SetWindowText(_T("Hockey is best!"));


	gamma_u=(float)point.x/SCALE;
	gamma_v=(float)point.y/SCALE;

	if(gamma_u*gamma_u+gamma_v*gamma_v>1)
	{
//		m_R.Format(_T("R=NaN"));
//		m_X.Format(_T("X=NaN"));
//		UpdateData(true);
//		UpdateData(false);
		pWnd2->SetWindowText(_T("Γ=NaN     θ=NaN"));
		if (b_Mark1)
		{
			pWnd->SetWindowText(_T("R=NaN	    X=NaN"));
		}
		else
		{
			pWnd->SetWindowText(_T("G=NaN	    B=NaN"));
		}

				
	}
	else
	{
		r=(1-gamma_u*gamma_u-gamma_v*gamma_v)/((1-gamma_u)*(1-gamma_u)+gamma_v*gamma_v);
		x=2*gamma_v/((1-gamma_u)*(1-gamma_u)+gamma_v*gamma_v);

		gamma=sqrt(gamma_u*gamma_u+gamma_v*gamma_v);
		theta=atan(gamma_v/gamma_u)/(2*PI)*360;
		
		if(gamma_u>=0&&gamma_v>=0)
			theta=theta;			
		else if(gamma_u>=0&&gamma_v<0)
			theta=theta+360;
		else theta=theta+180;
		

		gamma_theta.Format(_T("Γ=%.3f   θ=%.3f"),gamma,theta);
		if (b_Mark1)
		{
			r_x.Format(_T("R=%.3f	    X=%.3f"),r,x);
		}
		else
		{
			r_x.Format(_T("G=%.3f	    B=%.3f"),r,x);
		}
		

		pWnd2->SetWindowText(_T(gamma_theta));

		pWnd->SetWindowText(_T(r_x));


	}

	
	CDialog::OnMouseMove(nFlags, point);
}

void CMicroWaveDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here

	UpdateData(true);
	drawr(m_Edit_R,RGB(0,255,0),5);
	drawx(m_Edit_X,RGB(0,255,0),5);
	
}


void CMicroWaveDlg::draw_chart()
{
		drawx(2,RGB(255,255,0));
		drawx(1,RGB(255,255,0));
		drawx(0.5,RGB(255,255,0));
		drawx(-0.5,RGB(255,255,0));
		drawx(-1,RGB(255,255,0));
		drawx(-2,RGB(255,255,0));
}


int CMicroWaveDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
//	AnimateWindow(m_hWnd,1000,0x00040000|0x00020000);
	
	return 0;
}

void CMicroWaveDlg::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	
	AnimateWindow(m_hWnd,300,0x00010000|0x00000010);
	
	CDialog::OnClose();
}

void CMicroWaveDlg::CalculateControlPos1()//计算Smith Chart面板内所有控件的位置
{
	CRect rc1, rc2;
	int i;
	GetClientRect(&rc1);

	CWnd *pWndCtrl = NULL;

	pWndCtrl=GetDlgItem(m_Box1ID[0]);
	if(pWndCtrl!=NULL){
		pWndCtrl->GetWindowRect(&rc2);
		ScreenToClient(&rc2);
		pWndCtrl->MoveWindow(rc1.right-OFFSET,rc2.top,OFFSET,rc2.Height());
		
	}

	
	for(i=1;i<=11;i++){
		pWndCtrl=GetDlgItem(m_Box1ID[i]);
		if(pWndCtrl!=NULL){
			pWndCtrl->GetWindowRect(&rc2);
			ScreenToClient(&rc2);
			pWndCtrl->MoveWindow(rc1.right-OFFSET+10,rc2.top,rc2.Width(),rc2.Height());
		}
	}

	pWndCtrl=GetDlgItem(m_Box1ID[4]);
	if(pWndCtrl!=NULL){
		pWndCtrl->GetWindowRect(&rc2);
		ScreenToClient(&rc2);
		pWndCtrl->MoveWindow(rc1.right-OFFSET+5,rc2.top,rc2.Width(),rc2.Height());
	}


	for(i=12;i<BOX1_NUMBER;i++)
	{
		pWndCtrl=GetDlgItem(m_Box1ID[i]);
		if(pWndCtrl!=NULL){
			pWndCtrl->GetWindowRect(&rc2);
			ScreenToClient(&rc2);
			pWndCtrl->MoveWindow(rc1.right-OFFSET/2,rc2.top,rc2.Width(),rc2.Height());
		}

	}

	if(b_Mark2)//此处为后来添加
	{
		pWndCtrl = GetDlgItem( IDC_GAMMA_THETA );
		if(pWndCtrl!=NULL)
		{
			pWndCtrl->GetWindowRect(&rc2);
			ScreenToClient(&rc2);
			pWndCtrl->MoveWindow(rc1.right-OFFSET+10,rc2.top,rc2.Width(),rc2.Height());
		}
		pWndCtrl = GetDlgItem( IDC_R_X );
		if(pWndCtrl!=NULL)
		{
			pWndCtrl->GetWindowRect(&rc2);
			ScreenToClient(&rc2);
			pWndCtrl->MoveWindow(rc1.right-OFFSET+10,rc2.top,rc2.Width(),rc2.Height());

		}
	}



}

void CMicroWaveDlg::CalculateControlPos2()//计算单分支匹配面板内所有控件的位置
{
	CRect rc1, rc2;
	int i;
	GetClientRect(&rc1);

	CWnd *pWndCtrl = NULL;
	
	pWndCtrl=GetDlgItem(m_Box2ID[0]);
	if(pWndCtrl!=NULL){
		pWndCtrl->GetWindowRect(&rc2);
		ScreenToClient(&rc2);
		if(b_Mark2){
			pWndCtrl->MoveWindow(rc1.right-OFFSET,rc1.top+30,OFFSET,rc2.Height());
		}
		else
		{
//			pWndCtrl->MoveWindow(rc1.right-OFFSET,rc1.bottom-rc2.Height(),OFFSET,rc2.Height());
			pWndCtrl->MoveWindow(rc1.right-OFFSET,400,OFFSET,rc2.Height());

		}
		

	}

	pWndCtrl=GetDlgItem(m_Box2ID[1]);
	if(pWndCtrl!=NULL){
		pWndCtrl->GetWindowRect(&rc2);
		ScreenToClient(&rc2);
		pWndCtrl->MoveWindow(rc1.right-OFFSET+5,rc2.top,rc2.Width(),rc2.Height());
	}
	
	for(i=2;i<=6;i++){
		pWndCtrl=GetDlgItem(m_Box2ID[i]);
		if(pWndCtrl!=NULL){
			pWndCtrl->GetWindowRect(&rc2);
			ScreenToClient(&rc2);
			pWndCtrl->MoveWindow(rc1.right-OFFSET+10,rc2.top,rc2.Width(),rc2.Height());
		}

	}


	pWndCtrl=GetDlgItem(m_Box2ID[3]);	
	if(pWndCtrl!=NULL){
		pWndCtrl->GetWindowRect(&rc2);
		ScreenToClient(&rc2);
		pWndCtrl->MoveWindow(rc1.right-OFFSET+5,rc2.top,rc2.Width(),rc2.Height());
	}


	for(i=7;i<=9;i++)
	{
		pWndCtrl=GetDlgItem(m_Box2ID[i]);
		if(pWndCtrl!=NULL){
			pWndCtrl->GetWindowRect(&rc2);
			ScreenToClient(&rc2);
			pWndCtrl->MoveWindow(rc1.right-OFFSET/2,rc2.top,rc2.Width(),rc2.Height());
		}

	}

	pWndCtrl=GetDlgItem(m_Box2ID[10]);
	if(pWndCtrl!=NULL){
		pWndCtrl->GetWindowRect(&rc2);
		ScreenToClient(&rc2);
		pWndCtrl->MoveWindow(rc1.right-OFFSET/2-25,rc2.top,rc2.Width(),rc2.Height());
	}


	pWndCtrl=GetDlgItem(m_Box2ID[11]);
	if(pWndCtrl!=NULL){
		pWndCtrl->MoveWindow(20,rc1.bottom*2/3,rc1.Width()-OFFSET-30,rc1.bottom/3-20);
	}

	if(b_Mark2)//此处为后来添加
	{
		pWndCtrl = GetDlgItem( IDC_GAMMA_THETA );
		if(pWndCtrl!=NULL)
		{
			pWndCtrl->GetWindowRect(&rc2);
			ScreenToClient(&rc2);
			pWndCtrl->MoveWindow(rc1.right-OFFSET+10,rc2.top,rc2.Width(),rc2.Height());
		}
		pWndCtrl = GetDlgItem( IDC_R_X );
		if(pWndCtrl!=NULL)
		{
			pWndCtrl->GetWindowRect(&rc2);
			ScreenToClient(&rc2);
			pWndCtrl->MoveWindow(rc1.right-OFFSET+10,rc2.top,rc2.Width(),rc2.Height());

		}
	}


}

void CMicroWaveDlg::SetControlPos1()//设置Smith Chart面板内所有控件的位置
{

}

void CMicroWaveDlg::SetControlPos2()//设置单分支匹配面板内所有控件的位置
{

}

void CMicroWaveDlg::ShowControlPlane1(int nShow)
{
	CWnd *pWnd=NULL;
	for( int i=1; i<BOX1_NUMBER; i++ )
	{
		pWnd = GetDlgItem( m_Box1ID[i] );
		if(pWnd!=NULL)
			pWnd->ShowWindow( nShow );
	}
	
	if(b_Mark2)//此处为后来添加
	{
		pWnd = GetDlgItem( IDC_GAMMA_THETA );
		if(pWnd!=NULL)
		{
			pWnd->ShowWindow(SW_SHOW);
		}
		pWnd = GetDlgItem( IDC_R_X );
		if(pWnd!=NULL)
		{

⌨️ 快捷键说明

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