2003-01-22 00:45:36 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2002-07-17 04:07:32 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
2001-10-24 03:51:39 +08:00
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
|
|
|
*
|
2002-01-19 06:25:51 +08:00
|
|
|
* openscenegraph textLib / FTGL wrapper (http://homepages.paradise.net.nz/henryj/code/)
|
2001-10-24 03:51:39 +08:00
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* prog: max rheiner;mrn@paus.ch
|
|
|
|
* date: 4/25/2001 (m/d/y)
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OSGTEXT_TEXT
|
|
|
|
#define OSGTEXT_TEXT 1
|
|
|
|
|
|
|
|
#include <osg/Drawable>
|
2002-04-14 06:19:29 +08:00
|
|
|
#include <osg/GL>
|
2001-10-24 03:51:39 +08:00
|
|
|
#include <osg/Vec3>
|
|
|
|
#include <osg/Vec2>
|
|
|
|
|
2001-11-09 23:06:01 +08:00
|
|
|
#include <osgText/Font>
|
2003-01-08 23:22:17 +08:00
|
|
|
#include <osgText/EncodedText>
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2002-04-14 06:19:29 +08:00
|
|
|
#include <string>
|
|
|
|
|
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
|
|
|
{
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +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,
|
2002-06-25 05:44:27 +08:00
|
|
|
BOUNDINGBOX = 1<<1,
|
|
|
|
ALIGNMENT = 1<<2,
|
|
|
|
DEFAULT = TEXT,
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
};
|
2002-12-05 20:01:38 +08:00
|
|
|
|
|
|
|
enum AxisAlignment
|
|
|
|
{
|
|
|
|
XY_PLANE,
|
|
|
|
XZ_PLANE,
|
|
|
|
YZ_PLANE
|
|
|
|
};
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
|
|
|
Text();
|
2002-01-29 22:04:06 +08:00
|
|
|
Text(const Text& text,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
Text(Font* font);
|
|
|
|
|
|
|
|
virtual osg::Object* cloneType() const { return new Text(); }
|
2002-01-29 22:04:06 +08:00
|
|
|
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new Text(*this,copyop); }
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Text*>(obj)!=NULL; }
|
|
|
|
virtual const char* className() const { return "Text"; }
|
2002-06-12 02:41:57 +08:00
|
|
|
virtual const char* libraryName() const { return "osgText"; }
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
|
|
|
void setPosition(const osg::Vec2& pos);
|
|
|
|
void setPosition(const osg::Vec3& pos);
|
|
|
|
const osg::Vec3& getPosition() const { return _pos; }
|
|
|
|
|
2002-05-28 22:33:13 +08:00
|
|
|
|
|
|
|
void setColor(const osg::Vec4& color) { _color = color; }
|
|
|
|
osg::Vec4& getColor() { return _color; }
|
|
|
|
const osg::Vec4& getColor() const { return _color; }
|
|
|
|
|
|
|
|
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
void setDrawMode(int mode) { _drawMode=mode; }
|
|
|
|
int getDrawMode() const { return _drawMode; }
|
|
|
|
|
|
|
|
void setBoundingBox(int mode);
|
|
|
|
int getBoundingBox() const { return _boundingBoxType; }
|
|
|
|
|
|
|
|
void setAlignment(int alignment);
|
|
|
|
int getAlignment() const { return _alignment; }
|
2002-12-05 20:01:38 +08:00
|
|
|
|
|
|
|
void setAxisAlignment(AxisAlignment axis) { _axisAlignment = axis; dirtyDisplayList(); }
|
|
|
|
AxisAlignment getAxisAlignment() const { return _axisAlignment; }
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
|
|
|
void setFont(Font* font);
|
|
|
|
Font* getFont() { return _font.get(); }
|
|
|
|
const Font* getFont() const { return _font.get(); }
|
|
|
|
|
2003-01-08 23:22:17 +08:00
|
|
|
void setText(const char* text);
|
|
|
|
void setText(const std::string& text);
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
const std::string& getText() const { return _text; }
|
|
|
|
|
2002-12-07 03:03:34 +08:00
|
|
|
virtual bool supports(PrimitiveFunctor& pf) const;
|
|
|
|
virtual void accept(PrimitiveFunctor& pf) const;
|
|
|
|
|
2002-11-06 23:43:11 +08:00
|
|
|
virtual void drawImplementation(osg::State& state) const;
|
|
|
|
virtual void drawBoundingBox(void) const;
|
|
|
|
virtual void drawAlignment(void) const;
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
|
|
|
const osg::Vec3& getAlignmentPos() const { return _alignmentPos; };
|
|
|
|
|
2003-01-17 23:01:27 +08:00
|
|
|
void setEncodedText(EncodedText* encodedText) { _encodedText = encodedText; }
|
|
|
|
const EncodedText* getEncodedText() const { return _encodedText.get(); }
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2003-01-21 04:28:28 +08:00
|
|
|
/// override the compile to set up the alignment etc.
|
|
|
|
virtual void compile(osg::State& state) const;
|
|
|
|
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
enum FontType
|
|
|
|
{
|
|
|
|
UNDEF,
|
|
|
|
BITMAP,
|
|
|
|
PIXMAP,
|
|
|
|
OUTLINE,
|
|
|
|
POLYGON,
|
|
|
|
TEXTURE,
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual ~Text();
|
|
|
|
|
|
|
|
virtual void setDefaults(void);
|
2002-09-02 20:31:35 +08:00
|
|
|
virtual bool computeBound(void) const;
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
virtual void calcBounds(osg::Vec3* min,osg::Vec3* max) const;
|
|
|
|
void initAlignment(osg::Vec3* min,osg::Vec3* max);
|
|
|
|
bool initAlignment(void);
|
|
|
|
|
|
|
|
osg::ref_ptr<Font> _font;
|
|
|
|
|
|
|
|
bool _init;
|
|
|
|
bool _initAlignment;
|
|
|
|
std::string _text;
|
|
|
|
int _fontType;
|
|
|
|
int _alignment;
|
|
|
|
int _drawMode;
|
|
|
|
int _boundingBoxType;
|
2002-12-05 20:01:38 +08:00
|
|
|
AxisAlignment _axisAlignment;
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2003-01-17 23:01:27 +08:00
|
|
|
osg::ref_ptr<EncodedText> _encodedText;
|
2003-01-08 23:22:17 +08:00
|
|
|
|
2002-05-28 22:33:13 +08:00
|
|
|
osg::Vec3 _pos;
|
|
|
|
osg::Vec3 _alignmentPos;
|
|
|
|
osg::Vec4 _color;
|
2001-10-24 03:51:39 +08:00
|
|
|
};
|
|
|
|
|
2002-02-03 20:33:41 +08:00
|
|
|
}
|
2001-10-24 03:51:39 +08:00
|
|
|
|
2001-11-09 23:06:01 +08:00
|
|
|
#endif // OSGTEXT_TEXT
|