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

📄 dlgdel.cpp

📁 自己毕业时做的程序
💻 CPP
字号:
// DLGDEL.cpp : implementation file
//

#include "stdafx.h"
#include "RT.h"
#include "DLGDEL.h"
#include "Matrix.h"
#include "Complex.h"
#include "PandL.h"

#include<stdio.h>
#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
#include<iomanip.h>
#include<cstring>
#include<string.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDLGDEL dialog


CDLGDEL::CDLGDEL(CWnd* pParent /*=NULL*/)
	: CDialog(CDLGDEL::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDLGDEL)
	m_open1 = _T("");
	m_linenumber = 0;
	m_x = 0.0;
	m_y = 0.0;
	m_z = 0.0;
	//}}AFX_DATA_INIT
}


void CDLGDEL::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDLGDEL)
	DDX_Text(pDX, IDC_EDIT_OPEN1, m_open1);
	DDX_Text(pDX, IDC_EDIT_LINENUMBER, m_linenumber);
	DDX_Text(pDX, IDC_EDIT_X, m_x);
	DDX_Text(pDX, IDC_EDIT_Y, m_y);
	DDX_Text(pDX, IDC_EDIT_Z, m_z);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDLGDEL, CDialog)
	//{{AFX_MSG_MAP(CDLGDEL)
	ON_BN_CLICKED(IDC_BUT_OPEN1, OnButOpen1)
	ON_BN_CLICKED(IDC_BUT_DEL, OnButDel)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDLGDEL message handlers

void CDLGDEL::OnButOpen1() 
{
	// TODO: Add your control notification handler code here
	CString fileName;
	char* szFilter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||";
	CFileDialog dlg(TRUE, "txt", TEXT("name.txt"),
        OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT ,szFilter);
	
	dlg.DoModal();
	fileName = dlg.GetFileName();


	char FileFormat[4]="";

	if(fileName[0]=='\0')
	{
 		return;
	}
	for(int i=0;i<80;i++)
	{
		if(fileName[i]=='.')
		{
			for(int j=0;j<3;j++)
			{
				FileFormat[j]=fileName[i+1];
				i++;
			}
			break;
		}
	}
	if(!(FileFormat[0]=='t'||FileFormat[0]=='T'))
	{
		MessageBox("你选择的不是txt格式的文件!","Waring!",MB_ICONSTOP);
		return;
	}
	if(!(FileFormat[1]=='x'||FileFormat[1]=='X'))
	{
		MessageBox("你选择的不是txt格式的文件!","Waring!",MB_ICONSTOP);
		return;
	}
	if(!(FileFormat[2]=='t'||FileFormat[2]=='T'))
	{
		MessageBox("你选择的不是txt格式的文件!","Waring!",MB_ICONSTOP);
		return;
	}

	m_open1=fileName;
	Invalidate();
	UpdateData(FALSE);
}

void CDLGDEL::OnButDel() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	
	int i,j,k;
	double linenumber,mx,my,mz;
	i=0;j=0;k=0;
	linenumber=m_linenumber;
	mx=m_x;
	my=m_y;
	mz=m_z;
    
	CALine Line;

	CString strName= m_open1;
	Line.LoadTXTFile(strName);

	if(radio==1)
	{
		Line.Del(linenumber);
	}
	if(radio==2)
	{
		for(i=0;i<Line.m_LineList2.GetSize();i++)
		{
			if(Line.m_LineList2[i]->m_PointList2[0]->pt3.x==mx && Line.m_LineList2[i]->m_PointList2[0]->pt3.y==my && Line.m_LineList2[i]->m_PointList2[0]->pt3.z==mz)
			{
				Line.Del(i);
			}
		}
	}
	
	char save[200]="";
	CFileDialog dlgs(FALSE,"txt",NULL,
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		"txt File(*.txt)|*.txt", NULL );

	if(dlgs.DoModal()==IDOK){

		CString strSaveName= dlgs.GetPathName();
		strcat( save, strSaveName);	
	}

	ofstream outstuf;  //建立输出文件流对象
    outstuf.open(save,ios::out);  //连接文件,指定打开方式 

	int NumberOfPoint=0;
	for(i=0;i<Line.m_LineList2.GetSize();i++) //数组m[i][j]初始化
	{
       
         NumberOfPoint=NumberOfPoint+Line.m_LineList2[i]->m_PointList2.GetSize();

	}

	outstuf<<"total number of line:"<<"  "<<Line.m_LineList2.GetSize()<<"   "<<"total number of point:"<<"    "<<NumberOfPoint<<endl;
	for( i=0;i<Line.m_LineList2.GetSize();i++) //数组m[i][j]初始化
	{ 
		outstuf<<endl;
        outstuf <<"line"<<"  "<<i+1<<"  "<<"point"<<"   "<<Line.m_LineList2[i]->m_PointList2.GetSize()<<endl;
       

		for( j=0;j<Line.m_LineList2[i]->m_PointList2.GetSize();j++)
	   {
          outstuf <<Line.m_LineList2[i]->m_PointList2[j]->pt3.x <<"  "<<Line.m_LineList2[i]->m_PointList2[j]->pt3.y<<"  "<<Line.m_LineList2[i]->m_PointList2[j]->pt3.z<<"\n";  
	   }
	}
	outstuf.close();   //关闭文件
    MessageBox("删除已成功谢谢使用!","Thanks!",MB_ICONSTOP);

}

void CDLGDEL::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	radio=1;
}

void CDLGDEL::OnRadio2() 
{
	// TODO: Add your control notification handler code here
	radio=2;
}

⌨️ 快捷键说明

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