7 #include "dataReg/parser/TransferFunction.hpp" 9 #include <fwData/Color.hpp> 10 #include <fwData/TransferFunction.hpp> 12 #include <fwRuntime/Convert.hpp> 14 #include <fwServices/macros.hpp> 16 #include <boost/property_tree/xml_parser.hpp> 28 SLM_FATAL(
"This method is deprecated, and this shouldn't be used.");
35 ::fwData::TransferFunction::sptr tf = ::fwData::TransferFunction::dynamicCast( _obj );
36 SLM_ASSERT(
"TransferFunction not instanced", tf);
38 const ConfigType config = ::fwRuntime::Convert::toPropertyTree(m_cfg).get_child(
"object");
39 if(config.count(
"colors"))
41 const ConfigType colorCfg = config.get_child(
"colors");
43 const bool isDefault = colorCfg.get(
"<xmlattr>.default",
false);
46 ::fwData::TransferFunction::sptr defaultTf = ::fwData::TransferFunction::createDefaultTF();
47 tf->deepCopy(defaultTf);
51 const auto stepsConfig = colorCfg.equal_range(
"step");
53 for (
auto itStepCfg = stepsConfig.first; itStepCfg != stepsConfig.second; ++itStepCfg)
55 const double value = itStepCfg->second.get<
double>(
"<xmlattr>.value");
56 const std::string strColor = itStepCfg->second.get<std::string>(
"<xmlattr>.color");
58 ::fwData::Color::sptr newColor = ::fwData::Color::New();
59 newColor->setRGBA(strColor);
61 const ::fwData::TransferFunction::TFColor color(newColor->red(), newColor->green(),
62 newColor->blue(), newColor->alpha());
63 tf->addTFColor(value, color);
65 tf->setWLMinMax(tf->getMinMaxTFValues());
67 if (colorCfg.count(
"<xmlattr>.isClamped"))
69 const bool isClamped = colorCfg.get<
bool>(
"<xmlattr>.isClamped");
70 tf->setIsClamped(isClamped);
Specific service for the construction of a TransferFunction and its associated services from an XML-b...
The namespace dataReg (data registration) contains classes which allow to parse the xml configuration...
virtual DATAREG_API void updating() override
Updating method : create the process object.
DATAREG_API void createConfig(::fwTools::Object::sptr _obj) override
#define SLM_FATAL(message)
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
This class defines a transfer function.
Service type for the construction of an object and associated services from an XML-based description...