如何使用wxMathPlot创建"实时"图?

Tim*_*Tim 3 c++ graphing plot wxwidgets wxmathplot

我正在考虑使用wxMathPlot来绘制/绘制一些连续到达的数据.我想用它绘制"实时"情节/图表.那可能吗?

IE我不想只是一次性读取文件的静态图 - 我希望绘制流数据并继续到图的右侧 - (并让左侧掉落/滚出视图)

编辑

我还没有得到答案.wxmathPlot库中有一个名为mpFXYVector的有趣类,但它只是从数据向量中绘制一个图.我想要的是可以输入流并水平滚动图形的东西(如果需要也可以调整比例尺)

小智 5

谢谢ravenspoint ...... !! 我做了你说的..它完美无瑕!这是我的AddData()函数:

void mpFXYVector::AddData(float x, float y, std::vector<double> &xs, std::vector<double> &ys)
    {
        // Check if the data vectora are of the same size
        if (xs.size() != ys.size()) {
            wxLogError(_("wxMathPlot error: X and Y vector are not of the same length!"));
            return;
        }

        //Delete first point if you need a filo buffer (i dont need it)
        //xs.erase(xs.begin());
        //xy.erase(xy.begin());

        //Add new Data points at the end
        xs.push_back(x);
        ys.push_back(y);


        // Copy the data:
        m_xs = xs;
        m_ys = ys;

        // Update internal variables for the bounding box.
        if (xs.size()>0)
        {
            m_minX  = xs[0];
            m_maxX  = xs[0];
            m_minY  = ys[0];
            m_maxY  = ys[0];

            std::vector<double>::const_iterator  it;

            for (it=xs.begin();it!=xs.end();it++)
            {
                if (*it<m_minX) m_minX=*it;
                if (*it>m_maxX) m_maxX=*it;
            }
            for (it=ys.begin();it!=ys.end();it++)
            {
                if (*it<m_minY) m_minY=*it;
                if (*it>m_maxY) m_maxY=*it;
            }
            m_minX-=0.5f;
            m_minY-=0.5f;
            m_maxX+=0.5f;
            m_maxY+=0.5f;
        }
        else
        {
            m_minX  = -1;
            m_maxX  = 1;
            m_minY  = -1;
            m_maxY  = 1;
        }
    }
Run Code Online (Sandbox Code Playgroud)

在Main()中你只需要:

m_Vector->AddData(xPos,yPos,vectorX, vectorY);
m_plot->Fit();
Run Code Online (Sandbox Code Playgroud)