33 #ifndef vtkOpenGLContextDevice2DPrivate_h 
   34 #define vtkOpenGLContextDevice2DPrivate_h 
   83       : std::pair<Key, 
CacheData>(key, cacheData){}
 
   90       return this->first == other.first;
 
  127     typename std::list<CacheElement >::iterator it;
 
  128     for (it = this->
Cache.begin(); it != this->
Cache.end(); ++it)
 
  130       it->second.Texture->ReleaseGraphicsResources(window);
 
  146       this->
Cache.pop_back();
 
  148     this->
Cache.push_front(CacheElement(key, cacheData));
 
  149     return this->
Cache.begin()->second;
 
  169   typename std::list<CacheElement>::iterator it =
 
  170     std::find(this->Cache.begin(), this->Cache.end(), 
CacheElement(key));
 
  171   if (it != this->Cache.end())
 
  181   return this->AddCacheData(key, cacheData);
 
  187 template <
class StringType>
 
  199     return static_cast<unsigned int>(id);
 
  214     this->
Color.
Set(static_cast<unsigned char>(color[0] * 255),
 
  215                     static_cast<unsigned char>(color[1] * 255),
 
  216                     static_cast<unsigned char>(color[2] * 255),
 
  217                     static_cast<unsigned char>(textProperty->
GetOpacity() * 255));
 
  322       bool colorDiffer = 
false;
 
  323       while(!colorDiffer && i < 4)
 
  341       glEnable(capability);
 
  345       glDisable(capability);
 
  351     float* texCoord = 
new float[2*n];
 
  352     float minX = f[0]; 
float minY = f[1];
 
  353     float maxX = f[0]; 
float maxY = f[1];
 
  355     for(
int i = 0; i < n; ++i)
 
  357       minX = fptr[0] < minX ? fptr[0] : minX;
 
  358       maxX = fptr[0] > maxX ? fptr[0] : maxX;
 
  359       minY = fptr[1] < minY ? fptr[1] : minY;
 
  360       maxY = fptr[1] > maxY ? fptr[1] : maxY;
 
  367       float rangeX = (textureBounds[1] - textureBounds[0]) ?
 
  368         textureBounds[1] - textureBounds[0] : 1.;
 
  369       float rangeY = (textureBounds[3] - textureBounds[2]) ?
 
  370         textureBounds[3] - textureBounds[2] : 1.;
 
  371       for (
int i = 0; i < n; ++i)
 
  373         texCoord[i*2] = (fptr[0]-minX) / rangeX;
 
  374         texCoord[i*2+1] = (fptr[1]-minY) / rangeY;
 
  380       float rangeX = (maxX - minX)? maxX - minX : 1.f;
 
  381       float rangeY = (maxY - minY)? maxY - minY : 1.f;
 
  382       for (
int i = 0; i < n; ++i)
 
  384         texCoord[i*2] = (fptr[0]-minX)/rangeX;
 
  385         texCoord[i*2+1] = (fptr[1]-minY)/rangeY;
 
  395     for (
int i = 0; i < 2; ++i)
 
  397       while (pow2[i] < size[i])
 
  409       cout << 
"Error = not an unsigned char..." << endl;
 
  417     for (
int i = 0; i < 2; ++i)
 
  419       texCoords[i] = size[i] / 
float(newImg[i]);
 
  422     unsigned char *dataPtr =
 
  423         new unsigned char[newImg[0] * newImg[1] * bytesPerPixel];
 
  424     unsigned char *origPtr =
 
  427     for (
int i = 0; i < newImg[0]; ++i)
 
  429       for (
int j = 0; j < newImg[1]; ++j)
 
  431         for (
int k = 0; k < bytesPerPixel; ++k)
 
  433           if (i < size[0] && j < size[1])
 
  435             dataPtr[i * bytesPerPixel + j * newImg[0] * bytesPerPixel + k] =
 
  436                 origPtr[i * bytesPerPixel + j * size[0] * bytesPerPixel + k];
 
  440             dataPtr[i * bytesPerPixel + j * newImg[0] * bytesPerPixel + k] =
 
  448     GLint glFormat = bytesPerPixel == 3 ? GL_RGB : GL_RGBA;
 
  449     GLint glInternalFormat = bytesPerPixel == 3 ? GL_RGB8 : GL_RGBA8;
 
  451     glGenTextures(1, &tmpIndex);
 
  452     glBindTexture(GL_TEXTURE_2D, tmpIndex);
 
  454     glTexEnvf(GL_TEXTURE_ENV, vtkgl::COMBINE_RGB, GL_REPLACE);
 
  455     glTexEnvf(GL_TEXTURE_ENV, vtkgl::COMBINE_ALPHA, GL_REPLACE);
 
  457     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
  458     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
  459     glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
 
  460                      vtkgl::CLAMP_TO_EDGE );
 
  461     glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
 
  462                      vtkgl::CLAMP_TO_EDGE );
 
  464     glTexImage2D(GL_TEXTURE_2D, 0 , glInternalFormat,
 
  465                  newImg[0], newImg[1], 0, glFormat,
 
  466                  GL_UNSIGNED_BYTE, static_cast<const GLvoid *>(dataPtr));
 
  467     glAlphaFunc(GL_GREATER, static_cast<GLclampf>(0));
 
  468     glEnable(GL_ALPHA_TEST);
 
  469     glMatrixMode(GL_TEXTURE);
 
  471     glMatrixMode(GL_MODELVIEW);
 
  472     glEnable(GL_TEXTURE_2D);
 
  481       cout << 
