⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 designdoc.cpp

📁 本文以数字图像处理、压缩技术和MATLAB应用为基础
💻 CPP
📖 第 1 页 / 共 3 页
字号:
{
	// TODO: Add your command handler code here
	m_Thickness = 2;
	m_Color = RGB(192,192,0);
	m_ElemSelected = -1;
	m_sel_pt_a = 0;
	m_sel_pt_b = 0;
	if (m_CurrentElement != ID_ELEMENT_ROOM)
	{
		m_CurrentElement = ID_ELEMENT_ROOM;
		UpdateAllViews(NULL, 0);
	}
}

void CDesignDoc::OnUpdateElementRoom(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_CurrentElement == ID_ELEMENT_ROOM ? 1 : 0);
}

void CDesignDoc::OnElementCursor() 
{
	// TODO: Add your command handler code here
	m_ElemSelected = -1;
	m_sel_pt_a = 0;
	m_sel_pt_b = 0;
	if (m_CurrentElement != ID_ELEMENT_CURSOR)
	{
		m_CurrentElement = ID_ELEMENT_CURSOR;
		UpdateAllViews(NULL, 0);
	}
}

void CDesignDoc::OnUpdateElementCursor(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_CurrentElement == ID_ELEMENT_CURSOR ? 1 : 0);
}

void CDesignDoc::OnElementDoor() 
{
	// TODO: Add your command handler code here
	m_Thickness = 3;
	m_Color = RGB(154,102,26);
	m_ElemSelected = -1;
	m_sel_pt_a = 0;
	m_sel_pt_b = 0;
	if (m_CurrentElement != ID_ELEMENT_DOOR)
	{
		m_CurrentElement = ID_ELEMENT_DOOR;
		UpdateAllViews(NULL, 0);
	}
}

void CDesignDoc::OnUpdateElementDoor(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_CurrentElement == ID_ELEMENT_DOOR ? 1 : 0);
}

void CDesignDoc::OnElementWindow() 
{
	// TODO: Add your command handler code here
	m_Thickness = 3;
	m_Color = RGB(0,0,192);
	m_ElemSelected = -1;
	m_sel_pt_a = 0;
	m_sel_pt_b = 0;
	if (m_CurrentElement != ID_ELEMENT_WINDOW)
	{
		m_CurrentElement = ID_ELEMENT_WINDOW;
		UpdateAllViews(NULL, 0);
	}
}

void CDesignDoc::OnUpdateElementWindow(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_CurrentElement == ID_ELEMENT_WINDOW ? 1 : 0);	
}

void CDesignDoc::OnElementRoof() 
{
	// TODO: Add your command handler code here
	m_Thickness = 1;
	m_Color = RGB(192, 0, 0);
	m_ElemSelected = -1;
	m_sel_pt_a = 0;
	m_sel_pt_b = 0;
	if (m_CurrentElement != ID_ELEMENT_ROOF)
	{
		m_CurrentElement = ID_ELEMENT_ROOF;
		UpdateAllViews(NULL, 0);
	}
}

void CDesignDoc::OnUpdateElementRoof(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_CurrentElement == ID_ELEMENT_ROOF ? 1 : 0);
}

void CDesignDoc::OnViewWalkthrough() 
{
	// TODO: Add your command handler code here
	if (m_CurrentMode != ID_VIEW_WALKTHROUGH)
	{
		m_xRotate = 0;
		m_yRotate = 90;
		m_CurrentMode = ID_VIEW_WALKTHROUGH;
		UpdateAllViews(NULL, 0);
	}
}

void CDesignDoc::OnUpdateViewWalkthrough(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_CurrentMode == ID_VIEW_WALKTHROUGH ? 1 : 0);	
}

void CDesignDoc::OnViewNormal() 
{
	// TODO: Add your command handler code here

	if (m_CurrentMode != ID_VIEW_NORMAL)
	{
		m_CurrentMode = ID_VIEW_NORMAL;
		eyex = 0;
		eyey = 5;
		eyez = 100;
		centerx = 0;
		centery = 5;
		centerz = 99;
		m_xz_angle = 0;
		m_yz_angle = 0;

		UpdateAllViews(NULL, 0);
	}
}

