⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chartwnd.h

📁 PCI的一个测试程序,可以测试PCI driver和BOARD的功能.
💻 H
字号:
#pragma once

#include "chartdata.h"
#include "WndTips.h"
#include <afxtempl.h>

// CChartWnd

struct TPOINT
{
    ULONG   x;
    ULONG   y;
};

class TCurvePoint
{
public:
	ULONG   x;			// 点信息,x为size,y为Bps
	ULONG   y;
	
    double  DispX;
    int     UnitX;      // k/M
    double  DispY;
    int     UnitY;      // k/M

	int		ViewX;		// 点坐标,相对于ChartWnd
	int		ViewY;
};

class TAxresInfor
{
public:
	ULONG	Transformer;	// 1024 or 1024*1024
	
    ULONG   BaseValue;      // 0 is defualt
    ULONG   Layers;
    ULONG   SubLayers;

	ULONG	UnitValue;
	
	double  Ratio;	// origin value / Ratio => Point, calcualte while Drawing

public:
    TAxresInfor()
    {
        Transformer = 1024;
        BaseValue   = 0;
        Layers      = 8;
        SubLayers   = 5;
        UnitValue   = 20 * 1024;
        Ratio       = 20;
    }
};



class CChartItem
{
public:
    COLORREF        m_color;
    char            m_name[256];
    int             m_count;
    TCurvePoint *   m_pCurveData;

public:
    CChartItem()
    {
        m_color   = RGB(0,0,0);
        m_name[0] = 0;
        m_count   = 0;
        m_pCurveData = NULL;
    }
    ~CChartItem()
    {
        if (m_pCurveData)
            free(m_pCurveData);
    }

    void    SetId(COLORREF color, const char *name)
    {
        m_color = color;
        strncpy(m_name, name, sizeof(m_name) - 1);
        m_name[sizeof(m_name)-1] = 0;
    }

    void    SetChartData(int count, TCurvePoint * pChartData)
    {
        if (count <= 0)
            return;

        if (m_pCurveData)
            free(m_pCurveData);

        m_pCurveData = (TCurvePoint *)malloc(sizeof(TCurvePoint) * count);

        for(int i=0; i<count; ++i)
        {
            m_pCurveData[i].x = pChartData[i].x;
            m_pCurveData[i].y = pChartData[i].y;

            m_pCurveData[i].DispX = pChartData[i].DispX;
            m_pCurveData[i].DispY = pChartData[i].DispY;

            m_pCurveData[i].UnitX = pChartData[i].UnitX;
            m_pCurveData[i].UnitY = pChartData[i].UnitY;

            m_pCurveData[i].ViewX = pChartData[i].ViewX;
            m_pCurveData[i].ViewY = pChartData[i].ViewY;
        }
        m_count = count;
    }

    void    SetChartData(int count, TPOINT * pChartData)
    {
        if (count <= 0)
            return;

        if (m_pCurveData)
            free(m_pCurveData);

        m_pCurveData = (TCurvePoint *)malloc(sizeof(TCurvePoint) * count);

        for(int i=0; i<count; ++i)
        {
            m_pCurveData[i].x = pChartData[i].x;
            m_pCurveData[i].y = pChartData[i].y;

            CALC_BPS_UNIT(m_pCurveData[i].x, m_pCurveData[i].DispX, m_pCurveData[i].UnitX);
            CALC_BPS_UNIT(m_pCurveData[i].y, m_pCurveData[i].DispY, m_pCurveData[i].UnitY);

            m_pCurveData[i].ViewX = 0;
            m_pCurveData[i].ViewY = 0;
        }
        m_count = count;
    }

};

#define MAX_CHART_COUNT     16

class CChartWnd : public CWnd
{
	DECLARE_DYNAMIC(CChartWnd)

public:
	CChartWnd();
	virtual ~CChartWnd();

protected:
	DECLARE_MESSAGE_MAP()
public:
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);

private:
    int         m_nChartCount;
    CChartItem *m_pChartItem[MAX_CHART_COUNT];

    CString     m_strTitle;
    CString     m_strAxresName[2];
    TAxresInfor m_AxresInfor[2];

public:
    void    SetTitle(LPCTSTR p_szTitle);
    void    SetAxresName(LPCTSTR p_szXAxresName, LPCTSTR p_szYAxresName);
    CString GetTitle();
    CString GetAxresName_X();
    CString GetAxresName_Y();
    void    AddChart(COLORREF color, const char *name, int count, TPOINT *pChartData);
    void    CalcChart();

    void    ClearChart();
    void    SetLayers(int XLayer, int YLayer, int XSubLayer = 5, int YSubLayer = 5);

public:
    CWndTips    m_wndTips;

public:
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
};


⌨️ 快捷键说明

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