3. 在每个对话框里面添加需要的控件。
在每个不同平差类型的对话框中添加能够实现不同功能的函数,响应函数的不同决定了不同的执行结果。
4. 给每个需要实现不同功能的函数添加消息响应函数。
条件平差的计算和保存响应函数: void CTjpc1::OnButton1() { // TODO: Add your control notification handler code here
UpdateData(); // 在这里义了这几个矩阵 CMatrix jza,jza1,jzw,jzq,jzv,jzv1,jzn,jzk,jza0; double a0,r; // 将输入的已知矩阵各元素由字符转化为数值 jza.FromString(m_1edit1); jzw.FromString(m_1edit2); jzq.FromString(m_1edit3); r=1.0/(jza.GetNumRows()); jza1=jza.Transpose(); jzn=jza*jzq*jza1; // 求jzn的逆矩阵 if(jzn.InvertGaussJordan()) m_1edit4=jzn.ToString(\ else m_1edit4=\失败\
-20-
jzn.FromString(m_1edit4); jzk=jzn*jzw*(-1); // 求出由各个数值的改正数组成的jzv jzv=jzq*jza1*jzk; m_1edit4=jzv.ToString(\ jzv1=jzv.Transpose(); // 求协因数阵的逆矩阵权阵,此处用jzq代替一下 if(jzq.InvertGaussJordan()) m_1edit5=jzq.ToString(\ else m_1edit5=\失败\ jzq.FromString(m_1edit5); jza0=jzv1*jzq*jzv; jza0=jza0*r; m_1edit5=jza0.ToString(\ a0=atof(m_1edit5); a0=sqrt(a0); m_1edit5.Format(\ // 将所求得的输入到第四个框和第五个框里 GetDlgItem(IDC_EDIT4)->SetWindowText(m_1edit4); GetDlgItem(IDC_EDIT5)->SetWindowText(m_1edit5); CFile file;
file.Open(\CFile::modeNoTruncate |CFile::modeWrite);
file.SeekToEnd(); CString a=\ file.Write(a,strlen(a)); file.Write(\条件平差的记录数据:\条件平差的记录数据:\
file.Write(a,strlen(a)); file.Write(\矩阵为:\矩阵为:\ file.Write(a,strlen(a));
file.Write(m_1edit1, strlen(m_1edit1)); file.Write(a,strlen(a)); file.Write(\矩阵为:\矩阵为:\ file.Write(a,strlen(a)); file.Write(m_1edit2, strlen(m_1edit2)); file.Write(a,strlen(a)); file.Write(\矩阵为:\矩阵为:\ file.Write(a,strlen(a)); file.Write(m_1edit3, strlen(m_1edit3)); file.Write(a,strlen(a));
-21-
file.Write(\矩阵为:\矩阵为:\ file.Write(a,strlen(a)); file.Write(m_1edit4, strlen(m_1edit4)); file.Write(a,strlen(a)); file.Write(\单位中误差为:\单位中误差为:\
file.Write(a,strlen(a)); file.Write(m_1edit5, strlen(m_1edit5)); file.Write(a,strlen(a)); file.Close(); UpdateData(FALSE); }
清零的函数:
void CTjpc1::OnButton2() { // TODO: Add your control notification handler code here
GetDlgItem(IDC_EDIT1)->SetWindowText(NULL); GetDlgItem(IDC_EDIT2)->SetWindowText(NULL); GetDlgItem(IDC_EDIT3)->SetWindowText(NULL); GetDlgItem(IDC_EDIT4)->SetWindowText(NULL); GetDlgItem(IDC_EDIT5)->SetWindowText(NULL); }
间接平差的计算和保存响应函数: void CJjpc2::OnButton3() { // TODO: Add your control notification handler code here
UpdateData(); CMatrix jzb,jzb1,jzp,jzw,jzl,jzv,jzv1,jzx,jzn,jza0; double a0,r;int i; jzb.FromString(m_2edit1); jzp.FromString(m_2edit2); jzl.FromString(m_2edit3); if((jzb.GetNumRows==jzp.GetNumRows)&(jzp.GetNumRows==jzl.GetNumRows))
{ i=(jzb.GetNumRows()-jzb.GetNumColumns()); r=1.0/i; jzb1=jzb.Transpose(); jzn=jzb1*jzp*jzb;//m_2edit4=jzn.ToString(\ jzw=jzb1*jzp*jzl; if(jzn.InvertGaussJordan()) m_2edit4=jzn.ToString(\
-22-
else MessageBox(\数据输入有错,请仔细查出错误,并重新输入。\
jzn.FromString(m_2edit4); jzx=jzn*jzw; jzv=(jzb*jzx-jzl); jzv1=jzv.Transpose(); jza0=jzv1*jzp*jzv*r; m_2edit5=jza0.ToString(\ a0=atof(m_2edit5); a0=sqrt(a0); m_2edit5.Format(\ m_2edit4=jzv.ToString(\ GetDlgItem(IDC_EDIT4)->SetWindowText(m_2edit4); GetDlgItem(IDC_EDIT5)->SetWindowText(m_2edit5); } else { MessageBox(\矩阵输入的有错误!请重新输入!\ } CFile file;
file.Open(\CFile::modeNoTruncate |CFile::modeWrite);
file.SeekToEnd(); CString a=\ file.Write(a,strlen(a)); file.Write(\间接平差的记录数据:\间接平差的记录数据:\
file.Write(a,strlen(a)); file.Write(\矩阵为:\矩阵为:\ file.Write(a,strlen(a));
file.Write(m_2edit1, strlen(m_2edit1)); file.Write(a,strlen(a)); file.Write(\矩阵为:\矩阵为:\ file.Write(a,strlen(a)); file.Write(m_2edit2, strlen(m_2edit2)); file.Write(a,strlen(a)); file.Write(\矩阵为:\矩阵为:\ file.Write(a,strlen(a)); file.Write(m_2edit3, strlen(m_2edit3));
-23-
file.Write(a,strlen(a)); file.Write(\矩阵为:\矩阵为:\ file.Write(a,strlen(a)); file.Write(m_2edit4, strlen(m_2edit4)); file.Write(a,strlen(a)); file.Write(\单位中误差为:\单位中误差为:\
file.Write(a,strlen(a)); file.Write(m_2edit5, strlen(m_2edit5)); file.Write(a,strlen(a)); file.Close(); UpdateData(FALSE); }
附有参数条件平差的计算和保存响应函数: void CFctjpc3::OnButton5() { // TODO: Add your control notification handler code here
UpdateData(); // 在这里义了这几个矩阵 CMatrix
jza,jza1,jzb,jzb1,jzw,jzq,jzv,jzv1,jzn1,jzn2,jzx,jzk,jza0;
double a0,r; // 将输入的已知矩阵各元素由字符转化为数值 jza.FromString(m_3edit1); jzb.FromString(m_3edit2); jzw.FromString(m_3edit3); jzq.FromString(m_3edit4);
r=1.0/(jzb.GetNumRows()-jzb.GetNumColumns()); jza1=jza.Transpose(); jzb1=jzb.Transpose(); jzn1=jza*jzq*jza1; // 求jzn的逆矩阵 if(jzn1.InvertGaussJordan()) m_3edit5=jzn1.ToString(\ else MessageBox(\数据输入有错,请仔细查出错误,并重新输入。\
jzn1.FromString(m_3edit5); jzn2=jzb1*jzn1*jzb; {
-24-