📄 besizerview.cpp
字号:
// BesizerView.cpp : implementation of the CBesizerView class
//
#include "stdafx.h"
#include "Besizer.h"
#include"math.h"
#include "BesizerDoc.h"
#include "BesizerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBesizerView
IMPLEMENT_DYNCREATE(CBesizerView, CView)
BEGIN_MESSAGE_MAP(CBesizerView, CView)
//{{AFX_MSG_MAP(CBesizerView)
ON_COMMAND(ID_Be, OnBe)
ON_WM_LBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CBesizerView construction/destruction
CBesizerView::CBesizerView()
{
// TODO: add construction code here
}
CBesizerView::~CBesizerView()
{
}
BOOL CBesizerView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CBesizerView drawing
void CBesizerView::OnDraw(CDC* pDC)
{
CBesizerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CBesizerView printing
BOOL CBesizerView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CBesizerView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CBesizerView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CBesizerView diagnostics
#ifdef _DEBUG
void CBesizerView::AssertValid() const
{
CView::AssertValid();
}
void CBesizerView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CBesizerDoc* CBesizerView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBesizerDoc)));
return (CBesizerDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CBesizerView message handlers
void CBesizerView::OnBe()
{
// TODO: Add your command handler code here
m_huitu=true;
CClientDC *pdc=new CClientDC(this);
CPen pen;
pen.CreatePen(PS_SOLID,1,RGB(0,0XEF,0));
CPen *oldpen=(CPen*)pdc->SelectObject(&pen);
int cx,cy,i,n;
n=9;
double t,t2,t3,a0,a1,a2,a3,b0,b1,b2,b3,dt,xa,ya;
static int x[4]={30,60,120,230},y[4]={30,110,150,50};
cx=10,cy=160;
a0=x[0];
a1=-3*(x[0]-x[1]);
a2=3*x[0]-6*x[1]+3*x[2];
a3=-x[0]+3*x[1]-3*x[2]+x[3];
b0=y[0];
b1=-3*(y[0]-y[1]);
b2=3*y[0]-6*y[1]+3*y[2];
b3=-y[0]+3*y[1]-3*y[2]+y[3];
dt=1.0/n;
for(i=0;i<=n;i++)
{
t=i*dt;
t2=t*t;
t3=t2*t;
xa=a0+a1*t+a2*t2+a3*t3;//+cx;cy-
ya=(b0+b1*t+b2*t2+b3*t3);
if(i==0){pdc->MoveTo(xa,ya);}
else pdc->LineTo(xa,ya);
}
pdc->DeleteDC();
}
void CBesizerView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CPoint m_dot_begin,m_dot_end;
int m_dot_number;
CDC *pDC=GetDC();
if(m_huitu)
{
m_dot_number++;
switch(m_dot_number)
{
case 1:
m_dot_begin=point;
m_dot_end=point;
break;
case 2:
m_dot_end=point;
m_dot_number=0;
m_huitu=false;
pDC->MoveTo(m_dot_begin.x,m_dot_begin.y);
pDC->LineTo(m_dot_end.x,m_dot_end.y);
break;
}
}
ReleaseDC(pDC);
CView::OnLButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -