From: akl Date: Wed, 11 Dec 2013 10:01:21 +0000 (+0000) Subject: Fix of 0022437: EDF GEOM: Texture is lost when hiding and showing again a shape.... X-Git-Tag: V7_3_0~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=60b70427a45a0740400ad4e7c3bd2bf62cbd9d8d;p=modules%2Fgeom.git Fix of 0022437: EDF GEOM: Texture is lost when hiding and showing again a shape. Commit of patch from Renaud NEDELEC with one correction: don't put an empty texture property into default property map. --- diff --git a/src/EntityGUI/EntityGUI_PictureImportDlg.cxx b/src/EntityGUI/EntityGUI_PictureImportDlg.cxx index 3feaf26ad..3e521dfdb 100644 --- a/src/EntityGUI/EntityGUI_PictureImportDlg.cxx +++ b/src/EntityGUI/EntityGUI_PictureImportDlg.cxx @@ -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; } diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 25ad93b5a..8cad286d6 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -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 diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index ddc8c2e7c..b334172ed 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -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 )) { diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index eb95c26bc..d557d098c 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -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 ); } diff --git a/src/OBJECT/GEOM_Constants.cxx b/src/OBJECT/GEOM_Constants.cxx index 95a5840c2..8b89a773f 100644 --- a/src/OBJECT/GEOM_Constants.cxx +++ b/src/OBJECT/GEOM_Constants.cxx @@ -95,6 +95,8 @@ namespace GEOM "IsosColor", // - // outlines color "OutlineColor", // - + // texture + "Texture", // - }; return ( type >= GEOM::Visibility && type <= GEOM::LastProperty ) ? names[type] : QString(); } diff --git a/src/OBJECT/GEOM_Constants.h b/src/OBJECT/GEOM_Constants.h index 19b0c514f..aee0709b4 100644 --- a/src/OBJECT/GEOM_Constants.h +++ b/src/OBJECT/GEOM_Constants.h @@ -54,7 +54,8 @@ namespace GEOM PointColor, IsosColor, OutlineColor, - LastProperty = OutlineColor, + Texture, + LastProperty = Texture, }; GEOM_OBJECT_EXPORT double minDeflection();