billboard_text.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #include <rve_render_client/scene.h>
00031 #include <rve_render_client/client_context.h>
00032 #include <rve_msgs/make_vector3.h>
00033 #include <rve_interfaces/BillboardText.h>
00034 
00035 #include <boost/bind.hpp>
00036 
00037 #include "rve_render_client/billboard_text.h"
00038 
00039 namespace rve_render_client
00040 {
00041 
00042 BillboardTextPtr createBillboardText(const std::string& text)
00043 {
00044   BillboardTextPtr bbtext(new BillboardText(), destroySceneObject);
00045   bbtext->setText(text);
00046   return bbtext;
00047 }
00048 
00049 BillboardTextPtr createBillboardText(Scene* scene, const std::string& text)
00050 {
00051   BillboardTextPtr bbtext = createBillboardText( text );
00052   scene->addObject( bbtext.get() );
00053   return bbtext;
00054 }
00055 
00056 BillboardText::BillboardText()
00057 {
00058   proxy_index_ = addProxy("billboard_text");
00059   // Set alignment defaults to match server side defaults.
00060   alignment_.horizontal = rve_msgs::TextAlignment::H_LEFT;
00061   alignment_.vertical = rve_msgs::TextAlignment::V_TOP;
00062 }
00063 
00064 BillboardText::~BillboardText()
00065 {
00066 }
00067 
00068 rve_interfaces::BillboardTextProxy* BillboardText::getProxy(const ContextInfo& context)
00069 {
00070   return SceneObject::getProxy<rve_interfaces::BillboardTextProxy>(context, proxy_index_);
00071 }
00072 
00073 void BillboardText::doCreate(ContextInfo& context)
00074 {
00075   rve_interfaces::BillboardTextProxy* proxy = getProxy(context);
00076   proxy->create(getSceneID(context.scene), getID());
00077 
00078   rve_common::UUID scene_id = getSceneID(context.scene);
00079   proxy->setTextAsync(scene_id, getID(), text_);
00080   proxy->setPositionAsync(scene_id, getID(), position_);
00081   proxy->setCharacterHeightAsync(scene_id, getID(), character_height_);
00082   proxy->setColorAsync(scene_id, getID(), color_);
00083   proxy->setAlignmentAsync(scene_id, getID(), alignment_);
00084 }
00085 
00086 void BillboardText::doDestroy(ContextInfo& context)
00087 {
00088   rve_interfaces::BillboardTextProxy* proxy = getProxy(context);
00089   proxy->destroyAsync(getSceneID(context.scene), getID());
00090 }
00091 
00092 void BillboardText::getContextDependencies(V_UUID& deps)
00093 {
00094 }
00095 
00096 #define BILLBOARD_TEXT_MULTIPLEX(func, ...) \
00097     multiplex<rve_interfaces::BillboardTextProxy>(boost::bind(&rve_interfaces::BillboardTextProxy::func, _1, _2, getID(), __VA_ARGS__), proxy_index_);
00098 
00099 void BillboardText::setPosition(const rve_msgs::Vector3& pos)
00100 {
00101   position_ = pos;
00102   BILLBOARD_TEXT_MULTIPLEX(setPositionAsync, pos);
00103 }
00104 
00105 void BillboardText::setText(const std::string& text)
00106 {
00107   text_ = text;
00108   BILLBOARD_TEXT_MULTIPLEX(setTextAsync, text);
00109 }
00110 
00113 void BillboardText::setCharacterHeight( float height )
00114 {
00115   character_height_ = height;
00116   BILLBOARD_TEXT_MULTIPLEX(setCharacterHeightAsync, height);
00117 }
00118 
00123 void BillboardText::setHorizontalAlignment( uint8_t h )
00124 {
00125   alignment_.horizontal = h;
00126   BILLBOARD_TEXT_MULTIPLEX(setAlignmentAsync, alignment_);
00127 }
00128 
00133 void BillboardText::setVerticalAlignment( uint8_t v )
00134 {
00135   alignment_.vertical = v;
00136   BILLBOARD_TEXT_MULTIPLEX(setAlignmentAsync, alignment_);
00137 }
00138 
00141 void BillboardText::setColor(const rve_msgs::ColorRGB& color)
00142 {
00143   color_ = color;
00144   BILLBOARD_TEXT_MULTIPLEX(setColorAsync, color);
00145 }
00146 
00147 }


rve_render_client
Author(s): Josh Faust
autogenerated on Wed Dec 11 2013 14:31:32