mfc iocomp iPlotX控件,曲线显示或隐藏

来源:互联网 发布:电子书阅读器软件 编辑:程序博客网 时间:2024/06/07 01:48

1、右键添加iPlotX控件,

2、在其上边画条曲线 ,long index = m_iPlotX.AddChannel(); //动态添加通道,返回值是通道的索引

3、使用方法SetVisible显示或隐藏曲线,我的例子如下:

m_iPlotX.SetTitleText(_T("标题")); //设置标题

//使用button1画曲线

void CCiPlotXTestDlg::OnBnClickedButton1()
{
double XData;
double YData;
XData = 0;
YData = 0;
for(int i=0; i<100; i++)
{
XData = XData + 1;
YData = (rand()/(double)RAND_MAX)*100;
m_iPlotX.GetChannel(0).AddXY(XData, YData);

m_iPlotX.GetChannel(0).SetTitleText(_T("通道1")); //设置通道的Title
}
}


//使用button2显示或隐藏取向
void CCiPlotXTestDlg::OnBnClickedButton2()
{
if(button2TF)
{
((CButton *)GetDlgItem(IDC_BUTTON2))->SetWindowText(_T("显示")); //修改button的caption
button2TF = 0;
m_iPlotX.GetChannel(0).SetVisible(0);//隐藏通道一
}
else
{
((CButton *)GetDlgItem(IDC_BUTTON2))->SetWindowText(_T("隐藏")); 
button2TF = 1;
m_iPlotX.GetChannel(0).SetVisible(1); //显示通道一
}
}

//上边的方法是整个隐藏或显示

//下边的方法是从继续的地方继续画


void CCiPlotXTestDlg::OnBnClickedButton2()
{
//m_iPlotX.GetChannel(0).Clear();
if(button2TF)
{
((CButton *)GetDlgItem(IDC_BUTTON2))->SetWindowText(_T("显示")); //修改checkbox的状态
button2TF = 0;
//m_iPlotX.GetChannel(1).Clear();
m_iPlotX.GetChannel(1).SetVisible(0);
}
else
{
((CButton *)GetDlgItem(IDC_BUTTON2))->SetWindowText(_T("隐藏")); 
button2TF = 1;
m_iPlotX.GetChannel(1).Clear(); //清除之前画的线
m_iPlotX.GetChannel(1).SetVisible(1);
}
}


0 0
原创粉丝点击