GEOM_Displayer - Loading textures with non-ansi paths. (OCCT 6.7.0 compatibility)

This commit is contained in:
apl 2014-03-14 18:51:21 +04:00
parent 8bbd6e250f
commit 2e6cd84715
2 changed files with 21 additions and 7 deletions

View File

@ -138,6 +138,7 @@
// Hard-coded value of shape deflection coefficient for VTK viewer // Hard-coded value of shape deflection coefficient for VTK viewer
const double VTK_MIN_DEFLECTION = 0.001; const double VTK_MIN_DEFLECTION = 0.001;
#if OCC_VERSION_LARGE > 0x06070000
// Pixmap caching support // Pixmap caching support
namespace namespace
{ {
@ -258,6 +259,7 @@ namespace
} }
} }
} }
#endif
//================================================================ //================================================================
// Function : getActiveStudy // Function : getActiveStudy
@ -873,15 +875,23 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap
aImagePath = propMap.value( GEOM::propertyName( GEOM::Texture ) ).toString(); aImagePath = propMap.value( GEOM::propertyName( GEOM::Texture ) ).toString();
} }
Handle(Image_PixMap) aPixmap; if ( !aImagePath.isEmpty() ) {
if ( !aImagePath.isEmpty() ) #if OCC_VERSION_LARGE > 0x06070000
aPixmap = cacheTextureFor( aImagePath, AISShape ); Handle(Image_PixMap) aPixmap = cacheTextureFor( aImagePath, AISShape );
// apply image to shape // apply image to shape
if ( !aPixmap.IsNull() ) { if ( !aPixmap.IsNull() ) {
AISShape->SetTexturePixMap( aPixmap ); AISShape->SetTexturePixMap( aPixmap );
AISShape->SetTextureMapOn();
AISShape->DisableTextureModulate();
}
else
AISShape->SetTextureMapOff();
#else
AISShape->SetTextureFileName( TCollection_AsciiString( aImagePath.toUtf8().constData() ) );
AISShape->SetTextureMapOn(); AISShape->SetTextureMapOn();
AISShape->DisableTextureModulate(); AISShape->DisableTextureModulate();
#endif
} }
else else
AISShape->SetTextureMapOff(); AISShape->SetTextureMapOff();
@ -1948,11 +1958,13 @@ void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
UpdateColorScale(false,false); UpdateColorScale(false,false);
} }
#if OCC_VERSION_LARGE > 0x06070000
void GEOM_Displayer::BeforeErase( SALOME_View* v, const SALOME_OCCPrs* p ) void GEOM_Displayer::BeforeErase( SALOME_View* v, const SALOME_OCCPrs* p )
{ {
LightApp_Displayer::BeforeErase( v, p ); LightApp_Displayer::BeforeErase( v, p );
releaseTextures( p ); releaseTextures( p );
} }
#endif
void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p ) void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p )
{ {

View File

@ -45,7 +45,7 @@ class SALOME_OCCViewType;
#include <LightApp_Study.h> #include <LightApp_Study.h>
#include <Aspect_TypeOfMarker.hxx> #include <Aspect_TypeOfMarker.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <Basics_OCCTVersion.hxx>
#include <QList> #include <QList>
#include <list> #include <list>
@ -175,7 +175,9 @@ public:
virtual void Update( SALOME_VTKPrs* ); virtual void Update( SALOME_VTKPrs* );
virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* ); virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* ); virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
#if OCC_VERSION_LARGE > 0x06070000
virtual void BeforeErase ( SALOME_View*, const SALOME_OCCPrs* ); virtual void BeforeErase ( SALOME_View*, const SALOME_OCCPrs* );
#endif
virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* ); virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* );
/* This methos is used for activisation/deactivisation of objects to be displayed*/ /* This methos is used for activisation/deactivisation of objects to be displayed*/