7 #include "ioData/SAttachmentSeriesReader.hpp" 9 #include <fwData/location/Folder.hpp> 10 #include <fwData/location/SingleFile.hpp> 11 #include <fwData/mt/ObjectWriteLock.hpp> 13 #include <fwGui/dialog/LocationDialog.hpp> 15 #include <fwIO/IReader.hpp> 17 #include <fwMedData/AttachmentSeries.hpp> 18 #include <fwMedData/Equipment.hpp> 19 #include <fwMedData/Patient.hpp> 20 #include <fwMedData/SeriesDB.hpp> 21 #include <fwMedData/Study.hpp> 23 #include <fwMedDataTools/helper/SeriesDB.hpp> 25 #include <fwServices/macros.hpp> 27 #include <fwTools/dateAndTime.hpp> 28 #include <fwTools/UUID.hpp> 30 #include <boost/date_time/posix_time/posix_time.hpp> 31 #include <boost/filesystem/operations.hpp> 40 std::string getMediaType(const ::boost::filesystem::path& media)
42 std::string mediaType;
43 std::map<std::string, std::string> mimeMap =
45 {
".txt",
"text/plain"},
47 {
".pdf",
"application/pdf"},
48 {
".zip",
"application/zip"},
49 {
".mp3",
"audio/mpeg"},
50 {
".wav",
"audio/x-wav"},
51 {
".bmp",
"image/bmp"},
52 {
".jpeg",
"image/jpeg"},
53 {
".mpeg",
"video/mpeg"},
54 {
".mp4",
"video/mpeg"},
55 {
".avi",
"video/x-msvideo"}
57 const std::string extension = media.extension().string();
58 const auto iter = mimeMap.find(extension);
59 if(iter != mimeMap.end())
61 mediaType = iter->second;
68 void initSeries(::fwMedData::Series::sptr series,
const std::string& instanceUID)
70 const std::string unknown =
"unknown";
71 series->setModality(
"OT");
72 ::boost::posix_time::ptime now = ::boost::posix_time::second_clock::local_time();
73 const std::string date = ::fwTools::getDate(now);
74 const std::string time = ::fwTools::getTime(now);
75 series->setDate(date);
76 series->setTime(time);
80 series->getEquipment()->setInstitutionName(unknown);
82 series->getPatient()->setName(unknown);
83 series->getPatient()->setPatientId(unknown);
84 series->getPatient()->setBirthdate(unknown);
85 series->getPatient()->setSex(unknown);
87 series->getStudy()->setInstanceUID(instanceUID);
88 series->getStudy()->setDate(date);
89 series->getStudy()->setTime(time);
90 series->getStudy()->setReferringPhysicianName(unknown);
91 series->getStudy()->setDescription(unknown);
92 series->getStudy()->setPatientAge(unknown);
106 _sstream << std::endl <<
" AttachmentSerie reader";
113 std::vector< std::string > extensions;
114 extensions.push_back(
".*");
136 static ::boost::filesystem::path _sDefaultPath(
"");
141 dialogFile.
addFilter(
"Attachment file",
"*.*");
142 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
144 ::fwData::location::SingleFile::sptr result;
145 result = ::fwData::location::SingleFile::dynamicCast( dialogFile.
show() );
148 _sDefaultPath = result->getPath().parent_path();
150 this->
setFile(result->getPath());
165 ::fwMedData::SeriesDB::sptr seriesDB = this->getInOut< ::fwMedData::SeriesDB >(::fwIO::s_DATA_KEY);
167 ::fwMedData::AttachmentSeries::sptr series = ::fwMedData::AttachmentSeries::New();
169 initSeries(series, instanceUID);
170 series->setAttachmentPath(this->
getFile());
171 const std::string mediaType = getMediaType(this->
getFile());
172 series->setMediaType(mediaType);
177 seriesDBHelper.
add(series);
virtual IODATA_API void info(std::ostream &_sstream) override
Info method.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.
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.
virtual IODATA_API std::vector< std::string > getSupportedExtensions() override
Returns (filename) extension.
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:
FWIO_APIconst::boost::filesystem::path & getFile() const
Returns the file path set by the user or set during service configuration.
IODATA_API void configureWithIHM() override
Configure the attachment path.
SAttachmentSeries reader service.
FWIO_API void setFile(const ::boost::filesystem::path &file)
Sets file path.
Reader service API. It manages extension points definition and extension configuration.
IODATA_API void updating() override
Updating method. This method is called by update() from base service ( fwServices::IService ) ...
virtual IODATA_API void configuring() override
Configuring method : calls implementation from io::IReader
IODATA_API SAttachmentSeriesReader()
Constructor : does nothing.
IOPathType
IOPathType defines different type of paths used by service readers/writers.
virtual IODATA_API::fwIO::IOPathType getIOPathType() const override
Returns path type managed by the service, here FILE.
FWGUI_API void setTitle(const std::string &title) override
Set the title for the dialog.
Defines the generic file/folder selector dialog for IHM.
The namespace ioData contains reader and writer services for basic fwData::Object which doesn't need ...
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)
virtual FWSERVICES_API void info(std::ostream &_sstream)
Write information in a stream.