7 #include "ioITK/InrImageWriterService.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwData/Image.hpp> 12 #include <fwData/location/Folder.hpp> 13 #include <fwData/location/SingleFile.hpp> 15 #include <fwGui/Cursor.hpp> 16 #include <fwGui/dialog/LocationDialog.hpp> 17 #include <fwGui/dialog/MessageDialog.hpp> 18 #include <fwGui/dialog/ProgressDialog.hpp> 20 #include <fwIO/IWriter.hpp> 22 #include <fwItkIO/ImageWriter.hpp> 24 #include <fwServices/macros.hpp> 33 InrImageWriterService::InrImageWriterService() noexcept
39 InrImageWriterService::~InrImageWriterService() noexcept
62 static ::boost::filesystem::path _sDefaultPath;
67 dialogFile.
addFilter(
"Inrimage",
"*.inr.gz");
68 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::WRITE);
70 ::fwData::location::SingleFile::sptr result;
71 result = ::fwData::location::SingleFile::dynamicCast( dialogFile.
show() );
74 _sDefaultPath = result->getPath().parent_path();
75 this->
setFile( result->getPath() );
102 _sstream <<
"InrImageWriterService::info";
107 void InrImageWriterService::saveImage( const ::boost::filesystem::path& inrFile, const ::fwData::Image::csptr& image )
110 ::fwItkIO::ImageWriter::sptr myWriter = ::fwItkIO::ImageWriter::New();
112 myWriter->setObject(image);
113 myWriter->setFile(inrFile);
118 myWriter->addHandler( progressMeterGUI );
122 catch (
const std::exception& e)
124 std::stringstream ss;
125 ss <<
"Warning during saving : " << e.what();
128 ::fwGui::dialog::IMessageDialog::WARNING);
133 "Warning during saving",
134 ::fwGui::dialog::IMessageDialog::WARNING);
147 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(::fwIO::s_DATA_KEY);
151 image = this->getObject< ::fwData::Image >();
153 SLM_ASSERT(
"'" + ::fwIO::s_DATA_KEY +
"' key is not defined", image);
156 cursor.
setCursor(::fwGui::ICursor::BUSY);
157 saveImage(this->
getFile(), image);
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
virtual FWGUI_API void setCursor(::fwGui::ICursor::CursorType cursor) override
Set the cursor.
#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)
virtual IOITK_API void stopping() override
Override.
virtual IOITK_API void configureWithIHM() override
Override.
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:
virtual IOITK_API void starting() override
Override.
Defines the generic progress dialog for IHM. Use the Delegate design pattern. The specific implementa...
FWIO_API void setFile(const ::boost::filesystem::path &file)
Sets file path.
virtual FWIO_API void configuring() override
This method proposes to parse xml configuration to retrieve file/files/folder paths.
FWIO_APIconst::boost::filesystem::path & getFile() const
Returns the file path set by the user or set during service configuration.
IOITK_API void info(std::ostream &_sstream) override
Override.
FWIO_API void clearLocations()
Clear any location set by the setFile/setFiles/setFolder setter.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
IOITK_API void updating() override
Override.
IOPathType
IOPathType defines different type of paths used by service readers/writers.
Writer service API. It manages extension points definition and extension configuration.
FWGUI_API void setTitle(const std::string &title) override
Set the title for the dialog.
Defines the generic file/folder selector dialog for IHM.
Defines the generic cursor for IHM. Use the Delegate design pattern.
This class defines an image.
Writer for .inr.gz image.
FWGUI_API void saveDefaultLocation(::fwData::location::ILocation::sptr loc) override
Save the specified default location for the dialog in preferences (if available)
The namespace ioITK contains services for reader, writer and helper for itk image.
FWIO_API bool hasLocationDefined() const
Returns if a location has been defined ( by the configuration process or directly by user ) ...
virtual FWGUI_API void setDefaultCursor() override
Set the default cursor.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.
IOITK_API::fwIO::IOPathType getIOPathType() const override
Return managed file type, here FILE.
virtual IOITK_API void configuring() override
Override.