From 5f31ecd4ec48021dea64b70deabbc9dbaf418e5a Mon Sep 17 00:00:00 2001 From: ouv Date: Fri, 23 Sep 2005 13:08:45 +0000 Subject: [PATCH] SetTextures() method added --- src/VISU_I/VISU_GaussPoints_i.cc | 41 +++++++++++++++++++++++++++++--- src/VISU_I/VISU_GaussPoints_i.hh | 26 ++++++++++++++------ 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 389b38ed..68e6be9f 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -223,6 +223,9 @@ VISU::GaussPoints_i myGaussPointsPL = dynamic_cast(myPipeLine); ScalarMap_i::DoHook(); + + SetTextures( QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp", + QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_alpha.bmp" ); } @@ -302,19 +305,51 @@ VISU::GaussPoints_i UpdateActors(); } + +//---------------------------------------------------------------------------- +void +VISU::GaussPoints_i +::SetTextures( const QString& theMainTexture, + const QString& theAlphaTexture ) +{ + bool updateMainTexture = SetMainTexture( theMainTexture ); + bool updateAlphaTexture = SetAlphaTexture( theAlphaTexture ); + if( !updateMainTexture && !updateAlphaTexture ) + return; + + QString mainTextureFormat = theMainTexture.section( '.', -1 ); + QString mainTextureVTI = theMainTexture.section( '.', 0, -2 ) + ".vti"; + QString command1 = QString( "VISU_img2vti " ) + mainTextureFormat + + " " + theMainTexture + " " + mainTextureVTI; + //cout << command1.latin1() << endl; + bool convertMainTexture = system( command1.latin1() ) == 0; + + QString alphaTextureFormat = theAlphaTexture.section( '.', -1 ); + QString alphaTextureVTI = theAlphaTexture.section( '.', 0, -2 ) + ".vti"; + QString command2 = QString( "VISU_img2vti " ) + alphaTextureFormat + + " " + theAlphaTexture + " " + alphaTextureVTI; + //cout << command2.latin1() << endl; + bool convertAlphaTexture = system( command2.latin1() ) == 0; + + if( convertMainTexture && convertAlphaTexture ) + MakeTexture( mainTextureVTI, alphaTextureVTI ); +} + + +//---------------------------------------------------------------------------- void VISU::GaussPoints_i ::MakeTexture( const QString& theMainTexture, - const QString& theAlphaChannelTexture ) + const QString& theAlphaTexture ) { - if( theMainTexture.isNull() || theAlphaChannelTexture.isNull() ) + if( theMainTexture.isNull() || theAlphaTexture.isNull() ) return; vtkXMLImageDataReader* aMainReader = vtkXMLImageDataReader::New(); vtkXMLImageDataReader* anAlphaReader = vtkXMLImageDataReader::New(); aMainReader->SetFileName( theMainTexture ); - anAlphaReader->SetFileName( theAlphaChannelTexture ); + anAlphaReader->SetFileName( theAlphaTexture ); aMainReader->Update(); anAlphaReader->Update(); diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 916c1f95..c3b9e612 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -70,20 +70,28 @@ namespace VISU void ShowColored( bool theColored ); - void SetMainTexture( const QString& theMainTexture ) { + bool + SetMainTexture( const QString& theMainTexture ) { + bool update = myMainTexture != theMainTexture; myMainTexture = theMainTexture; + return update; } QString GetMainTexture() { return myMainTexture; } - void SetAlphaChannelTexture( const QString& theAlphaChannelTexture ) { - myAlphaChannelTexture = theAlphaChannelTexture; + bool + SetAlphaTexture( const QString& theAlphaTexture ) { + bool update = myAlphaTexture != theAlphaTexture; + myAlphaTexture = theAlphaTexture; + return update; } - QString GetAlphaChannelTexture() { return myAlphaChannelTexture; } + QString + GetAlphaTexture() { return myAlphaTexture; } - void MakeTexture( const QString& theMainTexture, - const QString& theAlphaChannelTexture ); + void + SetTextures( const QString& theMainTexture, + const QString& theAlphaTexture ); protected: virtual @@ -98,13 +106,17 @@ namespace VISU VISU_PipeLine* GetPipeLine(); + void + MakeTexture( const QString& theMainTexture, + const QString& theAlphaTexture ); + VISU_GaussPointsPL *myGaussPointsPL; bool myIsColored; QColor myColor; QString myMainTexture; - QString myAlphaChannelTexture; + QString myAlphaTexture; public: static -- 2.39.2