text_view_facing_marker.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include <OgreSceneNode.h>
31 #include <OgreSceneManager.h>
32 
33 #include <ros/assert.h>
34 
36 #include "rviz/display_context.h"
39 
41 
42 namespace rviz
43 {
44 
45 TextViewFacingMarker::TextViewFacingMarker(MarkerDisplay* owner, DisplayContext* context, Ogre::SceneNode* parent_node)
46 : MarkerBase(owner, context, parent_node)
47 , text_(0)
48 {
49 }
50 
52 {
53  delete text_;
54 }
55 
56 void TextViewFacingMarker::onNewMessage(const MarkerConstPtr& old_message, const MarkerConstPtr& new_message)
57 {
58  ROS_ASSERT(new_message->type == visualization_msgs::Marker::TEXT_VIEW_FACING);
59 
60  if (new_message->text.find_first_not_of(" \t\n\v\f\r") == std::string::npos)
61  return;
62 
63  if (!text_)
64  {
65  text_ = new MovableText(new_message->text);
67  scene_node_->attachObject(text_);
68 
69  handler_.reset( new MarkerSelectionHandler(this, MarkerID(new_message->ns, new_message->id ), context_ ));
70  handler_->addTrackedObject( text_ );
71  }
72 
73  Ogre::Vector3 pos, scale;
74  Ogre::Quaternion orient;
75  transform(new_message, pos, orient, scale);
76 
77  setPosition(pos);
78  text_->setCharacterHeight(new_message->scale.z);
79  text_->setColor(Ogre::ColourValue(new_message->color.r, new_message->color.g, new_message->color.b, new_message->color.a));
80  text_->setCaption(new_message->text);
81 }
82 
84 {
85  S_MaterialPtr materials;
86  if ( text_->getMaterial().get() )
87  {
88  materials.insert( text_->getMaterial() );
89  }
90  return materials;
91 }
92 
93 }
94 
Ogre::SceneNode * scene_node_
Definition: marker_base.h:104
bool transform(const MarkerConstPtr &message, Ogre::Vector3 &pos, Ogre::Quaternion &orient, Ogre::Vector3 &scale)
Definition: marker_base.cpp:88
virtual S_MaterialPtr getMaterials()
void setCharacterHeight(Ogre::Real height)
virtual void onNewMessage(const MarkerConstPtr &old_message, const MarkerConstPtr &new_message)
virtual void setPosition(const Ogre::Vector3 &position)
std::pair< std::string, int32_t > MarkerID
Pure-virtual base class for objects which give Display subclasses context in which to work...
boost::shared_ptr< MarkerSelectionHandler > handler_
Definition: marker_base.h:110
void setCaption(const Ogre::String &caption)
DisplayContext * context_
Definition: marker_base.h:102
void setTextAlignment(const HorizontalAlignment &horizontalAlignment, const VerticalAlignment &verticalAlignment)
visualization_msgs::Marker::ConstPtr MarkerConstPtr
Definition: marker_base.h:63
const Ogre::MaterialPtr & getMaterial(void) const
Definition: movable_text.h:173
void setColor(const Ogre::ColourValue &color)
TextViewFacingMarker(MarkerDisplay *owner, DisplayContext *context, Ogre::SceneNode *parent_node)
std::set< Ogre::MaterialPtr > S_MaterialPtr
Definition: marker_base.h:57
#define ROS_ASSERT(cond)
Displays "markers" sent in by other ROS nodes on the "visualization_marker" topic.


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Wed Aug 28 2019 04:01:51