《具有基本功能的矢量绘图软件实验报告》由会员分享,可在线阅读,更多相关《具有基本功能的矢量绘图软件实验报告(43页珍藏版)》请在金锄头文库上搜索。
1、 题 目 具有基本功能的矢量绘图软件 院、系(部) 专业及班级 学 号 姓 名 日 期 1 题目要求使用VS环境编写MFC类程序,制作一个具有基本功能的矢量绘图软件。2 需求分析本实验的”矢量绘图”软件是一个具有Office视觉样式的单文档应用程序,在应用程序的主框架窗口中包含一个Ribbon功能区,其中有两个标签选项卡:“主页”和“绘图”。当选择“绘图”选项卡后,将列出一些简单的绘图工具。选择某个绘图工具后,既可以再客户区绘制相应的图形;单击面板上的“画笔颜色”或“填充颜色”按钮后,将淡出一个颜色对话框以分别设置绘图的颜色及填充图形的颜色,而当单击“文本”按钮后,可以在客户区输入文本内容。3
2、 总体设计3.1 业务逻辑设计3.2 界面逻辑设计使用VS 新建项目,选择VC+项下的“MFC”项目类型,在弹出的“应用程序类型”界面中选择如图所示,然后进行一系列的设置后生成所需界面。所生成界面如图:3.3 数据库设计(如涉及数据库写这一部分) 数据库设计这里只给出表结构。4 详细设计MyDraw111view.h#pragma once#include Draw.h#define SHAPE_NULL 0#define SHAPE_PEN 1#define SHAPE_TEXT 2#define SHAPE_LINE 3#define SHAPE_RECT 4#define SHAPE_E
3、LLIPSE 5#define SHAPE_CIRCLE 6#define SHAPE_ERASER 7class CMydraw111View : public CView protected: / 仅从序列化创建CMydraw111View();DECLARE_DYNCREATE(CMydraw111View)/ 特性public:CMydraw111Doc* GetDocument() const;/ 操作public:BOOL m_bDrawShape;CPoint m_ptOrigin; /直线起始点CPoint m_ptPrv; / 直线终止点/ 重写public:virtual
4、void OnDraw(CDC* pDC); / 重写以绘制该视图virtual BOOL PreCreateWindow(CREATESTRUCT& cs);public:virtual CMydraw111View();#ifdef _DEBUGvirtual void AssertValid() const;virtual void Dump(CDumpContext& dc) const;#endifprotected:afx_msg void OnFilePrintPreview();afx_msg void OnRButtonUp(UINT nFlags, CPoint point
5、);afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);DECLARE_MESSAGE_MAP()public:int m_nDrawShape; /绘图类型COLORREF m_crDrawColor;COLORREF m_crFillColor;afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);afx_msg void OnDrawPen();afx_msg void OnDrawLine();afx_msg void OnUpdateDrawPen(CCmdUI *pCmdUI);
6、afx_msg void OnUpdateDrawLine(CCmdUI *pCmdUI);afx_msg void OnDrawColor();afx_msg void OnFillColor();afx_msg void OnLButtonDown(UINT nFlags, CPoint point);afx_msg void OnMouseMove(UINT nFlags, CPoint point);afx_msg void OnLButtonUp(UINT nFlags, CPoint point);BOOL m_bShowCaret;BOOL m_bInputTEXT;POINT
7、m_ptCaretPos;CString m_strTextBuf;LOGFONT m_lfTextFont;afx_msg void OnSetFocus(CWnd* pOldWnd);afx_msg void OnKillFocus(CWnd* pNewWnd);afx_msg void OnDrawText();afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);afx_msg void On
8、Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized);afx_msg void OnDrawRect();afx_msg void OnUpdateDrawRect(CCmdUI *pCmdUI);afx_msg void OnDrawEllipse();afx_msg void OnUpdateDrawEllipse(CCmdUI *pCmdUI);afx_msg void OnDrawCircle();afx_msg void OnUpdateDrawCircle(CCmdUI *pCmdUI);afx_msg void OnDra
9、wEraser();afx_msg void OnUpdateDrawEraser(CCmdUI *pCmdUI);afx_msg void OnUpdateDrawText(CCmdUI *pCmdUI);#ifndef _DEBUG / Mydraw111View.cpp 中的调试版本inline CMydraw111Doc* CMydraw111View:GetDocument() const return reinterpret_cast(m_pDocument); #endifMyDraw111view.cpp#include stdafx.h/ SHARED_HANDLERS 可以
10、在实现预览、缩略图和搜索筛选器句柄的/ ATL 项目中进行定义,并允许与该项目共享文档代码。#ifndef SHARED_HANDLERS#include Mydraw111.h#endif#include Mydraw111Doc.h#include Mydraw111View.h#include Draw.h#ifdef _DEBUG#define new DEBUG_NEW#endif/ CMydraw111ViewIMPLEMENT_DYNCREATE(CMydraw111View, CView)BEGIN_MESSAGE_MAP(CMydraw111View, CView)ON_WM
11、_CONTEXTMENU()ON_WM_RBUTTONUP()ON_WM_CREATE()ON_COMMAND(ID_DRAW_PEN, &CMydraw111View:OnDrawPen)ON_COMMAND(ID_DRAW_LINE, &CMydraw111View:OnDrawLine)ON_UPDATE_COMMAND_UI(ID_DRAW_PEN, &CMydraw111View:OnUpdateDrawPen)ON_UPDATE_COMMAND_UI(ID_DRAW_LINE, &CMydraw111View:OnUpdateDrawLine)ON_COMMAND(ID_DRAW_
12、COLOR, &CMydraw111View:OnDrawColor)ON_COMMAND(ID_FILL_COLOR, &CMydraw111View:OnFillColor)ON_WM_LBUTTONDOWN()ON_WM_MOUSEMOVE()ON_WM_LBUTTONUP()ON_WM_SETFOCUS()ON_WM_KILLFOCUS()ON_COMMAND(ID_DRAW_TEXT, &CMydraw111View:OnDrawText)ON_WM_CHAR()ON_WM_SETCURSOR()ON_WM_ACTIVATE()ON_COMMAND(ID_DRAW_RECT, &CM
13、ydraw111View:OnDrawRect)ON_UPDATE_COMMAND_UI(ID_DRAW_RECT, &CMydraw111View:OnUpdateDrawRect)ON_COMMAND(ID_DRAW_ELLIPSE, &CMydraw111View:OnDrawEllipse)ON_UPDATE_COMMAND_UI(ID_DRAW_ELLIPSE, &CMydraw111View:OnUpdateDrawEllipse)ON_COMMAND(ID_DRAW_CIRCLE, &CMydraw111View:OnDrawCircle)ON_UPDATE_COMMAND_UI
14、(ID_DRAW_CIRCLE, &CMydraw111View:OnUpdateDrawCircle)ON_COMMAND(ID_DRAW_ERASER, &CMydraw111View:OnDrawEraser)ON_UPDATE_COMMAND_UI(ID_DRAW_ERASER, &CMydraw111View:OnUpdateDrawEraser)ON_UPDATE_COMMAND_UI(ID_DRAW_TEXT, &CMydraw111View:OnUpdateDrawText)END_MESSAGE_MAP()/ CMydraw111View 构造/析构CMydraw111View:CMydraw111View()/ TODO: 在此处添加构造代码CMydraw111View:CMydraw111View()BOOL CMydraw111Vie