void CDesignDoc::OnUpdateViewNormal(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_CurrentMode == ID_VIEW_NORMAL ? 1 : 0);	
}





///////////////////////////////////////////////////////////////////////////////
// Implement CElement
IMPLEMENT_SERIAL (CElement, CObject, 1)

CRect CElement::GetDimRect()
{
	return CRect(	min(m_X1, m_X2),
					min(m_Y1, m_Y2),
					max(m_X1, m_X2),
					max(m_Y1, m_Y2));
}

void CElement::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
		ar << m_X1 << m_Y1 << m_X2 << m_Y2 << m_Color << m_Thickness;
	else
		ar >> m_X1 >> m_Y1 >> m_X2 >> m_Y2 >> m_Color >> m_Thickness;
}

///////////////////////////////////////////////////////////////////////////////
// Implement CRoom
IMPLEMENT_SERIAL (CRoom, CElement, 1)

CRoom::CRoom(int X1, int Y1, int X2, int Y2, COLORREF Color, int Thickness)
{
	m_X1 = min(X1, X2);
	m_Y1 = min(Y1, Y2);
	m_X2 = max(X1, X2);
	m_Y2 = max(Y1, Y2);
	m_Color = Color;
	m_Thickness = Thickness;
	m_ElemType = ROOM;
}

void CRoom::Serialize(CArchive& ar)
{
	CElement::Serialize(ar);
	if (ar.IsStoring())
		ar << m_ElemType;
	else
		ar >> m_ElemType;
}

void CRoom::Draw(CDC *pDC)
{
	CPen Pen, *pOldPen;

	Pen.CreatePen(PS_INSIDEFRAME, m_Thickness, m_Color);
	pOldPen = pDC->SelectObject(&Pen);
	pDC->SelectStockObject(NULL_BRUSH);

	pDC->Rectangle(m_X1, m_Y1, m_X2 + 1, m_Y2 + 1);

	pDC->SelectObject(pOldPen);
}

///////////////////////////////////////////////////////////////////////////////
// Implement CDoor
IMPLEMENT_SERIAL (CDoor, CElement, 1)

CDoor::CDoor(int X1, int Y1, int X2, int Y2, COLORREF Color, int Thickness)
{
	m_X1 = min(X1, X2);
	m_Y1 = min(Y1, Y2);
	m_X2 = max(X1, X2);
	m_Y2 = max(Y1, Y2);
	m_Color = Color;
	m_Thickness = Thickness;
	m_ElemType = DOOR;
}

void CDoor::Serialize(CArchive& ar)
{
	CElement::Serialize(ar);
	if (ar.IsStoring())
		ar << m_ElemType;
	else
		ar >> m_ElemType;
}

void CDoor::Draw(CDC *pDC)
{
	CPen Pen, *pOldPen;

	Pen.CreatePen(PS_INSIDEFRAME, m_Thickness, m_Color);
	pOldPen = pDC->SelectObject(&Pen);
	pDC->SelectStockObject(NULL_BRUSH);

	if (abs(m_X1 - m_X2) > abs(m_Y1 - m_Y2))
	{
		pDC->MoveTo(m_X1, m_Y1 + 8);
		pDC->LineTo(m_X2, m_Y1 + 8);
		pDC->LineTo(m_X1 + 8, m_Y1);
	}
	else
	{
		pDC->MoveTo(m_X1 + 8, m_Y1);
		pDC->LineTo(m_X1 + 8, m_Y2);
		pDC->LineTo(m_X1, m_Y1 + 8);
	}

	pDC->SelectObject(pOldPen);
}

///////////////////////////////////////////////////////////////////////////////
// Implement CWindow
IMPLEMENT_SERIAL (CWindow, CElement, 1)