"Error = not an unsigned char..." << endl;
 
  488     unsigned char *dataPtr =
 
  491     GLint glFormat = bytesPerPixel == 3 ? GL_RGB : GL_RGBA;
 
  492     GLint glInternalFormat = bytesPerPixel == 3 ? GL_RGB8 : GL_RGBA8;
 
  494     glGenTextures(1, &tmpIndex);
 
  495     glBindTexture(GL_TEXTURE_2D, tmpIndex);
 
  497     glTexEnvf(GL_TEXTURE_ENV, vtkgl::COMBINE_RGB, GL_REPLACE);
 
  498     glTexEnvf(GL_TEXTURE_ENV, vtkgl::COMBINE_ALPHA, GL_REPLACE);
 
  500     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
  501     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
  502     glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
 
  503                      vtkgl::CLAMP_TO_EDGE );
 
  504     glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
 
  505                      vtkgl::CLAMP_TO_EDGE );
 
  507     glTexImage2D(GL_TEXTURE_2D, 0 , glInternalFormat,
 
  508                  size[0], size[1], 0, glFormat,
 
  509                  GL_UNSIGNED_BYTE, static_cast<const GLvoid *>(dataPtr));
 
  510     glAlphaFunc(GL_GREATER, static_cast<GLclampf>(0));
 
  511     glEnable(GL_ALPHA_TEST);
 
  512     glMatrixMode(GL_TEXTURE);
 
  514     glMatrixMode(GL_MODELVIEW);
 
  515     glEnable(GL_TEXTURE_2D);
 
  550 #endif // VTKOPENGLCONTEXTDEVICE2DPRIVATE_H 
std::list< CacheElement > Cache
List of a pair of key and cache data. 
 
GLuint TextureFromImage(vtkImageData *image)
 
bool operator==(const CacheElement &other) const 
 
void SetGLCapability(GLenum capability, GLboolean state)
 
double * GetBounds()
Return a pointer to the geometry bounding box in the form (xmin,xmax, ymin,ymax, zmin,zmax). 
 
static int GetNumberOfScalarComponents(vtkInformation *meta_data)
Set/Get the number of scalar components for points. 
 
GLuint TextureFromImage(vtkImageData *image, vtkVector2f &texCoords)
 
bool IsKeyInCache(const Key &key) const 
Search the cache list to see if a given key already exists. 
 
TextPropertyKey(vtkTextProperty *textProperty, const StringType &text, int dpi)
Creates a TextPropertyKey. 
 
vtkSmartPointer< vtkTexture > Texture
 
static vtkSmartPointer< T > New()
Create an instance of a VTK object. 
 
CacheElement(const Key &key, const CacheData &cacheData)
 
void SetInputData(vtkDataObject *)
Assign a data object as input. 
 
void ReleaseGraphicsResources(vtkWindow *window)
Release all the OpenGL Pixel Buffer Object(PBO) associated with the textures of the cache list...
 
vtkSmartPointer< vtkImageData > ImageData
 
bool operator==(const TextPropertyKey &other) const 
Compares two TextPropertyKeys with each other. 
 
float * TexCoords(float *f, int n)
 
TextPropertyKey< vtkStdString > UTF8TextPropertyKey
 
window superclass for vtkRenderWindow 
 
size_t MaxSize
Maximum size the cache list can be. 
 
virtual int * GetDimensions()
Get dimensions of this structured points dataset. 
 
static int GetScalarType(vtkInformation *meta_data)
 
topologically and geometrically regular array of data 
 
vtkImageData * GetInput()
Get the input as a vtkImageData object. 
 
Some derived classes for the different vectors commonly used. 
 
CacheData & GetCacheData(const Key &key)
Return the cache associated to a key. 
 
void Set(const T &red, const T &green, const T &blue)
Set the red, green and blue components of the color. 
 
handles properties associated with a texture map 
 
vtkTextureImageCache()
Construct a texture image cache with a maximum number of texture of 50. 
 
virtual double GetOpacity()
Set/Get the text's opacity. 
 
represent text properties. 
 
vtkTextureImageCache< UTF16TextPropertyKey > TextTextureCache
Cache for text images. 
 
static unsigned int GetIdFromTextProperty(vtkTextProperty *textProperty)
Transform a text property into an unsigned long. 
 
CacheElement(const Key &key)
 
virtual double * GetColor()
Set the color of the text. 
 
GLfloat SavedClearColor[4]
 
#define VTK_UNSIGNED_CHAR
 
virtual void * GetScalarPointer(int coordinates[3])
Access the native pointer for the scalar data. 
 
vtkTexture * SpriteTexture
 
unsigned int TextureProperties
 
CacheElement associates a unique key to some cache. 
 
vtkVector2i FindPowerOfTwo(const vtkVector2i &size)
 
virtual int GetFontSize()
Set/Get the font size (in points). 
 
TextPropertyKey< vtkUnicodeString > UTF16TextPropertyKey
 
CacheData & AddCacheData(const Key &key, const CacheData &cacheData)
Add a new cache entry into the cache list. 
 
unsigned int TextPropertyId
 
GLboolean SavedStencilTest
 
void RestoreGLState(bool colorBuffer=false)
 
void SaveGLState(bool colorBuffer=false)
 
virtual void Delete()
Delete a VTK object. 
 
vtkTextureImageCache< UTF8TextPropertyKey > MathTextTextureCache
Cache for text images.