1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "SalomeApp_Tools.h"
24 #include <SUIT_Session.h>
25 #include <SUIT_Desktop.h>
26 #include <SUIT_MessageBox.h>
28 #include <utilities.h>
33 #include <Quantity_Color.hxx>
36 Convert QColor to Quantity_Color, if QColor is valid.
38 Quantity_Color SalomeApp_Tools::color( const QColor& c )
40 Quantity_Color aColor;
42 aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
47 Convert Quantity_Color to QColor.
49 QColor SalomeApp_Tools::color( const Quantity_Color& c )
51 return QColor( (int)( c.Red() * 255 ), (int)( c.Green() * 255 ), (int)( c.Blue() * 255 ) );
55 Gets message on exception \a S_ex.
57 QString SalomeApp_Tools::ExceptionToString( const SALOME::SALOME_Exception& S_ex )
61 switch ( S_ex.details.type )
64 case SALOME::INTERNAL_ERROR:
66 message = QString( S_ex.details.text );
67 QString source( S_ex.details.sourceFile );
69 line.setNum( S_ex.details.lineNumber );
70 message = message + " \n" + source + " : " + line;
73 case SALOME::BAD_PARAM:
75 message = QString( S_ex.details.text );
77 QString source( S_ex.details.sourceFile );
79 line.setNum( S_ex.details.lineNumber );
80 message = message + " \n" + source + " : " + line;
86 message = QString( "SALOME CORBA Exception Type invalid" );
87 QString source( S_ex.details.sourceFile );
89 line.setNum( S_ex.details.lineNumber );
90 message = message + " \n" + source + " : " + line;
98 Gets message box on exception \a S_ex.
100 void SalomeApp_Tools::QtCatchCorbaException( const SALOME::SALOME_Exception& S_ex )
102 QString message = ExceptionToString( S_ex );
106 switch ( S_ex.details.type )
109 case SALOME::INTERNAL_ERROR:
110 title = QObject::tr( "Engine Error" );
112 case SALOME::BAD_PARAM:
114 title = QObject::tr( "Engine Warning" );
117 title = QObject::tr( "Internal SALOME Error" );
122 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
125 SUIT_MessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(),