用c++画房子

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

//houseView.cpp:implementationoftheCHouseViewclass//#includestdafx.h#includehouse.h#includemath.h#includehouseDoc.h#includehouseView.h#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////CHouseViewIMPLEMENT_DYNCREATE(CHouseView,CView)BEGIN_MESSAGE_MAP(CHouseView,CView)//{{AFX_MSG_MAP(CHouseView)//NOTE-theClassWizardwilladdandremovemappingmacroshere.//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!//}}AFX_MSG_MAP//StandardprintingcommandsON_COMMAND(ID_FILE_PRINT,CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_DIRECT,CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_PREVIEW,CView::OnFilePrintPreview)END_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////CHouseViewconstruction/destructionCHouseView::CHouseView(){//TODO:addconstructioncodehere}CHouseView::~CHouseView(){}BOOLCHouseView::PreCreateWindow(CREATESTRUCT&cs){//TODO:ModifytheWindowclassorstylesherebymodifying//theCREATESTRUCTcsreturnCView::PreCreateWindow(cs);}///////////////////////////////////////////////////////////////////////////////CHouseViewdrawingvoidCHouseView::OnDraw(CDC*pDC){CHouseDoc*pDoc=GetDocument();ASSERT_VALID(pDoc);//TODO:adddrawcodefornativedataherefloata=3,b=2,c=1;floatp[10][3]={{-80,0,0},{80,0,0},{80,0,200},{0,0,260},{-80,0,200},{-80,220,0},{80,220,0},{80,220,200},{0,220,260},{-80,220,200}};floatq[10][3];floatu=(float)sqrt(a*a+b*b+c*c);floatv=(float)sqrt(a*a+b*b);for(inti=0;i10;i++){q[i][0]=200+p[i][0]*(-b/v)+p[i][1]*(a/u);q[i][1]=400-(p[i][0]*(-a*c/u/v)+p[i][1]*(-b*c/v/u)+p[i][2]*(v/u));}pDC-MoveTo(int(q[0][0]),int(q[0][1]));pDC-LineTo(int(q[1][0]),int(q[1][1]));pDC-MoveTo(int(q[1][0]),int(q[1][1]));pDC-LineTo(int(q[2][0]),int(q[2][1]));pDC-MoveTo(int(q[2][0]),int(q[2][1]));pDC-LineTo(int(q[3][0]),int(q[3][1]));pDC-MoveTo(int(q[3][0]),int(q[3][1]));pDC-LineTo(int(q[4][0]),int(q[4][1]));pDC-MoveTo(int(q[1][0]),int(q[1][1]));pDC-LineTo(int(q[6][0]),int(q[6][1]));pDC-MoveTo(int(q[6][0]),int(q[6][1]));pDC-LineTo(int(q[7][0]),int(q[7][1]));pDC-MoveTo(int(q[2][0]),int(q[2][1]));pDC-LineTo(int(q[7][0]),int(q[7][1]));pDC-MoveTo(int(q[7][0]),int(q[7][1]));pDC-LineTo(int(q[8][0]),int(q[8][1]));pDC-MoveTo(int(q[8][0]),int(q[8][1]));pDC-LineTo(int(q[3][0]),int(q[3][1]));pDC-MoveTo(int(q[6][0]),int(q[6][1]));pDC-LineTo(int(q[5][0]),int(q[5][1]));pDC-MoveTo(int(q[5][0]),int(q[5][1]));pDC-LineTo(int(q[0][0]),int(q[0][1]));pDC-MoveTo(int(q[9][0]),int(q[9][1]));pDC-LineTo(int(q[5][0]),int(q[5][1]));pDC-MoveTo(int(q[9][0]),int(q[9][1]));pDC-LineTo(int(q[4][0]),int(q[4][1]));pDC-MoveTo(int(q[4][0]),int(q[4][1]));pDC-LineTo(int(q[0][0]),int(q[0][1]));pDC-MoveTo(int(q[9][0]),int(q[9][1]));pDC-LineTo(int(q[8][0]),int(q[8][1]));}///////////////////////////////////////////////////////////////////////////////CHouseViewprintingBOOLCHouseView::OnPreparePrinting(CPrintInfo*pInfo){//defaultpreparationreturnDoPreparePrinting(pInfo);}voidCHouseView::OnBeginPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/){//TODO:addextrainitializationbeforeprinting}voidCHouseView::OnEndPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/){//TODO:addcleanupafterprinting}///////////////////////////////////////////////////////////////////////////////CHouseViewdiagnostics#ifdef_DEBUGvoidCHouseView::AssertValid()const{CView::AssertValid();}voidCHouseView::Dump(CDumpContext&dc)const{CView::Dump(dc);}CHouseDoc*CHouseView::GetDocument()//non-debugversionisinline{ASSERT(m_pDocument-IsKindOf(RUNTIME_CLASS(CHouseDoc)));return(CHouseDoc*)m_pDocument;}#endif//_DEBUG///////////////////////////////////////////////////////////////////////////////CHouseViewmessagehandlers//house.h:mainheaderfilefortheHOUSEapplication//#if!defined(AFX_HOUSE_H__8C6FCEDF_9263_41BB_92B8_D672FA0CC25C__INCLUDED_)#defineAFX_HOUSE_H__8C6FCEDF_9263_41BB_92B8_D672FA0CC25C__INCLUDED_#if_MSC_VER1000#pragmaonce#endif//_MSC_VER1000#ifndef__AFXWIN_H__#errorinclude'stdafx.h'beforeincludingthisfileforPCH#endif#includeresource.h//mainsymbols///////////////////////////////////////////////////////////////////////////////CHouseApp://Seehouse.cppfortheimplementationofthisclass//classCHouseApp:publicCWinApp{public:CHouseApp();//Overrides//ClassWizardgeneratedvirtualfunctionoverrides//{{AFX_VIRTUAL(CHouseApp)public:virtualBOOLInitInstance();//}}AFX_VIRTUAL//Implementation//{{AFX_MSG(CHouseApp)afx_msgvoidOnAppAbout();//NOTE-theClassWizardwilladdandremovememberfunctionshere.//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!//}}AFX_MSGDECLARE_MESSAGE_MAP()};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.#endif//!defined(AFX_HOUSE_H__8C6FCEDF_9263_41BB_92B8_D672FA0CC25C__INCLUDED_)//houseDoc.h:interfaceoftheCHouseDocclass///////////////////////////////////////////////////////////////////////////////#if!defined(AFX_HOUSEDOC_H__8630AC0F_F644_4E55_8D

1 / 11
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功