示例#1
0
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;
}
示例#2
0
void QGVScene::loadLayout(const QString &text)
{
		_graph->setGraph(QGVCore::agmemread2(text.toLocal8Bit().constData()));

		if(gvLayout(_context->context(), _graph->graph(), "dot") != 0)
    {
        qCritical()<<"Layout render error"<<agerrors()<<QString::fromLocal8Bit(aglasterr());
        return;
    }

    //Debug output
		//gvRenderFilename(_context->context(), _graph->graph(), "png", "debug.png");

    //Read nodes and edges
		for (Agnode_t* node = agfstnode(_graph->graph()); node != NULL; node = agnxtnode(_graph->graph(), node))
    {
				QGVNode *inode = new QGVNode(new QGVNodePrivate(node), this);
        inode->updateLayout();
        addItem(inode);
        _nodes.append (inode);
				for (Agedge_t* edge = agfstout(_graph->graph(), node); edge != NULL; edge = agnxtout(_graph->graph(), edge))
        {
						QGVEdge *iedge = new QGVEdge(new QGVEdgePrivate(edge), this);
            iedge->updateLayout();
            addItem(iedge);
            _edges.append (iedge);
        }

    }
    update();
}
示例#3
0
int gvFreeContext(GVC_t * gvc)
{
    GVG_t *gvg, *gvg_next;
    gvplugin_package_t *package, *package_next;

    emit_once_reset();
    gvg_next = gvc->gvgs;
    while ((gvg = gvg_next)) {
	gvg_next = gvg->next;
	free(gvg);
    }
    package_next = gvc->packages;
    while ((package = package_next)) {
	package_next = package->next;
	free(package->path);
	free(package->name);
	free(package);
    }
    gvjobs_delete(gvc);
    if (gvc->config_path)
	free(gvc->config_path);
    if (gvc->input_filenames)
	free(gvc->input_filenames);
    free(gvc);
    return (graphviz_errors + agerrors());
}
示例#4
0
//------------------------------------------------------------------------------
int main(void) {

  Agraph_t *g = agread(stdin, NULL);

  if ( !g )
    return 1;

  agclose(mostra_grafo(g));

  return agerrors();
}
示例#5
0
int gvFreeContext(GVC_t * gvc)
{
    if (gvc->active_jobs)
	gvdevice_finalize(gvc);
    emit_jobs_eof(gvc);
    gvrender_delete_jobs(gvc);
    if (gvc->config_path)
	free(gvc->config_path);
    free(gvc);
    return (graphviz_errors + agerrors());
}
示例#6
0
文件: nop.c 项目: joewalnes/graphviz2
int main(int argc, char **argv)
{
    Agraph_t *g;
    ingraph_state ig;

    init(argc, argv);
    newIngraph(&ig, Files, gread);

    while ((g = nextGraph(&ig)) != 0) {
	if (!chkOnly) agwrite(g, stdout);
	agclose(g);
    }

    return(ig.errors | agerrors());
}
示例#7
0
void QGVScene::applyLayout(const QString &algorithm)
{
		if(gvLayout(_context->context(), _graph->graph(),
                      algorithm.toLocal8Bit().data()) != 0)
    {
        /*
         * Si plantage ici :
         *  - Verifier que les dll sont dans le repertoire d'execution
         *  - Verifie que le fichier "configN" est dans le repertoire d'execution !
         */
        qCritical()<<"Layout render error"<<agerrors()<<QString::fromLocal8Bit(aglasterr());
        return;
    }

    //Debug output
		//gvRenderFilename(_context->context(), _graph->graph(), "canon", "debug.dot");
		//gvRenderFilename(_context->context(), _graph->graph(), "png", "debug.png");

    //Update items layout
    foreach(QGVNode* node, _nodes)
        node->updateLayout();

    foreach(QGVEdge* edge, _edges)
        edge->updateLayout();

    foreach(QGVSubGraph* sgraph, _subGraphs)
        sgraph->updateLayout();

    //Graph label
		textlabel_t *xlabel = GD_label(_graph->graph());
    if(xlabel)
    {
      if (_label == NULL)
        _label = addText(xlabel->text);
      else
        _label->setPlainText (xlabel->text);
      _label->setPos(QGVCore::centerToOrigin(QGVCore::toPoint(xlabel->pos, QGVCore::graphHeight(_graph->graph())), xlabel->dimen.x, -4));
    }

    update();
}
示例#8
0
文件: input.c 项目: aosm/graphviz
void dotneato_terminate(GVC_t *gvc)
{
    dotneato_eof(gvc);
    exit(graphviz_errors + agerrors());
}