GraphWin Call-Back FunctionsWhat is a Call-Back Function?Call-Back or Handler functions can be used to associate arbitrary functionality with the edit operations of the interactive interface of GraphWin. For complete examples of how to use Call-Back functions see Online Demos of Graph Algorithms and A Recipe for Online Demos of Network Algorithms.For every edit operation two handlers can be defined
The null-handler ( Simple Example Call-Back Functions New-Node and New-Edge OperationsThe following operation sets the pre-handler of the new-node operation tof , i.e., f(gw,p) is called before a node is created at position
p .
void gw.set_new_node_handler(bool (*f)(GraphWin&,const point&));The function void gw.set_new_node_handler(void (*f)(GraphWin&,node));sets the post-handler of the new-node operation to f , i.e., f(gw,v)
is called after a new node v has been created.
void gw.set_new_edge_handler(bool (*f)(GraphWin&,node,node));sets the pre-handler of the new-edge operation to f , i.e., f(gw,v,w)
is called before a new edge (v,w) is created. The function
void gw.set_new_edge_handler(void (*f)(GraphWin&,edge));sets the post-handler of the new-edge operation to f , i.e., f(gw,e)
is called after a new edge e has been created.
Del-Node and Del-Edge OperationsThe following operation sets the pre-handler of the del-node operation tof , i.e., f(gw,v) is called before a node is deleted.
void gw.set_del_node_handler(bool (*f)(GraphWin&,node));The function void gw.set_del_node_handler(void (*f)(GraphWin&));sets the post-handler of the del-node operation to f , i.e., f(gw)
is called after a node has been deleted.
void gw.set_del_edge_handler(bool (*f)(GraphWin&,node,node));sets the pre-handler of the del-edge operation to f , i.e., f(gw,e)
is called before an edge e is deleted. The function
void gw.set_del_edge_handler(void (*f)(GraphWin&));sets the post-handler of the del-edge operation to f , i.e., f(gw)
is called after an edge e has been deleted.
Init-Graph OperationsThe following operation sets the pre-handler of the init-graph operation tof , i.e., f(gw) is called every time before a global update
of the graph, e.g., in a clear, generate,
or load operation.
void gw.set_init_graph_handler(bool (*f)(GraphWin&));The function void gw.set_init_graph_handler(void (*f)(GraphWin&));sets the post-handler of the init-graph operation to f , i.e.,
f(gw) is called after each global update of the graph.
Move-HandlerNode moving and edge slider moving operations may have three different handlers. The first is called before moving starts, the second is called for every intermediate position, and the third one is called at the final position of the node after the moving has been finished. The handlers are set byvoid gw.set_start_move_node_handler (bool (*f)(GraphWin&,node)); void gw.set_move_node_handler (bool (*f)(GraphWin&,node,const point&)); void gw.set_end_move_node_handler (void (*f)(GraphWin&,node)); void gw.set_start_edge_slider_handler (bool (*f)(GraphWin&,edge,double),int i); void gw.set_edge_slider_handler (bool (*f)(GraphWin&,edge,double),int i); void gw.set_end_edge_slider_handler (void (*f)(GraphWin&,edge,double),int i);Each edge has three sliders associated with it. The integer argument i
in the last three functions selects the slider, i=0,1,2 . |
See also:Customizing the Interactive Interface A Recipe for Online Demos of Graph Algorithms A Recipe for Online Demos of Network Algorithms Manual Pages: |