Salome HOME
6c34c1e3fc94be4bbca287e4493af3fc2544e271
[modules/gui.git] / src / OCCViewer / OCCViewer.cxx
1 // Copyright (C) 2015-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // internal includes
21 #include "OCCViewer.h"
22
23 /*!
24   \brief Convert QColor object to Quantity_Color object.
25   \param c color object in Qt format
26   \return color object in OCC format
27 */
28 Quantity_Color OCCViewer::color( const QColor& c )
29 {
30   Quantity_Color aColor;
31   if ( c.isValid() )
32     aColor = Quantity_Color( c.red()   / 255., c.green() / 255.,
33                              c.blue()  / 255., Quantity_TOC_RGB );
34   return aColor;
35 }
36
37 /*!
38   \brief Convert Quantity_Color object to QColor object.
39   \param c color object in OCC format
40   \return color object in Qt format
41 */
42 QColor OCCViewer::color( const Quantity_Color& c )
43 {
44   return QColor ( int( c.Red()   * 255 ),
45                   int( c.Green() * 255 ),
46                   int( c.Blue()  * 255 ) );
47 }