Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How could I set container node in virtual diagram? (Read 846 times)
tt
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Jan 30th, 2024
How could I set container node in virtual diagram?
Feb 19th, 2024 at 1:26pm
Print Post  
I am using a virtualization diagram to create numerous nodes with multiple templates.
Individual nodes and links use nodesource and linksource. However, I don't know how to set up the container node of an individual node.

How can I set the container of a node in a virtualization diagram?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3303
Joined: Oct 19th, 2005
Re: How could I set container node in virtual diagram?
Reply #1 - Feb 19th, 2024 at 2:46pm
Print Post  
Try sample project here -
https://mindfusion.eu/Forum/YaBB.pl?num=1493301652/3#3

but remove container handling from OnNodeRealized handler; it should now be built into the diagram.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
tt
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Jan 30th, 2024
Re: How could I set container node in virtual diagram?
Reply #2 - Feb 20th, 2024 at 6:46am
Print Post  
I referred to the project attached here.
(https://mindfusion.eu/Forum/YaBB.pl?num=1494247571)

I have another questions for container node in virtual diagram.
I created 10 templated nodes in container node without position x, y.

Could I automatically arrange diagram using layout?
My code below is not working.
Code
Select All
FlowchartLayout layout = new FlowchartLayout();
layout.Orientation = Layout.Orientation.Horizontal;
layout.Arrange(virtualizingDiagram);
 

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3303
Joined: Oct 19th, 2005
Re: How could I set container node in virtual diagram?
Reply #3 - Feb 20th, 2024 at 3:38pm
Print Post  
Layouts do not apply recursively to containers at this time. With non-virtualizing diagram, you could call ContainerNode.Arrange(layout) for each container to arrange its child nodes, and then diagram.Arrange() to arrange the overall diagram (top-level containers). Unfortunately we do not have equivalent to ContainerNode.Arrange for VirtualizingDiaram at this time. Maybe try fully realizing all items using RealizeItems(large rect) method, arranging the containers and diagram as outlined above, and copying back the coordinates from realized diagram items to data items. You could possibly realize and arrange an offscreen VirtualizingDiagram with same data source to avoid creating all the UIElements in main diagram.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
tt
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Jan 30th, 2024
Re: How could I set container node in virtual diagram?
Reply #4 - Feb 21st, 2024 at 12:45am
Print Post  
The above is a bit difficult to understand for me.
Could I get sample projects or some code blocks please?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3303
Joined: Oct 19th, 2005
Re: How could I set container node in virtual diagram?
Reply #5 - Feb 21st, 2024 at 11:28am
Print Post  
Try this, also check ControlPoints handling in zipped project (VirtualizingDiagram only creates single-segment links at this time):

Code
Select All
void ArrangeContainers()
{
	var virtualDiagram = new VirtualizingDiagram();
	virtualDiagram.InstantiateNode =
		(dataItem) => InstantiateNode(virtualDiagram, dataItem);
	virtualDiagram.NodesSource = nodes;
	virtualDiagram.LinksSource = links;

	// this creates actual nodes and links for all data items
	var inifiniteViewport = new Rect(0, 0, 1000000, 1000000);
	virtualDiagram.RealizeItems(inifiniteViewport);

	// container.Arrange does not work for VirtualizingDiagram
	var offscreenDiagram = new Diagram();
	virtualDiagram.CopyTo(offscreenDiagram);

	// apply layout to containers
	var containers = offscreenDiagram.Nodes.OfType<ContainerNode>();
	foreach (var ctr in containers)
		ctr.Arrange(new TreeLayout { LinkStyle = TreeLayoutLinkType.Cascading3 });

	// apply layout to diagram
	offscreenDiagram.Arrange(
		new LayeredLayout { MultipleGraphsPlacement = MultipleGraphsPlacement.Horizontal });

	// now actual items have coordinates
	for (int i = 0; i < offscreenDiagram.Nodes.Count; i++)
	{
		var arrangedNode = offscreenDiagram.Nodes[i];
		var rect = arrangedNode.Bounds;

		var virtualNode = virtualDiagram.Nodes[i];
		var nodeData = (NodeData)virtualNode.DataContext;
		nodeData.X = rect.X;
		nodeData.Y = rect.Y;
		nodeData.Width = rect.Width;
		nodeData.Height = rect.Height;
	}
	for (int i = 0; i < offscreenDiagram.Links.Count; i++)
	{
		var arrangedLink = offscreenDiagram.Links[i];
		var points = arrangedLink.Bounds;

		var virtualLink = virtualDiagram.Links[i];
		var linkData = (LinkData)virtualLink.DataContext;
		linkData.ControlPoints = arrangedLink.ControlPoints;
	}
} 



https://mindfusion.eu/_samples/VirtualDiagLayout.zip

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint