diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/pgf/base/source/SimpleDemoOGDF.c++ |
Initial commit
Diffstat (limited to 'graphics/pgf/base/source/SimpleDemoOGDF.c++')
-rw-r--r-- | graphics/pgf/base/source/SimpleDemoOGDF.c++ | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/graphics/pgf/base/source/SimpleDemoOGDF.c++ b/graphics/pgf/base/source/SimpleDemoOGDF.c++ new file mode 100644 index 0000000000..b7d914c520 --- /dev/null +++ b/graphics/pgf/base/source/SimpleDemoOGDF.c++ @@ -0,0 +1,43 @@ +#include <pgf/gd/ogdf/c/InterfaceFromOGDF.h> + +#include <math.h> + +using namespace ogdf; +using namespace scripting; + +struct FastLayoutOGDF : declarations, ogdf_runner { + + void run () { + double angle = 6.28318530718 / graph.numberOfNodes(); + double radius = parameters->option<double>("my radius ogdf"); + + int i = 0; + for (node v = graph.firstNode(); v; v=v->succ(), i++) { + graph_attributes.x(v) = cos(angle*i) * radius; + graph_attributes.y(v) = sin(angle*i) * radius; + } + } + + void declare(script s) { + using namespace scripting; + + s.declare(key ("fast simple demo layout ogdf") + .summary ("The OGDF version of the hello world of graph drawing") + .precondition ("connected") + .algorithm (this)); + + s.declare(key ("my radius ogdf") + .summary ("A radius value for the hello world of graph drawing") + .type ("length") + .initial ("1cm")); + } + +}; + +extern "C" int luaopen_pgf_gd_ogdf_c_SimpleDemoOGDF (struct lua_State *state) { + + script (state).declare (new FastLayoutOGDF); + + return 0; +} + |