📄 delaunayview.cpp
字号:
// DelaunayView.cpp : implementation of the CDelaunayView class
//
#include "stdafx.h"
#include "Delaunay.h"
#include "DelaunayDoc.h"
#include "DelaunayView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDelaunayView
IMPLEMENT_DYNCREATE(CDelaunayView, CView)
BEGIN_MESSAGE_MAP(CDelaunayView, CView)
//{{AFX_MSG_MAP(CDelaunayView)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
ON_COMMAND(ID_DRAW_TIN, OnDrawTin)
ON_UPDATE_COMMAND_UI(ID_DRAW_TIN, OnUpdateDrawTin)
ON_COMMAND(ID_DRAW_VOR, OnDrawVor)
ON_UPDATE_COMMAND_UI(ID_DRAW_VOR, OnUpdateDrawVor)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CDelaunayView construction/destruction
CDelaunayView::CDelaunayView()
{
m_bVor = true;
m_bTin = true;
// TODO: add construction code here
}
CDelaunayView::~CDelaunayView()
{
}
BOOL CDelaunayView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDelaunayView drawing
void CDelaunayView::OnDraw(CDC* pDC)
{
CDelaunayDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if(m_bTin){
m_DTriangular.Draw(pDC);
}if(m_bVor){
Voronoi(m_voronoi,m_DTriangular);
Draw(pDC,m_voronoi);
}
}
/////////////////////////////////////////////////////////////////////////////
// CDelaunayView printing
BOOL CDelaunayView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDelaunayView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDelaunayView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDelaunayView diagnostics
#ifdef _DEBUG
void CDelaunayView::AssertValid() const
{
CView::AssertValid();
}
void CDelaunayView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDelaunayDoc* CDelaunayView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDelaunayDoc)));
return (CDelaunayDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDelaunayView message handlers
void CDelaunayView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_DTriangular.LButtonDown(point.x,point.y))
{
Invalidate(true);
}
CView::OnLButtonDown(nFlags, point);
}
void CDelaunayView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_DTriangular.RButtonDown(point.x,point.y))
{
Invalidate(true);
}
CView::OnRButtonDown(nFlags, point);
}
void CDelaunayView::OnDrawTin()
{
// TODO: Add your command handler code here
m_bTin = !m_bTin;
Invalidate();
}
void CDelaunayView::OnUpdateDrawTin(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_bTin);
}
void CDelaunayView::OnDrawVor()
{
// TODO: Add your command handler code here
m_bVor = !m_bVor;
Invalidate();
}
void CDelaunayView::OnUpdateDrawVor(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_bVor);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -