1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
19 #include "SalomeApp_Tools.h"
21 #include <SUIT_Session.h>
22 #include <SUIT_Desktop.h>
23 #include <SUIT_MessageBox.h>
25 #include <utilities.h>
28 Convert QColor to Quantity_Color, if QColor is valid.
30 Quantity_Color SalomeApp_Tools::color( const QColor& c )
32 Quantity_Color aColor;
34 aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
39 Convert Quantity_Color to QColor.
41 QColor SalomeApp_Tools::color( const Quantity_Color& c )
43 return QColor( (int)( c.Red() * 255 ), (int)( c.Green() * 255 ), (int)( c.Blue() * 255 ) );
47 Gets message on exception \a S_ex.
49 QString SalomeApp_Tools::ExceptionToString( const SALOME::SALOME_Exception& S_ex )
53 switch ( S_ex.details.type )
56 case SALOME::INTERNAL_ERROR:
58 message = QString( S_ex.details.text );
59 QString source( S_ex.details.sourceFile );
61 line.setNum( S_ex.details.lineNumber );
62 message = message + " \n" + source + " : " + line;
65 case SALOME::BAD_PARAM:
67 message = QString( S_ex.details.text );
69 QString source( S_ex.details.sourceFile );
71 line.setNum( S_ex.details.lineNumber );
72 message = message + " \n" + source + " : " + line;
78 message = QString( "SALOME CORBA Exception Type invalid" );
79 QString source( S_ex.details.sourceFile );
81 line.setNum( S_ex.details.lineNumber );
82 message = message + " \n" + source + " : " + line;
90 Gets message box on exception \a S_ex.
92 void SalomeApp_Tools::QtCatchCorbaException( const SALOME::SALOME_Exception& S_ex )
94 QString message = ExceptionToString( S_ex );
98 switch ( S_ex.details.type )
101 case SALOME::INTERNAL_ERROR:
102 title = QObject::tr( "Engine Error" );
104 case SALOME::BAD_PARAM:
106 title = QObject::tr( "Engine Warning" );
109 title = QObject::tr( "Internal SALOME Error" );
114 SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(),
115 title, message, QObject::tr( "OK" ) );
117 SUIT_MessageBox::warn1( SUIT_Session::session()->activeApplication()->desktop(),
118 title, message, QObject::tr( "OK" ) );