]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix of 0022437: EDF GEOM: Texture is lost when hiding and showing again a shape....
authorakl <akl@opencascade.com>
Wed, 11 Dec 2013 10:01:21 +0000 (10:01 +0000)
committerakl <akl@opencascade.com>
Wed, 11 Dec 2013 10:01:21 +0000 (10:01 +0000)
src/EntityGUI/EntityGUI_PictureImportDlg.cxx
src/GEOMGUI/GEOM_Displayer.cxx
src/GEOMGUI/GeometryGUI.cxx
src/GEOMToolsGUI/GEOMToolsGUI_1.cxx
src/OBJECT/GEOM_Constants.cxx
src/OBJECT/GEOM_Constants.h

index 3feaf26adbcd73fc023822feb571df9ae610c1e7..3e521dfdbdffde7f3f9536ee942e4a4acd7d1ae5 100644 (file)
@@ -184,12 +184,15 @@ bool EntityGUI_PictureImportDlg::execute( ObjectList& objects )
   int height            =  pixmap->height();
   int width             =  pixmap->width();
   
+  delete pixmap;
+  
   GEOM::GEOM_Object_var P1 = aBasicOperations->MakePointXYZ( -0.5*width, -0.5*height, 0 );
   GEOM::GEOM_Object_var P2 = aBasicOperations->MakePointXYZ( -0.5*width,  0.5*height, 0 );
   GEOM::GEOM_Object_var P3 = aBasicOperations->MakePointXYZ(  0.5*width,  0.5*height, 0 );
   GEOM::GEOM_Object_var P4 = aBasicOperations->MakePointXYZ(  0.5*width, -0.5*height, 0 );
   
   GEOM::GEOM_Object_var aFace = aBlocksOperations->MakeQuad4Vertices(P1,P2,P3,P4);
+  getDisplayer()->SetDisplayMode(3);
   getDisplayer()->SetTexture(theImgFileName.toStdString());
   
   if ( !aFace->_is_nil() )
@@ -198,8 +201,7 @@ bool EntityGUI_PictureImportDlg::execute( ObjectList& objects )
   }
   
   res=true;
-
+  
   return res;
 }
 
index 25ad93b5a499797965365a51d99df7d77e412365..8cad286d61de77ff463189fa5fb170b042c93fc6 100644 (file)
@@ -697,12 +697,36 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap
   AISShape->SetOwnDeviationCoefficient( qMax( propMap.value( GEOM::propertyName( GEOM::Deflection ) ).toDouble(), GEOM::minDeflection() ) );
 
   // set texture
+  bool textureAdded = false;
   if ( HasTexture() ) {
     // predefined display texture, manually set to displayer via GEOM_Displayer::SetTexture() function 
     AISShape->SetTextureFileName( TCollection_AsciiString( GetTexture().c_str() ) );
+    if ( ! entry.isEmpty() ) {
+      // check that study is active
+      SalomeApp_Study* study = getActiveStudy();
+      if ( study ) {
+        // Store the texture in object properties for next displays
+        study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::Texture ), QString( GetTexture().c_str() ) );
+        study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::DisplayMode ), 3 );
+        
+        // Update porpeties map
+        propMap = getObjectProperties( study, entry, myViewFrame );
+      }
+    }
+    textureAdded = true;
+  }
+  else {
+    // Texture from properties
+    QString aTexture = propMap.value( GEOM::propertyName( GEOM::Texture ) ).toString();
+    if ( !aTexture.isEmpty() ) {
+       AISShape->SetTextureFileName( TCollection_AsciiString( aTexture.toStdString().c_str() ) );
+       textureAdded = true;
+    }
+  }
+  if ( textureAdded ){ 
     AISShape->SetTextureMapOn();
     AISShape->DisableTextureModulate();
-    AISShape->SetDisplayMode( 3 );
   }
 
   // set line width
index ddc8c2e7ce86967992ffad192a3e20be64d4e6bd..b334172ed1daba79cdf9088392ecf370b732f4de 100644 (file)
@@ -2671,6 +2671,11 @@ void GeometryGUI::storeVisualParameters (int savePoint)
           param = occParam + GEOM::propertyName( GEOM::Color );
           ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
         }
+        
+        if (aProps.contains(GEOM::propertyName( GEOM::Texture ))) {
+          param = occParam + GEOM::propertyName( GEOM::Texture );
+          ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Texture )).toString().toStdString());
+        }
 
         if (vType == SVTK_Viewer::Type()) {
           if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
@@ -2821,6 +2826,8 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
           QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
           aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
         }
+      } else if (paramNameStr == GEOM::propertyName( GEOM::Texture )) {
+        aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val );
       } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
       } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
index eb95c26bc5fd3dd6681fb7e41c8708e6896532a0..d557d098c77eb47fb1fe1103204bc4bbcca57526 100644 (file)
@@ -298,9 +298,9 @@ void GEOMToolsGUI::OnTexture()
 
   QString aTexture = QFileDialog::getOpenFileName( dynamic_cast< SUIT_ViewWindow* >( window ),tr("GEOM_SELECT_IMAGE"),QString(), tr("OCC_TEXTURE_FILES"));
   if( !aTexture.isEmpty() ) {
-    displayer.SetTexture( aTexture.toStdString() );
     for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
       Handle( SALOME_InteractiveObject ) io = It.Value();
+      appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Texture ), aTexture );
       appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::DisplayMode ), 3 );
       if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
     }
index 95a5840c2c7ae5717322aa479a8216e630bd3b16..8b89a773f97f63dc42eaef0a2045596c9fb9e9b8 100644 (file)
@@ -95,6 +95,8 @@ namespace GEOM
       "IsosColor",       // -
       // outlines color
       "OutlineColor",    // -
+      // texture
+      "Texture",         // -
     };
     return ( type >= GEOM::Visibility && type <= GEOM::LastProperty ) ? names[type] : QString();
   }
index 19b0c514fc4ba5989c5ae9b7621f0d0743d7463f..aee0709b4ab2152cd8bdf147aebf0caf55a53567 100644 (file)
@@ -54,7 +54,8 @@ namespace GEOM
     PointColor,
     IsosColor,
     OutlineColor,
-    LastProperty = OutlineColor,
+    Texture,
+    LastProperty = Texture,
   };
 
   GEOM_OBJECT_EXPORT double minDeflection();