| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// Copyright (c) 2018, Joseph Mirabel |
| 2 |
|
|
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) |
| 3 |
|
|
// |
| 4 |
|
|
// This file is part of gepetto-viewer. |
| 5 |
|
|
// gepetto-viewer is free software: you can redistribute it |
| 6 |
|
|
// and/or modify it under the terms of the GNU Lesser General Public |
| 7 |
|
|
// License as published by the Free Software Foundation, either version |
| 8 |
|
|
// 3 of the License, or (at your option) any later version. |
| 9 |
|
|
// |
| 10 |
|
|
// gepetto-viewer is distributed in the hope that it will be |
| 11 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 12 |
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
|
|
// General Lesser Public License for more details. You should have |
| 14 |
|
|
// received a copy of the GNU Lesser General Public License along with |
| 15 |
|
|
// gepetto-viewer. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
|
|
|
| 17 |
|
|
#include <PythonQt.h> |
| 18 |
|
|
#include <QGVEdge.h> |
| 19 |
|
|
#include <QGVNode.h> |
| 20 |
|
|
#include <QGVScene.h> |
| 21 |
|
|
#include <QGVSubGraph.h> |
| 22 |
|
|
|
| 23 |
|
|
#include <decorator.hh> |
| 24 |
|
|
|
| 25 |
|
|
namespace PyQgv { |
| 26 |
|
|
|
| 27 |
|
|
// ------- QGVScene ------------------------------------------- // |
| 28 |
|
✗ |
QGVScene* QGVDecorator::new_QGVScene(const QString& name, QObject* parent) { |
| 29 |
|
✗ |
return new QGVScene(name, parent); |
| 30 |
|
|
} |
| 31 |
|
✗ |
void QGVDecorator::delete_QGVScene(QGVScene* s) { delete s; } |
| 32 |
|
|
|
| 33 |
|
✗ |
void QGVDecorator::setGraphAttribute(QGVScene* s, const QString& name, |
| 34 |
|
|
const QString& value) { |
| 35 |
|
✗ |
s->setGraphAttribute(name, value); |
| 36 |
|
|
} |
| 37 |
|
✗ |
void QGVDecorator::setNodeAttribute(QGVScene* s, const QString& name, |
| 38 |
|
|
const QString& value) { |
| 39 |
|
✗ |
s->setNodeAttribute(name, value); |
| 40 |
|
|
} |
| 41 |
|
✗ |
void QGVDecorator::setEdgeAttribute(QGVScene* s, const QString& name, |
| 42 |
|
|
const QString& value) { |
| 43 |
|
✗ |
s->setEdgeAttribute(name, value); |
| 44 |
|
|
} |
| 45 |
|
|
|
| 46 |
|
✗ |
QGVNode* QGVDecorator::addNode(QGVScene* s, const QString& label) { |
| 47 |
|
✗ |
return s->addNode(label); |
| 48 |
|
|
} |
| 49 |
|
✗ |
QGVEdge* QGVDecorator::addEdge(QGVScene* s, QGVNode* source, QGVNode* target, |
| 50 |
|
|
const QString label) { |
| 51 |
|
✗ |
return s->addEdge(source, target, label); |
| 52 |
|
|
} |
| 53 |
|
✗ |
QGVSubGraph* QGVDecorator::addSubGraph(QGVScene* s, const QString& name, |
| 54 |
|
|
bool cluster) { |
| 55 |
|
✗ |
return s->addSubGraph(name, cluster); |
| 56 |
|
|
} |
| 57 |
|
|
|
| 58 |
|
✗ |
void QGVDecorator::setRootNode(QGVScene* s, QGVNode* node) { |
| 59 |
|
✗ |
s->setRootNode(node); |
| 60 |
|
|
} |
| 61 |
|
✗ |
void QGVDecorator::setNodePositionAttribute(QGVScene* s) { |
| 62 |
|
✗ |
s->setNodePositionAttribute(); |
| 63 |
|
|
} |
| 64 |
|
|
|
| 65 |
|
✗ |
void QGVDecorator::loadLayout(QGVScene* s, const QString& text) { |
| 66 |
|
✗ |
s->loadLayout(text); |
| 67 |
|
|
} |
| 68 |
|
✗ |
void QGVDecorator::applyLayout(QGVScene* s, const QString& algorithm) { |
| 69 |
|
✗ |
s->applyLayout(algorithm); |
| 70 |
|
|
} |
| 71 |
|
✗ |
void QGVDecorator::render(QGVScene* s, const QString& algorithm) { |
| 72 |
|
✗ |
s->render(algorithm); |
| 73 |
|
|
} |
| 74 |
|
✗ |
void QGVDecorator::render(QGVScene* s, const QString& algorithm, |
| 75 |
|
|
const QString file) { |
| 76 |
|
✗ |
s->render(algorithm, file); |
| 77 |
|
|
} |
| 78 |
|
✗ |
bool QGVDecorator::writeGraph(QGVScene* s, const QString& filename) { |
| 79 |
|
✗ |
return s->writeGraph(filename); |
| 80 |
|
|
} |
| 81 |
|
✗ |
void QGVDecorator::freeLayout(QGVScene* s) { s->freeLayout(); } |
| 82 |
|
✗ |
void QGVDecorator::clear(QGVScene* s) { s->clear(); } |
| 83 |
|
|
// ------- QGVScene ------------------------------------------- // |
| 84 |
|
|
|
| 85 |
|
|
// ------- QGVScene ------------------------------------------- // |
| 86 |
|
✗ |
void QGVDecorator::setAttribute(QGVSubGraph* s, const QString& name, |
| 87 |
|
|
const QString& value) { |
| 88 |
|
✗ |
s->setAttribute(name, value); |
| 89 |
|
|
} |
| 90 |
|
✗ |
QString QGVDecorator::getAttribute(QGVSubGraph* s, const QString& name) { |
| 91 |
|
✗ |
return s->getAttribute(name); |
| 92 |
|
|
} |
| 93 |
|
|
|
| 94 |
|
✗ |
QGVNode* QGVDecorator::addNode(QGVSubGraph* s, const QString& label) { |
| 95 |
|
✗ |
return s->addNode(label); |
| 96 |
|
|
} |
| 97 |
|
✗ |
QGVSubGraph* QGVDecorator::addSubGraph(QGVSubGraph* s, const QString& name, |
| 98 |
|
|
bool cluster) { |
| 99 |
|
✗ |
return s->addSubGraph(name, cluster); |
| 100 |
|
|
} |
| 101 |
|
|
// ------- QGVScene ------------------------------------------- // |
| 102 |
|
|
|
| 103 |
|
|
// ------- QGVNode ------------------------------------------- // |
| 104 |
|
✗ |
void QGVDecorator::setAttribute(QGVNode* n, const QString& name, |
| 105 |
|
|
const QString& value) { |
| 106 |
|
✗ |
n->setAttribute(name, value); |
| 107 |
|
|
} |
| 108 |
|
✗ |
QString QGVDecorator::getAttribute(QGVNode* n, const QString& name) { |
| 109 |
|
✗ |
return n->getAttribute(name); |
| 110 |
|
|
} |
| 111 |
|
|
// ------- QGVNode ------------------------------------------- // |
| 112 |
|
|
|
| 113 |
|
|
// ------- QGVEdge ------------------------------------------- // |
| 114 |
|
✗ |
void QGVDecorator::setAttribute(QGVEdge* e, const QString& name, |
| 115 |
|
|
const QString& value) { |
| 116 |
|
✗ |
e->setAttribute(name, value); |
| 117 |
|
|
} |
| 118 |
|
✗ |
QString QGVDecorator::getAttribute(QGVEdge* e, const QString& name) { |
| 119 |
|
✗ |
return e->getAttribute(name); |
| 120 |
|
|
} |
| 121 |
|
|
// ------- QGVEdge ------------------------------------------- // |
| 122 |
|
|
|
| 123 |
|
✗ |
void registerQGV() { |
| 124 |
|
✗ |
PythonQt::self()->addDecorators(new QGVDecorator()); |
| 125 |
|
✗ |
PythonQt::self()->registerCPPClass("QGVScene", "QGraphicsScene", "QGraphViz"); |
| 126 |
|
✗ |
PythonQt::self()->registerCPPClass("QGVSubGraph", "QGraphicsItem", |
| 127 |
|
|
"QGraphViz"); |
| 128 |
|
✗ |
PythonQt::self()->registerCPPClass("QGVNode", "QGraphicsItem", "QGraphViz"); |
| 129 |
|
✗ |
PythonQt::self()->registerCPPClass("QGVEdge", "QGraphicsItem", "QGraphViz"); |
| 130 |
|
|
} |
| 131 |
|
|
|
| 132 |
|
|
} // namespace PyQgv |
| 133 |
|
|
|