7 #include "uiMeasurement/action/AddLandmark.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 11 #include <fwCom/Signals.hpp> 13 #include <fwCore/base.hpp> 15 #include <fwData/Boolean.hpp> 16 #include <fwData/Point.hpp> 17 #include <fwData/PointList.hpp> 18 #include <fwData/String.hpp> 20 #include <fwDataTools/fieldHelper/Image.hpp> 21 #include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp> 23 #include <fwGui/dialog/InputDialog.hpp> 24 #include <fwGui/dialog/MessageDialog.hpp> 26 #include <fwServices/macros.hpp> 39 AddLandmark::AddLandmark( ) noexcept
45 AddLandmark::~AddLandmark() noexcept
53 _sstream <<
"Action for remove distance" << std::endl;
59 bool defineLabel(std::string& name)
63 name =
"Label" + ::boost::lexical_cast< std::string >(count );
65 ::fwData::String::sptr url = ::fwData::String::New();
68 inputDlg.
setMessage(
"Which label for the point?");
70 std::string inputText = inputDlg.
getInput();
72 if(!inputText.empty())
86 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(
"image");
92 "It is impossible to add image landmarks. There is no loaded image in the software.",
93 ::fwGui::dialog::IMessageDialog::WARNING);
98 if ( defineLabel(value) )
104 SLM_ASSERT(
"landmarks not instanced", landmarks);
109 std::transform( newPoint->getCoord().begin(), newPoint->getCoord().end(),
110 image->getSpacing().begin(),
111 newPoint->getCoord().begin(),
112 std::multiplies<double>() );
113 std::transform( newPoint->getCoord().begin(), newPoint->getCoord().end(),
114 image->getOrigin().begin(),
115 newPoint->getCoord().begin(),
116 std::plus<double>() );
118 landmarks->getPoints().push_back( newPoint );
121 ::fwData::String::sptr label = ::fwData::String::New();
122 label->value() = value;
125 image->setField(
"ShowLandmarks", ::fwData::Boolean::New(
true));
129 sig->asyncEmit(newPoint);
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
#define SLM_TRACE_FUNC()
Trace contextual function signature.
static FWGUI_API IMessageDialog::Buttons showMessageDialog(const std::string &title, const std::string &message,::fwGui::dialog::IMessageDialog::Icons icon=INFO)
The namespace uiMeasurement contains actions to add/show/remove distances and landmarks.
This action adds landmaks on image.
void starting() override
Initialize the service activity.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
UIMEASUREMENT_API void info(std::ostream &_sstream) override
Write information in a stream.
Defines the service interface managing the menu items.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_LANDMARK_ADDED_SIG
Type of signal when image's buffer is added.
#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.
This class defines a list of points.
void configuring() override
Configure the service before starting. Apply the configuration to service.
This class defines an image.
void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...