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
This commit is contained in:
@@ -33,189 +33,207 @@ class FTFont;
|
||||
|
||||
namespace osgText {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Font - FontBaseClass
|
||||
/** META_Font macro define the standard clone, isSameKindAs,
|
||||
* className and getType methods.
|
||||
* Use when subclassing from Object to make it more convinient to define
|
||||
* the standard pure virtual methods which are required for all Object
|
||||
* subclasses.*/
|
||||
#define META_Font(name) \
|
||||
virtual osg::Object* cloneType() const { return new name(); } \
|
||||
virtual osg::Object* clone(const osg::Cloner& cloner) const { return new name (*this,cloner); } \
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
||||
virtual const char* className() const { return #name; } \
|
||||
|
||||
|
||||
|
||||
class OSGTEXT_EXPORT Font : public osg::Object
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
Font();
|
||||
Font();
|
||||
Font(const Font& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||
Object(font,cloner),
|
||||
_init(false),
|
||||
_created(false),
|
||||
_font(0L),
|
||||
_fontName(font._fontName),
|
||||
_pointSize(font._pointSize),
|
||||
_res(font._res),
|
||||
_textureSize(font._textureSize)
|
||||
{}
|
||||
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Font *>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Font"; }
|
||||
|
||||
bool open(const char* font);
|
||||
bool open(const std::string& font);
|
||||
|
||||
virtual bool create(osg::State& state,int pointSize, const unsigned int res = 72 );
|
||||
virtual bool create(osg::State& state);
|
||||
virtual void output(osg::State& state,const char* text);
|
||||
bool open(const char* font);
|
||||
bool open(const std::string& font);
|
||||
|
||||
virtual bool isOk(void) const { return _init; }
|
||||
virtual bool isCreated(void) const { return isOk() && _created; }
|
||||
virtual bool create(osg::State& state,int pointSize, const unsigned int res = 72 );
|
||||
virtual bool create(osg::State& state);
|
||||
virtual void output(osg::State& state,const char* text);
|
||||
|
||||
virtual float getWidth(const char* text) const;
|
||||
virtual int getHeight() const;
|
||||
virtual int getDescender() const;
|
||||
virtual int getAscender() const;
|
||||
virtual bool isOk(void) const { return _init; }
|
||||
virtual bool isCreated(void) const { return isOk() && _created; }
|
||||
|
||||
int getPointSize(void) const { return _pointSize; }
|
||||
int getTextureSize(void) const { return _textureSize; }
|
||||
const std::string& getFontName();
|
||||
virtual float getWidth(const char* text) const;
|
||||
virtual int getHeight() const;
|
||||
virtual int getDescender() const;
|
||||
virtual int getAscender() const;
|
||||
|
||||
FTFont* getFont(void) { return _font; }
|
||||
int getPointSize(void) const { return _pointSize; }
|
||||
int getTextureSize(void) const { return _textureSize; }
|
||||
const std::string& getFontName();
|
||||
|
||||
protected:
|
||||
FTFont* getFont(void) { return _font; }
|
||||
|
||||
virtual ~Font();
|
||||
protected:
|
||||
|
||||
virtual void clear();
|
||||
virtual ~Font();
|
||||
|
||||
virtual FTFont* createFontObj(void)=0;
|
||||
virtual void clear();
|
||||
|
||||
bool init(const std::string& font);
|
||||
virtual FTFont* createFontObj(void)=0;
|
||||
|
||||
bool _init;
|
||||
bool _created;
|
||||
bool init(const std::string& font);
|
||||
|
||||
FTFont* _font;
|
||||
std::string _fontName;
|
||||
int _pointSize;
|
||||
int _res;
|
||||
int _textureSize;
|
||||
bool _init;
|
||||
bool _created;
|
||||
|
||||
FTFont* _font;
|
||||
std::string _fontName;
|
||||
int _pointSize;
|
||||
int _res;
|
||||
int _textureSize;
|
||||
};
|
||||
// Font
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// RasterFont
|
||||
|
||||
class OSGTEXT_EXPORT RasterFont:public Font
|
||||
{
|
||||
public:
|
||||
RasterFont():Font(){;}
|
||||
RasterFont(const std::string& font):Font(){;}
|
||||
public:
|
||||
|
||||
protected:
|
||||
RasterFont():Font(){}
|
||||
RasterFont(const RasterFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||
Font(font,cloner) {}
|
||||
RasterFont(const std::string& font):Font() {}
|
||||
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RasterFont *>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "RasterFont"; }
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
// RasterFont
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// VectorFont
|
||||
|
||||
class OSGTEXT_EXPORT VectorFont:public Font
|
||||
{
|
||||
public:
|
||||
VectorFont():Font(){;}
|
||||
VectorFont(const std::string& font):Font(){;}
|
||||
public:
|
||||
VectorFont():Font(){}
|
||||
VectorFont(const VectorFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||
Font(font,cloner) {}
|
||||
VectorFont(const std::string& font):Font(){}
|
||||
|
||||
protected:
|
||||
double _precision;
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const VectorFont *>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "VectorFont"; }
|
||||
|
||||
protected:
|
||||
double _precision;
|
||||
};
|
||||
|
||||
// VectorFont
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// BitmapFont
|
||||
|
||||
class OSGTEXT_EXPORT BitmapFont:public RasterFont
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
|
||||
BitmapFont() {;}
|
||||
|
||||
BitmapFont(const std::string& font,
|
||||
int point_size);
|
||||
|
||||
META_Object(BitmapFont);
|
||||
BitmapFont() {}
|
||||
BitmapFont(const BitmapFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||
RasterFont(font,cloner) {}
|
||||
BitmapFont(const std::string& font,
|
||||
int point_size);
|
||||
|
||||
protected:
|
||||
META_Font(BitmapFont);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual FTFont* createFontObj(void);
|
||||
virtual FTFont* createFontObj(void);
|
||||
};
|
||||
|
||||
// BitmapFont
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PixmapFont
|
||||
class OSGTEXT_EXPORT PixmapFont:public RasterFont
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
PixmapFont() {;}
|
||||
|
||||
PixmapFont(const std::string& font,
|
||||
int point_size);
|
||||
|
||||
META_Object(PixmapFont);
|
||||
PixmapFont() {}
|
||||
PixmapFont(const PixmapFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||
RasterFont(font,cloner) {}
|
||||
|
||||
protected:
|
||||
PixmapFont(const std::string& font,
|
||||
int point_size);
|
||||
|
||||
virtual FTFont* createFontObj(void);
|
||||
META_Font(PixmapFont);
|
||||
|
||||
protected:
|
||||
|
||||
virtual FTFont* createFontObj(void);
|
||||
|
||||
};
|
||||
// PixmapFont
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TextureFont
|
||||
|
||||
class OSGTEXT_EXPORT TextureFont:public RasterFont
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
TextureFont() {;}
|
||||
|
||||
TextureFont(const std::string& font,
|
||||
int point_size);
|
||||
TextureFont() {}
|
||||
TextureFont(const TextureFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||
RasterFont(font,cloner) {}
|
||||
|
||||
TextureFont(const std::string& font,
|
||||
int point_size,
|
||||
int textureSize );
|
||||
|
||||
META_Object(TextureFont);
|
||||
TextureFont(const std::string& font,
|
||||
int point_size);
|
||||
|
||||
protected:
|
||||
TextureFont(const std::string& font,
|
||||
int point_size,
|
||||
int textureSize );
|
||||
|
||||
virtual FTFont* createFontObj(void);
|
||||
META_Font(TextureFont);
|
||||
|
||||
protected:
|
||||
|
||||
virtual FTFont* createFontObj(void);
|
||||
|
||||
};
|
||||
// PixmapFont
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// OutlineFont
|
||||
class OSGTEXT_EXPORT OutlineFont:public VectorFont
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
OutlineFont() {;}
|
||||
|
||||
OutlineFont(const std::string& font,
|
||||
int point_size,
|
||||
double precision);
|
||||
|
||||
META_Object(OutlineFont);
|
||||
OutlineFont() {}
|
||||
OutlineFont(const OutlineFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||
VectorFont(font,cloner) {}
|
||||
|
||||
protected:
|
||||
OutlineFont(const std::string& font,
|
||||
int point_size,
|
||||
double precision);
|
||||
|
||||
virtual FTFont* createFontObj(void);
|
||||
META_Font(OutlineFont);
|
||||
|
||||
protected:
|
||||
|
||||
virtual FTFont* createFontObj(void);
|
||||
|
||||
|
||||
};
|
||||
// OutlineFont
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PolygonFont
|
||||
class OSGTEXT_EXPORT PolygonFont:public VectorFont
|
||||
{
|
||||
public:
|
||||
|
||||
PolygonFont() {;}
|
||||
PolygonFont() {}
|
||||
PolygonFont(const PolygonFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||
VectorFont(font,cloner) {}
|
||||
|
||||
PolygonFont(const std::string& font,
|
||||
int point_size,
|
||||
@@ -225,15 +243,14 @@ public:
|
||||
int point_size,
|
||||
double precision);
|
||||
|
||||
META_Object(PolygonFont);
|
||||
META_Font(PolygonFont);
|
||||
|
||||
protected:
|
||||
|
||||
virtual FTFont* createFontObj(void);
|
||||
|
||||
};
|
||||
// PolygonFont
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user