int textureMode = bgData.texture( fileName );
QFileInfo fi( fileName );
if ( !fileName.isEmpty() && fi.exists() ) {
- // read texture from file
- QString extension = fi.suffix().toLower();
- vtkImageReader2* aReader = 0;
- if ( extension == "jpg" || extension == "jpeg" )
- aReader = vtkJPEGReader::New();
- else if ( extension == "bmp" )
- aReader = vtkBMPReader::New();
- else if ( extension == "tif" || extension == "tiff" )
- aReader = vtkTIFFReader::New();
- else if ( extension == "png" )
- aReader = vtkPNGReader::New();
- else if ( extension == "mhd" || extension == "mha" )
- aReader = vtkMetaImageReader::New();
- if ( aReader ) {
- // create texture
- aReader->SetFileName( fi.absoluteFilePath().toUtf8().constData() );
- aReader->Update();
- VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
- vtkImageMapToColors* aMap = 0;
- vtkAlgorithmOutput* anOutput;
- /*
- // special processing for BMP reader
- vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
- if ( aBMPReader ) {
- // Special processing for BMP file
- aBMPReader->SetAllow8BitBMP(1);
-
- aMap = vtkImageMapToColors::New();
- aMap->SetInputConnection( aBMPReader->GetOutputPort() );
- aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
- aMap->SetOutputFormatToRGB();
-
- anOutput = aMap->GetOutputPort();
- }
- else {
- }
- */
- anOutput = aReader->GetOutputPort( 0 );
- aTexture->SetInputConnection( anOutput );
- // set texture mode
- // VSR: Currently, VTK only supports Stretch mode, so below code will give
- // the same results for all modes
- switch ( textureMode ) {
- case Qtx::TileTexture:
- aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
- break;
- case Qtx::StretchTexture:
- aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
- break;
- case Qtx::CenterTexture:
- aTexture->SetPosition((int)VTKViewer_Texture::Centered);
- default:
- break;
- }
- // show textured background
- getRenderer()->SetTexturedBackground( true );
- getRenderer()->SetBackgroundTexture( aTexture );
-
- // clean-up resources
- if ( aMap )
- aMap->Delete();
- aReader->Delete();
- aTexture->Delete();
- ok = true;
- }
+ // read texture from file
+ QString extension = fi.suffix().toLower();
+ vtkImageReader2* aReader = 0;
+ if ( extension == "jpg" || extension == "jpeg" )
+ aReader = vtkJPEGReader::New();
+ else if ( extension == "bmp" )
+ aReader = vtkBMPReader::New();
+ else if ( extension == "tif" || extension == "tiff" )
+ aReader = vtkTIFFReader::New();
+ else if ( extension == "png" )
+ aReader = vtkPNGReader::New();
+ else if ( extension == "mhd" || extension == "mha" )
+ aReader = vtkMetaImageReader::New();
+ if ( aReader ) {
+ // create texture
- aReader->SetFileName( fi.absoluteFilePath().toLatin1().constData() );
++ aReader->SetFileName( fi.absoluteFilePath().toUtf8().constData() );
+ aReader->Update();
+ VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
+ vtkImageMapToColors* aMap = 0;
+ vtkAlgorithmOutput* anOutput;
+ /*
+ // special processing for BMP reader
+ vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
+ if ( aBMPReader ) {
+ // Special processing for BMP file
+ aBMPReader->SetAllow8BitBMP(1);
+
+ aMap = vtkImageMapToColors::New();
+ aMap->SetInputConnection( aBMPReader->GetOutputPort() );
+ aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
+ aMap->SetOutputFormatToRGB();
+
+ anOutput = aMap->GetOutputPort();
+ }
+ else {
+ }
+ */
+ anOutput = aReader->GetOutputPort( 0 );
+ aTexture->SetInputConnection( anOutput );
+ // set texture mode
+ // VSR: Currently, VTK only supports Stretch mode, so below code will give
+ // the same results for all modes
+ switch ( textureMode ) {
+ case Qtx::TileTexture:
+ aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
+ break;
+ case Qtx::StretchTexture:
+ aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
+ break;
+ case Qtx::CenterTexture:
+ aTexture->SetPosition((int)VTKViewer_Texture::Centered);
+ default:
+ break;
+ }
+ // show textured background
+ getRenderer()->SetTexturedBackground( true );
+ getRenderer()->SetBackgroundTexture( aTexture );
+
+ // clean-up resources
+ if ( aMap )
+ aMap->Delete();
+ aReader->Delete();
+ aTexture->Delete();
+ ok = true;
+ }
}
}
}
script.remove( QRegExp("^python.*[\\s]+") );
QString cmd = script+" "+args;
- QString command = QString( "exec(open(\"%1\",encoding='utf-8').read())" ).arg(cmd.trimmed());
++
+ QString command = QString( "exec(open(\"%1\", \"rb\").read())" ).arg(cmd.trimmed());
pyConsole->exec(command);
}
} // end for loop on pyfiles QStringList
if ( !aFile.isEmpty() )
{
- QString command = QString("exec(open(\"%1\",encoding='utf-8').read())").arg(aFile);
++
+ QString command = QString("exec(open(\"%1\", \"rb\").read())").arg(aFile);
#ifndef DISABLE_PYCONSOLE
PyConsole_Console* pyConsole = pythonConsole();
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
// load study from the temporary directory
- QString command = QString( "exec(open(\"%1\",encoding='utf-8').read())" ).arg( theDumpScript );
++
+ QString command = QString( "exec(open(\"%1\" ,\"rb\").read())" ).arg( theDumpScript );
#ifndef DISABLE_PYCONSOLE
PyConsole_Console* pyConsole = app->pythonConsole();