📄 netmapview.cpp
字号:
// NetMapView.cpp : implementation of the CNetMapView class
//
#include "stdafx.h"
#include "NetMap.h"
#include "MainFrm.h"
#include "NetMapDoc.h"
#include "NetMapView.h"
#include "MainFrm.h"
#include "MapView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNetMapView
IMPLEMENT_DYNCREATE(CNetMapView, CFormView)
BEGIN_MESSAGE_MAP(CNetMapView, CFormView)
//{{AFX_MSG_MAP(CNetMapView)
ON_WM_DESTROY()
ON_WM_CTLCOLOR()
ON_WM_PAINT()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNetMapView construction/destruction
CNetMapView::CNetMapView()
: CFormView(CNetMapView::IDD)
{
//{{AFX_DATA_INIT(CNetMapView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
paint=false;
}
CNetMapView::~CNetMapView()
{
}
void CNetMapView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNetMapView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BOOL CNetMapView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CNetMapView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
CMainFrame *pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
pMain->pNetMapView=this;
}
/////////////////////////////////////////////////////////////////////////////
// CNetMapView printing
BOOL CNetMapView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CNetMapView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CNetMapView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CNetMapView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CNetMapView diagnostics
#ifdef _DEBUG
void CNetMapView::AssertValid() const
{
CFormView::AssertValid();
}
void CNetMapView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CNetMapDoc* CNetMapView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNetMapDoc)));
return (CNetMapDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CNetMapView message handlers
void CNetMapView::OnDestroy()
{
CFormView::OnDestroy();
}
HBRUSH CNetMapView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
void CNetMapView::OnPaint()
{
CPaintDC dc(this); // device context for painting
if (paint==true)
{
CMainFrame *pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
CMainFrame::NodeData *p1;
CMainFrame::NodeData *p2;
CMapView *pList=pMain->pListView;
for (int i=0;i<pMain->NodeArray.GetSize();i++)
{
p1=(CMainFrame::NodeData *)(pList->m_map.GetItemData(pMain->NodeArray[i]));
dc.TextOut(p1->pImage->MyPos.x+40,p1->pImage->MyPos.y,p1->ip);
if (p1->m_neighbor.GetSize()>0)
{
for (int j=0;j<p1->m_neighbor.GetSize();j++)
{
p2=(CMainFrame::NodeData *)(pList->m_map.GetItemData(p1->m_neighbor[j].Id));
if ((p1->level)==(p2->level))
//对端节点和本节点横向位置相同;
{
dc.MoveTo(p1->pImage->MyPos.x,p1->pImage->MyPos.y+j*4);
dc.LineTo(p2->pImage->MyPos.x,p2->pImage->MyPos.y+j*4);
}
else
{
dc.MoveTo(p1->pImage->MyPos.x+j*4,p1->pImage->MyPos.y);
dc.LineTo(p2->pImage->MyPos.x+j*4,p2->pImage->MyPos.y);
}
}
}
}
}
}
// Do not call CFormView::OnPaint() for painting messages
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -