painterfacade.h

来自「神经网络中的K-MEAN聚类算法」· C头文件 代码 · 共 54 行

H
54
字号
#ifndef _PAINTER_FACADE_H__
#define _PAINTER_FACADE_H__

#define BASE_UNIT 20.0

class CPointf
{
public:
    CPointf(){x = 0.0; y = 0.0;}
    CPointf(double xval, double yval):x(xval), y(yval){}
    double x;
    double y;
};

/*************************************************************************
  some draw methods which map the point of math coordinates to logical ones      
  notice that this class never change the properties the device content,
  and user must set its properties outside this class                   
/*************************************************************************/

class PainterFacade
{
public:
    PainterFacade(CRect& logicalRect, double dbBaseUnit = BASE_UNIT)
        :m_logicalRect(logicalRect), 
         m_dbBaseUnit(dbBaseUnit){};
    
    /* map the point of math coordinates to logical ones */
    int MPtoLP(const CPointf *pSrcPf, CPoint *pDstP);

    /* the inverse function of MPtoLP */
    int LPtoMP(const CPoint *pSrcP, CPointf *pDstPf);

    /* draw the math coordinate */
    int DrawCoordinate(CDC *pDC);

    /* draw point use method of draw ellipse */
    int DrawPoint(CDC *pDC, const CPointf *pf);

    /* draw point use method of draw line */
    int DrawPoint(CDC *pDC, const CPointf *pf, int nPointUnit);

    /* draw a line for the linear formula ax + by + c = 0 */
    int DrawLine(CDC* pDC, double a, double b, double c);
 
    int DrawEllipse(CDC* pDC, const CPointf *pf, int a, int b);

    const CRect &GetRect() { return m_logicalRect; }
private:
    CRect m_logicalRect;
    double m_dbBaseUnit;
};

#endif /* _PAINTER_FACADE_H__ */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?