How to use a ROS rviz panel to draw in 3d Scene?

I'm working through the rviz tutorials and am trying to figure out how to use the example code "teleop_panel" to draw in the 3d scene. According to the tutorial this should be possible "A panel in RViz is a GUI widget which can be docked in the main window or floating. It does not show properties in the “Displays” panel like a Display, but it could show things in the 3D scene." But I can't figure out how to modify the source code to actually inject data into the 3d scene (like how the IMUDisplay plugin works).

My use case is that I would like to have a way to have some form of rich qt panel (with controls, indicators, etc) that can connect to other ROS topics and draw in the main 3d scene. I don't believe this is possible with the other options (such as a Display plugin) but I could be wrong.


When starting from the teleop_panel plugin tutorial, add the following members to the TeleopPanel class:

Ogre::SceneManager* scene_manager_;
Ogre::SceneNode* childScene;
rviz::MovableText* helloWorldText;

Next add the following code to the onInitialize() method:

scene_manager_ = vis_manager_->getSceneManager();
childScene = scene_manager_->getRootSceneNode()->createChildSceneNode();

helloWorldText = new rviz::MovableText("Hello World!");
childScene->attachObject(helloWorldText);
helloWorldText->setColor(Ogre::ColourValue::Red);
helloWorldText->setCharacterHeight(2);
helloWorldText->setVisible(true);

And finally to clean up add the following destructor:

TeleopPanel::~TeleopPanel() {
    // Destroy the child scene node since we don't need it anymore.
    scene_manager_->destroySceneNode(childScene);
}

Now when you load the panel you should see "Hello World!" at 0.0 in the 3D scene.