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/math/Box.hh"
29 #include "gazebo/util/system.hh"
30 
31 namespace boost
32 {
33  class recursive_mutex;
34 }
35 
36 namespace gazebo
37 {
38  namespace rendering
39  {
42 
45  class GZ_RENDERING_VISIBLE MovableText
46  : public Ogre::MovableObject, public Ogre::Renderable
47  {
50  public: enum HorizAlign {
54  H_CENTER
55  };
56 
59  public: enum VertAlign {
63  V_ABOVE
64  };
65 
67  public: MovableText();
68 
70  public: virtual ~MovableText();
71 
78  public: void Load(const std::string &_name,
79  const std::string &_text,
80  const std::string &_fontName = "Arial",
81  float _charHeight = 1.0,
82  const common::Color &_color = common::Color::White);
83 
86  public: void SetFontName(const std::string &_font);
87 
90  public: const std::string &GetFont() const;
91 
94  public: void SetText(const std::string &_text);
95 
98  public: const std::string &GetText() const;
99 
102  public: void SetColor(const common::Color &_color);
103 
106  public: const common::Color &GetColor() const;
107 
110  public: void SetCharHeight(float _height);
111 
114  public: float GetCharHeight() const;
115 
118  public:void SetSpaceWidth(float _width);
119 
122  public: float GetSpaceWidth() const;
123 
127  public: void SetTextAlignment(const HorizAlign &_hAlign,
128  const VertAlign &_vAlign);
129 
132  public: void SetBaseline(float _height);
133 
136  public: float GetBaseline() const;
137 
141  public: void SetShowOnTop(bool _show);
142 
145  public: bool GetShowOnTop() const;
146 
150  public: math::Box GetAABB() GAZEBO_DEPRECATED(8.0);
151 
155  public: ignition::math::Box AABB();
156 
158  public: void Update();
159 
165  public: virtual void visitRenderables(Ogre::Renderable::Visitor* _visitor,
166  bool _debug = false);
167 
170  protected: void _setupGeometry();
171 
174  protected: void _updateColors();
175 
178  protected: void getWorldTransforms(Ogre::Matrix4 *xform) const;
179 
182  protected: float getBoundingRadius() const;
183 
186  protected: float getSquaredViewDepth(const Ogre::Camera *cam) const;
187 
189  private: const Ogre::Quaternion &getWorldOrientation(void) const;
191  private: const Ogre::Vector3 &getWorldPosition(void) const;
193  private: const Ogre::AxisAlignedBox &getBoundingBox(void) const;
195  private: const Ogre::String &getMovableType() const;
196 
198  private: void _notifyCurrentCamera(Ogre::Camera *cam);
199 
201  private: void _updateRenderQueue(Ogre::RenderQueue* queue);
202 
205  protected: void getRenderOperation(Ogre::RenderOperation &op);
206 
209  protected: const Ogre::MaterialPtr &getMaterial(void) const;
210 
213  protected: const Ogre::LightList &getLights(void) const;
214 
215  private: std::string fontName;
216  private: std::string text;
217 
218  private: common::Color color;
219  private: Ogre::RenderOperation renderOp;
220  private: Ogre::AxisAlignedBox *aabb;
221  private: Ogre::LightList lightList;
222 
223  private: float charHeight;
224 
225  private: bool needUpdate;
226 
227  private: float radius;
228 
229  private: Ogre::Camera *camera;
230  private: Ogre::RenderWindow *renderWindow;
231  private: Ogre::Font *font;
232  private: Ogre::MaterialPtr material;
233  private: Ogre::MaterialPtr backgroundMaterial;
234 
235  private: float viewportAspectCoef;
236  private: float spaceWidth;
237  private: bool updateColors;
238  private: VertAlign vertAlign;
239  private: HorizAlign horizAlign;
240  private: bool onTop;
241  private: float baseline;
242 
243  private: bool dirty;
244 
245  private: boost::recursive_mutex *mutex;
246  private: Ogre::SimpleRenderable *renderable;
247  };
249  }
250 }
251 #endif
Basic camera sensor.
Definition: Camera.hh:85
VertAlign
vertical alignment
Definition: MovableText.hh:59
Movable text.
Definition: MovableText.hh:45
Definition: JointMaker.hh:44
Forward declarations for the common classes.
Definition: Animation.hh:33
Mathematical representation of a box and related functions.
Definition: Box.hh:41
STL namespace.
Left alignment.
Definition: MovableText.hh:52
Align below.
Definition: MovableText.hh:61
Definition: JointMaker.hh:39
Defines a color.
Definition: Color.hh:36
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
HorizAlign
Horizontal alignment.
Definition: MovableText.hh:50
Definition: Animation.hh:24