Changeset 13041 for OpenSceneGraph/trunk/include/osgText/TextBase
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgText/TextBase (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgText/TextBase
r12139 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 67 67 68 68 /** Set the Font reference width and height resolution in texels. 69 * Note, the size may not be supported by current font, 69 * Note, the size may not be supported by current font, 70 70 * the closest supported font size will be selected.*/ 71 71 void setFontResolution(unsigned int width, unsigned int height); … … 73 73 unsigned int getFontWidth() const { return _fontSize.first; } 74 74 unsigned int getFontHeight() const { return _fontSize.second; } 75 76 75 76 77 77 /** Set the text using a osgText::String.*/ 78 78 void setText(const String& text); 79 79 80 /** Set the text using a std::string, 80 /** Set the text using a std::string, 81 81 * which is converted to an internal TextString.*/ 82 82 void setText(const std::string& text); … … 86 86 void setText(const std::string& text,String::Encoding encoding); 87 87 88 /** Set the text using a wchar_t string, 88 /** Set the text using a wchar_t string, 89 89 * which is converted to an internal TextString.*/ 90 90 void setText(const wchar_t* text); 91 92 /** Get the text string. 91 92 /** Get the text string. 93 93 * Note, if you modify the string you must call Text::update() for 94 94 * the internal glyph reprentation to be updated.*/ … … 97 97 /** Get the const text string.*/ 98 98 const String& getText() const { return _text; } 99 100 /** update internal glyph respresentation used for rendering, 99 100 /** update internal glyph respresentation used for rendering, 101 101 * and bounding volume.*/ 102 102 void update() { computeGlyphRepresentation(); } … … 121 121 /** Set how the CharacterSize value relates to the final rendered character.*/ 122 122 void setCharacterSizeMode(CharacterSizeMode mode) { _characterSizeMode = mode; } 123 123 124 124 /** Get the CharacterSizeMode.*/ 125 125 CharacterSizeMode getCharacterSizeMode() const { return _characterSizeMode; } … … 128 128 /** Set the maximum width of the text box. 129 129 * With horizontal layouts any characters which do not fit are wrapped around. 130 * 0 or negative values indicate that no maximum width is set, lines can be as long as 130 * 0 or negative values indicate that no maximum width is set, lines can be as long as 131 131 * they need be to fit thre required text*/ 132 132 void setMaximumWidth(float maximumWidth); 133 133 134 134 /** Get the maximim width of the text box.*/ 135 135 float getMaximumWidth() const { return _maximumWidth; } … … 137 137 /** Set the maximum height of the text box. 138 138 * With horizontal layouts any characters which do not fit are wrapped around. 139 * 0 or negative values indicate that no maximum height is set, lines can be as long as 139 * 0 or negative values indicate that no maximum height is set, lines can be as long as 140 140 * they need be to fit the required text*/ 141 141 void setMaximumHeight(float maximumHeight); 142 142 143 143 /** Get the maximum height of the text box.*/ 144 144 float getMaximumHeight() const { return _maximumHeight; } 145 145 146 146 /** Set the line spacing of the text box, given as a percentage of 147 * the character height. The default value is 0 for backward 148 * compatibility. For longer paragraphs of text, a value of at 147 * the character height. The default value is 0 for backward 148 * compatibility. For longer paragraphs of text, a value of at 149 149 * least 25% (i.e. set line spacing to 0.25) is recommended. */ 150 150 void setLineSpacing(float lineSpacing); … … 157 157 /** Set the position of text.*/ 158 158 void setPosition(const osg::Vec3& pos); 159 159 160 160 /** Get the position of text.*/ 161 161 const osg::Vec3& getPosition() const { return _position; } 162 162 163 163 164 164 enum AlignmentType … … 175 175 RIGHT_CENTER, 176 176 RIGHT_BOTTOM, 177 177 178 178 LEFT_BASE_LINE, 179 179 CENTER_BASE_LINE, 180 180 RIGHT_BASE_LINE, 181 181 182 182 LEFT_BOTTOM_BASE_LINE, 183 183 CENTER_BOTTOM_BASE_LINE, 184 184 RIGHT_BOTTOM_BASE_LINE, 185 185 186 186 BASE_LINE = LEFT_BASE_LINE /// default. 187 188 }; 189 187 188 }; 189 190 190 void setAlignment(AlignmentType alignment); 191 191 AlignmentType getAlignment() const { return _alignment; } … … 206 206 void setAxisAlignment(AxisAlignment axis); 207 207 AxisAlignment getAxisAlignment() const { return _axisAlignment; } 208 208 209 209 void setRotation(const osg::Quat& quat); 210 210 const osg::Quat& getRotation() const { return _rotation; } … … 219 219 VERTICAL 220 220 }; 221 221 222 222 void setLayout(Layout layout); 223 223 224 224 Layout getLayout() const { return _layout; } 225 225 … … 234 234 235 235 void setDrawMode(unsigned int mode); 236 236 237 237 unsigned int getDrawMode() const { return _drawMode; } 238 238 239 239 void setBoundingBoxMargin(float margin); 240 240 241 241 float getBoundingBoxMargin() const { return _textBBMargin; } 242 242 243 243 void setBoundingBoxColor(const osg::Vec4& color){ _textBBColor = color; } 244 244 245 245 const osg::Vec4& getBoundingBoxColor() const { return _textBBColor; } 246 246 247 247 248 248 void setKerningType(KerningType kerningType) { _kerningType = kerningType; } 249 249 … … 264 264 virtual void releaseGLObjects(osg::State* state=0) const; 265 265 266 266 267 267 virtual osg::BoundingBox computeBound() const; 268 268 … … 278 278 virtual void computePositions(unsigned int contextID) const = 0; 279 279 virtual void computeGlyphRepresentation() = 0; 280 281 280 281 282 282 // members which have public access. 283 283 osg::Vec4 _color; … … 304 304 unsigned int _lineCount; 305 305 306 306 307 307 308 308 // internal caches of the positioning of the text. 309 309 310 310 struct AutoTransformCache 311 { 311 { 312 312 AutoTransformCache(): 313 313 _traversalNumber(-1), 314 314 _width(0), 315 315 _height(0) {} 316 316 317 317 int _traversalNumber; 318 318 int _width; … … 323 323 osg::Matrix _matrix; 324 324 }; 325 325 326 326 mutable osg::buffered_object<AutoTransformCache> _autoTransformCache; 327 327 mutable osg::Vec3 _offset; … … 334 334 335 335 #endif 336 336
