7 #include "ioITK/SInrSeriesDBReader.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwData/Image.hpp> 12 #include <fwData/location/Folder.hpp> 13 #include <fwData/location/MultiFiles.hpp> 14 #include <fwData/mt/ObjectWriteLock.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/IReader.hpp> 23 #include <fwItkIO/ImageReader.hpp> 25 #include <fwMedData/Equipment.hpp> 26 #include <fwMedData/ImageSeries.hpp> 27 #include <fwMedData/Patient.hpp> 28 #include <fwMedData/SeriesDB.hpp> 29 #include <fwMedData/Study.hpp> 31 #include <fwMedDataTools/helper/SeriesDB.hpp> 33 #include <fwServices/macros.hpp> 35 #include <fwTools/dateAndTime.hpp> 36 #include <fwTools/UUID.hpp> 38 #include <boost/date_time/posix_time/posix_time.hpp> 47 SInrSeriesDBReader::SInrSeriesDBReader() noexcept
53 SInrSeriesDBReader::~SInrSeriesDBReader() noexcept
76 static ::boost::filesystem::path _sDefaultPath;
81 dialogFile.
addFilter(
"Inrimage",
"*.inr.gz");
82 dialogFile.
setType(::fwGui::dialog::ILocationDialog::MULTI_FILES);
83 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
84 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::FILE_MUST_EXIST);
86 ::fwData::location::MultiFiles::sptr result;
87 result = ::fwData::location::MultiFiles::dynamicCast( dialogFile.
show() );
90 const ::fwData::location::ILocation::VectPathType paths = result->getPaths();
93 _sDefaultPath = paths[0].parent_path();
106 bool SInrSeriesDBReader::createImage( const ::boost::filesystem::path inrFile, ::fwData::Image::sptr image )
109 ::fwItkIO::ImageReader::sptr myLoader = ::fwItkIO::ImageReader::New();
112 myLoader->setObject(image);
113 myLoader->setFile(inrFile);
118 myLoader->addHandler( progressMeterGUI );
121 catch (
const std::exception& e)
123 std::stringstream ss;
124 ss <<
"Warning during loading : " << e.what();
127 ::fwGui::dialog::IMessageDialog::WARNING);
133 "Warning during loading",
134 ::fwGui::dialog::IMessageDialog::WARNING);
149 ::fwMedData::SeriesDB::sptr seriesDB = this->getInOut< ::fwMedData::SeriesDB >(::fwIO::s_DATA_KEY);
153 seriesDB = this->getObject< ::fwMedData::SeriesDB >();
155 SLM_ASSERT(
"SeriesDB not instanced", seriesDB);
157 ::fwMedData::SeriesDB::sptr localSeriesDB = ::fwMedData::SeriesDB::New();
160 cursor.
setCursor(::fwGui::ICursor::BUSY);
164 for(const ::boost::filesystem::path& path : this->
getFiles())
166 ::fwMedData::ImageSeries::sptr imgSeries = ::fwMedData::ImageSeries::New();
167 this->initSeries(imgSeries, instanceUID);
169 ::fwData::Image::sptr image = ::fwData::Image::New();
170 this->createImage( path, image );
171 imgSeries->setImage(image);
173 localSeriesDB->getContainer().push_back(imgSeries);
179 sDBhelper.
merge(localSeriesDB);
188 void SInrSeriesDBReader::initSeries(::fwMedData::Series::sptr series,
const std::string& instanceUID)
190 const std::string unknown =
"unknown";
191 series->setModality(
"OT");
192 ::boost::posix_time::ptime now = ::boost::posix_time::second_clock::local_time();
193 const std::string date = ::fwTools::getDate(now);
194 const std::string time = ::fwTools::getTime(now);
195 series->setDate(date);
196 series->setTime(time);
200 series->getEquipment()->setInstitutionName(unknown);
202 series->getPatient()->setName(unknown);
203 series->getPatient()->setPatientId(unknown);
204 series->getPatient()->setBirthdate(unknown);
205 series->getPatient()->setSex(unknown);
207 series->getStudy()->setInstanceUID(instanceUID);
208 series->getStudy()->setDate(date);
209 series->getStudy()->setTime(time);
210 series->getStudy()->setReferringPhysicianName(unknown);
211 series->getStudy()->setDescription(unknown);
212 series->getStudy()->setPatientAge(unknown);
virtual void configuring() override
Calls base class implementation.
#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.
virtual IOITK_API void updating() override
Reads inr files specified by user (configure or configureWithIHM) and pushes them into SeriesDB...
#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)
FWIO_API void setFiles(const ::fwIO::LocationsType &files)
Sets file paths.
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.
A helper to lock object on exclusive mode.
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
Returns managed file type, here FILES.
Reader service API. It manages extension points definition and extension configuration.
Reads inr files and pushes them into SeriesDB.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
virtual IOITK_API void configureWithIHM() override
Configure the inr files path.
FWIO_APIconst::fwIO::LocationsType & getFiles() const
Returns file paths set by the user or set during service configuration.
IOPathType
IOPathType defines different type of paths used by service readers/writers.
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.
FWGUI_API void setType(::fwGui::dialog::ILocationDialog::Types type) override
Set the type of location for the dialog (SINGLE_FILE, FORLDER, MULTI_FILES)
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.