# This script is designed to run with Understand as Graphical View # These graphs are rendered using Graphviz and the values for many of the options can be found at www.graphviz.org use base ("Understand::Graph::Gv"); use strict; # Required - Return the short name of the graph, slashes (\\) will be used to create directories in the menu sub name { return "test\\#1 Graph Template";} # Return 1 if this graph should run for the selected entity ($entity), 0 if not # return -1 to indicate this graph is never available, nor valid, for any entities. sub test_entity { my $entity = shift; # return $entity->kind->check("function"); # run the graph on function entities return 1; # run the graph on any entity by right clicking it and selecting graphical views } # Return 1 if this graph should be run on the entire project # and appear in the top level graph menu, otherwise return 0 # Understand must be restarted to view new global graphs sub test_global { return 1;} # Optional - Indicate this graph supports the cancel button. sub support_abort { return 1; } our $abort_called; # Optional - This function is called when the cancel button is clicked sub abort{ $abort_called=1; } # Required - Initialization code will be called once, per external graph object. sub init { my $graph = shift; $abort_called=0; #reset the cancel flag in case it was set on another run # These create graph options # $graph->options->define("Choice Name",["Option1","Option2",...],"default"); $graph->options->define("FavoriteColor",["Red","Blue","Green"],"Red"); } # Required - This is where the graph is actually run # if this is called for an entity $ent is set to the Understand::Ent object sub do_load { my $graph = shift; my $ent = shift; $graph->default("rankdir","LR","graph"); $graph->default("color","blue","node"); $graph->default("shape","box","node"); $graph->default("fontcolor","black","node"); my $color = $graph->options->lookup("FavoriteColor"); my $node = $graph->node($color); $node->set("color",$color); } # Callable Graph methods: # cluster([name[,label]]) - create a cluster subgraph. # db() - return the open db. # default(name,value[,kind]) - set an attribute default. # edge(node,node[,label[,ref]]) - create edge between two nodes. # node() - create unnamed, unlabeled node. # node(name[,label]) - create a named node. # node(unique_id, label, ent )- create a node associated with an entity. # options - return an options object for the graph. # progress(percent [,text]) - # set(name,value) - set an attribute. # subgraph() - create a subgraph. # yield() - yield time to the UI # # Callable Node methods: i.e. $node->set("color","red"); # set(name,value) - set an attribute. # sync(fileentity [,line[,column]]) - set sync file, line and column # # Callable Edge methods: i.e. $edge->set("color","blue"); # set(name,value) - set an attribute. # sync(fileentity [,line[,column]]) - set sync file, line and column # # Callable Options methods: # define(name,values,default) - define a new option # lookup(name) - return the value for an option # # To set cluster defaults use $cluster->default("fillcolor","red") # # Valid attribute values can be found at www.graphviz.org # Graph attributes: # bgcolor - cluster background color. # rankdir # default # # Node attributes : # fillcolor - fill color of node. # color - line color of node. # entity # font # fontcolor # fontsize # label # shape # # Edge attributes: # color