Back to index

salome-gui  6.5.0
SUITApp_Application.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "SUITApp_Application.h"
00024 
00025 #include <SUIT_Tools.h>
00026 #include <SUIT_ExceptionHandler.h>
00027 
00028 #include <Qtx.h>
00029 
00030 #include <QDir>
00031 #include <QTranslator>
00032 
00033 #ifdef WIN32
00034 #include <windows.h>
00035 #include <winbase.h>
00036 #else
00037 #include <unistd.h>
00038 #endif
00039 
00043 SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand )
00044 #ifdef ENABLE_TESTRECORDER
00045   : TestApplication( argc, argv ),
00046 #else
00047 #ifndef WIN32
00048   // san: Opening an X display and choosing a visual most suitable for 3D visualization
00049   // in order to make SALOME viewers work with non-native X servers
00050   : QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ),
00051 #else
00052   : QApplication( argc, argv ), 
00053 #endif
00054 #endif
00055 myExceptHandler( hand )
00056 {
00057   QString path = SUIT_Tools::dir( argv[0] ) + QDir::separator() + "../../resources";
00058   path = QDir::convertSeparators( QDir( path ).canonicalPath() );
00059 
00060   QTranslator* strTbl = new QTranslator( 0 );
00061   if ( strTbl->load( "SUITApp_msg_en.po", path  ) )
00062     installTranslator( strTbl );
00063   else
00064     delete strTbl;
00065 }
00066 
00070 SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand )
00071 #ifdef ENABLE_TESTRECORDER
00072   : TestApplication( argc, argv ),
00073 #else
00074   : QApplication( argc, argv, type ),
00075 #endif
00076 myExceptHandler( hand )
00077 {
00078     QTranslator* strTbl = new QTranslator( 0 );
00079     strTbl->load( "resources\\SUITApp_msg_en.po" );
00080     installTranslator( strTbl );
00081 }
00082 
00089 bool SUITApp_Application::notify( QObject* receiver, QEvent* e )
00090 {
00091   return myExceptHandler ? myExceptHandler->handle( receiver, e ) :
00092 #ifdef ENABLE_TESTRECORDER
00093                            TestApplication::notify( receiver, e );
00094 #else
00095                            QApplication::notify( receiver, e );
00096 #endif
00097 }
00098 
00103 void SUITApp_Application::setHandler( SUIT_ExceptionHandler* hand )
00104 {
00105         myExceptHandler = hand;
00106 }
00107 
00111 SUIT_ExceptionHandler* SUITApp_Application::handler() const
00112 {
00113   return myExceptHandler;
00114 }