MovableText.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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
29 
31 #include "gazebo/common/Color.hh"
32 #include "gazebo/math/MathTypes.hh"
33 #include "gazebo/util/system.hh"
34 
35 namespace boost
36 {
37  class recursive_mutex;
38 }
39 
40 namespace gazebo
41 {
42  namespace rendering
43  {
46 
49  class GZ_RENDERING_VISIBLE MovableText
50  : public Ogre::MovableObject, public Ogre::Renderable
51  {
54  public: enum HorizAlign {
58  H_CENTER
59  };
60 
63  public: enum VertAlign {
67  V_ABOVE
68  };
69 
71  public: MovableText();
72 
74  public: virtual ~MovableText();
75 
82  public: void Load(const std::string &_name,
83  const std::string &_text,
84  const std::string &_fontName = "Arial",
85  float _charHeight = 1.0,
86  const common::Color &_color = common::Color::White);
87 
90  public: void SetFontName(const std::string &_font);
91 
94  public: const std::string &GetFont() const;
95 
98  public: void SetText(const std::string &_text);
99 
102  public: const std::string &GetText() const;
103 
106  public: void SetColor(const common::Color &_color);
107 
110  public: const common::Color &GetColor() const;
111 
114  public: void SetCharHeight(float _height);
115 
118  public: float GetCharHeight() const;
119 
122  public:void SetSpaceWidth(float _width);
123 
126  public: float GetSpaceWidth() const;
127 
131  public: void SetTextAlignment(const HorizAlign &_hAlign,
132  const VertAlign &_vAlign);
133 
136  public: void SetBaseline(float _height);
137 
140  public: float GetBaseline() const;
141 
145  public: void SetShowOnTop(bool _show);
146 
149  public: bool GetShowOnTop() const;
150 
153  public: math::Box GetAABB();
154 
156  public: void Update();
157 
163  public: virtual void visitRenderables(Ogre::Renderable::Visitor* _visitor,
164  bool _debug = false);
165 
168  protected: void _setupGeometry();
169 
172  protected: void _updateColors();
173 
176  protected: void getWorldTransforms(Ogre::Matrix4 *xform) const;
177 
180  protected: float getBoundingRadius() const;
181 
184  protected: float getSquaredViewDepth(const Ogre::Camera *cam) const;
185 
187  private: const Ogre::Quaternion &getWorldOrientation(void) const;
189  private: const Ogre::Vector3 &getWorldPosition(void) const;
191  private: const Ogre::AxisAlignedBox &getBoundingBox(void) const;
193  private: const Ogre::String &getMovableType() const;
194 
196  private: void _notifyCurrentCamera(Ogre::Camera *cam);
197 
199  private: void _updateRenderQueue(Ogre::RenderQueue* queue);
200 
203  protected: void getRenderOperation(Ogre::RenderOperation &op);
204 
207  protected: const Ogre::MaterialPtr &getMaterial(void) const;
208 
211  protected: const Ogre::LightList &getLights(void) const;
212 
213  private: std::string fontName;
214  private: std::string text;
215 
216  private: common::Color color;
217  private: Ogre::RenderOperation renderOp;
218  private: Ogre::AxisAlignedBox *aabb;
219  private: Ogre::LightList lightList;
220 
221  private: float charHeight;
222 
223  private: bool needUpdate;
224 
225  private: float radius;
226 
227  private: Ogre::Camera *camera;
228  private: Ogre::RenderWindow *renderWindow;
229  private: Ogre::Font *font;
230  private: Ogre::MaterialPtr material;
231  private: Ogre::MaterialPtr backgroundMaterial;
232 
233  private: float viewportAspectCoef;
234  private: float spaceWidth;
235  private: bool updateColors;
236  private: VertAlign vertAlign;
237  private: HorizAlign horizAlign;
238  private: bool onTop;
239  private: float baseline;
240 
241  private: bool dirty;
242 
243  private: boost::recursive_mutex *mutex;
244  private: Ogre::SimpleRenderable *renderable;
245  };
247  }
248 }
249 #endif
VertAlign
vertical alignment
Definition: MovableText.hh:63
static const Color White
(1, 1, 1)
Definition: Color.hh:39
Movable text.
Definition: MovableText.hh:49
Mathematical representation of a box and related functions.
Definition: Box.hh:35
Left alignment.
Definition: MovableText.hh:56
Align below.
Definition: MovableText.hh:65
Forward declarations for the math classes.
Defines a color.
Definition: Color.hh:36
HorizAlign
Horizontal alignment.
Definition: MovableText.hh:54