本文主要是介绍基于MCF setPixel函数的画板程序(一)架构设计,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
流程设计
类设计
DrawElement类
#pragma once
#include <vector>
using namespace std;
class PaintElement
{
private:std::vector<CPoint> paintLine;COLORREF color;int weight;int mod;
public :void AddPoint(CPoint src);void Set(COLORREF in_color,int in_weight);void DrawPaint(CDC *pDC);
};
class PointElement
{
private:CPoint postion;COLORREF color;int weight;int mod;//线型
public:void CreatPoint(CPoint in_Point, COLORREF in_Color, int in_Weight);void CreatPoint(CPoint in_Point, COLORREF in_Color, int in_Weight, int in_Mod);void DrawPoint(CDC *pDC);
};
class LineElement
{
private:CPoint startPoint;CPoint endPoint;COLORREF color;int weight;int mod;
public ://Set optionvoid CreatLine(CPoint sPoint,CPoint ePoint,COLORREF in_Color,int in_Weight);//Draw Optionvoid LineDraw(CDC *pDC);
};
class RectElement
{
private:CPoint leftUp;CPoint rightDown;COLORREF color;int weight;int mod;
public:void CreatRect(CPoint sPoint, CPoint ePoint, COLORREF in_Color, int in_Weight);void RectDraw(CDC *pDC);
};
class DrawManage
{
private:std::vector<PointElement> pointSet;std::vector<LineElement> lineSet; std::vector<RectElement> rectSet;std::vector<PaintElement>paintSet;//Set Option
public :DrawManage();~DrawManage();//Data Optionvoid SetClear();void PointSetPushBack(PointElement src);void LineSetPushBack(LineElement src);void RectSetPushBack(RectElement src);void PaintSetPushBack(PaintElement src);//Draw Optionvoid SetDraw(CDC *pDC);void PointSetDraw(CDC *pDC);void LineSetDraw(CDC *pDC);void RectSetDraw(CDC *pDC);void PaintSetDraw(CDC *pDC);
};
SeletedMode类
#pragma once
enum UserSelectedMod
{Draw=0,Pick,Erase,Break
};
enum DrawMod
{Point=0,Line,Rect,Circle,Besiel,Paint
};
enum PickMod {};
enum EraseMod {};
enum BreakMod {};
class SelectMod
{public:SelectMod();~SelectMod();public:UserSelectedMod userSelectMod;DrawMod drawMod;//others
};
其他界面类省略
void CSketchpadView::OnDraw(CDC* pDC)
{CSketchpadDoc* pDoc = GetDocument();ASSERT_VALID(pDoc);if (!pDoc)return;//重画所有图集drawManage.SetDraw(pDC);
}
代码链接
https://github.com/LLDCoder/Sketchpad
这篇关于基于MCF setPixel函数的画板程序(一)架构设计的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!