mfc iocomp iPlotX控制元件,曲線顯示或隱藏
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);
}
}