2001-10-24 03:51:39 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* openscenegraph textLib / FTGL wrapper
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* prog: max rheiner;mrn@paus.ch
|
|
|
|
* date: 4/25/2001 (m/d/y)
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OSGTEXT_TEXT
|
|
|
|
#define OSGTEXT_TEXT 1
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <osg/GL>
|
|
|
|
#include <osg/Drawable>
|
|
|
|
#include <osg/Vec3>
|
|
|
|
#include <osg/Vec2>
|
|
|
|
|
|
|
|
// http://homepages.paradise.net.nz/henryj/code/
|
2001-10-31 20:27:48 +08:00
|
|
|
|
2001-11-09 23:06:01 +08:00
|
|
|
#include <osgText/Font>
|
2001-10-24 03:51:39 +08:00
|
|
|
|
|
|
|
namespace osgText {
|
|
|
|
|
2001-11-09 23:06:01 +08:00
|
|
|
class OSGTEXT_EXPORT Text : public osg::Drawable
|
2001-10-24 03:51:39 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum AlignmentType
|
|
|
|
{ // from left to right, top to bottom
|
|
|
|
LEFT_TOP,
|
|
|
|
LEFT_CENTER,
|
|
|
|
LEFT_BOTTOM,
|
|
|
|
|
|
|
|
CENTER_TOP,
|
|
|
|
CENTER_CENTER,
|
|
|
|
CENTER_BOTTOM,
|
|
|
|
|
|
|
|
RIGHT_TOP,
|
|
|
|
RIGHT_CENTER,
|
|
|
|
RIGHT_BOTTOM,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BoundingBoxType
|
|
|
|
{
|
|
|
|
GEOMETRY,
|
|
|
|
GLYPH,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DrawModeType
|
|
|
|
{ // from left to right, top to bottom
|
|
|
|
TEXT = 1<<0,
|
|
|
|
BOUNDINGBOX = 1<<1,
|
|
|
|
ALIGNEMENT = 1<<2,
|
|
|
|
DEFAULT = TEXT,
|
|
|
|
};
|
|
|
|
|
|
|
|
Text();
|
|
|
|
Text(Font* font);
|
|
|
|
|
|
|
|
META_Object(Text);
|
|
|
|
|
2001-11-03 04:11:37 +08:00
|
|
|
void setPosition(const osg::Vec2& pos);
|
|
|
|
void setPosition(const osg::Vec3& pos);
|
|
|
|
const osg::Vec3& getPosition() const { return _pos; }
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-03 04:11:37 +08:00
|
|
|
void setDrawMode(int mode) { _drawMode=mode; }
|
|
|
|
int getDrawMode() const { return _drawMode; }
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-03 04:11:37 +08:00
|
|
|
void setBoundingBox(int mode);
|
|
|
|
int getBoundingBox() const { return _boundingBoxType; }
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-09 23:06:01 +08:00
|
|
|
void setAlignment(int alignment);
|
|
|
|
int getAlignment() const { return _alignment; }
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-03 04:11:37 +08:00
|
|
|
void setFont(Font* font);
|
|
|
|
Font* getFont() { return _font.get(); }
|
|
|
|
const Font* getFont() const { return _font.get(); }
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-03 04:11:37 +08:00
|
|
|
void setText(const char* text) { _text=text; }
|
|
|
|
void setText(const std::string& text) { _text=text; }
|
|
|
|
const std::string& getText() const { return _text; }
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-03 04:11:37 +08:00
|
|
|
virtual void drawImmediateMode(osg::State& state);
|
|
|
|
virtual void drawBoundingBox(void);
|
2001-11-09 23:06:01 +08:00
|
|
|
virtual void drawAlignment(void);
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-09 23:06:01 +08:00
|
|
|
const osg::Vec3& getAlignmentPos() const { return _alignmentPos; };
|
2001-10-24 03:51:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
enum FontType
|
|
|
|
{
|
|
|
|
UNDEF,
|
|
|
|
BITMAP,
|
|
|
|
PIXMAP,
|
|
|
|
OUTLINE,
|
|
|
|
POLYGON,
|
|
|
|
TEXTURE,
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual ~Text();
|
|
|
|
|
|
|
|
virtual void setDefaults(void);
|
2001-11-03 04:11:37 +08:00
|
|
|
virtual const bool computeBound(void) const;
|
|
|
|
virtual void calcBounds(osg::Vec3* min,osg::Vec3* max) const;
|
2001-11-09 23:06:01 +08:00
|
|
|
void initAlignment(osg::Vec3* min,osg::Vec3* max);
|
|
|
|
bool initAlignment(void);
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-03 04:11:37 +08:00
|
|
|
osg::ref_ptr<Font> _font;
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-03 04:11:37 +08:00
|
|
|
bool _init;
|
2001-11-09 23:06:01 +08:00
|
|
|
bool _initAlignment;
|
2001-11-03 04:11:37 +08:00
|
|
|
std::string _text;
|
|
|
|
int _fontType;
|
2001-11-09 23:06:01 +08:00
|
|
|
int _alignment;
|
2001-11-03 04:11:37 +08:00
|
|
|
int _drawMode;
|
|
|
|
int _boundingBoxType;
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-03 04:11:37 +08:00
|
|
|
osg::Vec3 _pos;
|
2001-11-09 23:06:01 +08:00
|
|
|
osg::Vec3 _alignmentPos;
|
2001-10-24 03:51:39 +08:00
|
|
|
};
|
|
|
|
// Text
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2001-11-09 23:06:01 +08:00
|
|
|
#endif // OSGTEXT_TEXT
|