7 #include "uiMeasurement/action/SaveLandmark.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwData/location/Folder.hpp> 12 #include <fwData/location/SingleFile.hpp> 13 #include <fwData/Point.hpp> 14 #include <fwData/PointList.hpp> 15 #include <fwData/String.hpp> 17 #include <fwDataTools/fieldHelper/Image.hpp> 18 #include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp> 20 #include <fwGui/dialog/LocationDialog.hpp> 21 #include <fwGui/dialog/MessageDialog.hpp> 22 #include <fwGui/dialog/SelectorDialog.hpp> 24 #include <fwServices/IAppConfigManager.hpp> 25 #include <fwServices/macros.hpp> 26 #include <fwServices/registry/AppConfig.hpp> 27 #include <fwServices/registry/ServiceConfig.hpp> 41 SaveLandmark::SaveLandmark( ) noexcept
47 SaveLandmark::~SaveLandmark() noexcept
55 _sstream <<
"Action for save landmarks" << std::endl;
63 ::fwData::Image::sptr image = this->getObject< ::fwData::Image >();
68 "It is impossible to save image landmarks. There is no loaded image in the software.",
69 ::fwGui::dialog::IMessageDialog::WARNING);
72 static ::boost::filesystem::path _sDefaultPath(
"");
74 dialogFile.
setTitle(
"Choose a file to save landmarks");
76 dialogFile.
addFilter(
"Landmark file",
"*.json");
77 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::WRITE);
79 ::fwData::location::SingleFile::sptr result;
80 result = ::fwData::location::SingleFile::dynamicCast( dialogFile.
show() );
84 ::boost::filesystem::path path = result->getPath();
85 _sDefaultPath = path.parent_path();
116 void SaveLandmark::save(const ::boost::filesystem::path& path)
118 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(
"image");
126 replaceMap[
"landmark"] = landmarks->getID();
127 replaceMap[
"file"] = path.string();
129 ::fwRuntime::ConfigurationElement::csptr config =
131 getAdaptedTemplateConfig(
"SaveLandmark2", replaceMap,
true);
134 helper->setConfig( config );
136 helper->stopAndDestroy();
This action allows to save the landmarks stored in image.
void info(std::ostream &_sstream) override
Write information in a stream.
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
#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.
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.
Defines the service interface managing the menu items.
void starting() override
Initialize the service activity.
FWGUI_API void initialize()
Initialize the action.
This class defines a list of points.
static FWSERVICES_API std::shared_ptr< IAppConfigManager > New()
void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
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.
void configuring() override
Configure the service before starting. Apply the configuration to service.
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)
void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...