diff --git a/include/gepetto/gui/bodytreewidget.hh b/include/gepetto/gui/bodytreewidget.hh index c76724a1899b704a9b94d83161cc6b3d26ddb00b..a3950781339091f0497020de109c2e0c576178bc 100644 --- a/include/gepetto/gui/bodytreewidget.hh +++ b/include/gepetto/gui/bodytreewidget.hh @@ -68,6 +68,9 @@ namespace gepetto { /// Reload the body tree. void reloadBodyTree (); + /// Get selected bodies + QList<BodyTreeItem*> selectedBodies() const; + protected slots: /// Display the context menu for one item. /// \param pos position of the item diff --git a/include/gepetto/gui/fwd.hh b/include/gepetto/gui/fwd.hh index 58c8da259119596dbb5f882401982fe6d6256ccf..c1de5ddeb8f1c173681b81810104472befc8fe52 100644 --- a/include/gepetto/gui/fwd.hh +++ b/include/gepetto/gui/fwd.hh @@ -10,6 +10,7 @@ namespace gepetto { class OSGWidget; class PickHandler; class BodyTreeWidget; + class BodyTreeItem; class ViewerCorbaServer; diff --git a/include/gepetto/gui/mainwindow.hh b/include/gepetto/gui/mainwindow.hh index 0839c59967a2294b67a4ce01216d86d7b69d4ee5..308af890a6a6382e4ead1a550a39e3b73eba408a 100644 --- a/include/gepetto/gui/mainwindow.hh +++ b/include/gepetto/gui/mainwindow.hh @@ -68,9 +68,6 @@ namespace gepetto { /// Get the list of windows. QList <OSGWidget*> osgWindows () const; - /// Get the body tree widget. - BodyTreeWidget* bodyTree () const; - /// Get the plugin manager. PluginManager* pluginManager (); @@ -98,6 +95,13 @@ signals: void selectJointFromBodyName(const QString bodyName); public slots: + /// \addtogroup available_in_python Python API + /// These slots are available for Python scripting in plugins + /// \{ + + /// Get the body tree widget. + BodyTreeWidget* bodyTree () const; + /// Add the text to logs. /// \param text text to log void log (const QString& text); @@ -151,6 +155,8 @@ signals: void connectSlot(const char *slot, const char *signal, QObject* obj); + /// \} + private slots: OSGWidget* onCreateView(QString name); OSGWidget* onCreateView(); diff --git a/include/gepetto/gui/tree-item.hh b/include/gepetto/gui/tree-item.hh index a61b6c0428cb7fb16c99df9a90749e14fab90482..b1457d2b3f83a1cff429503946768d99e18c0612 100644 --- a/include/gepetto/gui/tree-item.hh +++ b/include/gepetto/gui/tree-item.hh @@ -41,7 +41,7 @@ namespace gepetto { protected: void init (); - protected slots: + public slots: void setViewingMode (QString mode); void setVisibilityMode (QString mode); void removeFromGroup (); @@ -49,6 +49,7 @@ namespace gepetto { void removeAll (); void addLandmark (); void deleteLandmark (); + QString text () const { return QStandardItem::text(); } private: graphics::NodePtr_t node_; diff --git a/pyplugins/CMakeLists.txt b/pyplugins/CMakeLists.txt index d1404b0dd7652dad563ec29b9f15c2ad4eda1dfc..8cabd85c85819a0714a5ee314ae21668a37fa950 100644 --- a/pyplugins/CMakeLists.txt +++ b/pyplugins/CMakeLists.txt @@ -18,6 +18,7 @@ INSTALL( FILES ${CMAKE_CURRENT_SOURCE_DIR}/gepetto/gui/pythonwidget.py + ${CMAKE_CURRENT_SOURCE_DIR}/gepetto/gui/blenderexport.py ${CMAKE_CURRENT_SOURCE_DIR}/gepetto/gui/__init__.py DESTINATION ${PYTHON_SITELIB}/gepetto/gui ) diff --git a/src/gui/bodytreewidget.cc b/src/gui/bodytreewidget.cc index a44b850a3e245c63b4164071a04cc92d146de0a5..00208d719d306ba5dc88fe44f38b7ccef964327f 100644 --- a/src/gui/bodytreewidget.cc +++ b/src/gui/bodytreewidget.cc @@ -70,7 +70,7 @@ namespace gepetto { toolBox_ = toolBox; model_ = new QStandardItemModel (this); view_->setModel(model_); - view_->setSelectionMode(QAbstractItemView::SingleSelection); + view_->setSelectionMode(QAbstractItemView::ExtendedSelection); connect (main, SIGNAL(refresh()), SLOT(reloadBodyTree())); connect (view_, SIGNAL (customContextMenuRequested(QPoint)), SLOT(customContextMenu(QPoint))); @@ -132,6 +132,17 @@ namespace gepetto { model_->appendRow(new BodyTreeItem (this, group)); } + QList<BodyTreeItem*> BodyTreeWidget::selectedBodies() const + { + QList<BodyTreeItem*> list; + foreach (const QModelIndex& index, view_->selectionModel ()->selectedIndexes ()) { + BodyTreeItem *item = dynamic_cast <BodyTreeItem*> + (model_->itemFromIndex (index)); + if (item) list.push_back(item); + } + return list; + } + void BodyTreeWidget::customContextMenu(const QPoint &pos) { QModelIndex index = view_->indexAt(pos); diff --git a/src/gui/pythonwidget.cc b/src/gui/pythonwidget.cc index bd1b5f8a30eafde9e5e481e9085f8fb40eaa5f2d..8d885506408fb088ddf7774642f4f05ec34a44e5 100644 --- a/src/gui/pythonwidget.cc +++ b/src/gui/pythonwidget.cc @@ -37,6 +37,7 @@ namespace gepetto { PythonQtObjectPtr sys = PythonQt::self()->importModule ("sys"); sys.evalScript ("argv = ['gepetto-gui']"); console_ = new PythonQtScriptingConsole(NULL, mainContext_); + PythonQt::self()->registerQObjectClassNames(QStringList() << "BodyTreeWidget" << "BodyTreeItem"); mainContext_.addObject("mainWindow", MainWindow::instance()); console_->QTextEdit::clear(); console_->consoleMessage(