1 #include "SalomeApp_Tools.h"
3 #include <SUIT_Session.h>
4 #include <SUIT_Desktop.h>
5 #include <SUIT_MessageBox.h>
10 Convert QColor to Quantity_Color, if QColor is valid.
12 Quantity_Color SalomeApp_Tools::color( const QColor& c )
14 Quantity_Color aColor;
16 aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
21 Convert Quantity_Color to QColor.
23 QColor SalomeApp_Tools::color( const Quantity_Color& c )
25 return QColor( (int)( c.Red() * 255 ), (int)( c.Green() * 255 ), (int)( c.Blue() * 255 ) );
29 Gets message on exception \a S_ex.
31 QString SalomeApp_Tools::ExceptionToString( const SALOME::SALOME_Exception& S_ex )
35 switch ( S_ex.details.type )
38 case SALOME::INTERNAL_ERROR:
40 message = QString( S_ex.details.text );
41 QString source( S_ex.details.sourceFile );
43 line.setNum( S_ex.details.lineNumber );
44 message = message + " \n" + source + " : " + line;
47 case SALOME::BAD_PARAM:
49 message = QString( S_ex.details.text );
51 QString source( S_ex.details.sourceFile );
53 line.setNum( S_ex.details.lineNumber );
54 message = message + " \n" + source + " : " + line;
60 message = QString( "SALOME CORBA Exception Type invalid" );
61 QString source( S_ex.details.sourceFile );
63 line.setNum( S_ex.details.lineNumber );
64 message = message + " \n" + source + " : " + line;
72 Gets message box on exception \a S_ex.
74 void SalomeApp_Tools::QtCatchCorbaException( const SALOME::SALOME_Exception& S_ex )
76 QString message = ExceptionToString( S_ex );
80 switch ( S_ex.details.type )
83 case SALOME::INTERNAL_ERROR:
84 title = QObject::tr( "Engine Error" );
86 case SALOME::BAD_PARAM:
88 title = QObject::tr( "Engine Warning" );
91 title = QObject::tr( "Internal SALOME Error" );
96 SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(),
97 title, message, QObject::tr( "OK" ) );
99 SUIT_MessageBox::warn1( SUIT_Session::session()->activeApplication()->desktop(),
100 title, message, QObject::tr( "OK" ) );