1 #include "SUIT_Tools.h"
9 Traces output to log-file.
10 If log is NULL, 'Salome_trace' file is created in temp directory.
11 Log file is written in 'append' mode.
13 void SUIT_Tools::trace( const char* lpszLog, const char* lpszFormat, ... )
15 QString tmpPath = tmpDir();
16 if ( !tmpPath.isEmpty() )
17 tmpPath += QDir::separator();
19 tmpPath += QString( "Salome_trace" );
22 pStream = fopen( lpszLog ? lpszLog : tmpPath.latin1(), "a" );
26 va_start( argptr, lpszFormat );
27 fprintf( pStream, "- Trace %s [%d] : %s", __FILE__, __LINE__, lpszFormat );
35 Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) )
36 and BottomRight = ( TopLeft + (x2-x1)(y2-y1) )
38 QRect SUIT_Tools::makeRect( const int x1, const int y1, const int x2, const int y2 )
40 return QRect( QMIN( x1, x2 ), QMIN( y1, y2 ), QABS( x2 - x1 ), QABS( y2 - y1 ) );
44 Creates font from string description
46 QFont SUIT_Tools::stringToFont( const QString& fontDescription )
49 if ( fontDescription.stripWhiteSpace().isEmpty() || !font.fromString( fontDescription ) )
50 font = QFont( "Courier", 11 );
55 Creates font's string description
57 QString SUIT_Tools::fontToString( const QFont& font )
59 return font.toString();
63 Center widget 'src' relative to widget 'ref'.
65 void SUIT_Tools::centerWidget( QWidget* src, const QWidget* ref )
67 SUIT_Tools::alignWidget( src, ref, Qt::AlignCenter );