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

Improve QGV bindings

parent f29a7c33
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,10 @@
#include <PythonQt/PythonQt.h>
#include <QGVScene.h>
#include <QGVNode.h>
#include <QGVEdge.h>
namespace PyQgv {
// ------- QGVScene ------------------------------------------- //
QGVScene* QGVDecorator::new_QGVScene(const QString &name) { return new QGVScene(name); }
......@@ -45,6 +49,16 @@ void QGVDecorator::freeLayout (QGVScene* s) { s->freeLayout(); }
void QGVDecorator::clear (QGVScene* s) { s->clear(); }
// ------- QGVScene ------------------------------------------- //
// ------- QGVNode ------------------------------------------- //
void QGVDecorator::setAttribute (QGVNode* n, const QString &name, const QString &value) { n->setAttribute(name,value); }
QString QGVDecorator::getAttribute (QGVNode* n, const QString &name) { return n->getAttribute(name); }
// ------- QGVNode ------------------------------------------- //
// ------- QGVEdge ------------------------------------------- //
void QGVDecorator::setAttribute (QGVEdge* e, const QString &name, const QString &value) { e->setAttribute(name,value); }
QString QGVDecorator::getAttribute (QGVEdge* e, const QString &name) { return e->getAttribute(name); }
// ------- QGVEdge ------------------------------------------- //
void registerQGV ()
{
PythonQt::self()->addDecorators (new QGVDecorator ());
......@@ -52,3 +66,5 @@ void registerQGV ()
PythonQt::self()->registerCPPClass ("QGVNode" , "QGraphicsItem" , "qgv");
PythonQt::self()->registerCPPClass ("QGVEdge" , "QGraphicsItem" , "qgv");
}
} // namespace PyQgv
......@@ -21,14 +21,15 @@ class QGVScene;
class QGVNode;
class QGVEdge;
class QGVCORE_EXPORT QGVDecorator : public QObject
{
namespace PyQgv {
class QGVCORE_EXPORT QGVDecorator : public QObject
{
Q_OBJECT
public slots:
public slots:
// ------- QGVScene ------------------------------------------- //
QGVScene* new_QGVScene(const QString &name);
// ------- QGVScene ------------------------------------------- //
QGVScene* new_QGVScene(const QString &name);
QGVScene* new_QGVScene(const QString &name, QObject *parent);
void delete_QGVScene(QGVScene* s);
......@@ -51,8 +52,19 @@ public slots:
void render (QGVScene* s, const QString &algorithm, const QString file);
void freeLayout (QGVScene* s);
void clear (QGVScene* s);
// ------- QGVScene ------------------------------------------- //
// ------- QGVScene ------------------------------------------- //
};
// ------- QGVNode ------------------------------------------- //
void setAttribute (QGVNode* n, const QString &name, const QString &value);
QString getAttribute (QGVNode* n, const QString &name);
// ------- QGVNode ------------------------------------------- //
void registerQGV ();
// ------- QGVEdge ------------------------------------------- //
void setAttribute (QGVEdge* e, const QString &name, const QString &value);
QString getAttribute (QGVEdge* e, const QString &name);
// ------- QGVEdge ------------------------------------------- //
};
/// Register QGV to PythonQt
void registerQGV ();
} // namespace PyQgv
......@@ -20,8 +20,10 @@
#include <decorator.hh>
void PyQGV::init() {
registerQGV();
}
namespace PyQgv {
void Plugin::init() {
registerQGV();
}
Q_EXPORT_PLUGIN2 (pyqgv, PyQGV)
Q_EXPORT_PLUGIN2 (pyqgv, Plugin)
} // namespace PyQgv
......@@ -20,12 +20,16 @@
#include <gepetto/gui/plugin-interface.hh>
class PyQGV : public QObject, public gepetto::gui::PluginInterface {
Q_OBJECT
Q_INTERFACES (gepetto::gui::PluginInterface)
namespace PyQgv {
/// Provide bindings of QGV library in PythonQt terminal.
class Plugin : public QObject, public gepetto::gui::PluginInterface {
Q_OBJECT
Q_INTERFACES (gepetto::gui::PluginInterface)
public:
QString name () const { return QString("PyQGV"); }
public:
QString name () const { return QString("PyQGV"); }
void init();
};
/// Calls \ref registerQGV
void init();
};
} // namespace PyQgv
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