21#ifndef vtkOpenGLContextDevice2DPrivate_h
22#define vtkOpenGLContextDevice2DPrivate_h
46VTK_ABI_NAMESPACE_BEGIN
89 return this->first == other.first;
105 return std::find(this->
Cache.begin(), this->Cache.end(), key) != this->
Cache.end();
123 typename std::list<CacheElement>::iterator it;
124 for (it = this->
Cache.begin(); it != this->
Cache.end(); ++it)
126 it->second.Texture->ReleaseGraphicsResources(window);
140 if (this->
Cache.size() >= this->MaxSize)
142 this->
Cache.pop_back();
145 return this->
Cache.begin()->second;
165 typename std::list<CacheElement>::iterator it =
166 std::find(this->Cache.begin(), this->Cache.end(),
CacheElement(key));
167 if (it != this->Cache.end())
175 return this->AddCacheData(key, cacheData);
181template <
class StringType>
198 vtkTypeUInt32 hash =
static_cast<vtkTypeUInt32
>(id);
202 assert(
"Hash is really a uint32" &&
static_cast<size_t>(hash) ==
id);
235 this->
Color.
Set(
static_cast<unsigned char>(color[0] * 255),
236 static_cast<unsigned char>(color[1] * 255),
static_cast<unsigned char>(color[2] * 255),
237 static_cast<unsigned char>(textProperty->
GetOpacity() * 255));
345 for (
int i = 0;
i < n; ++
i)
361 for (
int i = 0;
i < n; ++
i)
372 for (
int i = 0;
i < n; ++
i)
385 for (
int i = 0;
i < 2; ++
i)
404 image->GetDimensions(size);
407 for (
int i = 0;
i < 2; ++
i)
413 unsigned char*
origPtr =
static_cast<unsigned char*
>(image->GetScalarPointer());
421 if (
i < size[0] &&
j < size[1])
456 cout <<
"Error = not an unsigned char..." << endl;
461 image->GetDimensions(size);
463 unsigned char*
dataPtr =
static_cast<unsigned char*
>(image->GetScalarPointer());
546 this->cache =
new PolyDataCache();
557 this->Points = points;
579 struct PolyDataCacheItem
583 std::vector<float> PolyTri;
587 std::vector<float> Lines;
596 std::map<vtkPolyData*, PolyDataCacheItem*>::iterator
itPrev = this->PrevFrameCache.begin();
602 std::map<vtkPolyData*, PolyDataCacheItem*>::iterator
it = this->CurrentFrameCache.begin();
603 for (;
it != this->CurrentFrameCache.end(); ++
it)
611 PolyDataCacheItem*
cacheItem = this->CurrentFrameCache[
key];
624 this->PrevFrameCache.erase(key);
639 std::map<vtkPolyData*, PolyDataCacheItem*>::iterator
itPrev = this->PrevFrameCache.begin();
646 this->PrevFrameCache.clear();
649 std::swap(this->PrevFrameCache, this->CurrentFrameCache);
654 std::map<vtkPolyData*, PolyDataCacheItem*> PrevFrameCache;
655 std::map<vtkPolyData*, PolyDataCacheItem*> CurrentFrameCache;
664 this->CellPoints.reserve(this->NumPointsCell * 2);
666 for (
int i = 0;
i < this->NumPointsCell;
i++)
669 this->Points->
GetPoint(this->PointIds[
i], point);
672 float const x =
static_cast<float>(
point[0]) +
posX;
673 float const y =
static_cast<float>(
point[1]) +
posY;
674 this->CellPoints.push_back(x * scale);
675 this->CellPoints.push_back(y * scale);
688 std::cerr <<
"Scalar mode not supported!" << std::endl;
732 this->NumPointsCell = 2;
733 this->PointIds =
genericCell->GetPointIds()->GetPointer(
i);
738 for (
int j = 0;
j < this->NumPointsCell;
j++)
740 cacheItem->Lines.push_back(this->CellPoints[2 *
j]);
741 cacheItem->Lines.push_back(this->CellPoints[2 *
j + 1]);
749 this->CellColors->
Reset();
750 this->CellPoints.clear();
762 static_cast<int>(
cacheItem->Lines.size() / 2),
763 static_cast<unsigned char*
>(
cacheItem->LineColors->GetVoidPointer(0)),
764 cacheItem->LineColors->GetNumberOfComponents());
783 this->NumPointsCell =
genericCell->GetNumberOfPoints();
784 this->PointIds =
genericCell->GetPointIds()->GetPointer(0);
828 this->NumPointsCell =
genericCell->GetNumberOfPoints();
829 this->PointIds =
genericCell->GetPointIds()->GetPointer(0);
834 for (
int i = 0;
i < this->NumPointsCell - 2;
i++)
836 cacheItem->PolyTri.push_back(this->CellPoints[0]);
837 cacheItem->PolyTri.push_back(this->CellPoints[1]);
838 cacheItem->PolyTri.push_back(this->CellPoints[
i * 2 + 2]);
839 cacheItem->PolyTri.push_back(this->CellPoints[
i * 2 + 3]);
840 cacheItem->PolyTri.push_back(this->CellPoints[
i * 2 + 4]);
841 cacheItem->PolyTri.push_back(this->CellPoints[
i * 2 + 5]);
859 this->CellColors->
Reset();
860 this->CellPoints.clear();
864 cacheItem->PolygonsLoadingTime.Modified();
871 static_cast<unsigned char*
>(
cacheItem->PolyColors->GetVoidPointer(0)), 4);
886 std::vector<float> CellPoints;
890 PolyDataCache* cache;
void SetTuple(vtkIdType tupleIdx, const float *tuple) override
Set the data tuple at tupleIdx.
void GetTuple(vtkIdType tupleIdx, double *tuple) override
Get the data tuple at tupleIdx by filling in a user-provided array, Make sure that your array is larg...
int GetNumberOfComponents() const
Set/Get the dimension (n) of the components.
void Reset()
Reset to an empty state, without freeing any memory.
Efficient cell iterator for vtkDataSet topologies.
void Set(const T &red, const T &green, const T &blue)
Set the red, green and blue components of the color.
double * GetBounds()
Return a pointer to the geometry bounding box in the form (xmin,xmax, ymin,ymax, zmin,...
void SetNumberOfComponents(int num) override
Set/Get the dimension (n) of the components.
void SetNumberOfTuples(vtkIdType number) override
Set the number of tuples (a component group) in the array.
void SetInputData(vtkDataObject *)
Assign a data object as input.
topologically and geometrically regular array of data
Allocate and hold a VTK object.
virtual void Delete()
Delete a VTK object.
void Draw(int cellType, vtkPolyData *polyData, vtkPoints *points, float x, float y, float scale, int scalarMode, vtkUnsignedCharArray *colors=nullptr)
Draw primitives as specified by cellType.
CellArrayHelper(vtkOpenGLContextDevice2D *device)
vtkVector2i FindPowerOfTwo(const vtkVector2i &size)
void SaveGLState(vtkOpenGLState *ostate, bool colorBuffer=false)
unsigned int TextureProperties
void RestoreGLState(vtkOpenGLState *ostate, bool colorBuffer=false)
vtkTexture * SpriteTexture
GLuint TextureFromImage(vtkImageData *image, vtkVector2f &texCoords)
GLuint TextureFromImage(vtkImageData *image)
GLfloat SavedClearColor[4]
vtkOpenGLContextDeviceBufferObjectBuilder BufferObjectBuilder
vtkTextureImageCache< UTF8TextPropertyKey > TextTextureCache
Cache for text images.
float * TexCoords(float *f, int n)
Class for drawing 2D primitives using OpenGL 1.1+.
void CoreDrawTriangles(std::vector< float > &tverts, unsigned char *colors=nullptr, int numComp=0)
void DrawLines(float *f, int n, unsigned char *colors=nullptr, int nc_comps=0) override
Draw lines using the points - memory layout is as follows: l1p1,l1p2,l2p1,l2p2... The lines will be c...
Internal buffer object builder that maintains a cache of VBO groups.
void vtkglGetIntegerv(unsigned int pname, int *params)
bool GetEnumState(unsigned int name)
void SetEnumState(unsigned int name, bool value)
represent and manipulate 3D points
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
concrete dataset represents vertices, lines, polygons, and triangle strips
Hold a reference to a vtkObjectBase instance.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
represent text properties.
virtual double GetCellOffset()
Set/Get the horizontal offset between cells.
virtual int GetVerticalJustification()
Set/Get the vertical justification to bottom (default), middle, or top.
virtual double GetOpacity()
Set/Get the text's opacity.
virtual int GetFontSize()
Set/Get the font size (in points).
virtual double * GetColor()
Set the color of the text.
virtual double * GetInteriorLinesColor()
Set the color of the interior lines between cells.
virtual bool GetInteriorLinesVisibility()
Set/Get the visibility of the interior lines between cells.
virtual int GetInteriorLinesWidth()
Set the width (in pixels) of the interior lines between cells.
virtual int GetJustification()
Set/Get the horizontal justification to left (default), centered, or right.
bool IsKeyInCache(const Key &key) const
Search the cache list to see if a given key already exists.
std::list< CacheElement > Cache
List of a pair of key and cache data.
CacheData & AddCacheData(const Key &key, const CacheData &cacheData)
Add a new cache entry into the cache list.
void ReleaseGraphicsResources(vtkWindow *window)
Release all the OpenGL Pixel Buffer Object(PBO) associated with the textures of the cache list.
vtkTextureImageCache()
Construct a texture image cache with a maximum number of texture of 50.
size_t MaxSize
Maximum size the cache list can be.
CacheData & GetCacheData(const Key &key)
Return the cache associated to a key.
handles properties associated with a texture map
vtkImageData * GetInput()
Get the input as a vtkImageData object.
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
Some derived classes for the different vectors commonly used.
window superclass for vtkRenderWindow
TextPropertyKey(vtkTextProperty *textProperty, const StringType &text, int dpi)
Creates a TextPropertyKey.
vtkTypeUInt32 TextPropertyId
static vtkTypeUInt32 GetIdFromTextProperty(vtkTextProperty *tprop)
Transform a text property into an unsigned long.
bool operator==(const TextPropertyKey &other) const
Compares two TextPropertyKeys with each other.
vtkSmartPointer< vtkImageData > ImageData
vtkTextRenderer::Metrics Metrics
vtkSmartPointer< vtkTexture > Texture
CacheElement associates a unique key to some cache.
CacheElement(const Key &key, const CacheData &cacheData)
CacheElement(const Key &key)
bool operator==(const CacheElement &other) const
#define VTK_SCALAR_MODE_USE_POINT_DATA
#define VTK_SCALAR_MODE_USE_CELL_DATA
TextPropertyKey< std::string > UTF8TextPropertyKey
#define VTK_UNSIGNED_CHAR