I have a 3D surface chart.
I programmatically add some custom entities derived from BaseSceneEntity, invoked by a user action on some other part of my UI.
When I add the items, to get the screen to refresh I use this loop after adding a number of entities:
foreach(var item in _zone_items)
{
item.InvalidateScene();
}
_zone_items is a List holding the custom entities which have been added to the chart using
MainSurfaceChart.Viewport3D.RootEntity.Children.Add(cube);
This works fine, and even if I have removed some items from the _zone_items list, the screen still refreshes correctly and shows only the current items in _zone_items (and in RootEntity.Children)
The problem I have is when I remove all items from _zone_items. When I do this I use this loop:
foreach (var item in _zone_items)
{
MainSurfaceChart.Viewport3D.RootEntity.Children.Remove(item);
}
_zone_items.Clear();
(I use Remove(item) rather than Clear as in future I may have other entities which are not in _zone_items).
but now I have no way to refresh the screen as I have no entities to call InvalidateScene(). If I touch the mouse on the chart surface and move just slightly it re-renders and the entities are not re-drawn – so they have been removed.
How can I get the chart to refresh/re-render so as to remove the entities which are no longer in the RootEntity.Children? I would have hoped removing them from Children would remove them from the screen?
Thanks
Andrew M
- Andrew Milford asked 10 months ago
- You must login to post comments
Hi Andrew
I believe that BaseSceneEntity.invalidateScene()
simply calls up to SciChart3DSurface.invalidateElement()
. You should only need to call this once after an operation
Also – when removing items please ensure that you call .Dispose()
!
Let me know if this helps
- Andrew Burnett-Thompson answered 10 months ago
- You must login to post comments
Thanks
It seems like SciChart3DSurface.InvalidateElement() fixes the refresh issue.
But if I modify my deletion code to be:
foreach (var item in _zone_items)
{
_owner.MainSurfaceChart.Viewport3D.RootEntity.Children.Remove(item);
item.Dispose();
}
_zone_items.Clear();
I then get an exception when adding new items:
System.InvalidOperationException: ‘The Maximum Mesh ID has been exceeded. Please see https://www.scichart.com/questions/wpf/maximum-mesh-id‘
Not sure why or how that is related to disposing of scene entities!
I am pretty sure I haven’t displayed that many meshes, and anyway if I remove the item.Dispose() line it then works again.
- Andrew Milford answered 10 months ago
-
Hi Andrew, that was a bug which was fixed at some point. Or so I thought. I will notify the team
- You must login to post comments
Please login first to submit.