mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-24 19:50:33 +05:00
0052388: TC7.4.0:Texture is not correct by default
This commit is contained in:
parent
df08a82ac5
commit
e1689b8668
@ -87,11 +87,27 @@ SET(_moc_HEADERS
|
||||
GeometryGUI.h
|
||||
)
|
||||
|
||||
# --- resources ---
|
||||
|
||||
# resource files / to be processed by rcc
|
||||
SET(_rcc_RESOURCES GEOMGUI.qrc)
|
||||
|
||||
# resource files / to be processed by lrelease
|
||||
SET(_ts_RESOURCES
|
||||
GEOM_images.ts
|
||||
GEOM_msg_en.ts
|
||||
GEOM_msg_fr.ts
|
||||
GEOM_msg_ja.ts
|
||||
)
|
||||
|
||||
# --- sources ---
|
||||
|
||||
# sources / moc wrappings
|
||||
QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS})
|
||||
|
||||
# sources / rcc wrappings
|
||||
QT4_ADD_RESOURCES(_rcc_SOURCES ${_rcc_RESOURCES})
|
||||
|
||||
SET(GEOMGUI_SOURCES
|
||||
GeometryGUI.cxx
|
||||
GEOMGUI.cxx
|
||||
@ -103,18 +119,9 @@ SET(GEOMGUI_SOURCES
|
||||
GEOMGUI_CreationInfoWdg.cxx
|
||||
GEOMGUI_DimensionProperty.cxx
|
||||
${_moc_SOURCES}
|
||||
${_rcc_SOURCES}
|
||||
)
|
||||
|
||||
# --- resources ---
|
||||
|
||||
# resource files / to be processed by lrelease
|
||||
SET(GEOMGUI_RESOURCES
|
||||
GEOM_images.ts
|
||||
GEOM_msg_en.ts
|
||||
GEOM_msg_fr.ts
|
||||
GEOM_msg_ja.ts
|
||||
)
|
||||
|
||||
# --- rules ---
|
||||
|
||||
ADD_LIBRARY(GEOM ${GEOMGUI_SOURCES})
|
||||
@ -122,4 +129,4 @@ TARGET_LINK_LIBRARIES(GEOM ${_link_LIBRARIES})
|
||||
INSTALL(TARGETS GEOM EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
|
||||
|
||||
INSTALL(FILES ${GEOMGUI_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
|
||||
QT4_INSTALL_TS_RESOURCES("${GEOMGUI_RESOURCES}" "${SALOME_GEOM_INSTALL_RES_DATA}")
|
||||
QT4_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${SALOME_GEOM_INSTALL_RES_DATA}")
|
||||
|
5
src/GEOMGUI/GEOMGUI.qrc
Normal file
5
src/GEOMGUI/GEOMGUI.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>images/default_texture.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -158,6 +158,50 @@ namespace
|
||||
return aMap;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Function : imageToPixmap
|
||||
// Purpose : Concert QImage to OCCT pixmap
|
||||
//===========================================================================
|
||||
static inline Handle(Image_PixMap) imageToPixmap( const QImage& anImage )
|
||||
{
|
||||
Handle(Image_PixMap) aPixmap = new Image_PixMap();
|
||||
if ( !anImage.isNull() ) {
|
||||
aPixmap->InitTrash( Image_PixMap::ImgBGRA, anImage.width(), anImage.height() );
|
||||
aPixmap->SetTopDown( Standard_True );
|
||||
|
||||
const uchar* aImageBytes = anImage.bits();
|
||||
|
||||
for ( int aLine = anImage.height() - 1; aLine >= 0; --aLine ) {
|
||||
Image_ColorBGRA* aPixmapBytes = aPixmap->EditData<Image_ColorBGRA>().ChangeRow(aLine);
|
||||
|
||||
// convert pixels from ARGB to renderer-compatible RGBA
|
||||
for ( int aByte = 0; aByte < anImage.width(); ++aByte ) {
|
||||
aPixmapBytes->b() = (Standard_Byte) *aImageBytes++;
|
||||
aPixmapBytes->g() = (Standard_Byte) *aImageBytes++;
|
||||
aPixmapBytes->r() = (Standard_Byte) *aImageBytes++;
|
||||
aPixmapBytes->a() = (Standard_Byte) *aImageBytes++;
|
||||
aPixmapBytes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return aPixmap;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Function : getDefaultTexture
|
||||
// Purpose : Get default texture
|
||||
//===========================================================================
|
||||
static inline Handle(Image_PixMap) getDefaultTexture()
|
||||
{
|
||||
static Handle(Image_PixMap) aPixmap;
|
||||
if ( aPixmap.IsNull() ) {
|
||||
QPixmap px(":images/default_texture.png");
|
||||
if ( !px.isNull() )
|
||||
aPixmap = imageToPixmap( px.toImage() );
|
||||
}
|
||||
return aPixmap;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Function : cacheTextureFor
|
||||
// Purpose : Load and cache image for the specified presentation.
|
||||
@ -187,24 +231,7 @@ namespace
|
||||
if ( anImage.isNull() )
|
||||
return NULL;
|
||||
|
||||
aPixmap = new Image_PixMap();
|
||||
aPixmap->InitTrash( Image_PixMap::ImgBGRA, anImage.width(), anImage.height() );
|
||||
aPixmap->SetTopDown( Standard_True );
|
||||
|
||||
const uchar* aImageBytes = anImage.bits();
|
||||
|
||||
for ( int aLine = anImage.height() - 1; aLine >= 0; --aLine ) {
|
||||
Image_ColorBGRA* aPixmapBytes = aPixmap->EditData<Image_ColorBGRA>().ChangeRow(aLine);
|
||||
|
||||
// convert pixels from ARGB to renderer-compatible RGBA
|
||||
for ( int aByte = 0; aByte < anImage.width(); ++aByte ) {
|
||||
aPixmapBytes->b() = (Standard_Byte) *aImageBytes++;
|
||||
aPixmapBytes->g() = (Standard_Byte) *aImageBytes++;
|
||||
aPixmapBytes->r() = (Standard_Byte) *aImageBytes++;
|
||||
aPixmapBytes->a() = (Standard_Byte) *aImageBytes++;
|
||||
aPixmapBytes++;
|
||||
}
|
||||
}
|
||||
aPixmap = imageToPixmap( anImage );
|
||||
|
||||
aPixmapCacheMap.insert( thePath, aPixmap );
|
||||
|
||||
@ -866,7 +893,7 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap
|
||||
study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::Texture ), QString( GetTexture().c_str() ) );
|
||||
study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::DisplayMode ), 3 );
|
||||
|
||||
// Update porpeties map
|
||||
// Update propeties map
|
||||
propMap = getObjectProperties( study, entry, myViewFrame );
|
||||
}
|
||||
}
|
||||
@ -875,26 +902,29 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap
|
||||
aImagePath = propMap.value( GEOM::propertyName( GEOM::Texture ) ).toString();
|
||||
}
|
||||
|
||||
if ( !aImagePath.isEmpty() ) {
|
||||
#if OCC_VERSION_LARGE > 0x06070000
|
||||
Handle(Image_PixMap) aPixmap = cacheTextureFor( aImagePath, AISShape );
|
||||
Handle(Image_PixMap) aPixmap;
|
||||
if ( !aImagePath.isEmpty() )
|
||||
aPixmap = cacheTextureFor( aImagePath, AISShape );
|
||||
else
|
||||
aPixmap = getDefaultTexture();
|
||||
|
||||
// apply image to shape
|
||||
if ( !aPixmap.IsNull() ) {
|
||||
AISShape->SetTexturePixMap( aPixmap );
|
||||
AISShape->SetTextureMapOn();
|
||||
AISShape->DisableTextureModulate();
|
||||
}
|
||||
else
|
||||
AISShape->SetTextureMapOff();
|
||||
// apply image to shape
|
||||
if ( !aPixmap.IsNull() ) {
|
||||
AISShape->SetTexturePixMap( aPixmap );
|
||||
AISShape->SetTextureMapOn();
|
||||
AISShape->DisableTextureModulate();
|
||||
}
|
||||
else {
|
||||
AISShape->SetTextureMapOff();
|
||||
}
|
||||
#else
|
||||
if ( !aImagePath.isEmpty() ) {
|
||||
AISShape->SetTextureFileName( TCollection_AsciiString( aImagePath.toUtf8().constData() ) );
|
||||
AISShape->SetTextureMapOn();
|
||||
AISShape->DisableTextureModulate();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
AISShape->SetTextureMapOff();
|
||||
#endif
|
||||
|
||||
// set line width
|
||||
AISShape->SetWidth( HasWidth() ?
|
||||
|
@ -224,6 +224,8 @@ GeometryGUI::GeometryGUI() :
|
||||
myCreationInfoWdg = 0;
|
||||
|
||||
connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
|
||||
|
||||
Q_INIT_RESOURCE( GEOMGUI );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -2488,11 +2490,13 @@ void GeometryGUI::createPreferences()
|
||||
aModesList.append( tr("MEN_WIREFRAME") );
|
||||
aModesList.append( tr("MEN_SHADING") );
|
||||
aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
|
||||
aModesList.append( tr("MEN_TEXTURE") );
|
||||
|
||||
QList<QVariant> anIndexesList;
|
||||
anIndexesList.append(0);
|
||||
anIndexesList.append(1);
|
||||
anIndexesList.append(2);
|
||||
anIndexesList.append(3);
|
||||
|
||||
setPreferenceProperty( dispmode, "strings", aModesList );
|
||||
setPreferenceProperty( dispmode, "indexes", anIndexesList );
|
||||
|
BIN
src/GEOMGUI/images/default_texture.png
Executable file
BIN
src/GEOMGUI/images/default_texture.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Loading…
Reference in New Issue
Block a user