CWindow::CWindow(int X1, int Y1, int X2, int Y2, int outxy, COLORREF Color, int Thickness)
{
	m_X1 = min(X1, X2);
	m_Y1 = min(Y1, Y2);
	m_X2 = max(X1, X2);
	m_Y2 = max(Y1, Y2);
	m_OutXY = outxy;
	m_Color = Color;
	m_Thickness = Thickness;
	m_ElemType = WINDOW;
}

void CWindow::Serialize(CArchive& ar)
{
	CElement::Serialize(ar);
	if (ar.IsStoring())
		ar << m_OutXY << m_ElemType;
	else
		ar >> m_OutXY >> m_ElemType;
}

void CWindow::Draw(CDC *pDC)
{
	CPen Pen, *pOldPen;

	Pen.CreatePen(PS_INSIDEFRAME, m_Thickness, m_Color);
	pOldPen = pDC->SelectObject(&Pen);
	pDC->SelectStockObject(NULL_BRUSH);

	if (m_OutXY == OPENLEFT)
	{
		pDC->MoveTo(m_X1, m_Y1);
		pDC->LineTo(m_X1 + 8, m_Y1);
		pDC->LineTo(m_X1 + 8, m_Y2);
		pDC->LineTo(m_X1, m_Y2);
	}
	else if (m_OutXY == OPENRIGHT)
	{
		pDC->MoveTo(m_X2, m_Y1);
		pDC->LineTo(m_X2 - 8, m_Y1);
		pDC->LineTo(m_X2 - 8, m_Y2);
		pDC->LineTo(m_X2, m_Y2);
	}
	else if (m_OutXY == OPENDOWN)
	{
		pDC->MoveTo(m_X1, m_Y2);
		pDC->LineTo(m_X1, m_Y2 - 8);
		pDC->LineTo(m_X2, m_Y2 - 8);
		pDC->LineTo(m_X2, m_Y2);
	}
	else
	{
		pDC->MoveTo(m_X1, m_Y1);
		pDC->LineTo(m_X1, m_Y1 + 8);
		pDC->LineTo(m_X2, m_Y1 + 8);
		pDC->LineTo(m_X2, m_Y1);
	}
	pDC->SelectObject(pOldPen);
}

///////////////////////////////////////////////////////////////////////////////
// Implement CRoof
IMPLEMENT_SERIAL (CRoof, CElement, 1)

CRoof::CRoof(int X1, int Y1, int X2, int Y2, COLORREF Color, int Thickness, int Direction)
{
	m_X1 = min(X1, X2);
	m_Y1 = min(Y1, Y2);
	m_X2 = max(X1, X2);
	m_Y2 = max(Y1, Y2);
	m_Color = Color;
	m_Thickness = Thickness;
	m_Dir = Direction;
	m_ElemType = ROOF;
}

void CRoof::Serialize(CArchive& ar)
{
	CElement::Serialize(ar);
	if (ar.IsStoring())
		ar << m_Dir << m_ElemType;
	else
		ar >> m_Dir >> m_ElemType;
}

void CRoof::Draw(CDC *pDC)
{
	CPen Pen, Pen2, *pOldPen;

	Pen.CreatePen(PS_INSIDEFRAME, m_Thickness, RGB(250,220,220));
	pOldPen = pDC->SelectObject(&Pen);
	pDC->SelectStockObject(NULL_BRUSH);

	for (int i = (int)m_X1; i <= (int)m_X2; i = i + 4)
	{
		pDC->MoveTo(i, m_Y1);
		pDC->LineTo(i, m_Y2);
	}
	for (i = (int)m_Y1; i <= (int)m_Y2; i = i + 4)
	{
		pDC->MoveTo(m_X1, i);
		pDC->LineTo(m_X2, i);
	}
	pDC->SelectObject(pOldPen);


	Pen2.CreatePen(PS_INSIDEFRAME, m_Thickness, m_Color);
	pOldPen = pDC->SelectObject(&Pen2);
	pDC->Rectangle(m_X1, m_Y1, m_X2 + 1, m_Y2 + 1);
	pDC->SelectObject(pOldPen);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -