Creating Links

The IlvMakeLinkInteractor class is the base class for interactors that allow the user to interactively connect nodes in a grapher. Its constructor is as follows:

IlvMakeLinkInteractor(IlvManager* manager,

IlvView* view,

IlBoolean oriented = IlTrue);

The oriented parameter specifies whether created links are oriented. An example of how to create an interactor of this type and connect it to a grapher and one of its view is presented here:

IlvGrapher* graph = ...;

IlvView* view = graph->getFirstView();

IlvMakeLinkInteractor * inter = new IlvMakeLinkInteractor(graph, view);

graph->setInteractor(inter);

To connect two nodes, perform the following steps:

  1. Click the starting node. This node is highlighted if it is considered valid by the interactor.

  2. Drag the mouse until it is positioned over the ending node. If this node is valid, it is also highlighted.

  3. Release the mouse button to create the link.

You can control which node is valid by overloading the ::acceptFrom and ::acceptTo methods. There are two ways of specifying what type of link should be created:

The Grapher library provides several predefined subclasses of IlvMakeLinkInteractor:

  • - This class is used to create a link of type IlvLinkLabel.

Creating Polyline Links

The IlvMakePolyLinkInteractor class is a special kind of interactor that does not derive from IlvMakeLinkInteractor.

This interactor is used to create links whose intermediate points can be explicitly defined. It lets you control the shape drawn by the user by means of the IlvMakePolyLinkInteractor::accept method:

virtual IlBoolean accept(IlvPoint& point);

By overloading this method, you can add specific constraints on the position of the intermediate points of the link. Once these points have been defined, the link is created with the IlvMakePolyLinkInteractormakeLink method, which must be defined in subclasses to return the appropriate link instance. The grapher library provides one predefined subclass, IlvMakePolyLinkInteractor, which is used to create links of the IlvPolylineLinkImage type.