00001 #ifndef QBUTILITY_H
00002 #define QBUTILITY_H
00003
00004 #include "QbIncludes.h"
00005
00006 class QbUtility {
00007
00008 public:
00009 enum Alignment { CENTER, TOPLEFT, TOP, TOPRIGHT, RIGHT, BOTTOMRIGHT, BOTTOM, BOTTOMLEFT, LEFT };
00010
00011 static float getScaleToBox(
00012 const SbBox3f & box,
00013 SoNode * child,
00014 SbVec3f border,
00015 const SbViewportRegion & viewportRegion);
00016
00017 static float getScaleToParent(
00018 SoNode * parent,
00019 SoNode * child,
00020 SbVec3f border,
00021 const SbViewportRegion & viewportRegion);
00022
00023 static SbVec3f getAlignToParent(
00024 SoNode *parent,
00025 SoNode *child,
00026 Alignment alignment,
00027 SbVec3f border,
00028 const SbViewportRegion & viewportRegion);
00029
00030 static SbVec3f getAlignToBox(
00031 const SbBox3f & box,
00032 SoNode *child,
00033 Alignment alignment,
00034 SbVec3f border,
00035 const SbViewportRegion & viewportRegion);
00036
00037 static SbVec3f getAlignToPoint(
00038 const SbBox3f & box,
00039 const SbVec3f & point,
00040 Alignment alignment,
00041 SbVec3f border);
00042
00043 static SbBool generateTextBitmap(
00044 const SoMFString * string,
00045 SoTexture2 *texture,
00046 short textureWidth,
00047 short textureHeight,
00048 const SbColor textColor = SbColor(0, 0, 0),
00049 const SbColor bgColor = SbColor(.5, .5, .5));
00050
00051 static SoNode * readModel(
00052 SoInput & input,
00053 const char * modelFile,
00054 const char * defaultModel[] = NULL,
00055 SbBool okIfNotFound = true);
00056
00057 private:
00058 QbUtility();
00059 }
00060 ;
00061
00062
00063
00064 #define QB_UTILITY_DEFINE_ENUM_VALUE(_enumname_, _enumval_) \
00065 do { \
00066 if (SO_NODE_IS_FIRST_INSTANCE()) \
00067 fieldData->addEnumValue(SO__QUOTE(QbUtility::_enumname_), \
00068 SO__QUOTE(_enumval_), QbUtility::_enumval_); \
00069 } while (0)
00070
00071 #define QB_UTILITY_ADD_ALIGNMENT_FIELD(_identifier_, _default_) \
00072 SO_NODE_ADD_FIELD(_identifier_, (QbUtility::_default_)); \
00073 QB_UTILITY_DEFINE_ENUM_VALUE(Alignment, CENTER); \
00074 QB_UTILITY_DEFINE_ENUM_VALUE(Alignment, TOPLEFT); \
00075 QB_UTILITY_DEFINE_ENUM_VALUE(Alignment, TOP); \
00076 QB_UTILITY_DEFINE_ENUM_VALUE(Alignment, TOPRIGHT); \
00077 QB_UTILITY_DEFINE_ENUM_VALUE(Alignment, RIGHT); \
00078 QB_UTILITY_DEFINE_ENUM_VALUE(Alignment, BOTTOMRIGHT); \
00079 QB_UTILITY_DEFINE_ENUM_VALUE(Alignment, BOTTOM); \
00080 QB_UTILITY_DEFINE_ENUM_VALUE(Alignment, BOTTOMLEFT); \
00081 QB_UTILITY_DEFINE_ENUM_VALUE(Alignment, LEFT); \
00082 SO_NODE_SET_SF_ENUM_TYPE(_identifier_, QbUtility::Alignment)
00083
00084 #endif