-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// VISU OBJECT : interactive object for VISU entities implementation
// File: VISU_OpenGLPointSpriteMapper.cxx
// Author:
//
#include "VISU_OpenGLPointSpriteMapper.hxx"
-#include "SVTK_Extension.h"
+//#include "SVTK_Extension.h"
#include <vtkCamera.h>
#include <vtkCellArray.h>
this->PointSpriteMagnification = 1.0;
this->PointSpriteAlphaThreshold = 0.5;
+ this->PointSpriteOpacity = 1.0;
this->PointSpriteTexture = 0;
this->UseOpenGLMapper = false;
return;
this->PointSpriteClamp = theClamp;
+ this->Modified();
}
//-----------------------------------------------------------------------------
return;
this->AverageCellSize = theSize;
+ this->Modified();
}
//-----------------------------------------------------------------------------
return;
this->PointSpriteSize = theSize;
+ this->Modified();
}
//-----------------------------------------------------------------------------
return;
this->PointSpriteMinSize = theMinSize;
+ this->Modified();
}
//-----------------------------------------------------------------------------
return;
this->PointSpriteMaxSize = theMaxSize;
+ this->Modified();
}
//-----------------------------------------------------------------------------
return;
this->PointSpriteMagnification = theMagnification;
+ this->Modified();
}
//-----------------------------------------------------------------------------
return;
this->PointSpriteAlphaThreshold = theAlphaThreshold;
+ this->Modified();
}
//-----------------------------------------------------------------------------
glEnable( GL_POINT_SPRITE_ARB );
glEnable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB );
+ glPushAttrib( GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT );
+
+ this->RenderMode = this->PointSpriteOpacity < 1.0 ? VISU_OpenGLPointSpriteMapper::Accumulate : VISU_OpenGLPointSpriteMapper::Occlude;
+
switch (this->RenderMode)
{
case VISU_OpenGLPointSpriteMapper::Accumulate:
{
- glDisable(GL_DEPTH_TEST);
+ glDepthFunc( GL_LESS );
+ glEnable( GL_DEPTH_TEST );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE );
void VISU_OpenGLPointSpriteMapper::CleanupPointSprites()
{
// Set GL params back to normal to stop other vtkMappers displaying wrongly
- glDisable( GL_ALPHA_TEST );
-
- glEnable( GL_BLEND );
-
- glEnable( GL_DEPTH_TEST );
- glEnable( GL_LIGHTING );
- glEnable( GL_COLOR_MATERIAL );
+ glPopAttrib();
glDisable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB );
glDisable( GL_POINT_SPRITE_ARB );
int* aSize = GetImageData()->GetDimensions();
unsigned char* dataPtr = (unsigned char*)GetImageData()->GetScalarPointer();
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, aSize[0], aSize[1], 0,
- GL_RGBA, GL_UNSIGNED_BYTE, dataPtr );
+ GL_RGBA, GL_UNSIGNED_BYTE, dataPtr );
//glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable( GL_TEXTURE_2D );
//-----------------------------------------------------------------------------
template < class TCoordinates >
void DrawPoints( TCoordinates *theStartPoints,
- vtkCellArray *theCells,
- TColorFunctorBase* theColorFunctor,
- TVertex* theVertexArr,
- vtkIdType &theCellId,
- vtkIdType &theVertexId )
+ vtkCellArray *theCells,
+ TColorFunctorBase* theColorFunctor,
+ TVertex* theVertexArr,
+ vtkIdType &theCellId,
+ vtkIdType &theVertexId )
{
vtkIdType *ptIds = theCells->GetPointer();
vtkIdType *endPtIds = ptIds + theCells->GetNumberOfConnectivityEntries();
//-----------------------------------------------------------------------------
template < class TCoordinates >
void DrawCellsPoints( vtkPolyData *theInput,
- vtkPoints* thePoints,
- TColorFunctorBase* theColorFunctor,
- TVertex* theVertexArr )
+ vtkPoints* thePoints,
+ TColorFunctorBase* theColorFunctor,
+ TVertex* theVertexArr )
{
vtkIdType aCellId = 0, aVertexId = 0;
vtkPoints *points;
int noAbort = 1;
int cellScalars = 0;
- float tran;
-
- // get the transparency
- tran = theActor->GetProperty()->GetOpacity();
// if the primitives are invisable then get out of here
- if (tran <= 0.0)
+ if (this->PointSpriteOpacity <= 0.0)
{
return noAbort;
}
glPointSize( this->DefaultPointSize );
{
- TColorFunctorBase* aColorFunctor = NULL;
- if( colors && this->PointSpriteMode != 1 ) {
- if ( cellScalars )
- aColorFunctor = new TCellColors2Color( colors );
- else
- aColorFunctor = new TPointColors2Color( colors );
- } else {
- aColorFunctor = new TPropertyColor( theActor->GetProperty() );
- }
- if ( points->GetDataType() == VTK_FLOAT )
- ::DrawCellsPoints< float >( input, points, aColorFunctor, aVertexArr );
- else
- ::DrawCellsPoints< double >( input, points, aColorFunctor, aVertexArr );
-
- delete aColorFunctor;
+ TColorFunctorBase* aColorFunctor = NULL;
+ if( colors && this->PointSpriteMode != 1 ) {
+ if ( cellScalars )
+ aColorFunctor = new TCellColors2Color( colors );
+ else
+ aColorFunctor = new TPointColors2Color( colors );
+ } else {
+ aColorFunctor = new TPropertyColor( theActor->GetProperty() );
+ }
+ if ( points->GetDataType() == VTK_FLOAT )
+ ::DrawCellsPoints< float >( input, points, aColorFunctor, aVertexArr );
+ else
+ ::DrawCellsPoints< double >( input, points, aColorFunctor, aVertexArr );
+
+ delete aColorFunctor;
}
if( this->ExtensionsInitialized ) {
- GLuint aBufferObjectID = 0;
- vglGenBuffersARB( 1, &aBufferObjectID );
- vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
-
- int anArrayObjectSize = sizeof( TVertex ) * aTotalConnectivitySize;
- vglBufferDataARB( GL_ARRAY_BUFFER_ARB, anArrayObjectSize, aVertexArr, GL_STATIC_DRAW_ARB );
-
- delete [] aVertexArr;
-
- vglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
- vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
-
- glColorPointer( 4, GL_FLOAT, sizeof(TVertex), (void*)0 );
- glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), (void*)(4*sizeof(GLfloat)) );
-
- glEnableClientState( GL_VERTEX_ARRAY );
- glEnableClientState( GL_COLOR_ARRAY );
-
- glDrawArrays( GL_POINTS, 0, aTotalConnectivitySize );
-
- glDisableClientState( GL_COLOR_ARRAY );
- glDisableClientState( GL_VERTEX_ARRAY );
-
- vglDeleteBuffersARB( 1, &aBufferObjectID );
+ GLuint aBufferObjectID = 0;
+ vglGenBuffersARB( 1, &aBufferObjectID );
+ vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
+
+ int anArrayObjectSize = sizeof( TVertex ) * aTotalConnectivitySize;
+ vglBufferDataARB( GL_ARRAY_BUFFER_ARB, anArrayObjectSize, aVertexArr, GL_STATIC_DRAW_ARB );
+
+ delete [] aVertexArr;
+
+ vglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
+ vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
+
+ glColorPointer( 4, GL_FLOAT, sizeof(TVertex), (void*)0 );
+ glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), (void*)(4*sizeof(GLfloat)) );
+
+ glEnableClientState( GL_VERTEX_ARRAY );
+ glEnableClientState( GL_COLOR_ARRAY );
+
+ glDrawArrays( GL_POINTS, 0, aTotalConnectivitySize );
+
+ glDisableClientState( GL_COLOR_ARRAY );
+ glDisableClientState( GL_VERTEX_ARRAY );
+
+ vglDeleteBuffersARB( 1, &aBufferObjectID );
} else { // there are not extensions
- glColorPointer( 4, GL_FLOAT, sizeof(TVertex), aVertexArr );
- glVertexPointer( 3, GL_FLOAT, sizeof(TVertex),
- (void*)((GLfloat*)((void*)(aVertexArr)) + 4));
-
- glEnableClientState( GL_VERTEX_ARRAY );
- glEnableClientState( GL_COLOR_ARRAY );
-
- glDrawArrays( GL_POINTS, 0, aTotalConnectivitySize );
-
- glDisableClientState( GL_COLOR_ARRAY );
- glDisableClientState( GL_VERTEX_ARRAY );
-
- delete [] aVertexArr;
+ glColorPointer( 4, GL_FLOAT, sizeof(TVertex), aVertexArr );
+ glVertexPointer( 3, GL_FLOAT, sizeof(TVertex),
+ (void*)((GLfloat*)((void*)(aVertexArr)) + 4));
+
+ glEnableClientState( GL_VERTEX_ARRAY );
+ glEnableClientState( GL_COLOR_ARRAY );
+
+ glDrawArrays( GL_POINTS, 0, aTotalConnectivitySize );
+
+ glDisableClientState( GL_COLOR_ARRAY );
+ glDisableClientState( GL_VERTEX_ARRAY );
+
+ delete [] aVertexArr;
}
}