gis拓扑生成程序.docVIP

  • 13
  • 0
  • 约6千字
  • 约 8页
  • 2021-11-12 发布于江西
  • 举报
拓扑生成程序 罗宇 使用VisualC++6.0新建一个AppWizard MFC.exe项目,目名为tuopu。 选择创建一个对话框类型的应用程序。 第一,项界面设计。 打开对话框资源IDD_TUOPU_DIALOG,界面设计如图1: 添加完控件后,打开ClassWizard,针对IDD_MY_DIALOG所指向的类CMYDlg,添加DDX成员变量; CString m_sPathName1; CString m_sPathName2; CString m_editshow; 系统自动生成如下代码: void CTuopuDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CTuopuDlg) DDX_Text(pDX, IDC_EDIT1, m_sPathName1); DDX_Text(pDX, IDC_EDIT2, m_sPathName2); DDX_Text(pDX, IDC_EDIT3, m_editshow); //}}AFX_DATA_MAP } 代码编写。 在tuopu定义如下结构体: typedef struct arArc//弧段的结构体 { int a; char Ns[20]; char Ne[20]; int Pl; int Pr; }arArc; typedef struct Point//点的结构体 { char p[20]; int po1,po2,po3; }Point; typedef struct structp//多边形的结构体 { int num; CArrayint,int arP; }structp; arArc *arc; Point *point; structp *stp; 利用类向导为控件添加功能函数: 系统自动生成的消息路由为: BEGIN_MESSAGE_MAP(CMyDlg, CDialog) //{{AFX_MSG_MAP(CMyDlg) OON_BN_CLICKED(IDC_BUTTON_OPEN1, OnButtonOpen1) ON_BN_CLICKED(IDC_BUTTON_OPEN2, OnButtonOpen2) ON_BN_CLICKED(IDC_BUTTON_RUN, OnButtonRun) ON_COMMAND(ID_EXIT, OnExit) ON_COMMAND(IDM_USE, OnUse) ON_BN_CLICKED(IDC_PUTOUT, OnPutout) //}}AFX_MSG_MAP END_MESSAGE_MAP()}} 各个功能函数代码如下: void CTuopuDlg::OnButtonOpen1() //打开文件1:结点-弧拓扑关系 { // TODO: Add your control notification handler code here CFileDialog fdlg(true,NULL,NULL,OFN_OVERWRITEPROMPT,拓扑关系文件|*.dat;*.txt|,NULL); if(fdlg.DoModal()==IDOK) {m_sPathName1=fdlg.GetPathName();} if(m_sPathName1== ) return; UpdateData(false); } void CTuopuDlg::OnButtonOpen2() //打开文件2:弧-结点拓扑关系 { // TODO: Add your control notification handler code here CFileDialog fdlg(true,NULL,NULL,OFN_OVERWRITEPROMPT,拓扑关系文件|*.dat;*.txt|,NULL); if(fdlg.DoModal()==IDOK) {m_sPathName2=fdlg.GetPathName();} if(m_sPathName2== ) return; ((CButton*)GetDlgItem(IDC_BUTTON_RUN))-EnableWindow(true); UpdateData(false); } void CTuopuDlg::GetherData()//读取文件 { UpdateData(); int i; ifstream if1(m_sPathName1); point=new Point[4]; for(i=0;i4;i++)

文档评论(0)

1亿VIP精品文档

相关文档