7 #include "ioITK/InrImageReaderService.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 12 #include <fwCore/base.hpp> 14 #include <fwData/Image.hpp> 15 #include <fwData/location/Folder.hpp> 16 #include <fwData/location/SingleFile.hpp> 18 #include <fwGui/Cursor.hpp> 19 #include <fwGui/dialog/LocationDialog.hpp> 20 #include <fwGui/dialog/MessageDialog.hpp> 21 #include <fwGui/dialog/ProgressDialog.hpp> 23 #include <fwIO/IReader.hpp> 25 #include <fwItkIO/ImageReader.hpp> 27 #include <fwServices/macros.hpp> 36 InrImageReaderService::InrImageReaderService() noexcept
42 InrImageReaderService::~InrImageReaderService() noexcept
65 static ::boost::filesystem::path _sDefaultPath;
70 dialogFile.
addFilter(
"Inrimage",
"*.inr.gz");
71 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
72 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::FILE_MUST_EXIST);
74 ::fwData::location::SingleFile::sptr result;
75 result = ::fwData::location::SingleFile::dynamicCast( dialogFile.
show() );
78 _sDefaultPath = result->getPath().parent_path();
79 this->
setFile(result->getPath());
92 _sstream <<
"InrImageReaderService::info";
97 bool InrImageReaderService::createImage( const ::boost::filesystem::path& inrFileDir,
98 const ::fwData::Image::sptr& _pImg )
101 ::fwItkIO::ImageReader::sptr myLoader = ::fwItkIO::ImageReader::New();
104 myLoader->setObject(_pImg);
105 myLoader->setFile(inrFileDir);
110 myLoader->addHandler( progressMeterGUI );
113 catch (
const std::exception& e)
115 std::stringstream ss;
116 ss <<
"Warning during loading : " << e.what();
119 ::fwGui::dialog::IMessageDialog::WARNING);
125 "Warning during loading",
126 ::fwGui::dialog::IMessageDialog::WARNING);
140 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(::fwIO::s_DATA_KEY);
144 image = this->getObject< ::fwData::Image >();
146 SLM_ASSERT(
"'" + ::fwIO::s_DATA_KEY +
"' key is not defined", image);
148 if ( this->createImage( this->
getFile(), image) )
151 cursor.
setCursor(::fwGui::ICursor::BUSY);
152 notificationOfDBUpdate();
160 void InrImageReaderService::notificationOfDBUpdate()
163 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(::fwIO::s_DATA_KEY);
167 image = this->getObject< ::fwData::Image >();
169 SLM_ASSERT(
"'" + ::fwIO::s_DATA_KEY +
"' key is not defined", 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.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.
Class allowing to block a Connection.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
FWIO_API bool hasLocationDefined() const
Returns if a location has been defined ( by the configuration process or directly by user ) ...
virtual FWIO_API void configuring() override
This method proposes to parse xml configuration to retrieve file/files/folder paths.
static FWGUI_API IMessageDialog::Buttons showMessageDialog(const std::string &title, const std::string &message,::fwGui::dialog::IMessageDialog::Icons icon=INFO)
virtual IOITK_API void updating() override
Override.
virtual FWGUI_API void setDefaultLocation(::fwData::location::ILocation::sptr loc) override
Set the initial location for the dialog.
Reader for .inr.gz image.
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:
Defines the generic progress dialog for IHM. Use the Delegate design pattern. The specific implementa...
IOITK_API::fwIO::IOPathType getIOPathType() const override
Return managed file type, here FILE.
FWIO_APIconst::boost::filesystem::path & getFile() const
Returns the file path set by the user or set during service configuration.
UpdateSlotType::sptr m_slotUpdate
Slot to call update method.
FWIO_API void setFile(const ::boost::filesystem::path &file)
Sets file path.
Reader service API. It manages extension points definition and extension configuration.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
IOITK_API void info(std::ostream &_sstream) override
Override.
IOPathType
IOPathType defines different type of paths used by service readers/writers.
virtual IOITK_API void configuring() override
Override.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
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.
virtual IOITK_API void configureWithIHM() override
Override.
FWIO_API void clearLocations()
Clear any location set by the setFile/setFiles/setFolder setter.
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 setDefaultCursor() override
Set the default cursor.