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

📄 inptiondlg.cpp

📁 matlab和VC混合编程的数据n倍内插处理系统
💻 CPP
字号:
// inptionDlg.cpp : implementation file
//

#include "stdafx.h"
#include "inption.h"
#include "inptionDlg.h"
#include "set.h"
#include "matlib.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

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()

/////////////////////////////////////////////////////////////////////////////
// CInptionDlg dialog

CInptionDlg::CInptionDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CInptionDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CInptionDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CInptionDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInptionDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CInptionDlg, CDialog)
	//{{AFX_MSG_MAP(CInptionDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInptionDlg message handlers

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

	// 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 CInptionDlg::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 CInptionDlg::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 CInptionDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CInptionDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	 Cset dlg;
	 dlg.DoModal();
	 int L=dlg.m_Setlength;
	 int N=dlg.m_Setn;

	 initM(MATCOM_VERSION);
 dMm(FILENAME1); dMm(PATHNAME1);//为保存文件定义
 dMm(FILENAME); dMm(PATHNAME); dMm(fid); dMm(l); dMm(a); dMm(n);  dMm(T); dMm(NT); dMm(b); dMm(fid1); 
    double old_nargin=nargin_val; if (!nargin_set) nargin_val=0.0;
    nargin_set=0;
    double old_nargout=nargout_val; if (!nargout_set) nargout_val=0.0;
    nargout_set=0;
   /*[FILENAME,PATHNAME] = */uigetfile(TM("*.dat"),TM("选择读取的数据文件"),i_o,FILENAME,PATHNAME);
    fid = fopen((BR(PATHNAME),FILENAME),TM("r"));
 
/*[a,n] = */fread(fid,L,TM("double"),i_o,a,n);

		if (ExistFigure==true) 
	{
	//	clf(1);
			UpdateData(true);
		ExistFigure=false;
	}     //对图像进行清理,准备重新绘图
 //****************************
CWnd *p1=NULL;  
p1=(CWnd *)GetDlgItem(IDC_PC1);  //得到用于显示图像Static text控件的ID
Mm plothandle1=winaxes(p1->m_hWnd);  //将Static text的句柄设置赋给画图句柄
//***************************************************
   plot((CL(a)));
   ExistFigure=true;
 
   T = colon(1.0,1.0,length(a));
   NT = colon(1.0,1.0/N,length(a));
   b = interp1(T,a,NT,TM("cubic"));//对信号进行一维N倍三次多项式插值
//******************************************
 CWnd *p2=NULL;  
 p2=(CWnd *)GetDlgItem(IDC_PC2);  //得到用于显示图像Static text控件的ID
 Mm plothandle2=winaxes(p2->m_hWnd);  //将Static text的句柄设置赋给画图句柄
//******************************************
   plot((CL(b)));

   MessageBox("请选择保存路径和重新命名文件");
   uigetfile(TM("*.dat"),TM("选择保存路径并给新文件命名"),i_o,FILENAME1,PATHNAME1);
   fid1 = fopen((BR(PATHNAME1),FILENAME1),TM("w"));
   fwrite(fid1,b,TM("double"));//保存插值以后的数据为新文件
   nargin_val=old_nargin; nargout_val=old_nargout;
   exitM();
}

⌨️ 快捷键说明

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