Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ScatterDraw & ScatterCtrl » ScatterDraw data ownership
ScatterDraw data ownership [message #54066] Fri, 29 May 2020 11:27 Go to next message
busiek is currently offline  busiek
Messages: 51
Registered: February 2011
Location: Poland
Member
Hi,

After creating new serie (say with AddSeries<Vector<Pointf>>) I want ScatterDraw to take control over this data. How to do it?

I mean if someone deletes the serie using ScatterCtrl, the data stored with it should be deleted too. I tried several approaches with SetDataSource_Internal or with creating DataSource based class storing Vector<Pointf>, but it seems it is not a way to do it.

Jakub
Re: ScatterDraw data ownership [message #54070 is a reply to message #54066] Fri, 29 May 2020 23:27 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3196
Registered: August 2008
Senior Veteran
Hello Jakub

This is a good proposal. Now it has been added SetDataSourceInternal(). It copies all data sources to the ScatterDraw, so you can delete them or set them out of scope, and ScatterDraw/Ctrl will work properly. The only problem is that if original data source is changed, ScatterDraw will not change.


Best regards
Iñaki
Re: ScatterDraw data ownership [message #54084 is a reply to message #54070] Sat, 30 May 2020 18:37 Go to previous messageGo to next message
busiek is currently offline  busiek
Messages: 51
Registered: February 2011
Location: Poland
Member
Hi,

Thank you, it works. However, my app is interactive and user can create a new serie. Calling SetDataSourceInteral each time a serie is added, seems to be overwhelming. There could be also a version parameterized by serie's index. Another possibility is AddSeries(DataSource& ds) variant with additional parameter whether to take ownership of the data source.

Jakub
Re: ScatterDraw data ownership [message #54085 is a reply to message #54084] Sat, 30 May 2020 20:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3196
Registered: August 2008
Senior Veteran
Dear Jakob

If your application is interactive, I would not unlink Scatter from data. That is the nice thing of having all coupled.
In case that you need, for any case, to unlink them, SetDataSourceInternal() does the job just once after all AddSeries() calls.

In addition, if your user updates the data, you would have to call Refresh(). If you unlink the data, you would have to call SetDataSourceInternal(), so this does not require additional lines of code.


Best regards
Iñaki

[Updated on: Sat, 30 May 2020 20:03]

Report message to a moderator

Re: ScatterDraw data ownership [message #54087 is a reply to message #54085] Sat, 30 May 2020 22:45 Go to previous messageGo to next message
busiek is currently offline  busiek
Messages: 51
Registered: February 2011
Location: Poland
Member
Dear Koldo,

OK. Currently, I simply call SetDataSourceInternal() whenever I need - i.e. when new serie is created. It works. However, when I want to add some another serie, I need to call SetDataSourceInternal() again and - as I understand - it copies all data for all series once again, while only the data of the new serie should be copied. Correct me, if I am wrong.

I operate on a very big data. The main functionality of my app is to find some nice smoothing of the given data interactively. I try several settings, create new series basing on some previous one and compare visually how they match. Currently, the interface you provided simply suffices. I just wonder what would happen if a single serie needed ~1 GB memory to store. Then avoiding any kind of copying is welcome, but it is hypothetical setting Wink

Jakub
P.S. Scatter{Draw,Ctrl} is great and it saved me a lot of work Smile
Re: ScatterDraw data ownership [message #54094 is a reply to message #54087] Sun, 31 May 2020 20:51 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3196
Registered: August 2008
Senior Veteran
Dear Jakob

If you handle lots of data interactively, SetDataSourceInternal() is not the best option, as it copies the data from your source to the internal storage.
In this case, I strongly advice you to use Scatter normally, so you manage that the data will be always available for Scatter.


Best regards
Iñaki

[Updated on: Sun, 31 May 2020 20:52]

Report message to a moderator

Re: ScatterDraw data ownership [message #54095 is a reply to message #54094] Sun, 31 May 2020 22:24 Go to previous messageGo to next message
busiek is currently offline  busiek
Messages: 51
Registered: February 2011
Location: Poland
Member
Dear Koldo,

Well yes, that would be the best option, but then I will need from ScatterDraw some callbacks informing whether a serie is removed/inserted/swapped. Actually, I would be able to live with WhenRemoved callback to release memory for removed serie.

Jakub
Re: ScatterDraw data ownership [message #54101 is a reply to message #54095] Mon, 01 June 2020 08:00 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3196
Registered: August 2008
Senior Veteran
Dear Jakub

I do not understand you well. Series are added and removed by code, not by user, so why would it be necessary to add a callback?


Best regards
Iñaki
Re: ScatterDraw data ownership [message #54102 is a reply to message #54066] Mon, 01 June 2020 08:03 Go to previous messageGo to next message
busiek is currently offline  busiek
Messages: 51
Registered: February 2011
Location: Poland
Member
Well, in ScatterCtrl, under Properties you can remove or rearrange series. So this action can be performed by a user interactively. I use this functionality in my app. There is no way to get feedback whether such action by a user was performed.

[Updated on: Mon, 01 June 2020 08:03]

Report message to a moderator

Re: ScatterDraw data ownership [message #54105 is a reply to message #54102] Mon, 01 June 2020 10:35 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3196
Registered: August 2008
Senior Veteran
Yes, you are right.
I have added and documented this:
bool RemoveSeries(int index);
bool SwapSeries(int i1, int i2);

Function <bool(int)> WhenRemoveSeries;
Function <bool(int, int)> WhenSwapSeries;
The callbacks are called just before, and if they return false, the operation is not done and RemoveSeries() or SwapSeries() return also false.


Best regards
Iñaki

[Updated on: Mon, 01 June 2020 10:40]

Report message to a moderator

Re: ScatterDraw data ownership [message #54107 is a reply to message #54105] Mon, 01 June 2020 12:27 Go to previous messageGo to next message
busiek is currently offline  busiek
Messages: 51
Registered: February 2011
Location: Poland
Member
Thank you. That makes the job Smile
Re: ScatterDraw data ownership [message #54108 is a reply to message #54107] Mon, 01 June 2020 14:12 Go to previous message
koldo is currently offline  koldo
Messages: 3196
Registered: August 2008
Senior Veteran
Cool!

Best regards
Iñaki
Previous Topic: Ideas: Grid lines at "round" dates or values. More options for tooltip.
Goto Forum:
  


Current Time: Sun Sep 27 15:09:36 CEST 2020

Total time taken to generate the page: 0.01648 seconds