matrixlibmdiview.cpp

来自「MATLAB混合编程想把matlab强大的功能用在自己的工程实践中吗这是本不错的」· C++ 代码 · 共 143 行

CPP
143
字号
// MatrixLibMDIView.cpp : implementation of the CMatrixLibMDIView class
//

#include "stdafx.h"
#include "MatrixLibMDI.h"

#include "MatrixLibMDIDoc.h"
#include "MatrixLibMDIView.h"

#include <matlib.h>

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

/////////////////////////////////////////////////////////////////////////////
// CMatrixLibMDIView

IMPLEMENT_DYNCREATE(CMatrixLibMDIView, CView)

BEGIN_MESSAGE_MAP(CMatrixLibMDIView, CView)
	//{{AFX_MSG_MAP(CMatrixLibMDIView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMatrixLibMDIView construction/destruction

CMatrixLibMDIView::CMatrixLibMDIView()
{
	// TODO: add construction code here
	init=false;
}

CMatrixLibMDIView::~CMatrixLibMDIView()
{
}

BOOL CMatrixLibMDIView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMatrixLibMDIView drawing

void CMatrixLibMDIView::OnDraw(CDC* pDC)
{
	CMatrixLibMDIDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here

	if (!init)
	{
		initM(MATCOM_VERSION);  //Matrix<LIB>初始化
		
		Mm h = winaxes(m_hWnd);          //在MFC窗口句柄创建坐标轴
		axesposition(10,10,100,90);      //定义坐标轴在窗口中位置
		
		Mm  t; 
		t=linspace(0, 4*pi);
		plot((CL(t),sin(t),TM("r*")));    //画正弦曲线
		hold(TM("on"));					  //避免屏幕重绘操作
		
		//准备画余弦曲线            
		plot((CL(t),cos(t),TM("b-")));    
		
		//标注坐标轴
		title((CL(TM("Random plot"))));
		xlabel((CL(TM("This is the x axis"))));
		ylabel((CL(TM("This is the y axis"))));
		
		//设置绘图区属性
		set(h,(CL(TM("Color")),TM("white")));
		set(h,(CL(TM("Box")),TM("on")));
		set(gcf(),(CL(TM("Color")),TM("white")));
		set(gcf(),(CL(TM("Box")),TM("on")));
		set(gcf(), TM("MenuAbout"), TM("off"));
		set(gcf(), TM("MenuBar"), TM("None"));
//		set(gcf(), TM("IconFile"), TM("matlab.ico"));
		
		init=true;
	}
	
	drawnow();          //开始画图
	exitM();			 //退出Matrix<LIB)
	
}

/////////////////////////////////////////////////////////////////////////////
// CMatrixLibMDIView printing

BOOL CMatrixLibMDIView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMatrixLibMDIView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMatrixLibMDIView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMatrixLibMDIView diagnostics

#ifdef _DEBUG
void CMatrixLibMDIView::AssertValid() const
{
	CView::AssertValid();
}

void CMatrixLibMDIView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMatrixLibMDIDoc* CMatrixLibMDIView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMatrixLibMDIDoc)));
	return (CMatrixLibMDIDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMatrixLibMDIView message handlers

⌨️ 快捷键说明

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