this->PointSpriteMode = 0;
this->PointSpriteClamp = 256.0;
- this->PointSpriteSize = 0.15;
- this->PointSpriteMinSize = 0.3;
- this->PointSpriteMaxSize = 0.33;
+ this->PointSpriteSize = 0.2;
+ this->PointSpriteMinSize = 0.1;
+ this->PointSpriteMaxSize = 0.3;
this->PointSpriteMagnification = 1.0;
this->PointSpriteAlphaThreshold = 0.5;
this->PointSpriteTexture = 0;
this->UseOpenGLMapper = false;
+
+ this->TempMapper = vtkPolyDataMapper::New();
}
//-----------------------------------------------------------------------------
VISU_OpenGLPointSpriteMapper::~VISU_OpenGLPointSpriteMapper()
{
glDeleteTextures( 1, &PointSpriteTexture );
- if (this->LastWindow)
- {
+ if( this->LastWindow )
this->ReleaseGraphicsResources(this->LastWindow);
- }
+
+ if( this->TempMapper )
+ this->TempMapper->Delete();
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::ShallowCopy( vtkAbstractMapper* mapper )
this->SetImageData( m->GetImageData() );
this->SetPointSpriteAlphaThreshold( m->GetPointSpriteAlphaThreshold() );
}
- MAPPER_SUPERCLASS::ShallowCopy(mapper);
+
+ this->TempMapper->ShallowCopy( m );
+ this->TempMapper->SetInput( this->GetInput() );
+ Superclass::ShallowCopy( this->TempMapper );
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPrimitiveType( int thePrimitiveType )
{
- if(this->PrimitiveType == thePrimitiveType)
+ if( this->PrimitiveType == thePrimitiveType )
return;
this->PrimitiveType = thePrimitiveType;
- this->Modified();
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteMode( int theMode )
{
- if(this->PointSpriteMode == theMode)
+ if( this->PointSpriteMode == theMode )
return;
this->PointSpriteMode = theMode;
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteClamp( float theClamp )
{
- if(fabs(this->PointSpriteClamp - theClamp) < Tolerance)
+ if( fabs( this->PointSpriteClamp - theClamp ) < Tolerance )
return;
this->PointSpriteClamp = theClamp;
- this->Modified();
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteSize( float theSize )
{
- if(fabs(this->PointSpriteSize - theSize) < Tolerance)
+ if( fabs( this->PointSpriteSize - theSize ) < Tolerance )
return;
this->PointSpriteSize = theSize;
- this->Modified();
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize( float theMinSize )
{
- if(fabs(this->PointSpriteMinSize - theMinSize) < Tolerance)
+ if( fabs( this->PointSpriteMinSize - theMinSize ) < Tolerance )
return;
this->PointSpriteMinSize = theMinSize;
- this->Modified();
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteMaxSize( float theMaxSize )
{
- if(fabs(this->PointSpriteMaxSize - theMaxSize) < Tolerance)
+ if( fabs( this->PointSpriteMaxSize - theMaxSize ) < Tolerance )
return;
this->PointSpriteMaxSize = theMaxSize;
- this->Modified();
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteMagnification( float theMagnification )
{
- if(fabs(this->PointSpriteMagnification - theMagnification) < Tolerance)
+ if( fabs( this->PointSpriteMagnification - theMagnification ) < Tolerance )
return;
this->PointSpriteMagnification = theMagnification;
- this->Modified();
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteAlphaThreshold( float theAlphaThreshold )
{
- if(fabs(this->PointSpriteAlphaThreshold - theAlphaThreshold) < Tolerance)
+ if( fabs( this->PointSpriteAlphaThreshold - theAlphaThreshold ) < Tolerance )
return;
this->PointSpriteAlphaThreshold = theAlphaThreshold;
- this->Modified();
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::InitExtensions()
this->ExtensionsInitialized = 1;
}
+
+//-----------------------------------------------------------------------------
+float ViewToDisplay( vtkRenderer* theRenderer )
+{
+ float p1[3], p2[3];
+
+ theRenderer->SetViewPoint( 0.0, 0.0, 0.0 );
+ theRenderer->ViewToDisplay();
+ theRenderer->GetDisplayPoint( p1 );
+
+ theRenderer->SetViewPoint( 1.0, 1.0, 1.0 );
+ theRenderer->ViewToDisplay();
+ theRenderer->GetDisplayPoint( p2 );
+
+ float coefficient = sqrt( pow( p2[0] - p1[0], 2 ) + pow( p2[1] - p1[1], 2 ) ) / sqrt( 2 );
+ //cout << p1[0] << " " << p1[1] << " " << p1[2] << endl;
+ //cout << p2[0] << " " << p2[1] << " " << p2[2] << endl;
+ //cout << "ZOOM : " << coefficient << endl;
+
+ return coefficient;
+}
+
//-----------------------------------------------------------------------------
//
// Receives from Actor -> maps data to primitives
if( !this->ExtensionsInitialized && isUseThisMapper )
{
this->InitExtensions();
- act->GetProperty()->SetPointSize( 10.0f );
+ //act->GetProperty()->SetPointSize( 10.0f );
}
if( !isUseThisMapper )
// make sure our window is current
ren->GetRenderWindow()->MakeCurrent();
+ if( this->UsePointSprites ) //&& this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite )
+ this->InitPointSprites();
+
// Initializing the texture for Point Sprites
if( this->UseTextures && this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite )
this->InitTextures();
+ vglUseProgramObjectARB( this->VertexProgram );
+ float aViewToDisplay = ViewToDisplay( ren );
+ this->SetShaderVariable( "mode", this->PointSpriteMode );
+ this->SetShaderVariable( "clampSize", this->PointSpriteClamp );
+ this->SetShaderVariable( "geomSize", aViewToDisplay * this->AverageCellSize * this->PointSpriteSize );
+ this->SetShaderVariable( "minSize", aViewToDisplay * this->AverageCellSize * this->PointSpriteMinSize );
+ this->SetShaderVariable( "maxSize", aViewToDisplay * this->AverageCellSize * this->PointSpriteMaxSize );
+ this->SetShaderVariable( "magnification", this->PointSpriteMagnification );
+
//
// if something has changed regenerate colors and display lists
// if required
// time so that it is not zero
if ( this->TimeToDraw == 0.0 )
this->TimeToDraw = 0.0001;
+
+ vglUseProgramObjectARB( 0 );
+
+ if( this->UsePointSprites ) //&& this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite )
+ this->CleanupPointSprites();
}
//-----------------------------------------------------------------------------
float VISU_OpenGLPointSpriteMapper::GetMaximumSupportedSize()
GLfloat vx, vy, vz;
};
-float ViewToDisplay( vtkRenderer* theRenderer )
-{
- float p1[3], p2[3];
-
- theRenderer->SetViewPoint( 0.0, 0.0, 0.0 );
- theRenderer->ViewToDisplay();
- theRenderer->GetDisplayPoint( p1 );
-
- theRenderer->SetViewPoint( 1.0, 1.0, 1.0 );
- theRenderer->ViewToDisplay();
- theRenderer->GetDisplayPoint( p2 );
-
- float coefficient = sqrt( pow( p2[0] - p1[0], 2 ) + pow( p2[1] - p1[1], 2 ) ) / sqrt( 2 );
- //cout << p1[0] << " " << p1[1] << " " << p1[2] << endl;
- //cout << p2[0] << " " << p2[1] << " " << p2[2] << endl;
- //cout << "ZOOM : " << coefficient << endl;
-
- return coefficient;
-}
-
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *thePoints,
vtkUnsignedCharArray *theColors,
vtkRenderer *theRenderer,
vtkActor* theActor)
{
- if( this->UsePointSprites ) //&& this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite )
- this->InitPointSprites();
+ //cout << "VISU_OpenGLPointSpriteMapper::DrawPoints" << endl;
- if( this->PrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint )
- glEnable( GL_POINT_SMOOTH );
+ //if( this->PrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint )
+ // glEnable( GL_POINT_SMOOTH );
glPointSize( this->DefaultPointSize );
- vglUseProgramObjectARB( this->VertexProgram );
-
- this->SetShaderVariable( "clamp_size", this->PointSpriteClamp );
-
TVertex* aVertexArr = new TVertex[ this->TotalCells ];
float* aPropertyColor = theActor->GetProperty()->GetColor();
aGreen = int(col[1]);
aBlue = int(col[2]);
- aColor[0] = aRed / 255.0;
+ aColor[0] = aRed / 255.0;
aColor[1] = aGreen / 255.0;
- aColor[2] = aBlue / 255.0;
+ aColor[2] = aBlue / 255.0;
}
aVertex.r = aColor[0];
aVertex.g = aColor[1];
aVertex.b = aColor[2];
-
- if( this->PointSpriteMode == 0 )
- {
- aHue = ComputeHue( aRed, aGreen, aBlue );
- aSize = this->PointSpriteMinSize + ( PointSpriteMaxSize - PointSpriteMinSize ) * ( 1 - aHue / 241.0f );
- }
- else
- aSize = this->PointSpriteSize;
-
- aVertex.hue = aViewToDisplay * this->AverageCellSize * this->PointSpriteMagnification * aSize;
+ aVertex.hue = ComputeHue( aRed, aGreen, aBlue );
}
GLuint aBufferObjectID = 0;
vglDeleteBuffersARB( 1, &aBufferObjectID );
- vglUseProgramObjectARB( 0 );
-
- if( this->UsePointSprites ) //&& this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite )
- this->CleanupPointSprites();
-
- if( this->PrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint )
- glDisable( GL_POINT_SMOOTH );
+ //if( this->PrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint )
+ // glDisable( GL_POINT_SMOOTH );
}
//-----------------------------------------------------------------------------
int VISU_OpenGLPointSpriteMapper::Draw(vtkRenderer *aren, vtkActor *act)
{
- if( this->UseOpenGLMapper || this->PrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere )
+ if( this->UseOpenGLMapper ||
+ this->PrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere )
return MAPPER_SUPERCLASS::Draw( aren, act );
vtkOpenGLRenderer *ren = (vtkOpenGLRenderer *)aren;
}
this->LastWindow = NULL;
}
-//-----------------------------------------------------------------------------