fw4spl
InitQtPen.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwRenderQt/data/InitQtPen.hpp"
8 
9 #include <fwCore/base.hpp>
10 
11 namespace fwRenderQt
12 {
13 namespace data
14 {
15 
16 //---------------------------------------------------------------------------------------
17 
18 void InitQtPen::setPenColor(QPen& _pen, std::string _color)
19 {
20  QColor color(QString::fromStdString(_color));
21  if (color.isValid())
22  {
23  _pen.setColor(color);
24  }
25  else
26  {
27  // Default value: black (if the color id cannot be parsed)
28  _pen.setColor(Qt::GlobalColor(Qt::black));
29  }
30  _pen.setCosmetic(true);
31 }
32 
33 //---------------------------------------------------------------------------------------
34 
35 void InitQtPen::setPenColor(QPen& _pen, std::string _color, float _opacity)
36 {
37  InitQtPen::setPenColor( _pen, _color );
38 
39  QColor color = _pen.color();
40  color.setAlphaF( _opacity );
41  _pen.setColor( color );
42 }
43 
44 } // namespace data
45 } // namespace fwRenderQt
static FWRENDERQT_API void setPenColor(QPen &_pen, std::string _color)
Set a pen a color.
Definition: InitQtPen.cpp:18
The namespace fwRenderQt contains classes for rendering with Qt.
Definition: Axis.hpp:12