+//-----------------------------------------------------------------------------
+// Definition of structures and fuctions used in SetBallEnabled() method
+namespace VTK
+{
+ //----------------------------------------------------------------------------
+ vtkSmartPointer<vtkImageData> MakeTexture( const char* theMainTexture, const char* theAlphaTexture ) {
+ if( !theMainTexture || !theAlphaTexture )
+ return 0;
+
+ vtkXMLImageDataReader* aMainReader = vtkXMLImageDataReader::New();
+ vtkXMLImageDataReader* anAlphaReader = vtkXMLImageDataReader::New();
+
+ aMainReader->SetFileName( theMainTexture );
+ anAlphaReader->SetFileName( theAlphaTexture );
+
+ aMainReader->Update();
+ anAlphaReader->Update();
+
+ vtkImageData* aMainImageData = aMainReader->GetOutput();
+ vtkImageData* anAlphaImageData = anAlphaReader->GetOutput();
+
+ int* aMainImageSize = aMainImageData->GetDimensions();
+ int* anAlphaImageSize = anAlphaImageData->GetDimensions();
+ if(aMainImageSize[0] != anAlphaImageSize[0] || aMainImageSize[1] != anAlphaImageSize[1])
+ return NULL;
+
+ vtkSmartPointer<vtkImageData> aCompositeImageData = vtkImageData::New();
+ aCompositeImageData->Delete();
+
+ int aNbCompositeComponents = 4;
+ aCompositeImageData->SetDimensions(aMainImageSize);
+ aCompositeImageData->AllocateScalars( VTK_UNSIGNED_CHAR, aNbCompositeComponents );
+
+ unsigned char* aMainDataPtr = (unsigned char*)aMainImageData->GetScalarPointer();
+ unsigned char* anAlphaDataPtr = (unsigned char*)anAlphaImageData->GetScalarPointer();
+ unsigned char *aCompositeDataPtr = (unsigned char * )aCompositeImageData->GetScalarPointer();
+
+ int aNbMainComponents = aMainImageData->GetNumberOfScalarComponents();
+ int aNbAlphaComponents = anAlphaImageData->GetNumberOfScalarComponents();
+ int aCompositeSize = aMainImageSize[0] * aMainImageSize[1] * aNbCompositeComponents;
+
+ int aMainId = 0, anAlphaId = 0, aCompositeId = 0;
+ for(; aCompositeId < aCompositeSize;) {
+ aCompositeDataPtr[aCompositeId] = aMainDataPtr[aMainId];
+ aCompositeDataPtr[aCompositeId + 1] = aMainDataPtr[aMainId + 1];
+ aCompositeDataPtr[aCompositeId + 2] = aMainDataPtr[aMainId + 2];
+ aCompositeDataPtr[aCompositeId + 3] = anAlphaDataPtr[anAlphaId];
+
+ aMainId += aNbMainComponents;
+ anAlphaId += aNbAlphaComponents;
+ aCompositeId += aNbCompositeComponents;
+ }
+ aMainReader->Delete();
+ anAlphaReader->Delete();
+ return aCompositeImageData;
+ }
+}
+
+//-----------------------------------------------------------------------------
+bool VTKViewer_PolyDataMapper::GetBallEnabled()
+{
+ return this->BallEnabled;
+}
+//-----------------------------------------------------------------------------
+void VTKViewer_PolyDataMapper::SetBallEnabled( bool theBallEnabled )
+{
+ if( this->BallEnabled == theBallEnabled )
+ return;
+ else
+ this->BallEnabled = theBallEnabled;
+
+ if(!this->BallEnabled) {
+ this->ImageData = NULL;
+ }
+
+ if(this->BallEnabled) {
+ if(this->SpecialTextures.find(BallTextureId) == SpecialTextures.end()){
+ QString aMainTexture = getenv( "GUI_ROOT_DIR" );
+ aMainTexture.append("/share/salome/resources/gui/sprite_texture.vti");
+
+ QString anAlphaTexture = getenv( "GUI_ROOT_DIR" );
+ anAlphaTexture.append( "/share/salome/resources/gui/sprite_alpha.vti" );
+ vtkSmartPointer<vtkImageData> aTextureValue = VTK::MakeTexture( aMainTexture.toUtf8().constData(), anAlphaTexture.toUtf8().constData() );
+ this->SpecialTextures[BallTextureId] = aTextureValue;
+ }
+ this->ImageData = this->SpecialTextures[BallTextureId];
+ }
+ this->Modified();
+}
+
+//-----------------------------------------------------------------------------
+double VTKViewer_PolyDataMapper::GetBallScale()
+{
+ return this->BallScale;
+}
+//-----------------------------------------------------------------------------
+void VTKViewer_PolyDataMapper::SetBallScale( double theBallScale )
+{
+ if( this->BallScale == theBallScale )
+ return;
+ this->BallScale = theBallScale;
+}
+