1.2: Congruent link shapes and Piping sample

Another new sample for version 1.2 demonstrates several interesting features: Piping.

The pipes are implemented using multiple LinkShapes. They all have exactly the same route, but each has a different StrokeThickness. The darkest one is the thickest, and the lightest one is the thinnest. This results in a very simple gradient across the width of each pipe, regardless of the direction in which the pipe travels.

Valves may be dropped onto a pipe, causing them to be spliced into the pipe. Instruments may also be dropped onto a pipe, causing them to be attached to the pipe.

This is enabled by setting go:Part.DropOntoBehavior on the link and by setting the diagram’s DraggingTool.DropOntoEnabled=“True”.

To prevent nodes such as tanks from being spliced into pipes, and to permit instruments to be attached to pipes, there is a custom DraggingTool and overrides of DraggingTool.ConsiderDragOver and DropOnto.

When an instrument node is dropped onto a pipe link, the node is added to a group that is the label node for the link. Using a group as the link’s label node permits a varying number of selectable and draggable instrument nodes to be positioned along the link’s route.

(Because each link in a GraphLinksModel can have at most one label node, if we didn’t use a group to hold all of the instrument nodes we could only have a single instrument node as a label node on a link. Remember also that a link’s label node is a true node: any Link in any model can have as many child elements as you want, positioned whereever you want, but they aren’t Nodes that can be selected and deleted and linked etc.)

When a valve node is dropped onto a pipe link, it is automatically spliced into the link. Some code in the custom dragging tool rotates the valve so that it is naturally going in the proper direction for that segment of the pipe.