Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic draw a diagram in a scrollviewer performance question (Read 2984 times)
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
draw a diagram in a scrollviewer performance question
Dec 17th, 2014 at 3:26pm
Print Post  
I created a diagram in a scrollviewer node by node, link by link by reading a XML. I calculated the bounds of the diagram for zoom-in purpose. I can see the diagram will draw everything when I only have limited visible area in the scrollviewer. My question:
1. Is it possible only draw the visible area nodes and links? should I use GetNodesInViewport? Will this way help performance in case my diagram is very big?
2. How diagram is saved for zoom-in purpose? Is the diagram one piece or several pieces after it is created? If I can only draw visible area nodes and links, when I first created the diagram, how should I calculate the bounds for zoom-in purpose later? I still need to know all my nodes and links arrangement, do I?

Thanks,
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: draw a diagram in a scrollviewer performance question
Reply #1 - Dec 18th, 2014 at 9:36am
Print Post  
Quote:
Is it possible only draw the visible area nodes and links?


All DiagramItem-inherited objects you add to the diagram become a part of the WPF visual tree. If you want to add and remove items dynamically so that only ones inside current viewport exist in the visual tree, you will end up with something similar to what the VirtualizingDiagram control does, so check if it will work for you.

Quote:
should I use GetNodesInViewport?


GetNodesInViewport returns nodes from Diagram.Nodes collection that intersect with current viewport. You could implement some kind of virtualization yourself if you enable the RemoveHiddenItemsFromVisualTree property, and then each time scroll position changes set Visible = true for all items in the viewport, and Visible = false for all items outside of it.

Quote:
How diagram is saved for zoom-in purpose? Is the diagram one piece or several pieces after it is created?


The diagram with all of its child elements is part of the WPF visual tree.

Quote:
If I can only draw visible area nodes and links, when I first created the diagram, how should I calculate the bounds for zoom-in purpose later? I still need to know all my nodes and links arrangement, do I?


I suppose you could keep items detached from the diagram and only add them when their bounding rectangle intersects current viewport, or instead of DiagramNode and DiagramLink objects keep information in separate model data objects. Again, that's what VirtualizingDiagram already does out of the box; check the Virtualization sample project for an example of how it works.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
Re: draw a diagram in a scrollviewer performance question
Reply #2 - Dec 18th, 2014 at 4:19pm
Print Post  
Thank you, Stoyo! I am going to give a try.
  
Back to top
 
IP Logged
 
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
Re: draw a diagram in a scrollviewer performance question
Reply #3 - Jan 2nd, 2015 at 8:11pm
Print Post  
I am trying VirtualizingDiagram. Got questions:
1. use out of box VirtualizingDiagram, Do I suppose to only see nodes and links in the viewport? I attached an image from snoop to capture the diagram, the visible viewport is the rectangle on the left, I was hoping only see nodes in that rectangle.
2. I am not be able to find RemoveHiddenItemsFromVisualTree property. Is it in VirtualizingDiagram class?

Thanks,
  

snoop-zoomer.JPG (Attachment deleted)
Back to top
 
IP Logged
 
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
Re: draw a diagram in a scrollviewer performance question
Reply #4 - Jan 2nd, 2015 at 10:26pm
Print Post  
Continue with my questions:
3. I couldn't make VirtualizingDiagram collects ShapeNode as NodesSource. Tried 2 ways: 1) ShapeNode is the base class of NodeData, Create a collection of NodeData with different shape, brush...), 2) NodeData class with Shape, Brush as property, create a collection of NodeData.
4. When VirtualizingDiagram collects LinksSource, will it accept ControlPoint to create Links? My Links have control points, not directly go from origin to destination.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: draw a diagram in a scrollviewer performance question
Reply #5 - Jan 5th, 2015 at 9:45am
Print Post  
Quote:
1. use out of box VirtualizingDiagram, Do I suppose to only see nodes and links in the viewport? I attached an image from snoop to capture the diagram, the visible viewport is the rectangle on the left, I was hoping only see nodes in that rectangle.


You might be seeing more nodes if this tool intercepts the layout process and passes a larger arrange size to the diagram. If it just shows all current children of a control in a separate view, you can still see nodes outside of the viewport because they are not reused until number of elements reaches VisualCacheSize.

Quote:
2. I am not be able to find RemoveHiddenItemsFromVisualTree property. Is it in VirtualizingDiagram class?


I think it's available since the v3.1 release, try upgrading to latest version.

Quote:
3. I couldn't make VirtualizingDiagram collects ShapeNode as NodesSource. Tried 2 ways: 1) ShapeNode is the base class of NodeData, Create a collection of NodeData with different shape, brush...), 2) NodeData class with Shape, Brush as property, create a collection of NodeData.
4. When VirtualizingDiagram collects LinksSource, will it accept ControlPoint to create Links? My Links have control points, not directly go from origin to destination.


It doesn't seem the control expects actual ShapeNode and DiagramLink data objects, and for example it looks for X,Y properties in data items instead of Bounds. It should still be possible to use actual nodes and links as items, try setting node positions from ResolveNodePosition callback, and copying or binding other properties from InstantiateNode and InstantiateLink callbacks.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint