7 #include "uiMeasurement/action/RemoveLandmark.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwData/Image.hpp> 12 #include <fwData/Point.hpp> 13 #include <fwData/PointList.hpp> 14 #include <fwData/String.hpp> 15 #include <fwData/Vector.hpp> 17 #include <fwDataTools/fieldHelper/Image.hpp> 18 #include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp> 20 #include <fwGui/dialog/SelectorDialog.hpp> 22 #include <fwServices/macros.hpp> 24 #include <boost/lexical_cast.hpp> 36 static const ::fwServices::IService::KeyType s_IMAGE_INOUT =
"image";
40 RemoveLandmark::RemoveLandmark( ) noexcept
46 RemoveLandmark::~RemoveLandmark() noexcept
54 _sstream <<
"Action for remove landmark" << std::endl;
59 ::fwData::Point::sptr RemoveLandmark::getLandmarkToRemove(::fwData::Image::sptr image,
bool& removeAll)
61 ::fwData::Point::sptr landmarkToRemove;
66 SLM_ASSERT(
"No Field ImageLandmarks", landmarksBackup);
68 std::vector< std::string > selections;
69 selections.push_back(
"ALL");
70 std::map< std::string, ::fwData::Point::sptr > correspondance;
72 for(::fwData::Point::sptr landmark : landmarksBackup->getPoints())
77 selections.push_back( *name );
78 correspondance[ *name ] = landmark;
81 ::fwGui::dialog::SelectorDialog::sptr selector = ::fwGui::dialog::SelectorDialog::New();
82 selector->setTitle(
"Select a landmark to remove");
83 selector->setSelections(selections);
84 std::string selection = selector->show();
85 if( !selection.empty() )
87 if (selection ==
"ALL")
94 landmarkToRemove = correspondance[selection];
98 return landmarkToRemove;
103 void RemoveLandmark::notify( ::fwData::Image::sptr image, ::fwData::Point::sptr backup)
106 sig->asyncEmit(backup);
113 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
117 image = this->getObject< ::fwData::Image >();
124 if (!landmarks->getPoints().empty())
127 ::fwData::Point::sptr landmarkToRemove = this->getLandmarkToRemove(image, requestAll );
130 if ( landmarkToRemove )
133 ::fwData::PointList::PointListContainer::iterator itr;
134 itr = std::find( landmarks->getPoints().begin(), landmarks->getPoints().end(), landmarkToRemove );
135 if (itr != landmarks->getPoints().end())
137 landmarks->getPoints().erase(itr);
138 this->notify(image, landmarkToRemove);
145 this->notify(image, landmarkToRemove);
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
void configuring() override
Configure the service before starting. Apply the configuration to service.
The namespace uiMeasurement contains actions to add/show/remove distances and landmarks.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
Defines the service interface managing the menu items.
void info(std::ostream &_sstream) override
Write information in a stream.
void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWGUI_API void initialize()
Initialize the action.
void starting() override
Initialize the service activity.
This class defines a list of points.
This class defines an image.
This class contains an std::string value.
This action removes landmarks from an image.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_LANDMARK_REMOVED_SIG
Type of signal when image's buffer is added.