Grapher Interactors
The
IlvManager class provides a wide range of interactors that are used to create objects and change their shape. The
IlvGrapher class contains specific interactors designed to create new nodes and links and change the way they are connected:
Selection Interactor
The
IlvGraphSelectInteractor class derives from the
IlvSelectInteractor class. It contains additional member functions used to manage the drawing of ghost images for links attached to nodes that are moved or enlarged. This class has the following constructor:
IlvGraphSelectInteractor(IlvManager* manager, IlvView* view);
This constructor initializes a new instance of the
IlvGraphSelectInteractor class that lets you select individual objects or groups of objects in the view
view connected to the manager
manager. This manager is assumed to be an instance of the
IlvGrapher class.
Creating Nodes
The
IlvMakeNodeInteractor class is the base class for interactors that allow the user to interactively create nodes in a grapher. Instances of this class must be attached to a grapher and one of its connected views, as shown here:
IlvGrapher* graph = ...;
IlvView* view = ...;
IlvMakeNodeInteractor * inter = new IlvMakeNodeInteractor(graph, view);
graph->setInteractor(inter);
To create a node, drag a rectangular region in the working view. There are two ways to specify what type of graphic object is created:
The grapher library provides predefined subclasses of
IlvMakeNodeInteractor:
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
IlvMakeLinkInteractor::acceptFrom and
IlvMakeLinkInteractor::acceptTo methods. There are two ways of specifying what type of link should be created:
The Grapher library provides several predefined subclasses of
IlvMakeLinkInteractor:
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
IlvMakePolyLinkInteractor::makeLink method, which must be defined in subclasses to return the appropriate link instance. The grapher library provides one predefined subclass,
IlvMakePolylineLinkInteractor, which is used to create links of the
IlvPolylineLinkImage type.
Editing Connection Pins
The
IlvPinEditorInteractor class lets the user interactively edit the connection pins of a grapher node. When this interactor is active, selecting a node will highlight its connection pins, as shown in
Highlighted Connection Pins:
Highlighted Connection Pins
Once a grapher node is selected, you can:
Add a new connection pin by clicking inside the node.
Remove a connection pin. To do this, select the pin with the mouse and press the Delete key.
Move an existing connection pin. To do this, select the pin with the mouse and drag it to its desired location.
Connect and disconnect links to or from a pin. To do this, first select a connection pin, and then click the considered link.
Note: If the working node is already associated with a pin management object, this object must be of the IlvGenericPin type. If the node does not define any connection pin, then an IlvGenericPin instance is automatically created. |
Editing Links
When a link is selected, its selection object draws handles that you can use to change its shape or edit the way it is connected.
A Selected Link shows a link that has been selected:
A Selected Link
An end point handle can be dragged to:
Change the connection pin to which the link is attached. When the handle is dragged near a connection pin, the pin is highlighted and the link uses its position to compute the location of its end point.
Connect the link to another node.
The intermediate point handles can be used to edit the shape of the link. The kind of interaction allowed by these handles depends on the kind of link being edited.
Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.