Commit 199565a6 authored by Emilie Harquel's avatar Emilie Harquel
Browse files

see #1863 : Fixed SSynchronizeWindowingTF : set default BW TF if selected TF...

see #1863 : Fixed SSynchronizeWindowingTF : set default BW TF if selected TF is not found (deleted by editor)

--HG--
branch : fw4spl_0.7.9
parent 30729291
......@@ -23,9 +23,9 @@ namespace ctrlSelection
* @date 2011.
*
* A selected TF name is stored in a field. There is a default selection fields (id = ::fwComEd::Dictionary::m_transfertFunctionId).
* Specific selection fiels are given in service configuration.
* Specific selection fields are given in service configuration.
*
* @note This service must have a high communication channel priority, it must synchronize TF before visualisation.
* @note This service must have a high communication channel priority, it must synchronize TF before visualization.
*/
class CTRLSELECTION_CLASS_API SSynchronizeWindowingTF : public ::fwServices::IController
{
......
......@@ -6,14 +6,15 @@
#include <boost/foreach.hpp>
#include <fwServices/Base.hpp>
#include <fwData/Image.hpp>
#include <fwData/Integer.hpp>
#include <fwData/String.hpp>
#include <fwData/TransfertFunction.hpp>
#include <fwData/Composite.hpp>
#include <fwServices/Base.hpp>
#include <fwServices/IEditionService.hpp>
#include <fwComEd/ImageMsg.hpp>
#include <fwComEd/Dictionary.hpp>
#include <fwComEd/fieldHelper/MedicalImageHelpers.hpp>
......@@ -130,6 +131,21 @@ void SSynchronizeWindowingTF::updateTFFromMinMax()
{
tfName = image->getFieldSingleElement< ::fwData::String >( fieldId );
}
// If TF doesn't exist : set default BW TF
// This case can occur if the TF is deleted by TF editor
if (tfCompo->find(tfName->value()) == tfCompo->end())
{
OSLM_WARN("TF '" << *tfName << "' doesn't exist => set BW TF");
::fwComEd::fieldHelper::MedicalImageHelpers::setBWTF(image, fieldId);
::fwComEd::ImageMsg::NewSptr msg;
msg->addEvent(::fwComEd::ImageMsg::TRANSFERTFUNCTION) ;
::fwServices::IEditionService::notify( this->getSptr(), image, msg );
tfName = image->getFieldSingleElement< ::fwData::String >( fieldId );
}
::fwData::TransfertFunction::sptr pTF = ::fwData::TransfertFunction::dynamicCast( (*tfCompo)[tfName->value()] );
::fwComEd::fieldHelper::MedicalImageHelpers::updateTFFromMinMax(min, max, pTF);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment