7 #include "uiMeasurement/action/SFocusLandmark.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 11 #include <fwCom/Signals.hpp> 12 #include <fwCom/Slot.hpp> 13 #include <fwCom/Slot.hxx> 14 #include <fwCom/Slots.hpp> 15 #include <fwCom/Slots.hxx> 17 #include <fwCore/base.hpp> 19 #include <fwData/Image.hpp> 20 #include <fwData/Integer.hpp> 21 #include <fwData/Landmarks.hpp> 23 #include <fwDataTools/fieldHelper/Image.hpp> 24 #include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp> 26 #include <fwGui/dialog/MessageDialog.hpp> 28 #include <fwServices/macros.hpp> 35 static const ::fwServices::IService::KeyType s_LANDMARKS_INPUT =
"landmarks";
36 static const ::fwServices::IService::KeyType s_IMAGE_INOUT =
"image";
38 static const ::fwCom::Slots::SlotKeyType s_SELECT_LANDMARK_SLOT =
"selectLandmark";
39 static const ::fwCom::Slots::SlotKeyType s_DESELECT_LANDMARK_SLOT =
"deselectLandmark";
40 static const ::fwCom::Slots::SlotKeyType s_DESELECT_FROM_GROUP_SLOT =
"deselectFromGroup";
41 static const ::fwCom::Slots::SlotKeyType s_RENAME_GROUP_SLOT =
"renameGroup";
47 SFocusLandmark::SFocusLandmark( ) noexcept :
51 newSlot(s_SELECT_LANDMARK_SLOT, &SFocusLandmark::selectLandmark,
this);
52 newSlot(s_DESELECT_LANDMARK_SLOT, &SFocusLandmark::deselectLandmark,
this);
53 newSlot(s_DESELECT_FROM_GROUP_SLOT, &SFocusLandmark::deselectFromGroup,
this);
54 newSlot(s_RENAME_GROUP_SLOT, &SFocusLandmark::renameGroup,
this);
59 SFocusLandmark::~SFocusLandmark() noexcept
91 ::fwData::Image::sptr pImage = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
95 messageBox.
setTitle(
"Add landmarks");
97 "It is impossible to add image landmarks. There is no loaded image in the software." );
98 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::WARNING);
99 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
105 ::fwData::Landmarks::csptr landmarks = this->getInput< ::fwData::Landmarks >(s_LANDMARKS_INPUT);
109 const ::fwData::Landmarks::PointType&
point = landmarks->getPoint(m_groupName, m_index);
111 ::fwData::Integer::sptr paramA = ::fwData::Integer::New();
113 static_cast<int>((point[2] - pImage->getOrigin()[2] ) / pImage->getSpacing()[2] +0.5);
114 ::fwData::Integer::sptr paramF = ::fwData::Integer::New();
116 static_cast<int>((point[1] - pImage->getOrigin()[1]) / pImage->getSpacing()[1] +0.5);
117 ::fwData::Integer::sptr paramS = ::fwData::Integer::New();
119 static_cast<int>((point[0] - pImage->getOrigin()[0]) / pImage->getSpacing()[0] +0.5);
120 if( paramS->value() >= 0 &&
121 paramF->value() >= 0 &&
122 paramA->value() >= 0 &&
123 pImage->getSize()[0] >
static_cast< ::fwData::Image::SizeType::value_type
>(paramS->value()) &&
124 pImage->getSize()[1] >
static_cast< ::fwData::Image::SizeType::value_type
>(paramF->value()) &&
125 pImage->getSize()[2] >
static_cast< ::fwData::Image::SizeType::value_type
>(paramA->value()) )
134 sig->asyncEmit(paramA->value(), paramF->value(), paramS->value());
139 "It is impossible to focus image landmarks: " 140 "landmark is outside image.",
141 ::fwGui::dialog::IMessageDialog::WARNING);
147 "It is impossible to focus image landmarks: " 148 + std::string(e.what()),
149 ::fwGui::dialog::IMessageDialog::WARNING);
158 void SFocusLandmark::selectLandmark(std::string groupName,
size_t index)
160 m_groupName = groupName;
168 void SFocusLandmark::deselectLandmark(std::string groupName,
size_t index)
170 if (m_groupName == groupName && m_index == index)
174 m_isSelected =
false;
181 void SFocusLandmark::deselectFromGroup(std::string groupName)
183 if (m_groupName == groupName)
187 m_isSelected =
false;
194 void SFocusLandmark::renameGroup(std::string oldGroupName, std::string newGroupName)
196 if (m_groupName == oldGroupName)
198 m_groupName = newGroupName;
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_SLICE_INDEX_MODIFIED_SIG
Type of signal when image's buffer is added.
This class is a helper to define the connections of a service and its data.
virtual FWGUI_API void setIsExecutable(bool isExecutable)
Set the action service executable or not.
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
This action moves the image slice on selected landmark.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_DESELECTED_SIG
Type of signal when a group is added.
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
Defines the generic message box for IHM. Use the Delegate design pattern.
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.
Implements data exception class.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_REMOVED_SIG
Type of signal when a group is added.
Defines the service interface managing the menu items.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_SELECTED_SIG
Type of signal when a group is added.
UIMEASUREMENT_API void configuring() override
Do nothing.
UIMEASUREMENT_API void starting() override
Do nothing.
virtual FWGUI_API void addButton(IMessageDialog::Buttons button) override
Add a button (OK, YES_NO, YES, NO, CANCEL)
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_RENAMED_SIG
Type of signal when a group is added.
virtual FWGUI_API IMessageDialog::Buttons show() override
Show the message box and return the clicked button.
FWGUI_API void initialize()
Initialize the action.
UIMEASUREMENT_API void stopping() override
Do nothing.
virtual FWGUI_API void setIcon(IMessageDialog::Icons icon) override
Set the icon (CRITICAL, WARNING, INFO or QUESTION)
UIMEASUREMENT_API void updating() override
Focus the image slices on the selected landmark.
UIMEASUREMENT_API KeyConnectionsMap getAutoConnections() const override
Defines connection to Landmarks data.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_REMOVED_SIG
Type of signal when a group is added.
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the message box.