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

📄 nllbfdlg.cpp

📁 平均功率谱密度多维分形,可以计算二维位场数据的分维值
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// nllbfDlg.cpp : implementation file
//
//**********************************************************//
//程序功能:利用求和法划分背景异常值
//参数设置:
//
//**********************************************************//
//作者:柯丹
//时间:2004年4月15日
//版本:1.0
//修改时间:2004年5月26日
//**********************************************************//

#include "stdafx.h"
#include "nllbf.h"
#include "nllbfDlg.h"
#include "afxtempl.h"//CArray class
#include "afx.h"
#include "math.h"
#include "afxres.h"
#include "string.h"

#define ROWS_MAX 3500///输入文件的最大行数或列数
#define COLS_MAX 3500///输入的纵分区与横分区的乘积最大值
#define IDC_TIMER 100


static char szBufStrA[13][20];////用于读取文件A头
static char szBufStrB[13][20];////用于读取文件B头

static int rows,cols,k,i,j;
static double xcor,ycor,cellsize;//定义左下角坐标及网格间距
char szBufMax[50],szBufMin[50],szBufCols[50],szBufAver[50];
char szBufParameter[50],szBufDataIn[200];
char szBufPa[200][20];//最大可设置200个r值
char szBufR[50][20],szBufDataOut[200];
//int  lengthh,lengthv;
float datamax,datamin,dataaver;//最大值,最小值及平均值
float dtmida,dtmidb;//中间变量a,b
FILE * fpPa,* fpIn,* fpOut;//文件输入和文件输出

NMHDR* pNMHDR;
LRESULT* pResult;

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
CNumber CNllbfDlg::CAdd(CNumber c1,CNumber c2)
{
	CNumber c;
	c.re=c1.re+c2.re;
	c.im=c1.im+c2.im;
	return c;
}
CNumber CNllbfDlg::CSub(CNumber c1,CNumber c2)
{
	CNumber c;
	c.re=c1.re-c2.re;
	c.im=c1.im-c2.im;
	return c;
}
CNumber CNllbfDlg::CMul(CNumber c1,CNumber c2)
{
	CNumber c;
	c.re=c1.re*c2.re-c1.im*c2.im;
	c.im=c1.re*c2.im+c2.re*c1.im;
	return c;
}

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNllbfDlg dialog

CNllbfDlg::CNllbfDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CNllbfDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CNllbfDlg)
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CNllbfDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CNllbfDlg)
	DDX_Control(pDX, IDC_EDIT_AVERAGE, m_EditAverage);
	DDX_Control(pDX, IDC_EDIT_FIELIND, m_EditDataInB);
	DDX_Control(pDX, IDC_EDIT_MIN, m_EditMin);
	DDX_Control(pDX, IDC_EDIT_MAX, m_EditMax);
	DDX_Control(pDX, IDC_EDIT_NCELLSIZE, m_EditCellSize);
	DDX_Control(pDX, IDC_STATIC_STATUS, m_Status);
	DDX_Control(pDX, IDC_EDIT_FILEOUT, m_EditDataOut);
	DDX_Control(pDX, IDC_EDIT_NCOLS, m_EditCols);
	DDX_Control(pDX, IDC_EDIT_NROWS, m_EditRows);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CNllbfDlg, CDialog)
	//{{AFX_MSG_MAP(CNllbfDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_FILE_OUT, OnButtonFileOut)
	ON_EN_CHANGE(IDC_EDIT_NCOLS, OnChangeEditNcols)
	ON_EN_CHANGE(IDC_EDIT_NROWS, OnChangeEditNrows)
	ON_BN_CLICKED(IDC_BUTTON_FILE_INB, OnButtonFileInb)
	//}}AFX_MSG_MAP
    ON_WM_TIMER()
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNllbfDlg message handlers

