Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Adding data to a PtMTrend: (3 Items)
   
Adding data to a PtMTrend  
Hi,

I'm having some trouble adding data to a PtMTrend widget. I have multiple trends in the same widget and I am trying to 
use PtMTrendAddData() so that the trends scroll across the screen. The structure of the code is like below:

std::vector data;
data.resize(20);
// Fill data here
PtMTrendAddData(widget, 0, &data[0], data.size());
// Fill data for second trend here
PtMTrendAddData(widget, 1, &data[0], data.size());

It seems that when I add data to one trend the other gets zero added to it for the same length. I tried to add data for 
all trends at the same time, but I could only add to one trend at a time.

Is it possible to use PtMTrendAddData() in this scenario or do I have to maintain my own buffer for each trend into 
which I add the new data and change the entire data for each trend on an update using PtMTrendChangeData()?

Thanks.
Re: Adding data to a PtMTrend  
It looks like you are doing this from an input callback or a workproc.

Put PtHold()/PtRelease() around the trend updates:

PtHold();
...
PtMTrendAddData();
PtMTrendAddData();
...
PtRelease();
Re: Adding data to a PtMTrend  
Hi Misha,

Yes, I should have said. I am doing this from a thread (using PtEnter() and PtLeave() to get access to the UI).

Your solution works perfectly.

Thank you.