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

📄 chartwnd.cpp

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

#include "stdafx.h"
#include "virtualWave.h"
#include "ChartWnd.h"

#include "ChartLine.h"
#include "ChartRx.h"
#include "ChartSerial.h"

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

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

CChartWnd::CChartWnd()
{
	mChart = new CChartRx();
}

CChartWnd::~CChartWnd()
{

	delete mChart;
}

BOOL CChartWnd::Create(LPCTSTR lpszText, DWORD dwStyle,
				const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	dwStyle = dwStyle | WS_CHILD | WS_VISIBLE;
	return	mChart->Create(lpszText, dwStyle, rect, pParentWnd, nID);
}

void CChartWnd::SetXScale(double min, double max)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->SetXScale(min, max);
}

void CChartWnd::SetYScale(double min, double max)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->SetYScale(min, max);
}

void CChartWnd::SetTitle(int index, LPCTSTR str)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->SetTitleText(index, str);
}

void CChartWnd::SetChartType(int type)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->SetChartType(type);
}

void CChartWnd::SetYDivision(int major, int mini)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->SetYDivision(major, mini);
}

void CChartWnd::SetXDivision(int major, int mini)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->SetXDivision(major, mini);
}

void CChartWnd::SetTickFormat(CString x, CString y)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->SetTickFormat(x, y);
}

void CChartWnd::SetSerialCount(int count)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->SetSerialCount(count);
}

void CChartWnd::SetSerialColor(int index, COLORREF cr)
{
	CChartRx * pChart = (CChartRx *)mChart;
	CChartSerial * serial = pChart->GetSerial(index);
	serial->crSerial = cr;
}

COLORREF CChartWnd::GetSerialColor(int index)
{
	CChartRx * pChart = (CChartRx *)mChart;
	CChartSerial * serial = pChart->GetSerial(index);
	return serial->crSerial;

}

void CChartWnd::SetSerialPoints(int index, int count)
{
	CChartRx * pChart = (CChartRx *)mChart;
	CChartSerial * serial = pChart->GetSerial(index);
	serial->SetSize(count, -1);

}

void CChartWnd::AddSerialPoint(int index, double x, double y, double value)
{
	CChartRx * pChart = (CChartRx *)mChart;
	CChartSerial * serial = pChart->GetSerial(index);
	serial->AddPoint(x, y, value);
}

void CChartWnd::AddSerialPointEx(int index, double x, double y, double value)
{
	CChartRx * pChart = (CChartRx *)mChart;
	CChartSerial * serial = pChart->GetSerial(index);
	serial->AddPointEx(x, y, value);
}

void CChartWnd::ClearSerialPoints(int index)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->ClearSerialPoints(index);
}

void CChartWnd::AddXLabel(double xVal)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->AddXLabel(xVal);
}

void CChartWnd::ClearXLabels()
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->ClearXLabels();
}

void CChartWnd::ShowTip(BOOL bShow)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->bShowTip = bShow;
}

void CChartWnd::CanMagnify(BOOL bShow)
{
	CChartRx * pChart = (CChartRx *)mChart;
	pChart->bCanMagnify = bShow;
}

void CChartWnd::SaveBmp(LPCTSTR Filepath, BOOL bWhileBack)
{
	CChartRx * pChart = (CChartRx *)mChart;	
	if (bWhileBack)
		pChart->SaveBmpEx(Filepath);
	else
		pChart->SaveBmp(Filepath);
}


void CChartWnd::Updata()
{
	CChartRx * pChart = (CChartRx *)mChart;	
	pChart->Updata();
}

void CChartWnd::SetBackColor(COLORREF cr)
{
	CChartRx * pChart = (CChartRx *)mChart;	
	pChart->crBackGround = cr;
}

void CChartWnd::SetForeColor(COLORREF cr)
{
	CChartRx * pChart = (CChartRx *)mChart;	
	pChart->crForeGround = cr;
}

void CChartWnd::SetTitleColor(int index, COLORREF cr)
{
	CChartRx * pChart = (CChartRx *)mChart;	
	if (index == 0)
	{
		pChart->TitleLabel.SetColor(cr);
	}
	else if (index == 1)
	{
		pChart->x_AxisTitle.SetColor(cr);
	}
	else if (index == 2)
	{
		pChart->y_AxisTitle.SetColor(cr);
	}
}

void CChartWnd::SetLableColor(int index, COLORREF cr)
{
	CChartRx * pChart = (CChartRx *)mChart;	

	if (index == 1)
	{
		pChart->x_AxisLabel.SetColor(cr);
	}
	else if (index == 2)
	{
		pChart->y_AxisLabel.SetColor(cr);
	}
	else if (index == 3)
	{
		pChart->TipLabel.SetColor(cr);
	}
	else if (index == 4)
	{
		pChart->userPointsLabel.SetColor(cr);
	}
}

void CChartWnd::SetTitleFontSize(int index, int size)
{
	CChartRx * pChart = (CChartRx *)mChart;	
	if (pChart->pMemDC == NULL)
		return;

	if (index == 0)
	{
		pChart->TitleLabel.SetFontSize(size, pChart->pMemDC->m_hDC);
	}
	else if (index == 1)
	{
		pChart->x_AxisTitle.SetFontSize(size, pChart->pMemDC->m_hDC);
	}
	else if (index == 2)
	{
		pChart->y_AxisTitle.SetFontSize(size, pChart->pMemDC->m_hDC);
	}
}

void CChartWnd::SetLabelFontSize(int index, int size)
{
	CChartRx * pChart = (CChartRx *)mChart;	
	if (pChart->pMemDC == NULL)
		return;

	if (index == 1)
	{
		pChart->x_AxisLabel.SetFontSize(size, pChart->pMemDC->m_hDC);
	}
	else if (index == 2)
	{
		pChart->y_AxisLabel.SetFontSize(size, pChart->pMemDC->m_hDC);
	}
	else if (index == 3)
	{
		pChart->TipLabel.SetFontSize(size, pChart->pMemDC->m_hDC);
	}
	else if (index == 4)
	{
		pChart->userPointsLabel.SetFontSize(size, pChart->pMemDC->m_hDC);
	}
}

⌨️ 快捷键说明

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