|
Data duplication between user data and the the data set object for each layer |
Posted by DCKelley on Mar-21-2011 03:32 |
|
I am new of ChartDirector and have just started evaluating the product for graphing some large data sets we have. So far so good, and it seems like just what we needed. It is also key to our needs to be able to move from MFC/C++ to Qt for some code reuse (and away from dot Net) and I like what I have seen so far.
My question concerns how the data set objects are created in each chart layer. When I use an array of doubles in a call like
c->addBarLayer(DoubleArray( theData, theCount)
Can I then delete or reuse the data array I passed in for another layer (different data contents) (theData in the above)?
Am I right in presuming that the addXXXLayer call will clone a copy for the data set objects it needs?
Am I right in perusing that when I free up the chart object (c inthe above) all these data set are also removed?
Many thanks for your support
DCk. |
Re: Data duplication between user data and the the data set object for each layer |
Posted by Peter Kwan on Mar-21-2011 12:08 |
|
Hi DCKelley,
When your pass any data to ChartDirector, ChartDirector will clone it. So you can use the data array "theData" for another purpose.
When the chart object is destroyed, all memory allocated by the chart will be released automatically. This includes the memory used to store the cloned data, and the Layer and DataSet objects, etc..
In brief, in the ChartDirector API, if the memory is allocated by your code (eg. your code uses "new" or "malloc"), your code would need to "delete" or "free" the memory. If the memory is not allocated by your code (eg. the memory for cloning is allocated by ChartDirector internally, not by your code), your code do not need to free the memory. ChartDirector will automatically free the memory when it no longer needs it.
For ChartDirector objects, typically your code only allocates the chart object (eg. by using "new XYChart(....)"), so this is the only object you need to delete.
Hope this can help.
Regards
Peter Kwan |
Re: Data duplication between user data and the the data set object for each layer |
Posted by DC Kelley on Mar-22-2011 02:34 |
|
Peter
Thanks for the rapid reply. It works as advertised and your suggestion/confirmation is most helpful.
At a first cut, 20 line layers each of 25,000 points each take no appreciable time to 'clone' and perhaps 3 seconds to plot the group (on a middle aged 1.6G machine). With 30 layers and 86,000 point (one sec over an entire 24 hour day) it takes 7~8 seconds. Size of image makes no apparent impact (this data set needs a ~50x decimation to plot it, which slows down others). For our needs, these are good speed results. I am really looking forward to jumping into this. Thanks for creating such a wonderful tool. |
|