Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Fast Diagram Creation (Read 2216 times)
luffy911
YaBB Newbies
*
Offline



Posts: 8
Joined: Sep 2nd, 2010
Fast Diagram Creation
Sep 2nd, 2010 at 8:17pm
Print Post  
Hello,
   I am trying to optimize my diagram loading.  Since we are using our custom data, I cannot use the Load function.  In my profiler, I saw that a lot of time is spent in the redraw function which is called each time I change a property on a node.

My node creation will be like this:
Node = new ShapeNode(diagram)
           {
               Tag = this,
               Bounds = NodeBounds,
               Shape = VariableShape,
               Brush = new MindFusion.Drawing.SolidBrush(ShapeColor),
               Pen = NodePen,
               EnabledHandles = AdjustmentHandles.Move,
               HandlesStyle = HandlesStyle.Custom,               
               CustomDraw = CustomDraw.Additional
           };

Which will does a lot of redraws.  Is there function I could call to prevent any redraw while I am creating all the node of my diagram ?
ex:
    diagram.BeginUpdate()

    //Create a lot of node and link and add them to the diagram

    diagram.EndUpdate() // Redraw diagram


Thank you


Olivier Pomerleau
Ubisoft


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Fast Diagram Creation
Reply #1 - Sep 2nd, 2010 at 8:31pm
Print Post  
Hi,

You could assign the Diagram to a DiagramView only after loading all nodes. Nothing should redraw when there's no view displaying the diagram.

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



Posts: 8
Joined: Sep 2nd, 2010
Re: Fast Diagram Creation
Reply #2 - Sep 2nd, 2010 at 9:04pm
Print Post  
Problem solved !

Thank you it does works well!

  
Back to top
 
IP Logged
 
Nedor
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 16
Joined: Aug 6th, 2010
Re: Fast Diagram Creation
Reply #3 - Sep 7th, 2010 at 1:27pm
Print Post  
Sorry to bring back this topic, but i have a smilar problem like luffy911, but its a bit more complex.

I load the whole diagram in small parts with a load on demand mechanism (only such nodes/links are loaded which are currently visible).
- If I try to load a new region of the diagram, other regions which are loaded before, shouldn't be removed from the view.
- I have to append the loaded links/nodes to the active diagram.
- Nodes which are currently loaded can be connected to other nodes, which are already part of the diagram.
- The loading of this new nodes/links is done asynchrone.

How can I improve the speed of such an mechanism?

Currently the loading of a Region is done like this:
1. A BackgroundWorker starts to load the nodes/links for one Region
2. If the data was loaded, a ReportProgress event is sent
3. on the ReportProgress event all the loaded Nodes/Links are added to the Graph.
4. If some more Regions should be loaded goto 1.

Currently 3. is the bottleneck. Instead of adding all Nodes/Links before repainting the view, a repaint is done after each single Add.






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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Fast Diagram Creation
Reply #4 - Sep 7th, 2010 at 1:49pm
Print Post  
Redrawing should not be that slow. Check these tips, some of them might help more:
http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_disc;action=display;num=123393917...

In addition to them, try the following if using auto-routing:
- add all links after all nodes, or you could get the routing function run many times and discard the result when next node is added
- enclose the item-addition code between diagram.LinkRouter.Suspend and Resume calls.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint