All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MovableText.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: Middleman between OGRE and Gazebo
18  * Author: indepedentCreations@gmail.com
19  * Date: 13 Feb 2006
20  */
21 
22 #ifndef _MOVABLETEXT_HH_
23 #define _MOVABLETEXT_HH_
24 
25 #include <string>
26 
27 // TODO: remove this line
28 #include "rendering/ogre_gazebo.h"
29 
30 #include "common/CommonTypes.hh"
31 #include "common/Color.hh"
32 #include "math/MathTypes.hh"
33 
34 namespace boost
35 {
36  class recursive_mutex;
37 }
38 
39 namespace gazebo
40 {
41  namespace rendering
42  {
45 
48  class MovableText : public Ogre::MovableObject, public Ogre::Renderable
49  {
52  public: enum HorizAlign {
57  };
58 
61  public: enum VertAlign {
66  };
67 
69  public: MovableText();
70 
72  public: virtual ~MovableText();
73 
80  public: void Load(const std::string &_name,
81  const std::string &_text,
82  const std::string &_fontName = "Arial",
83  float _charHeight = 1.0,
84  const common::Color &_color = common::Color::White);
85 
88  public: void SetFontName(const std::string &_font);
89 
92  public: const std::string &GetFont() const;
93 
96  public: void SetText(const std::string &_text);
97 
100  public: const std::string &GetText() const;
101 
104  public: void SetColor(const common::Color &_color);
105 
108  public: const common::Color &GetColor() const;
109 
112  public: void SetCharHeight(float _height);
113 
116  public: float GetCharHeight() const;
117 
120  public:void SetSpaceWidth(float _width);
121 
124  public: float GetSpaceWidth() const;
125 
129  public: void SetTextAlignment(const HorizAlign &_hAlign,
130  const VertAlign &_vAlign);
131 
134  public: void SetBaseline(float _height);
135 
138  public: float GetBaseline() const;
139 
143  public: void SetShowOnTop(bool _show);
144 
147  public: bool GetShowOnTop() const;
148 
151  public: math::Box GetAABB();
152 
154  public: void Update();
155 
161  public: virtual void visitRenderables(Ogre::Renderable::Visitor* _visitor,
162  bool _debug = false);
163 
166  protected: void _setupGeometry();
167 
170  protected: void _updateColors();
171 
174  protected: void getWorldTransforms(Ogre::Matrix4 *xform) const;
175 
178  protected: float getBoundingRadius() const;
179 
182  protected: float getSquaredViewDepth(const Ogre::Camera *cam) const;
183 
185  private: const Ogre::Quaternion &getWorldOrientation(void) const;
187  private: const Ogre::Vector3 &getWorldPosition(void) const;
189  private: const Ogre::AxisAlignedBox &getBoundingBox(void) const;
191  private: const Ogre::String &getMovableType() const;
192 
194  private: void _notifyCurrentCamera(Ogre::Camera *cam);
195 
197  private: void _updateRenderQueue(Ogre::RenderQueue* queue);
198 
201  protected: void getRenderOperation(Ogre::RenderOperation &op);
202 
205  protected: const Ogre::MaterialPtr &getMaterial(void) const;
206 
209  protected: const Ogre::LightList &getLights(void) const;
210 
211  private: std::string fontName;
212  private: std::string text;
213 
214  private: common::Color color;
215  private: Ogre::RenderOperation renderOp;
216  private: Ogre::AxisAlignedBox *aabb;
217  private: Ogre::LightList lightList;
218 
219  private: float charHeight;
220 
221  private: bool needUpdate;
222 
223  private: float radius;
224 
225  private: Ogre::Camera *camera;
226  private: Ogre::RenderWindow *renderWindow;
227  private: Ogre::Font *font;
228  private: Ogre::MaterialPtr material;
229  private: Ogre::MaterialPtr backgroundMaterial;
230 
231  private: float viewportAspectCoef;
232  private: float spaceWidth;
233  private: bool updateColors;
234  private: VertAlign vertAlign;
235  private: HorizAlign horizAlign;
236  private: bool onTop;
237  private: float baseline;
238 
239  private: bool dirty;
240 
241  private: boost::recursive_mutex *mutex;
242  private: Ogre::SimpleRenderable *renderable;
243  };
245  }
246 }
247 #endif