diff --git a/CMakeLists.txt b/CMakeLists.txt index afa818aafe2bdb3c8e0a76cbf0b29c9e0ec6b385..f5e3f7c78406effa5c1a04509af2b8da16efa4ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,7 @@ ADD_SUBDIRECTORY(src) IF(NOT CLIENT_ONLY) ADD_SUBDIRECTORY(src/gui) + ADD_SUBDIRECTORY(plugins) ADD_SUBDIRECTORY(pyplugins) ADD_SUBDIRECTORY(blender) ADD_SUBDIRECTORY(examples EXCLUDE_FROM_ALL) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..cfbcda4a2ed6ee11be02be28a434cb1f62a2f414 --- /dev/null +++ b/plugins/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# Copyright (c) 2018 CNRS +# Authors: Joseph Mirabel +# +# +# This file is part of gepetto-viewer-corba +# gepetto-viewer-corba is free software: you can redistribute it +# and/or modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation, either version +# 3 of the License, or (at your option) any later version. +# +# gepetto-viewer-corba is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Lesser Public License for more details. You should have +# received a copy of the GNU Lesser General Public License along with +# gepetto-viewer-corba If not, see +# <http://www.gnu.org/licenses/>. + +#ADD_SUBDIRECTORY(plugin-skeleton) + +IF(PYTHONQT_FOUND) + ADD_OPTIONAL_DEPENDENCY("QGVCore") + + SET(BUILD_PY_QGV ${QGVCORE_FOUND} + CACHE BOOL "Build PyQGV plugin") +ENDIF(PYTHONQT_FOUND) + +IF(BUILD_PY_QGV) + ADD_SUBDIRECTORY(pyqgv) +ENDIF(BUILD_PY_QGV) diff --git a/plugins/pyqgv/CMakeLists.txt b/plugins/pyqgv/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..20669fea70c8a1068ff7d4f84379157f2abf58e1 --- /dev/null +++ b/plugins/pyqgv/CMakeLists.txt @@ -0,0 +1,62 @@ +# Copyright (c) 2018 CNRS +# Authors: Joseph Mirabel +# +# +# This file is part of gepetto-viewer-corba +# gepetto-viewer-corba is free software: you can redistribute it +# and/or modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation, either version +# 3 of the License, or (at your option) any later version. +# +# gepetto-viewer-corba is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Lesser Public License for more details. You should have +# received a copy of the GNU Lesser General Public License along with +# gepetto-viewer-corba If not, see +# <http://www.gnu.org/licenses/>. + +SET(PLUGIN_NAME pyqgv) + +SET(${PLUGIN_NAME}_HEADERS_NO_MOC + ) + +SET(${PLUGIN_NAME}_HEADERS + plugin.hh + decorator.hh + ) + +SET(${PLUGIN_NAME}_FORMS + ) + +SET(${PLUGIN_NAME}_RESOURCES + ) + +QT4_WRAP_CPP(${PLUGIN_NAME}_HEADERS_MOC ${${PLUGIN_NAME}_HEADERS}) +QT4_WRAP_UI(${PLUGIN_NAME}_FORMS_HEADERS ${${PLUGIN_NAME}_FORMS}) +QT4_ADD_RESOURCES(${PLUGIN_NAME}_RESOURCES_RCC ${${PLUGIN_NAME}_RESOURCES}) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_INCLUDE_PATH}) +INCLUDE(${QT_USE_FILE}) +ADD_DEFINITIONS(${QT_DEFINITIONS}) +ADD_DEFINITIONS(-DQT_PLUGIN) +ADD_DEFINITIONS(-DQT_NO_DEBUG) +ADD_DEFINITIONS(-DQT_SHARED) + +SET (${PLUGIN_NAME}_SOURCES + plugin.cc + decorator.cc + ) + +ADD_LIBRARY(${PLUGIN_NAME} SHARED ${${PLUGIN_NAME}_SOURCES} + ${${PLUGIN_NAME}_HEADERS_NO_MOC} + ${${PLUGIN_NAME}_HEADERS_MOC} + ${${PLUGIN_NAME}_FORMS_HEADERS} + ${${PLUGIN_NAME}_RESOURCES_RCC} + ) + +TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES} ${PYTHONQT_LIBRARIES}) +PKG_CONFIG_USE_DEPENDENCY(${PLUGIN_NAME} "QGVCore") + +# Uncomment to install +INSTALL(TARGETS ${PLUGIN_NAME} DESTINATION lib/gepetto-gui-plugins) diff --git a/plugins/pyqgv/decorator.cc b/plugins/pyqgv/decorator.cc new file mode 100644 index 0000000000000000000000000000000000000000..540c6770f18d6709f18760418c518c393e9b8f95 --- /dev/null +++ b/plugins/pyqgv/decorator.cc @@ -0,0 +1,54 @@ +// Copyright (c) 2018, Joseph Mirabel +// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) +// +// This file is part of gepetto-viewer-corba. +// gepetto-viewer-corba is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version +// 3 of the License, or (at your option) any later version. +// +// gepetto-viewer-corba is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. You should have +// received a copy of the GNU Lesser General Public License along with +// gepetto-viewer-corba. If not, see <http://www.gnu.org/licenses/>. + +#include <decorator.hh> + +#include <PythonQt/PythonQt.h> +#include <QGVScene.h> + +// ------- QGVScene ------------------------------------------- // +QGVScene* QGVDecorator::new_QGVScene(const QString &name) { return new QGVScene(name); } +QGVScene* QGVDecorator::new_QGVScene(const QString &name, QObject *parent) { return new QGVScene(name, parent); } +void QGVDecorator::delete_QGVScene(QGVScene* s) { delete s; } + +void QGVDecorator::setGraphAttribute(QGVScene* s, const QString &name, const QString &value) { s->setGraphAttribute(name, value); } +void QGVDecorator::setNodeAttribute (QGVScene* s, const QString &name, const QString &value) { s->setNodeAttribute (name, value); } +void QGVDecorator::setEdgeAttribute (QGVScene* s, const QString &name, const QString &value) { s->setEdgeAttribute (name, value); } + +QGVNode* QGVDecorator::addNode(QGVScene* s, const QString& label) { return s->addNode (label); } +QGVEdge* QGVDecorator::addEdge(QGVScene* s, QGVNode* source, QGVNode* target) { return s->addEdge (source, target); } +QGVEdge* QGVDecorator::addEdge(QGVScene* s, QGVNode* source, QGVNode* target, const QString& label) { return s->addEdge (source, target, label); } +// QGVSubGraph* QGVDecorator::addSubGraph(const QString& name, bool cluster=true); + +void QGVDecorator::setRootNode(QGVScene* s, QGVNode *node) { s->setRootNode (node); } + +// void QGVDecorator::setNodePositionAttribute(); + +void QGVDecorator::loadLayout (QGVScene* s, const QString &text) { s->loadLayout(text); } +void QGVDecorator::applyLayout(QGVScene* s, const QString &algorithm) { s->applyLayout(algorithm); } +void QGVDecorator::render (QGVScene* s, const QString &algorithm) { s->render(algorithm); } +void QGVDecorator::render (QGVScene* s, const QString &algorithm, const QString file) { s->render(algorithm, file); } +void QGVDecorator::freeLayout (QGVScene* s) { s->freeLayout(); } +void QGVDecorator::clear (QGVScene* s) { s->clear(); } +// ------- QGVScene ------------------------------------------- // + +void registerQGV () +{ + PythonQt::self()->addDecorators (new QGVDecorator ()); + PythonQt::self()->registerCPPClass ("QGVScene", "QGraphicsScene", "qgv"); + PythonQt::self()->registerCPPClass ("QGVNode" , "QGraphicsItem" , "qgv"); + PythonQt::self()->registerCPPClass ("QGVEdge" , "QGraphicsItem" , "qgv"); +} diff --git a/plugins/pyqgv/decorator.hh b/plugins/pyqgv/decorator.hh new file mode 100644 index 0000000000000000000000000000000000000000..78e741dfc25ef15f72a29740ee5e57678f7ed1da --- /dev/null +++ b/plugins/pyqgv/decorator.hh @@ -0,0 +1,58 @@ +// Copyright (c) 2018, Joseph Mirabel +// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) +// +// This file is part of gepetto-viewer-corba. +// gepetto-viewer-corba is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version +// 3 of the License, or (at your option) any later version. +// +// gepetto-viewer-corba is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. You should have +// received a copy of the GNU Lesser General Public License along with +// gepetto-viewer-corba. If not, see <http://www.gnu.org/licenses/>. + +#include "qgv.h" +#include <QObject> + +class QGVScene; +class QGVNode; +class QGVEdge; + +class QGVCORE_EXPORT QGVDecorator : public QObject +{ + Q_OBJECT + +public slots: + +// ------- QGVScene ------------------------------------------- // + QGVScene* new_QGVScene(const QString &name); + QGVScene* new_QGVScene(const QString &name, QObject *parent); + void delete_QGVScene(QGVScene* s); + + void setGraphAttribute(QGVScene* s, const QString &name, const QString &value); + void setNodeAttribute (QGVScene* s, const QString &name, const QString &value); + void setEdgeAttribute (QGVScene* s, const QString &name, const QString &value); + + QGVNode* addNode(QGVScene* s, const QString& label); + QGVEdge* addEdge(QGVScene* s, QGVNode* source, QGVNode* target); + QGVEdge* addEdge(QGVScene* s, QGVNode* source, QGVNode* target, const QString& label); + // QGVSubGraph* addSubGraph(const QString& name, bool cluster=true); + + void setRootNode(QGVScene* s, QGVNode *node); + + // void setNodePositionAttribute(); + + void loadLayout (QGVScene* s, const QString &text); + void applyLayout(QGVScene* s, const QString &algorithm); + void render (QGVScene* s, const QString &algorithm); + void render (QGVScene* s, const QString &algorithm, const QString file); + void freeLayout (QGVScene* s); + void clear (QGVScene* s); +// ------- QGVScene ------------------------------------------- // + +}; + +void registerQGV (); diff --git a/plugins/pyqgv/plugin.cc b/plugins/pyqgv/plugin.cc new file mode 100644 index 0000000000000000000000000000000000000000..5dd343675d1d72438237a8d605122fc2a51cb595 --- /dev/null +++ b/plugins/pyqgv/plugin.cc @@ -0,0 +1,27 @@ +// Copyright (c) 2018 CNRS +// Authors: Joseph Mirabel +// +// +// This file is part of gepetto-viewer-corba +// gepetto-viewer-corba is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version +// 3 of the License, or (at your option) any later version. +// +// gepetto-viewer-corba is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. You should have +// received a copy of the GNU Lesser General Public License along with +// gepetto-viewer-corba If not, see +// <http://www.gnu.org/licenses/>. + +#include <plugin.hh> + +#include <decorator.hh> + +void PyQGV::init() { + registerQGV(); +} + +Q_EXPORT_PLUGIN2 (pyqgv, PyQGV) diff --git a/plugins/pyqgv/plugin.hh b/plugins/pyqgv/plugin.hh new file mode 100644 index 0000000000000000000000000000000000000000..21587601d1a6d6152403ce980c743d4e0f808399 --- /dev/null +++ b/plugins/pyqgv/plugin.hh @@ -0,0 +1,31 @@ +// Copyright (c) 2018 CNRS +// Authors: Joseph Mirabel +// +// +// This file is part of gepetto-viewer-corba +// gepetto-viewer-corba is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version +// 3 of the License, or (at your option) any later version. +// +// gepetto-viewer-corba is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. You should have +// received a copy of the GNU Lesser General Public License along with +// gepetto-viewer-corba If not, see +// <http://www.gnu.org/licenses/>. + +#include <QObject> + +#include <gepetto/gui/plugin-interface.hh> + +class PyQGV : public QObject, public gepetto::gui::PluginInterface { + Q_OBJECT + Q_INTERFACES (gepetto::gui::PluginInterface) + + public: + QString name () const { return QString("PyQGV"); } + + void init(); +};