0
$\begingroup$

Rosanswers logo

Hi,

I am currently developing a rviz plugin tool (myTool, inherited from rviz::Tool) and a rviz panel (myPanel, inherited from rviz::Panel). They come together, so I want to open myPanel as soon as myTool is added to the tool bar in rviz. But I couldn't find a way to do it.

I am able to achieve the reverse. i.e. when I add myPanel through menu option in rviz, myTool is automatically added into the tool bar in rviz. This is done by the following code in myPanel.cpp

vis_manager_->getToolManager()->addTool("myTool");

It would be nice if there is a similar way to open myPanel through code in myTool.cpp.

Or maybe there's a more elegant way to do this?

Thanks!


Originally posted by ms0719584 on ROS Answers with karma: 11 on 2016-07-29

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The vis_manager_ has the addPanelByName function, see:

https://github.com/ros-visualization/rviz/blob/115e9afe1b0a80e08cb7b2a7a3a97988e81bac94/src/rviz/visualization_frame.cpp#L1214-L1241

You'd have to figure out how to get the parameters, maybe look to the openNewPanelDialog function and the NewObjectDialog class for those:

https://github.com/ros-visualization/rviz/blob/115e9afe1b0a80e08cb7b2a7a3a97988e81bac94/src/rviz/visualization_frame.cpp#L572-L591

https://github.com/ros-visualization/rviz/blob/0d423d6249a39f7f3ddd591007952c6dc940b6ac/src/rviz/new_object_dialog.cpp#L52

Sorry I couldn't be more specific, but I've never tried to do what you've described. I hope you find a way that works for sure.


Originally posted by William with karma: 17335 on 2016-08-01

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by ms0719584 on 2016-08-02:
vis_manager_ doesn't have addPanelByName. This member function is in rviz::VisualizationFrame. But I could only get its parent class rviz::WindowManagerInterface through vis_manager->getWindowManager(). I couldn't find any function that returns rviz::VisualizationManager.

Comment by William on 2016-08-08:
Hmm, you're right, I got those two mixed up. It might not be possible as-is. I'm sorry I don't have time to work something out for you, but if you find a way to do it, or have an idea of how it could be better organized, please open an issue on rviz.

Comment by ms0719584 on 2016-08-08:
I find out I can get rviz::VisualizationFrame through casting: (rviz::VisualizationFrame*) vis_manager->getWindowManager(), but now the problem is addPanelByName is protected, so I cannot access it. There is a public function addPane, but it seems to create a empty panel,not an exiting one.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.