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

Make BodyTree accessible from python.

parent 31d35091
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -10,6 +10,7 @@ namespace gepetto {
class OSGWidget;
class PickHandler;
class BodyTreeWidget;
class BodyTreeItem;
class ViewerCorbaServer;
......
......@@ -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();
......
......@@ -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_;
......
......@@ -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
)
......@@ -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);
......
......@@ -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(
......
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