]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
SetTextures() method added
authorouv <ouv@opencascade.com>
Fri, 23 Sep 2005 13:08:45 +0000 (13:08 +0000)
committerouv <ouv@opencascade.com>
Fri, 23 Sep 2005 13:08:45 +0000 (13:08 +0000)
src/VISU_I/VISU_GaussPoints_i.cc
src/VISU_I/VISU_GaussPoints_i.hh

index 389b38edfc917994613e1f61992046bfe3f32bd5..68e6be9f9a367cb4573967365556b30b08077d99 100644 (file)
@@ -223,6 +223,9 @@ VISU::GaussPoints_i
   myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(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();
index 916c1f95bd03199d4b56ff5ed5a79a840306db03..c3b9e612fd6903421caa91a3478f3f22f6ef6d4f 100644 (file)
@@ -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