📄 dataexplatformdialog.cpp
字号:
// DataExPlatFormDialog.cpp : implementation file
//
#include "stdafx.h"
#include "MagneticPro.h"
#include "DataExPlatFormDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDataExPlatFormDialog dialog
CDataExPlatFormDialog::CDataExPlatFormDialog(CWnd* pParent /*=NULL*/)
: CDialog(CDataExPlatFormDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CDataExPlatFormDialog)
m_X = 718500; //初始化X,Y起始坐标,点数,方向
m_Y = 4668000; //初始化
m_Direction = 1; //
m_PointNum = 161;
m_StartNum = -60;
//}}AFX_DATA_INIT
PointNum=0;
xStart=m_X;
yStart=m_Y;
iStartNum=-60;
}
void CDataExPlatFormDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDataExPlatFormDialog)
DDX_Text(pDX, IDC_GETX, m_X);
DDX_Text(pDX, IDC_GETY, m_Y);
DDX_Text(pDX, IDC_DIRECT, m_Direction);
DDV_MinMaxInt(pDX, m_Direction, 0, 1);
DDX_Text(pDX, IDC_POINTNUM, m_PointNum);
DDV_MinMaxInt(pDX, m_PointNum, 10, 10000);
DDX_Text(pDX, IDC_STARTNUM, m_StartNum);
DDV_MinMaxInt(pDX, m_StartNum, -200, 600);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDataExPlatFormDialog, CDialog)
//{{AFX_MSG_MAP(CDataExPlatFormDialog)
ON_BN_CLICKED(IDC_CZM, OnCzm)
ON_BN_CLICKED(IDC_ENVI, OnEnvi)
ON_BN_CLICKED(IDC_G856, OnG856)
ON_BN_CLICKED(IDC_SUNENVI, OnSunenvi)
ON_BN_CLICKED(IDC_SAVEDAT, OnSavedat)
ON_BN_CLICKED(IDC_SAVESUN, OnSavesun)
ON_BN_CLICKED(IDC_SunCZM, OnSunCZM)
ON_BN_CLICKED(IDC_Sun_G856, OnSunG856)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDataExPlatFormDialog message handlers
////////////////////////////////////////////////////////////////////////////
//////////////// 以下是CZM-3的文件处理程序段 //////////////////////
////////////////////////////////////////////////////////////////////////////
void CDataExPlatFormDialog::OnCzm()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
PointNum=m_PointNum;
CFileDialog dlg(TRUE,_T("txt"),_T("*.txt"),
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("文本文件 (*.txT)|*.txt|"));
dlg.m_ofn.lpstrInitialDir="D:\\by\\CZM-3\\DATA";
dlg.m_ofn.lpstrTitle="打开CZM-3数据文件";
if (dlg.DoModal())
{
CStdioFile *pFile=new CStdioFile;
//char strTemp[9];
CString strTemp="",str1,str2;
int iLong=40;
strTemp=dlg.GetFileName();
if(strTemp=="")
{
::AfxMessageBox("Filename is empty!");
}
else
{
try{
pFile->Open(dlg.GetFileName(),CFile::modeRead); // 打开文件指针
for(int i=0;i<4;i++ )
pFile->ReadString(strTemp);
for(int i=0;i<PointNum;i++)
{
pFile->ReadString(strTemp);
iLong=strTemp.GetLength();
if(iLong<40)
goto s;
mdata[i]=atof(strTemp.Mid(30,8));
RecTime[i]=strTemp.Mid(40,9);
}
s: pFile->Close();
}
catch(...)
{
::AfxMessageBox("The format of the file is not match!");
}
}
}
}
////////////////////////////////////////////////////////////////////////////
//////////////// 以下是Envi的文件处理程序段 //////////////////////
////////////////////////////////////////////////////////////////////////////
void CDataExPlatFormDialog::OnEnvi()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
PointNum=m_PointNum;
CFileDialog dlg(TRUE,_T("txt"),_T("*.txt"),
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_EXPLORER|OFN_ENABLESIZING,
_T("文本文件 (*.txT)|*.txt|"));
dlg.m_ofn.lpstrInitialDir="D:\\by\\ENVI\\DATA";
dlg.m_ofn.lpstrTitle="打开ENVI数据文件";
if (dlg.DoModal())
{
CStdioFile *pFile=new CStdioFile;
//char strTemp[9];
CString strTemp="",str1,str2;
int iLong=40;
strTemp=dlg.GetFileName();
if(strTemp=="")
{
::AfxMessageBox("Filename is empty!");
}
else
{
try{
pFile->Open(dlg.GetFileName(),CFile::modeRead); // 打开文件指针
for(int i=0;i<13;i++ )
pFile->ReadString(strTemp);
for( int i=0;i<PointNum;i++)
{
pFile->ReadString(strTemp);
iLong=strTemp.GetLength();
if(iLong<40)
goto s;
mdata[i]=atof(strTemp.Mid(16,8));
RecTime[i]=strTemp.Mid(32,9);
}
s: pFile->Close();
}
catch(...)
{
::AfxMessageBox("The format of the file is not match!");
}
}
}
}
////////////////////////////////////////////////////////////////////////////
//////////////// 以下是G856的文件处理程序段 //////////////////////
////////////////////////////////////////////////////////////////////////////
void CDataExPlatFormDialog::OnG856()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
PointNum=m_PointNum;
CFileDialog dlg(TRUE,_T("dat"),_T("*.dat"),
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("数据文件 (*.dat)|*.dat|"));
if (dlg.DoModal())
{
CStdioFile *pFile=new CStdioFile;
int iLong=25;
CString strTemp="",str1,str2;
// int nHour=0,nMinute=0,nSecond=0;
// mPointNum=0;
strTemp=dlg.GetFileName();
if(strTemp=="")
{
::AfxMessageBox("Filename is empty!");
}
else
{
try{
pFile->Open(dlg.GetFileName(),CFile::modeRead); // 打开文件指针
//for(int i=0;i<13;i++ )
// pFile->ReadString(strTemp);
for( int i=0;i<PointNum;i++)
{
pFile->ReadString(strTemp);
iLong=strTemp.GetLength();
if(iLong<25)
goto s;
mdata[i]=atof(strTemp.Right(7))/10.0;
RecTime[i]=strTemp.Mid(9,2)+":"+strTemp.Mid(11,2)+":"+strTemp.Mid(13,2)+" ";
}
s: pFile->Close();
}
catch(...)
{
::AfxMessageBox("The format of the file is not match!");
}
}
}
}
////////////////////////////////////////////////////////////////////////////
//////////////// 以下是ENVI日变数据文件处理程序段 //////////////////////
////////////////////////////////////////////////////////////////////////////
void CDataExPlatFormDialog::OnSunenvi()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
PointNum=m_PointNum;
CFileDialog dlg(TRUE,_T("txt"),_T("*.txt"),
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("文本文件 (*.txT)|*.txt|"));
if (dlg.DoModal())
{
CStdioFile *pFile=new CStdioFile;
//char strTemp[9];
CString strTemp="",str1,str2;
// int nHour=0,nMinute=0,nSecond=0;
// mPointNum=0;
strTemp=dlg.GetFileName();
if(strTemp=="")
{
::AfxMessageBox("Filename is empty!");
}
else
{
pFile->Open(dlg.GetFileName(),CFile::modeRead); // 打开文件指针
pFile->ReadString(strTemp);
strTemp=strTemp+"\n";
sPointNum=0;
while(/*(strTemp!="")||*/( sPointNum<2000))
{
sdata[sPointNum]=atof(strTemp.Right(8));
sRecTime[sPointNum]=(atof(strTemp.Left(10)));//*1000000;
pFile->ReadString(strTemp);
sPointNum++;
};
pFile->Close();
}
}
ProSunData();
}
////////////////////////////////////////////////////////////////////////////
////////////////以下是CZM-3,ENVI,G856输出数据处理程序段////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -