Pre loader

Hiding Entities added to 3D chart

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

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

Version
8.2.0.27935
  • You must to post comments
0
0

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

  • You must to post comments
0
0

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 Burnett-Thompson
    Hi Andrew, that was a bug which was fixed at some point. Or so I thought. I will notify the team
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.