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 "SUIT_Tools.h"
31 Traces output to log-file.
32 If log is NULL, 'Salome_trace' file is created in temp directory.
33 Log file is written in 'append' mode.
35 void SUIT_Tools::trace( const char* lpszLog, const char* lpszFormat, ... )
37 QString tmpPath = tmpDir();
38 if ( !tmpPath.isEmpty() )
39 tmpPath += QDir::separator();
41 tmpPath += QString( "Salome_trace" );
44 pStream = fopen( lpszLog ? lpszLog : (const char*)tmpPath.toLatin1(), "a" );
48 va_start( argptr, lpszFormat );
49 fprintf( pStream, "- Trace %s [%d] : %s", __FILE__, __LINE__, lpszFormat );
57 Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) )
58 and BottomRight = ( TopLeft + (x2-x1)(y2-y1) )
60 QRect SUIT_Tools::makeRect( const int x1, const int y1, const int x2, const int y2 )
62 return QRect( qMin( x1, x2 ), qMin( y1, y2 ), qAbs( x2 - x1 ), qAbs( y2 - y1 ) );
66 Creates font's string description
68 QString SUIT_Tools::fontToString( const QFont& font )
70 return font.toString();
74 Center widget 'src' relative to widget 'ref'.
76 void SUIT_Tools::centerWidget( QWidget* src, const QWidget* ref )
78 SUIT_Tools::alignWidget( src, ref, Qt::AlignCenter );