BOOL CNllbfDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

		
	// TODO: Add extra initialization here
	m_EditRows.SetWindowText("");
	m_EditCols.SetWindowText("");
	m_EditMax.SetWindowText(""); 
	m_EditMin.SetWindowText(""); 
	m_Status.SetWindowText("");
	//time set
	//COleDateTime dtMin(1998,1,1,0,0,0);
    //COleDateTime dtMax(1998,1,1,0,0,0);
	//m_MyTime.SetRange(&dtMin,&dtMax);
    //m_MyTime.SetFormat("mm':'ss");
	//m_MyTime.SetTime(COleDateTime(0,0));
	//m_MyTime.GetTime();
	///m_ProcessStrong.ShowWindow(SW_HIDE);//隐藏进程条
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE

    




	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CNllbfDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CNllbfDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CNllbfDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CNllbfDlg::OnOK() 
{
	// TODO: Add extra validation here
	//m_MyTime.SetFormat("yyy'/'MM'/'dd''HH':'mm':'ss");
	//m_MyTime.SetFormat("mm':'ss");
	//m_MyTime.SetTime(COleDateTime(0,0));
    //COleDateTime dtChosenTime;
	//m/_MyTime.GetTime(dtChosenTime);
	//m_Time.SetWindowText(dtChosenTime.Format("%M:%S"));
    
//COleDateTime dtChosenTime;
	
	
	
	sprintf(szBufMax,"%s","");
    sprintf(szBufMin,"%s","");
	sprintf(szBufParameter,"%s","");
	sprintf(szBufDataIn,"%s","");
	sprintf(szBufDataOut,"%s","");
	

	////获得文本框内容
	m_EditMax.GetWindowText(szBufMax,sizeof(szBufMax));//原始数据最大值
	m_EditMin.GetWindowText(szBufMin,sizeof(szBufMin));//原始数据最小值
	//m_EditParameter.GetWindowText(szBufParameter,sizeof(szBufParameter));
	m_EditDataInB.GetWindowText(szBufDataIn,sizeof(szBufDataIn));
	m_EditDataOut.GetWindowText(szBufDataOut,sizeof(szBufDataOut));
	
	
	  
       ///////读取六行文件头,取得左下角坐标及网格间距//调试成功
        //for(k=1;k<=12;k++)
	      // fscanf(fpIna,"%s",&szBufStrA[k]);
	//MessageBox("写文件失败!!!", "信息",MB_ICONINFORMATION|MB_OK);
	
	if(strlen(szBufDataIn)&&strlen(szBufDataOut)&&strlen(szBufMax)&&strlen(szBufMin))
	{
	   if(ADD(szBufDataIn,szBufDataOut))
	   {				
		  m_Status.SetWindowText("");
		  MessageBox("计算成功!!!","信息",MB_ICONINFORMATION|MB_OK);
		  CDialog::OnOK();
	   }
	   else
	   {
     	  CDialog::OnOK();
		  MessageBox("计算失败!!!","信息",MB_ICONINFORMATION|MB_OK);
	   }
	
	}
	else MessageBox( "参数不能为空!!!","信息",MB_ICONINFORMATION|MB_OK);
    
}
 
/////输出文件按钮
void CNllbfDlg::OnButtonFileOut() 
{
	// TODO: Add your control notification handler code here
	char FileHName[FILENAME_MAX];
	sprintf(FileHName,"%s","");
	OPENFILENAME ofn;
	// TODO: Add your control notification handler code here
	ofn.lStructSize       = sizeof(OPENFILENAME); 
	ofn.hwndOwner         = ::GetFocus();
	ofn.hInstance         = NULL; 
	ofn.lpstrFilter       = "文本文件(*.txt)\0*.txt\0All Files(*.*)\0*.*\0";
	ofn.lpstrCustomFilter = NULL; 
	ofn.nMaxCustFilter    = 0;
	ofn.nFilterIndex      = 0; 
	ofn.lpstrFile         = FileHName; 
	ofn.nMaxFile          = _MAX_PATH; 
	ofn.lpstrFileTitle    = NULL;
	ofn.nMaxFileTitle     = _MAX_FNAME; 
	ofn.lpstrInitialDir   = NULL;
	ofn.lpstrTitle        = "浏览"; 
	ofn.Flags             = 0;
	ofn.nFileOffset       = 0; 
	ofn.nFileExtension    = 0;
	ofn.lpstrDefExt       = "txt"; 
	ofn.lCustData         = 0L;
	ofn.lpfnHook          = NULL; 
	ofn.lpTemplateName    = NULL;
	if(GetOpenFileName(&ofn))
	{
		m_EditDataOut.SetWindowText(FileHName);
        //m_EditDataOut.SetWindowText("DataOut.txt");
	}

	
}


void CNllbfDlg::OnChangeEditNcols() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	//ncols=m_EditCols.GetWindowText; 
	
}

void CNllbfDlg::OnChangeEditNrows() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	//nrows=m_EditRows.GetWindowText;
}


//////打开原始数据文件
void CNllbfDlg::OnButtonFileInb() 
{
	// TODO: Add your control notification handler code here
	 char FileBName[FILENAME_MAX];
	 sprintf(FileBName,"%s","");
	 OPENFILENAME ofn;
	 ofn.lStructSize       = sizeof(OPENFILENAME); 

⌨️ 快捷键说明

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