Back to index

salome-gui  6.5.0
CAF_Tools.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : CAF_Tools.cxx
00024 //  Author : UI team
00025 //
00026 #include "CAF_Tools.h"
00027 
00038 QString CAF_Tools::toQString ( const TCollection_ExtendedString& src )
00039 {
00040   return QString( (const QChar*)src.ToExtString(), src.Length() );
00041 }
00042 
00048 QString CAF_Tools::toQString( const TCollection_AsciiString& src )
00049 {
00050   return QString( src.ToCString() );
00051 }
00052 
00058 TCollection_AsciiString CAF_Tools::toAsciiString( const QString& src )
00059 {
00060   TCollection_AsciiString res;
00061   if ( !src.isEmpty() )
00062     res = TCollection_AsciiString( src.toLatin1().data() );
00063   return res;
00064 }
00065 
00071 TCollection_ExtendedString CAF_Tools::toExtString ( const QString& src )
00072 {
00073   TCollection_ExtendedString result;
00074   for ( int i = 0; i < (int)src.length(); i++ )
00075     result.Insert( i + 1, src[ i ].unicode() );
00076   return result;
00077 }
00078 
00084 Quantity_Color CAF_Tools::color( const QColor& c )
00085 {
00086   Quantity_Color aColor;
00087   if ( c.isValid() )
00088     aColor = Quantity_Color( c.red()   / 255., c.green() / 255.,
00089                              c.blue()  / 255., Quantity_TOC_RGB );
00090   return aColor;
00091 }
00092 
00098 QColor CAF_Tools::color( const Quantity_Color& c )
00099 {
00100   return QColor ( int( c.Red()   * 255 ),
00101                   int( c.Green() * 255 ),
00102                   int( c.Blue()  * 255 ) );
00103 }