7 #include "fwData/registry/macros.hpp" 8 #include "fwData/Exception.hpp" 9 #include "fwData/Color.hpp" 11 #include <fwCore/base.hpp> 27 Color::sptr Color::ColorFactory(Color::ColorType red, Color::ColorType green, Color::ColorType blue,
28 Color::ColorType alpha)
30 Color::sptr color = ::fwData::Color::New();
31 color->m_vRGBA = {red, green, blue, alpha};
45 Color::csptr other = Color::dynamicConstCast(_source);
47 "Unable to copy" + (_source ? _source->getClassname() : std::string(
"<NULL>"))
57 Color::csptr other = Color::dynamicConstCast(_source);
59 "Unable to copy" + (_source ? _source->getClassname() : std::string(
"<NULL>"))
67 void Color::setRGBA(
const ColorType red,
const ColorType green,
const ColorType blue,
const ColorType alpha )
69 m_vRGBA = {red, green, blue, alpha};
77 "Color string should start with '#' and followed by 6 ou 8 " 78 "hexadecimal digits. Given color : " << hexaColor,
80 && ( hexaColor.length() == 7 || hexaColor.length() == 9)
83 std::string redString = hexaColor.substr(1, 2);
84 std::string greenString = hexaColor.substr(3, 2);
85 std::string blueString = hexaColor.substr(5, 2);
88 std::istringstream iss;
92 iss.str (greenString);
98 if (hexaColor.length() == 9)
100 std::string alphaString = hexaColor.substr(7, 2);
102 iss.str (alphaString);
103 iss >> std::hex >> a;
106 this->
setRGBA(r/255.0f, g/255.0f, b/255.0f, a/255.0f);
111 Color::ColorType &Color::red()
116 Color::ColorType &Color::green()
121 Color::ColorType &Color::blue()
126 Color::ColorType &Color::alpha()
131 const Color::ColorType &Color::red()
const 136 const Color::ColorType &Color::green()
const 141 const Color::ColorType &Color::blue()
const 146 const Color::ColorType &Color::alpha()
const virtual FWDATA_API ~Color()
Destructor.
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
ColorArray m_vRGBA
RGBA of the image (in terms of points)
virtual const std::string & getClassname() const override
return full object's classname with its namespace, i.e. fwCore::BaseObject
This class defines color object.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
FWDATA_API Color(::fwData::Object::Key key)
Constructor.
void setRGBA(const ColorArray &_vRGBA)
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
Contains the representation of the data objects used in the framework.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)