vtkTextureText.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __vtkTextureText_h
00026 #define __vtkTextureText_h
00027
00028 #include "vtkObject.h"
00029 #include "vtkFreetypeRasterizer.h"
00030 #include "vtkTextureFont.h"
00031 #include <vtkQueryAtlasConfigure.h>
00032 #include <vtkFollower.h>
00033
00034 #include "vtkTextureTextPolys.h"
00035 #include "vtkFontParameters.h"
00036
00037 #include <vector>
00038 #include <vector>
00039
00040
00041 class vtkRenderer;
00042
00043
00044
00045 #define VTK_TEXT_ALIGNMENT_FLUSH_LEFT (0)
00046 #define VTK_TEXT_ALIGNMENT_FLUSH_RIGHT (1)
00047 #define VTK_TEXT_ALIGNMENT_JUSTIFIED (2)
00048 #define VTK_TEXT_ALIGNMENT_CENTERED (3)
00049 #define VTK_TEXT_ALIGNMENT_MONOSPACE (4)
00050
00051 #define VTK_TEXT_NLCHAR 'n'
00052 #define VTK_TEXT_SPACECHAR 'i'
00053
00054 #define VTK_TEXT_BOTTOM_LEFT (0)
00055 #define VTK_TEXT_BOTTOM_RIGHT (1)
00056 #define VTK_TEXT_TOP_RIGHT (2)
00057 #define VTK_TEXT_TOP_LEFT (3)
00058
00059
00060
00061
00062 class characterPosition
00063 {
00064 public:
00065 characterPosition(unsigned char c);
00066 ~characterPosition() {};
00067
00068
00069 Vector3D<vtkFloatingPointType> mbox_pos;
00070 char character;
00071 };
00072
00073
00074
00075 class VTK_QUERYATLAS_EXPORT vtkTextureText : public vtkObject
00076 {
00077 public:
00078 void PrintSelf(ostream& os, vtkIndent indent);
00079 vtkTypeRevisionMacro(vtkTextureText,vtkObject);
00080
00081 static vtkTextureText *New();
00082
00083 int CreateTextureText();
00084
00085 int mCharCount;
00086
00087
00088 Vector3D<vtkFloatingPointType> *mCharGsetCoords;
00089 Vector2D<vtkFloatingPointType> *mTexCoords;
00090
00091 vtkFloatingPointType* (*baselineFunc) (vtkFloatingPointType *vec, void *args);
00092 void *baselineArgs;
00093
00094 std::vector<characterPosition *>mCharacterPositions;
00095
00096
00097 void buildQuads();
00098 void UpdateTexture();
00099
00100 vtkGetObjectMacro(Texture, vtkTexture);
00101 vtkGetObjectMacro(Follower, vtkFollower);
00102
00103 vtkGetObjectMacro(TextureTextPolys, vtkTextureTextPolys);
00104
00105 vtkTextureTextPolys *GetPolyDataSource();
00106
00107 vtkGetObjectMacro(TextureFont, vtkTextureFont);
00108 vtkSetObjectMacro(TextureFont, vtkTextureFont);
00109
00110 vtkGetObjectMacro(FontParameters, vtkFontParameters);
00111
00112 vtkGetStringMacro(CharacterArray);
00113
00114
00115
00116
00117
00118 vtkGetMacro(BoxWidth, vtkFloatingPointType);
00119 vtkSetMacro(BoxWidth, vtkFloatingPointType);
00120 vtkGetMacro(BoxHeight, vtkFloatingPointType);
00121 vtkSetMacro(BoxHeight, vtkFloatingPointType);
00122
00123 void SetBoxSize(vtkFloatingPointType w, vtkFloatingPointType h);
00124
00125 void SetWrapped(bool wrpd);
00126
00127 vtkGetMacro(Wrapped, bool);
00128
00129 void WrappedOn();
00130 void WrappedOff();
00131
00132 vtkGetMacro(Leading, vtkFloatingPointType);
00133 vtkSetMacro(Leading, vtkFloatingPointType);
00134
00135 vtkGetMacro(Indent, vtkFloatingPointType);
00136 vtkSetMacro(Indent, vtkFloatingPointType);
00137
00138 vtkGetMacro(CharacterSpace, vtkFloatingPointType);
00139 vtkSetMacro(CharacterSpace, vtkFloatingPointType);
00140
00141 vtkGetMacro(Alignment, short);
00142 vtkSetMacro(Alignment, short);
00143
00144
00145 void SetText(char *string);
00146 vtkGetStringMacro(Text);
00147
00148 void SetDefaultAlignment(short alignment);
00149 short GetDefaultAlignment();
00150
00151 vtkGetMacro(Initialized, int);
00152 vtkGetMacro(Error, int);
00153
00154
00155 void SetBaselineFunction(vtkFloatingPointType* (*f) (vtkFloatingPointType *vec, void *args), void *args);
00156 void UpdateBaseline();
00157 void ApplyBaselineFunction();
00158
00159 void CalculateRangeBox(Vector3D<vtkFloatingPointType> *min, Vector3D<vtkFloatingPointType> *max, int start, int end);
00160
00161
00162
00163
00164
00165 static vtkFloatingPointType GetAdvanceWidth(char *string, char *fontname, bool space);
00166 int CalculateNumberLines();
00167
00168 void AddPositionOffset(vtkFloatingPointType pos[3]);
00169 void AddPositionOffset(vtkFloatingPointType x, vtkFloatingPointType y, vtkFloatingPointType z);
00170
00171 void SetPositionOffset(vtkFloatingPointType pos[3]);
00172 void SetPositionOffset(vtkFloatingPointType x, vtkFloatingPointType y, vtkFloatingPointType z);
00173 void GetPositionOffset(vtkFloatingPointType pos[3]);
00174
00175 void DoPositionOffset();
00176
00177 void Modified();
00178
00179 void SetDim(int d);
00180
00181
00182 protected:
00183 vtkTextureText();
00184 ~vtkTextureText();
00185
00186 int Initialized;
00187 int Error;
00188
00189
00190
00191 vtkFloatingPointType Leading;
00192 vtkFloatingPointType Indent;
00193 int mLineCount;
00194
00195 vtkFloatingPointType CharacterSpace;
00196
00197 bool Wrapped;
00198 vtkFloatingPointType BoxWidth;
00199 vtkFloatingPointType BoxHeight;
00200
00201
00202
00203
00204
00205
00206
00207 short Alignment;
00208 static short sDefaultTextAlignment;
00209 vtkFloatingPointType word_space_when_justified;
00210
00211 char *CharacterArray;
00212 char *Text;
00213
00214 Vector3D<vtkFloatingPointType> PositionOffset;
00215
00216 vtkFontParameters *FontParameters;
00217 vtkTexture *Texture;
00218 vtkFollower *Follower;
00219 vtkTextureFont *TextureFont;
00220 vtkTextureTextPolys *TextureTextPolys;
00221
00222 vtkFloatingPointType TextOpacity;
00223 int Dim;
00224
00225 void deleteAllChars();
00226
00227
00228 vtkFloatingPointType getLinePos(unsigned int _start);
00229 vtkFloatingPointType getLineLength(unsigned int _start);
00230 int getCharLine(unsigned int _start);
00231 vtkFloatingPointType getLineWordCount(unsigned int _start, vtkFloatingPointType ind = 0);
00232
00233
00234 void setCharCoords(Vector3D<vtkFloatingPointType> *char_gset_coords, Vector2D<vtkFloatingPointType> *tex_coords,
00235 vtkTextureFont *textureFont, int the_char, Vector3D<vtkFloatingPointType> text_pos);
00236
00237
00238 };
00239
00240 #endif