博客
关于我
VC++绘制铁路道岔
阅读量:108 次
发布时间:2019-02-26

本文共 2558 字,大约阅读时间需要 8 分钟。

绘制代码;

void CDaocaView::OnDraw(CDC* pDC){	CDaocaDoc* pDoc = GetDocument();	ASSERT_VALID(pDoc);	// TODO: add draw code for native data here	COLORREF DaoChaColor= RGB(0,0,0);	int width = m_rect.Width() ;	int height = m_rect.Height() ;	CPen newpen(PS_SOLID,60,DaoChaColor);	CPen newpen1(PS_SOLID,60,RGB(0,255,255));	CPen *pOldPen = pDC->SelectObject(&newpen);     pDC->MoveTo(m_rect.left,(int)(m_rect.top + height*0.5));	 pDC->LineTo((int)(m_rect.left +width*0.33),(int)(m_rect.top + height*0.5));    	 pDC->MoveTo((int)(m_rect.left +width*0.33),(int)(m_rect.top+height*0.5));	 pDC->LineTo((int)(m_rect.left +width*0.5),(int)(m_rect.top+(height*0.5+width*(sqrt(3))/6)));	 pDC->MoveTo((int)(m_rect.left +width*0.67),(int)(m_rect.top + height*0.5));	 pDC->LineTo((int)(m_rect.left +width),m_rect.top+height*0.5);	m_rect.left=240;	m_rect.right=440;	 pDC->MoveTo(m_rect.left,(int)(m_rect.top + height*0.5));	 pDC->LineTo((int)(m_rect.left +width/3),(int)(m_rect.top + height*0.5));	 pOldPen = pDC->SelectObject(&newpen1);	 pDC->MoveTo((int)(m_rect.left +width/3),(int)(m_rect.top+height*0.5));	 pDC->LineTo((int)(m_rect.left +width*2/3),(int)(m_rect.top+height*0.5));	 pOldPen = pDC->SelectObject(&newpen);	 pDC->MoveTo((int)(m_rect.left +width*2/3),(int)(m_rect.top + height*0.5));	 pDC->LineTo((int)(m_rect.left +width),m_rect.top+height*0.5);	 m_rect.left=470;	 m_rect.right=670; 	 pDC->MoveTo(m_rect.left,(int)(m_rect.top + height*0.5));	 pDC->LineTo((int)(m_rect.left +width/3),(int)(m_rect.top + height*0.5));	 pDC->MoveTo((int)(m_rect.left +width/3),(int)(m_rect.top+height*0.5));	 pDC->LineTo((int)(m_rect.left +width*0.5),(int)(m_rect.top+(height*0.5-width*(sqrt(3))/6)));	 pDC->MoveTo((int)(m_rect.left +width*2/3),(int)(m_rect.top + height*0.5));	 pDC->LineTo((int)(m_rect.left +width),m_rect.top+height*0.5);	 m_rect.left=700;	 m_rect.right=900; 	 pDC->MoveTo(m_rect.left,(int)(m_rect.top + height*0.5));	 pDC->LineTo((int)(m_rect.left +width/3),(int)(m_rect.top + height*0.5));	 pDC->MoveTo((int)(m_rect.left +width/3),(int)(m_rect.top+height*0.5));	 pDC->LineTo((int)(m_rect.left +width/2),(int)(m_rect.top+(height*0.5+width*(sqrt(3))/6)));	 pDC->MoveTo((int)(m_rect.left +width*2/3),(int)(m_rect.top + height*0.5));	 pDC->LineTo((int)(m_rect.left +width),m_rect.top+height*0.5);       	pDC->SetBkMode(TRANSPARENT);	pDC->SelectObject(pOldPen);}

头文件添加一个成员变量:CRect m_rect;

初始化;

CDaocaView::CDaocaView(){	// TODO: add construction code here	m_rect.left=10;	m_rect.top=10;	m_rect.right=210;	m_rect.bottom=210;}

包含<math.h>;

绘制效果如下;

    我也不太了解什么是道岔;可能是指的铁路交叉的地方;

转载地址:http://kpyy.baihongyu.com/

你可能感兴趣的文章
MySQL Connector/Net 句柄泄露
查看>>
multiprocessor(中)
查看>>
mysql CPU使用率过高的一次处理经历
查看>>
Multisim中555定时器使用技巧
查看>>
MySQL CRUD 数据表基础操作实战
查看>>
multisim变压器反馈式_穿过隔离栅供电:认识隔离式直流/ 直流偏置电源
查看>>
mysql csv import meets charset
查看>>
multivariate_normal TypeError: ufunc ‘add‘ output (typecode ‘O‘) could not be coerced to provided……
查看>>
MySQL DBA 数据库优化策略
查看>>
multi_index_container
查看>>
MySQL DBA 进阶知识详解
查看>>
Mura CMS processAsyncObject SQL注入漏洞复现(CVE-2024-32640)
查看>>
Mysql DBA 高级运维学习之路-DQL语句之select知识讲解
查看>>
mysql deadlock found when trying to get lock暴力解决
查看>>
MuseTalk如何生成高质量视频(使用技巧)
查看>>
mutiplemap 总结
查看>>
MySQL DELETE 表别名问题
查看>>
MySQL Error Handling in Stored Procedures---转载
查看>>
MVC 区域功能
查看>>
MySQL FEDERATED 提示
查看>>