Grapher interactor to create links defined by several points. More...
#include <ilviews/grapher/polylink.h>
Public Member Functions | |
IlvMakePolyLinkInteractor (IlvManager *manager, IlvView *view, IlBoolean oriented=IlFalse) | |
Constructor. More... | |
virtual void | abort () |
Resets the interactor to an inactive state. | |
virtual IlBoolean | accept (IlvPoint &point) |
Checks if a point is valid. More... | |
virtual IlBoolean | acceptEnd (IlUInt count, IlvPoint *allPoints) |
Validates the link creation. More... | |
virtual void | doIt (IlUInt count, IlvPoint *allPoints) |
Creates and adds a new link to the grapher. More... | |
IlvGraphic * | getEndNode () const |
Returns the ending node. More... | |
IlvGrapher * | getGrapher () const |
Returns the grapher to which the interactor is attached. More... | |
IlvGraphic * | getStartNode () const |
Returns the starting node. More... | |
virtual void | init () |
Resets the interactor to an active state. | |
IlBoolean | isOriented () const |
Indicates whether created links are oriented. More... | |
virtual void | react (IlvPoint &point, IlUShort modifiers=0) |
Highlights the nodes under a given point. More... | |
void | setEndNode (IlvGraphic *end) |
Sets the ending node. More... | |
void | setStartNode (IlvGraphic *start) |
Sets the starting node. More... | |
Protected Member Functions | |
virtual IlvLinkImage * | makeLink (IlUInt count, IlvPoint *points)=0 |
Factory method to create the new link instance. More... | |
virtual void | storeLink (IlvLinkImage *link) |
Adds the new link instance to the grapher. More... | |
Grapher interactor to create links defined by several points.
Library: ilvgrapher
This is an interactor abstract class. You need to subtype this class to create the links. In particular, the IlvMakePolyLinkInteractor::makeLink()
method should be redefined to create links of the appropriate type.
IlvPolylineLinkImage
. IlvMakePolyLinkInteractor::IlvMakePolyLinkInteractor | ( | IlvManager * | manager, |
IlvView * | view, | ||
IlBoolean | oriented = IlFalse |
||
) |
Constructor.
The constructor initializes a new instance of the IlvMakePolyLinkInteractor
class for the view view and the grapher manager.
The manager parameter is assumed to be of type IlvGrapher
. The oriented parameter is used to create the link in the IlvMakePolyLinkInteractor::makeLink()
method.
manager | The grapher to which the interactor is attached. |
view | The view to which the interactor is attached. |
oriented | IlTrue if created links are oriented and IlFalse otherwise. |
Checks if a point is valid.
If the point point is the first of the link, it is accepted only if there is a node containing this point. In this case, the node is registered as the starting node of the link that will be created by the IlvMakePolyLinkInteractor::makeLink()
method.
This method can be overloaded to add specific constraints on the starting node or on the intermediate points that will define the link.
point | The point to validate, in manager coordinates. |
IlTrue
if the point that the user provides is acceptable. Otherwise, it returns IlFalse
. getStartNode()
. Reimplemented from IlvMakePolyPointsInteractor.
|
virtual |
Validates the link creation.
Called by the member function IlvMakePolyLinkInteractor::doIt()
before creating the link. If this method returns IlTrue
, the doIt()
method proceeds. Otherwise, it is aborted and no link is created. The default implementation returns IlTrue
.
count | The number of points specified by the user. |
allPoints | The points specified by the user. |
Creates and adds a new link to the grapher.
Called when the user ends the interaction (usually through a double-click). The allPoints array gives all the points drawn by the user. The default implementation first calls the IlvMakePolyLinkInteractor::makeLink()
method with the intermediate points of the link (that is, all the points of allPoints except the first and the last). It then calls IlvMakePolyLinkInteractor::storeLink()
with the created instance to add it to the grapher.
count | The number of points specified by the user. |
allPoints | The points specified by the user. |
Implements IlvMakePolyPointsInteractor.
IlvGraphic* IlvMakePolyLinkInteractor::getEndNode | ( | ) | const |
Returns the ending node.
The ending node is registered by the IlvMakePolyLinkInteractor::react
member function each time the mouse passes over a new node.
IlvGrapher* IlvMakePolyLinkInteractor::getGrapher | ( | ) | const |
Returns the grapher to which the interactor is attached.
IlvGraphic* IlvMakePolyLinkInteractor::getStartNode | ( | ) | const |
Returns the starting node.
The starting node is stored by the IlvMakePolyLinkInteractor::accept()
member function when the first mouse click occurs.
IlBoolean IlvMakePolyLinkInteractor::isOriented | ( | ) | const |
Indicates whether created links are oriented.
IlTrue
if created links are oriented and IlFalse
otherwise.
|
protectedpure virtual |
Factory method to create the new link instance.
The points array specifies the intermediate points of the link (that is, the two endpoints of the link are not given in this array).
This method must be redefined to create the appropriate link instance. The link is created using the information given by the IlvMakePolyLinkInteractor::getStartNode()
, IlvMakePolyLinkInteractor::getEndNode()
, and IlvMakePolyLinkInteractor::isOriented()
methods.
count | The number of intermediate points defining the link. |
points | The intermediate points defining the link. |
getStartNode()
, getEndNode()
, isOriented()
. Implemented in IlvMakePolylineLinkInteractor.
Highlights the nodes under a given point.
Highlights (by selecting and deselecting) the nodes over which the mouse passes. The last selected node is registered as the ending node of the link. If the node uses connection pins, these are highlighted and the closest pin to point point is stored.
point | The point in manager coordinates. |
modifiers | The modifier keys that were active when the user created the current point. |
IlvGrapherPin
, IlvGrapherPin::getClosest()
, getEndNode()
. Reimplemented from IlvMakePolyPointsInteractor.
void IlvMakePolyLinkInteractor::setEndNode | ( | IlvGraphic * | end | ) |
Sets the ending node.
end | The new ending node. |
void IlvMakePolyLinkInteractor::setStartNode | ( | IlvGraphic * | start | ) |
Sets the starting node.
start | The new starting node. |
|
protectedvirtual |
Adds the new link instance to the grapher.
If connection pins were registered during the interaction, this method connects them to link before it is added to the grapher.
link | The new link. |
IlvGrapherPin
, IlvGrapherPin::setPinIndex()
.