//get image
QImage buf;
- QString aPicturePath = getenv("GLViewer__Background_Picture");
+ QString aPicturePath = Qtx::getenv("GLViewer__Background_Picture");
if ( !aPicturePath.isEmpty() && buf.load( aPicturePath ) )
{ // Load first image from file
ADD_EXECUTABLE(HelpBrowser ${HelpBrowser_SOURCES})
TARGET_LINK_LIBRARIES(HelpBrowser ${_link_LIBRARIES})
INSTALL(TARGETS HelpBrowser EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
+INSTALL(FILES qt.conf DESTINATION ${SALOME_INSTALL_BINS})
#include <iostream>
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+
namespace
{
void printHelp()
}
}
+#if defined(WIN32) && defined(UNICODE)
+ LPWSTR *szArglist = NULL;
+ int nArgs;
+ int i;
+ szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
+ helpfile = QString::fromWCharArray(szArglist[nArgs-1]);
+ // Free memory allocated for CommandLineToArgvW arguments.
+ LocalFree(szArglist);
+#endif
+
// Show help and exit if '--help' or '-h' option has been specified via command line
if ( showHelp )
{
// Load file specified via command line
if ( helpfile.isEmpty() ) {
- QString docdir = qgetenv( "DOCUMENTATION_ROOT_DIR" );
+ QString docdir = Qtx::getenv( "DOCUMENTATION_ROOT_DIR" );
if ( !docdir.isEmpty() )
helpfile = QDir::toNativeSeparators( QString( "%1/index.html" ).arg( docdir ) );
}
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>COPYING</file>
- <file alias="qt/etc/qt.conf">qt.conf</file>
</qresource>
</RCC>
QString modName = moduleName( aModule ); // module name
if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir env variable
- QString modDir = getenv( rootDir.toUtf8().constData() ); // module root dir path
+ QString modDir = Qtx::getenv( rootDir.toUtf8().constData() ); // module root dir path
QString docSection;
if (resMgr->hasValue( modName, "documentation" ) )
docSection = resMgr->stringValue(modName, "documentation");
QFileInfo fi( url );
if ( fi.isRelative() && !component.isEmpty() )
{
- QString rootDir = getenv( (component + "_ROOT_DIR").toLatin1().constData() );
+ QString rootDir = Qtx::getenv( (component + "_ROOT_DIR").toLatin1().constData() );
if ( !rootDir.isEmpty() )
{
path = (QStringList() << rootDir << "share" << "doc" << "salome" << "gui" << component << url).join( QDir::separator() );
QStringList paths;
#if defined(WIN32)
- paths = QString( ::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
+ paths = QString( Qtx::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
#elif defined(__APPLE__)
- paths = QString( ::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
+ paths = QString( Qtx::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
#else
- paths = QString( ::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
+ paths = QString( Qtx::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
#endif
bool isFound = false;
#include <QFileInfo>
#include <QDir>
+#include <Qtx.h>
+
#ifdef WIN32
#include <time.h>
#endif
#include "PVViewer_Behaviors.h"
#include "PVViewer_Core.h"
+#include <Qtx.h>
+
#include <QApplication>
#include <QStringList>
#include <QDir>
// Obtain command-line arguments
int argc = 0;
char** argv = 0;
- QString aOptions = getenv("PARAVIEW_OPTIONS");
+ QString aOptions = Qtx::getenv("PARAVIEW_OPTIONS");
QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts);
argv = new char*[aOptList.size() + 4]; // add one, MPI requires argv[argc] = 0!
for (int i =0; i< aOptList.size() + 4; i++)
std::stringstream msg;
// Try to connect to the external PVServer - gives priority to an externally specified URL:
- QString serverUrlEnv = getenv("PARAVIEW_PVSERVER_URL");
+ QString serverUrlEnv = Qtx::getenv("PARAVIEW_PVSERVER_URL");
std::string serverUrl;
if (!serverUrlEnv.isEmpty())
{
#include <stdarg.h>
#include <clocale>
+#ifdef WIN32
+#include <windows.h>
+#define MAX_VALUE_SIZE 32767 // Limit according to http://msdn.microsoft.com/en-us/library/ms683188.aspx
+#endif
+
+#include <iostream>
+
#define BICOLOR_CHANGE_HUE
/*!
*/
QString Qtx::tmpDir()
{
- const char* tmpdir = ::getenv( "TEMP" );
- if ( !tmpdir )
- tmpdir = ::getenv ( "TMP" );
- if ( !tmpdir )
+ QString tmpdir = getenv( "TEMP" );
+ if ( tmpdir.isEmpty() )
+ tmpdir = getenv ( "TMP" );
+ if ( tmpdir.isEmpty() )
{
#ifdef WIN32
- tmpdir = "C:\\";
+ tmpdir = QString("C:\\");
#else
- tmpdir = "/tmp";
+ tmpdir = QString("/tmp");
#endif
}
- return QString( tmpdir );
+ return tmpdir;
}
/*!
break;
QString newStr;
- if ( ::getenv( envName.toUtf8() ) || mode == Always )
- newStr = QString( ::getenv( envName.toUtf8() ) );
+ if ( getenv( envName ).isEmpty() || mode == Always )
+ newStr = QString( getenv( envName ) );
if ( newStr.isNull() )
{
QString Qtx::qtDir( const QString& context )
{
- const char* vars[] = { "QT5_ROOT_DIR", "QT4_ROOT_DIR", "QT_ROOT_DIR", "QTDIR" };
+
+ QStringList vars = { "QT5_ROOT_DIR", "QT4_ROOT_DIR", "QT_ROOT_DIR", "QTDIR" };
QString qtPath;
- for (uint i = 0; i < sizeof(vars)/sizeof(vars[0]) && qtPath.isEmpty(); i++ )
- qtPath = qgetenv( vars[i] );
+ for (uint i = 0; i < vars.length() && qtPath.isEmpty(); i++ ) {
+ qtPath = getenv(vars[i]);
+ }
if ( !qtPath.isEmpty() && !context.isEmpty() )
qtPath = QDir( qtPath ).absoluteFilePath( context );
return qtPath;
return font;
}
+QString Qtx::getenv(const QString & envVar)
+{
+ QString value;
+#ifndef WIN32
+ value = qgetenv(envVar.toLocal8Bit().constData());
+#else
+ LPTSTR buff = new TCHAR[MAX_VALUE_SIZE];
+#ifdef UNICODE
+ LPTSTR anEnvVar = new TCHAR[envVar.length() + 1];
+ anEnvVar[envVar.toWCharArray(anEnvVar)] = '\0';
+#else
+ const TCHAR* anEnvVar = envVar.toLocal8Bit(buff).constData();
+#endif
+ const DWORD ret = GetEnvironmentVariable(anEnvVar, buff, MAX_VALUE_SIZE);
+ buff[ret] = '\0';
+ if (ret > 0) {
+#ifdef UNICODE
+ value = QString::fromWCharArray(buff);
+#else
+ value = QString::fromLocal8Bit(buff);
+#endif
+ }
+ delete buff;
+#ifdef UNICODE
+ delete anEnvVar;
+#endif
+#endif
+ return value;
+}
+
#if !defined WIN32 && !defined __APPLE__
#include <X11/Xlib.h>
static QFont stringToFont( const QString& fontDescription );
+ static QString getenv( const QString& envVar );
+
#ifndef WIN32
static void* getDisplay();
static Qt::HANDLE getVisual();
QString newStr = constants.value( envName, QString() );
// Then we check for environment variable
- if ( newStr.isEmpty() && ::getenv( envName.toLatin1() ) )
- newStr = QString( ::getenv( envName.toLatin1() ) );
+ QString tmpValue = Qtx::getenv( envName );
+ if ( newStr.isEmpty() && !tmpValue.isEmpty() )
+ newStr = tmpValue;
if ( newStr.isEmpty() )
{
envVar = envVar.arg( appName );
QString dirs;
- if ( ::getenv( envVar.toLatin1() ) )
- dirs = ::getenv( envVar.toLatin1() );
+ QString tmpValue = Qtx::getenv( envVar );
+ if ( !tmpValue.isEmpty() )
+ dirs = tmpValue;
#ifdef WIN32
QString dirsep = ";"; // for Windows: ";" is used as directories separator
#else
#include <math.h>
+#include <Qtx.h>
+
#ifdef WIN32
#include <UserEnv.h>
#endif
{
setObjectName( name );
setModal( modal );
- QString env;
- if ( ::getenv( "SALOME_LICENSE_FILE" ) )
- env = ::getenv( "SALOME_LICENSE_FILE" );
-
+ QString env = Qtx::getenv( "SALOME_LICENSE_FILE" );
QFile file( env ); // Read the text from a file
if ( !file.exists() || !file.open( QIODevice::ReadOnly ) )
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <Qtx.h>
+
#include <QtxDoubleSpinBox.h>
#include <QtxIntSpinBox.h>
aFilter.append( tr( "FLT_AVI_FILES" ) );
aFilter.append( tr( "FLT_ALL_FILES" ) );
- QString aFileName = SUIT_FileDlg::getFileName( this, getenv( "HOME" ), aFilter,
+ QString aFileName = SUIT_FileDlg::getFileName( this, Qtx::getenv( "HOME" ), aFilter,
tr( "FILE_NAME" ), false );
if( aFileName.isNull() )
#ifdef WIN32
#define sleep _sleep
+#include <windows.h>
+#include <stdio.h>
+#include <shellapi.h>
#endif
#include <time.h>
#include <QRegExp>
#include <QTextStream>
+#include <Basics_Utils.hxx>
+
/*! - read arguments, define list of server to launch with their arguments.
* - wait for naming service
* - create and run a thread for launch of all servers
_qappl.setApplicationVersion( salomeVersion() );
// Add application library path (to search style plugin etc...)
- QString path = QDir::toNativeSeparators( SUIT_Tools::addSlash( QString( ::getenv( "GUI_ROOT_DIR" ) ) ) + QString( "bin/salome" ) );
+ QString path = QDir::toNativeSeparators( SUIT_Tools::addSlash( QString( Qtx::getenv( "GUI_ROOT_DIR" ) ) ) + QString( "bin/salome" ) );
_qappl.addLibraryPath( path );
bool isGUI = isFound( "GUI", argc, argv );
SALOME_NamingService* _NS = 0;
GetInterfaceThread* guiThread = 0;
Session_ServerLauncher* myServerLauncher = 0;
-
+#if defined(WIN32) && defined(UNICODE)
+ char** new_argv = NULL;
+#endif
try {
// ...initialize Python (only once)
int _argc = 1;
// ...lock mutex to block embedded servers launching thread until wait( mutex )
_GUIMutex.lock();
// ...create launcher
+#if defined(WIN32) && defined(UNICODE)
+ LPWSTR *szArglist = NULL;
+ int nArgs;
+ int i;
+ szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
+ new_argv = new char*[nArgs];
+ for (i = 0; i < nArgs; i++) {
+ new_argv[i] = (char*) Kernel_Utils::utf8_encode(szArglist[i]);
+ }
+ // Free memory allocated for CommandLineToArgvW arguments.
+ LocalFree(szArglist);
+ myServerLauncher = new Session_ServerLauncher(nArgs, new_argv, orb, poa, &_GUIMutex, &_ServerLaunch, &_SessionMutex, &_SessionStarted);
+#else
myServerLauncher = new Session_ServerLauncher( argc, argv, orb, poa, &_GUIMutex, &_ServerLaunch, &_SessionMutex, &_SessionStarted );
+#endif
// ...block this thread until launcher is ready
_ServerLaunch.wait( &_GUIMutex );
delete guiThread;
delete myServerLauncher;
delete _NS;
+#if defined(WIN32) && defined(UNICODE)
+ delete[] new_argv;
+#endif
try {
orb->shutdown(0);
Style_ResourceMgr::Style_ResourceMgr()
: QtxResourceMgr( "SalomeStyle", "%1Config" )
{
- if ( dirList().isEmpty() && ::getenv( "GUI_ROOT_DIR" ) )
- setDirList( QStringList() << Qtx::addSlash( ::getenv( "GUI_ROOT_DIR" ) ) + "share/salome/resources/gui" );
+ QString gui_root = Qtx::getenv( "GUI_ROOT_DIR" );
+ if ( dirList().isEmpty() && !gui_root.isEmpty() )
+ setDirList( QStringList() << Qtx::addSlash( gui_root ) + "share/salome/resources/gui" );
setCurrentFormat( "xml" );
}
#include <QIntValidator>
#include <QFile>
+#include <Qtx.h>
+
#include <OSD_Process.hxx>
#include <OSD_Path.hxx>
#include <TCollection_AsciiString.hxx>
}
else {
QString command = "";
- if ( getenv("KERNEL_ROOT_DIR") )
- command = QString( getenv( "KERNEL_ROOT_DIR" ) ) + "/bin/salome/runIDLparser -K " + IDLpath + " -Wbcatalog=" + XmlFile;
+ QString kernel_root = Qtx::getenv("KERNEL_ROOT_DIR");
+ if ( !kernel_root.isEmpty() )
+ command = kernel_root + "/bin/salome/runIDLparser -K " + IDLpath + " -Wbcatalog=" + XmlFile;
else {
SUIT_MessageBox::critical( this,
tr("TOOLS_ERR_ERROR"),
#include "VTKViewer_OpenGLHelper.h"
+#include <Basics_Utils.hxx>
#ifndef WIN32
# ifndef GLX_GLXEXT_LEGACY
{
char* readFromFile( std::string fileName )
{
+#if defined(WIN32) && defined(UNICODE)
+ const wchar_t* wFileName = Kernel_Utils::utf8_decode( fileName.c_str() );
+ FILE* file = _wfopen( wFileName, L"r" );
+#else
FILE* file = fopen( fileName.c_str(), "r" );
-
+#endif
char* content = NULL;
int count = 0;
#include <vtkOpenGL.h>
#include <vtkObjectFactory.h>
+#include <Basics_Utils.hxx>
+
vtkStandardNewMacro(VTKViewer_OpenGLRenderer);
VTKViewer_OpenGLRenderer::VTKViewer_OpenGLRenderer()
{
if (this->BackgroundProgram == 0)
{
- std::string filePath = std::string( getenv( "GUI_ROOT_DIR") ) + "/share/salome/resources/gui/Background";
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring wFilePath = std::wstring( _wgetenv(L"GUI_ROOT_DIR") ) + L"/share/salome/resources/gui/Background";
+ std::string filePath = Kernel_Utils::utf8_encode_s( wFilePath );
+#else
+ std::string filePath = std::string(getenv("GUI_ROOT_DIR")) + "/share/salome/resources/gui/Background";
+#endif
+
if (!this->OpenGLHelper.CreateShaderProgram (filePath,
this->BackgroundProgram,
this->BackgroundVertexShader,
#include <vtkCommand.h>
#include <vtkCellData.h>
+#include <Basics_Utils.hxx>
+
#ifndef WIN32
# ifndef GLX_GLXEXT_LEGACY
# define GLX_GLXEXT_LEGACY
int VTKViewer_PolyDataMapper::InitShader()
{
#ifdef VTK_OPENGL2
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring wFilePath = std::wstring(_wgetenv(L"GUI_ROOT_DIR")) + L"/share/salome/resources/gui/Point";
+ std::string filePath = Kernel_Utils::utf8_encode_s(wFilePath.c_str());
+#else
std::string filePath = std::string( getenv( "GUI_ROOT_DIR") ) + "/share/salome/resources/gui/Point";
+#endif
if( !this->OpenGLHelper.CreateShaderProgram(filePath, this->PointProgram, this->VertexShader, this->FragmentShader) )
return false;
this->OpenGLHelper.vglUseProgramObjectARB( current_program );
this->OpenGLHelper.vglGenVertexArraysARB(1, &this->VertexArrayObject);
+#else
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring wFilePath = std::wstring(_wgetenv( L"GUI_ROOT_DIR" ) ) + L"/share/salome/resources/gui/Vertex_Program_ARB.txt";
+ std::string fileName = Kernel_Utils::utf8_encode( wFilePath.c_str() );
#else
std::string fileName = std::string( getenv( "GUI_ROOT_DIR") ) +
"/share/salome/resources/gui/Vertex_Program_ARB.txt";
+#endif
char* shader = GUI_OPENGL::readFromFile( fileName );