1 // Copyright (C) 2007-2008 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.
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
22 // File : CAF_Tools.cxx
25 #include "CAF_Tools.h"
29 \brief Prodives a set of helpful static methods.
33 \brief Convert TCollection_ExtendedString \a src to QString.
34 \param src string to be converted
35 \return resulting QString object
37 QString CAF_Tools::toQString ( const TCollection_ExtendedString& src )
39 return QString( (const QChar*)src.ToExtString(), src.Length() );
43 \brief Convert TCollection_AsciiString \a src to QString.
44 \param src string to be converted
45 \return resulting QString object
47 QString CAF_Tools::toQString( const TCollection_AsciiString& src )
49 return QString( src.ToCString() );
53 \brief Convert QString \a src to TCollection_AsciiString.
54 \param src string to be converted
55 \return resulting TCollection_AsciiString object
57 TCollection_AsciiString CAF_Tools::toAsciiString( const QString& src )
59 TCollection_AsciiString res;
61 res = TCollection_AsciiString( src.toLatin1().data() );
66 \brief Convert QString \a src to TCollection_ExtendedString.
67 \param src string to be converted
68 \return resulting TCollection_ExtendedString object
70 TCollection_ExtendedString CAF_Tools::toExtString ( const QString& src )
72 TCollection_ExtendedString result;
73 for ( int i = 0; i < (int)src.length(); i++ )
74 result.Insert( i + 1, src[ i ].unicode() );
79 \brief Convert QColor object to Quantity_Color object.
80 \param c color object in Qt format
81 \return color object in OCC format
83 Quantity_Color CAF_Tools::color( const QColor& c )
85 Quantity_Color aColor;
87 aColor = Quantity_Color( c.red() / 255., c.green() / 255.,
88 c.blue() / 255., Quantity_TOC_RGB );
93 \brief Convert Quantity_Color object to QColor object.
94 \param c color object in OCC format
95 \return color object in Qt format
97 QColor CAF_Tools::color( const Quantity_Color& c )
99 return QColor ( int( c.Red() * 255 ),
100 int( c.Green() * 255 ),
101 int( c.Blue() * 255 ) );