7 #include "ioITK/SJpgImageSeriesWriter.hpp" 9 #include "ioITK/JpgImageWriterService.hpp" 11 #include <fwCore/base.hpp> 13 #include <fwData/Image.hpp> 14 #include <fwData/location/Folder.hpp> 16 #include <fwGui/Cursor.hpp> 17 #include <fwGui/dialog/LocationDialog.hpp> 18 #include <fwGui/dialog/MessageDialog.hpp> 19 #include <fwGui/dialog/ProgressDialog.hpp> 21 #include <fwIO/IWriter.hpp> 23 #include <fwMedData/ImageSeries.hpp> 25 #include <fwServices/macros.hpp> 34 SJpgImageSeriesWriter::SJpgImageSeriesWriter() noexcept
40 SJpgImageSeriesWriter::~SJpgImageSeriesWriter() noexcept
48 return ::fwIO::FOLDER;
63 static ::boost::filesystem::path _sDefaultPath;
68 dialog.
setOption(::fwGui::dialog::ILocationDialog::WRITE);
69 dialog.
setType(::fwGui::dialog::ILocationDialog::FOLDER);
71 ::fwData::location::Folder::sptr result;
73 while (result = ::fwData::location::Folder::dynamicCast( dialog.
show() ))
75 if( ::boost::filesystem::is_empty(result->getFolder()) )
81 messageBox.
setTitle(
"Overwrite confirmation");
82 messageBox.
setMessage(
"The selected directory is not empty. Write anyway ?");
83 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::QUESTION);
84 messageBox.
addButton(::fwGui::dialog::IMessageDialog::YES);
85 messageBox.
addButton(::fwGui::dialog::IMessageDialog::CANCEL);
86 if( messageBox.
show() == ::fwGui::dialog::IMessageDialog::YES)
94 _sDefaultPath = result->getFolder().parent_path();
122 _sstream <<
"SJpgImageSeriesWriter::info";
134 ::fwMedData::ImageSeries::csptr imageSeries = this->getInput< ::fwMedData::ImageSeries >(::fwIO::s_DATA_KEY);
138 imageSeries = this->getObject< ::fwMedData::ImageSeries >();
140 SLM_ASSERT(
"Image series is not instanced", imageSeries);
141 SLM_ASSERT(
"Image from image series is not instanced", imageSeries->getImage());
144 cursor.
setCursor(::fwGui::ICursor::BUSY);
145 JpgImageWriterService::saveImage(this->
getFolder(), imageSeries->getImage());
146 cursor.setDefaultCursor();
#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.
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.
virtual FWGUI_API void setDefaultLocation(::fwData::location::ILocation::sptr loc) override
Set the initial location for the dialog.
virtual IOITK_API void stopping() override
Override.
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.
IOITK_API::fwIO::IOPathType getIOPathType() const override
Return managed file type, here FOLDER.
IOITK_API void info(std::ostream &_sstream) override
Override.
virtual IOITK_API void configuring() override
Override.
virtual FWGUI_API void addButton(IMessageDialog::Buttons button) override
Add a button (OK, YES_NO, YES, NO, CANCEL)
virtual FWGUI_API IMessageDialog::Buttons show() override
Show the message box and return the clicked button.
virtual IOITK_API void configureWithIHM() override
Override.
virtual FWIO_API void configuring() override
This method proposes to parse xml configuration to retrieve file/files/folder paths.
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) ...
FWIO_APIconst::boost::filesystem::path & getFolder() const
Returns folder path set by the user or set during service configuration.
virtual FWGUI_API void setIcon(IMessageDialog::Icons icon) override
Set the icon (CRITICAL, WARNING, INFO or QUESTION)
IOPathType
IOPathType defines different type of paths used by service readers/writers.
Write an image to jpg format.
virtual IOITK_API void starting() override
Override.
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.
FWIO_API void setFolder(const ::boost::filesystem::path &folder)
Sets folder path.
FWGUI_API void setType(::fwGui::dialog::ILocationDialog::Types type) override
Set the type of location for the dialog (SINGLE_FILE, FORLDER, MULTI_FILES)
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.
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the message box.
FWIO_API bool hasLocationDefined() const
Returns if a location has been defined ( by the configuration process or directly by user ) ...
IOITK_API void updating() override
Override.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.