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

📄 chartserial.cpp

📁 实现波形的显示,可以作为示波器的一个模块
💻 CPP
字号:
// ChartSerial.cpp: implementation of the CChartSerial class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
//#include "RxChart.h"
#include "ChartSerial.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CChartSerial::CChartSerial()
{
	bShow = TRUE;
	pointCount = 0;
	crSerial = RGB(255, 0, 0);
}

CChartSerial::~CChartSerial()
{
	Clear();
}

//DEL void CChartSerial::SetCount(int count)
//DEL {
//DEL 	this->DataPairs.SetSize(count, 50);
//DEL }

void CChartSerial::AddPoint(double x, double y, double data)
{
	LPPOINTDATA pPoint = new POINTDATA();
	if (pPoint == NULL)
	{
		AfxMessageBox("CChartRx: 建立数据点失败!");
		return;
	}
	pPoint->x = x;
	pPoint->y = y;
	pPoint->data = data;
	this->DataPairs.Add(pPoint);
	this->pointCount ++;
}

int CChartSerial::GetPointCount()
{
	return this->pointCount;
}

LPPOINTDATA CChartSerial::GetPoint(int index)
{
	return (LPPOINTDATA)(this->DataPairs.GetAt(index));
}

void CChartSerial::Clear()
{
	int i;
	LPPOINTDATA pPoint = NULL;
	for (i=0; i<pointCount; i++)
	{
	//	pPoint = NULL;
		pPoint = (LPPOINTDATA)(this->DataPairs.GetAt(i));
		delete pPoint;
	}
	this->DataPairs.RemoveAll();
	this->DataPairs.SetSize(0, 1024);
	this->pointCount = 0;
}

void CChartSerial::SetShow(BOOL bShow)
{
	this->bShow = bShow;
}

void CChartSerial::SetSize(int max, int nGrow)
{
	DataPairs.SetSize(max, nGrow);
	this->pointCount = 0;
	this->Upbound = max;
}
// 使用直接插入的方式设置数据,不重复分配内存
void CChartSerial::AddPointEx(double x, double y, double data)
{
	LPPOINTDATA pPoint = new POINTDATA();
	pPoint->x = x;
	pPoint->y = y;
	pPoint->data = data;
	this->DataPairs.SetAt(this->pointCount, pPoint);
	this->pointCount ++;
}

⌨️ 快捷键说明

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