#pragma once #ifdef UNICODE #define COPYSTRING wcscpy_s #else #define COPYSTRING strcpy_s #endif #define STR_CLASS_NAME _T("CDrawGraph") typedef CArray DataBuff; // CDrawGraph class CDrawGraph : public CWnd { DECLARE_DYNAMIC(CDrawGraph) CFont m_fontView; COLORREF m_clrCoordBkg,m_clrFrame,m_clrWave; int m_nMarginLeft,m_nMarginTop,m_nMarginRight,m_nMarginBottom; double m_dbStartX, m_dbEndX,m_dbStartY,m_dbEndY; double m_dbResolutionX,m_dbResolutionY; int m_nDivisionX,m_nDivisionY; DataBuff m_dataGraphY; DataBuff m_dataGraphX; CString m_XAxisLabel,m_YAxisLabel; public: CDrawGraph(); virtual ~CDrawGraph(); void RegisterCtrlClass(); void SetViewFont(const CString& strFont, int nPointSize, int nWeight, BOOL bIsRedraw=TRUE); void SetMargin(int nLeft, int nTop, int nRight, int nBottom, BOOL bIsRedraw=TRUE); bool SetGraphyView(double dbStartX, double dbEndX, double dbStartY, double dbEndY, int nDivisionX = 10, int nDivisionY = 10, BOOL bIsRedraw=TRUE); void SetResolution(double dbResolutionX, double dbResolutionY, BOOL bIsRedraw=TRUE); void LoadGraphyYAxisData(DataBuff& dataShow); void LoadGraphyXAxisData(DataBuff& dataShow); void AddGraphyData(double _data); void RedrawGraph(BOOL bIsRedraw=TRUE); void SetCoordinateLabel(const CString& _XAxis,const CString& _YAxis); void RemoveGraphyData(BOOL bIsRedraw=TRUE); void DrawCoordinate(CDC* pDC, CRect rectCoord); void DrawIdealCurve(CDC* pDC, CRect rectCoord); void DrawActualCurve(CDC* pDC, CRect rectCoord); protected: virtual void PreSubclassWindow(); public: afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() };