📄 vertex.cpp
字号:
// Vertex.cpp: implementation of the CVertex class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CollegeWizard.h"
#include <afx.h>//包含类CObject
//#include <math.h>
#include "InsertVertexDlg.h"
#include "Vertex.h"
#include "Path.h"
#define STRETCH 20 //矩形上下左右延伸大小
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CVertex::CVertex()
{
m_serialNum = 0; //该景点或建筑的编号
next = NULL;
paths = NULL;
m_bIsSight = FALSE;
strcpy(m_name,"未知");
strcpy(m_information,"未知");
strcpy(m_finishedTime,"未知");
}
CVertex::CVertex(int serialNum, //该景点或建筑的编号,必须大于零
BOOL bIsSight, //是景点还是建筑,景点为TRUE,建筑为FALSE
CString name, //该景点或建筑的名称
CString information, //该景点或建筑的相关信息
CString finishedTime, //该景点或建筑的完成时间
CPoint location, //在校园中的位置
class CPath * PATHS, //存储依附于该景点或建筑的道路的链表
class CVertex* NEXT)//下一个景点或建筑
{
m_serialNum = serialNum;
m_bIsSight = bIsSight;
strcpy(m_name,name);
strcpy(m_information,information);
strcpy(m_finishedTime,finishedTime);
m_location = location;
paths = PATHS;
next = NEXT;
}
CVertex::~CVertex()
{
}
//////////////////////////////////////////////////////////////////////
// 操作函数
//////////////////////////////////////////////////////////////////////
//DEL BOOL CVertex::InsertPath(CPath *path)
//DEL {
//DEL
//DEL return TRUE;
//DEL }
int CVertex::GetSerialNum()
{
return m_serialNum;
}
void CVertex::SetSerialNum(int serialNum)
{
m_serialNum = serialNum;
}
BOOL CVertex::GetIsSight()
{
return m_bIsSight;
}
void CVertex::SetIsSight(BOOL isSight)
{
m_bIsSight = isSight;
}
CString CVertex::GetName()
{
return m_name;
}
void CVertex::SetName(CString name)
{
strcpy(m_name,name);
}
CString CVertex::GetInformation()
{
return m_information;
}
void CVertex::SetInformation(CString information)
{
strcpy(m_information,information);
}
CString CVertex::GetFinishedTime()
{
return m_finishedTime;
}
void CVertex::SetFinishedTime(CString finishedTime)
{
strcpy(m_finishedTime,finishedTime);
}
CPoint CVertex::GetLocation()
{
return m_location;
}
void CVertex::SetLocation(CPoint location)
{
m_location = location;
}
CPath * CVertex::GetPaths()
{
return paths;
}
void CVertex::SetPaths(CPath *PATHS)
{
paths = PATHS;
}
CVertex* CVertex::GetNext()
{
return next;
}
void CVertex::SetNext(CVertex *NEXT)
{
next = NEXT;
}
////////////////////////////////////////////////////////////////////////////
//判断一个点是否落在景点或建筑内,是则返回所在景点或建筑的指针,否则返回NULL
CVertex* CVertex::IsLocatedIn(CPoint point)
{
if((abs(m_location.x - point.x)) <= STRETCH && (abs(m_location.y - point.y) <= STRETCH))
return this;
else return NULL;
}
//////////////////////////////////////////////////////////////////////
void CVertex::Draw(CDC *pDC)
{
CRect vertex(m_location.x - STRETCH,m_location.y - STRETCH,
m_location.x + STRETCH,m_location.y + STRETCH);
COLORREF color = RGB(0,0,192);//定义一个颜色变量
CBrush brush(HS_FDIAGONAL,color);
CBrush* oldBrush = pDC->SelectObject(&brush);
CPen pen(PS_INSIDEFRAME,2,color);
CPen* oldPen = pDC->SelectObject(&pen);
pDC->Rectangle(vertex);
CString strSerialNum;
strSerialNum.Format("%d",m_serialNum);
pDC->DrawText(strSerialNum,vertex,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
pDC->SelectObject(oldPen);
pDC->SelectObject(oldBrush);
}
//////////////////////////////////////////////////////////////////////
void CVertex::ShowInformation()
{
CString isSight,strInfo;
if(m_bIsSight)
isSight = "景点\n编号: \t";
else isSight = "建筑\n编号: \t";
strInfo.Format("%s%d%s%s%s%s%s%d%S%d%s%s",isSight,m_serialNum,
"\n名称: \t",m_name,"\n完成时间: ",m_finishedTime,
"\n位置: \t(",m_location.x,
",",m_location.y,")\n",
m_information);
AfxMessageBox(strInfo,NULL,MB_OK);
}
//////////////////////////////////////////////////////////////////////
void CVertex::Update()
{
CInsertVertexDlg VertexDlg;
if(IDOK == VertexDlg.DoModal())
{
m_bIsSight = !VertexDlg.m_isConstructure;
strcpy(m_name,VertexDlg.m_name);
strcpy(m_finishedTime,VertexDlg.m_finishedTime);
strcpy(m_information,VertexDlg.m_information);
}
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -