📄 currentlayerview.cpp
字号:
// CurrentLayerView.cpp : implementation file
//
#include "stdafx.h"
#include "SlsPrj.h"
#include "CurrentLayerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCurrentLayerView
IMPLEMENT_DYNCREATE(CCurrentLayerView, CBaseView)
CCurrentLayerView::CCurrentLayerView()
{
}
CCurrentLayerView::~CCurrentLayerView()
{
}
BEGIN_MESSAGE_MAP(CCurrentLayerView, CBaseView)
//{{AFX_MSG_MAP(CCurrentLayerView)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCurrentLayerView drawing
void CCurrentLayerView::OnDraw(CDC* pDC)
{
CStlDoc* pDoc = GetDocument();
CBaseView::OnDraw(pDC); //绘制背景
CPoint logPt;
CPen BluePen(PS_SOLID, 5, RGB(255, 255, 255));
CPen* pOldPen=pDC->SelectObject( &BluePen );
SCANPATH& path = (pDoc->m_pathData).m_scanPath;
for(int i=0; i < (path.polygons.GetSize()); i++)
{
logPt = GetLogicCoordinate(path.polygons[i][0]);
pDC->MoveTo(logPt);
int totalPt=path.polygons[i].GetSize();
for (int j=1; j <= totalPt; j++)
{
logPt = GetLogicCoordinate(path.polygons[i][j%totalPt]);
pDC->LineTo(logPt);
}
}
CPen YellowPen(PS_SOLID, 2, RGB(255, 255, 255));
pOldPen=pDC->SelectObject( &YellowPen );
for(i=0; i < (path.polylines.GetSize()); i++)
{
logPt = GetLogicCoordinate(path.polylines[i].m_startPoint);
pDC->MoveTo(logPt);
logPt = GetLogicCoordinate(path.polylines[i].m_endPoint);
pDC->LineTo(logPt);
}
pDC->SelectObject(pOldPen);
}
/////////////////////////////////////////////////////////////////////////////
// CCurrentLayerView diagnostics
#ifdef _DEBUG
void CCurrentLayerView::AssertValid() const
{
CBaseView::AssertValid();
}
void CCurrentLayerView::Dump(CDumpContext& dc) const
{
CBaseView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCurrentLayerView message handlers
void CCurrentLayerView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
if((lHint == ID_HINT_ONEVIEW) || (lHint == ID_HINT_TWOVIEWS))
{
CBaseView::OnUpdate(pSender, lHint, pHint);
}
else
{
if(lHint == ID_HINT_SINGLE_SLICE)
{
InvalidateRect(&m_clientRect, FALSE); //Don't erase the background
UpdateWindow();
}
}
}
void CCurrentLayerView::OnInitialUpdate()
{
CBaseView::OnInitialUpdate();
}
void CCurrentLayerView::OnPaint()
{
CPaintDC dc(this);
OnPrepareDC( &dc ); //设置影射方式
CRect logRect=m_clientRect;
dc.DPtoLP( &logRect ); //逻辑坐标
m_pMemDC = new CDC;
m_pBitmap = new CBitmap;
m_pMemDC->CreateCompatibleDC( &dc );
m_pBitmap->CreateCompatibleBitmap(&dc, m_clientRect.Width(),
m_clientRect.Height()); //设备坐标
CBitmap* pOldBitmap = ( CBitmap* )m_pMemDC->SelectObject( m_pBitmap );
OnPrepareDC( m_pMemDC ); //设置影射方式
OnDraw( m_pMemDC );
//逻辑坐标
dc.BitBlt(logRect.left, logRect.top,
logRect.Width(), logRect.Height(),
m_pMemDC, logRect.left,
logRect.top, SRCCOPY);
m_pMemDC->SelectObject(pOldBitmap);
delete m_pMemDC;
delete m_pBitmap;
}
BOOL CCurrentLayerView::PreCreateWindow(CREATESTRUCT& cs)
{
return CBaseView::PreCreateWindow(cs);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -