ros-visualization / visualization_tutorials

Tutorials related to using and extending RViz and interactive_markers.
262 stars 263 forks source link

How to have mouse interaction after setViewController? #36

Closed lucasw closed 7 years ago

lucasw commented 7 years ago

I've modified myviz.cpp here https://github.com/lucasw/visualization_tutorials/tree/set-view-controller-test and using a custom view controller appears to work as far as rendering the grid from a default location, but the mouse is unable to rotate or translate the view.

Is there something else I need to do to hook up the mouse? Is it still owned by the old default view controller somehow?

Also on answers: http://answers.ros.org/question/256100/rviz-setviewcontroller-doesnt-hook-up-mouse-events

lucasw commented 7 years ago

The solution is to use view manager setCurrentViewControllerType

  manager_ = new rviz::VisualizationManager( render_panel_ );
  render_panel_->initialize( manager_->getSceneManager(), manager_ );
  manager_->initialize();
  manager_->startUpdate();

  QString class_id = "rviz/Orbit";
  manager_->getViewManager()->setCurrentViewControllerType(class_id);
wjwwood commented 7 years ago

Glad to see you figured it out, and thanks for documenting what you did!