7 #include "uiMedDataQt/SSeriesViewer.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwData/String.hpp> 12 #include <fwData/Vector.hpp> 14 #include <fwDataCamp/getObject.hpp> 16 #include <fwMedData/Series.hpp> 18 #include <fwServices/macros.hpp> 19 #include <fwServices/registry/AppConfig.hpp> 28 static const ::fwServices::IService::KeyType s_SERIES_INPUT =
"series";
47 _sstream << std::string(
"SSeriesViewer");
61 if(m_configTemplateManager)
63 m_configTemplateManager->stopAndDestroy();
64 m_configTemplateManager.reset();
72 ::fwData::Vector::csptr vector = this->getInput< ::fwData::Vector >(s_SERIES_INPUT);
76 vector = this->getObject< ::fwData::Vector >();
79 if(m_configTemplateManager)
81 m_configTemplateManager->stopAndDestroy();
82 m_configTemplateManager.reset();
85 if(vector->size() == 1)
87 ::fwData::Object::sptr obj = vector->front();
88 std::string
classname = obj->getClassname();
89 SeriesConfigMapType::iterator itr = m_seriesConfigs.find(classname);
91 if(itr != m_seriesConfigs.end())
93 SeriesConfigInfo
info = itr->second;
94 std::string configId = info.configId;
96 std::map< std::string, std::string > replaceMap;
99 replaceMap[
"GENERIC_UID"] = genericUidAdaptor;
100 replaceMap[
"WID_PARENT"] = m_parentView;
101 replaceMap[
"objectID"] = obj->getID();
103 for(
const ReplaceValuesMapType::value_type& elt : info.extractValues)
105 ::fwData::Object::sptr
object = ::fwDataCamp::getObject( obj, elt.second );
106 OSLM_ASSERT(
"Object from name "<< elt.second <<
" not found",
object);
107 replaceMap[elt.first] =
object->getID();
110 for(
const ReplaceValuesMapType::value_type& elt : info.parameters)
112 SLM_ASSERT(
"Value '" << elt.first <<
"' already used in extracted values.",
113 replaceMap.find(elt.first) == replaceMap.end());
114 replaceMap[elt.first] = elt.second;
119 m_configTemplateManager->setConfig( configId, replaceMap );
122 m_configTemplateManager->launch();
131 std::vector < ::fwRuntime::ConfigurationElement::sptr > viewCfg =
m_configuration->find(
"parentView");
132 SLM_ASSERT(
"Missing tag 'parentView'", viewCfg.size() == 1);
134 m_parentView = viewCfg[0]->getAttributeValue(
"wid");
135 SLM_ASSERT(
"'wid' attribute missing for tag 'parentView'.", !m_parentView.empty());
137 std::vector < ::fwRuntime::ConfigurationElement::sptr > configsCfg =
m_configuration->find(
"configs");
138 SLM_ASSERT(
"Missing tag 'configs'", configsCfg.size() == 1);
140 std::vector < ::fwRuntime::ConfigurationElement::sptr > config = configsCfg[0]->find(
"config");
141 SLM_ASSERT(
"Missing tag 'config'", !config.empty());
143 for(const ::fwRuntime::ConfigurationElement::sptr& elt : config)
145 SeriesConfigInfo
info;
146 info.configId = elt->getAttributeValue(
"id");
147 SLM_ASSERT(
"'id' attribute must not be empty", !info.configId.empty());
148 std::string seriesType = elt->getAttributeValue(
"type");
149 SLM_ASSERT(
"'type' attribute must not be empty", !seriesType.empty());
150 OSLM_ASSERT(
"Type " << seriesType <<
" is already defined.",
151 m_seriesConfigs.find(seriesType) == m_seriesConfigs.end() );
153 for(const ::fwRuntime::ConfigurationElement::sptr& extractElt : elt->find(
"extract"))
155 std::string path = extractElt->getAttributeValue(
"path");
156 SLM_ASSERT(
"'path' attribute must not be empty", !path.empty());
157 std::string pattern = extractElt->getAttributeValue(
"pattern");
158 SLM_ASSERT(
"'pattern' attribute must not be empty", !pattern.empty());
159 info.extractValues[pattern] = path;
162 for(const ::fwRuntime::ConfigurationElement::sptr& param : elt->find(
"parameter"))
164 std::string replace = param->getAttributeValue(
"replace");
165 SLM_ASSERT(
"'replace' attribute must not be empty", !replace.empty());
166 std::string by = param->getAttributeValue(
"by");
169 by = param->getAttributeValue(
"uid");
171 SLM_ASSERT(
"'by' attribute must not be empty", !by.empty());
172 info.parameters[replace] = by;
175 m_seriesConfigs[seriesType] =
info;
198 if (this->getInput< ::fwData::Vector >(s_SERIES_INPUT))
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
The namespace uiMedDataQt contains editors for medical data.
This class is a helper to define the connections of a service and its data.
virtual void stopping() override
Stops the config if it is running.
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
virtual void starting() override
Calls updating on starting.
virtual UIMEDDATAQT_API ~SSeriesViewer() noexcept
Destructor.
virtual UIMEDDATAQT_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_OBJECTS_SIG
Type of signal when objects are added.
virtual void configuring() override
Configures the service.
This Service allows to preview the selected series in the Vector. For the moment, it works only on a ...
This class defines a vector of objects.
This interface defines control service API. Does nothing particularly, can be considered as a default...
virtual UIMEDDATAQT_API KeyConnectionsType getObjSrvConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
virtual void info(std::ostream &_sstream) override
Write information in a stream.
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
::fwCom::helper::SigSlotConnection::KeyConnectionsType KeyConnectionsType
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
UIMEDDATAQT_API SSeriesViewer()
Constructor.
virtual void updating() override
Launch the config on the object if possible.
static const std::string & classname()
return object's classname without its namespace, i.e. BaseObject
static FWSERVICES_API std::shared_ptr< IAppConfigManager > New()
static FWSERVICES_API std::string getUniqueIdentifier(const std::string &serviceUid="")
Create an unique identifier.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_OBJECTS_SIG
Type of signal when objects are added.
static FWSERVICES_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_SLOT
Slot to call start method.