MovableText.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 #ifndef GAZEBO_RENDERING_MOVABLETEXT_HH_
18 #define GAZEBO_RENDERING_MOVABLETEXT_HH_
19 
20 #include <string>
21 
22 #include <ignition/math/Box.hh>
23 
24 // TODO: remove this line
26 
27 #include "gazebo/common/Color.hh"
28 #include "gazebo/util/system.hh"
29 
30 namespace boost
31 {
32  class recursive_mutex;
33 }
34 
35 namespace gazebo
36 {
37  namespace rendering
38  {
41 
44  class GZ_RENDERING_VISIBLE MovableText
45  : public Ogre::MovableObject, public Ogre::Renderable
46  {
49  public: enum HorizAlign {
53  H_CENTER
54  };
55 
58  public: enum VertAlign {
62  V_ABOVE
63  };
64 
66  public: MovableText();
67 
69  public: virtual ~MovableText();
70 
77  public: void Load(const std::string &_name,
78  const std::string &_text,
79  const std::string &_fontName = "Arial",
80  float _charHeight = 1.0,
81  const common::Color &_color = common::Color::White);
82 
85  public: void SetFontName(const std::string &_font);
86 
89  public: const std::string &GetFont() const;
90 
93  public: void SetText(const std::string &_text);
94 
97  public: const std::string &GetText() const;
98 
101  public: void SetColor(const common::Color &_color);
102 
105  public: const common::Color &GetColor() const;
106 
109  public: void SetCharHeight(float _height);
110 
113  public: float GetCharHeight() const;
114 
117  public:void SetSpaceWidth(float _width);
118 
121  public: float GetSpaceWidth() const;
122 
126  public: void SetTextAlignment(const HorizAlign &_hAlign,
127  const VertAlign &_vAlign);
128 
131  public: void SetBaseline(float _height);
132 
135  public: float GetBaseline() const;
136 
140  public: void SetShowOnTop(bool _show);
141 
144  public: bool GetShowOnTop() const;
145 
148  public: ignition::math::Box AABB();
149 
151  public: void Update();
152 
158  public: virtual void visitRenderables(Ogre::Renderable::Visitor* _visitor,
159  bool _debug = false);
160 
163  protected: void _setupGeometry();
164 
167  protected: void _updateColors();
168 
171  protected: void getWorldTransforms(Ogre::Matrix4 *xform) const;
172 
175  protected: float getBoundingRadius() const;
176 
179  protected: float getSquaredViewDepth(const Ogre::Camera *cam) const;
180 
182  private: const Ogre::Quaternion &getWorldOrientation(void) const;
184  private: const Ogre::Vector3 &getWorldPosition(void) const;
186  private: const Ogre::AxisAlignedBox &getBoundingBox(void) const;
188  private: const Ogre::String &getMovableType() const;
189 
191  private: void _notifyCurrentCamera(Ogre::Camera *cam);
192 
194  private: void _updateRenderQueue(Ogre::RenderQueue* queue);
195 
198  protected: void getRenderOperation(Ogre::RenderOperation &op);
199 
202  protected: const Ogre::MaterialPtr &getMaterial(void) const;
203 
206  protected: const Ogre::LightList &getLights(void) const;
207 
208  private: std::string fontName;
209  private: std::string text;
210 
211  private: common::Color color;
212  private: Ogre::RenderOperation renderOp;
213  private: Ogre::AxisAlignedBox *aabb;
214  private: Ogre::LightList lightList;
215 
216  private: float charHeight;
217 
218  private: bool needUpdate;
219 
220  private: float radius;
221 
222  private: Ogre::Camera *camera;
223  private: Ogre::RenderWindow *renderWindow;
224  private: Ogre::Font *font;
225  private: Ogre::MaterialPtr material;
226  private: Ogre::MaterialPtr backgroundMaterial;
227 
228  private: float viewportAspectCoef;
229  private: float spaceWidth;
230  private: bool updateColors;
231  private: VertAlign vertAlign;
232  private: HorizAlign horizAlign;
233  private: bool onTop;
234  private: float baseline;
235 
236  private: bool dirty;
237 
238  private: boost::recursive_mutex *mutex;
239  private: Ogre::SimpleRenderable *renderable;
240  };
242  }
243 }
244 #endif
VertAlign
vertical alignment
Definition: MovableText.hh:58
Movable text.
Definition: MovableText.hh:44
Definition: JointMaker.hh:44
Forward declarations for the common classes.
Definition: Animation.hh:33
Left alignment.
Definition: MovableText.hh:51
Align below.
Definition: MovableText.hh:60
Defines a color.
Definition: Color.hh:35
HorizAlign
Horizontal alignment.
Definition: MovableText.hh:49