1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
23 #include "SalomeApp_Tools.h"
25 #include <SUIT_Session.h>
26 #include <SUIT_Desktop.h>
27 #include <SUIT_MessageBox.h>
29 #include <utilities.h>
34 #include <Quantity_Color.hxx>
37 Convert QColor to Quantity_Color, if QColor is valid.
39 Quantity_Color SalomeApp_Tools::color( const QColor& c )
41 Quantity_Color aColor;
43 aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
48 Convert Quantity_Color to QColor.
50 QColor SalomeApp_Tools::color( const Quantity_Color& c )
52 return QColor( (int)( c.Red() * 255 ), (int)( c.Green() * 255 ), (int)( c.Blue() * 255 ) );
56 Gets message on exception \a S_ex.
58 QString SalomeApp_Tools::ExceptionToString( const SALOME::SALOME_Exception& S_ex )
62 switch ( S_ex.details.type )
65 case SALOME::INTERNAL_ERROR:
67 message = QString( S_ex.details.text );
68 QString source( S_ex.details.sourceFile );
70 line.setNum( S_ex.details.lineNumber );
71 message = message + " \n" + source + " : " + line;
74 case SALOME::BAD_PARAM:
76 message = QString( S_ex.details.text );
78 QString source( S_ex.details.sourceFile );
80 line.setNum( S_ex.details.lineNumber );
81 message = message + " \n" + source + " : " + line;
87 message = QString( "SALOME CORBA Exception Type invalid" );
88 QString source( S_ex.details.sourceFile );
90 line.setNum( S_ex.details.lineNumber );
91 message = message + " \n" + source + " : " + line;
99 Gets message box on exception \a S_ex.
101 void SalomeApp_Tools::QtCatchCorbaException( const SALOME::SALOME_Exception& S_ex )
103 QString message = ExceptionToString( S_ex );
107 switch ( S_ex.details.type )
110 case SALOME::INTERNAL_ERROR:
111 title = QObject::tr( "Engine Error" );
113 case SALOME::BAD_PARAM:
115 title = QObject::tr( "Engine Warning" );
118 title = QObject::tr( "Internal SALOME Error" );
123 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
126 SUIT_MessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(),