SpotPanel Issu


At first, thx for your help about my last post, a friend of mine is curently working on that.

I have an other issu with SpotPanel.

I create 8 attach points on my node but I am wondering if it’s possible to attach a link all other I want on a node instead of having fixed point where I can attach it?

Moreover, when using attach point, link doesn’t touch my figure (this is logical because ma spotpannel is at middleright position) :

I am wondering if it’s possible to attach my links all over my nodes and not just on 8 fixed points?

Hope you will understand,

Thx in advance for your help

Don’t use separate port objects at all. (Then you won’t need a SpotPanel either.)

Note that the other two links connect directly to the Alpha shape. That’s because those links are connected to a port element that has go:Node.FromSpot or ToSpot values of Spot.None, which causes link routing to go to the nearest intersection point along the edge of the shape.

By default the whole node acts as the (only) port element. You appear to have added elements with a value for go:Node.PortId. But if you want any link to connect to any point in the node, I think you do not want to use separate port elements.

Orthogonal routing will normally cause links to go towards the center of the port. If you want to adjust that point for any particular link you can set the Link.Route.FromSpot or ToSpot values, which take precedence over the spot values on the port element.

Oki, but I would like to let the user choose where he wants to attach the link on my node.

If I use Spot.None, the link will touch my node but the user wont be able to choose where the node and the link touch each other. Am I wrong?

I would like to be able to do that with my graph :

Is there a way to do that?

Are you saying that you want a tool that lets the user drag the end of a link in order to specify exactly where the link should terminate on the node? If so, there isn’t any such predefined tool – you’ll need to implement this yourself.

The closest similar functionality is the LinkShiftingTool that is in the Sequential Function sample in version 1.3. But that tool assumes the user can only shift the end of the link along the sides of the rectangular node, not anywhere within the bounds.

Another consideration is that having such a tool handle at the end of the link will conflict with the handles used by the RelinkingTool, if you want to allow users to do that. But maybe you could customize the RelinkingTool to support “shifting” the endpoint of the link when the pointer is within the bounds of the original node, and is “relinking” to another node when the pointer is outside of the bounds of the original node.

In either scenario you’ll want to set the Link.Route.FromSpot or ToSpot to be a Spot that accurately identifies where you want it to terminate. Look in the sample LinkShiftingTool.DoReshape method for an example of this.

Yes, I want to let the user drag the end of the link where he wants along the side of my nodes but not in my nodes.

What I don’t understand is if my node isn’t rectangular but triangular, will I be able to drag the end of my link where I want along the side of my node or is it only true for rectangular nodes? :$

I look the sequential function sample but on this sample I can’t shift the end of the link along the sides of the node, maybe I didn’t understand what you said…

The code in the Sequential Function sample of version 1.3 assumes the node/port is rectangular. But you could adapt the code to restrict the end-point to assume the node/port is triangular if you want to implement that.

That is new functionality that was added in the 1.3 samples. You’ll need to install the 1.3 (beta) kit to get the code.

Thx a lot, I am going to look at that :)

Could you tell me where I can get the 1.3 (beta) kit plz?

Thx in advance

There was an announcement in this forum. Look in the top section of the list of topics.

Thx, It seems very complicated to do this because I want to allow users using all kind or forms (rectangular, triangular, circle…)

Is it a way to put my spotpanels on my triangular/rectangular form without using “0.0 0.0” or “1.0 0.0”? How can I get my forms’ borders and can I create my spots on these borders? :$

You can use our code to compute that point if you inherit from the Route class so that you can call Route.GetLinkPointFromPoint.

This function is used to link at a specific point on my nodes, no?

I would like to create several spot on my borders’ nodes, but, in order to do that, I must be able to get back the borders route of my nodes (whatever they are : rectangular, triangular, circle…) and then put spot wherever I want on these borders.

Is that possible? :$

Route.GetLinkPointFromPoint is just used to compute the nearest intersection point of a line with an element. Of course it’s frequently used when routing links to port elements with go:Node…Spot=“None”, but you could use it for other purposes such as constraining the permitted end points of a link whose end is being shifted, or for deciding where to put a port when setting up a node.

I try to do that :

Route route= new Route();

Point pointSpot1 = route.GetLinkPointFromPoint(this,
new Point(localisation_x, localisation_y),
new Point(localisation_x + 100, localisation_y),

localisation_x and localisation_y are my node’s coordonnate. I dont understant what the port is…

And I can’t find GetLinkPointFromPoint, maybe because it is protected… I can find GetLinkPoint for exemple, but it is public…

That’s why you have to subclass Route.

For your purposes, you can just pass the Rectangle or Ellipse or Path as the “port”.

For your usage, you might be able to just use a singleton of that class, so that you don’t have to have an instance of a Link using your Route-inheriting class. But I’m not sure about that. You can try calling it without it being part of a Link and see if it works.

“this” is of myData type (inherit from GraphLinksModelNodeData)

How can I cast myData in a Node type?

Thx again for your help :)

You can’t. At the model level there’s no way to tell how the data is going to be represented in the Diagram control. It depends entirely on the DataTemplate that is used to create the Node, including the data-bindings that are used.

If you are trying to implement a tool like LinkShiftingTool, the code will be working with a particular port FrameworkElement that is in a particular Node. In the case above, it will be the triangular Path. So you’ll have an element when you try to determine the geometrical intersection of a line with the element (Shape).

Ok, but I am still lost…

So the frameworkElement is NodeFigure.Triangle?

I try to do that but I still don’t know what is port… :$

foreach (Node node in myDiagram.SelectedParts)
MyData data = node.Data as MyData;

            Point pointLocalisation = node.Location;

            double localisation_x = pointLocalisation.X;
            double localisation_y = pointLocalisation.Y;

            CustomRoute route = new CustomRoute();

            Point pointSpot = route.CustomGetLinkPointFromPoint(node,
                                                     /* my figure */,
                                                     new Point(localisation_x, localisation_y),
                                                     new Point(localisation_x + 100, localisation_y),

            myDiagram.StartTransaction("Adding spots");

            Spot spot = data.Spot;

            spot.X = pointSpot.X;
            spot.Y = pointSpot.Y;

            data.Spot = spot;

            myDiagram.CommitTransaction("Adding spots");

If you only have one port for each node, you could use “node.Port” where you now have “/* my figure */”.

I first want to try with one port but I would like to create several port :)