00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "text_view_facing_marker.h"
00031
00032 #include "rviz/visualization_manager.h"
00033
00034 #include <ogre_tools/movable_text.h>
00035
00036 #include <OGRE/OgreSceneNode.h>
00037 #include <OGRE/OgreSceneManager.h>
00038
00039 namespace rviz
00040 {
00041
00042 TextViewFacingMarker::TextViewFacingMarker(MarkerDisplay* owner, VisualizationManager* manager, Ogre::SceneNode* parent_node)
00043 : MarkerBase(owner, manager, parent_node)
00044 , text_(0)
00045 {
00046 if (parent_node)
00047 {
00048 scene_node_ = parent_node->createChildSceneNode();
00049 }
00050 else
00051 {
00052 scene_node_ = vis_manager_->getSceneManager()->getRootSceneNode()->createChildSceneNode();
00053 }
00054 }
00055
00056 TextViewFacingMarker::~TextViewFacingMarker()
00057 {
00058 vis_manager_->getSceneManager()->destroySceneNode(scene_node_->getName());
00059 delete text_;
00060 }
00061
00062 void TextViewFacingMarker::onNewMessage(const MarkerConstPtr& old_message, const MarkerConstPtr& new_message)
00063 {
00064 ROS_ASSERT(new_message->type == visualization_msgs::Marker::TEXT_VIEW_FACING);
00065
00066 if (!text_)
00067 {
00068 text_ = new ogre_tools::MovableText(new_message->text);
00069 text_->setTextAlignment(ogre_tools::MovableText::H_CENTER, ogre_tools::MovableText::V_CENTER);
00070 scene_node_->attachObject(text_);
00071 }
00072
00073 Ogre::Vector3 pos, scale;
00074 Ogre::Quaternion orient;
00075 transform(new_message, pos, orient, scale);
00076
00077 scene_node_->setPosition(pos);
00078 text_->setCharacterHeight(new_message->scale.z);
00079 text_->setColor(Ogre::ColourValue(new_message->color.r, new_message->color.g, new_message->color.b, new_message->color.a));
00080 text_->setCaption(new_message->text);
00081 }
00082
00083 }
00084