After digging Tulip‘s code for several days, I still couldn’t find out how to load and run a plugin. This afternoon, my thesis project assistant sent me a working sample code that does what I want! Only in one or two days I guess. Oh God, he’s so fast!
This is how it’s done.
-
Initialize Tulip. At least I can figure this out myself 🙂
tlp::initTulipLib(); tlp::loadPlugins();
-
Check the existence of a plugin.
string layoutName = "Circular"; tlp::LayoutProperty::factory->pluginExists(layoutName);
-
And this is the most important chunk of code that I’m looking for.
tlp::LayoutProperty *myLayout = graph->getProperty<tlp::LayoutProperty>("viewLayout"); graph->computeProperty(layoutName, myLayout, errorMsg);
After that, the layouting is hopefully done. We only need to iterate the vertices and get position of each vertex.
tmp1 = myLayout->getNodeValue(n);
printf("node: %d, x=%f, y=%f, z=%fn", n.id, tmp1.getX(), tmp1.getY(), tmp1.getZ());