diff --git a/include/gepetto/gui/osgwidget.hh b/include/gepetto/gui/osgwidget.hh index 09769c1d00b2b599c7bffb5b21750ffa7fd10261..c213de15c9d7e6fad78e3ce924240594502070d9 100644 --- a/include/gepetto/gui/osgwidget.hh +++ b/include/gepetto/gui/osgwidget.hh @@ -58,7 +58,7 @@ namespace gepetto { WindowsManager::WindowID windowID () const; signals: - void selected (QString name); + void selected (QString name, QVector3D positionInWorldFrame); void requestMotion (graphics::NodePtr_t node, graphics::Node::Arrow direction, float speed); @@ -85,10 +85,8 @@ signals: virtual void paintEvent( QPaintEvent* paintEvent ); - private slots: - void transferSelected (QString name); - private: + void emitSelected (QString name, QVector3D positionInWorldFrame); osgGA::EventQueue* getEventQueue() const; osg::ref_ptr<osgQt::GraphicsWindowQt> graphicsWindow_; diff --git a/include/gepetto/gui/pick-handler.hh b/include/gepetto/gui/pick-handler.hh index 0bb88ced60b2a280a77b6f48fdacb9e3ecfc200a..fd281b2a3adaf9b6af9715dfe39d8913a3fca73b 100644 --- a/include/gepetto/gui/pick-handler.hh +++ b/include/gepetto/gui/pick-handler.hh @@ -16,7 +16,7 @@ namespace gepetto { Q_OBJECT public: - PickHandler (WindowsManagerPtr_t wsm); + PickHandler (OSGWidget* parent, WindowsManagerPtr_t wsm); virtual ~PickHandler(); @@ -31,9 +31,6 @@ namespace gepetto { void bodyTreeCurrentChanged (const QModelIndex ¤t, const QModelIndex &previous); - signals: - void selected (QString name); - private: std::list <graphics::NodePtr_t> computeIntersection (osgGA::GUIActionAdapter& aa, const float& x, const float& y); diff --git a/pyplugins/gepetto/gui/pythonwidget.py b/pyplugins/gepetto/gui/pythonwidget.py index 979cd2f55e64cce56cd28e2c453fb891872099d8..3356dbffdde155388f8fe14cdc0b4b7ff08ba540 100644 --- a/pyplugins/gepetto/gui/pythonwidget.py +++ b/pyplugins/gepetto/gui/pythonwidget.py @@ -85,7 +85,7 @@ class Plugin(QtGui.QDockWidget): ### If present, this function is called when a new OSG Widget is created. def osgWidget(self, osgWindow): - osgWindow.connect('selected(QString)', self.selected) + osgWindow.connect('selected(QString,QVector3D)', self.selected) def resetConnection(self): self.client = Client() @@ -93,5 +93,5 @@ class Plugin(QtGui.QDockWidget): def refresh(self): self.nodeCreator.update() - def selected(self, name): - QtGui.QMessageBox.information(self, "Selected object", name) + def selected(self, name, posInWorldFrame): + QtGui.QMessageBox.information(self, "Selected object", name + " " + str(posInWorldFrame)) diff --git a/src/gui/osgwidget.cc b/src/gui/osgwidget.cc index 5737ea4abae11ee7c182600de58def4b7cf369ea..63ff462f5d72a21f6604c7103544284171ba79f0 100644 --- a/src/gui/osgwidget.cc +++ b/src/gui/osgwidget.cc @@ -81,7 +81,7 @@ namespace gepetto { : QWidget( parent, f ) , graphicsWindow_() , wsm_ (wm) - , pickHandler_ (new PickHandler (wsm_)) + , pickHandler_ (new PickHandler (this, wsm_)) , wid_ (-1) , wm_ () , viewer_ (new osgViewer::Viewer) @@ -134,8 +134,6 @@ namespace gepetto { 1); viewer_->addEventHandler(screenCapture_); viewer_->addEventHandler(new osgViewer::HelpHandler); - - connect(pickHandler_, SIGNAL(selected(QString)), SLOT(transferSelected(QString))); viewer_->addEventHandler(pickHandler_); wid_ = wm->createWindow (name.c_str(), viewer_, graphicsWindow_.get()); @@ -155,8 +153,8 @@ namespace gepetto { render_.start (); parent->bodyTree()->connect(this, - SIGNAL (selected(QString)), SLOT (selectBodyByName(QString))); - parent->connect(this, SIGNAL (selected(QString)), + SIGNAL (selected(QString,QVector3D)), SLOT (selectBodyByName(QString))); + parent->connect(this, SIGNAL (selected(QString,QVector3D)), SLOT (requestSelectJointFromBodyName(QString))); } @@ -198,9 +196,9 @@ namespace gepetto { // wsm_->lock().unlock(); } - void gepetto::gui::OSGWidget::transferSelected(QString name) + void OSGWidget::emitSelected(QString name, QVector3D positionInWorldFrame) { - emit selected (name); + emit selected (name, positionInWorldFrame); } void OSGWidget::onHome() diff --git a/src/gui/pick-handler.cc b/src/gui/pick-handler.cc index 13e25f2fc12980ee9f933b83a2c323e6f59d3dc9..e66f082224b3b4b3994ee621caececcfd8fee685 100644 --- a/src/gui/pick-handler.cc +++ b/src/gui/pick-handler.cc @@ -20,8 +20,10 @@ namespace gepetto { namespace gui { - PickHandler::PickHandler(WindowsManagerPtr_t wsm) - : wsm_ (wsm) + PickHandler::PickHandler(OSGWidget *parent, WindowsManagerPtr_t wsm) + : QObject (parent) + , wsm_ (wsm) + , parent_ (parent) , last_ () , pushed_ (false) , lastX_ (0) @@ -130,7 +132,9 @@ namespace gepetto { if (boost::regex_match (n->getID(), boost::regex ("^.*_[0-9]+$"))) continue; select (n); - emit selected (QString::fromStdString(n->getID ())); + osg::Vec3d p = it->getWorldIntersectPoint(); + QVector3D pWF (p[0],p[1],p[2]); + parent_->emitSelected(QString::fromStdString(n->getID ()), pWF); return nodes; // nodes.push_back(n); // break;