Exemplo n.º 1
0
CElement* CSketcherView::CreateElement(void) const
{

	// Get a pointer to the document for this view
	CSketcherDoc* pDoc = GetDocument();

	ASSERT_VALID(pDoc); // Verify the pointer is good
	
	// Now select the element using the type stored in the document
	switch(pDoc->GetElementType())
	{
		case RECTANGLE:
			return new CRectangle(m_FirstPoint, m_SecondPoint,pDoc->GetElementColor(),pDoc->GetElementPenStyle());

		case CIRCLE:
			return new CCircle(m_FirstPoint, m_SecondPoint, pDoc->GetElementColor(),pDoc->GetElementPenStyle());

		case CURVE:
			return new CCurve(new CPoint(m_FirstPoint), new CPoint(m_SecondPoint), pDoc->GetElementColor(),pDoc->GetElementPenStyle());

		case LINE:
			return new CLine(m_FirstPoint, m_SecondPoint, pDoc->GetElementColor(),pDoc->GetElementPenStyle());
		
		case ELLIPSE:
			return new CEllipse(m_FirstPoint, m_SecondPoint, pDoc->GetElementColor(),pDoc->GetElementPenStyle());

		default:
			// Something's gone wrong
			AfxMessageBox(_T("Bad Element code"), MB_OK);
			AfxAbort();
		
		return nullptr;
	}

}