Skip to content
Snippets Groups Projects
Commit 1c769d0c authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Allow to render to file and add setNodePositionAttribute

parent c8361a96
No related branches found
No related tags found
No related merge requests found
......@@ -100,6 +100,14 @@ QString QGVNode::getAttribute(const QString &name) const
return QString();
}
QString QGVNode::posToAttributeString() const
{
qreal gheight = QGVCore::graphHeight(_scene->_graph->graph());
qreal width = ND_width(_node->node())*DotDefaultDPI;
qreal height = ND_height(_node->node())*DotDefaultDPI;
return QGVCore::qtToGvPos (QGVCore::centerToOrigin (pos(), -width, -height), gheight);
}
void QGVNode::setIcon(const QImage &icon)
{
_icon = icon;
......
......@@ -43,6 +43,8 @@ public:
void setAttribute(const QString &label, const QString &value);
QString getAttribute(const QString &name) const;
QString posToAttributeString () const;
void setIcon(const QImage &icon);
enum { Type = UserType + 2 };
......
......@@ -120,6 +120,14 @@ void QGVScene::setRootNode(QGVNode *node)
agset(_graph->graph(), root, node->label().toLocal8Bit().data());
}
void QGVScene::setNodePositionAttribute()
{
foreach(QGVNode* node, _nodes) {
node->setAttribute("pos", node->posToAttributeString().toLocal8Bit().constData());
node->setAttribute ("pin", "true");
}
}
void QGVScene::loadLayout(const QString &text)
{
_graph->setGraph(QGVCore::agmemread2(text.toLocal8Bit().constData()));
......@@ -199,6 +207,12 @@ void QGVScene::render (const QString &algorithm) {
algorithm.toLocal8Bit().data(), NULL);
}
void QGVScene::render (const QString algorithm, const QString filename) {
gvRenderFilename(_context->context(), _graph->graph(),
algorithm.toLocal8Bit().data(),
filename.toLocal8Bit().data());
}
void QGVScene::freeLayout() {
gvFreeLayout(_context->context(), _graph->graph());
}
......
......@@ -50,9 +50,12 @@ public:
void setRootNode(QGVNode *node);
void setNodePositionAttribute();
void loadLayout(const QString &text);
void applyLayout(const QString &algorithm = "dot");
void render (const QString &algorithm);
void render (const QString algorithm, const QString file);
void freeLayout();
void clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment