DrawSysView.h
上传用户:taoguanmin
上传日期:2007-05-11
资源大小:180k
文件大小:5k
- // DrawSysView.h : interface of the CDrawSysView class
- //
- /////////////////////////////////////////////////////////////////////////////
- #if !defined(AFX_DRAWSYSVIEW_H__425C0345_B72D_45B7_9628_01D8E32F4E09__INCLUDED_)
- #define AFX_DRAWSYSVIEW_H__425C0345_B72D_45B7_9628_01D8E32F4E09__INCLUDED_
- #pragma warning(disable:4786)//禁止waring号为4786的warning消息
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "SetDlg.h"
- #include "stdlib.h"
- #include "math.h"
- #include <list>
- #include <vector>
- enum DRAWSORT{DsNull,DsLine,DsCircle,DsManyBd,DsCutLine,DsBezier,DsStroke,DsText};//画图类型
- //直线
- struct LINE
- {
- POINT pStart;
- POINT pEnd;
- bool operator==(LINE l)
- {
- if(l.pStart.x==pStart.x && l.pStart.y==pStart.y && l.pEnd.x==pEnd.x && l.pEnd.y==pEnd.y)
- return 1;
- return 0;
- };
- };
- //圆
- struct CIRCLE
- {
- POINT pMid;//圆心
- int r; //半径
- };
- //文本
- struct TEXT
- {
- CString str;
- POINT p;
- };
- using namespace std;
- typedef vector<POINT> BEZIER;//Bezier曲线
- class CDrawSysView : public CView
- {
- protected: // create from serialization only
- CDrawSysView();
- DECLARE_DYNCREATE(CDrawSysView)
- // Attributes
- public:
- CDrawSysDoc* GetDocument();
- // Operations
- public:
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CDrawSysView)
- public:
- virtual void OnDraw(CDC* pDC); // overridden to draw this view
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- protected:
- virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
- virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
- virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
- //}}AFX_VIRTUAL
- // Implementation
- public:
- void Circle(long pcx,long pcy,int r,CDC *pDC);
- virtual ~CDrawSysView();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- protected:
- void Line_DDA(POINT p1,POINT p2,CDC *pDC);
- void Line_Bresenham(POINT p1,POINT p2,CDC *pDC);
- void Line(POINT p1,POINT p2,CDC *pDC);
- void Line(LINE l,CDC *pDC);
- void Line(long p1x,long p1y,long p2x,long p2y,CDC *pDC);
- void Circle(POINT pc,int r,CDC *pDC);
- void Circle(CIRCLE c,CDC *pDC);
- int GetDist(POINT p1,POINT p2);
- void CutLine(RECT rect,POINT& p1,POINT& p2);//剪切直线
- void CutLine(RECT rect,LINE& l);
- void Bezier(vector<POINT> vectorPoint,CDC *pDC);
- void Draw3DText(CString str,CRect rectText,int nHeight,int nWidth,int nWeight,BYTE bItalic,LPCTSTR lpszFacename,CDC *pDC);
- protected:
- DRAWSORT m_dsDrawSort; //画图类型
- DRAWLINESORT m_dlsDrawLSort;//画直线的方式
- POINT m_startPoint;//前点
- POINT m_endPoint; //后点
- POINT m_spManyBd; //多边形的第一个点
- bool m_bIsMouseDown;//鼠标是否在移动
- bool m_bIsFirstDone;//多边形的第一条边是否画完
- bool m_bIsDel;
- int m_iPenWidth; //画笔宽度
- long m_lPenColor; //画笔颜色
- long m_lBkColor; //背景颜色
- long m_lFillColor;//填充颜色
- list<LINE> m_listAllLine; //当前所有的直线
- list<CIRCLE> m_listAllCircle;//当前所有的圆
- list<BEZIER> m_listBezier; //当前所有的贝塞尔曲线
- vector<TEXT> m_vectorText; //当前所有文本
- BEZIER m_vectorCurBezier;//当前的贝塞尔曲线
- //光标
- HCURSOR m_hDLCursor;//直线
- HCURSOR m_hDCCursor;//圆
- HCURSOR m_hCLCursor;//剪切
- HCURSOR m_hDBCursor;//贝塞尔曲线
- HCURSOR m_hDTCursor;//文本
- HCURSOR m_hDSCursor;//随手画
- CSetDlg m_SetDlg;
- CStatusBar* m_pwndStatusBar;
- CEdit m_edtTextIn;
- // Generated message map functions
- protected:
- //{{AFX_MSG(CDrawSysView)
- afx_msg void OnLine();
- afx_msg void OnCircle();
- afx_msg void OnUpdateLine(CCmdUI* pCmdUI);
- afx_msg void OnUpdateCircle(CCmdUI* pCmdUI);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnDda();
- afx_msg void OnBresenham();
- afx_msg void OnSet();
- afx_msg void OnManybd();
- afx_msg void OnUpdateManybd(CCmdUI* pCmdUI);
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnCut();
- afx_msg void OnUpdateCut(CCmdUI* pCmdUI);
- afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnBezier();
- afx_msg void OnUpdateBezier(CCmdUI* pCmdUI);
- afx_msg void OnText();
- afx_msg void OnClear();
- afx_msg void OnStroke();
- afx_msg void OnUpdateStroke(CCmdUI* pCmdUI);
- afx_msg void OnUpdateText(CCmdUI* pCmdUI);
- afx_msg void OnTest();
- afx_msg void OnRandline();
- afx_msg void OnRefresh();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- #ifndef _DEBUG // debug version in DrawSysView.cpp
- inline CDrawSysDoc* CDrawSysView::GetDocument()
- { return (CDrawSysDoc*)m_pDocument; }
- #endif
- /////////////////////////////////////////////////////////////////////////////
- //{{AFX_INSERT_LOCATION}}
- // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
- #endif // !defined(AFX_DRAWSYSVIEW_H__425C0345_B72D_45B7_9628_01D8E32F4E09__INCLUDED_)