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 2011 Nate Koenig
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 
159  public: virtual void visitRenderables(Ogre::Renderable::Visitor* visitor,
160  bool debug = false);
161 
164  protected: void _setupGeometry();
165 
168  protected: void _updateColors();
169 
172  protected: void getWorldTransforms(Ogre::Matrix4 *xform) const;
173 
176  protected: float getBoundingRadius() const;
177 
180  protected: float getSquaredViewDepth(const Ogre::Camera *cam) const;
181 
183  private: const Ogre::Quaternion &getWorldOrientation(void) const;
185  private: const Ogre::Vector3 &getWorldPosition(void) const;
187  private: const Ogre::AxisAlignedBox &getBoundingBox(void) const;
189  private: const Ogre::String &getMovableType() const;
190 
192  private: void _notifyCurrentCamera(Ogre::Camera *cam);
193 
195  private: void _updateRenderQueue(Ogre::RenderQueue* queue);
196 
199  protected: void getRenderOperation(Ogre::RenderOperation &op);
200 
203  protected: const Ogre::MaterialPtr &getMaterial(void) const;
204 
207  protected: const Ogre::LightList &getLights(void) const;
208 
209  private: std::string fontName;
210  private: std::string text;
211 
212  private: common::Color color;
213  private: Ogre::RenderOperation renderOp;
214  private: Ogre::AxisAlignedBox *aabb;
215  private: Ogre::LightList lightList;
216 
217  private: float charHeight;
218 
219  private: bool needUpdate;
220 
221  private: float radius;
222 
223  private: Ogre::Camera *camera;
224  private: Ogre::RenderWindow *renderWindow;
225  private: Ogre::Font *font;
226  private: Ogre::MaterialPtr material;
227  private: Ogre::MaterialPtr backgroundMaterial;
228 
229  private: float viewportAspectCoef;
230  private: float spaceWidth;
231  private: bool updateColors;
232  private: VertAlign vertAlign;
233  private: HorizAlign horizAlign;
234  private: bool onTop;
235  private: float baseline;
236 
237  private: bool dirty;
238 
239  private: boost::recursive_mutex *mutex;
240  private: Ogre::SimpleRenderable *renderable;
241  };
243  }
244 }
245 #endif