📄 zbxbhview.cpp
字号:
// ZBXBHView.cpp : implementation of the CZBXBHView class
//
#include "stdafx.h"
#include "ZBXBH.h"
#include "ZBXBHDoc.h"
#include "ZBXBHView.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CZBXBHView
IMPLEMENT_DYNCREATE(CZBXBHView, CView)
BEGIN_MESSAGE_MAP(CZBXBHView, CView)
//{{AFX_MSG_MAP(CZBXBHView)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CZBXBHView construction/destruction
CZBXBHView::CZBXBHView()
{
// TODO: add construction code here
xw1=100;
yw1=50;
zw1=80;
xw2=200;
yw2=150;
zw2=50;
a=50;
b=60;
c=50;
}
CZBXBHView::~CZBXBHView()
{
}
BOOL CZBXBHView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CZBXBHView drawing
void CZBXBHView::OnDraw(CDC* pDC)
{
CZBXBHDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
ZBXBH(pDC,xw1,yw1,zw1,xw2,yw2,zw2,a,b,c);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CZBXBHView printing
BOOL CZBXBHView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CZBXBHView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CZBXBHView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CZBXBHView diagnostics
#ifdef _DEBUG
void CZBXBHView::AssertValid() const
{
CView::AssertValid();
}
void CZBXBHView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CZBXBHDoc* CZBXBHView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CZBXBHDoc)));
return (CZBXBHDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CZBXBHView message handlers
void CZBXBHView::ZBXBH(CDC *pDC, int xw1, int yw1, int zw1, int xw2, int yw2, int zw2,int a,int b,int c)
{
int xe1,ye1,ze1;
int xe2,ye2,ze2;
int xs1,ys1,zs1;
int xs2,ys2,zs2;
double u,v;
zs1=100;
zs2=100;
v=sqrt(a*a+b*b);
u=sqrt(a*a+b*b+c*c);
xe1=xw1*(double)(-b/v)+yw1*(double)(a/v);
ye1=xw1*((double)(-a*c)/(double)(u*v))+yw1*((double)(-b*c)/(double)(u*v))+zw1*(double)(v/u);
ze1=xw1*(-a/u)+yw1*(-b/u)+zw1*(-c/u);
xe2=xw2*(int)(-b/v)+yw2*(int)(a/v);
ye2=xw2*((double)(-a*c)/(double)(u*v))+yw2*((double)(-b*c)/(double)(u*v))+zw2*(double)(v/u);
ze2=xw2*(-a/u)+yw2*(-b/u)+zw2*(-c/u);
xs1=xe1*zs1/ze1;
ys1=ye1*zs1/ze1;
xs2=xe2*zs2/ze2;
ys2=ye2*zs2/ze2;
pDC->MoveTo(xw1,yw1);
pDC->LineTo(xw2,yw2);
pDC->MoveTo(xs1,ys1);
pDC->LineTo(xs2,ys2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -