7 #include "uiMeasurement/action/AddDistance.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/Image.hpp> 17 #include <fwData/Point.hpp> 18 #include <fwData/PointList.hpp> 19 #include <fwData/Vector.hpp> 21 #include <fwDataTools/fieldHelper/Image.hpp> 23 #include <fwServices/macros.hpp> 34 static const ::fwServices::IService::KeyType s_IMAGE_INOUT =
"image";
38 AddDistance::AddDistance( ) noexcept
44 AddDistance::~AddDistance() noexcept
52 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
56 image = this->getObject< ::fwData::Image >();
60 SLM_WARN(
"The key '" + s_IMAGE_INOUT +
"' is not found.");
64 ::fwData::Point::sptr pt1 = ::fwData::Point::New();
65 std::copy( image->getOrigin().begin(), image->getOrigin().begin() +3, pt1->getCoord().begin() );
67 ::fwData::Point::sptr pt2 = ::fwData::Point::New();
68 std::copy( image->getSize().begin(), image->getSize().begin() +3, pt2->getCoord().begin() );
70 std::transform( pt2->getCoord().begin(), pt2->getCoord().end(),
71 image->getSpacing().begin(),
72 pt2->getCoord().begin(),
73 std::multiplies<double>() );
74 std::transform( pt2->getCoord().begin(), pt2->getCoord().end(),
75 image->getOrigin().begin(),
76 pt2->getCoord().begin(),
77 std::plus<double>() );
79 ::fwData::PointList::sptr pl = ::fwData::PointList::New();
81 pl->getPoints().push_back( pt1 );
82 pl->getPoints().push_back( pt2 );
84 ::fwData::Vector::sptr vectDist;
87 vectDist->getContainer().push_back(pl);
90 image->setField(
"ShowDistances", ::fwData::Boolean::New(
true));
void configuring() override
Configure the service before starting. Apply the configuration to service.
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
The namespace uiMeasurement contains actions to add/show/remove distances and landmarks.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...
void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
#define SLM_WARN(message)
Defines the service interface managing the menu items.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_DISTANCE_ADDED_SIG
Type of signal when image's buffer is added.
FWGUI_API void initialize()
Initialize the action.
This action adds distances on an image field.
This class defines an image.
void starting() override
Initialize the service activity.