版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、/ Experiment_Frame_OneView.cpp : implementation of the CExperiment_Frame_OneView class/#include stdafx.h#include Experiment_Frame_One.h#include Experiment_Frame_OneDoc.h#include Experiment_Frame_OneView.h#include SettingDlg.h#include InputDialog.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEsta
2、tic char THIS_FILE = _FILE_;#endif/ CExperiment_Frame_OneViewIMPLEMENT_DYNCREATE(CExperiment_Frame_OneView, CView)BEGIN_MESSAGE_MAP(CExperiment_Frame_OneView, CView)/AFX_MSG_MAP(CExperiment_Frame_OneView)ON_COMMAND(IDM_SETTING, OnSetting)ON_COMMAND(IDM_INPUT, OnInput)/AFX_MSG_MAP/ Standard printing
3、commandsON_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()/ CExperiment_Frame_OneView construction/destructionCExperiment_Frame_OneView:CExperiment_Frame_OneView()/ TODO: add cons
4、truction code herem_bGridOn = true;m_iMarginSize = 20;m_iPointSize = 20;m_iActive_Algorithm = 0;m_PointColor = RGB(255, 0, 0); X0 = Y0 = 0; X1 = Y1 = 10;CExperiment_Frame_OneView:CExperiment_Frame_OneView()BOOL CExperiment_Frame_OneView:PreCreateWindow(CREATESTRUCT& cs)/ TODO: Modify the Window clas
5、s or styles here by modifying/ the CREATESTRUCT csreturn CView:PreCreateWindow(cs);/ CExperiment_Frame_OneView drawingvoid CExperiment_Frame_OneView:OnDraw(CDC* pDC)CExperiment_Frame_OneDoc* pDoc = GetDocument();ASSERT_VALID(pDoc);/ TODO: add draw code for native data hereif( this-m_bGridOn )this-Dr
6、awGrid(pDC);switch( this-m_iActive_Algorithm) case 0: /DDADDA(X0,Y0,X1,Y1);break;case 1: /Mid_BresenhamMid_Bresenham(X0,Y0,X1,Y1);break;default:break;CView:OnDraw(pDC);/ CExperiment_Frame_OneView printingBOOL CExperiment_Frame_OneView:OnPreparePrinting(CPrintInfo* pInfo)/ default preparationreturn D
7、oPreparePrinting(pInfo);void CExperiment_Frame_OneView:OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)/ TODO: add extra initialization before printingvoid CExperiment_Frame_OneView:OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)/ TODO: add cleanup after printing/ CExperiment_Frame_OneView di
8、agnostics#ifdef _DEBUGvoid CExperiment_Frame_OneView:AssertValid() constCView:AssertValid();void CExperiment_Frame_OneView:Dump(CDumpContext& dc) constCView:Dump(dc);CExperiment_Frame_OneDoc* CExperiment_Frame_OneView:GetDocument() / non-debug version is inlineASSERT(m_pDocument-IsKindOf(RUNTIME_CLA
9、SS(CExperiment_Frame_OneDoc);return (CExperiment_Frame_OneDoc*)m_pDocument;#endif /_DEBUG/ CExperiment_Frame_OneView message handlersvoid CExperiment_Frame_OneView:DrawGrid(CDC *pDC)CRect ClientRect;GetClientRect( &ClientRect );CPen *pNewPen = new CPen;pNewPen-CreatePen(PS_DOT, 1, RGB(256,0,0);CPen
10、*pOldPen = pDC-SelectObject(pNewPen);int x0 = ClientRect.left + m_iMarginSize; int x1 = x0 + (ClientRect.right -ClientRect.left - 2*m_iMarginSize)/m_iPointSize * m_iPointSize;int y0 = ClientRect.bottom - m_iMarginSize;int y1 = y0 - (ClientRect.bottom - ClientRect.top - 2*m_iMarginSize)/m_iPointSize
11、* m_iPointSize;int x, y;/Draw horizontal linesfor ( y = y0; y = y1; y -= m_iPointSize)pDC-MoveTo(x0, y);pDC-LineTo(x1, y);/Draw vertical linesfor ( x = x0; x MoveTo(x, y0);pDC-LineTo(x, y1);pDC-SelectObject(pOldPen);pNewPen-DeleteObject();return;void CExperiment_Frame_OneView:DrawPixel(int X, int Y)
12、CDC *pDC= GetDC();CBrush *pNewBrush = new CBrush;pNewBrush-CreateSolidBrush(m_PointColor);CBrush *pOldBrush = pDC-SelectObject(pNewBrush);CPen *pNewPen = new CPen;pNewPen-CreatePen(PS_NULL, 1, RGB(0,0,0);CPen *pOldPen = pDC-SelectObject(pNewPen);CRect ClientRect;GetClientRect( &ClientRect );int x0 =
13、 ClientRect.left + m_iMarginSize; int y0 = ClientRect.bottom - m_iMarginSize;CRect Point;Point.left = x0 + X*m_iPointSize;Point.right = Point.left + m_iPointSize;Point.bottom = y0 - Y*m_iPointSize;Point.top = Point.bottom - m_iPointSize;pDC-Rectangle(&Point);pDC-SelectObject(pOldBrush);pNewBrush-Del
14、eteObject();pDC-SelectObject(pOldPen);pOldPen-DeleteObject();void CExperiment_Frame_OneView:OnSetting() CSettingDlg SettingDialog(m_iPointSize, m_PointColor, m_iActive_Algorithm, m_bGridOn );if ( SettingDialog.DoModal() = IDOK )this-m_bGridOn = SettingDialog.m_bGridOn;this-m_PointColor = SettingDial
15、og.m_Point_Color;this-m_iPointSize = SettingDialog.m_Point_Size;this-m_iActive_Algorithm = SettingDialog.m_iActive_Algorithm;this-Invalidate();void CExperiment_Frame_OneView:OnInput() CInputDialog InputDialog(X0, Y0, X1, Y1);if ( InputDialog.DoModal() = IDOK)X0 = InputDialog.m_X0;X1 = InputDialog.m_X1;Y0 = InputDialog.m_Y0;Y1 = InputDialog.m_Y1;Invalidate();/-算法实现-/绘制像素的函数DrawPixel(x, y);void CExperiment_Frame_OneView:DDA(int X0, int Y0, int X1, int Y1)int dx,dy,epsl,k;float x,y,xIncre,yIncre;dx=X1-X0; dy=Y1-Y0;x=X0; y=Y0;if(abs(dx)abs(dy) epsl=abs(dx);else epsl=a
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2025学年度“安全生产事故隐患排查”知识竞赛模拟题库及答案详解【有一套】
- 2024-2025学年度法律职业资格考试每日一练试卷附参考答案详解(满分必刷)
- 2024-2025学年反射疗法师大赛理论高分题库完整附答案详解
- 软件开发项目经理训练指南
- 2024-2025学年南京特殊教育师范学院单招《语文》复习提分资料及完整答案详解1套
- 2024-2025学年度电工复习提分资料含完整答案详解(夺冠)
- 2024-2025学年度护士资格证通关题库【培优B卷】附答案详解
- 2024-2025学年广西英华国际职业学院妇产护理期末考试黑钻押题含完整答案详解(名校卷)
- 2024-2025学年度收银审核员试题预测试卷【重点】附答案详解
- 2026中国人寿招聘面试题及答案
- 2025年国家统一司法考试真题及答案
- 2025年黑龙江生态工程职业学院单招职业倾向性测试模拟测试卷附答案解析
- 易考优课件教学课件
- 人流室感染控制措施
- 风电项目安全生产实施计划书
- 皮肤型红斑狼疮诊疗指南(2025年)
- 融媒体应聘考试题及答案
- 2025年西安医专选拔面试题库及答案
- 鄂科版二年级全册心理健康教育教案
- 《SBT 11204-2017衣物清洗服务规范》(2026年)实施指南
- 老年2型糖尿病合并认知障碍照护方案
评论
0/150
提交评论