__attribute__((used)) char* vizRenderFromString(const char *string, const char *format, const char *engine) { Agraph_t *graph; char *result; unsigned int length; if (context == NULL) { context = gvContext(); gvAddLibrary(context, &gvplugin_core_LTX_library); gvAddLibrary(context, &gvplugin_dot_layout_LTX_library); gvAddLibrary(context, &gvplugin_neato_layout_LTX_library); } graph = agmemread((char *) string); gvLayout(context, graph, engine); gvRenderData(context, graph, format, &result, &length); gvFreeLayout(context, graph); agclose(graph); return result; }
bool CFrmSettings::createLayout() { rdr_t rdr; //first attach attributes to graph int _pos = graphData.indexOf(tr("{")); graphData.replace(_pos, 1, "{" + WIDGET(QTextEdit, teAttributes)->toPlainText()); /* Reset line number and file name; * If known, might want to use real name */ agsetfile((char*)"<gvedit>"); QByteArray bytes = graphData.toUtf8(); rdr.data = bytes.constData(); rdr.len = strlen(rdr.data); rdr.cur = 0; graph = agmemread(rdr.data); if (!graph) return false; if (agerrors()) { agclose(graph); graph = NULL; return false; } Agraph_t *G = this->graph; QString layout; layout=WIDGET(QComboBox, cbLayout)->currentText(); gvLayout(gvc, G, (char *)layout.toUtf8().constData()); /* library function */ return true; }
void GraphvizPlotter::plot() { if(path.length() == 0) { throw "Path is empty"; } if(name.length() == 0) { throw "Name is empty"; } // nacte nastaveny format grafu std::string format = getStringOutputFormat(); // vytvori konecne umisteni a nazev souboru std::string filename = path + name + "." + format; // vytvori potrebne struktury graphvizu GVC_t *gvc; Agraph_t *g; gvc = gvContext(); // parsovani ze struktury DOT do interni reprezentace graphvizu g = agmemread(getDot().c_str()); // pouziti defaultniho nastroje dot gvLayout(gvc, g, "dot"); // vykresleni grafu do souboru gvRenderFilename(gvc, g, format.c_str(), filename.c_str()); // uvolneni vsech struktur graphvizu z pameti gvFreeLayout(gvc, g); agclose(g); }
void SkillGuiGraphDrawingArea::layout_graph() { if (__graph) { gvFreeLayout(__gvc, __graph); agclose(__graph); } __graph = agmemread((char *)__graph_dot.c_str()); if (__graph) { gvLayout(__gvc, __graph, (char *)"dot"); } }
Graph *GraphvizPlotter::parseDot(std::string content) { if(content.length() == 0) { throw "content is empty"; } g_graph = agmemread(content.c_str()); if (g_graph) { parse(); } return graph; }
GraphVizUtils::VerticesCoordinates GraphVizUtils::getVerticesCoordinates( GraphIF * graph, GraphVizEngine layoutEngine, GraphDimmention graphMaxWidth, GraphDimmention graphMaxHeight) { GVC_t *gvc { }; Agraph_t *g { }; std::string dotFormatedGraph { }; char * graphRenderedData { }; unsigned int length { }; VerticesCoordinates verticesCoordinates { }; std::stringstream ss { }; gvc = gvContext(); dotFormatedGraph = OutputUtils::impl::DOT::exportGraph(graph); g = agmemread(dotFormatedGraph.c_str()); gvLayout(gvc, g, EnumUtils::getGraphVizEngineString(layoutEngine)); gvRenderData(gvc, g, "plain", &graphRenderedData, &length); ss << graphRenderedData; switch (layoutEngine) { case GraphVizEngine::DOT: break; case GraphVizEngine::NEATO: verticesCoordinates = GraphVizUtils::impl::getVerticesCoordinatesAsNeato(ss, graph->getNumberOfVertices(), graphMaxWidth, graphMaxHeight); break; default: break; } gvFreeRenderData(graphRenderedData); gvFreeLayout(gvc, g); agclose(g); gvFreeContext(gvc); return verticesCoordinates; }
__attribute__((used)) char* vizRenderFromString(char *string, char *format) { GVC_t *context = gvContext(); gvAddLibrary(context, &gvplugin_core_LTX_library); gvAddLibrary(context, &gvplugin_dot_layout_LTX_library); Agraph_t *graph = agmemread(string); gvLayout(context, graph, "dot"); char *result; unsigned int length; gvRenderData(context, graph, format, &result, &length); gvFreeLayout(context, graph); agclose(graph); gvFinalize(context); gvFreeContext(context); return result; }
graph_t* next_input_graph(void) { graph_t *g; g = agmemread(Files[0]); return g; }
Agraph_t *readstring(char *string) { if (!gvc) gvc = gvContext(); return agmemread(string); }
Agraph_t *readstring(char *string) { if (!gvc) gv_init(); return agmemread(string); }
bool DotFunction::LazyDotSequence::InternalIterator::next(Item& aItem) { if(!is_open) { GraphvizFunction::throwErrorWithQName(theItemSequence->theFunc->theModule->getItemFactory(), "IM003", "DotFunction::LazyDotSequence Iterator consumed without open"); } Item lItem; Agraph_t *lGraph = 0; String lGraphInput; GVC_t *lGvc = 0; std::ifstream lSVGFile; if (!arg_iter->next(lItem)) // exhausted return false; lGvc = gvContext(); try { lGraphInput = lItem.getStringValue(); lGraph = agmemread(const_cast<char*>(lGraphInput.c_str())); if (!lGraph) { GraphvizFunction::throwErrorWithQName(theItemSequence->theFunc->theModule->getItemFactory(), "IM003", "could not read input"); } if ( gvLayout(lGvc, lGraph, const_cast<char*>("dot")) != 0 ) { GraphvizFunction::throwErrorWithQName(theItemSequence->theFunc->theModule->getItemFactory(), "IM003", "could not generate layout"); } std::string lTmpFile = theItemSequence->theFunc->getGraphvizTmpFileName(theItemSequence->theFunc->theModule->getItemFactory()); if ( gvRenderFilename(lGvc, lGraph, const_cast<char*>("svg"), const_cast<char*>(lTmpFile.c_str())) != 0 ) { GraphvizFunction::throwErrorWithQName(theItemSequence->theFunc->theModule->getItemFactory(), "IM003", "could not render graph"); } lSVGFile.open(lTmpFile.c_str()); if (lSVGFile.bad()) { std::ostringstream lErrorMsg; lErrorMsg << "could not read from file " << lTmpFile.c_str(); GraphvizFunction::throwErrorWithQName(theItemSequence->theFunc->theModule->getItemFactory(), "IM003", lErrorMsg.str()); } aItem = Zorba::getInstance(0)->getXmlDataManager()->parseXML(lSVGFile); gvFreeLayout(lGvc, lGraph); agclose(lGraph); gvFreeContext(lGvc); remove(lTmpFile.c_str()); } catch (...) { aItem = NULL; if (lGraph) { gvFreeLayout(lGvc, lGraph); agclose(lGraph); } gvFreeContext(lGvc); throw; } return true; } /* DotFunction::LazyDotSequence::next */