7 #include "uiMeasurement/action/LoadLandmark.hpp" 9 #include <fwCom/Signal.hxx> 11 #include <fwCore/base.hpp> 13 #include <fwData/location/Folder.hpp> 14 #include <fwData/location/SingleFile.hpp> 15 #include <fwData/Point.hpp> 16 #include <fwData/PointList.hpp> 17 #include <fwData/String.hpp> 19 #include <fwDataTools/fieldHelper/Image.hpp> 20 #include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp> 22 #include <fwGui/dialog/LocationDialog.hpp> 23 #include <fwGui/dialog/MessageDialog.hpp> 25 #include <fwServices/IAppConfigManager.hpp> 26 #include <fwServices/macros.hpp> 27 #include <fwServices/registry/AppConfig.hpp> 28 #include <fwServices/registry/ServiceConfig.hpp> 42 LoadLandmark::LoadLandmark( ) noexcept
48 LoadLandmark::~LoadLandmark() noexcept
56 _sstream <<
"Action for load landmarks" << std::endl;
64 ::fwData::Image::sptr image = this->getObject< ::fwData::Image >();
69 "It is impossible to load image landmarks. There is no loaded image in the software.",
70 ::fwGui::dialog::IMessageDialog::WARNING);
73 static ::boost::filesystem::path _sDefaultPath(
"");
75 dialogFile.
setTitle(
"Choose a file to load landmarks");
77 dialogFile.
addFilter(
"Landmark file",
"*.json");
78 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
80 ::fwData::location::SingleFile::sptr result;
81 result = ::fwData::location::SingleFile::dynamicCast( dialogFile.
show() );
85 ::boost::filesystem::path path = result->getPath();
86 _sDefaultPath = path.parent_path();
93 sig->asyncEmit(::fwData::Point::sptr());
121 void LoadLandmark::load(const ::boost::filesystem::path& path)
123 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(
"image");
124 SLM_ASSERT(
"In-Out 'image' is not found.", image);
130 SLM_ASSERT(
"landmarks not instanced", landmarks);
132 ::fwData::PointList::sptr newLandmarks = ::fwData::PointList::New();
135 replaceMap[
"landmark"] = newLandmarks->getID();
136 replaceMap[
"file"] = path.string();
138 ::fwRuntime::ConfigurationElement::csptr config =
140 getAdaptedTemplateConfig(
"LoadLandmark2", replaceMap,
true);
143 helper->setConfig( config );
145 helper->stopAndDestroy();
147 for(::fwData::Point::sptr landmark : newLandmarks->getPoints())
149 landmarks->getPoints().push_back( landmark );
151 sig->asyncEmit(landmark);
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
void info(std::ostream &_sstream) override
Write information in a stream.
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.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
virtual FWGUI_API void setDefaultLocation(::fwData::location::ILocation::sptr loc) override
Set the initial location for the dialog.
FWGUI_API::fwGui::dialog::ILocationDialog & setOption(::fwGui::dialog::ILocationDialog::Options option) override
allow to set option to the file dialog mode=READ/WRITE, check=FILE_MUST_EXIST
FWGUI_API::fwData::location::ILocation::sptr show() override
Display the dialog.
FWGUI_API void addFilter(const std::string &filterName, const std::string &wildcardList) override
specify some filtering when browsing files:
#define FW_DEPRECATED_MSG(message, version)
Use this macro when deprecating a function to warn the developer.
void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
void starting() override
Initialize the service activity.
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.
This action allows to load landmarks from a file.
#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 configuring() override
Configure the service before starting. Apply the configuration to service.
void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...
This class defines a list of points.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
static FWSERVICES_API std::shared_ptr< IAppConfigManager > New()
FWGUI_API void setTitle(const std::string &title) override
Set the title for the dialog.
Defines the generic file/folder selector dialog for IHM.
static FWSERVICES_API AppConfig::sptr getDefault()
Return an instance of AppConfig.
static FWSERVICES_API std::string getUniqueIdentifier(const std::string &serviceUid="")
Create an unique identifier.
This class defines an image.
std::map< std::string, std::string > FieldAdaptorType
Associations of <pattern, value>.
FWGUI_API void saveDefaultLocation(::fwData::location::ILocation::sptr loc) override
Save the specified default location for the dialog in preferences (if available)