7 #ifndef __FWDATA_CAMP_MAPPER_HPP__ 8 #define __FWDATA_CAMP_MAPPER_HPP__ 10 #include "fwData/TransferFunction.hpp" 12 #include <fwCamp/Mapper/ValueMapper.hpp> 14 #include <boost/algorithm/string.hpp> 22 typedef ::fwData::TransferFunction::TFColor
ReturnType;
23 static const int type = camp::stringType;
24 static const std::string to(
const ReturnType& source)
26 std::string result =
"";
28 std::string current = boost::lexical_cast< std::string>(source.
r);
32 current = boost::lexical_cast< std::string>(source.
g);
36 current = boost::lexical_cast< std::string>(source.
b);
40 current = boost::lexical_cast< std::string>(source.
a);
47 static ReturnType from(
bool source)
49 CAMP_ERROR(camp::BadType(camp::boolType, camp::mapType<ReturnType>()));
51 static ReturnType from(
long source)
53 CAMP_ERROR(camp::BadType(camp::intType, camp::mapType<ReturnType>()));
55 static ReturnType from(
double source)
57 CAMP_ERROR(camp::BadType(camp::realType, camp::mapType<ReturnType>()));
59 static ReturnType from(
const camp::EnumObject& source)
61 CAMP_ERROR(camp::BadType(camp::enumType, camp::mapType<ReturnType>()));
63 static ReturnType from(
const camp::UserObject& source)
65 CAMP_ERROR(camp::BadType(camp::userType, camp::mapType<ReturnType>()));
67 static ReturnType from(
const std::string& source)
69 std::vector< std::string> result;
71 ::boost::split(result, source, boost::is_any_of(
";"));
73 if(result.size() >= 4)
75 tfColor.
r = ValueMapper<float>::from(result[0]);
76 tfColor.
g = ValueMapper<float>::from(result[1]);
77 tfColor.
b = ValueMapper<float>::from(result[2]);
78 tfColor.
a = ValueMapper<float>::from(result[3]);
82 OSLM_WARN(
"Your tf color is not correctly setted, nb of component : " << result.size());
ColorType r
red color (value [0,1])
ColorType b
blue color (value [0,1])
ColorType a
alpha (value [0,1])
#define OSLM_WARN(message)
ColorType g
green color (value [0,1])
Macro for deep and shallow copies.